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):
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.
- Assistant
I'll start by exploring the repository structure and locating the typed-table emit path that builds
CREATE TABLEstatements. - Assistant
Next I’ll inspect the store generator templates and related Go code for where columns are emitted.
- Assistant
I'll inspect
store.go.tmplandschema_builder.gofor how typed columns and CREATE TABLE are produced. - Assistant
rg is not available, let me use grep.
- Assistant
Reading
schema_builder.goto see how table columns are composed. - Assistant
Let me continue reading the file.
- Assistant
I'll inspect sub-resource table building and how upserts are generated for typed tables.
- Assistant
I'll look at dependent-parent tables, the typed-table gate, and related store template logic.
- Assistant
Checking low-gravity tables and UpsertBatch behavior for JSON-only resources.
- Assistant
I'll search the codebase and docs for any existing column-cap or JSON-only handling.
- Assistant
Checking how the generator logs and how schema tests are structured.
- Assistant
There's an interesting subtlety with hasTypedTable. If I reset to 3 columns for wide tables, hasTypedTable becomes false, so no table is created. I see the subtlety you spotted with
hasTypedTable—resetting the column count to 3 for wide tables would makehasTypedTablereturn false, which would skip table creation entirely. - Assistant
I'll check other hasTypedTable consumers and related tests that might need updating.
- Assistant
Let me check ListIDs and Status for domain tables and the upsert batch test - with JSONOnly, creatingQueues domain tables dmthat get tapped by UpsertBatch is good.
- Assistant
I'll confirm where schema building is invoked and then implement the column-cap fallback.
- Assistant
Implementing the column-cap fallback: update
TableDef, apply the cap after dependent parents are added, and adjusthasTypedTable. - Assistant
Let me implement the changes now.
- Assistant
I'll update
TableDefand add the column-cap helper inschema_builder.go. - Assistant
Updating
schemaWithDependentParentsand addingapplyTypedColumnCap. - Assistant
Next I’ll wire
applyTypedColumnCapintoBuildSchemaandadd the helper implementation. - Assistant
Updating BuildSchema's return path and adding the column-cap helper.
- Assistant
The previous edit left the file corrupted around
sync_state; fixing that section now. - Assistant
I need to fix the broken section from lines 179-213.
- Assistant
Updating
hasTypedTableso JSON-only fallback tables still get domain table creation and UpsertBatch dispatch. - Assistant
Fixing the broken
pathContainsParamfunction definition. - Assistant
I'll verify the packages compile, then add a temporary reproduction script to validate wide vs narrow behavior.
- Assistant
Need to set GOPATH/GOMODCACHE
- Assistant
Writing a temporary script to verify the acceptance criteria for wide and narrow resources.
- Assistant
I need to check the actual
ResourceandEndpointstruct definitions. - Assistant
I'll fix the test to match the real struct field names and types.
- Assistant
Removing the added test file per the "don't add tests" rule, then validating end-to-end generation with a temp script.
- Assistant
I'll create a temporary test file, run it to verify generation, then remove it.
- Assistant
Store wasn't generated — I'll check how
VisionSetandNewenable store generation. - Assistant
Updating the temporary test to set
VisionSet.Store = true. - Assistant
I'll hard-test generated store open/migrate against an empty DB for the wide resource.
- Assistant
I'll extend the temporary test to open and migrate the generated store DB.
- Assistant
I'll rewrite the end-to-end check as a cleaner temporary script.
- Assistant
I'll have the reuse test run
go mod tidyin the generated output before building. - Assistant
I'll open the temporary test file and apply the tidy step correctly.
- Assistant
Let me edit to add go mod tidy
- Assistant
Run the test again.
- Assistant
All acceptance checks passed. Removing the temporary test file and running the existing related generator tests.
- Assistant
I'll review the final diff and format the changed files.
- Assistant
Checking that only the intended source files differ, and that cache noise isn't included.
- Assistant
Restoring the original dependent-parent comment and merging it with the column-cap note.
- Assistant
The last edit broke
renderVisionAndRootFiles; restoring that function and the dependent-parent helper. - Assistant
Let me look at the current broken state and fix the whole section.
- Assistant
I need to fix the broken section between lines 2432-2446.
- Assistant
Still missing the functiondeclaration — restoring it.
- Assistant
Verifying final state ofthe changed files, then submitting.
- Assistant
Running a quick final verification of the package and the column-cap helper.
- Assistant
Go ignores
_-prefixed test files—renaming and re-running.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.