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 generator templates for store.
- Assistant
There's a store.go.tmpl template. Let me also look for how columns are computed.
- Assistant
rg is not available, I'll use grep.
- Assistant
Let me look at schema_builder.go and the store template.
- Assistant
I'll read schema_builder.go to understand how tables and columns are constructed.
- Assistant
Continuing through the rest of schema_builder.go.
- Assistant
Checking how dependent-parent columns are factored in and how the template uses TableDef.
- Assistant
Let me continue reading and also look at buildSubResourceTable and any dependent parent column logic.
- Assistant
Let me finish reading the file and also look at tests related to schema_builder.
- Assistant
Checking wherein dependent-parent columns get injected and how gate for typed upsert works.
- Assistant
I'll inspect
schemaWithDependentParentsand how typed upserts are gated by column count. - Assistant
Checking where logging happens during generation and reviewing schema_builder tests.
- Assistant
Let me also check if there's existing "fallback" Logic or if AGENTS.md has relevant guidance, and how logging is done in the generator.
- Assistant
Inspecting store template gating for typed upserts and batch dispatch.
- Assistant
Looking at hasTypedTable and UpsertBatch handling.
- Assistant
Reviewing UpsertBatch and the typed upsert generation path in detail.
- Assistant
I need the store template Upsert sections, not generator.go twice.
- Assistant
Inspecting UpsertBatch dispatch rann and related store helpers.
- Assistant
Checking callers of BuildSchema and whether batch generation uses other paths.
- Assistant
Hmm the grep on directory failed strangely. Let me try again.
- Assistant
I'll check backfill column logic and existing test patterns to mirror.
- Assistant
Implementing the JSON-only fallback for wide tables: updating
TableDefandBuildSchema, then adjustinghasTypedTable. - Assistant
I edited the wrong file and broke imports — restoring generator.go, then applying the change in schema_builder.go.
- Assistant
Updating
TableDefand applying the fallback inschema_builder.go. - Assistant
Adding the constant, helper, and call site at the end of BuildSchema.
- Assistant
Now add the constant after baseTableColumns and the apply function. Also modify BuildSchema return.
- Assistant
Next I'll apply the fallback right before BuildSchema returns.
- Assistant
I'll update the return and add the apply function after BuildSchema.
- Assistant
Updating
schemaWithDependentParentsandhasTypedTablenext. - Assistant
I'll update schemaWithDependentParents to skip JSONOnly and re-apply fallback.
- Assistant
Updating hasTypedTable so JSONOnly tables still get domain CREATE/upsert.
- Assistant
I'll update hasTypedTable to handle JSONOnly.
- Assistant
Writing a temporary verification script to exercise the fallback path.
- Assistant
I'll put a temporary in-package test under internalemb/generator and run it.
- Assistant
There are typos. Let me rewrite the test file cleanly.
- Assistant
Need to set GOPATH/GOMODCACHE. There's a .gocache directoryборе in the repo.
- Assistant
There's /go and GOCACHE might need to be set. Let me try.
- Assistant
I need to inspect the existing test fixtures to match the correct ernspec types.
- Assistant
There's already a
findTablehelper. Let me rewrite the test usingu correct types. - Assistant
BuildSchema tests pass. The generate path fails because profile is nil — I'll initialize it.
- Assistant
I can set g.profile to an empty profiler.Profile. Let me check the type.
- Assistant
Let me fix the test to set profile properly.
- Assistant
Hmm empty output?
- Assistant
Let me search differently
- Assistant
It's APIProfile. Let me check how g.profile is typed.
- Assistant
I can set g.profile = profiler.Profile(s) or &profiler.APIProfile{}.
- Assistant
The first replace worked (profile set); the second replace for the import failed. Fixing the import.
- Assistant
Let me fix import with edit.
- Assistant
Also need renderTemplate to work - New() might not load templates until Generate is called. Let me run the test.
- Assistant
All three temp tests passed. Running existing schema_builder tests and verifying square the SQLite CREATE path.
- Assistant
Running a fuller generator package compile and removing the temporary test file.
- Assistant
Cleaning
.gocachenoise from the working tree and verifying only source diffs remain. - Assistant
Confirming the generator.go diff looks correct before submitting.
- Assistant
Verifying the final schema_builder.go structure once more.
- Assistant
I'll printk the key section of schema_builder.go.
- Assistant
Ready to submit. Verifying only the intended files are in the diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.