generator: typed-table emit exceeds SQLite column cap on wide config singletons Filed by…
- User
generator: typed-table emit exceeds SQLite column cap on wide config singletons
Filed by
/printing-press-retrofrom a run of HaloPSA (scorecard 91/100 Grade A, 100% verify pass).Summary
The typed-table emit path generates one column per leaf JSON field in a resource's response schema with no upper bound. On HaloPSA's tenant-global
/Controlconfig singleton, this produced a 3,747-columnCREATE TABLEthat exceeded SQLite's defaultSQLITE_MAX_COLUMN=2000. Generation passed every quality gate;sync --full --dry-rundied cold withSQL logic error: too many columns on control (1). The failure mode is silent until first sync.Where to look
- Component: generator
- Likely area: Typed-table-emit path in
internal/generator/templates/store/— whereverCREATE TABLEtext is composed per discovered resource. - Triggered when: A spec resource's response schema flattens to >~1500 leaf fields. Enterprise config singletons are the obvious class.
What we observed
Run-1 output (post-generate):
PASS go mod tidy / govulncheck / go vet / go build PASS halopsa-pp-cli --help / version / doctor Generated halopsa at .../working/halopsa-pp-cliFirst
sync --full --dry-run:Error: opening local database: running migrations: migration failed: SQL logic error: too many columns on control (1)Per-table column counts (top 5 widest, recorded by Python introspection of
internal/store/store.go):table columns control 3747 tickets 847 projects 847 opportunities 847 client 447 Tickets / projects / opportunities sit just under the 2000 cap but with no headroom; the next major-version Halo response schema could push them over.
Workaround applied this run: hand-stripped
/Control*paths from the spec (5 paths) and added a stubControlschema so residual$reftargets resolved. Regenerated successfully.Suspected root cause
Confident. The typed-table-emit path walks the resource's response schema and emits one column per leaf field with no width sanity check. The store package has no JSON-only fallback for resources whose schema exceeds a safe column count.
- Assistant
I’ll trace the store-generation model and its tests first, then implement the 1,500-column dispatch and run formatting, focused tests, the full suite, and golden verification if generated output is affected.
- Assistant
rgis unavailable in this checkout, so I’m usingfind/grepfor the same repository inspection. - Assistant
The key distinction is now clear: ordinary three-column low-gravity resources intentionally have no domain table, while a capped resource must keep a three-column domain table and receive writes. I’m adding an explicit JSON-only table state so it cannot accidentally inherit typed indexes, FTS, migrations, or typed dispatch.
- Assistant
The cap logic and generator-level regression coverage are in place. The focused test is now compiling a generated wide CLI and opening its SQLite store, which directly exercises the original first-sync failure path.
- Assistant
The focused regression passes, including a real migration plus batch write into the three-column fallback table. I’m now checking the broader generator suite for unintended template changes before running repository-wide verification.
- Assistant
The repository-wide test run is proceeding with constrained Go parallelism; the unconstrained suite exhausts this container’s process limit because many generator tests compile printed CLIs concurrently. Golden verification is separately blocked because the required local
jqbinary is absent. - Assistant
So far, the constrained full suite is green across the CLI and supporting packages and is currently in the generator package—the slowest portion because it repeatedly builds generated projects.
- Assistant
The full run found at least one generator-package failure, but the test harness emitted enough expected warning output to truncate the actual failing test name. I’m rerunning that package with output filtered to failure diagnostics so I can distinguish a real regression from an environment-only gate.
- Assistant
The filtered rerun is still working through generated-project compilations and has not emitted a failure yet. The focused wide-table tests remain green; this pass is solely isolating the broader suite’s failing case.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.