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 explore the generator templates for store.
- Assistant
Looking at the store template and related generator code for column emission.
- Assistant
rg is not found, let me use grep instead.
- Assistant
There's already related logic around JSON-only tables. Inspecting generator.go for how tables and columns are built.
- Assistant
Let me look at TableDef structure and how schema is built.
- Assistant
Reading schema_builder.go — that's where table columns get constructed.
- Assistant
Let me continue reading the schema_builder.go file.
- Assistant
There's already a related skip path — inspecting that and how tables get filtered.
- Assistant
I need to open generator.go more carefully.
- Assistant
Checking how hasTypedTable gates table creation and upserts in the store template.
- Assistant
Searching for existing JSON-only paths and upsert patterns for untyped tables.
- Assistant
Checking why 3-column tables are skipped and whether AGENTS.md documents this.
- Assistant
Checking how generation logs work and reviewing sub-resource table building thoroughly.
- Assistant
Checking callers of BuildSchema and schemaWithDependentParents:
- Assistant
Checking other places that might need to handle JSONOnly tables:
- Assistant
Checking the sync template's hasTypedTable usage:
- Assistant
Implementing the column-cap fallback: collapse wide tables to JSON-only after parent columns are added, and keep them creatable/upsertable.
- Assistant
Adding the applyColumnCap function and updating hasTypedTable and schemaWithDependentParents.
- Assistant
I'll add applyColumnCap after BuildSchema returns, and before computeDataGravity.
- Assistant
Fixing the accidental duplicate function header.
- Assistant
Removing the duplicate epCount line.
- Assistant
Updating schemaWithDependentParents and hasTypedTable next.
- Assistant
I'll fix the spacing and update hasTypedTable.
- Assistant
Now update hasTypedTable.
- Assistant
Fixing the broken pathContainsParam entry.
- Assistant
Verifying the package compiles, then testing the wide-table fallback with a temporary script.
- Assistant
Need to set up the Go environment variables.
- Assistant
Build succeeded. Writing and running a verification script for the wide-table and normal cases.
- Assistant
Putting the verification as a temporary test inside the generator package.
- Assistant
There's a fail. Let me see the full error.
- Assistant
Inspecting the generated store.go for the control table definition.
- Assistant
Inspecting the generated control table DDL and upsert.
- Assistant
Verifying that migrations succeed when opening an empty database with the generated store.
- Assistant
Simplifying the verification test to avoid fragile string parsing.
- Assistant
Rewriting the verification test carefully.
- Assistant
There's a garbage line. Let me check the file around line nancy 128.
- Assistant
The replace didn't work because of tab/space issues. Let me fix.
- Assistant
Main assertions passed. Finishing migrationscheck via Python's sqlite3.
- Assistant
Need to clean up unused imports.
- Assistant
Removing the temporary test and running related, existing generator tests.
- Assistant
Verifying the final code state and edge cases at the 1500 boundary.
- Assistant
Restoring unintended
.gocachechanges so the submit only includes our fix. - Assistant
Confirming our generator diffs are clean and nothing else is modified.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.