Skip to content

feat(m6.7): Go reins CLI over a reflected SQLite database - #26

Merged
shamspias merged 1 commit into
mainfrom
build/m6.7-go-cli
Jul 5, 2026
Merged

feat(m6.7): Go reins CLI over a reflected SQLite database#26
shamspias merged 1 commit into
mainfrom
build/m6.7-go-cli

Conversation

@shamspias

Copy link
Copy Markdown
Owner

Closes the last user-facing gap in the Go port: a zero-code path. Go has no SQLAlchemy-automap, so instead of hand-written models the CLI reflects a live database through its own schema.

  • orm/sqlreflect.go: ReflectSQLite reads a live SQLite schema via PRAGMA into the same ORM-neutral ModelInfo the GORM path uses, so it flows straight through the existing BuildCapabilities (intent names, natural-key lookups, linting, trimming, schema index). SQLBackend runs the six ops as portable, parameterized SQL with validated + double-quoted identifiers (§2.6 — treat every name as untrusted); FromSQL wires reflect → capabilities. database/sql keeps the orm package driver-free.
  • cli/cli.go: Inspect / Ask / Chat as plain functions taking an io.Writer and a reins.Model, so they test with a FakeModel and no network. ask/chat build a READ_ONLY agent (writes aren't even generated); inspect --write reveals the gated create/update/delete. OpenDB accepts ./app.db, :memory:, sqlite:/// URLs, and file: URIs.
  • cmd/reins/main.go: the thin entrypoint — inspect/ask/chat/version, --model (provider:model) or env auto-detect, --write. The pure-Go glebarez/go-sqlite driver ships with the CLI (core stays driver-free; it is the driver GORM already pulls in, so no double-registration).
  • version.go: Version const (0.1.0a1) matching the Python package, so reins version reports the same string across languages.
  • README: Go section (install, inspect/ask/chat, in-code Define/NewAgent/Ask) and the roadmap now records Go as a working alpha that passes the shared conformance suite.

Verified: make go-check green (gofmt, vet, all tests — reflect round-trips, linted generated caps, read-only omits writes, injection-rejecting identifier quoting, FakeModel-driven ask/chat, hinted errors) and a built binary smoke-tested against a real SQLite file (reflected a table, chose the unique non-pk column as the natural key, gated writes behind --write).

Closes the last user-facing gap in the Go port: a zero-code path. Go has no
SQLAlchemy-automap, so instead of hand-written models the CLI reflects a live
database through its own schema.

- orm/sqlreflect.go: ReflectSQLite reads a live SQLite schema via PRAGMA into the
  same ORM-neutral ModelInfo the GORM path uses, so it flows straight through the
  existing BuildCapabilities (intent names, natural-key lookups, linting, trimming,
  schema index). SQLBackend runs the six ops as portable, parameterized SQL with
  validated + double-quoted identifiers (§2.6 — treat every name as untrusted);
  FromSQL wires reflect → capabilities. database/sql keeps the orm package
  driver-free.
- cli/cli.go: Inspect / Ask / Chat as plain functions taking an io.Writer and a
  reins.Model, so they test with a FakeModel and no network. ask/chat build a
  READ_ONLY agent (writes aren't even generated); inspect --write reveals the gated
  create/update/delete. OpenDB accepts ./app.db, :memory:, sqlite:/// URLs, and
  file: URIs.
- cmd/reins/main.go: the thin entrypoint — inspect/ask/chat/version, --model
  (provider:model) or env auto-detect, --write. The pure-Go glebarez/go-sqlite
  driver ships with the CLI (core stays driver-free; it is the driver GORM already
  pulls in, so no double-registration).
- version.go: Version const (0.1.0a1) matching the Python package, so
  `reins version` reports the same string across languages.
- README: Go section (install, inspect/ask/chat, in-code Define/NewAgent/Ask) and
  the roadmap now records Go as a working alpha that passes the shared conformance
  suite.

Verified: make go-check green (gofmt, vet, all tests — reflect round-trips, linted
generated caps, read-only omits writes, injection-rejecting identifier quoting,
FakeModel-driven ask/chat, hinted errors) and a built binary smoke-tested against a
real SQLite file (reflected a table, chose the unique non-pk column as the natural
key, gated writes behind --write).
@shamspias
shamspias merged commit aafc00c into main Jul 5, 2026
2 checks passed
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.

1 participant