Skip to content

fix: ProjectMind V2 hardening β€” stable identity, visibility enforcement, dry-run retrieval - #19

Merged
hemang-doshi merged 1 commit into
mainfrom
fix/projectmind-v2-hardening
Jun 28, 2026
Merged

fix: ProjectMind V2 hardening β€” stable identity, visibility enforcement, dry-run retrieval#19
hemang-doshi merged 1 commit into
mainfrom
fix/projectmind-v2-hardening

Conversation

@hemang-doshi

Copy link
Copy Markdown
Owner

Summary

ProjectMind hardening pass fixing critical architecture issues identified in the V2 audit.

Changes

Stable Project Identity

  • project_id persisted to .agent-memory/config.json on init (stable UUID, not path-derived)
  • Opening from subdirectory or renamed/moved repo resolves same identity
  • openProject() reconciles config project_id with DB row; updates root on move

Shared Visibility Gate

  • src/core/memory-visibility.ts β€” single source of truth
  • Supersession fix: old memory hidden only if superseding memory is visible
  • MCP listMemoriesReadOnly() now applies visibility gate
  • All agent-facing paths (retrieve, preflight, MCP pack, MCP list) use same gate

Non-Mutating Explain/Dry-Run

  • retrieveMemories({ dryRun: true }) skips markMemoriesRetrieved + event
  • explain-retrieval always passes dryRun: true

Enforceable Preflight + agentmem run

  • preflight --enforce sets exit codes (block=2, warn=1)
  • agentmem run -- <cmd>: preflight-gated command execution

Candidate Metadata Preservation

  • Approved candidates preserve paths/tags from candidate metadata

Docs

  • snapshot.md rewritten for V2 with honest limitations

New Tests

  • tests/project-identity.test.ts (3 tests: init, move, subdirectory)

Verification

pnpm typecheck   β†’ zero errors
pnpm test        β†’ 32 files, 184 tests, zero failures
pnpm build       β†’ clean

…orcement

Phase 1 β€” Stable Project Identity:
- Add project_id to config; generate stable UUID on init, persist to .agent-memory/config.json
- openProject() reconciles config project_id with DB row; tolerates moved/renamed repos
- Add getProjectById() and updateProjectRoot() to repository
- Tests: repo move preserves memory visibility, subdirectory resolves same identity

Phase 2 β€” Shared Visibility Gate:
- Create src/core/memory-visibility.ts with isAgentVisibleMemory() + selectAgentVisibleMemories()
- selectAgentVisibleMemories() fixes supersession: old hidden only if superseder is visible
- MCP listMemoriesReadOnly() now applies visibility gate (was: raw status/type filter)
- All agent-facing paths (retrieve, preflight, MCP) use same gate

Phase 5/6 β€” Non-mutating Retrieval + Enforceable Preflight:
- retrieveMemories() accepts dryRun: true; skips markMemoriesRetrieved + event write
- explain-retrieval always passes dryRun: true
- preflight --enforce sets exit code (block=2, warn=1, allow=0)
- agentmem run -- <cmd>: preflight gates command execution, records result event

Phase 8 β€” Candidate Metadata Preservation:
- Candidate paths/tags preserved on approval from existing.metadata

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
@hemang-doshi
hemang-doshi force-pushed the fix/projectmind-v2-hardening branch from a95d085 to 76dfd2a Compare June 28, 2026 19:45
@hemang-doshi
hemang-doshi merged commit f00a8b2 into main Jun 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant