← Back to Pull requests

fix(init): keep a running role's read-only binds: the dot-file written in place, a breaking --init refused (#389) #402

Closed
unknown closed this pull request without merging on Nov 14, 2026 16:19 UTC
View on GitHub
unknown unknown commented on Nov 14, 2026 07:47 UTC
Author

asb --init and asb --apply replaced .agent-sandbox by renaming a new file over it. A running sandbox has single-file mounts on some of the project's files: the dot-file and the role's purpose file read-only, or a copy of the role's own over one. A host rename over such a file detaches the mount. In a role with the project read-write (the roles model's Supervisor and setup), the path then led to the host's new file, writable; this was measured with the Supervisor running.

  • The dot-file is written in place. An existing .agent-sandbox keeps its inode and mode; it is written through a descriptor shown to be the file, then cut to the new length. A running role sees the new text and still cannot write it. --setup-remote's policy write does the same, and brings back what the write said there. A file that is not writable is refused before anything is written. A write that fails midway says the file may be half-written and keeps the intended text in a file it names. A dot-file with another name (a hard link) is still written in place, with a warning and the find line, starting at the file's mount point, that lists the other names.

  • A launch records its single-file mounts. Those that sit on a host file go in keeper/binds: the mount point's host path, whether its directory is read-write or read-only from the host, the mount's own mode, and whether its source is the file itself. A read-write mount of a file over itself on a copy-on-write project is recorded too.

  • --init refuses a breaking run. Before writing anything, it refuses (exit 2) a run that would:

  • - replace such a file in a directory the role has read-write, unless the role had the file itself read-write (e.g. the Supervisor's purpose file when the model text changed, also when the role has its own copy over it);
    - replace one where the role would lose its own copy or read-write mount in a read-only project;
    - replace or remove one the role has read-write in a copy-on-write project, where its writes would stop reaching the project's file;
    - remove one mounted into a running role with the project read-write or read-only (e.g. implementer=1 while implementer-2 runs);
    - add an instance again while a running sandbox has that instance's old clone declared, or as its project, which the backup would move from under it.

    It looks at every running sandbox of yours, another project's included when it has this project's files mounted. It names each role (with its project when it is another's), the file, and the asb --role ROLE --shutdown to run first. A sandbox started by an older asb, or one whose launch could not be recorded, has its declared files taken as mounted.

  • What goes ahead. Roles with the project read-only keep running and see the new text. Under a copy-on-write project the old read-only or copied file stays. A role's read-write declaration over a file in a read-write project is no reason to refuse. A count that removes a running instance with no file of it bound going is not refused: its sandbox keeps the policy it launched with until it is shut down. The dot-file is never a reason to refuse. --init no longer renames a file over one with the same text, and a plain re-run counts no bookkeeping file as changed.

  • What remains. A write outside asb to .agent-sandbox, a purpose file, or a file in a host-bound directory that a role has read-only or as its own copy (e.g. CLAUDE.md with instructions = read-only, or the role's .claude.json, under --preset shared) still detaches a running role's mount where that directory is read-write for it. Examples: an editor's save by rename, sed -i, a git checkout. docs/design.md lists it with what remains.
  • Tests: unit tests for the in-place write and its failures, the mount record, and each refusal and go-ahead case; a new integration suite tests/integration/init-running.bats under real bwrap.

    Refs #389 (point 7)

    ---
    _🤖 Drafted by Claude Code (an AI agent) and reviewed & approved by pearu._

    Diff: 502 lines (+376 / -126) across 6 files Reviewer: pearu Review duration: 512m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 502 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.372
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #402"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.8% · Safe to merge
    18.8%