Skip to content

Make the shared catalog run scan link-safe for every caller (for opensoft/openxFactory#1187) - #1190

Merged
brettheap merged 9 commits into
mainfrom
fix/1187-iter-runs-link-safe
Sep 27, 2026
Merged

brettheap merged 9 commits into
mainfrom
fix/1187-iter-runs-link-safe

Conversation

@brettheap

@brettheap brettheap commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-1

For #1187, the follow-up to #1175 (squash c5e26140, the opensoft/xFactory#519 fix) registered from Copilot's round-8 thread on #1175. Brett Heap authorized this as a DRAFT on 2026-09-27 ("go ahead with both follow-up drafts"). DRAFT: it lands only on Brett Heap's word, and the lane coordinator lands it.

The defect (main a9e7db75)

_iter_runs (scripts/doc_health/catalog.py:670-689) is the one scan of recorded catalog runs. It has three callers: _claim_sequence (:757, the writer's sequence allocation and stale refusal), load_snapshot (:1225, the latest, by-date and by-id lookup that every other document-catalog check and catalog_dispatch._recompute consume), and document_catalog._run_identity_findings (document_catalog.py:816). The scan used is_dir() (:677, :680, :683), is_file() (:686) and _load_yaml_json (:688), and all three follow symlinks. So:

  • A symlinked day directory, run directory or run.yaml was enumerated, and its run.yaml read, as though it were a recorded run. That held whether the link pointed outside the catalog root or back inside the tree.
  • load_snapshot returned such a link as the latest run when it was dated latest. A day directory aliasing a real one even made a run "latest" under a date it was never recorded on.
  • _claim_sequence took its highest sequence and newest date from wherever the link pointed, and passed over a dangling link as if nothing were there.
  • A malformed linked run.yaml raised out of the scan before the run-identity check's per-run try, so the family collapsed into one whole-family catalog-integrity finding (the Copilot thread's point). A link under a name the writer never mints went unreported.

#1175 made the writer refuse links and wrote this boundary into _run_identity_findings ("Making that shared scan link-safe would change every reader, and it is outside this check", document_catalog.py:803).

The scan now

_iter_runs yields a _RunEntry(as_of, sequence, run_id, run_dir, refusal) per entry. It classifies every node by the mode of its own explicit os.lstat (_own_mode), never by a second stat, before it lists or reads it. So it never stats or reads through a link, not even to classify it, and never takes a node it cannot check for absent (review rounds 3 to 5). It fails closed: a node it cannot check, or a directory it cannot list (_listing), is refused like a link, because a link could hide there (review rounds 2 and 3).

  • A link where the writer makes a day directory, a run directory or run.yaml, or a node there the scan cannot check (or a day directory it cannot list), is yielded as a refused entry for that entry alone, whether the link dangles, points inside the tree or escapes the catalog root. refusal is the CatalogError, and sequence is None because nothing behind the link was read. A symlinked day directory is one entry, the day itself; its runs are never listed.
  • A recorded run holding a link anywhere inside it (a linked snapshot or subdirectory) is refused the same way, because load_snapshot would read that run's snapshots through the link. So is a recorded run holding a directory the scan cannot list, or an entry it cannot lstat, since a link could hide there (review round 2). The scan's own walk, _link_inside, is driven by each node's own lstat: it descends only into a real directory and never stats a link's target, as os.walk does to classify an entry (review round 4), and it fails closed. _refuse_links_inside, which write_run's preflight also calls, is left unchanged. The run's run.yaml is not read either.
  • A link, or a node the scan cannot check or list, at the catalog root or a catalog directory above the day directories (_catalog_chain) puts every run behind it, with no single entry to report, so the scan raises CatalogError.
  • Unchanged: a missing catalog directory, or a node there that is not a directory, still means no runs (the occupied-paths test pins load_snapshot(...) is None there). A crashed run without run.yaml is still skipped. Dot-named entries are still skipped, now by name alone, before any stat. A regular run.yaml that cannot be parsed still raises from the scan. The order is still sorted days, then sorted runs.

Every caller now destructures the five fields, so none can use a refused entry without naming its refusal.

Per-caller behaviour: the choice, and why

caller what a refused entry does why
load_snapshot (latest, as_of, run_id) Never selected. The latest matching run readable without a link is returned, or None. Its content would be read through the link. Treating it like a crashed run keeps "latest" a total order over the runs that can be read, and the family reports the entry, so it is never passed over unseen. The family's other checks, and catalog_dispatch's carry-forward, never judge or build on content read through a link.
_claim_sequence (the writer) Refuses the claim, with CatalogError "no run sequence is claimed beside a catalog entry the run scan refuses (...)", before any number is claimed or anything is written. The scan never reads that entry's sequence or date. A claim beside it could reuse the number its run.yaml records, or land a run dated before it; skipping it would quietly weaken the stale refusal. The claims ledger covers every number this tree claimed, but not a foreign link's, and recording past a linked latest run would carry forward from an older run. This matches the writer's existing posture: _read_claims refuses a foreign claim node rather than skipping it. Once the entry is repaired or removed, the claim lands one past every number the catalog holds, so the number a linked run occupies is never reused. Every refusal comes before anything is created or read through a link (review round 1): the run scan runs first, the claims directory must not be a link, and .sequence/ is created only when a number is about to be claimed.
_run_identity_findings (the family) Reported as the existing catalog-integrity finding (same detail text, same action string) for that entry alone, at runs/<day> or runs/<day>/<run-id>, whatever the entry's name. Per-entry isolation was the Copilot thread's ask. A malformed linked run.yaml no longer aborts the family, and a hand-named link is no longer silent. No action string is added, so the 24-action pin table is unchanged.

A link on the catalog chain raises from every caller. The family reports it once, as its whole-family catalog-integrity finding; it used to read every run through the link and then report each one. The writer refuses, as its preflight already did.

Relation to #1186 (#1189, landed)

#1189 landed as 73c50410 and is merged in at 7bd23303 with no conflict. It changed write_run's preflight and added _refuse_foreign_descendants (and _is_writer_temp) after _refuse_links_inside. It touches none of _refuse_links_inside, _iter_runs, _claim_sequence or load_snapshot, and this PR touches none of write_run, its preflight or _snapshot_files. At 7bd23303 both PRs' catalog, document-catalog, dispatch, baseline and cataloger tests pass together (247 passed at 0ce26a0e; main 73c50410: 233).

Tests and validators

New tests. Each FAILS on main and passes here: run against main 73c50410's source, exactly these 14 fail and the other 106 tests in the two files pass. Every table case was also run alone against main's source, where each fails:

  • test_catalog.py
    • test_run_scan_refuses_every_symlink_position_for_that_entry_alone: 11 cases. The day directory, run directory and run.yaml positions each escape the root, point inside the tree, and dangle; a recorded run also holds a linked snapshot, or a linked subdirectory. The escaping cases link to a run.yaml that is not even JSON, which main reads and raises on.
    • test_run_scan_fails_closed_on_a_directory_it_cannot_list (review round 2): a directory inside a recorded run with mode 0o100 (unlistable) or 0o400 (listable, not searchable) refuses that run in the scan, load_snapshot and the claim. It also fails on 3f80fe1f, where the 0o400 case escaped the scan as a raw PermissionError.
    • test_run_scan_never_takes_an_unchecked_node_for_link_free (review round 3): pins Path.is_symlink to its Python 3.13 behaviour (os.path.islink, which swallows OSError), so 3.12 CI proves the scan does not depend on it. It covers a child of a readable but unsearchable subdirectory, an unsearchable run directory, an unsearchable and an unlistable day directory, and an unlistable runs directory. Each case fails on main and on 47132d05, where the last four escaped as raw PermissionErrors.
    • test_run_scan_never_stats_a_link_target (review round 4): records every call that stats a link's target (os.stat following links, which Path.is_dir, is_file and exists reach, and a listed entry classified following links, as os.walk does) while the scan, load_snapshot (latest and by id) and the claim run. It covers 10 link positions: a day directory, a run directory, run.yaml, and inside a recorded run a linked file and a linked directory that each escape the root, point inside the tree or dangle, plus a link below real subdirectories. A control proves the recorder sees both ways os.walk stats a target. The seven inside-run cases fail on 9635c646, where the recorder names the link; every case fails on main.
    • test_run_scan_classifies_every_node_by_its_own_lstat (review round 5): records every following stat while the scan runs (there are none). Then it pins is_dir() and is_file() to their Python 3.13 behaviour (swallowing every OSError) and denies the following stat of a catalog directory, a day directory, a run directory, a run.yaml, or every node; the scan yields every run each time. Each phase and case fails on 7bd23303 and on main, where the scan silently yields nothing.
    • test_latest_run_is_never_a_symlinked_entry: 4 cases.
    • test_no_sequence_is_claimed_beside_a_symlinked_entry: 4 cases. One moves a recorded run out and replaces it with a link, then restores it; the claim is then 3, never the linked run's 2.
    • test_a_refused_claim_creates_nothing (review round 1): 5 cases. A claim refused beside a refused entry, or as stale, and a direct claim through a linked root, runs directory or .sequence, create nothing (not even .sequence/) and claim nothing through the link. Each case also fails on this PR's first head, b6a70644.
    • test_a_symlinked_catalog_directory_refuses_the_whole_scan: the root, health, document-catalog and runs.
    • test_run_scan_matches_the_legacy_scan_on_a_clean_tree, the clean-tree proof: several days, several runs a day, a slash-separated repository, a crashed run, stray files and a hidden directory. It compares the scan with a verbatim copy of main's _iter_runs, and checks the latest, by-date and by-id lookups, the next claimed sequence and the stale refusal. On a clean tree main is the reference, so this test fails on main only through the new entry interface (refusal), which is exactly what this change adds.
  • test_document_catalog.py
    • test_symlinked_scan_entries_are_reported_for_that_entry_alone: 9 cases, including a hand-named link and dangling day, run and run.yaml links, which main left unreported.
    • test_a_run_holding_a_directory_the_scan_cannot_list_is_reported_alone (review round 2): one catalog-integrity finding for that run; main and 3f80fe1f reported nothing.
    • test_a_linked_latest_run_never_feeds_the_other_checks: main reported the linked run's artifact-type defect.
    • test_a_symlinked_runs_directory_is_one_whole_family_finding.

No existing test changes, including #1175's five-case test_symlinked_run_is_reported_as_catalog_integrity.

  • test_catalog, test_document_catalog, test_catalog_dispatch, test_catalog_baseline: 165 passed (main 73c50410: 151). With test_cataloger, test_families, test_family_enumeration, test_suite, test_lifecycle_scan_set and test_action_pins added: 399 passed (main: 385).
  • The whole tests/doc-health directory at 0ce26a0e, with openDox and openXdox materialized as CI does: 2009 passed, 0 failed.
  • scripts/validate-document-catalog.py: rc 0, 0 error(s), 0 warning(s), on this tree and on the aggregation tree.
  • scripts/validate-openspec-cli-pin.py --all: rc 0, with its one accepted exception (add-chain-attestation).

The aggregation's real recorded runs

On a read-only clone of opensoft/xFactory main 0eac0891, with the seven catalogued repositories materialized, main's code and this branch's give byte-identical results for every caller:

  • all 31 scan rows (none refused), the latest run, all 28 by-date and 29 by-id lookups;
  • the claim inputs (next sequence 32, newest date 2026-09-26), and an end-to-end write_run into a scratch copy of the runs tree (sequence 32, same run id);
  • the run-identity check (0 findings);
  • the whole --family document-catalog report at as-of 2026-09-27: 585 stale-entry, 7 coverage and 2935 pending-aging findings, all corpus drift since the 2026-09-26 run and identical on both, with no catalog-integrity or run-identity finding.

The scan took 0.010 s there (0.018 s on main), so the inside-run link walk costs nothing measurable at this size. Re-run at 0ce26a0e (after all five review rounds, with #1189 merged in) against main 73c50410, the probe and the whole family report are still byte-identical to main.

Review

  • Round 1 (Copilot and Codex, one finding at b6a70644): the claim step created .sequence/ before the run scan could refuse, and a direct claim through a linked root or claims directory created or read through the link first. Taken in 7147943e, pinned by test_a_refused_claim_creates_nothing; both threads answered and resolved.
  • Round 2 (Copilot, at 3f80fe1f): the walk inside a recorded run skipped a directory it could not list, in silence. Taken in 47132d05 with the scan's own fail-closed walk, pinned by the two round-2 tests; answered and resolved.
  • Round 3 (Copilot, at 47132d05): Path.is_symlink reports a node it cannot lstat as no link from Python 3.13. Taken in 9635c646: every scan check is an explicit lstat, every listing fails closed, at the positions as well as inside runs; pinned by test_run_scan_never_takes_an_unchecked_node_for_link_free; answered and resolved.
  • Round 4 (Copilot, at 9635c646): os.walk classifies each listed entry with DirEntry.is_dir(), which follows a link to stat its target before the scan's lstat check sees it. Taken in 039b88f6: _link_inside walks by each node's own lstat (_own_mode), lists names only and descends only into real directories; pinned by test_run_scan_never_stats_a_link_target; answered and resolved.
  • Round 5 (Copilot, at 7bd23303): no finding posted and no thread, but the overview counted "two moderate fail-closed filesystem handling issues". The reviewer's job log shows the two candidates it stored and never posted: catalog.py:818 (the chain's is_dir()) and :844 (run.yaml's is_file()), a second, link-following stat that from Python 3.13 reads a failed stat as absent. Taken in 0ce26a0e: every node is classified by its own lstat mode at all four sites, so the scan makes no following stat; pinned by test_run_scan_classifies_every_node_by_its_own_lstat; answered in a PR comment.
  • Main merged in three times, never rebased: 27374719 (Drop the idle #1159 row from KNOWN_STRICT_FINDINGS #1188) at 3f80fe1f, d90df42d (Confine --seal-out to the checkout and create it fresh before sealed code runs (#1182) #1185) at aa09eba2, and 73c50410 (Preflight every run-directory descendant against the exact allowed set #1189) at 7bd23303; no conflict.

🤖 Generated with Claude Code

_iter_runs, the scan behind load_snapshot, the writer's sequence claim and
the run-identity check, followed symlinks: is_dir(), is_file() and the
run.yaml read all do. A symlinked day directory, run directory or run.yaml
was enumerated, and its run.yaml read, as though it were a recorded run,
and a malformed linked run.yaml aborted the scan for every caller. #1175
(c5e2614) made the writer refuse links but left this reader unchanged
(Copilot round-8 thread on #1175, registered as this follow-up).

The scan now checks each node for a link before it lists, stats or reads
it, and never reads through one:

- a link where the writer makes a day directory, run directory or run.yaml
  (dangling, pointing inside the tree, or escaping the catalog root), and a
  recorded run holding a link anywhere inside it, is yielded as a refused
  entry for that entry alone, with no sequence read;
- a link at the catalog root or a catalog directory above the day
  directories puts every run behind it, so the scan raises CatalogError;
- a missing or non-directory catalog node still means no runs, and a
  regular run.yaml that cannot be parsed still raises, both unchanged.

Per caller:

- load_snapshot never selects a refused entry, as latest, by date or by
  id; it returns the latest matching run readable without a link, or None;
- _claim_sequence claims nothing beside a refused entry: its sequence and
  date were never read, so a claim could reuse the number it records or
  land a run dated before it. The writer records nothing until the entry
  is repaired or removed, as it already does beside a foreign claim node;
- the run-identity check reports each refused entry as the existing
  catalog-integrity finding for that entry alone, whatever its name (a
  symlinked day directory is reported as the day itself).

On a tree without links every caller sees exactly the runs the scan saw
before: the clean-tree test compares against a copy of the old scan, and
over the aggregation's 31 real recorded runs every scan row, lookup, next
sequence and document-catalog finding is byte-identical to main.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 27, 2026 19:05
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@sourcery-ai

sourcery-ai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes _iter_runs a link-safe shared boundary: it detects symlinks without following them, yields refused entries for isolated run-level defects, and raises for links that obscure the entire catalog. Snapshot loading excludes refused entries, writers refuse sequence claims until they are repaired, and document-catalog checks report isolated catalog-integrity findings, with extensive regression tests covering all link positions and unchanged clean-tree behavior.

Sequence diagram for link-safe catalog run scanning

sequenceDiagram
    participant Caller
    participant IterRuns as _iter_runs
    participant Snapshot as load_snapshot
    participant Writer as _claim_sequence
    participant Family as _run_identity_findings

    Caller->>IterRuns: _iter_runs(root)
    IterRuns->>IterRuns: is_symlink(node)
    alt Isolated symlink or linked content inside run
        IterRuns-->>Snapshot: _RunEntry(refusal)
        IterRuns-->>Writer: _RunEntry(refusal)
        IterRuns-->>Family: _RunEntry(refusal)
        Snapshot->>Snapshot: Exclude refused entry
        Writer-->>Caller: CatalogError
        Family->>Family: Raise refusal for entry
        Family-->>Caller: catalog-integrity finding
    else Clean recorded run
        IterRuns->>IterRuns: _load_yaml_json(run.yaml)
        IterRuns-->>Snapshot: _RunEntry(sequence, run_id, run_dir)
        IterRuns-->>Writer: _RunEntry(sequence, run_id, run_dir)
        IterRuns-->>Family: _RunEntry(sequence, run_id, run_dir)
    end
    alt Symlink on catalog chain
        IterRuns-->>Caller: CatalogError
    end
Loading

Flow diagram for symlink handling in the shared run scan

flowchart TD
    A[_iter_runs scans catalog] --> B{Symlink on catalog chain?}
    B -- Yes --> C[Raise CatalogError for whole scan]
    B -- No --> D{Symlink at day, run, run.yaml, or inside run?}
    D -- Yes --> E[Yield _RunEntry with refusal]
    D -- No --> F{Recorded run.yaml exists?}
    F -- No --> G[Skip crashed or in-flight run]
    F -- Yes --> H[_load_yaml_json and yield readable _RunEntry]
    E --> I[load_snapshot excludes entry]
    E --> J[_claim_sequence refuses claim]
    E --> K[_run_identity_findings reports catalog-integrity]
Loading

File-Level Changes

Change Details Files
Makes the shared recorded-run scan symlink-safe and exposes per-entry refusals without following links.
  • Introduces _RunEntry with an optional CatalogError refusal.
  • Checks catalog-chain, day, run, metadata, and in-run descendants for symlinks before listing, statting, or reading.
  • Preserves clean-tree ordering and crashed-run handling while raising for links above individual run entries.
scripts/doc_health/catalog.py
Updates scan consumers to apply caller-specific behavior to refused entries.
  • Prevents snapshot lookup from selecting refused runs.
  • Stops sequence allocation before claiming or writing when any run entry is refused.
  • Reports refused entries as per-entry catalog-integrity findings while retaining whole-family handling for catalog-chain links.
scripts/doc_health/catalog.py
scripts/doc_health/document_catalog.py
Adds comprehensive regression coverage for link refusal and caller isolation.
  • Covers symlinks at day, run, metadata, snapshot, descendant, and catalog-chain positions, including dangling, internal, and escaping links.
  • Verifies latest/date/id lookup exclusion, sequence-claim refusal and recovery, and per-entry versus whole-family findings.
  • Proves clean-tree compatibility with the legacy scan and validates that linked content does not feed other document-catalog checks.
tests/doc-health/test_catalog.py
tests/doc-health/test_document_catalog.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

_claim_sequence can mutate a destination through a symlink before refusal.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This pull request makes catalog run scanning symlink-safe across readers, writers, and document-catalog validation.

Changes:

  • Reject symlinked catalog entries without following them.
  • Prevent refused entries from affecting snapshots or sequence allocation.
  • Report refused entries individually with expanded test coverage.
File Summary
tests/​doc-health/​test_document_catalog.py Tests isolated catalog-integrity reporting.
tests/​doc-health/​test_catalog.py Tests symlink handling, lookups, and sequence claims.
scripts/​doc_health/​document_catalog.py Reports refused entries individually.
scripts/​doc_health/​catalog.py Implements link-safe scanning; critical issue: _claim_sequence creates the claims directory before validating symlinked catalog paths.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/doc_health/catalog.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b6a706448e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/doc_health/catalog.py Resolved
brettheap and others added 2 commits September 27, 2026 19:11
…#1187)

Review on #1190 (Copilot and Codex, one finding): _claim_sequence created
runs/.sequence before the run scan could refuse. A write_run refused beside
a linked entry, or as stale, still left the claims directory behind, and a
direct claim through a linked root or runs directory created it inside the
link's target before the scan raised. A linked claims directory was read,
and claimed into, through the link.

The claim loop now runs the run scan first, which refuses a link on the
catalog chain before anything follows it. It then refuses a claims
directory that is a link or not a directory (_refuse_foreign_node), reads
the claims, applies the stale refusal, and creates the claims directory
only when a number is about to be claimed. The new
test_a_refused_claim_creates_nothing covers all five refusals; each case
fails on main and on b6a7064.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #1188 (2737471); no overlap with the catalog scan.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 27, 2026 19:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

_refuse_links_inside can silently skip unenumerable subtrees, allowing symlinks to evade refusal.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread scripts/doc_health/catalog.py Resolved
Review round 2 on #1190 (Copilot): the walk inside a recorded run reused
_refuse_links_inside, whose os.walk passes no onerror. A directory it could
not list was skipped in silence, so the run was yielded as link-free over a
subtree nobody saw, and a link below it would evade the refusal. An entry
it could list but not lstat escaped the scan as a raw PermissionError,
which no caller catches.

The run scan now has its own walk, _link_inside. Its onerror raises, and an
entry it cannot lstat is caught, so either refuses that run alone, as the
existing catalog-integrity finding, exactly like a link inside it.
load_snapshot never selects that run and no sequence is claimed beside it.
_refuse_links_inside, which write_run's preflight also calls, is left as it
is, so the writer's behaviour does not change here.

New tests: test_run_scan_fails_closed_on_a_directory_it_cannot_list
(unlistable and unsearchable) and
test_a_run_holding_a_directory_the_scan_cannot_list_is_reported_alone.
Both fail on main and on 3f80fe1.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 27, 2026 19:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Fix the symlink detection path so permission errors fail closed as intended.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread scripts/doc_health/catalog.py Resolved
…losed (for #1187)

Review round 3 on #1190 (Copilot): from Python 3.13 Path.is_symlink is
os.path.islink, which reports a node whose lstat is denied as no link. So
a scan built on it would pass a child of a listable but unsearchable
directory, a link included, as link-free. Python 3.12 raises instead, but
out of the scan, as a raw PermissionError that no caller catches. The
same held at the positions: a day or run directory the scan could not
list or search escaped as a raw PermissionError on 3.12 (on main too),
and would be passed over on 3.13.

Every link check in the scan now goes through _link_refusal, an explicit
os.lstat that refuses a symlink or a node whose lstat fails for any reason
but its absence. Every listing goes through _listing, which refuses a
directory it cannot list. Whatever the scan cannot check or list refuses
that entry alone (a day directory it cannot list is refused as the day),
and a node on the catalog chain it cannot check or list refuses the whole
scan, as a chain link does. Behaviour on a readable tree is unchanged.

test_run_scan_never_takes_an_unchecked_node_for_link_free pins
Path.is_symlink to its 3.13 behaviour and covers the exact case plus an
unsearchable run directory, an unsearchable and an unlistable day
directory, and an unlistable runs directory. Each case fails on main and
on 47132d0.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 27, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A critical finding remains: directory symlinks may still be followed during scan traversal.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread scripts/doc_health/catalog.py Resolved
brettheap and others added 3 commits September 27, 2026 20:17
… target (for #1187)

Review round 4 (Copilot, #1190): the scan's walk inside a recorded run
was os.walk, which sorts every entry it lists into directories and files
with DirEntry.is_dir(). That follows a link to stat its target before the
scan's own lstat check sees the link, so a link inside a run had its
target stat-ed although nothing behind it was read.

_link_inside now walks by each node's own lstat (_own_mode, which
_link_refusal now wraps): it lists names only, identifies a link before
anything else touches it, and descends only into a real directory, in
the same depth-first name order, failing closed as before. The writer's
own walk (_refuse_links_inside) is unchanged.

test_run_scan_never_stats_a_link_target records every call that stats a
link's target (os.stat following links, and a listed entry classified
following links) while the scan, load_snapshot and the claim run. A
control proves the recorder sees both ways os.walk does it. Every
link-inside position fails on 9635c64, where the recorder names the
link, and every position fails on main.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #1185 (d90df42); no overlap with the catalog scan.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #1189 (73c5041), the write_run descendant preflight; it
auto-merges beside the run scan with no conflict.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 27, 2026 20:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Two moderate fail-closed filesystem handling issues remain unresolved.

Review effort: Lite
Findings: None

Resolved since last review (1)

…d stat (for #1187)

Review round 5 (Copilot, #1190): its review at 7bd2330 posted no
finding, but its overview counted two moderate fail-closed issues, and
its job log shows the two candidate comments it stored and never posted,
at the catalog chain's is_dir() and at run.yaml's is_file(). After its
lstat check the scan still asked is_dir() and is_file() what a node was.
Each stats the node a second time, following links, and from Python 3.13
swallows every OSError. So a catalog, day or run directory, or a
run.yaml, whose second stat failed read as absent: the scan reported no
catalog, or passed over a day or a recorded run, instead of failing
closed.

_iter_runs now classifies every node by the mode its own lstat returned
(_own_mode), at all four sites, so it makes no following stat at all.
_link_refusal, left unused, is removed. For a node that is not a link,
lstat and stat report the same mode, so on a tree nothing races every
caller sees the same runs as before.

test_run_scan_classifies_every_node_by_its_own_lstat records every
following stat while the scan runs (there are none now). Then it pins
is_dir() and is_file() to their 3.13 behaviour and denies the following
stat of a catalog directory, a day directory, a run directory, a
run.yaml, or every node; the scan yields every run each time. Each phase
and case fails on 7bd2330 and on main, where the scan silently yields
nothing.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 27, 2026 21:32
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-1

Review round 5, taken in 0ce26a0e. Copilot's review at 7bd23303 posted no finding and opened no thread, but its overview read "Two moderate fail-closed filesystem handling issues remain unresolved." The reviewer's job log (job 108701811573) shows the two candidate comments it stored, kept through dedup and severity classification, and never posted: scripts/doc_health/catalog.py:818 (the catalog chain's node.is_dir()) and :844 (meta_path.is_file()), both a moderate bug.

Both hold. After its lstat check the scan still asked is_dir() and is_file() what a node was. Each stats the node a second time, following links, and from Python 3.13 swallows every OSError. So a catalog, day or run directory, or a run.yaml, whose second stat failed read as absent, and the scan reported no catalog, or passed over a day or a recorded run, instead of failing closed. The day-directory and run-directory checks had the same pattern.

_iter_runs now classifies every node by the mode its own lstat returned (_own_mode), at all four sites, so it makes no following stat at all; _link_refusal, left unused, is removed. For a node that is not a link, lstat and stat report the same mode, so on a tree nothing races every caller sees the same runs. On the aggregation's real catalog the probe and the whole family report are byte-identical to main 73c50410.

Pinned by test_run_scan_classifies_every_node_by_its_own_lstat. It records every following stat while the scan runs (there are none now). Then it pins is_dir() and is_file() to their 3.13 behaviour and denies the following stat of a catalog directory, a day directory, a run directory, a run.yaml, or every node; the scan yields every run each time. Each phase and case fails on 7bd23303 and on main, where the scan silently yields nothing. Full tests/doc-health at 0ce26a0e: 2009 passed, 0 failed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues remain.

Review effort: Lite
Findings: None

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap marked this pull request as ready for review September 27, 2026 21:54

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 2 days and 20 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit 7af30fc into main Sep 27, 2026
16 checks passed
brettheap added a commit that referenced this pull request Sep 30, 2026
… read a subdirectory, and correct the 3.13 rationale (for #1197) (#1200)

* Fail the write_run preflight closed when the link-refusal walk cannot read a subdirectory, and correct the 3.13 rationale

_refuse_links_inside's own os.walk(run_dir) passed no onerror at all,
unlike its sibling _refuse_foreign_descendants (PR #1189/#1190), which
already fails closed the same way. An unreadable subdirectory was
silently skipped, so a symlink hiding inside one would never be caught.
Both walks now share a new _refuse_unreadable_walk(run_dir) onerror
factory that refuses by name, tree-relative to run_dir.

Also corrects the false "Python 3.13 pathlib swallows every OSError"
rationale left in catalog.py's _own_mode docstring and two
tests/doc-health/test_catalog.py comments: verification against the
actual CPython 3.12/3.13 sources found the _ignore_error errno
allow-list unchanged between versions, so the behaviour those comments
justify (explicit os.lstat + errno handling) is correct, but the
stated reason was wrong. See the PR body for the sources.

For #1197 (re-scoped after the verification pass
found the original Python 3.13 premise false).

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Describe the documented pathlib contract instead of calling it private

Copilot review (PR #1200): the prior rewrite called the propagate-vs-
absent contract on Path.is_symlink/is_dir/is_file "private" and
"undocumented." Checked against the official docs.python.org/3.13
pathlib page: it explicitly says "False is also returned if the path
doesn't exist or is a broken symlink; other errors (such as permission
errors) are propagated" for all three. That is a documented, public
contract, not an internal detail.

Reworded catalog.py's _own_mode docstring and both corrected
test_catalog.py comments to say so, and reframed the explicit os.lstat
as insulation against a future version changing that contract, not a
correction of today's.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Qualify the pathlib contract as documented through 3.13, changed in 3.14

Codex review (PR #1200, P3): the previous wording framed Python 3.14
delegating is_symlink/is_dir/is_file to os.path.islink/isdir/isfile
(which swallow every OSError) as only a hypothetical future change.
Checked the CPython 3.14 branch directly: Lib/pathlib/__init__.py's
Path.is_symlink() already is `return os.path.islink(self)`, and
is_dir()/is_file() call os.path.isdir()/isfile() the same way when
follow_symlinks=True (the default), falling back to a bare
`except (OSError, ValueError): return False` otherwise. The change
has already landed there; it is not speculative.

Reworded catalog.py's _own_mode docstring and both test_catalog.py
comments to say the propagate-vs-absent contract holds through 3.13
and changes in 3.14, and reframed the link-free test's monkeypatch as
pinning to Python 3.14's actual is_symlink body, not a hypothetical
worst case.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Classify every listed node by its own lstat, not by Path.is_symlink

Copilot review (PR #1200, high severity): onerror only covers a failed
scandir(top), not a failed per-entry classification. os.walk's own
is_dir() catches an OSError from one listed entry and treats it as a
plain file rather than aborting (same on 3.12, 3.13, and 3.14), and
the entry is still yielded either way. A bare node.is_symlink() would
then misclassify it right along with os.walk: not a directory to
refuse enumerating, and on Python 3.14 not a symlink either, since
is_symlink there swallows the same error (Lib/pathlib/__init__.py:
`return os.path.islink(self)`).

_refuse_links_inside now classifies every listed name with _own_mode,
the same explicit os.lstat primitive _link_inside already uses for
the read-side scan, instead of calling Path.is_symlink directly. A
node _own_mode cannot check (any errno but ENOENT/ENOTDIR) refuses by
name, on every interpreter version alike.

New test test_refuse_links_inside_fails_closed_on_an_unprobeable_entry
injects the OSError from os.lstat itself (the per-node probe), not
from scandir, per the review's ask.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Drive both run-directory walks by each node's own lstat, not os.walk's split

Codex (P1) and Copilot, reviewing PR #1200 at 9f3e67b, found the same
fail-open: os.walk splits each listing with DirEntry.is_dir(), and when
that call raises it files the entry as a non-directory and never enters
it, though the entry's own lstat then says it is a directory. Classifying
every listed name by _own_mode did not help while os.walk still chose
what to enter, so a symlink below such a directory stayed hidden and
_refuse_links_inside passed the run.

Both writer walks now go through one explicit walk, _walk_run_tree: it
lists names only (os.scandir, never asked to classify an entry), splits
them by each node's own lstat (_own_mode), enters exactly the nodes that
lstat says are directories, and refuses a link, an unprobeable node or
an unlistable directory as it goes. It is the walk _link_inside already
makes for the read-side scan, raising where that one returns.
_refuse_foreign_descendants uses it too: under os.walk's split a
directory whose is_dir() failed was refused under its own name instead
of the stranger inside it, or, at a recorded file's own path, passed
without being entered. The onerror factory _refuse_unreadable_walk
becomes _unenumerable_refusal, the same tree-relative refusal.

Two regression tests inject the failure on DirEntry.is_dir() alone (a
scandir wrapper), assert the premise that os.walk then never enters the
directory, and assert both walks still refuse by name. Both failed
before this change: the link test did not raise, and the stranger test
named the directory, not the stranger. The os.walk is_dir() handling was
checked in CPython 3.12, 3.13 and 3.14's Lib/os.py.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Name a node the writer's walk cannot probe by its path in the run

Copilot, reviewing PR #1200 at 89c1d63: the walk raised _own_mode's
refusal unchanged for a node whose lstat fails, and that refusal
interpolates the raw OSError, host-absolute path and all, while the
same walk names a directory it cannot list relative to run_dir.

_walk_run_tree now probes each node with _walked_mode: the explicit
lstat _own_mode makes, with the same errno handling, refusing a symlink
exactly as _own_mode does (_symlink_refusal) but naming a node it cannot
check by its path relative to run_dir, in _unenumerable_refusal's form,
with the OSError kept as the cause. _own_mode itself, which the
read-side scan uses, is unchanged; follow-up #1201 covers its message.

The unprobeable-entry test now nests the denied node, and both
fail-closed tests assert the relative name and the absence of the
absolute path; the extended test failed on the prior head.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Oct 5, 2026
… with a Python 3.14 CI leg (for #1201) (#1211)

* Fail the write_run preflight closed when the link-refusal walk cannot read a subdirectory, and correct the 3.13 rationale

_refuse_links_inside's own os.walk(run_dir) passed no onerror at all,
unlike its sibling _refuse_foreign_descendants (PR #1189/#1190), which
already fails closed the same way. An unreadable subdirectory was
silently skipped, so a symlink hiding inside one would never be caught.
Both walks now share a new _refuse_unreadable_walk(run_dir) onerror
factory that refuses by name, tree-relative to run_dir.

Also corrects the false "Python 3.13 pathlib swallows every OSError"
rationale left in catalog.py's _own_mode docstring and two
tests/doc-health/test_catalog.py comments: verification against the
actual CPython 3.12/3.13 sources found the _ignore_error errno
allow-list unchanged between versions, so the behaviour those comments
justify (explicit os.lstat + errno handling) is correct, but the
stated reason was wrong. See the PR body for the sources.

For #1197 (re-scoped after the verification pass
found the original Python 3.13 premise false).

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Describe the documented pathlib contract instead of calling it private

Copilot review (PR #1200): the prior rewrite called the propagate-vs-
absent contract on Path.is_symlink/is_dir/is_file "private" and
"undocumented." Checked against the official docs.python.org/3.13
pathlib page: it explicitly says "False is also returned if the path
doesn't exist or is a broken symlink; other errors (such as permission
errors) are propagated" for all three. That is a documented, public
contract, not an internal detail.

Reworded catalog.py's _own_mode docstring and both corrected
test_catalog.py comments to say so, and reframed the explicit os.lstat
as insulation against a future version changing that contract, not a
correction of today's.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Qualify the pathlib contract as documented through 3.13, changed in 3.14

Codex review (PR #1200, P3): the previous wording framed Python 3.14
delegating is_symlink/is_dir/is_file to os.path.islink/isdir/isfile
(which swallow every OSError) as only a hypothetical future change.
Checked the CPython 3.14 branch directly: Lib/pathlib/__init__.py's
Path.is_symlink() already is `return os.path.islink(self)`, and
is_dir()/is_file() call os.path.isdir()/isfile() the same way when
follow_symlinks=True (the default), falling back to a bare
`except (OSError, ValueError): return False` otherwise. The change
has already landed there; it is not speculative.

Reworded catalog.py's _own_mode docstring and both test_catalog.py
comments to say the propagate-vs-absent contract holds through 3.13
and changes in 3.14, and reframed the link-free test's monkeypatch as
pinning to Python 3.14's actual is_symlink body, not a hypothetical
worst case.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Classify every listed node by its own lstat, not by Path.is_symlink

Copilot review (PR #1200, high severity): onerror only covers a failed
scandir(top), not a failed per-entry classification. os.walk's own
is_dir() catches an OSError from one listed entry and treats it as a
plain file rather than aborting (same on 3.12, 3.13, and 3.14), and
the entry is still yielded either way. A bare node.is_symlink() would
then misclassify it right along with os.walk: not a directory to
refuse enumerating, and on Python 3.14 not a symlink either, since
is_symlink there swallows the same error (Lib/pathlib/__init__.py:
`return os.path.islink(self)`).

_refuse_links_inside now classifies every listed name with _own_mode,
the same explicit os.lstat primitive _link_inside already uses for
the read-side scan, instead of calling Path.is_symlink directly. A
node _own_mode cannot check (any errno but ENOENT/ENOTDIR) refuses by
name, on every interpreter version alike.

New test test_refuse_links_inside_fails_closed_on_an_unprobeable_entry
injects the OSError from os.lstat itself (the per-node probe), not
from scandir, per the review's ask.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* Route the six doc-health gates through one strict probe, fs_probe (for #1201)

Python 3.14's Path.exists/is_dir/is_file/is_symlink answer False for a node
whose stat fails for any reason; through 3.13 they raise every OSError that
does not name the node's absence. The #1201 survey found six read-side sites
where that False switches a gate off: the complete-coverage baseline gate
(catalog_baseline.is_baseline_complete and load_baseline), the regression
gate (runner.main's --previous-report), the preflight validators
(preflight._entrypoints and run_preflight), the pin-record ladder
(families._pinned_arm), the aggregation-backlog detector
(ideation_routing._aggregation_backlog_findings) and the catalog-tag guard
(ideation_readiness.load_catalog_tags).

Brett Heap's ruling (1(b), raw OSError) routes them through one leaf module,
scripts/doc_health/fs_probe.py: one explicit os.stat or os.lstat with the
3.12/3.13 allow-list written out (ENOENT, ENOTDIR, EBADF and ELOOP read as
absent, every other errno propagates raw). On 3.12 and 3.13 each site
behaves exactly as before; on 3.14 it stops swallowing. Each site carries a
one-line comment saying why it must refuse.

tests/doc-health/conftest.py gains pathlib_314, which runs a test natively
and again under CPython 3.14's own query bodies (transcribed from
Lib/pathlib/__init__.py), and ProbeDenial, which denies os.stat/os.lstat of
named nodes (chmod denies nothing to root). test_fs_probe.py pins the errno
table and drives each gate with EACCES and EIO under both models; against
the old probes every 3.14-model gate case fails.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fail the catalog writer's probes closed, with a tree-relative refusal (for #1201)

The writer's five pathlib probes (_refuse_foreign_node, _occupied,
_read_claims, and the run-directory probes in write_snapshot and write_run)
now classify a node by the one explicit lstat the run scan already used
(_node_mode, beneath _own_mode). A node whose lstat fails for any reason but
FileNotFoundError or NotADirectoryError is a CatalogError, never absent. On
3.14 the no-follow guard used to pass an unstat-able node, a symlink
included, as absent, and an existing immutable record read as "nothing
there".

The refusal (_unchecked_refusal, which _own_mode's refusal now uses too)
names the node by its path under the catalog root and the failure by its
errno name, never str(exc): CI's secret sweeper redacts the host-absolute
path the OSError carries. To name nodes tree-relative, the catalog root is
threaded through _own_mode, _link_inside, _refuse_links_inside,
_refuse_foreign_node, _read_claims, _occupied, _read_record, _holds_exactly,
_load_run_bytes and _addresses_itself (document_catalog's one caller and
the tests' direct calls updated). The symlink and "occupied by a" messages
keep their text.

Tests: every node the preflight classifies, and every probe after it, with
EACCES and EIO, under both pathlib models: a controlled refusal, a redacted
message, and a tree unchanged node for node. Against the pre-change code all
56 of those cases fail. Absence still reads as absent, ELOOP refuses (the
catalog's flavour is stricter than fs_probe's), and no refusal carries the
OSError's own filename or strerror.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Add the doc-health-py314 CI leg, a job of its own beside pytest-suite (for #1201)

Ruling 3 on #1201: .github/workflows/doc-health-py314.yml runs
python -m pytest tests/doc-health on actions/setup-python 3.14, with the
same nested checkout, gitlinks and hash-pinned lock as pytest-suite. It is
a separate job, not a matrix on pytest-suite, because a matrix renames that
required job's check-runs and its pinned context would never report. No
ruleset requires it. test_py314_leg.py pins both halves.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse a symlink loop in resolve_in_root on every Python version (for #1201)

RULED by Brett Heap, "#1201 3.14: 1(a)". Python 3.12's non-strict
Path.resolve() stat-ed its own result and raised RuntimeError on ELOOP,
which resolve_in_root turned into its UNRESOLVABLE refusal. Python 3.13
dropped that check (its resolve() is a bare os.path.realpath), so on 3.13
and 3.14 a looping pin record came back resolved and the pinned-target arm
reported it as merely absent. The new doc-health-py314 leg measured this:
test_a_self_looping_symlink_record_cannot_be_resolved_and_reads_nothing
failed on 3.14.7, on this branch and on its unchanged base alike.

scripts/pin_containment.py now asks the filesystem itself: after resolving,
_is_symlink_loop stats the root and the target and refuses on ELOOP (or
Windows' ERROR_CANT_RESOLVE_FILENAME), the question 3.12 asked, with no
version test. Any other stat failure is left to the caller, as 3.12 left
it. The refusal's reason names no path.

Tests: the existing loop test is unchanged and passes on 3.12 and 3.14. New:
a self-loop and a two-link cycle under CPython 3.13's own resolve body
(monkeypatched onto Path on any interpreter), same finding byte for byte and
nothing read; and a loop in an intermediate directory, called directly,
under both resolves. Without the fix the three 3.13-model cases fail.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse a looping root in boundary_dir on every Python version too (for #1201)

The same ruling as the previous commit, "#1201 3.14: 1(a)", applied to the
other resolve in scripts/pin_containment.py. boundary_dir resolves the root
before it checks the contracts/ boundary. On 3.12 a root that loops (or one
reached through a looping ancestor) made that resolve raise RuntimeError,
and the root refused as UNRESOLVABLE. From 3.13 on the resolve returned, the
contracts/ probes below it failed on ELOOP and read as absent, and the root
refused as BOUNDARY_MISSING instead: a refusal that changed with the
interpreter.

boundary_dir now asks _is_symlink_loop of the resolved root (os.stat and
ELOOP, no version test) and returns UNRESOLVABLE, whose reason names no
path. Its second resolve needs no check: it runs only on a contracts/ that
already stat-ed as a real directory. The two refusals now share one reason
string. The one caller, families._pinned_arm, prints the reason text, which
is unchanged.

Tests: a root that is itself a loop, and a root under a looping ancestor,
each natively and under CPython 3.13's own resolve body patched onto Path.
Without the fix the two 3.13-model cases fail.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Install the 3.14 leg's lock binary-only, and return the pathlib_314 model (for #1201)

SonarCloud flagged the new doc-health-py314 job's pip step (githubactions
S8541): without --only-binary :all:, a package could run a setup script.
Every package in requirements/hermes-runtime-contracts.lock ships a 3.14
wheel (17 of 17 on the job's first runs and on a local 3.14.7), so the step
now installs as former-id-arrival-gate.yml and openxdox-consumer-gate.yml
do: --require-hashes --only-binary :all:, in a literal block because ":all:
-r" is not a plain YAML scalar. pytest-suite.yml keeps its own form.

The pathlib_314 fixture returns its model instead of yielding it (SonarCloud
python S9100): it has no teardown of its own, monkeypatch undoes the swap.

Lane: openxfactory-1
Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants