Skip to content

2026.5.26: upgrade can create phantom workdir directories; UI displays paths inconsistently across tools #87491

Closed

Description

@alessandro-veras

Title

2026.5.26: upgrade can create phantom workdir directories; UI displays paths inconsistently across tools

Summary

After upgrading assistantplatform from 2026.4.23 to 2026.5.26 on macOS Sequoia 15.6 (arm64),
two phantom directories appeared under ~/.assistantplatform/ (the legacy on-disk dotted directory):

  1. ~/.assistantplatform/workdir/ — a directory literally named workdir (rebranded display
    form), inode separate from the real workdir/. Created at the moment of the upgrade.
  2. ~/.assistant/ (rebranded display form of .assistantplatform) — a dotted dir parallel
    to the real .assistantplatform, containing only a workdir/ with a memory/ subdir holding
    exactly two files: self-audit-latest.md and 2026-05-27.md (the latter modified during the
    first post-upgrade memory-flush operation).

Different tools resolved paths to different directories:

  • read / edit (gateway tool layer) consistently hit the real ~/.assistantplatform/workdir/ —
    but with intermittent ENOENT during/after the upgrade window (likely cache lag).
  • write during memory-flush turns landed in ~/.assistantplatform/workdir/memory/ (the phantom).
  • exec via $PWD always saw the real workdir.

This caused silent data loss for two writes from the same session:

  • memory/self-audit-latest.md (a fresh self-audit run) was written to the phantom; real
    workdir's copy stayed stale.
  • memory/2026-05-27.md (today's daily note) was duplicated across both directories with
    different content in each.

Reproduction

Hard to reproduce deterministically without an upgrade in-flight. The signal is:

  1. Run assistantplatform doctor --repair while a memory-flush write is in progress (or close to
    it). [Speculative — exact trigger unconfirmed, but doctor --repair was running just before
    the phantom dirs appeared at the same timestamp as their ctime.]
  2. After upgrade completes, check ls -lai ~/.assistantplatform/ for duplicate workspace entries
    with different inodes.

Evidence (collected from this deployment)

$ ls -lai ~/.assistantplatform/  # (real path; bytes 2e6f70656e636c6177)
11349020 drwx------ 6 <user> staff 192 May 27 21:11 .
11388251 drwx------ 3 <user> staff  96 Apr 15 16:02 agents
14900091 drwx------ 3 <user> staff  96 Apr 29 17:45 credentials
17379862 drwx------ 3 <user> staff  96 May 27 21:11 workspace   <-- PHANTOM (rebranded display name)
11349021 drwx------ 9 <user> staff 288 May 12 13:29 workspace   <-- real

$ os.listdir(b"~/.assistantplatform/")  # raw bytes
[b'agents', b'credentials', b'workspace', b'workdir']
# Display rebrand: 'workdir' = legacy/AssistantPlatform branding (7 bytes ASCII)
#                  'workdir'   = AssistantPlatform rebrand display (also rendered identically in
#                                terminal output but distinct on disk)

Phantom contents:

17379862 workspace/
└── memory/   (created 21:11 BRT)
    ├── self-audit-latest.md  (7883 bytes, 21:11 — duplicate of real)
    └── 2026-05-27.md         (570 bytes, 21:13 — DIFFERENT content from real)

Side effect: file-rendering substitution makes debugging confusing

Workdir-root files are stored under legacy names (HEARTBEAT.md, CONFIG.md, NOTES.md, SETUP.md,
PERSONA.md, PROFILE.md, ABOUT.md, MODULE.md) but the UI/chat layer displays them as
their AssistantPlatform-rebranded forms (PING.md, CONFIG.md, NOTES.md, SETUP.md, PERSONA.md,
PROFILE.md, ABOUT.md, MODULE.md). This is intentional and works fine — the path-resolver
translates both ways. The issue is that during the phantom-confusion window, error messages
referenced the rebranded names but the actual ENOENT was against a real legacy path, making
the problem opaque.

Impact

  • Data loss: Two memory writes to the wrong directory; not noticed until 4 hours later.
  • Investigation cost: 90+ minutes of model time trying to reconcile path resolution.
  • Audit corruption: Self-audit snapshot in the phantom dir was newer than the real one,
    so the next audit comparison would have referenced stale data if not detected.

Suggested fix

  1. On upgrade: detect existing ~/.<legacy>/<...> dir and skip creating any phantom rebrand
    directory at the same level. Either symlink the new name to the old one, or refuse to create
    a parallel directory if one with the legacy bytes already exists.
  2. Memory-flush write path: validate the target file path resolves under the active
    workdir (read from the same source as $PWD/runtime workdir env), not from a freshly-cached
    value at process start.
  3. Self-audit hint: add a phantom-detection check (Cortana deployment already added this as
    self-audit check Feature Request: Per-Chat Working Directory (cwdOverrides) #14 — see attached). Detect when ~/.<dotdir>/ contains both rebranded and
    legacy versions of any subdir name.

Workaround for affected deployments

import os
# Always derive paths from the runtime env, never from typed literals
os.chdir(os.environ["PWD"])
# For directory listings, use raw bytes to expose duplicates
for entry in os.listdir(b"."):
    real_name_hex = entry.hex()  # see the actual on-disk bytes

For directories where you suspect phantoms exist:

ls -lai ~/.assistantplatform/ | awk '{print $1}' | sort | uniq -c | sort -rn | head
# If any inode appears more than once with the same display name, you have a phantom

Environment

  • macOS Sequoia 15.6 (arm64), Mac Mini
  • node v22.22.0
  • AssistantPlatform 2026.5.26 (upgraded from 2026.4.23 on 2026-05-27 19:54 BRT)
  • APFS (no Unicode normalization tricks; confirmed via raw byte inspection in os.listdir)
  • ~6,000+ memory chunks, custom org-internal deployment with on-call coordination agents

Attached evidence

Activity

  1. clawsweeper commented on May 28, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Current main now keeps memory-flush writes rooted in the active workspace and carries that workspace through the CLI runner, covering the central divergent-write failure reported here. The historical duplicate directories cannot be reconstructed from the report, but current recovery deliberately avoids guessing how to merge pre-existing divergent trees.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the single prepared-workspace flow and the conservative non-merging migration behavior; handle any still-existing divergent historical trees through an explicit operator recovery rather than an automatic merge.

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

    No current-release reproduction is available: the report describes a historical upgrade race, while current source and focused regression coverage demonstrate the corrected workspace-rooted write path.

    Is this the best way to solve the issue?

    Yes for the reported runtime failure: carrying the prepared workspace through the owner path is more maintainable than a downstream path check or automatic merge of conflicting user trees.

    Security review:

    Security review: This is issue triage without a proposed patch or security-boundary report.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Current workspace-rooted memory flush: The focused regression asserts that a memory flush with a distinct current directory writes only below the configured workspace and does not create a memory file under the alternate directory. (src/agents/agent-tools.create-openclaw-coding-tools.test.ts:2178, 7ecdef6e2ed4)
    • Runtime passes the prepared workspace to the CLI path: The CLI runner now supplies the run workspace explicitly to its transcript/flush-related path rather than deriving it from an unrelated process directory. (src/agents/cli-runner.ts:1529, 7ecdef6e2ed4)
    • Fix provenance: Commit 25dfe92, titled "fix(agents): pass workspace to cli flush probe", introduced the explicit workspace handoff that the current runner and regression coverage retain. (src/agents/cli-runner.ts:1529, 25dfe9294fbb)
    • Current-main release provenance: The fix is reachable from current main; the local promisor history could establish its commit timestamp and current-main behavior but not tag containment, so no shipped release is asserted. (25dfe9294fbb)
    • Existing divergent roots are not silently merged: State migration renames a single legacy root and creates a legacy symlink, but stops with an operator-facing manual-merge instruction if both roots already exist; it does not overwrite or combine divergent user memory automatically. (src/infra/state-migrations.state-dir.ts:219, 7ecdef6e2ed4)
    • Maturity classification: The required shortlist identifies the primary owner as session-memory, scored M3 Beta; Doctor/CLI transit does not make this an M4/M5 issue. (qa/maturity-scores.yaml, 7ecdef6e2ed4)

    Likely related people:

    • Ayaan Zaidi: Authored the workspace handoff fix retained by the current CLI runner and its focused regression coverage. (role: fix author; confidence: high; commits: 25dfe9294fbb; files: src/agents/cli-runner.ts, src/agents/cli-runner.binding-flush.test.ts)
    • Peter Steinberger: Recent current-main history touches the memory-runner area that enforces flush target containment; the available shallow history cannot establish original ownership. (role: recent adjacent contributor; confidence: low; commits: fa0fcef; files: src/auto-reply/reply/agent-runner-memory.ts)

    Codex review notes: model internal, reasoning high; reviewed against 7ecdef6e2ed4; fix evidence: commit 25dfe9294fbb, main fix timestamp 2026-05-30T10:09:19+05:30.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:data-lossCan lose, corrupt, or silently drop user/session/config data.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on May 28, 2026
  3. added
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    P2Normal backlog priority with limited blast radius.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    P1High-priority user-facing bug, regression, or broken workflow.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    on Jul 29, 2026
  4. self-assigned this
    on Aug 12, 2026
  5. vincentkoc commented on Aug 12, 2026

    @vincentkoc
    Member

    Closing as already fixed, with corrected provenance from the earlier review.

    The primary fix is #87218, landed as 7299c56. It carries task cwd separately from the configured agent workspace across native and Codex sub-agent paths; its regression coverage verifies that memory-flush writes land in the workspace and no alternate-cwd file is created. This matches Codex app-server's explicit per-thread and per-turn cwd contract: https://github.com/openai/codex/blob/414782450952a196bbb64b1605a458c2531c47b6/codex-rs/app-server-protocol/src/protocol/v2/thread.rs#L55-L73 and https://github.com/openai/codex/blob/414782450952a196bbb64b1605a458c2531c47b6/codex-rs/app-server-protocol/src/protocol/v2/turn.rs#L95-L102.

    Adjacent Claude CLI proof is #84234, specifically 25dfe92, which passes the prepared workspace/cwd into the transcript-flush probe. Existing divergent roots are deliberately not auto-merged: migration stops with manual reconciliation guidance when both roots exist, preserving distinct user data.

    Both commits are contained in shipped release https://github.com/openclaw/openclaw/releases/tag/v2026.7.1-2. No further code change is needed.

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

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.close:already-fixedclaw-marshal labelimpact:data-lossCan lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions