Skip to content

feat(acp): expose Artifact and Memory Host operations - #5685

Merged
Sun-GLiang merged 6 commits into
apache:mainfrom
Sun-GLiang:feat/acp-artifact-memory-pr7
Sep 26, 2026
Merged

Sun-GLiang merged 6 commits into
apache:mainfrom
Sun-GLiang:feat/acp-artifact-memory-pr7

Conversation

@Sun-GLiang

@Sun-GLiang Sun-GLiang commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Expose Runtime Host Artifact and Memory operations through five explicit private ACP methods for query, ingest, delete, and mutation.
  • Reuse Host input validation and Session ownership checks, recover the lazy Host connection, clean up unfinished uploads, and avoid replaying an interrupted Memory mutation.
  • Surface canonical Artifact references in completed tool results and make Session Memory available to subsequent model requests. Add ACP client documentation and regression coverage.
  • After review, bound unresolved Artifact upload tracking while preserving uncertain outcomes and concurrent duplicate identities. Serialize expiry cleanup against same-ID requests and clear old tracking when the Host connection changes. Do not advertise missing or corrupt archived results as readable Artifacts.

Refs #3132

Verification

  • CLI build and typecheck passed. Full CLI test:dist: 1278 passed, 3 skipped, 0 failed.
  • Focused ACP registry, event mapper, and real ACP/Host child-process tests passed. New cases cover rejected and uncertain uploads, digest failures, expiry cleanup, concurrent begins, Host replacement, and unavailable archive references.
  • Repository lint, format check, and git diff --check passed. The current Host compatibility epoch is 188; this PR changes no Host wire schema.
  • Six selected new regression cases all failed in an isolated worktree at the preceding PR head a7e40a763; two concurrency/replacement cases also failed at efd5db120. All pass after repair. Earlier ablations and full validation are recorded in packages/cli/src/acp/VALIDATION.md.
  • Official ACP SDK tests exercise a real stdio ACP child against a real in-process Runtime Host, including Artifact byte round trips, Session-scoped Memory in subsequent provider input, and Host replacement recovery.
  • A third-party editor's private-extension UI was not smoke-tested.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex authored the implementation, tests, and documentation. Commits include a Generated-by: Codex trailer.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Resolve PR 6 integration conflicts, retain upload cleanup after conflicting requests, remove the stale adapter upload cap, and clear corrected tool Artifact references.

Generated-by: Codex
Tool result kinds are exclusive, so each result contributes at most one canonical Artifact reference. Keep the per-Session in-flight upload wait after its close-race ablation failed.

Generated-by: Codex
@Sun-GLiang
Sun-GLiang marked this pull request as ready for review September 25, 2026 14:42
Use the existing per-upload pending request count to defer cleanup while any ingest is in flight. Remove the separate begin counter and reference after isolated ablation confirms the behavior.

Generated-by: Codex

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the current head c1fb81cd98dc2d34f3bef1084827be4530a11649 against the unchanged PR base, including the new upload-tracking simplification. I found no substantiated P0–P3 issue in the inspected paths. The latest commit removes the separate pendingBegins counter and uses the existing per-upload pendingRequests counter to retain an identity until in-flight ingests settle; it preserves the same-ID cleanup wait and connection-availability reset. The rest of the PR adds ACP Artifact/Memory extension routing, Session ownership checks, Host-backed operations, upload cleanup, and regression coverage.

The current-head test check passed (run 36154233227). The PR diff passes git diff --check, and the current head merges cleanly with main in a local merge-tree calculation. I did not independently run the full suite or test a real Zed client or other platforms; repository branch-protection requirements were not readable through the API. Feature adoption and final merge readiness remain human decisions.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[kabi-grok] Review of exact head c1fb81cd98dc2d34f3bef1084827be4530a11649. Same GitHub owner as the coordinating agent, different model. I did not read other reviewers' comments.

I am not approving. Required test is completed/success. MERGEABLE / BLOCKED. Not a draft. I will not merge it.

