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 analyze the issue and develop a solution. Let me start by exploring the repository structure.
Assistant
The issue mentions
internal/generator/templates/store/but onlystore.go.tmplexists. Let me explore this and understand how store is generated.Assistant
Now I see the
CREATE TABLEblock uses{{safeName .Name}}and iterates over.Columns. Let me find where Tables/Columns is built:Assistant
Now I understand
hasTypedTable. Let me find whereTableDefis defined andColumnsare constructed:Assistant
Now I understand. Let me look at how
schemaWithDependentParentsworks (whereColumnsis computed/applied):Assistant
Now let me look at the rest of store.go.tmpl around the upsert path to understand typed table generation:
Assistant
Let me look at the schema_builder_test.go and check for existing tests around wide tables / column counts:
Assistant
No existing fallback mechanism. Let me look at how tests are structured for schema_builder:
Assistant
Let me look at the
domainUpsertMethodNamefunction:Assistant
Now I have a clear understanding. Let me also check how
len(t.Columns) > 3works forhasTypedTable:baseTableColumnsisid,data,synced_at= 3 columns- When
hasTypedTablereturns true (i.e., > 3 columns), the table gets the typed CREATE TABLE block, upsert, FTS5, etc.
So the path I need to take:
- Detect wide resources (Columns > 1500, including dependent parents)
- When wide, generate JSON-only schema:
id TEXT PRIMARY KEY, data JSON NOT NULL, synced_at DATETIME - No typed indexes, no FTS5, no typed upsert code
Let me also look at the rest of
BuildSchemaand the function that handles dependent tables:Assistant
Now let me check the entire
BuildSchemato see what's there. Theid/data/synced_atare 3 columns. A> 3check meanshasTypedTablereturns false when we have only 3 columns. That means the JSON-only path needs to be triggered when columns exceed 1500.Let me check what
upsertGenericResourceTxdoes to confirm we can keep the generic insert path:Assistant
Good - the generic resources table path works independently. Now let me look at the testdata to find existing fixture specs and how they're structured:
Assistant
The store directory doesn't exist for golden. Let me check the golden test:
Assistant
So
internal/storeisn't generated for the golden test by default. Let me check the spec to understand vision capabilities:Assistant
Now let me look at the spec test fixtures to understand how to test:
Assistant
Now let me look at how to test the build. Let me first check existing tests around the columns to understand the test patterns:
Assistant
Now I have a complete understanding. Let me design my solution:
Approach: Modify
BuildSchema(orschemaWithDependentParents) to check the column count after building the table. If a table has more than 1500 columns, strip it down to justid,data,synced_at(the JSON-only fallback). ThehasTypedTablepredicate already gates onlen(t.Columns) > 3, so trimming to 3 columns naturally hides it from typed-table emission.Let me also check if there's an issue with sub-resources (which start with 4 columns:
id,parent_id,data,synced_at):The cleanest approach is to add a column-count check in
BuildSchemaitself. After all the columns are computed (and before/after dependent parents), check if the table is "wide". If so, replace the columns with just the base 3.Let me first reproduce the issue. Let me check if there's a way to construct a wide spec:
Assistant
Now let me check existing schema_builder_test to understand the test patterns:
Assistant
Now let me look at how the
sync_statetable is constructed (this is the 4-column one - has primary key, last_cursor, last_synced_at, total_count):Assistant
Good - sync_state has 4 columns but
hasTypedTablealready excludes it by name.Now I understand the issue completely. Let me check where column count threshold should go. Per the contract:
Use 1500 columns as the safety cap for a generated typed SQLite resource table, including dependent-parent columns.
So:
- In
BuildSchema— after computing columns for a table, iflen(t.Columns) > 1500, reset to base 3 columns (id, data, synced_at) - In
schemaWithDependentParents— same applies after adding parent_id, so a wide table with parent_id also collapses - The JSON-only schema:
id TEXT PRIMARY KEY, data JSON NOT NULL, synced_at DATETIME— these are exactlybaseTableColumns
- In
Assistant
Now I have a clear plan. Let me implement the changes:
- Modify
BuildSchemainschema_builder.go: after building each table, iflen(t.Columns) > MaxResourceColumns(1500), trim it to the base columns. - Modify
schemaWithDependentParentsingenerator.go: also collapse the table back if it would exceed the cap after parent_id is added. - Log a warning when this fallback fires.
Let me first look at the full
BuildSchemato understand its structure better:- Modify
Assistant
Now let me check what's in the schema_builder_test.go for sub-resources:
Assistant
Now let me understand the test infrastructure first. Let me check if there's a way to run a small reproducer:
Assistant
Good, the build works. Now let me run the existing tests to make sure they pass:
Assistant
Let me now write a reproducer script for the issue first:
Assistant
The test passes because it doesn't have enough unique field names. The dedup is collapsing them. Let me fix the test to actually have 3000+ unique columns:
Assistant
I've reproduced the bug. Now let me delete the repro file and implement the fix:
Assistant
Now let me implement the fix in
schema_builder.go:Assistant
Now I'll implement the fix. Let me modify
schema_builder.goto add the column-count check:Assistant
Now let me apply the fix. I'll add a
maxResourceColumnsconstant and trim wide tables inBuildSchema:Assistant
The edit removed the function comment block. Let me revert that and use a different approach:
Assistant
Let me revert and try a different edit approach:
Assistant
Good, reverted. Now let me add the constant properly:
Assistant
The edit corrupted the function signature line. Let me fix:
Assistant
Good. Now let me add the column-count check inside BuildSchema, right after the table is built:
Assistant
The edit duplicated text. Let me revert and try again with a cleaner approach:
Assistant
Let me take a different approach - use a Python script to do precise multi-line edits:
Assistant
Let me use Python to make the multi-line edits properly:
Assistant
Let me check the exact text:
Assistant
The indentation is
\t\t(two tabs) not\t(one tab). Let me update the Python script:Assistant
Let me check if the first assertion (old_base_end) succeeded:
Assistant
Nothing was applied. Let me verify the actual content of the relevant section:
Assistant
I see, the indentation is
\t\t(two tabs) throughout, not\t(one tab). Let me fix:Assistant
Let me verify the changes:
Assistant
Now let me build:
Assistant
Now I need to also handle the case in
schemaWithDependentParentsbecause the contract says "including dependent-parent columns". Let me also add the check there:Assistant
I need to add the wide-resource check after parent_id is added. Let me update:
Assistant
Wait, let me reconsider. The contract says "Use 1500 columns as the safety cap for a generated typed SQLite resource table, including dependent-parent columns." This means the cap applies AFTER adding parent_id. But my current logic in only acts if a table that was originally narrow (≤1500 cols) grows past 1500 by adding parent_id — which is essentially impossible since parent_id adds 1 column. And for tables that were already collapsed (≤3 cols), adding parent_id would bring them to 4 cols, but only if they're dependent resources. So my logic might be a little off.
Assistant
Let me reconsider. The cleaner approach is: when BuildSchema collapses a table to JSON-only, it should also mark the table so we don't add parent_id later. Or, the cleaner way is to do the wide-resource check at the very end (in
schemaWithDependentParents), comparing against the original column count which we preserve in the TableDef.Actually let me just rethink: rather than carrying state, I'll preserve the original wide-ness by checking if
t.Columnshas been collapsed. The collapse setst.Columnsto exactlybaseTableColumns(3 entries). So inschemaWithDependentParents, if we add parent_id to a table that's exactlybaseTableColumns, that means it's already JSON-only.But wait — what if a regular table with low gravity was never extended (so just baseTableColumns)? Adding parent_id would push to 4 cols. Hmm. We can't distinguish "never extended" from "collapsed to JSON-only" purely from column count.
The cleanest solution is to track this state explicitly. Let me add a field to
TableDef:Assistant
Now update the wide-resource check in BuildSchema to set JSONOnly:
Assistant
Now let me fix the
schemaWithDependentParentsto skip parent_id for JSONOnly tables:Assistant
Now let me also check the
hasTypedTablepredicate. Since it gates onlen(t.Columns) > 3and JSON-only tables have exactly 3 columns, this should automatically skip them. But I should also consider: thedomainUpsertMethodNamefor "sync_state" table returnsUpsertSyncState, which... let me check what happens if domainUpsertMethodName matches "UpsertBatch":Assistant
OK, so
hasTypedTablealready correctly excludes JSON-only tables (3 cols).Now let me think about the rest of the system. The templates iterate over
.Tablesand gate onhasTypedTable. They will skip the JSON-only tables. But theCREATE TABLEblock still creates a per-resource table for every table in.Tables:Let me look at the templates again:
Assistant
The template gates on
hasTypedTable, so a JSON-only table will be skipped from the CREATE TABLE block. But the contract says:Resources exceeding the cap must retain their per-resource table but fall back to a JSON-only schema containing
id,data, andsynced_atHmm — so they should STILL have a per-resource table created, just with the JSON-only schema. This means I need to remove the
hasTypedTablegate from the CREATE TABLE block, or add a separate template block for JSON-only tables.Let me re-read the contract carefully:
Use 1500 columns as the safety cap for a generated typed SQLite resource table, including dependent-parent columns. Resources exceeding the cap must retain their per-resource table but fall back to a JSON-only schema containing
id,data, andsynced_at; do not generate typed-column indexes, FTS structures, or typed upsert code for that fallback table.So:
- Per-resource table IS created (with JSON-only schema)
- No typed-column indexes
- No FTS structures
- No typed upsert code
Let me update the template to handle this:
Assistant
OK. Now I see the template structure. The
hasTypedTablegate is for "tables that have a typed Upsert". The contract says:- Per-resource table IS created (with JSON-only schema)
- No typed-column indexes (which is handled because we already set Indexes = nil in BuildSchema)
- No FTS structures (handled: FTS5 = false)
- No typed upsert code (handled by hasTypedTable gate)
Assistant
Looking at the structure:
{{- range .Tables}}opens{{- if hasTypedTable .}}opens- FTS section with
{{- if .FTS5}}...{{- end}}and{{- if .FTS5Triggers}}...{{- else}}...{{- end}} {{- end}}closeshasTypedTable{{- end}}closesrange .Tables
So I need to add a JSON-only block right after
hasTypedTableends but beforerange .Tablesends. Let me do that:Assistant
Let me verify:
Assistant
Wait — the JSON-only block is now INSIDE the
hasTypedTable .{{- if hasTypedTable .}}block (the indentation suggests it's nested). Let me check:The structure is:
{{- range .Tables}} {{- if hasTypedTable .}} [typed block] [FTS block] {{- end}} <-- closes hasTypedTable {{- if .JSONOnly}} <-- my new block [JSON-only block] {{- end}} <-- my close {{- end}} <-- closes range .TablesLet me verify the structure with the surrounding context more carefully:
Assistant
Let me look at the FTS end section and the JSONOnly block more carefully:
Assistant
Looking at the structure:
- Line 320:
{{- end}}closes{{- if .FTS5Triggers}}...{{- else}}...{{- end}} - Line 327:
{{- if .JSONOnly}}opens my new block - Line 335:
{{- end}}closes{{- if .JSONOnly}} - Line 336:
{{- end}}closes{{- if hasTypedTable .}} - (Need to find another
{{- end}}forrange .Tables)
Wait, let me look at line 336 again. We need to count:
- Line 320:
Assistant
Now let me trace the structure:
{{- range .Tables}}(line 274){{- if hasTypedTable .}}(line 278){{- range $i, $col := .Columns}}(line 281){{- if $i}},{{end}}(line 282){{- end}}(line 284, closes Columns range){{- range .Indexes}}(line 286){{- end}}(line 288, closes Indexes range){{- if .FTS5}}(line 289){{- if .FTS5Triggers}}(line 290){{- range $i, $field := .FTS5Fields}}(line 292){{- if $i}},{{end}}(line 293){{- end}}(line 295, closes FTS5Fields range){{- else}}(line 312){{- range $i, $field := .FTS5Fields}}(line 315){{- end}}(line 317, closes FTS5Fields range){{- end}}(line 320, closes FTS5Triggers... wait, else consumes the close)
Assistant
Wait, I see. Looking at the original template (before my changes), the structure had:
{{- range .Tables}}(line 274){{- if hasTypedTable .}}(line 278)- ... typed stuff ...
{{- end}}(line 320 — closes FTS5Triggers else/end){{- end}}(closes FTS5 if){{- end}}(closes hasTypedTable if){{- end}}(closes range .Tables)
That's FOUR closing
{{- end}}for: FTS5Triggers, FTS5, hasTypedTable, range .Tables.Let me re-look at the lines (using
cat -nto make this clearer):Assistant
OK so I see:
- Line 288:
{{- if .FTS5}} - Line 289:
{{- if .FTS5Triggers}} - Line 312:
{{- else}}(this is for FTS5Triggers) - Line 320:
{{- end}}(closes FTS5Triggers... but wait, what closes FTS5?)
Hmm. Let me look at the original template to understand the correct structure:
- Line 288:
Assistant
Original had 4 closes at end:
{{- end}}(closes FTS5Triggers... wait, there are nested ifs)
Let me count opens and closes for the original:
- Opens: range .Tables, if hasTypedTable, range .Columns, if i, range .FTS5Fields (in else branch),
Assistant
So in the original there are FOUR
{{- end}}at the end:- Line 320: closes FTS5Triggers (
{{- if .FTS5Triggers}}...{{- else}}...{{- end}}) - Line 321: closes FTS5 (
{{- if .FTS5}}...{{- end}}) - Line 322: closes hasTypedTable
- Line 323: closes range .Tables
OK so my edit added the JSONOnly block between lines 320 and 321. Let me look at my current file:
- Line 320: closes FTS5Triggers (
Assistant
So now I have:
- Line 320 (the one before my block): closes FTS5Triggers
- Line 335 (my new): closes JSONOnly
- Line 336: closes FTS5 OR hasTypedTable OR range .Tables
Wait, only ONE
{{- end}}after my new block! That's wrong because the JSONOnly is being inserted INSIDE the FTS5 block (which is inside hasTypedTable, which is inside range .Tables).Let me check this more carefully. The structure right after my insertion:
{{- end}} // closes FTS5Triggers (line 320) ... comment block {{- if .JSONOnly}} ... CREATE TABLE ... {{- end}} // closes JSONOnly (line 335) {{- end}} // closes ??? (line 336)Hmm, but JSONOnly should be inside
hasTypedTable(since we want it to be processed for each table). So the structure should be:{{- range .Tables}} {{- if hasTypedTable .}} ... typed block ... [FTS5 block] {{- end}} {{- if .JSONOnly}} // <-- need to be inside range .Tables but OUTSIDE hasTypedTable ... CREATE TABLE ... {{- end}} {{- end}}So I need:
- 1
{{- end}}for FTS5Triggers (after the else branch)
Assistant
Let me verify:
Assistant
Now structure is:
- Line 274:
range .Tables - Line 278:
if hasTypedTable - ...typed stuff...
- Line 320:
end(closes FTS5Triggers with else) - Line 321:
end(closes FTS5) - Line 322:
end(closes hasTypedTable) - Line 323-331: comment block
- Line 332:
if .JSONOnly - Line 339:
end(closes JSONOnly) - Line 340:
end(closes range .Tables)
This is correct! Let me also check the sync.go.tmpl to see if there are similar dispatch patterns:
- Line 274:
Assistant
Good. The sync.go.tmpl dispatches to typed Upsert functions but they're already gated by
hasTypedTable. Since wide resources have len(Columns) == 3 andhasTypedTablereturns false for them, the dispatch is skipped. The fallback todb.Upsert(resource, id, data)is the generic insert path.Let me also check
store_upsert_batch_test.go.tmpl:Assistant
OK so the test files also gate on
hasTypedTable, so wide tables won't get tests. That's fine.Let me build and run the tests now:
Assistant
Let me now write a comprehensive reproducer to verify the fix:
Assistant
Excellent! The fix works:
- The wide resource gets collapsed to JSON-only (3 cols: id, data, synced_at)
- The log message is emitted:
store-fallback: control (3003 cols) -> JSON-only (exceeds 1500-column safety cap; records still land in the generic resources table) - Narrow resource
issuesretains its typed columns
Now let me also verify the store template renders correctly. Let me test that by simulating template rendering:
Assistant
Let me clean up the test file first, then look at how to test the rendered template:
Assistant
Let me look for a generator test that runs the template:
Assistant
Good, I can use this pattern. Let me write a test to verify the template renders correctly for wide tables. Let me first inspect how
minimalSpeclooks:Assistant
Now let me look at the store_resolve_by_name_guard_test.go more carefully and check how Generate works with the spec to ensure the template is rendered:
Assistant
Now let me write a test that does full generation with a wide resource and checks the store.go file. But first let me check what
Generatedoes and ifminimalSpectriggers store rendering:Assistant
Let me write a test that simulates a wide resource and verifies the rendered store.go:
Assistant
Let me fix the test:
Assistant
There's no
Syncablefield. Let me look at how resources are marked syncable. Theprofiler.SyncableResourcesis the result of profiling. Let me check how the existing tests set up syncable resources:Assistant
Let me look at the existing test for what triggers store generation, then simplify my test:
Assistant
Let me update:
Assistant
The test passed the column count check (3 columns) but failed somewhere. Let me see the full output:
Assistant
Hmm, the stderr output didn't include the store-fallback message. Let me check more output:
Assistant
The store-fallback message wasn't generated. That means Generate() didn't render the store.go file in this test, OR the wide-resource detection didn't fire. Let me check if the test passed the column count check at line 114. Yes it did (3 cols). But the store-fallback log wasn't there.
Wait, looking more carefully - the stderr captured only the WARNING line, not the store-fallback. This suggests that the Generate() call did not call BuildSchema, or stderr wasn't written yet. Or maybe Generate() is not calling renderStoreFiles for this spec. Let me check:
Assistant
OK so
renderStoreFilesIS called fromrenderVisionAndRootFiles. The question is whetherg.VisionSet.Storeis true for our spec. Let me check what the vision-set selection does:Assistant
Let me check if my spec actually gets marked syncable. The store generation requires
g.VisionSet.Store. Let me check what makes that true:Assistant
So the store is generated if
HighVolumeorNeedsSearch. My test fixture probably doesn't trigger that. Let me check the syncable resources detection - maybe my resource isn't even being marked syncable.Looking at the test output, my test passed
column count: 3check - but that's checking the generated store.go. So the store.go WAS generated (with the wide-resource detection working). But the stderr didn't include the fallback log...Wait — let me re-read the output. The stderr was captured BEFORE the Generate() call returned, and the fallback log was written to stderr during BuildSchema. But the stderr capture shows only the WARNING line. The fallback log was either not written or written to a different file descriptor.
Hmm, let me look more carefully:
Assistant
OK so the store.go was generated. The output is truncated due to 7027 chars. Let me increase the buffer:
Assistant
Actually, let me write a simpler version that just reads in a loop and accumulates:
Assistant
Excellent! The test passes now. The fix is working correctly:
controltable has 3 columns (id, data, synced_at) ✓- The fallback log is emitted ✓
- No typed upsert code for control ✓
- No FTS for control ✓
Let me also verify the negative case (narrow resource still gets typed columns):
Assistant
Both the wide and narrow resources work correctly. Let me also test the dependent-parent case:
Assistant
Let me see the test file:
Assistant
The replacement left a stray brace. Let me fix it:
Assistant
The replacement didn't work because the strings differ. Let me use sed directly:
Assistant
The text doesn't have the closing
},correctly. Let me check what's there:Assistant
Now let me run the test:
Assistant
The dependent-resource case also works correctly. The wide dependent resource
ticketsis collapsed to JSON-only, even though it's a child ofaccounts.Now let me clean up my test files and run the existing tests to make sure I didn't break anything:
Assistant
That looks like a pre-existing failure (vulnerability in Go std lib) unrelated to my changes. Let me skip the govulncheck and just run tests:
Assistant
All tests pass. Let me also check the profile-related test failure - it's running govulncheck as part of the test:
Assistant
OK so the test is doing full generate + govulncheck which is a separate failure (Go stdlib vuln, unrelated). Let me confirm by running just the schema_builder tests:
Assistant
All schema builder tests pass. Let me also run the store-related and template-related tests:
Assistant
Let me also test the full generator with a real CLI to ensure my changes don't break the golden test:
Assistant
Let me find the golden test runner:
Assistant
This is a bash script for golden testing. Let me run the relevant tests in the generator package directly:
Assistant
All generate tests pass. Let me also run a broader test suite to verify nothing else is broken:
Assistant
Let me check that failing test to see if it's pre-existing:
Assistant
Good - that test fails without my changes too. It's a pre-existing failure unrelated to my work. Let me restore my changes:
Assistant
Wait, go.mod is also modified? Let me check:
Assistant
Hmm,
go mod tidywas probably run during testing. Let me revert it:Assistant
Now let me also check the upstream
go.mod:Assistant
Good. Now let me view the full diff to ensure correctness:
Assistant
Let me run the tests once more to confirm everything is working:
Assistant
Let me also look at the entire store template to ensure the JSONOnly block is positioned correctly:
Assistant
The template structure is correct. Let me also think about edge cases:
-
Sub-resources (sharded or non-sharded) — sub-resources start with 4 columns (id, parent_id, data, synced_at). The maxResourceColumns check is
> 1500, so a sub-resource starting with 4 cols won't be affected unless it grows beyond 1500 cols (rare). -
Low-gravity tables — these stay at 3 cols and don't trigger the fallback.
-
Sync_state table — 4 cols, never triggers fallback.
hasTypedTablealready excludes it by name. -
Wide sub-resource — If a sub-resource has many response fields, the same logic applies. Let me check that:
-
Assistant
Sub-resources start with 4 columns: id, parent_id, data, synced_at. They don't get extended with response-derived columns (only top-level resources do). So sub-resources can never trigger the wide-resource check via
BuildSchema. Good.Now let me also verify the
hasTypedTablepredicate interacts correctly with JSONOnly. Let me also checkisBackfillColumnfor store tables:Assistant
OK these are about backfilling columns, not directly about wide-resource handling.
Now let me also think about another edge case: what if
maxResourceColumnsis exactly hit? The check is> maxResourceColumns, so 1500 cols is allowed but 1501 is not. That matches the contract "Use 1500 columns as the safety cap".Let me check the actual edge: the contract says "Use 1500 columns as the safety cap". My check is
> 1500. So 1500 is allowed, 1501+ triggers fallback. This is correct.Let me also run a broader subset of tests to make sure nothing else is affected:
Assistant
Excellent. Everything builds and tests pass. Let me also write one more reproducer to ensure the full sync flow works:
Assistant
Now let me clean up the test files (they shouldn't be part of the submission):
Assistant
Good - no more test files. Let me confirm the final state:
Assistant
go.mod was modified again — must have been from go test importing packages. Let me revert it:
Assistant
Good. Now let me also verify the build is still clean:
Assistant
All tests pass. Let me also verify my final diff:
Assistant
Let me revert the go.mod change again since the tests don't need it:
Assistant
Let me also double-check by reading the final state of each file:
Assistant
All three files look good. Let me also do a final check on the test suite:
Assistant
Wait, the test name
TestWideResourcedoesn't exist anymore (since I removed the test file). Let me verify it's just because there are noWideResourcetests butBuildSchematests pass:Assistant
All
TestBuildSchematests pass. Now let me verify the final files are in the right state:Assistant
Three files modified. Let me verify by running my reproducer logic one more time and the test suite:
Assistant
Both positive and negative cases work correctly. Note the
9 colsfor control — this is the count of\n\t\t\t"patterns. Let me check:Assistant
The issue is that my count of 9 includes the
CREATE TABLE IF NOT EXISTS "control"line. The"\n\t\t\t\""pattern matches the"after\t\t\twhich is\t\t\t"control". Let me check the test more carefully:Assistant
OK the substring ")`," isn't found. The issue is my test fixture doesn't have that exact closing pattern. Let me check what the actual CREATE TABLE looks like:
Assistant
Hmm — for a small spec, the CREATE TABLE for control is not generated. The reason is: my mini spec has only 5 fields, so it's below the 1500 cap, so it gets the typed path. But the typed path is gated on
hasTypedTablewhich requireslen(Columns) > 3ANDgravity >= 2. Let me check what gravity is for this spec...Actually, the issue might be the syncability of the resource. Let me check what causes the store to be generated and whether my minimal fixture triggers the store template. Let me check the dogfood.json output to see what was generated:
Assistant
OK the table IS generated but my test was wrong - I was searching for the wrong pattern. Let me search for
CREATE TABLEand look for the actual control table:Assistant
Hmm, no actual CREATE TABLE for control. Let me look at the generated file:
Assistant
So control doesn't appear in the store.go. The reason: with 5 fields (including id), the table is generated but probably is not marked as syncable, so the per-resource CREATE TABLE is skipped. Let me check this. Actually, looking at my final acceptance test output, it showed
9 colsfor control, meaning the CREATE TABLE for control WAS generated. So the issue must be that my mini dump test doesn't trigger the same path.Wait, let me re-read my final test. The output said:
Positive: control table collapsed to JSON-only with 9 cols
9 colsis suspicious. Let me look at what's actually in the test:Looking at my final test code, I have:
colCount := strings.Count(createBlock, "\n\t\t\t\"")For the control block which is:
`CREATE TABLE IF NOT EXISTS "control" ( "id" TEXT PRIMARY KEY, "data" JSON NOT NULL, "synced_at" DATETIME DEFAULT CURRENT_TIMESTAMP )`The
\n\t\t\t"pattern matches each line that starts with\t\t\t". That's 3 lines (id, data, synced_at). But it ALSO matches theCREATE TABLE IF NOT EXISTS "control"line because is preceded by in the surrounding context...Assistant
Now the count is 3 (correct). The CREATE TABLE block is 142 chars and the colCount is 3. The earlier count of 9 was wrong because I was looking at a wider range that included more text.
So my final acceptance test had a bug in counting, but the logic is correct (the table is collapsed to JSON-only). Let me remove the test files and clean up:
Assistant
Let me verify everything is clean:
Assistant
All tests pass. Let me also do a final sanity check of 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.