Repository navigation
feat(identity): schema v29 — portable project key, host, profile; remote checkpoint/resume - #15
Merged
Merged
Conversation
…ote checkpoint/resume
ADR-0009 §3/§4/§7. A local realpath cannot key work across the Mac, Linux
and WSL. Checkpoints now carry project_key (normalized git origin remote,
else ENGRAM_PROJECT_KEY, else host:realpath), host and profile
(ENGRAM_PROFILE); the unique key is (project_key, host, profile,
session_id). SQLite cannot drop the old UNIQUE(project_path, session_id)
in place, so v29 rebuilds the table and backfills legacy rows with
project_key = project_path, host = this machine, profile = default.
- src/identity.py: normalize_remote_url, project_key_for, host_name,
profile_name (one git subprocess at most, no DB)
- checkpoint: upsert/milestone take project_key/host/profile; resume
matches key OR path, profile-scoped by default (--all-profiles), shows
the originating host, computes "commits since" only for this host's
checkpoints; Stop hook prefers last_assistant_message over the
transcript tail; echo detection refactored to run from text
(record_echoes_from_text) so the server can do it without the
client's transcript
- provenance: code-set column on mistakes/patterns/skills/conversations/
prompts ('local' | 'remote:<host>'); memory_ops.create_* take
provenance=, MCP add handlers forward it, the server sets it (a caller
cannot forge it)
- schema_meta.instance_id set by init_db (ensure_instance_id)
- serve: POST /v1/checkpoint (204) and GET /v1/resume
- migration test for v29 (rebuild, backfill, index, old UNIQUE gone,
provenance default); identity tests; checkpoint tests (two hosts, one
session; profile scoping; legacy rows; last_assistant_message; echoes
from text); serve tests (checkpoint→resume across hosts, provenance
stamp, caps matrix)
Verification: ruff clean, pyright 0 errors, Cloak 0 errors, full suite
1480 passed after regenerating docs/COMMANDS.md (the command-reference
test caught the new --all-profiles flag before the regen).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
7 of 18 tasks
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.
Summary
Second server-side slice of ADR-0009 Phase 1 (#12): the identity migration and the two endpoints that depended on it.
Schema v29
checkpointsgainsproject_key,host,profile; unique key becomes(project_key, host, profile, session_id). SQLite cannot drop the oldUNIQUE(project_path, session_id)in place, so the migration rebuilds the table and backfills legacy rows withproject_key = project_path,host = <this machine>,profile = default.provenancecolumn (local|remote:<host>).memory_ops.create_*takeprovenance=, the MCP add handlers forward it, and the server sets it — a caller cannot forge it. Same mechanism as the v27 relation edges, as the portable-brains plan proposed.schema_meta.instance_id, set byinit_db.Identity (
src/identity.py):project_key_for()= normalized gitoriginremote (every spelling ofgithub.com/owner/repocollapses to one key) →ENGRAM_PROJECT_KEY→host:realpath.host_name(),profile_name()(ENGRAM_PROFILE, defaultdefault). One git subprocess at most, no DB.Checkpoints and resume
upsert_checkpoint/record_milestonetake the three identity fields; local callers compute them, the server passes what the client sent.engram resumematches on key OR path (legacy rows stay reachable), is profile-scoped by default (--all-profileswidens), shows the originating host, and computes "commits since" only against this machine's own checkpoints.last_assistant_messageover the transcript tail (the docs say the file "may lag").record_echoes_from_text), so the server can do it without the client's transcript; the transcript path remains as fallback.Server:
POST /v1/checkpoint(answers 204 — a Stop hook that returned context would keep Claude working) andGET /v1/resume?project_key=&profile=&host=&all_profiles=&limit=.Verification
last_assistant_message, echoes from text); serve (checkpoint→resume across hosts, provenance stamp, caps matrix)--all-profilesflag beforedocs/COMMANDS.mdwas regenerated; regenerated and re-run green.Rebased onto main after #14 merged.
🤖 Generated with Claude Code