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 implement this as a generator-level fallback, add wide and narrow resource coverage, then run formatting, targeted tests, the full Go suite, and golden verification if generated output is affected. The issue is already filed in the supplied report; I’ll work from that local problem statement without external access.
- Assistant
rgis unavailable in this workspace, so I’m switching tofind/grepand tracing the store template and its tests directly. - Assistant
The existing template uses one predicate for both “table exists” and “typed projection exists,” so simply trimming columns would drop the per-resource table. I’m separating those concepts: wide tables remain emitted as three-column JSON-only tables, while typed indexes, FTS, public typed upserts, and typed batch dispatch remain disabled; batch writes get a dedicated JSON-only dispatch.
- Assistant
The regression coverage now generates a 3,001-field resource alongside a normal typed resource, opens a fresh generated SQLite store, verifies the wide table has exactly three columns, writes through
UpsertBatch, and confirms the narrow typed projection still works. I’m formatting and running that focused test next. - Assistant
The focused tests pass, including the boundary case where a table is exactly at 1,500 columns before a dependent
parent_idcolumn pushes it over the cap. The fallback is applied after that dependent-column expansion, so the cap truly includes parent columns. Next I’m checking deterministic generator output, then the full suite. - Assistant
Golden verification is blocked by a missing local prerequisite (
jq); the harness exited before generating or comparing artifacts. I’ll still run the complete Go test suite and inspect the repository diff for unintended changes. - Assistant
The first full-suite attempt hit the container’s process limit while Go was compiling many packages in parallel (
fork/exec … resource temporarily unavailable), not a code failure. I’m rerunning with package parallelism capped at two. - Assistant
The throttled full suite is still running cleanly; it is in the slower integration-heavy packages and has not emitted a test failure.
- Assistant
The second full run compiled successfully but the pipeline package’s highly parallel subprocess tests again exhausted the environment’s process allowance. I’ve confirmed no lingering process leak and the diff is clean; I’m making one final full-suite run with both package and test parallelism constrained.
- Assistant
The serial full-suite run is progressing without failures. Its output is quiet because packages are now running one at a time, which avoids the prior subprocess exhaustion.
- Assistant
Still clean and active; the repository’s full suite contains long-running generated/integration tests, so the constrained run trades speed for reliability. The focused generator and generated-SQLite regression tests have already passed.
- Assistant
No failure output after several minutes. I’m letting the constrained suite finish rather than treating the earlier environment-limit failures as a result.
- Assistant
The process-constrained suite completed with one unrelated pipeline test failure:
TestLiveCheck_BinaryRefreshReasonIncludesSourceWalkError. I’m rerunning that test alone to determine whether it is an environmental/flaky baseline issue; all generator packages, including this change, passed in the full run. - Assistant
The remaining full-suite failure is confirmed baseline/environment-specific: its test creates a mode-
000directory and expects traversal to fail, but this container runs as root and can still traverse it. The changed generator package passed. I’m doing the final relative-path binary build and repository hygiene check now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.