Skip to content

fix(runtime): resolve physical roots before logical /data aliases #433

Description

@GTC2333

Problem

When BP_DATA_DIR=/data, the agent workspace and persistent library use physical paths under the same prefix that is also treated as a logical alias:

  • workspace: /data/workspaces/<session>
  • persistent library: /data/data
  • logical /data/...: persistent library

Structured file tools currently interpret every /data/... as a logical path before checking whether it is already a real path under the current workspace or persistent directory. This rewrites workspace paths to /data/data/workspaces/... and can rewrite /data/data/... to /data/data/data/.... Bash still uses the physical path, so Bash and read/write/edit disagree about the same string.

Root cause

rewriteLogicalPath selects /data by string prefix before classifying known physical roots. Existing tests use /root/.bp-root, so they do not cover the production collision.

Proposed fix

  • For absolute paths, classify current workspace, attachments, persistent, and shared physical roots first.
  • Apply logical aliases only when the path is not already under a known physical root.
  • Keep HTTP Files API logical-path behavior unchanged.
  • Add regression tests with cwd=/data/workspaces/s1 and persistentDir=/data/data.

Acceptance criteria

  • Structured tools and Bash address the same workspace file.
  • Real persistent paths are not rewritten twice.
  • Logical /data/x still maps to /data/data/x.
  • /workspace/x remains session-scoped.
  • Existing traversal and cross-session confinement tests continue to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions