Skip to content

fix/legacy prose implicit worktree scope - #1156

Closed
wrightpt wants to merge 63 commits into
rohitg00:mainfrom
wrightpt:fix/legacy-prose-implicit-worktree-scope
Closed

fix/legacy prose implicit worktree scope#1156
wrightpt wants to merge 63 commits into
rohitg00:mainfrom
wrightpt:fix/legacy-prose-implicit-worktree-scope

Conversation

@wrightpt

@wrightpt wrightpt commented Aug 5, 2026

Copy link
Copy Markdown
  • feat: harden session context and workstation tool surface
  • fix: preserve session activity time during context migration
  • feat: expose deployment source revision in health
  • fix: keep viewer stream updates transient
  • fix action list pagination
  • chore add AgentMemory project scope
  • Decouple hook capture from synchronous observe
  • Await asynchronous hook transport acknowledgements
  • fix: make observation ingestion durable
  • build: rebuild runtime before npm pack
  • fix: prevent duplicate worker registration
  • feat: add stateless Streamable HTTP MCP transport
  • fix invocation bookkeeping leak
  • chore: refresh generated skill reference
  • fix hooks: bound project scope traversal
  • chore: refresh generated hook scripts
  • test: compare canonical project paths
  • fix(actions): exclude blocked work from frontier
  • feat: add Actions v2 schema and migration
  • fix: harden Actions v2 migration invariants
  • fix(actions): compare normalized rows semantically
  • fix(actions): coerce undefined state::get results to null at the StateKV boundary
  • docs: record iii-engine state semantics and workstation deploy path
  • feat(actions): add mem::action-gc terminal-action pruning
  • ci: retire push/PR triggers to workflow_dispatch (local-builds quota policy)
  • feat: add curated workstation LLM tool profile
  • fix: normalize sentence punctuation in URL checks
  • feat: complete workstation LLM MCP surface
  • feat(actions): add bounded graph snapshot reads
  • fix(lessons): accept omitted sort order
  • feat(lessons): add audited correction API (ExportImportInputSchema rejects current v0.4.0 exports #17)
  • feat(lessons): add causal schema foundation
  • fix: harden causal lesson schema invariants
  • fix: fail closed on unavailable lesson evidence
  • fix(viewer): render structured lesson facets
  • feat: enforce causal lesson access policy
  • fix: fail closed on lesson access edge cases
  • fix: close causal lesson access boundaries
  • fix: harden remaining lesson access boundaries
  • feat: add authorized causal lesson hybrid retrieval
  • fix(memories): clear dangling supersedes/parentId/relatedIds on delete + heal
  • fix(diagnostics): review corrections — gate honesty + concurrency safety
  • fix(lessons): allow implicit worktree scope for legacy prose saves

Summary by CodeRabbit

  • New Features

    • Added Streamable HTTP MCP support with authentication, origin controls, health checks, and secure remote access.
    • Added workstation tools for session enrichment, diagnostics, flow compression, and LLM connectivity checks.
    • Added structured causal lessons with hybrid retrieval, evidence metadata, lifecycle controls, authorization, deletion, and supersession.
    • Expanded action management with readiness views, approvals, scheduling, ownership, pagination, graphs, revisions, and migration.
    • Added asynchronous observation ingestion with durable queue receipts and idempotent observation IDs.
    • Added caller identity and token support across integrations.
  • Documentation

    • Updated setup guides, configuration references, tool listings, and API documentation.

wrightpt added 30 commits July 9, 2026 23:28
…tion

Merge workstation AgentMemory hardening stack
Add canonical AgentMemory project scope
Decouple hook capture from synchronous observe
Await asynchronous hook transport acknowledgements
Make observation ingestion durable and report disabled LLM work as skipped
Build runtime assets automatically before npm packaging.
Prevent duplicate workers from unregistering live AgentMemory routes.
Add resilient Streamable HTTP MCP transport
Exclude blocked actions from AgentMemory frontier
wrightpt and others added 26 commits July 27, 2026 23:37
ci: retire push/PR triggers to workflow_dispatch (local-builds quota policy)
feat: add curated workstation LLM tool profile
fix: ignore sentence punctuation in compression URL checks
Complete workstation DeepSeek MCP surface
Add idempotent, audited lesson deletion and supersession through the existing StateModule authority. Expose validated REST and MCP surfaces, prevent silent resurrection, regenerate interface documentation, and isolate embedding-provider tests from workstation environment state. Validated locally: npm test (1,560 passed), npm run build, npm run skills:check, git diff --check.
feat(lessons): add causal lesson schema foundation
feat: enforce causal lesson access policy
…eval-v3

feat: add authorized causal lesson hybrid retrieval
…e + heal

Root cause (D2): mem::governance-delete and mem::governance-bulk deleted a
memory without clearing supersedes/parentId/relatedIds back-references in
*other* memories, so every delete minted new memory-missing-supersedes
warnings. The heal path could not repair them either (the warn was
fixable=false and no prune branch existed).

Changes (code-only; no live data touched, no restart/deploy):
- src/state/memory-utils.ts: add pure stripMemoryReferences() that drops
  references to a given id set from supersedes/parentId/relatedIds and
  reports what was removed. Shared by governance and diagnostics.
- src/functions/governance.ts: governance-delete and governance-bulk now
  call clearDanglingMemoryReferences() on surviving memories after a
  delete, returning repairedReferrers + removedReferences in the result
  and audit details. Indexes untouched (ref fields are not searchable).
- src/functions/diagnostics.ts:
  * memory-missing-supersedes warn is now fixable=true.
  * add memory-missing-parent and memory-missing-related warn detection.
  * add a memories heal branch that prunes dangling supersedes/parentId/
    relatedIds (dry-run supported), audited as reason
    "dangling-memory-reference-prune".
- Honest project-coverage messaging (D3): the diagnostic no longer
  blindly prescribes infer-memory-projects. It splits the unscoped count
  into session-linked (inferable) vs session-less (ambiguous; the
  migration returns them unchanged), and says so explicitly — verified
  live that infer-memory-projects is updated=0/ambiguous=128 here.

Tests: +8 in test/diagnostics.test.ts and test/governance.test.ts
covering delete cleanup (single + bulk), heal prune (apply + dry-run),
the new parentId/relatedIds warns, and the honest coverage messages.
Full suite: 1699 passed (160 files). Build: tsdown OK.

Not pushed, not merged, not deployed, not activated. The diverged local
main (ahead 2 / behind 13) is untouched. The running engine build is
unchanged; these changes take effect only after a supervisor-authorized
build + systemctl restart agentmemory.service, at which point the
existing dangling references can be pruned via
mem::heal {categories:["memories"]} (dry-run first).

Refs: AgentMemory action act_msfdnoby_4609034b3c0f (workstation)
Code-only supervisor review corrections for 6c27da2. No live mutation,
no restart/deploy.

(1) blocked-deps-done false-positive guard (the rebound root cause):
- src/functions/actions.ts: export hasExplicitNonDependencyGate() — true
  when an action is held by blockedReason / awaitingHuman / pending-or-
  rejected approval / an unsatisfied gated_by checkpoint (i.e. NOT by its
  requires-deps alone).
- diagnostics.ts diagnosis: only flag blocked-deps-done (fixable) when the
  block is dependency-only; explicitly-gated actions are intentionally
  blocked and are no longer flagged.
- diagnostics.ts heal: the blocked-deps-done branch now skips explicitly-
  gated actions (returns false -> skipped), so heal no longer churns
  revisions or writes a misleading newStatus=pending audit for actions
  legacyStatusFor would immediately re-block.

(2) Honest project-coverage fixability: fixable = inferableCount > 0. When
  every unscoped memory lacks sessionIds the infer-memory-projects
  migration is a no-op, so the finding is not auto-fixable.

(3) clearDanglingMemoryReferences concurrency: each survivor is now
  repaired under its per-memory keyed lock (mem:memory:<id>) with a fresh
  read immediately before strip/write, so a concurrent survivor update is
  preserved instead of clobbered by a stale snapshot.

(4) Removed the untracked node_modules symlink from the worktree.

Tests (+4): diagnose "explicit human/approval/blockedReason gates not
flagged"; heal "does not unblock an explicit-gate action"; governance
concurrency "preserves a concurrent survivor update" and "does not clobber
a concurrently-corrected survivor" (both fail on the pre-fix code).
Project-coverage tests gained fixable assertions (zero-candidate=false,
mixed=true). Full suite 1703 passed (160 files); tsdown build OK. git
status clean (node_modules symlink removed).

Not pushed, not merged, not deployed, not activated. REBOUND-INVESTIGATION
conclusions unchanged (the three live actions remain correctly blocked by
their approval gates; this commit just stops flagging/healing them).

Refs: AgentMemory action act_msfdnoby_4609034b3c0f (workstation)
fix(memories): repair dangling references and diagnostic false positives
The causal schema foundation (495b051) tightened scope validation but the
three write entry points (mem::lesson-save, api::lesson-save REST, and the
memory_lesson_save MCP handler) parse input without
allowImplicitWorktreeScope, so every scope-less legacy prose save fails
with 'scope.scopeId is required for non-global explicit scopes'. The
causal-lesson-schema-v1 spec mandates: 'Legacy prose lessons retain the
fail-closed implicit worktree scope for compatibility' and 'Legacy
prose-only saves remain valid'.

Restore the spec behavior at all three entry points. Structured causal
lessons still require an explicit durable scope (that guard is independent
in parseLessonSaveInput and is now regression-tested). No change to global
scope humanApproval, access enforcement, or FORCE_PROXY semantics.
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@wrightpt wrightpt closed this Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a542180-2183-4217-ae46-72c24800f0e0

📥 Commits

Reviewing files that changed from the base of the PR and between d60652a and abfc83e.

⛔ Files ignored due to path filters (2)
  • assets/tags/light/stat-tools.svg is excluded by !**/*.svg
  • assets/tags/stat-tools.svg is excluded by !**/*.svg
📒 Files selected for processing (189)
  • .agentmemory/project.json
  • .env.example
  • .github/workflows/ci.yml
  • AGENTS.md
  • CHANGELOG.md
  • INSTALL_FOR_AGENTS.md
  • README.md
  • docs/superpowers/specs/2026-07-17-actions-v2-design.md
  • docs/superpowers/specs/2026-08-02-causal-lesson-schema-v1.md
  • docs/superpowers/specs/2026-08-03-causal-lesson-access-v2.md
  • docs/superpowers/specs/2026-08-03-causal-lesson-hybrid-retrieval-v3.md
  • iii-config.docker.yaml
  • iii-config.yaml
  • integrations/hermes/README.md
  • integrations/hermes/__init__.py
  • integrations/openclaw/README.md
  • integrations/openclaw/plugin.mjs
  • integrations/pi/README.md
  • integrations/pi/index.ts
  • integrations/pi/security.ts
  • package.json
  • packages/mcp/README.md
  • packages/mcp/bin.mjs
  • plugin/.claude-plugin/plugin.json
  • plugin/.codex-plugin/plugin.json
  • plugin/.mcp.copilot.json
  • plugin/.mcp.json
  • plugin/opencode/README.md
  • plugin/opencode/agentmemory-capture.ts
  • plugin/plugin.json
  • plugin/scripts/notification.mjs
  • plugin/scripts/post-commit.mjs
  • plugin/scripts/post-tool-failure.mjs
  • plugin/scripts/post-tool-use.mjs
  • plugin/scripts/pre-compact.mjs
  • plugin/scripts/pre-tool-use.mjs
  • plugin/scripts/prompt-submit.mjs
  • plugin/scripts/session-end.mjs
  • plugin/scripts/session-start.mjs
  • plugin/scripts/stop.mjs
  • plugin/scripts/subagent-start.mjs
  • plugin/scripts/subagent-stop.mjs
  • plugin/scripts/task-completed.mjs
  • plugin/skills/agentmemory-config/REFERENCE.md
  • plugin/skills/agentmemory-mcp-tools/REFERENCE.md
  • plugin/skills/agentmemory-rest-api/REFERENCE.md
  • src/cli.ts
  • src/cli/connect/util.ts
  • src/config.ts
  • src/eval/metrics-store.ts
  • src/functions/action-model.ts
  • src/functions/action-query.ts
  • src/functions/action-readiness-refresh.ts
  • src/functions/action-store.ts
  • src/functions/actions-v2-migration.ts
  • src/functions/actions.ts
  • src/functions/audit.ts
  • src/functions/checkpoints.ts
  • src/functions/compress-file.ts
  • src/functions/compress.ts
  • src/functions/consolidation-pipeline.ts
  • src/functions/context.ts
  • src/functions/crystallize.ts
  • src/functions/diagnostics.ts
  • src/functions/disk-size-manager.ts
  • src/functions/evict.ts
  • src/functions/export-import.ts
  • src/functions/frontier.ts
  • src/functions/governance.ts
  • src/functions/image-quota-cleanup.ts
  • src/functions/image-refs.ts
  • src/functions/leases.ts
  • src/functions/lesson-access.ts
  • src/functions/lesson-locks.ts
  • src/functions/lesson-model.ts
  • src/functions/lesson-retrieval.ts
  • src/functions/lessons.ts
  • src/functions/llm-smoke.ts
  • src/functions/mesh.ts
  • src/functions/migrate.ts
  • src/functions/observe.ts
  • src/functions/obsidian-export.ts
  • src/functions/reflect.ts
  • src/functions/remember.ts
  • src/functions/replay.ts
  • src/functions/routines.ts
  • src/functions/sentinels.ts
  • src/functions/session-context.ts
  • src/functions/session-list.ts
  • src/functions/sketches.ts
  • src/functions/smart-search.ts
  • src/functions/summarize.ts
  • src/hooks/_observe.ts
  • src/hooks/_project.ts
  • src/hooks/notification.ts
  • src/hooks/post-tool-failure.ts
  • src/hooks/post-tool-use.ts
  • src/hooks/pre-compact.ts
  • src/hooks/prompt-submit.ts
  • src/hooks/session-start.ts
  • src/hooks/subagent-start.ts
  • src/hooks/subagent-stop.ts
  • src/hooks/task-completed.ts
  • src/index.ts
  • src/mcp/http-error.ts
  • src/mcp/http.ts
  • src/mcp/plaintext-credential.ts
  • src/mcp/rest-proxy.ts
  • src/mcp/server.ts
  • src/mcp/standalone.ts
  • src/mcp/tools-registry.ts
  • src/prompts/reflect.ts
  • src/providers/noop.ts
  • src/providers/resilient.ts
  • src/state/kv.ts
  • src/state/memory-utils.ts
  • src/state/schema.ts
  • src/triggers/api.ts
  • src/triggers/events.ts
  • src/types.ts
  • src/utils/trigger-detached.ts
  • src/viewer/index.html
  • src/viewer/server.ts
  • src/worker-pidfile.ts
  • test/actions-api-pagination.test.ts
  • test/actions-gc.test.ts
  • test/actions-v2-migration.test.ts
  • test/actions-v2.test.ts
  • test/actions.test.ts
  • test/api-llm-state.test.ts
  • test/api-observe-async.test.ts
  • test/api-workstation-llm-tools.test.ts
  • test/auto-compress.test.ts
  • test/causal-lessons-api.test.ts
  • test/cli-connect.test.ts
  • test/cli-replay-headers.test.ts
  • test/compress-disabled.test.ts
  • test/compress-file.test.ts
  • test/consistency.test.ts
  • test/consolidation-pipeline.test.ts
  • test/context-lessons.test.ts
  • test/copilot-plugin.test.ts
  • test/detached-trigger.test.ts
  • test/diagnostics.test.ts
  • test/embedding-provider.test.ts
  • test/env-loader.test.ts
  • test/export-import.test.ts
  • test/frontier.test.ts
  • test/governance.test.ts
  • test/hermes-plugin.test.ts
  • test/hook-observation-client.test.ts
  • test/hook-project.test.ts
  • test/integration-plaintext-http.test.ts
  • test/leases.test.ts
  • test/lesson-access.test.ts
  • test/lesson-authorization.test.ts
  • test/lesson-corrections.test.ts
  • test/lesson-model.test.ts
  • test/lesson-retrieval.test.ts
  • test/lessons-api-pagination.test.ts
  • test/lessons.test.ts
  • test/llm-execution-state.test.ts
  • test/llm-smoke.test.ts
  • test/mcp-http.test.ts
  • test/mcp-llm-tools.test.ts
  • test/mcp-plaintext-credential.test.ts
  • test/mcp-standalone-proxy.test.ts
  • test/mcp-standalone.test.ts
  • test/mcp-surface-default.test.ts
  • test/metrics-store.test.ts
  • test/observe-implicit-session.test.ts
  • test/obsidian-export.test.ts
  • test/project-manifest.test.ts
  • test/queue-config.test.ts
  • test/reflect.test.ts
  • test/replay-import-key.test.ts
  • test/session-context.test.ts
  • test/session-end-triggers-graph.test.ts
  • test/session-list.test.ts
  • test/session-start-event-authorization.test.ts
  • test/smart-search.test.ts
  • test/state-kv.test.ts
  • test/stop-worker-pidfile.test.ts
  • test/summarize.test.ts
  • test/tool-count-consistency.test.ts
  • test/viewer-host.test.ts
  • test/viewer-lessons-schema.test.ts
  • test/worker-pidfile.test.ts
  • tsdown.config.ts

📝 Walkthrough

Walkthrough

This PR adds Actions v2 persistence and migration, structured causal lessons with authorization and hybrid retrieval, Streamable HTTP MCP support, asynchronous observation ingestion, LLM execution-state reporting, expanded workstation tools, session pagination, and updated integrations, documentation, and tests.

Changes

AgentMemory platform expansion

Layer / File(s) Summary
Actions v2 storage and workflows
src/functions/action-*.ts, src/functions/actions.ts, src/functions/leases.ts, src/functions/checkpoints.ts, src/functions/sentinels.ts, src/types.ts
Actions use normalized typed fields, locked event-sourced persistence, readiness classification, revisions, pagination, graph snapshots, migration, and garbage collection.
Causal lessons and access control
src/functions/lesson-*.ts, src/functions/lessons.ts, src/functions/reflect.ts, src/triggers/api.ts, src/mcp/server.ts
Lessons support structured schemas, evidence, lifecycle and scope metadata, authorization contexts, hybrid retrieval, corrections, export controls, and access-aware projections.
MCP, API, and workstation operations
src/mcp/*, src/cli.ts, src/triggers/api.ts, src/functions/llm-smoke.ts, src/functions/session-*.ts
The project adds Streamable HTTP MCP transport, workstation tools, LLM smoke testing, session context updates, bounded session queries, and expanded REST routes.
Observation, hooks, and integrations
src/hooks/*, plugin/scripts/*, src/functions/observe.ts, integrations/*, src/utils/trigger-detached.ts
Observation delivery uses asynchronous queue submission, richer project context, caller identity headers, bounded acknowledgements, durable observation IDs, and detached SDK triggers.
Runtime, viewer, packaging, and validation
src/config.ts, src/eval/metrics-store.ts, src/viewer/*, src/worker-pidfile.ts, package.json, tsdown.config.ts, test/*
LLM skips are measured separately, worker startup uses pidfile leases, the viewer renders structured lesson data, HTTP output is packaged, and comprehensive tests cover the new behavior.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • rohitg00/agentmemory#315: Extends plaintext HTTP credential guards in the same integrations to support caller tokens.
  • rohitg00/agentmemory#687: Shares the hook project-context resolution and asynchronous observation transport changes.
  • rohitg00/agentmemory#1132: Provides related lesson-deletion functionality expanded here with authorization, locking, lifecycle, and supersession handling.
✨ Finishing Touches 💡 2
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch fix/legacy-prose-implicit-worktree-scope
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@wrightpt
wrightpt deleted the fix/legacy-prose-implicit-worktree-scope branch August 6, 2026 00:24
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