Skip to content

test(acp): preserve resident recovery on final core - #1236

Open
sethkarten wants to merge 24 commits into
mainfrom
v080/acp-p1-final-core
Open

test(acp): preserve resident recovery on final core#1236
sethkarten wants to merge 24 commits into
mainfrom
v080/acp-p1-final-core

Conversation

@sethkarten

@sethkarten sethkarten commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Warning

BLOCKED ON CORE — topology-only reconstruction targeting main. The five-path P1 delta is tests/docs/package-command only and depends on resident launch-environment production surfaces not yet present on main. Expected test dependency failures are intentional evidence; do not merge until the required Core implementation lands.

Topology

Base PR targeting main, as required.

  • first parent / prior reviewed head: c3ab0a13ff164598ac42c3cca2bc426cc5cccd68
  • second parent / pinned main: 47dccfad4c0e71cd357f12d233ac44cc803af8c5
  • current head: 6fecbb81737f0473718e66c4265630812d90df05

Exact incremental scope versus main

Only five paths:

  • packages/coding-agent/CHANGELOG.md
  • packages/coding-agent/package.json
  • packages/coding-agent/test/acp-resident-lifecycle.test.ts
  • packages/coding-agent/test/daemon-protocol.test.ts
  • packages/coding-agent/test/daemon-supervisor-process.test.ts

No production src/** path is included. Required Core APIs/semantics remain an explicit dependency.

No live or paid evaluation was run.


Note

High Risk
Changes daemon supervisor worker recovery, credential persistence, and ACP lifecycle—security-sensitive paths where misbehavior could leak secrets or break session recovery after crashes.

Overview
Resident daemon workers no longer keep full launch environments or session runtime config on disk. New sanitizeAgentSessionRuntimeConfigForDurableStorage and filterPersistedDaemonLaunchEnv strip secrets (tokens, headers, API keys, etc.) before supervisor and worker descriptors are written; startup re-sanitizes existing descriptors and may rewrite them.

Recovery behavior changes for ownerless residents: a dead worker without a one-shot launchEnv from a local client create goes to failed (“Waiting for a client with fresh environment”) instead of auto-relaunching from ambient env or stale descriptors. reuseWorkerForCreate single-flights concurrent fresh resumes, merges transient env only for that recovery, and clears it after success or failure. Replacement launches use an allowlisted inherited env so the supervisor’s ambient credentials are not passed to workers.

ACP / client wiring: reattachable ACP sessions (session file, not --no-session) use resident lifecycle via isClientOwnedDaemonSession. Daemon create always receives launchEnv; attach skips failed residents so resume can supply a new environment. Update-restart restore uses explicit lifecycle: "resident" and empty launchEnv as a recovery capability marker.

Also kills tracked detached children on daemon socket shutdown, pins supervisor registry dir into worker env, and tightens session-path matching for restarted supervisors (ambiguity/conflict errors).

Tests add acp-resident-lifecycle, expand supervisor monitor/process coverage, and adjust regressions to expect fail-closed then client-driven recovery.

Reviewed by Cursor Bugbot for commit dc6f1a8. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Preserve resident worker recovery on final core with credential sanitization

  • Resident daemon workers now fail-closed when their supervisor restarts without a fresh client-supplied launchEnv, rather than attempting to relaunch with stale or missing credentials.
  • Adds filterPersistedDaemonLaunchEnv and an allowlist (DAEMON_PERSISTED_LAUNCH_ENV_KEYS) so only non-secret env vars are written to durable worker descriptors; secrets are stripped on load, promotion, and persist.
  • Adds sanitizeAgentSessionRuntimeConfigForDurableStorage to redact credential-bearing fields (API keys, tokens, headers, AWS creds) from persisted session configs.
  • ACP sessions with a session file are now treated as resident (not client-owned) via the new isClientOwnedDaemonSession helper; createDaemonClientConnection skips attaching to failed workers and issues a create with fresh launchEnv instead.
  • Extends test coverage across daemon supervisor, ACP lifecycle, and session config sanitization to assert fail-closed behavior, credential non-persistence, and explicit recovery semantics.
  • Behavioral Change: failed resident workers no longer auto-recover; a client must supply a fresh launchEnv via a create request to resume them.

Macroscope summarized dc6f1a8.

@sethkarten
sethkarten changed the base branch from v080/final-core-main-project-mcp-hardened to main August 11, 2026 18:05
@sethkarten
sethkarten marked this pull request as ready for review August 12, 2026 06:18
Comment thread packages/coding-agent/test/acp-resident-lifecycle.test.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9750558. Configure here.

Comment thread packages/coding-agent/src/package-manager-cli.ts
Comment thread packages/coding-agent/src/package-manager-cli.ts
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