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):
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
- Assistant
I’ll trace the generator’s store templates and generation flow, identify how leaf columns and dependent-parent columns are counted, then add a 1500-column dispatch to a JSON-only table path. I’ll preserve narrow-resource output, run focused tests (and broader tests if practical), and inspect the diff before submission.
- Assistant
The repository already contains a
hasDomainUpsert/typed-table predicate, so I’m checking whether this is partial infrastructure or an existing fallback that misses width accounting. I’ll follow the data model from schema flattening through template context and then adjust the single dispatch point rather than duplicating runtime logic. - Assistant
The correct boundary is after
schemaWithDependentParents: that is where the final column count includesparent_id. I’ll mark only tables over 1500 as JSON-only, reset their columns to the canonical three, and clear indexes/FTS metadata. The store template will create those tables but exclude them from all typed upsert, dispatch, index, and FTS generation. - Assistant
The implementation now resets wide tables to exactly three columns and excludes them from typed code paths. The initial test command was blocked before compilation because this environment has neither
GOMODCACHEnorGOPATH; I’ll still validate template/control-flow consistency locally, inspect generated-related templates, and run any available static checks. - Assistant
I found an important cross-template dispatch:
sync.go.tmplalso useshasTypedTablefor single-object responses. Since JSON-only resources must have no typed upsert anywhere, I’m making the shared predicate itself excludeJSONOnly; this prevents generated calls to a deliberately omittedUpsert<Resource>method, not just batch dispatch calls. - Assistant
The shared predicate fix closes the single-object path as well. The final checks show no whitespace errors and only the intended three files changed. I’ll perform one last diff review and attempt the focused test command with an isolated temporary module cache; if dependencies are unavailable, I’ll report that limitation in the final checklist.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.