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):
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
Confident. The typed-table-emit path walks the resource's response schema and emits one column per leaf field with no width sanity check. The store package has no JSON-only fallback for resources whose schema exceeds a safe column count.
- Assistant
I’ll trace the store generation and its existing tests, then implement the 1,500-column cutoff at the Printing Press generator level and verify both wide fallback and unchanged narrow output.
- Assistant
rgisn’t installed in this environment, so I’m using targetedfind/grepinspection instead. The task is already filed, and I’m keeping all work local as requested. - Assistant
The key distinction is now clear: a wide resource cannot merely lose its typed columns, because the existing three-column shape is normally treated as “no per-resource table.” I’m adding an explicit JSON-only table state so migration and sync keep the resource table, while typed indexes, FTS, and typed upsert helpers remain disabled.
- Assistant
The implementation and boundary tests are in place. The focused test run is still compiling dependencies; once it finishes I’ll address any template or generated-runtime failures, then run the required broader checks and golden verification.
- Assistant
The focused tests now pass, including compiling and testing a generated store from a 3,001-field resource. I’m strengthening the generated test contract so future wide-resource outputs verify that
UpsertBatchactually populates the three-column table, not just that the emitted source looks correct. - Assistant
The generated runtime test passes. Golden verification cannot start because this checkout lacks the required
jqexecutable; I’m not updating goldens, and the template’s narrow-resource branches are designed to render byte-identically. I’m proceeding with the full Go test suite and relative-path binary build. - Assistant
The first full-suite attempt hit the container’s process limit (
fork/exec … resource temporarily unavailable), not a code failure. I’m letting that invocation drain, then I’ll rerun with constrained Go package parallelism so it produces a reliable result. - Assistant
The constrained full suite is progressing without the earlier process-limit errors. It is quiet because packages are running serially; I’ll keep it bounded and report any genuine failing package separately from environment-only checks.
- Assistant
The serial run has cleared the command and foundational packages and is now in the larger CLI/generator tests. No resource-exhaustion messages or implementation failures have appeared in this rerun.
- Assistant
The long-running generator package is still active under the constrained run; the earlier focused generator and generated-SQLite tests already pass. I’m continuing until the repository-wide result completes.
- Assistant
The generator package remains quiet but healthy; serial execution makes its many generated-project builds substantially slower. There is still no failure output in the constrained run.
- Assistant
The constrained run eliminated process exhaustion, but
internal/generatorstill reports at least one failure amid very noisy attribution output. I’m isolating the failing test name now; the other completed packages are passing. - Assistant
The isolated generator run is still executing; its output is filtered to failures, so silence is expected until a failing assertion or final result appears.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.