Skip to content

fix(agents): preserve workspace ownership across path aliases - #130372

Merged
steipete merged 1 commit into
mainfrom
codex/loc-sweep-workspace-identity-20260826
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-sweep-workspace-identity-20260826

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Workspace lookup and agent-deletion safety each used a private realpath-or-lexical fallback. A dangling symlink lost its target identity: lookup could miss the owning agent, and deletion could miss another agent sharing the vanished workspace. Dreaming separately retained duplicate roster aliases already normalized by agent configuration.

Why This Change Was Made

Reuse the existing bounded workspace symlink walker for filesystem ownership, removing both duplicate canonicalizers and the separate dreaming roster loop. Share traversal, not stored-key normalization: filesystem paths preserve Unicode bytes, while persisted state-key normalization stays exactly where it was. There is no schema, hash, alias, or stored-data migration.

Production LOC: +26/-72 (net -46). Tests: +110/-1 (net +109).

User Impact

Workspace ownership and shared-workspace deletion protection follow dangling symlink targets correctly. Distinct Linux NFC/NFD directory names remain distinct for routing and deletion. Dreaming processes canonical agent identities once.

Existing persisted state keys still NFC-fold those names; repairing that separate storage identity needs an explicit migration/design decision and is not part of this PR.

Evidence

  • Exact candidate: 2296f3f6cb232ae61956a22077a083eeb5718153.
  • Three original-code regressions reproduced: duplicate dreaming roster IDs, missed dangling shared workspace, and missed workspace owner.
  • Independent review caught a Unicode error in the first candidate. Real Linux proof created distinct NFC/NFD inodes, reproduced wrong-agent routing, and passed after filesystem path and stored identity were separated.
  • 142 local tests pass, with one Linux-only skip; 98 tests pass on real Linux, including distinct Unicode inodes, dangling links, cycles, ownership/deletion and state-store contracts. Remote workflow: https://github.com/openclaw/openclaw/actions/runs/33006357752 . The proof lease was stopped.
  • Full selected changed gate passed after task-only dependency links were corrected to an existing matching install. No dependency files or checker rules were changed.
  • Fresh structured Codex P1 and separate independent exact-commit review passed. Dependency source inspection confirms the alternative existing-ancestor resolver loses dangling targets, so it cannot replace the bounded walker here.
OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs src/agents/agent-delete-safety.test.ts src/agents/agent-scope.test.ts src/memory-host-sdk/dreaming.test.ts src/agents/workspace-state-store.test.ts src/commands/agents.delete.test.ts src/commands/agents.delete.workspace.test.ts src/gateway/server-methods/agents-workspace.test.ts

Maintainer-requested, AI-assisted. Required exact-head hosted CI and native landing checks remain mandatory.

@clawsweeper

clawsweeper Bot commented Aug 26, 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 agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 20:21
@steipete

Copy link
Copy Markdown
Contributor Author

Exact-head landing verification: Share the bounded workspace symlink traversal for lookup and deletion, preserving filesystem Unicode bytes; remove duplicated canonicalizers and dreaming roster normalization.

Production +26/-72 (−46); tests +110/-1 (+109). Three original baseline failures reproduce alias-roster and dangling-workspace errors. Final142 local tests and98 actual Linux tests pass, including distinct NFC/NFD inodes and correct routing/deletion. Full matching changed gate, P1 and independent exact-head source/proof review pass. Hosted CI is green for 2296f3f.

Best-fix judgment: Direct existing-ancestor realpath loses dangling symlink targets; sharing the persisted normalized key incorrectly merges distinct Linux Unicode paths. The bounded walker with an identity transform is the correct owner.

Limitations: Persisted state keys retain their existing normalization. The pre-existing stored NFC-key collision needs separately approved storage/migration design; this PR does not claim to fix it. Latest available ClawSweeper comment is a review-start placeholder, without an actionable rank-up list; independent final-source review is complete. No new config, dependency, protocol or database schema is introduced.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 4:29 PM ET / 20:29 UTC.

ClawSweeper review

What this changes

Centralizes workspace-path canonicalization so agent lookup and deletion safety follow dangling symlink aliases while retaining separate persisted state identity rules.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this active maintainer PR open. The exact head contains a coherent owner-boundary fix for dangling workspace aliases, but current-main comparison and the later PR comment could not be fetched because the shallow checkout lacks those objects and GitHub DNS was unavailable.

Priority: P2
Reviewed head: 2296f3f6cb232ae61956a22077a083eeb5718153

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The exact-head patch has coherent ownership boundaries and focused regression coverage; final current-main refresh remains unavailable in this review environment.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless provides focused Linux and hosted-validation evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless provides focused Linux and hosted-validation evidence.
Evidence reviewed 5 items Shared ownership boundary: The new resolver follows existing ancestors and dangling symlink targets, then is consumed by both routing and deletion-overlap checks.
Caller and sibling coverage: Workspace ownership affects TUI, skills CLI, session-memory display routing, command deletion, and gateway deletion planning; state identity remains NFC-normalized separately.
Regression tests: Focused tests cover dangling aliases for lookup and deletion, Linux NFC/NFD directory separation, roster alias deduplication, cycles, and state-store alias behavior.
Findings None None.
Security None None.

Live Verification

Command: OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs src/agents/agent-delete-safety.test.ts src/agents/agent-scope.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.agents-core.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130372-JnNsCt/target

 ✓  agents-core  src/agents/agent-scope.test.ts (41 tests) 85ms
 ✓  agents-core  src/agents/agent-delete-safety.test.ts (4 tests) 4ms

 Test Files  2 passed (2)
      Tests  45 passed (45)
   Start at  20:30:49
   Duration  2.38s (transform 1.68s, setup 989ms, import 937ms, tests 89ms, environment 0ms)

[test] passed 1 Vitest shard in 8.88s
[test] starting test/vitest/vitest.agents-core.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130372-JnNsCt/target

 ✓  agents-core  src/agents/agent-scope.test.ts (41 tests) 62ms
 ✓  agents-core  src/agents/agent-delete-safety.test.ts (4 tests) 4ms

 Test Files  2 passed (2)
      Tests  45 passed (45)
   Start at  20:30:58
   Duration  1.27s (transform 535ms, setup 456ms, import 508ms, tests 66ms, environment 0ms)

[test] passed 1 Vitest shard in 7.71s

Assertions:

  • PASS expect_output: passed

How this fits together

Agent workspace configuration feeds routing, deletion safety, and memory dreaming. These paths resolve an agent owner before selecting sessions, cleaning files, or scheduling workspace work.

flowchart LR
A[Agent configuration] --> B[Workspace resolver]
B --> C[Canonical filesystem path]
C --> D[Agent routing]
C --> E[Deletion safety]
A --> F[Dreaming roster]
F --> G[Workspace scheduling]
Loading

Before merge

  • Resolve merge risk (P1) - The review environment could not retrieve current-main source or the later PR comment, so final merge review should refresh those checks once repository objects and GitHub access are available.
  • Complete next step (P2) - The active maintainer-labeled PR needs normal exact-head CI and refreshed current-main review, not a separate repair job.
Agent review details

Security

None.

PR surface

Source -46, Tests +109. Total +63 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 26 72 -46
Tests 3 110 1 +109
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 136 73 +63

Review metrics

Metric Value Why it matters
Production versus test delta production -46 net, tests +109 net The patch removes duplicated canonicalizers while adding focused ownership and identity regressions.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/memory-host-sdk/dreaming.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one shared filesystem-path walker, retain NFC normalization only for persisted state identities, and complete exact-head CI plus a refreshed current-main review before merging.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one shared filesystem-path walker, retain NFC normalization only for persisted state identities, and complete exact-head CI plus a refreshed current-main review before merging.

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

Yes, from source: a dangling symlink makes direct realpath fail, whereas the shared walker follows its lexical target before ownership comparison. The read-only review did not run tests because they create temporary filesystem artifacts.

Is this the best way to solve the issue?

Yes. Sharing the bounded walker removes duplicate ownership policy while preserving the distinct persisted-state normalization contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs agent workspace routing and deletion safety with a bounded, configuration-dependent impact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless provides focused Linux and hosted-validation evidence.

Label justifications:

  • P2: This repairs agent workspace routing and deletion safety with a bounded, configuration-dependent impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless provides focused Linux and hosted-validation evidence.

Evidence

What I checked:

  • Shared ownership boundary: The new resolver follows existing ancestors and dangling symlink targets, then is consumed by both routing and deletion-overlap checks. (src/agents/workspace-state-identity.ts:21, 2296f3f6cb23)
  • Caller and sibling coverage: Workspace ownership affects TUI, skills CLI, session-memory display routing, command deletion, and gateway deletion planning; state identity remains NFC-normalized separately. (src/agents/agent-scope.ts:602, 2296f3f6cb23)
  • Regression tests: Focused tests cover dangling aliases for lookup and deletion, Linux NFC/NFD directory separation, roster alias deduplication, cycles, and state-store alias behavior. (src/agents/agent-scope.test.ts:1225, 2296f3f6cb23)
  • History and ownership: Blame attributes the shared resolver and its consumers to the PR head; history also shows Peter Steinberger as the dominant recent contributor across these agent ownership paths. (src/agents/workspace-state-identity.ts:71, 2296f3f6cb23)
  • Current-main inspection gap: The local checkout is a grafted/promisor PR head with no merge base for the supplied base SHA; attempts to retrieve missing objects and GitHub PR metadata failed because GitHub DNS was unavailable.

Likely related people:

  • steipete: Authored the current change and is the dominant recent contributor in the inspected agent ownership history. (role: recent area contributor; confidence: high; commits: 2296f3f6cb23, 1ca60fbc3a3f; files: src/agents/workspace-state-identity.ts, src/agents/agent-scope.ts, src/agents/agent-delete-safety.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the current-main diff and latest PR discussion after GitHub access is restored.

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.

@steipete
steipete merged commit 26d3b08 into main Aug 26, 2026
275 checks passed
@steipete
steipete deleted the codex/loc-sweep-workspace-identity-20260826 branch August 26, 2026 20:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant