Skip to content

Run the account commands on SQLite on the run's one database handle - #69

Merged
SirLouen merged 26 commits into
mainfrom
feat/68-auth-sqlite
Oct 12, 2026
Merged

SirLouen merged 26 commits into
mainfrom
feat/68-auth-sqlite

Conversation

@SirLouen

@SirLouen SirLouen commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Closes #68

What

  • A new module, gonsole/auth/sqlite. Stores builds gouncer's SQLite account store and a SQLite record store on the run's one handle, for auth.Config.Stores. The run owns that handle, so there is nothing to release.
  • Migration and RecordMigration are the two schema steps on that handle, the accounts first, then the records. Each takes the file's migration lock for its own run, with MigrateOptions from the program's own settings.
  • The records live in gonsole_records with their own version table, gonsole_goose_db_version. Times are UTC microseconds, and the arguments and flags must be valid JSON.
  • The record store passes recordstest. A busy, locked or constraint failure carries dbkit's error class.
  • The module's lint refuses any SQLite driver, sql.Open, dbkit/sqlite.Open and sqlitetest outside the tests. gonsole/auth's own lint now allows only the gouncer packages it imports.

Why

Downstream applications need the account commands, Authorize, Record and account:records in the one SQLite file that holds the rest of their data, on the one handle a run opens.

Testing Instructions

Run the testing toolchain in gonsole/auth/sqlite. It needs no database server. The tests run every account command through a program whose opener counts one open per run, refuse the accounts Authorize must refuse, and show that a record behind a busy file waits no longer than the busy timeout.

Summary by CodeRabbit

  • New Features
    • Added SQLite support for authentication accounts and command records, using the program’s existing database connection.
    • Added SQLite database migrations for account and record storage.
    • Updated authentication documentation to describe support for PostgreSQL and SQLite.
  • Bug Fixes
    • Improved error reporting for SQLite record storage, including duplicate records and database operation failures.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 7e5ce69c-b7ef-4453-b6a6-3cdff4d59ff4

📥 Commits

Reviewing files that changed from the base of the PR and between 9763073 and c538cc5.


📒 Files selected for processing (11)
  • gonsole/auth/sqlite/authorize_test.go
  • gonsole/auth/sqlite/busy_test.go
  • gonsole/auth/sqlite/commands_test.go
  • gonsole/auth/sqlite/failures_test.go
  • gonsole/auth/sqlite/helpers_test.go
  • gonsole/auth/sqlite/lock_test.go
  • gonsole/auth/sqlite/program_test.go
  • gonsole/auth/sqlite/record_test.go
  • gonsole/auth/sqlite/records_test.go
  • gonsole/auth/sqlite/schema_test.go
  • gonsole/auth/sqlite/stores_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

The pull request adds a nested gonsole/auth/sqlite module. It provides SQLite account and command-record stores using the database handle supplied by gonsole, along with schema migrations and tests. The pull request also updates package descriptions and CI coverage.

Changes

SQLite authentication

Layer / File(s) Summary
SQLite schema and migrations
gonsole/auth/sqlite/schema.go, gonsole/auth/sqlite/migrations/*, gonsole/auth/sqlite/schema_test.go, gonsole/auth/sqlite/lock_test.go, gonsole/auth/sqlite/numbers_test.go, gonsole/auth/sqlite/schema_internal_test.go
Adds account and record migration steps with lock options. The records migration creates gonsole_records, its dedicated version table, and a descending timestamp index. Tests cover migration order, locking, schema constraints, and migration numbering.
SQLite command-record store
gonsole/auth/sqlite/records.go, gonsole/auth/sqlite/contract_test.go, gonsole/auth/sqlite/records_test.go, gonsole/auth/sqlite/failures_test.go, gonsole/auth/sqlite/busy_test.go, gonsole/auth/sqlite/export_test.go
Adds record insertion and listing with JSON arguments and flags, timestamps, and action-labeled database errors. Tests cover the shared record-store contract, error classification, timeouts, and malformed records.
Single-handle stores and account commands
gonsole/auth/sqlite/stores.go, gonsole/auth/sqlite/program_test.go, gonsole/auth/sqlite/stores_test.go, gonsole/auth/sqlite/commands_test.go, gonsole/auth/sqlite/authorize_test.go, gonsole/auth/sqlite/record_test.go, gonsole/auth/sqlite/helpers_test.go
Adds Stores to build account and record stores from gonsole.Call.DB. Tests cover store construction, account commands, authorization, and record output.
Module checks and documentation
gonsole/auth/sqlite/go.mod, gonsole/auth/sqlite/.golangci.yml, .github/workflows/ci.yml, README.md, gonsole/auth/.golangci.yml, gonsole/auth/doc.go, gonsole/auth/sqlite/doc.go, gonsole/auth/sqlite/CHANGELOG.md, gonsole/auth/sqlite/libc_test.go
Adds module dependency and lint configuration, includes the module in CI test, vet, lint, and vulnerability-check jobs, and updates package and README descriptions. The module changelog records its additions and error behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant GonsoleCall as gonsole.Call
  participant SQLiteStores as sqlite.Stores
  participant Database as SQLite database handle
  participant AuthStores as auth.Stores
  GonsoleCall->>SQLiteStores: Provide Call
  SQLiteStores->>GonsoleCall: Request call.DB(ctx)
  GonsoleCall->>Database: Return shared database handle
  Database-->>SQLiteStores: Provide handle
  SQLiteStores->>AuthStores: Build account and record stores
  AuthStores-->>GonsoleCall: Return stores with no release function
Loading

Merge Risk: ⚪ Minimal · up to c538c

No actionable merge-blocking issue is established; the change is ready for normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 55.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 60 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes the main change: adding SQLite support for account commands while using the run's single database handle.
Linked Issues check Passed Issue #68 is directly linked and has coding requirements. gonsole/auth/sqlite.Stores uses call.DB(ctx) and returns both stores without opening or releasing a handle. Migration and `RecordMigrati…
Out of Scope Changes check Passed The changes stay within issue #68. Production code adds the requested SQLite stores and schema steps. Tests verify the requested behavior. CI, lint configuration, package documentation, README text, a…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

codescene-access[bot]

This comment was marked as outdated.

@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High impact] The changes since the previous review address the timestamp test's 32-bit overflow. There are no outstanding findings blocking merge.

Summary

Adds gonsole/auth/sqlite so account commands and command records use the run's existing SQLite handle.

  • SQLite account commands and records use the run's one database handle.

No new issues were found in the changes since the previous review.

Reviews (3) · Last reviewed commit: "test(gonsole/auth/sqlite): read the stor..." · Reviewed by Greptile

codescene-access[bot]

This comment was marked as outdated.

Comment thread gonsole/auth/sqlite/records_test.go Outdated

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates Passed
4 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@SirLouen
SirLouen merged commit 132c232 into main Oct 12, 2026
38 checks passed
@SirLouen
SirLouen deleted the feat/68-auth-sqlite branch October 12, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run the account commands on SQLite on the run's one database handle

1 participant