feat: add greplica graph promote to commit working memory into main - #109
Open
burrows99 wants to merge 2 commits into
Open
feat: add greplica graph promote to commit working memory into main#109burrows99 wants to merge 2 commits into
greplica graph promote to commit working memory into main#109burrows99 wants to merge 2 commits into
Conversation
Working memory (the working scope) kept accumulating with no way to move it into the committed main scope, so the boundary between stable repo facts and active session edits kept blurring. This adds `greplica graph promote`. It moves every working-scope membership into the main scope under one new main memory commit, then clears working. Claims travel together with their edges, so a `supersedes` edge that retires a main claim is promoted along with its new claim and the retirement survives once working is empty. Object rows are keyed by (repo_id, id) and are left in place; both scopes belong to the same repo, so promotion only re-homes this repo's memberships. Running it on an empty working scope is a no-op. A scripts/check-graph-promote.js smoke test covers the move, the cleared working scope, the preserved supersession, and the no-op, and is wired into npm test. Closes Autoloops#22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
After demo: the same flow now works. graph promote moves working memory into main and clears working, and a second run confirms working is empty. after.mp4 |
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
Adds
greplica graph promote, which commits the working scope into main.Working memory (the
workingscope) is where a session's new claims, flows,components and edges land. Until now nothing moved them into the committed
mainscope, so working memory grew without bound and the line between stablerepo facts and active session edits kept blurring (#22).
graph promotemoves every working membership into main under one new mainmemory commit, then clears working:
Running it again is a no-op:
The design fork: supersession
readGraphdecides which claims are live by walkingsupersedesedges acrossthe union of main and working (
activeSubjectKeys). A working claim usuallysupersedes an older main claim through a
supersedesedge. If promote moved theclaim but left that edge behind, clearing working would bring the stale main
claim back to life.
So promote moves every working membership together, claims and their edges, under
one main memory commit. The
supersedesedge lands in main next to the new claimand the retired claim stays retired.
check-graph-promote.jsasserts exactlythis: it seeds a v1 claim in main, a v2 claim plus a
supersedesedge in working,promotes, and checks that v1 is still retired once working is emptied.
I raised this fork on the issue and went with emptying working (dropping the
working memberships) rather than leaving a tombstone commit. I can switch to a
tombstone if maintainers prefer that.
Scope of this first pass
The issue sketches
graph promote [--scope <scope_id>]. Today there is one fixedworking scope per repo (
requireWorkingScope), so there is no other scope totarget yet. This pass promotes the whole working scope with no flag; a
--scopeselector fits once session or branch scopes exist (#20).
Layering and safety
apps/cli/main.ts: thegraph promotecommand, handler and printer.libs/knowledge-graph/service.ts:promoteWorkingorchestration.libs/storage/sqlite/repository.ts:promoteWorkingToMain, one transaction.libs/knowledge-graph/graph-promote.ts: the purecountPromotedSubjectstally.scripts/check-graph-promote.js: smoke test, wired intonpm test.Object rows are keyed by
(repo_id, id)since #107 and are left untouched.Both scopes belong to the same repo, so promotion only re-homes memberships,
never object rows.
Testing
npm run typecheckclean.npm testgreen, including the newcheck-graph-promote.js.Before and after demos are in the thread below.
Closes #22