feat(undo): metadata table + 0.7 format-migration boundary#44
Merged
Conversation
Adds a fourth per-app companion table tigerfs.<app>_metadata for non-operational events about a workspace -- sibling of _history, _log, _savepoint. The 0.6→0.7 migration appends one row with subject='history-format-migration' as its final step; the undo engine refuses any undo whose target precedes that row's entry_id. Why this is needed ADR-017's relational-directory migration rewrites <app>_history rows' parent_id from the *current* source state, not historical state. For files moved between directories before the migration, the historical parent_id is destroyed. Pre-migration log entries are structurally valid against the new schema but semantically unsafe to undo: an undo of an old "edit" that was actually a directory rename would silently restore content while leaving the row at its current location, with no signal to the user. Mechanism - New table tigerfs.<app>_metadata (entry_id UUIDv7 PK, subject TEXT, user_id TEXT, description TEXT, payload JSONB). Created by build.go for fresh installs and by addParentPointerMigration for upgrades. - Subject values and the "_metadata" suffix are defined once in fs/synth/metadata.go and referenced by every consumer. No literal strings inline. - loadSynthCache queries metadata at mount time for history-enabled apps, caches in ViewInfo.Metadata. Soft-fails to nil on transient DB errors -- fail-open is the right default (the alternative would refuse all undo on a momentary DB hiccup). - fs/undo.go gains blockingSubjects (a hard-coded map of subjects that block undo) and checkBoundary, wired into ExecuteUndoSingle and ExecuteUndo. Engine owns the blocking-set decision; the metadata table records facts, not policy. Refuse policy If any blocking-subject entry has entry_id > target_log_id, the whole undo is refused -- no partial work, no silent skip. Applies to all three entry points (single, to-log-id, to-savepoint). Tests - Unit: 12 cases for checkBoundary, 3 cache-load cases, DB round-trip + soft-fail. - Integration: TestSynth_MigrateAddParentPointer extended with the full 0.6 fixture → migrate → boundary verification flow (block via ExecuteUndoSingle and ExecuteUndoToLogID, allow via post-migration edit + ExecuteUndoToSavepoint + ExecuteUndoToLogID, idempotency). TestSynth_FreshInstall_MetadataFastPath validates that workspaces that never migrated have an empty metadata table and zero per-undo overhead. Behavioral impact Pre-v0.7 log entries in upgraded workspaces remain readable in .log/ and .history/ but cannot be undone -- noted in docs/history.md Limitations and docs/spec.md § Migration Boundaries. See ADR-019 for the design rationale and alternatives considered.
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.
tigerfs.<app>_metadata(sibling of_history/_log/_savepoint) fornon-operational events about a workspace. UUIDv7
entry_idPK in the same clock domain aslog_id, plussubject,user_id,description,payload JSONB.subject = 'history-format-migration'as its final step. Theundo engine refuses any undo whose target precedes the row's
entry_id(single, to-log-id, and to-savepoint flows;all-or-nothing — no partial work). Error surfaces as
EPERMwith the row'sdescriptionas the hint.parent_idfrom the currentsource state, not historical state. For files moved between directories pre-migration, the historical location is
destroyed — undoing such an entry would silently restore content while leaving the row at its current directory with
no signal. Pre-migration entries stay readable in
.log/and.history/; only.undo/refuses._metadatasuffix live ininternal/tigerfs/fs/synth/metadata.go; no literal strings inline. The undo engine's hard-codedblockingSubjectsmap owns the policy; the metadata table records facts.
checkBoundaryreturns nil immediately → zero per-undooverhead.
checkBoundary, 3 cache-load cases, DB round-trip + soft-fail, plus extendedTestSynth_MigrateAddParentPointer(full 0.6 fixture → migrate → block via ExecuteUndoSingle/ExecuteUndoToLogID;allow via post-migration edit/ExecuteUndoToSavepoint/ExecuteUndoToLogID; idempotency) and new
TestSynth_FreshInstall_MetadataFastPath.docs/spec.md§ Migration Boundaries,docs/history.md(Limitations bullet + four-companion-tablesupdate), and new
docs/adr/019-undo-boundary-via-metadata-table.mddocumenting alternatives considered.