ISSUE DESCRIPTION generator: typed-table emit exceeds SQLite column cap on wide config…
- User
ISSUE DESCRIPTION
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
Assistant
Let me look at how existing tests exercise BuildSchema and store rendering.
Assistant
Now let me make the changes. First,
schema_builder.go:Assistant
I dropped the
return schemastatement. Fix:Assistant
Now edit the template. First the CREATE TABLE gate:
Assistant
Now update the UpsertBatch section —
$hasTypedcomputation and dispatch:Assistant
The
{{- end}}closing the range got consumed. Restore it:Assistant
Now build a reproduction/verification harness. Let me see how existing tests render templates end-to-end:
Assistant
Now create a temporary reproduction test (to be removed before submit):
Assistant
First, reproduce the original bug by stashing the fix (temp test is untracked so it stays):
Assistant
Bug reproduced exactly as in the issue. Now restore the fix and verify:
Assistant
All pass. Now run the existing test suites — first quick (
-short), then the full store-related tests:Assistant
This looks environmental (stdlib vuln in the installed toolchain go1.26.4, fixed in 1.26.5). Confirm it fails on the pristine tree:
Assistant
Only the pre-existing failure. Now run the full (non-short) store-related compile tests:
Assistant
While that runs, check other packages that consume the schema (profiler mentioned "SubResourceShardedNames"; pipeline):
Assistant
Only diff is a 3-line doc comment. To keep narrow-spec output fully byte-identical, gate those comment lines on
$hasJSONOnly(which is defined at template top-level earlier):Assistant
Run
go vetand gofmt on the changed Go files:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.