Repository navigation
Description
Problem
capability_init (agentdescent/surface_capability.py:192-231 at live main 41b5c587) writes two leaves under the --out directory:
<dir>/capability-traces.jsonlwith a plainopen(traces_path, "w")in the--demobranch (:196-205) — no leaf check.<dir>/spec.jsonthroughatomic_write_json(:231), whose leaf link is already refused (fix(surface): refuse a symlinked destination in atomic_write_text instead of replacing the link #1031).
So the second leaf is guarded and the first is not: a symlink planted exactly at the traces leaf is followed, and the file it points at is destroyed. Measured at 41b5c587 with outside/keep.json = ORIGINAL-OUTSIDE-BYTES:
| # | shape | result | outside file |
|---|---|---|---|
| A | link at out/capability-traces.jsonl, capability init --demo --out out/spec.json |
exit 0, link still a symlink | rewritten with the demo trace JSONL, sha256 b1b717df59e7fab3 → fcf7cb8df79084f1 |
| B | link at out/spec.json, same command |
exit 2, one clean SurfaceError: cannot write .../out/spec.json: 'spec.json' is a symlink |
untouched — but out/capability-traces.jsonl is already on disk (452 bytes) when it refuses, so the command leaves a half-written fixture |
| C | no links (control) | exit 0, both leaves written | untouched |
| D | link at the traces leaf, --demo omitted |
exit 0, leaf untouched | untouched — the --demo branch is the writer, so only that path is exposed |
Fix shape
The rule is already in the tree: _refuse_linked_dest in agentdescent/demo.py:259-283 (#1017 / #1021) checks every fixture leaf with filetree.dest_problem(root, path) before the first byte, precisely because "a partial fixture is worse than no fixture". This surface's fixture skipped that rule.
- In
capability_init, beforeos.makedirswrites anything:filetree.dest_problem(directory, traces_path)and the same fortarget, raisingSurfaceError(f"cannot write {path}: {problem}"). - That also settles row B: refuse both leaves up front instead of writing the traces and then failing on the spec.
- One test covering A and B (exit 2, one
error:line, outside sha unchanged, no fixture leaf left behind), plus C/D as controls.
Scope
agentdescent/surface_capability.py, its test file, one changelog.d/ fragment, one docstring line on the writer. T2 by path.
Probe: run-1114-0114/ (Product) and a Lead re-run of all four rows through the real CLI.
Activity
HugoXK commentedon Nov 14, 2026
Claim: branch
agent/1043-capability-trace-leaf, cut from live main41b5c587733abfd9bceb4c2f1a8dfe87d866feaf.Red first with only the new test file, then the guard:
filetree.dest_problem(directory, traces_path)and the same fortargetbefore the first byte, wrapped asSurfaceError(f"cannot write {path}: {problem}"), following_refuse_linked_destindemo.py.Field note: assignee set,
agent-workingadded, for this claim.test(cli): red rows for a hardlink and a directory at the capability …
fix(cli): stage the capability traces fixture so a linked leaf keeps …
fix(cli): make the capability traces durable and interrupt-safe, spec…
fix(capability): refuse a link at the capability fixture leaves befor…