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 TABLE statements.
- Assistant
Let me look at the store templates and related generator code.
- Assistant
Found
store.go.tmpl. I'll inspect how CREATE TABLE and column emission work. - Assistant
I'll inspect how store table data is prepared in the generator and open the relevant CREATE TABLE section.
- Assistant
schema_builder.golooks central — I'll read it next. - Assistant
Let me read more of this file, especially around JSON-only and dependent parent columns.
- Assistant
I'll check parent-column injection and existing schema builder tests for patterns.
- Assistant
I'll review schema finalization and how typed upsert generation decides what to emit.
- Assistant
I'll check how generation-time logging works and inspect the store template's typed-table gates.
- Assistant
I need to understand UpsertBatch and how non-typed tables currently behave.
- Assistant
I'll inspect the typed upsert section and any low-gravity table handling for the right pattern.
- Assistant
I'll check other
hasTypedTableuses and store test templates so the gate stays consistent. - Assistant
Let me look at the upsert batch test for typed tables and the schema version test for backfill.
- Assistant
I'll check how sync uses hasTypedTable and look for related generator tests.
- Assistant
I'll inspect the generic Upsert path and whether low-gravity resources still get domain tables.
- Assistant
I'll check existing imports and reproductive patterns in tests, then implement the fix.
- Assistant
Implementing the column-cap fallback: update
TableDef, apply the cap after schema finalization, and fixhasTypedTableso JSON-only wide tables still get domain tables and upsert dispatch. - Assistant
I edited the wrong file — restoring the test file and applying the change to
schema_builder.go. - Assistant
Good, test file restored. Now let me properly edit schema_builder.go.
- Assistant
Good. Now update TableDef and add the constant and function.
- Assistant
Next I'll hook the fallback into BuildSchema and add the helper function.
- Assistant
I'll replace
return tableswith the fallback call, and add the apply function right after BuildSchema. - Assistant
Updating
schemaWithDependentParentsandhasTypedTablenext. - Assistant
I'll update schemaWithDependentParents and hasTypedTable.
- Assistant
I'll fix that comment typo and update
hasTypedTable. - Assistant
Updating
hasTypedTablenext: - Assistant
Updating
hasTypedTableso JSON-only fallback tables still emit domain CREATE/upsert/batch dispatch. - Assistant
I'll clean up the comment wording, then verify with a synthetic wide-spec end-to-end.
- Assistant
Writing a temporary verification script for wide and narrow resources.
- Assistant
Fixing typos in the verify script so it runs cleanly.
- Assistant
I'll write the verify script through a clean Python file to avoid corruption.
- Assistant
I'll use the create command for a clean test harness file.
- Assistant
Let me remove and create
- Assistant
Now I'll edit the empty file carefully.
- Assistant
Checking the rest of the file for corruption.
- Assistant
I'll fix the corrupted lines.
- Assistant
Need to fix more corruptions
- Assistant
Checking VisionTemplateSet and generator.New signatures before running.
- Assistant
I'll check whether Generate requires a profile, then run the verify script.
- Assistant
I'll run the verification script.
- Assistant
I'll put the verification harness inside the generator package so it can import internals.
- Assistant
I'll add a temporary test inside the generator package, run it: then remove it.
- Assistant
Now write the test carefully.
- Assistant
The bulk edit is corrupting text — I'll write the file with a short Python script instead.
- Assistant
I'll write a minimal pure-ASCII test using only short, carefully typed appends.
- Assistant
Checking that
findTableexists, then running the temp test. - Assistant
Verifying that opening the generated store against an empty DB succeeds.
- Assistant
Rewriting the entire temp test carefully, including a store open check.
- Assistant
I'll open the file and fix the remaining regex/escape issues.
- Assistant
Running the temp test including the store open check.
- Assistant
I'll fix the temp test to run
go mod tidybefore opening the store. - Assistant
All checks passed. Removing the temp test and running related existing tests.
- Assistant
Verifying the final diff and that no temp files remain.
- Assistant
Re-reading the contract: JSON-only tables should keep CREATE TABLE + batch dispatch, but not typed Upsert methods. I'll adjust templates accordingly.
- Assistant
The solution matches the acceptance criteria. Cleaning up and submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.