Repository navigation
Realize harden-path-escape-helpers-against-symlink-loops § 3: the four containment guards answer a symlink loop (refs #1074) - #1107
Conversation
`harden-path-escape-helpers-against-symlink-loops` § 3.1, § 3.3 and § 3.5,
taken as ONE act because `design.md` D2 ruled it one: `code_surface`'s
docstring ends "`target_release._unescaped` is the exact shape this mirrors"
and `target_release._unescaped`'s opens "THIS IS `_registry_present`'S TEST,
GENERALIZED TO ANY PATH THIS MODULE OPENS", and correcting one module alone
would leave a documented claim of identity FALSE — which misleads the next
reader more than no claim would, the claim being what tells them they need
only understand one of the two.
§ 3.1 `scripts/code_surface.py`: `_unescaped`'s clause widened to
`except (OSError, RuntimeError):`, and its docstring amended to name
`RuntimeError` beside `OSError` as a failure this guard closes,
keeping its written claim that `target_release._unescaped` "is the
exact shape this mirrors" TRUE.
§ 3.3 `scripts/target_release.py`: `_unescaped`'s clause and
`_registry_present`'s clause both widened to
`except (OSError, RuntimeError):`, and both docstrings amended,
`_unescaped`'s keeping its claim to generalize `_registry_present`'s
test TRUE.
§ 3.5 `scripts/proposal-support.py`: `_contained`'s clause widened to
`except (OSError, ValueError, RuntimeError):`, the `ValueError`
guarding the relative-path computation's own failure and STAYING;
`contained_dir` and `contained_file` docstrings amended to name the
set.
`Path.resolve(strict=True)` signals a symlink loop as `RuntimeError`, a
subclass of neither `OSError` nor `ValueError`, so all four clauses were open
at exactly that failure and three of the four are driven to it by a COMMITTED
tree shape. Re-measured on this head (`3e32d987`) at the packet's own line
numbers, unchanged from `c6997f12`: `code_surface.py:777`,
`target_release.py:394` and `:630`, `proposal-support.py:347`.
`_registry_present` is widened too (D3) although NO tree state reaches its
clause — `is_dir()` absorbs the loop as `OSError(ELOOP)` and answers `False`
in all three positions (D0.5, re-measured here) — because a pre-check and a
resolution are two separate reads of a tree that can change between them, and
because a reader of the module sees the clause and not the pre-check.
FOUR CLAUSES AND FIVE DOCSTRINGS, AND NOTHING ELSE. `git diff -U0 -- scripts/`
removes exactly four lines, the four clauses. The ELEVEN other
`except OSError`-family clauses `design.md` D4 enumerates — `code_surface.py`
:568 and :656, `target_release.py` :337 and :528, `proposal-support.py` :162,
:416, :2541, :3724, :4290, :4312 and :4511 — guard reads, writes and
subprocesses where a `RuntimeError` would be a defect in this repository's own
code, and are deliberately left (§ 6.1); so is
`proposal-support.py:3939`'s already-wider `except Exception:`.
Refs #1074
Refs #1083
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…lause
`harden-path-escape-helpers-against-symlink-loops` § 3.2, § 3.4 and § 3.6.
FOUR cases, ONE PER CLAUSE, in THREE packages — which is the packet's own
count and the reason it is not one per module:
§ 3.2 `tests/code_surface/`: one test that builds an `a -> b -> a` loop
under `tmp_path`, in ALL THREE exposed positions the first requirement
names (the candidate's own leaf; a parent component above an ordinary
leaf; and the SCANNED ROOT itself, `spec.md`'s third scenario), and
asserts `_unescaped` returns `None` in each.
§ 3.4 `tests/target_release/`: TWO cases. One for `_unescaped` in all three
positions, as 3.2; and one for `_registry_present` DECLARED AS A TEST
OF THE CLAUSE, with the declaration in the test's own docstring and
not only in this packet, and driven by a seam that makes the pre-check
pass while the resolution fails, so it still FAILS against the unfixed
clause.
§ 3.6 `tests/proposal-support/`: one test that builds the loop and asserts
`contained_dir` and `contained_file` return `False`, in all three
positions, plus the CLEAN-CANDIDATE sub-case that only this guard of
the four reaches — a real candidate under an unresolvable root, so
`proposal-support.py:343` succeeds and `:346` raises — asserted here
and claimed nowhere else.
THE PAIR OF RUNS, NOT THE PASSING HALF. Against the unfixed clauses, on
`Python 3.12.3` (the version `.github/workflows/pytest-suite.yml` pins):
4 failed, each with `RuntimeError: Symlink loop from …` out of
`code_surface.py:775`, `target_release.py:392` (the seamed clause test),
`target_release.py:628` and `proposal-support.py:343`. Against the widened
clauses: 4 passed. The three-package suite is 452 passed, 296 subtests passed.
Each of the three positions was verified to drive the clause on its own, and
in the third the loop is reached THROUGH THE CANDIDATE and never through a
separate root read: `candidate = repo_root / relative` traverses it, so
`code_surface.py:775` / `target_release.py:628` raises and the root
resolution on the next line is never executed (`design.md` D5). The
`_registry_present` case re-measures D0.5 first — unseamed, all three
positions return `False` at the `is_dir()` pre-check — which is both the
correction to #1074's own text and the reason that case has to be a clause
test rather than a fourth tree fixture.
§ 3.7 NO SYMLINK IS ADDED TO THE TRACKED TREE: every loop is built at test
time under the test's own temporary directory and torn down with it;
`git ls-files -s | awk '$1 == "120000"'` returns nothing.
§ 3.8 NO OTHER FILE MOVES: `git diff --stat origin/main` is six files, three
scripts and these three test files, and `git diff -U0 -- tests/` removes not
one line — no existing test is edited, renamed, flipped or deleted.
ONE DEPARTURE FROM § 3.6'S LETTER, IN ITS OWN SPIRIT.
`tests/proposal-support/test_proposal_support.py` is a pure `unittest` module
ending in `unittest.main()`, and a pytest-fixture function added to it would
silently not run under that entry point. The loop is therefore built under
`TemporaryDirectory()`, which is this package's spelling of `tmp_path` and is
exactly what the ratified requirement asks for: "SHALL BUILD THAT LOOP AT TEST
TIME, under the test's own temporary directory".
Refs #1074
Refs #1083
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Reviewer's GuideThe PR closes symlink-loop escape and containment failure paths by catching Sequence diagram for symlink-loop containment guardssequenceDiagram
participant Validator
participant Guard
participant Path
participant Filesystem
Validator->>Guard: _unescaped(repo_root, relative)
Guard->>Path: candidate.resolve(strict=True)
Path->>Filesystem: Resolve candidate path
Filesystem-->>Path: Symlink loop
Path-->>Guard: RuntimeError
Guard-->>Validator: None
participant Containment
Validator->>Containment: contained_dir(root, path)
Containment->>Path: resolved.relative_to(root.resolve(strict=True))
Path->>Filesystem: Resolve root or candidate
Filesystem-->>Path: Symlink loop
Path-->>Containment: RuntimeError
Containment-->>Validator: False
Flow diagram for symlink-loop guard handlingflowchart TD
A[Path resolution begins] --> B{Resolution succeeds}
B -->|Yes| C[Apply containment or registry judgment]
B -->|OSError| D[Return safe negative answer]
B -->|ValueError in containment| D
B -->|RuntimeError symlink loop| D
D --> E[Drop candidate or report absent/uncontained]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟢 Approval recommended
All reviewed changes are covered by regression tests and no unresolved blocking issues remain.
Pull request overview
Hardens path-containment helpers against symlink-loop resolution failures and adds temporary regression coverage.
Changes:
- Catch
RuntimeErrorfrom symlink loops. - Update containment documentation.
- Add coverage across affected validators and loop positions.
File summaries
| File | Summary |
|---|---|
tests/target_release/test_target_release_gate.py |
Tests candidate and registry loop handling. |
tests/proposal-support/test_proposal_support.py |
Tests containment failures. |
tests/code_surface/test_code_surface_gate.py |
Tests loop handling in three positions. |
scripts/target_release.py |
Hardens registry and candidate checks. |
scripts/proposal-support.py |
Treats looped paths as uncontained. |
scripts/code_surface.py |
Hardens _unescaped. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…oop is dropped, never a traceback, in all three path-escape helpers (#1083) Refs #1074. Proposal packet harden-path-escape-helpers-against-symlink-loops, PACKET ONLY: two ADDED requirements over release-realization (ten scenarios), the README Active changes bullet and the sweep-ledger row. RATIFIED by Brett Heap 2026-09-18 ~09:55Z, verbatim "Ratify; land when green" (terminal multiple-choice answer to lane openXfactory-5), encoded in the packet; LANDED on his word of 2026-09-18 ~14:20Z, verbatim "land #1083". pytest-suite is red only on main's own archive-date-vs-commit finding for 2026-09-16-add-composed-view-authoring (identical on main's run 35336659842; dispositioned on the PR), which this packet does not touch. The realization is PR #1107; the archive is a separate act on a separate word. Lane: openxfactory-5 (openXfactory-5) Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues remain; only a minor documentation nit was identified.
Review details
Suppressed comments (1)
tests/proposal-support/test_proposal_support.py:4221
- This docstring says the test uses this package's
tmp_path, but this unittest module actually creates its temporary directory withTemporaryDirectory()below. That makes the stated fixture/API inaccurate; please nameTemporaryDirectory()(or simply say “temporary directory”) so the test documentation matches the implementation.
directory, which is the second requirement's rule and this package's
`tmp_path`: a committed loop is tracked as two ordinary git objects
- Files reviewed: 6/6 changed files
- Comments generated: 0 new
- Review effort level: Lite
…oops with this PR's own evidence `harden-path-escape-helpers-against-symlink-loops` § 3 and § 4, realized by this pull request (#1107, commits `17390262` the four clause widenings, `4892fa5f` the four test cases) and now on this branch after merging `origin/main` (`ebcdbc0c`, #1083's landing of the packet) in the preceding commit. § 3.1/3.3/3.5 (the three modules): DONE, cited by commit and current line number, docstring claim of identity (code_surface._unescaped mirrors target_release._unescaped; target_release._unescaped generalizes _registry_present's test) kept TRUE because all four clauses widen in one commit, per design.md D2's ruling. § 3.2/3.4/3.6 (the four test cases): DONE, cited by test id, with the fails-then-passes pair the requirement demands (RuntimeError against c6997f1's clause, PASSED against this branch's). § 3.7/3.8: PROVEN, re-run at the merged head 87eb684 — `git ls-files -s | awk '$1 == "120000"'` empty; `git diff --stat origin/main` names exactly the six files (three modules, three test files), the four deleted lines being exactly the four unwidened clauses. § 4.1/4.2: GREEN, re-run at 87eb684 — `452 passed, 297 subtests passed` (the three packages; +1 subtest is the corpus sweep now counting this packet's own directory, admitted by the merge); the three live-corpus validators all exit 0. § 4.3: PROVEN, the two design.md D0.3 trees rebuilt and the four tracebacking entry points plus the fifth (unchanged) reader re-run at 87eb684, reproducing PR #1107's own body table exactly. § 4.4: LEFT OPEN, `- [ ]`, with a dated note. pytest-suite at 87eb684 (run 35354873708, 14m9s) is red on exactly four tests, all in tests/sequenced_after/, all one finding — archive-date-disposition STALE: 2026-09-16-add-composed-view-authoring — none touching this packet's six files. Confirmed inherited and not caused here: the identical 4-failure signature reproduces on a clean worktree at plain origin/main (ebcdbc0) with no realization content at all. main is red on this today (lane openxfactory-4's 2026-09-16-add-composed-view-authoring; repair PR #1109 in flight). § 5 and § 6 untouched; `.openspec.yaml` untouched (its own tasks name no realization field to record). Validated at this head: `openspec validate harden-path-escape-helpers-against-symlink-loops --strict` passes; `--all --strict` 109/110 pass (the one failure, add-chain-attestation, is untouched by this branch and pre-existing on main); `pytest tests/code_surface tests/target_release tests/proposal-support tests/sequenced_after -q` → 4 failed (the inherited finding above), 734 passed, 297 subtests passed; `validate-code-surface.py .` and `proposal-support.py . verify harden-path-escape-helpers-against-symlink-loops` exit 0; `validate-sequenced-after.py . --ledger-diff` exit 0, ledger consistent (220 rows). Refs #1074 Lane: openxfactory-5 (openXfactory-5) Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Add explicit loop assertions in the parent/root tests and reconcile the task-file scope discrepancy.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
tests/code_surface/test_code_surface_gate.py:619
- These parent/root cases do not verify that the fixture actually produces
RuntimeError: if_symlink_loopfailed to create a loop and the remaining path were merely missing, the unfixedexcept OSErrorwould still returnNoneand these assertions would pass. Since the PR's proof requires a failing run against the old clause, explicitly assertparent_loop.resolve(strict=True)andlooped_root.resolve(strict=True)raise before invoking_unescaped.
_symlink_loop(parent_root, "openspec")
assert cs._unescaped(
parent_root, Path("openspec/changes/a-packet/proposal.md")) is None
tests/target_release/test_target_release_gate.py:726
- The parent and scanned-root assertions do not independently establish a symlink loop. If either helper call produced a missing path rather than a loop, the baseline
except OSErrorwould also returnNone, so the advertised failing-then-passing proof would be incomplete. Addpytest.raises(RuntimeError)checks for the parent-loop path andlooped_rootbefore calling_unescaped.
_symlink_loop(parent_root, "openspec")
assert tr._unescaped(
parent_root, Path("openspec/changes/a-packet/proposal.md")) is None
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
Resolve the discrepancy between the documented six-file scope and the modified task file.
Review details
Suppressed comments (1)
openspec/changes/harden-path-escape-helpers-against-symlink-loops/tasks.md:126
- The PR description says this realization changes six files and that nothing in the packet directory is touched, but this diff also modifies this packet's
tasks.md(and records the verification state there). Please either update the description/file count to include this bookkeeping change or remove the packet edit if it is not intended to be part of this PR.
- [x] 3.1 `scripts/code_surface.py`: `_unescaped`'s clause widened to
- Files reviewed: 7/7 changed files
- Comments generated: 0 new
- Review effort level: Lite
pytest-suite is GREEN at PR #1107 head 8fb0fc9, run 35359208240 (2026-09-18), confirmed by `gh run view 35359208240 --json conclusion` returning success. Appended beside the prior LEFT OPEN note (which recorded the inherited red at the earlier head 87eb684, since repaired on main) rather than replacing it, because the tick itself is the ARCHIVE act's: taken from main's own green run at the landed merge, since a tick commit always moves the head past the run it cites (the add-declared-former-id precedent). Item stays - [ ]; § 5 stays - [ ]; § 6 stays - [~]. Lane: openxfactory-5 (openXfactory-5) Refs #1074 Refs #1083 Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Task §4.4 remains unchecked despite green evidence, and the packet description conflicts with the seven-file diff.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
openspec/changes/harden-path-escape-helpers-against-symlink-loops/tasks.md:141
- The realization description says this PR contains six files and that nothing in the packet directory is touched, but this change also modifies this packet's
tasks.md(and the added text itself records those task updates). Please reconcile the PR description with the actual seven-file diff so the landing/archive record is not misleading.
**DONE, commit `17390262` (PR #1107)**: the clause reads
`except (OSError, RuntimeError):` at `scripts/code_surface.py:791` (the
docstring's own growth moves the line off the packet's `:777`
measurement; the two resolutions it guards are unmoved). The docstring
now reads "`Path.resolve(strict=True)` reports a missing or unreadable
component as an `OSError` and a SYMLINK LOOP as a `RuntimeError` … A
clause naming only `OSError` is open at exactly the loop" and still
closes "`target_release._unescaped` is the exact shape this mirrors" —
kept TRUE because `target_release._unescaped`'s own clause widens in the
SAME commit (§ 3.3). `git show 17390262 --numstat --
scripts/code_surface.py`: `15 1`.
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 3 days and 7 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
|
Lane: openxfactory-5 (openXfactory-5) LANDING — lane openXfactory-5, session 651195c7-1854-491e-894a-e6542ef5e9f4@Eagle, 2026-09-18T17:06:12Z, PR #1107 into opensoft/openxFactory main |
|
Lane: openxfactory-5 (openXfactory-5) LANDED — lane openXfactory-5, session 651195c7-1854-491e-894a-e6542ef5e9f4@Eagle, 2026-09-18T17:06:34Z, PR #1107 into opensoft/openxFactory main → merge c22c4fc; Realize harden-path-escape-helpers-against-symlink-loops § 3: the four containment guards answer a symlink loop (refs #1074) |
…DME entry
The archive makes this packet's per-change sweep-ledger row stale by that
ledger's own design, so it is re-seeded with the sanctioned tool and with no
hand edit:
python3 scripts/validate-sequenced-after.py . --seed-ledger --moved-by '#1116'
-> wrote tests/sequenced_after/corpus-ledger.yaml (221 rows, 1 moved by #1116)
- harden-path-escape-helpers-against-symlink-loops
Before the seed, --ledger-diff read "per-change sweep ledger STALE (4
finding(s))": this change's row plus the three derived totals it feeds (active
ledger-derived 47 != measured 46; archived 174 != 175; active_sole 20 != 19).
After: "per-change sweep ledger consistent with the corpus (221 rows)".
EXACTLY ONE ROW MOVES and no code byte moves: state active -> archived,
moved_by "#1083" -> "#1116", moved_on 2026-09-17 -> 2026-09-18. `class: sole`
is HELD -- this change writes two requirement keys novel to the whole corpus,
so no partner flips from sole to co-modifier and NO MOVEMENT LOG entry is owed.
The same commit writes PR #1116 into the README archived-ledger entry in place
of the ARCHIVE-PR-NUMBER-PENDING marker the archive commit deliberately left:
the real number does not exist until the pull request does, which is why this
is a second commit and not a hand edit to the first.
Refs #1074
Refs #1083
Refs #1107
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…arrier-identity check `tasks.md` § 3.2, quoted: "`scripts/estate_inventory.py` (NEW): the reader and the row-level judge, in the shape `scripts/code_surface.py` uses: read through the shipped strict loader, no second parser, no path reached through a symlink at leaf or ancestor, deterministic, no network. Public: load the inventory, resolve an identifier (address, bare name, or former address through `contracts/policies/repository-identity.yaml`), and report the row-level findings § 3.4 gates. IT RE-CHECKS THE FOUR IN-TREE KINDS ONLY … It also carries the CARRIER-IDENTITY CHECK that mode uses — given a path, read the tree's own origin URL and normalize it, and resolve a FORMER carrier address through `contracts/policies/repository-identity.yaml` — returning verified / unverified rather than raising, so § 3.3 can report an unverified tree as NOT RE-CHECKED instead of failing the run (ruling "Bind the carrier identity", § 1.5 (a))." WHAT IS HERE. `load_inventory` reads the file through `frontmatter_strict. strict_load` — the shipped strict loader, no second parser — and REFUSES rather than picks: a duplicate address, a shared bare name (naming BOTH rows, because "picking is how an authorization lands in the wrong repository"), a kind outside the closed five, a governance class outside the closed three, an admission with no site, a `gitlink` with no carrier, a `change` whose id is not a change-directory name, a `pin`/`workflow` path that is absolute, carries `..` or sits outside the directory its kind names, and — both ways — a `provisional:` that disagrees with the presence of a `change` admission. `resolve` resolves three spellings and no fourth: an address against a row's address, a bare name against a row's unique bare name, a FORMER address through the transfer map to a current row, carrying WHICH of the three happened so the caller can report the former case rather than refuse it (`design.md` D5). Nothing is resolved by asking the provider. The comparison is CASE-SENSITIVE because the transfer map's own `field_rules.current` says this estate compares the owner segment case-sensitively "even where the provider compares case-insensitively" — a case-insensitive resolver would admit exactly the spellings each row's `owner_case` names as NOT this estate's. `load_transfers` drops the PENDING rows, which is the map's own `pending_row_rule` and not a strictness invented here: a pending row declares a change that has not happened, and every use this module makes of the map is a live reference. `evidence_verdicts` re-checks the four IN-TREE kinds on every run and reports `gitlink` as NOT RE-CHECKED without exception — not passed, not failed. A `pin` or `workflow` whose file is present but no longer NAMES the row's repository is GONE too: presence of the file is not presence of the evidence. A `change` is judged in three states, and the archived one's detail names both remedies the requirement reaches. `carrier_identity` NEVER RAISES. It reads the tree's own origin URL (`git -C <path> remote get-url origin`, a local config read that reaches no network), normalizes past the `git@`/`https://` spellings and the `.git` suffix, and verifies against the carrier or against the carrier's FORMER address through the transfer map — the two places this estate already states an identity. Every failure (no git, no repository, no origin, an unrecognized URL spelling, a timeout) returns unverified, because the one verdict for a tree that could not be confirmed is NOT RE-CHECKED and a raise would turn a caller's typo into a failed run. THE CONTAINMENT GUARDS ARE MIRRORED AND NOT APPROXIMATED. `_has_symlinked_ancestor` and `_unescaped` are `code_surface.py`'s exact shapes, including `except (OSError, RuntimeError)` — `Path.resolve(strict=True)` reports a SYMLINK LOOP as a `RuntimeError`, a subclass of neither `OSError` nor `ValueError`, so a clause naming only `OSError` is open at exactly the loop (openxFactory #1074, realized at PR #1107). Exercised over the live tree: 33 rows load; the six identifiers the corpus declares all resolve (three by bare name, three by address); `opensoft/ codexFactory` resolves as a FORMER address to `codeXfactory/codexFactory`; `openxFactorie` does not resolve; 30 admissions report NOT RE-CHECKED, 9 NAMED, 0 GONE. Refs #1087 Refs #1101 Lane: openxfactory-5 (openXfactory-5) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…87eb684 Copilot found the § 3 bullet naming 87eb684 as the realization head that tasks.md's §§ 4.1-4.3 measurements were re-run at. 87eb684 is PR #1107's intermediate merge of origin/main on that branch, not its actual head: the realization head was bc9ebf9, merged to main as c22c4fc (already correct at line 45's Green-at-the-realization-head row). The measurements were genuinely taken at 87eb684 per tasks.md's own text, so that citation stands; only the mislabel is corrected. Lane: openxfactory-5 (openXfactory-5) Co-Authored-By: Claude Fable 5.1 <[email protected]> Refs #1074
…d-plus-green realization evidence (#1083 → ebcdbc0, #1107 → c22c4fc, main green at 049d54a) (#1116) Closes #1074 (the packet's § 5.3: the archive pull request closes the governing issue by a closing keyword written here and in no commit message). ARCHIVE of harden-path-escape-helpers-against-symlink-loops on merged-plus-green realization evidence: proposal PR #1083 → ebcdbc0, realization PR #1107 → c22c4fc, main pytest-suite green at 049d54a (run 35372664200). Promotes the two ADDED requirements (ten scenarios) onto release-realization; tasks.md §§ 4.4 and 5 ticked on that evidence. LANDED by MERGE COMMIT on Brett Heap's word of 2026-09-21 ~20:40Z, verbatim "archive it #1112 and #1116". Refs #1083, #1107. Lane: openxfactory-5 (openXfactory-5) Co-Authored-By: Claude Fable 5.1 <[email protected]>



Lane: openxfactory-5 (openXfactory-5)
REALIZATION of the ratified packet
harden-path-escape-helpers-against-symlink-loops(proposal PR #1083 →ebcdbc0c, ratified by Brett Heap 2026-09-18 approximately 09:55Z, verbatim "Ratify; land when green"). This PR lands on his separate word, verbatim "land #1107 when it is un-drafted." Six realization files: three modules and the three test packages that prove them (named below). The packet directory IS touched here, in exactly one file and only in the way this landing authorizes:openspec/changes/harden-path-escape-helpers-against-symlink-loops/tasks.md— commitd8baaeefticked §§ 3–4 with this PR's own evidence now that the packet is onmain, and commitbc9ebf95added § 4.4's dated evidence note for this PR's own greenpytest-suiterun. Nothing underopenspec/specs/is touched. The archive (§ 5) and § 6 stay open/carried — a separate act on a separate word and on merged-plus-green evidence.Refs #1074
Refs #1083
code_surface: openxFactory. Six files: three modules and the three test packages that prove them.What § 3 owed, and what is here
Path.resolve(strict=True)signals a SYMLINK LOOP by raisingRuntimeError, which is a subclass of NEITHEROSErrorNORValueError, so four containment guards that promise an ANSWER were open at exactly that failure and three of the four are driven to it by a COMMITTED tree shape. The packet's four line numbers, re-read on this head3e32d987, are unchanged from thec6997f12they were measured at:code_surface.py:777,target_release.py:394and:630,proposal-support.py:347.scripts/code_surface.py_unescaped→except (OSError, RuntimeError):, docstring amendedscripts/target_release.py_unescapedAND_registry_present→except (OSError, RuntimeError):, both docstrings amendedscripts/proposal-support.py_contained→except (OSError, ValueError, RuntimeError):, theValueErrorSTAYING;contained_dirandcontained_filedocstrings amendedtests/code_surface/_unescaped, all three positionstests/target_release/_unescapedall three positions, and_registry_presentDECLARED AS A CLAUSE TESTtests/proposal-support/contained_dir+contained_file, all three positions + the clean-candidate sub-caseFOUR CLAUSES, FIVE DOCSTRINGS, FOUR TEST CASES IN THREE PACKAGES — the packet's own counts (
proposal.mdcode_surface:front matter,tasks.md§ 4.1).The three sites are corrected in ONE act because
design.mdD2 ruled it one:code_surface._unescaped's docstring ends "target_release._unescapedis the exact shape this mirrors" andtarget_release._unescaped's opens "THIS IS_registry_present'S TEST, GENERALIZED TO ANY PATH THIS MODULE OPENS". Correcting one module alone leaves a documented claim of identity FALSE._registry_presentis widened too (D3) although no tree state reaches its clause:is_dir()callsos.stat, which reports the loop asOSError(ELOOP), andis_dir()absorbs that and answersFalse. Re-measured here in all three positions the first requirement names — loop AT the registry leaf, at the ANCESTORcontracts/, andrepo_rootITSELF a loop —returned Falsefrom every one, which is D0.5's correction to #1074's own text reproduced on this head. Its test is therefore D3's test of the CLAUSE, declared as one in the test's own docstring, driven by a seam that makes the pre-check pass while the resolution is left entirely REAL and meets a REAL loop.The pair of runs: FAILING against the unfixed clauses, then PASSING
The failing half is taken on a worktree at
origin/main(3e32d987) with only this PR's test files checked out over it, soscripts/is untouched main:Four cases, four clauses, and the raising line of each is the guard's own resolution — including
target_release.py:392, which is the seamed clause test really meeting a real loop and not a mocked exception. The same command at this PR's head:Each of the three positions was verified to drive its clause on its own, not merely the first one the test reaches — every
_unescapedposition raises atcode_surface.py:775/target_release.py:628, the CANDIDATE resolution, and never at the root line below it, becausecandidate = repo_root / relativealready traverses the loop (design.mdD5). The clean-candidate sub-case is the one that raises atproposal-support.py:346,resolved.relative_to(root.resolve(strict=True)), and it is asserted only intests/proposal-support/.§ 4 verification, at this head
§ 4.1
python3 -m pytest tests/code_surface tests/target_release tests/proposal-support -q§ 4.2 — the widened clauses changed no judgment of the real tree:
§ 4.3 —
design.mdD0.3's TWO trees re-run through the FOUR entry points that traceback today, with the FIFTH reader beside them. TREE ONE is a minimalopenspec/changes/a-real-change/whoseproposal.mdis a two-linka -> b -> aloop; TREE TWO carries the loop on.openspec.yamlinstead. Both sides are shown, because D0.3's own record is the traceback:origin/main(3e32d98)validate-code-surface.py<tree one>RuntimeError: Symlink loop from '…/a-real-change/proposal.md', exit 10 active proposals, 0 declaring … validation passed, exit 0validate-target-release.py<tree one>RuntimeError: Symlink loop from '…/a-real-change/proposal.md', exit 10 active proposals, 0 declaring … validation passed, exit 0former_identity_claimants<tree two>RuntimeErroratproposal-support.py:343{'a-real-change': ['the live packet `openspec/changes/a-real-change`']}declared_former_ids_in_tree<tree two>RuntimeErroratproposal-support.py:343[]contained_change_dir_names<tree two>{'a-real-change'}{'a-real-change'}— UNCHANGEDAll four now REPORT rather than traceback, and the reported judgment is the drop each guard's docstring promises: the looped
proposal.mdis DROPPED from both scans (0 active proposals), and the unreadable.openspec.yamlcontributes no lineage ([]) while the packet the repository really does contain is still swept. The fifth reader's answer is UNCHANGED, which § 4.3 requires as part of the evidence and not as an omission from it:contained_change_dir_namesnever reached a guard, so the widening must not turn its result into a drop.§ 4.4
pytest-suiteat this head — the check run on this PR.Beyond § 4: the suite this branch does NOT make green, and does not make red either
test_THE_LIVE_RECORD_DISPOSITIONS_ONLY_REAL_DISAGREEMENTS_and_NAMES_FACTS,test_THE_LIVE_PLAIN_RUN_IS_GREEN_WITH_ZERO_UNDISPOSITIONEDandtest_corpus_sequenced_after_all_validate, all on one finding:INHERITED FROM
main, NOT CAUSED HERE — the adding commit named in the finding ISmain's own tip. Proved by running the identical command on an untouched worktree atorigin/main:3 failed, 283 passed in 41.53s, the same three tests. This branch adds no disposition row and does not touchtests/sequenced_after/archive-date-dispositions.yaml; that finding belongs to its own lane (PR #1056).No linter runs on
scripts/in this repository's CI — there is nopyproject.toml,setup.cfg,ruff.toml,.flake8ortox.ini, and no workflow referencesruff,flake8,pylintorblack.§ 3.7 — NO SYMLINK IS ADDED TO THE TRACKED TREE
Nothing. Every loop in these four tests is built at test time under the test's own temporary directory and torn down with it. A committed loop is tracked as two ordinary git objects and would be met by every recursive reader this estate runs — the corpus scans, the document-health families, the archive gate, the notebook projection, the packaging tools — not only the guard under test; a fixture that reds tools unrelated to the defect it proves is a second defect introduced to demonstrate the first.
§ 3.8 — NO OTHER FILE MOVES
Six files. No validator arm, no workflow, no contract member, no schema, no report field, no promoted byte, nothing in
openspec/.And the four deletions are the four clauses and nothing else:
The ELEVEN other
except OSError-family clausesdesign.mdD4 enumerates by AST scan —code_surface.py:568 and :656,target_release.py:337 and :528,proposal-support.py:162, :416, :2541, :3724, :4290, :4312 and :4511 — are read and deliberately left (§ 6.1): they guard reads, writes and subprocesses, where absorbing aRuntimeErrorwould swallow a defect in this repository's own code.proposal-support.py:3939's already-widerexcept Exception:is retained rather than narrowed.One departure from § 3.6's letter, in its own spirit
§ 3.6 says the loop is built "under
tmp_path", pytest's spelling.tests/proposal-support/test_proposal_support.pyis a pureunittestmodule ending inunittest.main(), with no pytest import and no fixture use anywhere in its 155 tests; a fixture-taking function added to it would silently not run under that entry point. The loop is therefore built underTemporaryDirectory(), this package's own spelling of the same thing and exactly what the ratified requirement asks for: "SHALL BUILD THAT LOOP AT TEST TIME, under the test's own temporary directory". The other three cases taketmp_pathliterally, their files being pytest throughout.🤖 Generated with Claude Code
Summary by Sourcery
Harden path containment helpers against symlink-loop resolution failures and verify that affected scans continue reporting safely.
Bug Fixes:
RuntimeErrorresolution failures as absent, unescaped, or uncontained paths.Enhancements:
Tests: