Skip to content

fix(acp): allow harness resets from read-only installations - #158551

Merged
steipete merged 5 commits into
mainfrom
steipete/perf-micro-harness-reset-hook-eacces-20260919
Sep 26, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/perf-micro-harness-reset-hook-eacces-20260919

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes ACP harness resets failing with EACCES from a read-only installation, while preserving sessions stored under the former <workspace>/state default during upgrades.

User Impact

GitHub Copilot, Kilo Code, OpenCode, Pi, and Qwen Code reset hooks use acpx/ under the Gateway state directory, honoring OPENCLAW_STATE_DIR. Other reset-hook failures warn once per harness ID per process; subsequent resets still retry.

Upgrade behavior: when no explicit plugins.entries.acpx.config.stateDir is configured and the new default is empty, ACPX startup or openclaw doctor --fix automatically adopts the old state directory, including its sessions and other files. Set the existing override only to retain the old location. An occupied destination and explicit overrides are preserved. Failed adoption warns with the override to set and retains the applicable legacy path for that process. Inspection errors on an already-used destination preserve that destination.

Why This Change Was Made

The existing ACPX session-owner migration module owns adoption for both Doctor and service startup, before runtime storage is opened. It uses the already-declared fs-safe move primitive for same-filesystem rename and source-verified cross-filesystem copying and cleanup. Pending/completed markers live in existing plugin state, so completion can recover after a marker-write failure and completed adoption never revisits stale legacy files. Doctor declares both directories for update backup and reports adoption problems as recoverable warnings.

No new configuration, dependency, filesystem sidecar, or runtime cache is added. The migration follow-up adds about 200 production lines for recovery, notices, backup inventory, and both entry points. The existing filesystem implementation owns the actual move.

Evidence

Contract Before After
Five registered reset hooks with a read-only package directory 5 EACCES failures All 5 succeed
Default-state adoption: absent destination, empty destination, cross-device move All 3 lose session visibility All 3 preserve readable sessions and remove the old directory
Unreadable legacy state or failed move Both select the empty new store Both select the legacy path and warn
Explicit location or occupied destination Preserved Preserved
Warnings from 222 failing resets across two harness IDs and registry replacement 222 2; all 222 attempts still run

Validation uses blacksmith-testbox, profile openclaw-check. No live Gateway was changed or restarted, and no production CPU or loop-delay improvement is claimed.

  • Baseline lease tbx_01m3dt8j2rjym4jybg7xemah03 (run): node scripts/run-vitest.mjs extensions/acpx/src/service.test.ts --maxWorkers=1 -t 'preserves legacy sessions at startup' reproduced 5 failures and 2 passing controls on the existing PR head. The test runner took 9.85 s after dependency installation and fixture correction.
  • Candidate lease tbx_01m3dtphd09tzt6gr00x6sd3nx (run): the five-file focused command passed 61 tests in 59.32 s wall. Coverage includes real filesystem moves and ACPX record reads, injected EXDEV/I/O failures, process-local fallback, marker completion recovery, owner repair, and registered read-only reset hooks.
  • Final lease tbx_01m3dveky88aa2cpnn7nadhbqf (run): 62 focused cases passed, including the final startup/Doctor marker-precedence and non-creating inspection assertions. node scripts/check-changed.mjs --base 7472eb3b614ef11aa6a2d939568c60ab9decd3da passed all 25 core test typecheck groups, extension production/test typing, dead-code scans, and core lint before finding three missing-brace lint errors. After fixing those, the same native command scoped to the five changed extension files passed completely, including extension lint and the remaining architecture guards. The unchanged core-test and docs proof was retained. pnpm build passed in 477.78 s; the full final remote command exited 0 in 13m 40.90s. The build reported a Control UI startup-size warning (371,740 B gzip versus a 371,332 B limit); this patch changes no production UI source. All leases are stopped.
  • Independent Codex review: no actionable P0–P2 findings after resolving marker persistence, fallback selection, and completed-marker precedence in both startup and Doctor detection.

The Doctor integration fixture covers both automatic adoption and an explicit old location, then loads the retained upstream session from the selected store. Restart coverage also makes stale legacy files unreadable after completed adoption; startup and Doctor must honor the marker. Empty-state Doctor detection must remain non-creating and avoid runtime/ownership inspection.

Measured single-worker file cost: pnpm test extensions/acpx/src/service.test.ts --maxWorkers=1 passed 32 cases in 36.30 s cold wall, including worker-bundle compilation; the final additional Doctor assertions also passed on rerun. The existing Doctor integration file passed all seven cases in 22.64 s wall. pnpm test extensions/acpx/doctor-contract-api.test.ts --maxWorkers=1 passed all eight cases in 9.33 s wall. The existing process-backed owner-migration suite passed all 14 cases in 31.38 s runner wall.

Validation recovery: fresh leases required pnpm install --frozen-lockfile. Two sync timeouts occurred before test execution; those leases were stopped and replaced. An early cross-device staging error was fixed by reusing fs-safe; the assertion ratchet was fixed with an explicit result type.

The first follow-up CI run failed in check-test-types-core-1 because main commit 9ee2b0b3b6f1 (#158464) moved ControlUiRootState without updating a retained-assets test import. Main fixed that in da8149b8ba7d; the PR uses that owning fix when merged. A concurrent test-only repair here was backed out with a normal commit to remove the overlap, leaving the final source tree identical to the Testbox-validated migration commit 6bd176e248ef. The merge was checked without conflicts. GitHub CI is green on f63393b110e521a14ff8158fce57e12f1647712d, including openclaw/ci-gate, in 995 s workflow wall time. The PR has 144 passing checks, 48 skipped checks, and no outstanding checks; it remains open and unmerged.

The type-import failure was also reproduced on isolated merge source d3f3f2415ef8 using blacksmith-testbox lease tbx_01m3dzaaf8ezc41r5zxqbt53fr (run); the repaired UI E2E type graph passed in 10.31 s. The corresponding five-group typecheck stripe, typed lint, formatting, and whitespace checks passed. This temporary proof checkout and lease were removed.

Focused command:

node scripts/run-vitest.mjs \
  extensions/acpx/src/service.test.ts \
  extensions/acpx/doctor-contract-api.test.ts \
  extensions/acpx/src/session-owner-migration.test.ts \
  extensions/acpx/harness-reset.test.ts \
  src/acp/runtime/session-meta-doctor.test.ts --maxWorkers=1

Cross-device and permission failures are injected at filesystem operations; the move, storage, and recovery code are real. Service tests capture the prepared runtime configuration and load records with the published ACPX store. The registered-hook regression exercises real runtime initialization. This is synthetic upgrade-state proof, not a published-updater or production Gateway campaign.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: acpx size: S labels Sep 26, 2026
@steipete
steipete marked this pull request as ready for review September 26, 2026 01:47
@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: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 26, 2026, 12:48 AM ET / 04:48 UTC (Revision 4).

ClawSweeper review

What this changes

The branch moves ACPX session storage into Gateway state, adds startup and Doctor migration for older sessions, and limits repeated harness-reset warnings.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep this PR open: its migration still skips installations with existing ACPX adapter files, leaving older sessions invisible after the default storage location changes.

Priority: P1
Reviewed head: f63393b110e521a14ff8158fce57e12f1647712d

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Focused synthetic validation supports the read-only reset change, but the unresolved published-layout migration defect prevents merge readiness.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The supplied repository state classifies the author as MEMBER, so the external-contributor proof gate is not applied. Testbox cases exercise real filesystem moves and record reads in synthetic state, but omit the published adapter-file layout; stored-state upgrade compatibility remains insufficient.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state classifies the author as MEMBER, so the external-contributor proof gate is not applied. Testbox cases exercise real filesystem moves and record reads in synthetic state, but omit the published adapter-file layout; stored-state upgrade compatibility remains insufficient.
Evidence reviewed 9 items Changed storage default: The PR changes the default from workspace/state to the Gateway state directory's acpx child.
Released installation layout: Release v2026.9.6 prepared adapter files under Gateway state/acpx while the then-current config stored sessions under workspace/state; the release was published on 2026-09-23.
Published release confirmation: GitHub identifies v2026.9.6 as a published release; its service also creates Gateway state/acpx during startup.
Findings 1 actionable finding [P1] Migrate sessions when ACPX already contains adapter files
Security None None.

How this fits together

The ACPX plugin connects OpenClaw agent sessions to ACP runtimes. Gateway configuration selects its storage location; startup, Doctor, and reset hooks then read or change session records there.

flowchart LR
A[Gateway workspace] --> C[ACPX configuration]
B[Gateway state directory] --> C
C --> D[Startup and Doctor migration]
D --> E[ACPX session store]
F[Harness reset hooks] --> E
E --> G[Agent sessions]
Loading

Before merge

  • Migrate sessions when ACPX already contains adapter files (P1) - A v2026.9.6 installation writes adapter wrappers and an auth home into the new acpx destination while keeping sessions in &lt;workspace>/state. That makes destinationEmpty false, so this return selects the new store without adopting or warning about the old sessions; Doctor has the same gap. Use a nonconflicting destination or safe adoption and test the published layout.
  • Resolve merge risk (P1) - Upgrade compatibility remains unproven for the published layout containing adapter files, while the new default can silently select a store without the user's existing sessions.
  • Complete next step (P2) - Repair adoption for installations with existing Gateway ACPX adapter files and demonstrate session continuity from a published-state fixture before merge.
  • Improve patch quality - Add a published-layout upgrade regression that retains both ACPX sessions and adapter files through startup and Doctor.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] Migrate sessions when ACPX already contains adapter files — extensions/acpx/src/session-owner-migration.ts:117-118
Agent review details

Security

None.

PR surface

Source +219, Tests +340, Docs +18. Total +577 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 5 236 17 +219
Tests 7 354 14 +340
Docs 2 18 0 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 608 31 +577

Review metrics

Metric Value Why it matters
Production and test growth production +219 net, tests +340 net The added migration and recovery logic has a stated purpose, but its published-layout case remains uncovered.
Persisted migration metadata 1 new keyed-store namespace The completion marker makes existing-state upgrade behavior part of the merge contract.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/acpx/doctor-contract-api.ts, migration/backfill/repair: extensions/acpx/src/service.ts, migration/backfill/repair: extensions/acpx/src/session-owner-migration.ts, unknown-data-model-change: extensions/acpx/src/session-owner-migration.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair the published-layout upgrade (recommended)
    Use a nonconflicting session destination or conflict-safe adoption, then prove that startup and Doctor retain sessions alongside existing adapter files.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve published ACPX adapter files while migrating legacy sessions; add a v2026.9.6-layout startup and Doctor regression before considering merge.

Technical review

Best possible solution:

Place ACPX sessions in a writable Gateway-owned directory that cannot collide with adapter files, and use the shared startup and Doctor migration path to preserve existing records through upgrade.

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

Yes, from source: start with v2026.9.6 sessions in workspace/state and generated files in Gateway state/acpx, then apply this branch's default. The destination check skips adoption; this read-only review did not execute that upgrade.

Is this the best way to solve the issue?

No. Moving storage out of a read-only installation is appropriate, but the chosen destination collides with published adapter files; a separate session directory or conflict-safe migration is needed.

Full review comments:

  • [P1] Migrate sessions when ACPX already contains adapter files — extensions/acpx/src/session-owner-migration.ts:117-118
    A v2026.9.6 installation writes adapter wrappers and an auth home into the new acpx destination while keeping sessions in &lt;workspace>/state. That makes destinationEmpty false, so this return selects the new store without adopting or warning about the old sessions; Doctor has the same gap. Use a nonconflicting destination or safe adoption and test the published layout.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: A normal upgrade can hide existing ACPX sessions and break resumed agent work.
  • merge-risk: 🚨 compatibility: The new default conflicts with adapter files created by the published release.
  • merge-risk: 🚨 session-state: The selected session store can omit records that remain in the former location.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The supplied repository state classifies the author as MEMBER, so the external-contributor proof gate is not applied. Testbox cases exercise real filesystem moves and record reads in synthetic state, but omit the published adapter-file layout; stored-state upgrade compatibility remains insufficient.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/acpx/src/service.test.ts extensions/acpx/doctor-contract-api.test.ts extensions/acpx/src/session-owner-migration.test.ts src/acp/runtime/session-meta-doctor.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs.
  • [P1] Published v2026.9.6 state layout to candidate startup and Doctor session-read proof.

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)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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 (3 earlier review cycles)
  • reviewed 2026-09-26T01:54:28.510Z sha 1002608 :: blocked before merge. :: [P1] Migrate shipped ACPX sessions before switching the default
  • reviewed 2026-09-26T02:52:49.331Z sha 7472eb3 :: blocked before merge. :: [P1] Preserve shipped ACPX sessions before changing the default
  • reviewed 2026-09-26T04:15:33.453Z sha 6bd176e :: blocked before merge. :: [P1] Handle existing adapter files during session adoption

Adopt the workspace state directory through the existing ACPX migration owner during startup and Doctor repair. Preserve explicit locations, warn and retain legacy state on failed adoption, and recover the one-time marker without revisiting completed migrations.
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 26, 2026
Fix the stale ControlUiRootState import exposed by merge CI after its owner moved on main. Type the fixture through the handler input without restoring an implementation re-export or changing browser behavior.
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Sep 26, 2026
Back out the parallel fixture adjustment now that main contains da8149b. This removes the merge overlap while preserving the validated ACPX migration source tree and the requested branch history.
@openclaw-barnacle openclaw-barnacle Bot removed the app: web-ui App: web-ui label Sep 26, 2026
@steipete
steipete merged commit ccaeab1 into main Sep 26, 2026
206 of 209 checks passed
@steipete
steipete deleted the steipete/perf-micro-harness-reset-hook-eacces-20260919 branch September 26, 2026 05:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…#158551)

* fix(acp): allow harness resets from read-only installations

* test(acp): pin legacy state in Doctor migration fixture

* fix(acpx): migrate legacy default session state on upgrade

Adopt the workspace state directory through the existing ACPX migration owner during startup and Doctor repair. Preserve explicit locations, warn and retain legacy state on failed adoption, and recover the one-time marker without revisiting completed migrations.

* test(ui): derive retained asset root from handler contract

Fix the stale ControlUiRootState import exposed by merge CI after its owner moved on main. Type the fixture through the handler input without restoring an implementation re-export or changing browser behavior.

* test(ui): use the root type import repair from main

Back out the parallel fixture adjustment now that main contains 6fa14a2. This removes the merge overlap while preserving the validated ACPX migration source tree and the requested branch history.
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 extensions: acpx merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant