Skip to content

fix(acp): keep configured aliases as session owners - #136165

Closed
service-cyber wants to merge 19 commits into
openclaw:mainfrom
service-cyber:devmon/acp-alias-pr-ready-20260901
Closed

service-cyber wants to merge 19 commits into
openclaw:mainfrom
service-cyber:devmon/acp-alias-pr-ready-20260901

Conversation

@service-cyber

@service-cyber service-cyber commented Sep 2, 2026 •

Copy link
Copy Markdown

Related: #126539

What Problem This Solves

Configured OpenClaw ACP aliases could dispatch through an external harness and then persist that harness as the session owner. Session lookup, workspace/account routing, bindings, resume authorization, cancellation, and cleanup could consequently disagree about who owned the session.

Why This Change Was Made

Configured ACP aliases now remain the persistent OpenClaw owner. agents.entries.*.runtime.acp.agent is used only as the external dispatch harness. Owner identity is carried through session keys/stores, workspace and account selection, bindings, runtime initialization, lifecycle registration, resume, cancel, and cleanup.

Runtime compatibility fallback has been removed. Resume and lifecycle commands read only the canonical configured-owner store.

Legacy harness-owned rows are handled explicitly:

  1. openclaw doctor inventories eligible legacy ACP sessions without changing them.
  2. openclaw doctor --fix migrates a row only when its harness maps to exactly one configured owner.
  3. Doctor atomically claims and consumes the legacy ACP metadata before re-homing session-owned state under agent:<owner>:..., so retries can finish a partial move and another alias cannot replay the source.
  4. Multiple aliases for one harness, a harness that is itself an owner plus another alias, bare keys in shared owner/harness stores, and canonical target collisions fail closed with operator guidance.

This PR deliberately excludes Codex command detection, CODEX_HOME policy, and shell/interpreter/package-runner parsing.

User Impact

  • Configured aliases are stable across spawn, status, resume, cancel, close, and cleanup.
  • Alias workspace and bound account remain authoritative while the external harness performs execution.
  • Unconfigured external harnesses remain owned/routed by the requester.
  • Legacy sessions do not resume implicitly. Operators inventory and migrate eligible records through Doctor; ambiguous records remain untouched until configuration or state is resolved.

Evidence

Exact reviewed head: 79af7db588a4bd6f1e0dd9f775936fdd7b1bd0d0
Reviewed base: 9b95e87c4b2b506cc35c62e714f05cce4b71c61d
Diff: 17 files, +2894/-116 (+728/-58 production, +2130/-47 tests, +36/-11 docs).

Exact-head proof

  • Focused owner/target/Doctor//acp lifecycle and process proof: 257/257 passed across seven Vitest shards, including concurrent target-write rejection, source-removal race compensation, concurrent successful-migration preservation, divergent interrupted-stage retry rejection, expected-harness discovery, and strict source/canonical/legacy-target ACP metadata agreement.
  • The configured-alias process test executes a real ACPX turn under owner reviewer, harness owner-fixture, owner workspace/account/binding, then rejects a foreign resume before any ACPX peer-state byte changes.
  • Two real ACPX process tests preserve separate owner histories across restart and exercise resume/status/config/cancel/close for global and shared-project scopes.
  • Doctor tests cover unique-owner migration, idempotency, partial-failure retry, consumed-source replay prevention, multiple aliases, ACP and every configured non-ACP self-owner ambiguity, legacy-target metadata canonicalization, expected-harness discovery plus strict agreement across all populated source/canonical/legacy-target metadata (including incompatible agent/binding rows), separate-store bare/scoped keys, shared-store ambiguity, unrelated bare rows, canonical collisions, source-removal race compensation followed by retry, preservation of a concurrent successful migration, and fail-closed recovery when an interrupted canonical stage diverges from the legacy source.
  • Resume tests admit owner-scoped global sessions while continuing to reject ambiguous bare keys in fixed shared stores.
  • Changed-file oxlint, formatting, diff, max-lines, assertion-safety, dependency-pin, plugin-boundary, and wrapper-shadowing gates pass.
  • Scanner-backed P0-P2 autoreview and secret scan: scoped-clean at 0.91 confidence on the exact head.

Environment-only baseline exceptions

  • check:changed completes candidate-owned checks, then production core typecheck stops on four unrelated upstream assertBeforeRename errors in src/infra/install-package-dir.ts; the ACP diff does not touch that path.
  • Docs formatting, markdown/template lint, MDX, glossary, and config-example checks pass; link audit cannot start because the shared install lacks unrelated @sindresorhus/slugify.
  • The host's managed pnpm 12.1.0 shim is invalid (ENOEXEC); verification uses the installed pnpm 10.30.1 with automatic version switching disabled via an external temporary user config. No package files or dependencies are changed.

Standard CI will rerun missing-package lanes from a clean install.

Deploy / rollback

No migration, deployment, or production configuration change is performed by this PR. Operators must invoke openclaw doctor --fix explicitly to migrate eligible legacy rows. Before that action, rollback is the previous draft head 28489b2985f4d6befc8b6ab8d2377276ba9d8738. If an operator runs Doctor repair, normal state backups are the rollback boundary for migrated persisted data.

Reviewer routing

Please review configured-alias ownership, canonical-only runtime reads, Doctor's single-owner claim/consumption protocol, ambiguity/collision handling, and owner-consistent account/binding lifecycle. Generalized command parsing is intentionally absent.

Worked on by

Devmon (implementation, verification, and technical review) under Scott's authorization; coordinated by Asimov.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: acpx size: XL labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 4, 2026, 3:08 PM ET / 19:08 UTC.

ClawSweeper review

What this changes

This PR makes a configured ACP alias own its session and lifecycle while its configured ACP agent remains the external execution harness, with Doctor migration for legacy harness-owned sessions.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 11 items remain

Keep open: the alias-owner repair is still absent from current main, but the new Doctor migration can delete rehomed delivery records when a shared-store source race rolls back the staged target. It also needs real exact-head authority-path proof and maintainer acceptance of the canonical-only legacy-session upgrade behavior.

Priority: P1
Reviewed head: 79af7db588a4bd6f1e0dd9f775936fdd7b1bd0d0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The owner-boundary direction is well exercised in tests, but a P1 shared-store rollback defect and missing real behavior proof prevent merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: Authority-chain proof required: the new test invokes the production slash-command handler and a synthetic local ACPX peer, but uses an in-memory channel binding and calls the foreign-resume validator directly; the supplied body contains no inspectable exact-head trace of a foreign sessions_spawn request being rejected before final ACPX I/O. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Authority-chain proof required: the new test invokes the production slash-command handler and a synthetic local ACPX peer, but uses an in-memory channel binding and calls the foreign-resume validator directly; the supplied body contains no inspectable exact-head trace of a foreign sessions_spawn request being rejected before final ACPX I/O. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Introduced rollback defect: The new migration stages the canonical target and copies owner state before source removal, then removes that staged target after a source-change conflict; the removal requests owned-window cleanup.
Shared-store delivery loss path: Exact .sqlite session stores are shared across scoped owner keys; canonical repair rewrites copied conversation delivery source keys to the target, while target cleanup deletes deliveries under that target key.
Missing shared-store race coverage: The source-race regression test uses separate owner stores, while the shared-store case asserts only session entries and no conversation-delivery artifact survives rollback.
Findings 1 actionable finding [P1] Preserve shared-store delivery artifacts during rollback
Security None None.

How this fits together

ACP spawn requests resolve an OpenClaw alias and an external ACP harness; the alias determines the durable session key, workspace, account binding, and lifecycle controls while the harness executes the turn. Doctor migrates old harness-owned session records into that owner namespace before normal runtime use.

flowchart LR
  Requester[Requester session] --> Resolve[Resolve alias and harness]
  Resolve --> Owner[Configured session owner]
  Owner --> Runtime[External ACP harness]
  Owner --> State[Session state and bindings]
  State --> Controls[Resume and lifecycle controls]
  Legacy[Legacy harness-owned records] --> Doctor[Explicit Doctor migration]
  Doctor --> State
Loading

Decision needed

Question Recommendation
Should legacy harness-owned ACP sessions remain unavailable at runtime until explicit Doctor migration, or should OpenClaw preserve a temporary compatibility path? Keep explicit Doctor migration: Repair the rollback data-loss path, then keep canonical-only runtime reads and require Doctor to move eligible legacy sessions.

Why: The PR intentionally removes runtime promotion for existing persisted sessions; this is an upgrade-policy choice beyond the mechanical rollback repair.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Authority-chain proof required: the new test invokes the production slash-command handler and a synthetic local ACPX peer, but uses an in-memory channel binding and calls the foreign-resume validator directly; the supplied body contains no inspectable exact-head trace of a foreign sessions_spawn request being rejected before final ACPX I/O. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve shared-store delivery artifacts during rollback (P1) - When source removal rejects a concurrent change, this rolls back the staged target after its artifact copy has rewritten conversation_deliveries to that target key. In an exact shared SQLite store, cleanup deletes those rows while the source entry remains, silently losing delivery state. Make the move atomic or restore artifacts to the source before target cleanup, and cover this race with a delivery row.
  • Resolve merge risk (P1) - A Doctor source-removal race on an exact shared SQLite store can silently delete conversation-delivery state while leaving the legacy source session in place.
  • Resolve merge risk (P1) - Canonical-only runtime reads make legacy harness-owned sessions unavailable until an operator runs Doctor, so maintainers need to accept that upgrade behavior.
  • Resolve merge risk (P1) - The supplied test is a real local ACPX fixture but does not prove a foreign sessions_spawn request reaches rejection immediately before final process I/O.
  • Complete next step (P0) - Repair the shared-store rollback data loss, add exact-head real authority-path proof, and obtain a maintainer decision on canonical-only legacy-session behavior before merge.
  • Improve patch quality - Make shared-store artifact rollback atomic or restore copied delivery records before deleting the staged target.
  • Improve patch quality - Add a focused exact shared-SQLite source-race test containing a conversation-delivery record.
  • Improve patch quality - Provide a redacted exact-head ACPX trace of configured-alias ownership and a foreign sessions_spawn rejection before process I/O; update the PR body for automatic re-review.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] Preserve shared-store delivery artifacts during rollback — src/commands/doctor-acp-owner-sessions.ts:214-218
