feat(memory): project identity and global namespace - #533
Open
initializ-mk wants to merge 1 commit into
Open
initializ-mk wants to merge 1 commit into
initializ-mk wants to merge 1 commit into
Conversation
Introduce the foundation for a unified global memory store under
~/.forge/memory with two ownership namespaces:
projects/<project-id> coding-session memory keyed by git remote
agents/<agent-id> deployed-agent operational memory keyed by agent_id
- ProjectID: sha256(normalized git remote)[:12] with a local-<hash>
fallback so equivalent remote URLs collapse and distinct local
checkouts never do. AgentID normalizes forge.yaml agent_id to a
filesystem-safe segment.
- Registry: JSON map (projects.json / agents.json) id -> entry,
unioning local paths across checkouts; atomic writes.
- NewGlobalFileStore(root, namespace, id) with a single-segment path
guard; NewFileStore retained for repo-local use.
- MigrateRepoLocal: copies repo-local .forge/memory into
agents/<agent-id>/, mapping daily logs to sessions/, leaving the
source intact with a .migrated sentinel (idempotent).
- forge memory {migrate,projects,agents} CLI.
- Add atomic-write helper (temp -> fsync -> rename) for all new writes.
- Fix FileVectorStore.Search silently clamping k<=0 to 10, which
capped keyword-only full scans.
Tests: TestProjectID, TestAgentID, TestRegistry, TestMigrate,
TestNormalizeRemote.
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.
Phase 0 of the semantic-memory + procedural-rework track
Establishes the foundation for a unified global memory store at
~/.forge/memorywith two ownership namespaces that never cross-contaminate:projects/<project-id>/agents/<agent-id>/forge.yamlagent_idThis PR lands only the identity + namespace + migration primitives and the
forge memoryCLI. Later phases build the card, exports, procedure rework, promotion ladder,context_load, and the optimizer rewire on top.What's here
ProjectID(worktree)=sha256(normalized remote)[:12], with alocal-<hash>fallback.NormalizeRemotecollapses scp/https/ssh forms + credentials + ports +.gitso equivalent URLs map to one id; distinct local checkouts never collapse.AgentID(raw)normalizes aforge.yamlagent_id into a filesystem-safe segment.Registry— JSON map (projects.json/agents.json) of id → entry, unioning local paths across checkouts. Atomic writes.NewGlobalFileStore(root, namespace, id)with a single-segment path guard (traversal barrier).NewFileStoreretained for repo-local use.MigrateRepoLocal— copies a repo-local.forge/memoryintoagents/<agent-id>/, mapping daily logs (YYYY-MM-DD.md) intosessions/. Copy, not move: the source is left intact with a.migratedsentinel, so it's idempotent and nothing is stranded for a still-repo-local runtime.forge memory {migrate,projects,agents}CLI (migrate --dry-run,--dir).Incidental fixes (from grounding the spec against real code)
FileVectorStorehad a partial temp→rename (no fsync).FileVectorStore.Searchsilently clampingk<=0to 10, which capped keyword-only full scans. It now returns the whole corpus fork<=0.Gate (all green)
go test ./forge-core/memory/... -run 'TestProjectID|TestAgentID|TestRegistry|TestMigrate' -v✅go vet ./forge-core/memory/...✅forge memory migrate --dry-run/forge memory projects/forge memory agentsexercised end-to-end in a sandbox HOME ✅gofmtclean.