Frame

Merge-base 9c96bb71657664c677c7024393f8847a6fb3ec4e. This SHA is behind live main (epoch on main is 189; this SHA still carries 188). The 11 files in this PR do not touch RUNTIME_HOST_COMPATIBILITY_EPOCH. Artifact/Memory are existing Host operations; ACP is a new client surface. Not bumping the Host epoch for that is correct.

Trust / ownership

Artifact query / ingest / delete always #assertOwned(input.sessionId) before dispatch and again beforeDispatch. That is the right gate for Session-scoped Artifact IDs. I did not find a path that substitutes another Session's sessionId without hitting unknown_session.

[P2] this pull request — memoryQuery has no Session ownership check. MemoryQueryInput has no sessionId (host-wide state / entries / documents). memoryMutate only #assertOwned when scope.kind === 'session'. Workspace-scoped mutate and every query go straight to #hostRequest. Entry projections include sessionId. An ACP client can therefore read (and workspace-mutate) Memory that belongs to Sessions this registry never owned, as long as it can talk to the Host. Artifact is Session-gated; Memory query is not. Tests cover unowned Artifact after close and session-scoped mutate after connection loss; they do not assert that memoryQuery is limited to owned Sessions.

Upload cleanup / same-ID reuse

Ingest tracking is keyed by [sessionId, uploadId]. begin waits for an in-flight cleanup of that key. Interrupted dispatched begin sets mayBeOpen. Session close waits #artifactOperations then aborts remaining uploads. TTL prune aborts expired IDs before the 64-cap rejects. Tests pin: lost dispatched begin aborted on close; close waits for in-flight begin; conflicting replay; failed commits do not eat the cap; Host replacement drops old tracking and only aborts fresh on the new connection (the previous Host is gone). Same-ID reuse after cleanup is tested.

Connection identity change clears #artifactUploads without aborting the old Host. That matches a dead connection; it is not a silent reuse on the new Host.

Verification bounds

Walked: session-registry.ts Artifact/Memory methods, #assertOwned, ingest tracking/cleanup/close, maka-acp-agent.ts extension routes, Memory protocol input shapes, epoch on this SHA vs live main, the new registry tests for ingest/close/reuse. Did not run the CLI test files locally. Did not read the GPT review. Did not audit Host-side Artifact/Memory authorization (unchanged in this PR).


Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one. Seat: kabi-grok.

简体中文

席位 kabi-grok。只绑 c1fb81cd9。不 approve。Artifact 有 #assertOwned(sessionId)。P2:memoryQuery 没有 Session 所有权检查,输入也没有 sessionId,可读到本 registry 未拥有的 Session 的 Memory。上传清理/同 ID 复用有测试。本 PR 不改 Host epoch(现有 Host 操作的 ACP 暴露)。

return this.#artifactRequest('artifact.delete', input);
}

async memoryQuery(input: MemoryQueryInput): Promise<MemoryQueryResult> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] memoryQuery calls #hostRequest with no #assertOwned. MemoryQueryInput has no Session id (host-wide state/entries/documents). memoryMutate only checks ownership when scope.kind === 'session'.

Artifact operations require an owned sessionId. Memory query therefore lets this ACP client read entries whose sessionId it never owned, if the Host connection can reach them. Either filter query results to #ownedSessionIds, require a Session scope on query, or document that Memory is operator/Host-wide and not Session-isolated.

Tests do not pin the unowned-query case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Withdrawing this P2 on c1fb81cd98dc2d34f3bef1084827be4530a11649.

I treated MemoryQueryInput as if it were Session-scoped like Artifact. It is not: kinds are only state / entries_* / document_*. There is no sessionId to #assertOwned. An entry projection's sessionId is origin metadata on a workspace store, not a tenant key.

Host memory.query (HostMemoryCoordinator.#query) authorizes with the connection's policy/activation (blockedByPolicy, agentReadEnabled) and reads the whole bundle. That is the access boundary. This PR only routes ACP onto that existing operation; I have no evidence that ACP credentials receive memory.query when they should not.

Not restating as a permission finding without that evidence.

Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one. Seat: kabi-grok.

@zhiiw zhiiw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (blind — I have not read the existing GPT review). Conclusions bind to c1fb81cd98dc2d34f3bef1084827be4530a11649 (CI test green on this head).

Verified locally (real Windows 11, Node 24.18.1 — the version CI pins), with the path/lock/large-file angle the request named:

  • Real child processes on Windows: acp-artifact-memory-child-process (the suite exercising Artifact byte round trips, Session-scoped Memory, and Host replacement through a real stdio child + real Host) — 4/5 assertions pass; the one "failure" is EBUSY unlinking the temp context-offload.sqlite at teardown (zero assertion failures across two runs — my machine's documented environment class, the same failure exists on the base for this fixture style, not this PR's account).
  • Registry/mapper/agent suites: 193/194 — the single failure is a pre-existing symlink EPERM environment test (no developer mode on this machine), unrelated to this PR.
  • Ablation (the dispatch's ask): reverting session-registry.ts to the author's named pre-review head a7e40a763 while keeping the tests → 4 of the 6 named regression cases fail (upload-limit exhaustion, rejected-begin accumulation, outcome-unknown cleanup, expired-identity abort) — the fixes are load-bearing. The other 2 (close aborts a possibly opened Artifact…, a conflicting replay…) pass with only that file reverted, i.e. their protection lives in the other changed files; the author's whole-tree ablation at a7e40a763 is consistent with this, and my narrower revert is the more precise attribution of which file carries which protection. Restored → 6/6 green.

Read in the production diff and agree with: Session ownership checks (#assertOwned) gate every new route; every extension request carries a timeout (30s, 5s for cleanup); unfinished uploads are bounded (64) with TTL + grace, cleanup serialized per upload key so a late abort cannot race a reused id; the connection-identity watch clears tracking state on Host replacement; close aborts still-open uploads; an interrupted begin keeps its uncertain outcome instead of replaying. The mayBeOpen bookkeeping keeps interrupted uploads reclaimable without double-aborting.

Not verified: the third-party editor's private-extension UI (not smoke-tested by the author either); the full CLI dist sweep (I ran the suites in this PR's blast radius, not all 1278); the VALIDATION.md record (cited, not rechecked).

No P0–P3 findings.


Automated review notice: This comment was posted by an automated review agent operated by zhiiw. It is not an independent human review and does not replace one.

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at c1fb81cd98dc2d34f3bef1084827be4530a11649 at the requester's ask. Reviews from three model families on this head found no P0–P2.

  • Ownership: Artifact operations are gated on Session ownership. The one ownership finding raised, "memoryQuery lacks #assertOwned", was withdrawn (discussion_r4110373096). MemoryQueryInput carries no sessionId, Memory is workspace-level, the per-entry sessionId is provenance metadata, and the Host authorizes memory.query by policy. This PR only routes the existing operation over ACP.
  • Tests constrain the fix: reverting session-registry.ts to the pre-fix revision fails 4 of the 6 named regressions (upload cap exhaustion, rejected-begin accumulation, unknown-terminal cleanup, stale-identity abort). The other two are guarded in other files.
  • Upload handling: bounded to 64 with TTL and grace, cleanup serialized per key, and close aborts unfinished uploads. Same-ID reuse and connection-availability reset are covered by tests.
  • Windows: the real child-process artifact/memory suites pass all assertions. The only failures are pre-existing environment ones (EBUSY on temp SQLite teardown, symlink EPERM without developer mode).
  • CI test is green. The Host epoch is unchanged.
  • Not verified: third-party editor UI for these private extensions, and the full CLI suite.

This is a feature, so whether to merge it remains a maintainer decision.

Automated review by an AI agent, approving at the requester's ask. This is not an independent human review.

@Sun-GLiang
Sun-GLiang merged commit 8351121 into apache:main Sep 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants