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):
codePASS 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:codeError: 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 paths from the spec (5 paths) and added a stub schema so residual targets resolved. Regenerated successfully.
- Assistant
Now let me look at the remaining consumers of the schema (
visionRenderData,renderMCPToolFiles,SearchableFields) and the test templates: - Assistant
Now let me check the existing schema_builder test helpers and the top of the test file:
- Assistant
2.
generator.go— dependent-parent interplay, template funcs: - Assistant
3.
store.go.tmpl— creation gate, JSON-only upsert code, batch dispatch: - Assistant
Now the UpsertBatch dispatch:
- Assistant
4.
sync.go.tmpl— single-object dispatch (the config-singleton path that triggered the bug): - Assistant
6. Unit tests. First look at an existing fixture for the spec shape:
- Assistant
7. Generator-level compile-and-migrate test — insert after the reserved-word test:
- Assistant
Now build and run the schema builder tests:
- Assistant
Now the full generator compile test (this renders and compiles a generated CLI):
- Assistant
Same 16 failures on the clean tree — they're pre-existing environmental issues, not from my change. Let me confirm the failure sets are identical:
- Assistant
Byte-identical golden output — my change is neutral for all existing fixtures. Now run the full test suite:
- Assistant
While that runs, let me check the
sharesnapshot allowlist mentioned at generator.go:1680, in case it enumerates tables: - Assistant
While that runs, check for any other template consumers of table columns/FTS beyond the ones already handled:
- Assistant
While waiting on the suite, strengthen the generator test to pin that the generated store test file actually contains the JSON-only regression test:
- Assistant
All environmental (
fork/exec ... resource temporarily unavailable). Rerun the failed packages serially with bounded parallelism: - Assistant
The concurrent
-shortbackground run is competing for the same process limits. Wait for it to finish first: - Assistant
While waiting, let me record the environment quirks discovered this session:
- Assistant
While the suite runs, review the full diff:
- Assistant
Still resource exhaustion. Run each failing package alone, fully serialized:
- Assistant
Pre-existing toolchain issue. Now the key full-mode compile tests for the templates I touched, serially with nothing else running:
- Assistant
All green. Let me update the memory file with the govulncheck detail discovered:
- Assistant
Final review of the complete diff:
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.