Agent review details

Security

None.

PR surface

Source +670, Tests +2083, Docs +25. Total +2778 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 11 728 58 +670
Tests 5 2130 47 +2083
Docs 1 36 11 +25
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 2894 116 +2778

Review metrics

Metric Value Why it matters
Production versus test delta production +728/-58; tests +2,130/-47; docs +36/-11 The substantial persistent-migration expansion needs the shared-store rollback defect resolved before its upgrade cost is acceptable.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/acp/runtime/session-meta-owner-migration.ts, migration/backfill/repair: src/commands/doctor-acp-owner-sessions.ts, migration/backfill/repair: src/commands/doctor-session-transcripts.ts, unknown-data-model-change: src/acp/runtime/session-meta-owner-migration.ts, unknown-data-model-change: src/commands/doctor-acp-owner-sessions.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair shared-store rollback (recommended)
    Make session-owned artifact movement atomic with the entry move, or restore artifacts to the legacy key before deleting a failed staged target, then add a focused shared-SQLite regression.
  2. Accept the legacy-session policy explicitly
    After the data-loss repair, maintainers may accept canonical-only runtime reads and the explicit Doctor migration requirement for existing sessions.

Technical review

Best possible solution:

Make the owner migration preserve or restore all shared-store artifacts on rollback, add a shared-SQLite delivery regression, and retain canonical-only runtime reads only after maintainers accept the explicit Doctor upgrade path.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: use an exact shared SQLite session store with a conversation-delivery row, then change the source entry between target staging and source removal. The existing source-race harness provides the injection point but lacks the shared-store artifact assertion.

Is this the best way to solve the issue?

No: alias/harness separation is the right owner boundary, but the staged-target rollback must not delete copied shared-store artifacts and the upgrade policy still needs maintainer confirmation.

Full review comments:

  • [P1] Preserve shared-store delivery artifacts during rollback — src/commands/doctor-acp-owner-sessions.ts:214-218
    When source removal rejects a concurrent change, this rolls back the staged target after its artifact copy has rewritten conversation_deliveries to that target key. In an exact shared SQLite store, cleanup deletes those rows while the source entry remains, silently losing delivery state. Make the move atomic or restore artifacts to the source before target cleanup, and cover this race with a delivery row.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d2a674a6c859.

Labels

Label changes:

  • add merge-risk: 🚨 session-state: Rollback after copying a shared-store session can remove rehomed conversation-delivery records.

Label justifications:

  • P1: The introduced migration race can silently remove session delivery state during an explicit operator repair.
  • merge-risk: 🚨 compatibility: Existing harness-owned sessions stop resolving at runtime until explicit Doctor migration is completed.
  • merge-risk: 🚨 session-state: Rollback after copying a shared-store session can remove rehomed conversation-delivery records.
  • merge-risk: 🚨 security-boundary: The change alters ownership-based resume authorization, but the nearest forbidden request lacks final-effect proof.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: the new test invokes the production slash-command handler and a synthetic local ACPX peer, but uses an in-memory channel binding and calls the foreign-resume validator directly; the supplied body contains no inspectable exact-head trace of a foreign sessions_spawn request being rejected before final ACPX I/O. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/commands/doctor-acp-owner-sessions.test.ts.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-02T08:40:24.980Z sha 0e041160b78f898a34ea8790ee641f5187a5f89d :: needs real behavior proof before merge. :: [P1] Preserve the isolated Codex environment for wrapped aliases | [P2] Update ACP documentation for alias-owned sessions
  • reviewed 2026-09-04T15:06:44.624Z sha 28489b2985f4d6befc8b6ab8d2377276ba9d8738 :: needs real behavior proof before merge. :: none

@service-cyber
service-cyber force-pushed the devmon/acp-alias-pr-ready-20260901 branch from 0e04116 to 28489b2 Compare September 4, 2026 14:48
@service-cyber service-cyber changed the title fix(acp): OpenClaw owns ACP sessions; recognize Codex aliases fix(acp): keep configured aliases as session owners Sep 4, 2026
@service-cyber

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 4, 2026
@service-cyber
service-cyber force-pushed the devmon/acp-alias-pr-ready-20260901 branch from 28489b2 to 79af7db Compare September 4, 2026 19:00
@service-cyber

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Sep 4, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 2, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@openclaw-barnacle openclaw-barnacle Bot closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant