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
Let me look at how the schema is used elsewhere — the upsert batch test template, sync template, and MCP tool files:
- Assistant
Let me check the remaining consumers of
Tables/schema: - Assistant
Now let me check for any other template ranging over table
.Columns: - Assistant
Now add the cap constant and enforcement function after
baseTableColumns: - Assistant
Now wire it into
schemaWithDependentParentsand updatehasTypedTable: - Assistant
Now add the unit tests:
- Assistant
Now the end-to-end generator test. Let me add it after
TestGenerateStoreMigrateUsesBeginImmediate: - Assistant
Now let me verify the acceptance criterion end-to-end: generate a wide-spec CLI, build it, and run its store tests against a real SQLite DB. I'll use a throwaway program:
- Assistant
Now run the full checks — fmt, tests, golden verify:
- Assistant
Let me check whether these failures are related to my change or pre-existing:
- Assistant
Passes in isolation — the earlier failures were sandbox process-limit contention (those tests spawn subprocesses). Re-run those packages serially:
- Assistant
Those failures pre-exist on the clean tree — they're environmental (subprocess-heavy tests hitting the sandbox's process limits), not caused by my change. Now the generator package and golden suite:
- Assistant
Pre-existing toolchain issue. Now run the golden suite — my change touches generated-CLI emission:
- Assistant
Identical failure sets — my change introduces zero golden diffs. Final checks: lint and formatting on the touched files:
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.