A dump rewrites the ids of Artefact and ABOUT rows, so restore reads it - #607
Merged
Merged
Conversation
The pattern that finds graph tables in a dump let a table's body run past its own `;`. `_ag_label_vertex` and `_ag_label_edge` have no INHERITS clause, so each matched through to the next table's clause and hid it: `Artefact` and `ABOUT` were never recognised as graph tables, their ids stayed as text, and AGE's graphid rejects text input. The body now stops at the statement's `;`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWZHuy7xJbVqxyLipnvwdY
danbarua
enabled auto-merge (squash)
September 30, 2026 23:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
labkit restorecould not read a filelabkit dumphad just written once the record held an artefact:The first failing line was
INSERT INTO labkit_t1."Artefact" VALUES ('3659174697238529', '{...}').Cause
AGE's
graphidhas no text input, sorestorableinpackages/core-db/dump.tsrewrites the id columns of every graph table's rows toag_catalog._graphid(label, entry). It finds the graph tables with aCREATE TABLE ... INHERITS (..._ag_label_vertex|edge)pattern whose body was[\s\S]*?, which can run past the statement's own;.pg_dumporders tables by name, and_ag_label_vertexand_ag_label_edge(which have noINHERITS) come directly beforeArtefactandABOUT. Each of those two matched through to the next table'sINHERITSclause, so it was recorded under the wrong name, andArtefactandABOUTwere never recognised as graph tables. Their rows kept the text literal.drizzle.__drizzle_migrationsdid the same to_ag_label_edge. The other labels were unaffected, which is why a record holding only questions, enquiries and notes round-tripped.Fix
The table body is
[^;]*, so a match cannot run into the next statement. This is a one-line change to the pattern.Ruled out, measured
search_path = ag_catalog, "$user", publicbefore the dump runs, or again after itsset_config('search_path', '', false), with a dump written before the fix: the restore still fails with the same error.provisionTenantGraphrun forlabkit_t1:'3659174697238529'::ag_catalog.graphidand the rawINSERTboth fail with the same error;INSERT ... VALUES (ag_catalog._graphid(13, 1), '{}')succeeds.Test
tests/persistence/dump-restore.test.tsgains a test that writes anArtefact, aClaim, aCriterionEvaluationand anABOUTedge, dumps and restores them, and checks thatentityAsHalreturns the same result for each handle before and after. It also checks that no graph-tableINSERTin the dump still starts with a text id. Without the fix it fails (1 pass, 1 fail); with the fix, 2 pass.Round trip with the compiled binary
After
bun run cli:build,open+observe+noteinto recorda,dump,restoreintob, then comparegetandwhyoutput between the two records:bun run check:quick: all 25 passed.A dump written before this change still contains the text ids, so it still fails to restore. Restoring it needs a fresh dump from the source record.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FWZHuy7xJbVqxyLipnvwdY