You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FLOOR PART 4 successor: the bytecode cache leaves the pinned legs, and the refusal stops overclaiming - #1132
THE VERDICT DOES NOT MOVE, and for a hardening act that is the number that matters. At this head the equivalence runner still renders 14,849 bytes, sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735, exit 0, and EXPECT_SKIPPED: "6" is untouched.
1. sys.pycache_prefix, set before the legs are imported — and the bytecode allowlist retires
r4049745762. An allowlisted __pycache__/*.pyc is trusted BY PATHNAME, and CPython validates a cached .pyc against the mtime and size recorded in its own HEADER — so a crafted cache still matching the tracked source is loaded and EXECUTED. The legs are imported in post_stack(), before verify_pins() sweeps anything, so that bytecode would have rendered the post side while the verdict named a commit it did not come from; and the sweep could not have caught it even if it had looked, because the class was allowlisted precisely on the grounds that this runner's own imports created it.
sys.pycache_prefix removes the condition rather than policing it: with it set CPython neither READS nor writes a __pycache__ beside the source. sys.dont_write_bytecode is not the remedy and was not proposed as one — it stops the writing and leaves the reading, which is the half the finding is about.
It is set in two places, and the second is not belt and braces
post_stack(), before import carved_reach — for the reason the GIT_NO_LAZY_FETCH guard three lines above it is set there: a guarantee this runner's verdict rests on is made BY this runner, on the process, before the shared reader is imported, rather than inherited from a reader that could stop providing it.
carved_reach.install() — because the registered item's premise, that this runner creates those files, is true but not exhaustive, and the difference is a red required gate. MEASURED: tests/ideation-dashboard/test_lens.py on its own left 46 .pyc files under the two src/ roots, and tests/ideation-dashboard sorts BEFORE tests/snapshot_equivalence in the single pytest tests/ process pytest-suite runs. Retiring the allowlist in the runner alone would have made every end-to-end run in that gate refuse — on bytecode a sibling suite wrote. Proven before it was fixed: with the allowlist stubbed out and the legs carrying that suite's bytecode, python3 scripts/verify-snapshot-equivalence.py refuses equivalence-reach-unavailable and lists !! src/opendox/__pycache__/….
install() is the one gate every route into the legs passes through (module() calls it), so it is where the guarantee belongs, and it covers the importers a conftest cannot: tests/ideation-dashboard/test_cli_column_split.py's BOOTSTRAP and tests/domain_profile's probe each bootstrap the reach in a FRESH interpreter.
A prefix the process has already chosen — PYTHONPYCACHEPREFIX, or a host — is left alone: any prefix satisfies the requirement, and one pointed INTO a leg is caught by the sweep it would be trying to fool.
Where the cache goes, and why inside the checkout
<repo>/.pycache. The exposure needs a writer in the working tree, and such a writer could edit scripts/carved_reach.py itself — the threat-model argument already on this lane's record — while a fixed path under a shared /tmp is a directory another user can create FIRST and fill with exactly the crafted caches above. The root .gitignore already carries *.py[cod], so every file written there is ignored and git status --porcelain -unormal is unchanged (measured); nothing is added to it. If the directory cannot be written, CPython silently skips caching — the failure mode is a slower import, never a broken one.
The allowlist does not retire — it is RE-FOUNDED, and the gate is why
This is the one place the act departs from the registered wording, and it departs because the premise failed a measurement. Item 1 expected that once the runner stops writing bytecode into the legs there is nothing left to pass over. It was retired outright at e85d15384, and pytest-suite failed 23 tests — all in tests/snapshot_equivalence, all cascading from equivalence-reach-unavailable … !! src/opendox/__pycache__/{__init__,corpus_adapter}.cpython-312.pyc (run 35660132139). Those two files come from a second, independent reach: scripts/corpus_adapter_openxfactory/ puts openDox/code/src on sys.path itself and never mentions carved_reach (RULED OQ-Q, #872). Reproduced exactly here — import corpus_adapter_openxfactory.adapter with no prefix set leaves precisely those two .pyc files.
That is the second time the premise failed (the first was test_lens.py's 46 files, answered by fixing install()), and it settles the question: the enumeration of importers is not closable by inspection — any consumer, any future script, a developer running the leg's own suite inside the leg — and a required gate must not rest on "nothing anywhere ever writes a .pyc into a pinned checkout".
So what changes is the GROUND, which is what the finding was actually about:
the old rule
the rule now
passes over
__pycache__/<name>.pyc
__pycache__/<name>.pyc
because
this runner's own imports created it — trust by PROVENANCE, which a pathname cannot establish and a crafted cache defeats
this process cannot read it — sys.pycache_prefix is set before any leg import, so CPython consults no __pycache__ beside a source
asserted by
nothing
test_a_leg_module_is_never_cached_beside_its_source, through importlib.util.cache_from_source() on a real leg module
It is the rule this file has already applied three times to scope — the spec mounts, the flag scan, the untracked read: a state that cannot change this run's result must not refuse it. And everything the pass-over does not cover stays dirt, tested: an ignored .py under src, and a sourceless src/shadow.pyc at a module's own path, which the prefix does NOT make unreachable because it moves cache lookups and not the module search path.
Three texts this act made stale are corrected with it, in round 6's idiom: worktree_dirt()'s "THREE READS" (it asks FOUR, and the ignored read was missing from its own list), and the two places — unmaterialized_legs() and main() — that said composing the stack writes __pycache__ into the tree whose cleanliness the next check asserts. Runbook § 2.3 takes the same correction and states what the sweep passes over and why. It promises no one-time cleanup, and this sentence used to (Copilot at 34ab803e4, "previously missed"): the cleanup was owed by the version of this act that retired the pass-over outright, and it stopped being owed when the pass-over came back at d45522ddc — a checkout carrying bytecode from before this change is passed over, not reported. The runbook was corrected in that commit; the description was not, until now. (A stale description is fixed in the description: it costs no push, on #1115 round 9's precedent.)
2. :608 — the refusal that exists so as not to overclaim stops opening with an overclaim
Copilot's suppressed finding at 50a3e574, with the remedy exactly as registered. The branch is the one added two rounds earlier so that a FAILED tree read would stop delivering a diagnosis it cannot support, and its first clause then said git archive"matched none of" the two archive paths — which asserts that NEITHER matched. git archive fails as soon as ONE pathspec matches nothing, and _absence() returning None is precisely the state in which this runner cannot say which; the next sentence of the same refusal says so outright. It now reads "did not match at least one of", with " and " joining the list rather than " or ", since the two are no longer being offered as alternatives. The code, the remedy and the ls-tree the operator is sent to are unchanged.
OK — 1 of 1 corpus state(s) equivalent, exit 0, 14,849 bytes / 764b077b…0735
bytecode in the legs after a full suite run
0.pyc, 0 __pycache__ directories
the CI failure, reproduced and then not reproduced
with opendox/__pycache__/{__init__,corpus_adapter}.cpython-312.pyc present, the runner is ok at the same digest and the suite is 109 passed
the gate's own ordering, one process — pytest tests/ideation-dashboard tests/domain_profile tests/snapshot_equivalence
1248 passed, 13 skipped, legs still clean
mutation sweep
26 of 26 caught, 0 survived
the LEG ADVANCE #1134 brought (openXdox-code 2529c10a → ab04453d, openDox-code → d816cf06)
the runner still OK, same 14,849 bytes / 764b077b…0735 — the floor doing exactly what it exists for, across a real leg bump
doc-health
names neither docs/opendox-cutover-runbook.md nor any file this PR touches
The six new tests: the ORDER (a fake reach records sys.pycache_prefix at require(), install() and the first module() — the real reach sets the same prefix, so only a fake can say which of the two did it); a host's own prefix left alone; a real end-to-end run leaving both pinned trees byte for byte as it found them; cache_from_source() for a leg module landing outside the leg, which is the exposure stated the way CPython states it; the runner's and the reach's spellings of the cache home held together; and the reach taking every importer's bytecode out of the legs, probed in two fresh interpreters.
A note on the sweep, because it went wrong first and the second run is the one quoted. The mutant that puts the cache home INSIDE a leg leaves .pyc files there that restoring the SOURCE does not remove, so the three mutants after it were "caught" by their predecessor's mess rather than by their own defect (24 failures each, in 17s). The harness now clears both __pycache__ and a stray .pycache from the legs before every run; in the honest sweep those same mutants fail exactly one test each. 12 of 12, with each result its own.
Copilot, two rounds, both FACT and both taken
Round 1 — keeping every non-None prefix was a hole: PYTHONPYCACHEPREFIX inside a pinned mount defeats the guarantee it is being kept for, a LEG-ROOT prefix puts the cache inside the pin and outside the src the sweep scans, and even an in-src prefix is read during post_stack(), which imports the legs BEFORE verify_pins() sweeps anything — so "caught later" is not caught for an exposure whose content is that code ran. A chosen prefix is now kept only while it resolves outside every pinned mount; relative prefixes go too (CPython resolves a relative head at WRITE time against a working directory this runner does not control) and symlinks are resolved on both sides.
Round 2 — the fallback was not held to the rule it enforces: a pre-existing <repo>/.pycache that is a SYMLINK into a pinned mount lands the cache exactly where the function exists to keep it out of. Both are checked now, with a freshly created mkdtemp() as the last resort — a directory this process just made cannot hold a crafted cache to read, and install() runs in every conftest here, so a stray symlink in one checkout must not become an ImportError in all of them.
Round 3 — and this one is a defect one commit old: round 2 promised that a stray symlink must not become an ImportError in every conftest here, then asked Path.resolve() for an answer it RAISES on. Measured on this repository's own interpreter, CPython 3.12.3: Path("a").resolve() on a cyclic link raises RuntimeError: Symlink loop, with strict=False as well as strict=True — while os.path.realpath() swallows it and returns the path unresolved, which is exactly why reading one's behaviour off the other is wrong. _resolved() answers None where the filesystem will not answer and the caller fails safe on it: a path that cannot be SHOWN to be outside every pinned mount is treated as inside.
Round 4 — and this is the one that looked safe: PYTHONPYCACHEPREFIX=/ passed the predicate as "outside every pin", and is the opposite. In prefix mode CPython does not put the cache AT the prefix — cache_from_source() appends the source's OWN absolute directory and drops the __pycache__ component — so the filesystem root maps a leg module straight back beside its own source. Measured: with PYTHONPYCACHEPREFIX=/, cache_from_source(<leg>/src/openxdox/generator.py) is <leg>/src/openxdox/generator.cpython-312.pyc, inside the pin and read before verify_pins() sweeps. The predicate now maps each mount through CPython's own rule and refuses a prefix whose cache would LAND in the pin, so the root is refused as the case it is rather than as a special case.
Replacing rather than refusing, in all four rounds, is GIT_ATTR_NOSYSTEM's precedent in this same file: an ambient variable that would weaken a guarantee is overridden, never turned into a required gate's refusal.
Round 5 is REGISTERED, not taken (comment 5769773339), and the head stops moving for this class as d815f2970 said it would. Its first half is true — honouring a host prefix trusts whoever can write inside it, and inside_a_pinned_mount() is a LOCATION predicate, never a trust one. Its second half is what round 4 closed: no accepted prefix can redirect a lookup into a pinned leg. What remains is environment trust, which an actor who can set PYTHONPYCACHEPREFIX defeats through PYTHONPATH or PYTHONSTARTUP in the same breath — this lane's own threat model, on the record at r4049745762. Remedy registered with both options and a recommendation.
The naming nit is answered rather than taken:every_importers_bytecode is the quantifier the test is about — EVERY importer's bytecode, not all of some bytecode — and all_importers_bytecode moves the quantifier onto the wrong noun.
Summary by Sourcery
Keep compiled bytecode out of pinned legs before imports and make equivalence refusals accurately describe indeterminate archive reads.
Bug Fixes:
Prevent execution of cached Python bytecode from pinned leg checkouts by relocating bytecode caches before leg imports.
Correct equivalence refusal wording so unreadable archive results do not overstate which paths were absent.
Enhancements:
Retain the scoped bytecode sweep while basing its exception on established unreachability rather than presumed provenance.
Harden cache-prefix selection against pinned paths, symlinks, unresolved paths, and unsafe temporary-directory fallbacks.
Align runner and shared reach cache handling and update the cutover runbook to document the revised cleanliness checks.
Documentation:
Update the cutover runbook to describe the four-part worktree sweep and bytecode-cache behavior.
Tests:
Add coverage for cache-prefix ordering, safe fallback behavior, pinned-path and symlink handling, importer coverage, worktree dirt classification, and end-to-end leg cleanliness.
…the allowlist that guarded it retires
Registered item 1 of the successor act to #1115 (comment `5736824535`,
discussion `r4049745762`): an allowlisted `__pycache__/*.pyc` is trusted BY
PATHNAME, and CPython validates a cached `.pyc` against the mtime and size in
its own header — so a crafted cache still matching the tracked source is
loaded and EXECUTED, by the run whose entire claim is that this tree IS the
commit it is pinned at. The legs are imported before the sweep runs, so the
sweep could not have caught it even if it had looked, and it was told not to
look: the allowlist existed because this runner's own imports created the
files.
`sys.pycache_prefix` removes the condition instead of policing it. With it
set CPython neither READS nor writes a `__pycache__` beside the source, so
nothing can be crafted into this process and nothing is written into a tree
this repository pins. `sys.dont_write_bytecode` is not the remedy — it stops
the writing and leaves the reading, which is the half the finding is about.
WHERE IT IS SET, AND WHY IN TWO PLACES. `post_stack()` sets it on the process
before `import carved_reach`, for the reason the `GIT_NO_LAZY_FETCH` guard
three lines above it is set here: a guarantee this runner's verdict rests on
is made BY this runner, before the shared reader is imported, rather than
inherited from it. `carved_reach.install()` sets it too, and that one is not
belt and braces — MEASURED: the runner is not the only importer.
`tests/ideation-dashboard/test_lens.py` alone left 46 `.pyc` files under the
two `src/` roots, and that directory sorts BEFORE `tests/snapshot_equivalence`
in the single `pytest tests/` process the required gate runs. Retiring the
allowlist in the runner alone would have made every end-to-end run in that
gate refuse on bytecode a sibling suite wrote — the registered item's own
premise, that the runner creates those files, is true but not exhaustive.
`install()` is the one gate every route into the legs passes through
(`module()` calls it), so it is where the guarantee belongs. A prefix the
process has already chosen — `PYTHONPYCACHEPREFIX`, or a host — is left
alone: any prefix satisfies this, and one pointed INTO a leg is caught by the
sweep it would be trying to fool.
The cache home is `<repo>/.pycache`, inside the checkout deliberately: the
exposure needs a writer in the working tree, and such a writer could edit
`carved_reach.py` itself, while a fixed path under a shared `/tmp` is a
directory another user can create first and fill with exactly the crafted
caches above. The root `.gitignore` already ignores `*.py[cod]`, so every file
written there is ignored and `git status` is unchanged (measured); nothing is
added to it.
THE ALLOWLIST IS GONE. Every ignored file under the import surface is dirt
now — a `.py`, a sourceless `src/shadow.pyc` and a `__pycache__` `.pyc`
alike — and nothing under it is trusted by its pathname. Three texts this act
made stale are corrected with it: `worktree_dirt()`'s "THREE READS" (it asks
four, and the ignored read was missing from its own list), and the two places
that said composing the stack writes `__pycache__` into the tree whose
cleanliness the next check asserts.
MEASURED at this commit: 100 passed, 0 skipped (95 + six new, the two
allowlist tests folded into one that asserts the stronger rule);
`EXPECT_SKIPPED: "6"` untouched; the verdict UNCHANGED at 14,849 bytes,
`sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735`,
exit 0; zero `.pyc` under either leg after a full suite run; and
`pytest tests/ideation-dashboard tests/domain_profile tests/snapshot_equivalence`
in ONE process — the gate's own ordering — 1248 passed, 13 skipped, legs
still clean.
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…stops opening with an overclaim
Registered item 2 of the successor act to #1115 (Copilot at `50a3e574`,
suppressed; the remedy spelled out in comment `5736824535`). The branch is
the one added two rounds earlier precisely so that a FAILED tree read would
stop delivering a diagnosis it cannot support — and its first clause then
asserted that `git archive` "matched none of" the two archive paths, which
says NEITHER matched. `git archive` fails as soon as ONE pathspec matches
nothing, and `_absence()` returning `None` is exactly the state in which this
runner cannot say which: the next sentence of the same refusal says so
outright ("could not read that commit's tree to say WHICH of them is
missing"). What the failure does support is that at least one of them did not
match, and that is what it says now — `" and "` rather than `" or "` in the
joined list, since the two are no longer being offered as alternatives.
Nothing else moves: the code, the remedy and the `ls-tree` the operator is
sent to are as they stand. The existing regression
(`test_a_tree_read_that_failed_does_not_become_a_post_shed_verdict`) already
exercises the branch, so the assertions join it there — the detail does not
say `matched none of`, it does say `did not match at least one of`, and the
conjunction survives into the joined list, which is the half a wording fix
loses most easily.
MEASURED: 100 passed, 0 skipped; verdict unchanged at 14,849 bytes,
`sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735`.
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This hardening PR eliminates execution of pathname-allowlisted bytecode from pinned legs by redirecting CPython caches before every importer can load them, makes the import-surface sweep distrust all ignored files, and precisely qualifies the unreadable-tree refusal without changing the equivalence verdict.
Sequence diagram for bytecode isolation before pinned-leg imports
sequenceDiagram
participant Runner as verify-snapshot-equivalence
participant Reach as carved_reach
participant CPython
participant Legs as Pinned legs
Runner->>Runner: post_stack()
alt sys.pycache_prefix is unset
Runner->>CPython: set sys.pycache_prefix to .pycache
else prefix already chosen
Runner->>CPython: retain existing prefix
end
Runner->>Reach: import carved_reach
Reach->>Reach: install()
Reach->>CPython: preserve cache prefix
Reach->>Legs: expose src modules
CPython->>Runner: import modules without leg-local __pycache__ reads or writes
Loading
Flow diagram for the complete import-surface dirt sweep
flowchart TD
Start[Verify pinned leg cleanliness] --> Tracked[Read tracked diff under src]
Tracked --> Ignored[Read every ignored file under src]
Ignored --> Untracked[Read non-ignored untracked files]
Untracked --> Flags[Read assume-unchanged and skip-worktree flags]
Flags --> Decision{Any dirt found?}
Decision -->|Yes| Refuse[Refuse equivalence]
Decision -->|No| Continue[Proceed to pin verification and rendering]
Loading
Flow diagram for the precise unreadable-tree refusal
flowchart TD
Archive[git archive pre_commit with two pathspecs] --> Result{Archive fails}
Result -->|Failure may mean one or both paths unmatched| Refusal[Refuse: did not match at least one path]
Refusal --> Operator[Direct operator to ls-tree]
Result -->|No failure| Extract[Extract pre-tree and continue]
Loading
File-Level Changes
Change
Details
Files
Moves Python bytecode caching out of pinned leg checkouts and removes the cache allowlist from cleanliness verification.
Set a repository-local pycache prefix before runner imports and from the shared reach installer, while preserving an existing process prefix.
Treat all ignored files under each leg's import surface—including both cache layouts, sourceless .pyc files, and ignored Python sources—as dirt.
Update sweep and runbook documentation to describe four checks, cache behavior, and cleanup of stale bytecode.
Add ordering, prefix-preservation, end-to-end cleanliness, cache-location, consistency, and fresh-interpreter coverage.
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!
…t — Copilot round 1
Both findings are FACT on the landed text, and they are one class: "any
prefix at all satisfies this" was wrong, and the sentence I defended it with
("one pointed INTO a leg would be caught by the sweep it is trying to fool")
was wrong twice over.
* A prefix at a LEG ROOT — `PYTHONPYCACHEPREFIX=<repo>/openDox/code` — puts
the cache inside the pin AND OUTSIDE the `src` the cleanliness sweep
scans, so a crafted cache there is invisible to the one check that was
supposed to report it. The sweep's scope is right (only `src` can reach an
import through `carved_reach`) and it simply does not cover this.
* Even a prefix UNDER `src` is read during `post_stack()`, which imports the
legs BEFORE `verify_pins()` sweeps anything — so the refusal arrives after
the crafted cache has already executed. "Caught later" is not caught for an
exposure whose whole content is that code ran.
`bytecode_out_of_the_legs()` now KEEPS a prefix the process chose only while
it resolves outside every pinned mount, and replaces it otherwise. A RELATIVE
prefix is in the replaced class too: CPython joins the prefix with the source
file's own directory at WRITE time and resolves a relative head against
whatever the working directory is then, so where it lands is not knowable
here — and a guarantee that cannot be checked is not a guarantee. Symlinks
are resolved on both sides, since a link into a leg is the same placement
under another name. REPLACING rather than refusing is `GIT_ATTR_NOSYSTEM`'s
precedent in this same file: an ambient variable that would weaken a
guarantee is overridden, never turned into a required gate's refusal.
The mount set is DERIVED in the runner (`LEG_GITLINKS`'s root entries, so it
cannot fall out of step with the pins it verifies) and spelled in the reach,
because `openXdox`'s own root is not a `MOUNTS` key — no manifest row arrives
there — so a set derived from `MOUNTS` alone would have missed exactly the
leg-root case above. A test holds the two sets equal and holds both to every
mount `MOUNTS` declares.
Six new tests (106 passed, 0 skipped): the five spellings of an in-pin prefix
— the mount, its `code`, its `code/src`, a relative one and a symlink — each
replaced; the reach probed for the same two cases in fresh interpreters, since
it is where every importer but this runner arrives; and the mount sets held
together. Verdict unchanged: 14,849 bytes,
`sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735`.
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
… pass-over comes back re-founded on what the run cannot reach
TWO THINGS, and the second is this act's own registered premise failing a
measurement.
1. COPILOT ROUND 2, FACT, taken. `BYTECODE_HOME` is a PATH and not a
guarantee: a pre-existing `<repo>/.pycache` that is a SYMLINK into a
pinned mount puts the cache exactly where `bytecode_out_of_the_legs()`
exists to keep it out of. `inside_a_pinned_mount()` resolves links and
would have said so — it was asked about a host's prefix and never about
the fallback. It is asked about both now, and the last resort is a
directory this process has just created (`mkdtemp`), which cannot hold a
crafted cache to read. Not a refusal: `install()` runs in every conftest
in this repository, and a stray symlink in one checkout must not become
an ImportError in all of them.
2. THE PASS-OVER FOR `__pycache__/<name>.pyc` COMES BACK — re-founded, not
restored. `pytest-suite` at `e85d15384` FAILED 23 tests, all in
`tests/snapshot_equivalence`, all cascading from
`equivalence-reach-unavailable … !! src/opendox/__pycache__/
{__init__,corpus_adapter}.cpython-312.pyc`. Those two files are written by
a SECOND and independent reach into the legs: `scripts/
corpus_adapter_openxfactory/` puts `openDox/code/src` on `sys.path`
itself and never mentions `carved_reach` (RULED OQ-Q, `#872`). Reproduced
here exactly — `import corpus_adapter_openxfactory.adapter` with no
prefix set leaves precisely those two `.pyc` files.
The registered item's premise was that once the runner stops writing
bytecode into the legs there is nothing left to pass over. It is false,
and it failed twice: first at `tests/ideation-dashboard/test_lens.py`'s
46 `.pyc` files (answered by fixing `carved_reach.install()`), then here.
The enumeration of importers is not closable by inspection — any
consumer, any future script, a developer running the leg's own suite
inside the leg — and a REQUIRED gate must not rest on "nothing anywhere
ever writes a `.pyc` into a pinned checkout".
What changes is the GROUND, which is what the finding was actually about.
The old rule was "the bytecode this runner's own imports create": trust by
PROVENANCE, which a pathname cannot establish, and which a crafted cache
defeats. The rule now is REACHABILITY: with `sys.pycache_prefix` set
before any leg import, this process consults no `__pycache__` beside any
source, so those bytes cannot execute in this run whoever wrote them —
the same rule this file has applied three times to scope (the spec
mounts, the flag scan, the untracked read): a state that cannot change
this run's result must not refuse it. It is asserted, not assumed:
`test_a_leg_module_is_never_cached_beside_its_source` puts a real leg
module through `importlib.util.cache_from_source()`.
Everything the pass-over does NOT cover stays dirt and is tested: an
ignored `.py` under `src`, and a sourceless `src/shadow.pyc` at a module's
own path — which the prefix does not make unreachable, because it moves
CACHE lookups and not the module search path.
`test_a_run_writes_no_bytecode_into_either_pinned_leg` drops its
precondition on the legs being empty and keeps the claim this runner can
make about itself: whatever it found, it ADDS nothing.
MEASURED at this commit, with `origin/main` `6932adf1` merged in: 109 passed,
0 skipped; the runner `ok` with the verdict unchanged at 14,849 bytes,
`sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735` —
including with the CI's own dirt present, reproduced by importing the second
reach first.
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…opilot round 3
FACT, and it is a defect one commit old: the round before promised that a
stray symlink in one checkout must not become an ImportError in every
conftest in this repository, and then asked `Path.resolve()` for an answer it
RAISES on.
MEASURED on this repository's own interpreter, CPython 3.12.3:
>>> ln -s b a; ln -s a b
>>> pathlib.Path("a").resolve()
RuntimeError: Symlink loop from '…/a'
— with `strict=False` as well as `strict=True`, which is the half that
surprises, since `os.path.realpath()` swallows the loop and returns the path
unresolved. So a cyclic `<repo>/.pycache`, or a cyclic
`PYTHONPYCACHEPREFIX`, would have raised out of `carved_reach.install()`
before the fallback could be chosen — the exact failure mode the fallback
exists to prevent, one layer up.
`_resolved()` answers `None` where the filesystem will not answer, and the
one caller FAILS SAFE on it: a path that cannot be SHOWN to be outside every
pinned mount is treated as inside, so the cache goes to the freshly created
directory. The mount side is resolved through the same helper, because a leg
path that cannot be resolved is equally a mount this run cannot prove a
prefix is outside of. `(OSError, RuntimeError, ValueError)` — the loop is the
`RuntimeError`, a permission or a name too long is the `OSError`, and an
embedded NUL is the `ValueError`.
Three tests (112 passed, 0 skipped): a cyclic prefix through `post_stack()`;
a cyclic `BYTECODE_HOME` with nothing chosen; and the reach in a FRESH
interpreter with `PYTHONPYCACHEPREFIX` cyclic, asserting no `RuntimeError`
reaches stderr and that `install()` still returns — which is where the crash
would have landed. Verdict unchanged: 14,849 bytes,
`sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735`.
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ere the prefix is — Copilot round 4, and the last
FACT, MEASURED. `PYTHONPYCACHEPREFIX=/` passed `inside_a_pinned_mount()` as
"outside every pin", and it is the opposite: in prefix mode CPython does not
put the cache AT the prefix — `cache_from_source()` builds the directory as
`_path_join(sys.pycache_prefix, head.lstrip(path_separators))`, the source's
OWN absolute directory appended to the prefix, and drops the `__pycache__`
component entirely. So the filesystem root maps a leg module straight back
beside its own source:
$ PYTHONPYCACHEPREFIX=/ python3 -c 'import importlib.util; print(
importlib.util.cache_from_source(".../openXdox/code/src/openxdox/
generator.py"))'
.../openXdox/code/src/openxdox/generator.cpython-312.pyc
— inside the pin, read during `post_stack()` before `verify_pins()` sweeps
anything, and with no `__pycache__` component, so not even the class the
sweep passes over.
The predicate now asks the question it was always about: for each pinned
mount it maps the mount's own directory through CPython's rule and refuses a
prefix whose cache would land inside the pin. The root is then refused as
the case it is rather than as a special case, and any other prefix with the
same property is refused with it. `test_a_host_prefix_inside_a_pin_is_
replaced_rather_than_kept` gains `/` as a sixth spelling; the mount-set test
and the reach's fresh-interpreter probe assert it on both sides.
113 passed, 0 skipped. Verdict unchanged: 14,849 bytes,
`sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735`.
THE HEAD STOPS MOVING FOR THIS FINDING CLASS HERE. Four rounds of
cache-prefix findings have each been a real defect in code the round before
introduced, and each has been fixed; from here anything further in this
class is answered and REGISTERED for a successor act rather than pushed, on
#1115's rule — every push draws a fresh full-file review, and the floor this
pull request measures has to be able to land.
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
REGISTERED WITH ITS REMEDY, NOT TAKEN — the head stops moving for this finding class, as d815f2970 said it would. Copilot's review at d815f2970 reports 0 new comments outside this one class and these two findings, which are one finding stated twice.
scripts/verify-snapshot-equivalence.py:313 / scripts/carved_reach.py:412 — a host prefix is a LOCATION test, not a TRUST test
An inherited PYTHONPYCACHEPREFIX=/tmp … lets CPython read <prefix>/<absolute source path>/…pyc; a pre-created subtree or symlink can redirect that lookup into a pinned leg…
The first half is TRUE and I will not argue it: honouring any host prefix trusts whoever can write inside it, and /tmp is world-writable, so a pre-created /tmp/<abs source dir>/generator.cpython-312.pyc whose header matches the tracked source would be executed. inside_a_pinned_mount() is a location predicate and its docstring says so; it was never a claim about trust.
The second half is not what happens, and the difference is the whole point of rounds 1–4. A prefix cannot redirect a lookup INTO a pinned leg any more — that is exactly what d815f2970 closed by mapping each mount through CPython's own rule (_path_join(prefix, head.lstrip(path_separators))) and refusing any prefix whose cache would land inside the pin, the filesystem root included. Measured at this head: inside_a_pinned_mount("/") is True, and so is every spelling of a leg path, relative or symlinked. A symlink INSIDE an accepted prefix pointing at a leg does not help either — it would place the attacker's bytes in the leg, where the cleanliness sweep reports them, and CPython would still read them from the prefix path, not from the leg's __pycache__.
So what is left is the real residue, stated exactly: the guarantee this act was registered to make is about the PINNED LEGS, and it holds. It is not, and was never, a guarantee that a host who controls this process's environment cannot feed it code.
Why it is registered rather than pushed
An actor who can set PYTHONPYCACHEPREFIX can set PYTHONPATH, PYTHONSTARTUP or PYTHONHOME in the same breath, and the runner process (unlike the PRE child, which is -I) is not isolated from any of them by design. This lane already has that threat model on the record, from the act that registered this work (r4049745762): "the exposure needs a writer in the checkout — who could equally edit scripts/carved_reach.py, scripts/opendox_host.py or this runner itself, none of which any pin covers." Closing environment trust properly is that shape of act, not a fifth round on this one.
The remedy for the successor, with the tradeoff, because both halves are real:
Ignore host prefixes entirely — always BYTECODE_HOME, falling back to mkdtemp(). Simplest, and it makes the cache root process-controlled by construction. Cost: it overrides a deliberate host choice in every run, including the legitimate ones (a read-only source tree, a CI cache), which is what rounds 1–4 deliberately avoided.
Accept a host prefix only when it is process-controlled: created by this process, or stat-checked as ours with mode 0700 and no symlink on the mapped path. Keeps the host's intent, costs a real ownership check and a per-mapped-path check on every import surface.
Recommended: (2) for the reach and (1) for the runner — the runner is a gate with one job and no reason to honour an ambient cache at all, while carved_reach.install() runs in every conftest in this repository and should not quietly discard a host's configuration.
The head that is going ready
d815f2970 — four head-moving rounds on this class, each a real defect in code the round before introduced, each fixed and tested: an in-pin prefix kept (round 1), the fallback not held to its own rule (round 2), Path.resolve() raising RuntimeError on a cyclic link — measured, CPython 3.12.3, with strict=False too (round 3), and the filesystem root mapping a leg module back beside its own source (round 4, measured). 113 passed / 0 skipped, mutation sweep 26 of 26 caught, 0 unresolved threads, and the verdict unchanged throughout at 14,849 bytes, sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735 with EXPECT_SKIPPED: "6" untouched — which, for a hardening act, is the number that matters most.
…sproved, and the last resort's own parent — Copilot round 6
Two of the three findings are taken, and both are defects in what THIS ACT
wrote. The third is registered, not taken.
1. A DOCSTRING OF MINE WAS FLATLY FALSE, and this act had already measured it
false: `_bytecode_out_of_the_legs()` said it is called from `install()`,
"so every route this repository has into the legs passes through it". It
is not. `scripts/corpus_adapter_openxfactory/` puts `openDox/code/src` on
`sys.path` itself and imports `opendox.corpus_adapter` without coming
through the reach at all (RULED OQ-Q, `#872`) — which is the measurement
that made this act re-found the sweep's pass-over two commits ago, written
into the runner and the commit message and left standing wrong here. The
claim is narrowed to what it supports: no importer REACHING THROUGH
`carved_reach` reads or writes bytecode inside a pinned mount. A test
holds the narrowing to the measurement, so it fails if that importer ever
does go through the reach.
2. `tempfile.mkdtemp()` HONOURS `TMPDIR`, so the last resort could be created
inside a pinned mount and was assigned without being checked again. The
PARENT is chosen before anything is written now: the temp directory when
it is outside every mount, and otherwise the repository root — which
CONTAINS the mounts and therefore cannot be inside one. `mkdtemp()`
creates a real directory and not a symlink, so a parent that resolves
outside the pins has children that do.
The probe for it is written against `tempfile.tempdir`, not `TMPDIR`, and
the difference is measured: `gettempdir()` MEMOISES into `tempfile.tempdir`
the first time anything in the process calls it, so a test that sets the
environment variable afterwards passes against code that never looked.
That is the fourth time in this family a test has had to be rewritten
because its first spelling asserted something it was not reaching.
REGISTERED, NOT TAKEN: "make `scripts/corpus_adapter_openxfactory/` use the
shared bootstrap". It is a real improvement and it is a change to a package
this act has no other business in, under a different ruling (OQ-Q); the
runner's own guarantee does not rest on it, which is precisely why the sweep
passes over unreachable bytecode rather than counting on the legs being
empty.
115 passed, 0 skipped. Verdict unchanged at the ADVANCED legs #1134 brought
(openXdox-code `ab04453d`, openDox-code `d816cf06`): 14,849 bytes,
`sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735`.
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
THE REGISTERED LIST FOR THE SUCCESSOR ACT, AND THE HEAD STOPS HERE. This supersedes nothing in comment 5769773339 — it adds the round-6 item to it and states the disposition of every finding on this pull request in one place.
Six Copilot rounds, all on ONE class (bytecode-cache isolation). Four moved the head, each fixing a real defect in code the round before had introduced; round 5 was registered; round 6 was taken only where it named text of mine that this act's own measurement had already disproved. The rule this follows is #1115's: a defect this act INTRODUCED gets fixed however late; a finding about ground this act did not break is answered and registered.
Taken
round
finding
fix
1
an in-pin PYTHONPYCACHEPREFIX was kept; a LEG-ROOT prefix is inside the pin and outside the swept src; an in-src one is read during post_stack(), before verify_pins() sweeps
e85d15384
2
the FALLBACK was not held to the rule it enforces — a <repo>/.pycache symlinked into a pin
d45522ddc
3
Path.resolve() RAISES RuntimeError on a cyclic link — measured, CPython 3.12.3, with strict=False too, where os.path.realpath() swallows it
80d43f670
4
/ passed as "outside every pin" and is the opposite: prefix mode appends the source's own absolute directory and drops __pycache__, so the root maps a leg module back beside its own source (measured)
d815f2970
6a
a docstring of mine said install() is on "every route this repository has into the legs" — false, and this act had already measured it false
34ab803e4
6b
mkdtemp() honours TMPDIR, so the last resort could be created inside a pin and assigned unchecked
34ab803e4
Registered, not taken — for the successor act, with remedies
A host prefix is a LOCATION test, not a TRUST test (round 5, r4067659381 / r4067659405). True, and out of this act's reach: an actor who can set PYTHONPYCACHEPREFIX can set PYTHONPATH or PYTHONSTARTUP in the same breath, and the runner process is not -I isolated by design. This lane's threat model is on the record at r4049745762. Remedy, recommended: ignore host prefixes in the RUNNER (a gate with one job has no reason to honour an ambient cache); in the REACH accept one only when process-controlled — created by us, or stat-checked as ours at 0700 with no symlink on the mapped path.
Route scripts/corpus_adapter_openxfactory/ through the shared bootstrap (round 6, r4067751544). It puts openDox/code/src on sys.path itself and imports opendox.corpus_adapter without the reach (RULED OQ-Q, #872). A real improvement, in a package this act has no other business in. It is deliberately NOT a dependency of anything here: the sweep passes over bytecode it has established is UNREACHABLE rather than counting on the legs being empty, precisely so that a required gate never rests on an enumeration of importers that cannot be closed by inspection — which this pull request proved, in the gate, at e85d15384.
The head that is going ready
34ab803e4. 115 passed / 0 skipped, EXPECT_SKIPPED: "6" untouched, 0 unresolved threads, mutation sweep 26 of 26 caught at the shape before this commit, and the verdict unchanged throughout — including across the leg advance #1134 brought (openXdox-code 2529c10a → ab04453d, openDox-code → d816cf06), which is the floor doing exactly what it exists for: 14,849 bytes, sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735.
Document one-time cleanup for existing __pycache__ files
docs/opendox-cutover-runbook.md:921
The PR description says §2.3 also documents the one-time cleanup for __pycache__ files left by runs before this change, but this section only explains that future runs stop writing them and gives no cleanup command. Existing ignored caches can therefore remain in both code legs without the promised operator procedure; add the per-leg git -C ... clean -fdX -- src instructions or correct the description.
ADDENDUM to the registered list (5769952739), answering Copilot's headline at 34ab803e4 — where the review itself reports Findings: None. Neither item moves the head; one is measured, one was a stale sentence in this description and is fixed in this description.
The cache-prefix assertion rejects valid host-selected prefixes, and the runbook omits the promised cleanup command.
1. "rejects valid host-selected prefixes" — MEASURED at this head, and it does not
Every ordinary host prefix is ACCEPTED and kept, including ones inside the checkout:
Three classes are rejected and each has its reason in the code and a test:
inside a pinned mount — the exposure this act exists to close.
the filesystem root — not a special case but the general one: in prefix mode cache_from_source() appends the SOURCE'S own absolute directory to the prefix and drops the __pycache__ component, so / maps a leg module back beside its own source. Measured: with PYTHONPYCACHEPREFIX=/, cache_from_source(<leg>/src/openxdox/generator.py) is <leg>/src/openxdox/generator.cpython-312.pyc. Any other prefix with that property is rejected with it, and none of the ordinary ones have it.
a relative prefix — CPython resolves a relative head at WRITE time, against whatever the working directory then is, which install() cannot know and a tool that chdirs into a leg would make a pin. A guarantee that cannot be checked is not one; the remedy for a host that wants a relative path is to spell it absolutely.
A prefix that is rejected is not an error and nothing refuses: it is REPLACED with the checked one, on GIT_ATTR_NOSYSTEM's precedent in this same file.
2. "the runbook omits the promised cleanup command" — TRUE OF THE DESCRIPTION, not of the runbook, and the description is what was stale
The one-time git -C <leg> clean -fdX -- src was owed by the version of this act that retired the pass-over outright. It stopped being owed at d45522ddc, when the pass-over came back re-founded: a checkout carrying bytecode from before this change is passed over, not reported, so there is nothing an operator must clean. The runbook was corrected in that same commit — § 2.3 now says what the sweep passes over and why, and promises no cleanup. This pull request's DESCRIPTION still promised one; it is corrected now, in the description, which costs no push (#1115 round 9's precedent for exactly this).
The runbook's only clean -fdX is the one the runner prints itself, from _clean_advice(), for ignored entries that ARE dirt — an ignored .py, or a sourceless src/shadow.pyc. That remedy is real and unchanged.
The head going ready
34ab803e4 — every required context SUCCESS (pytest-suite, SonarCloud, openxdox-consumer-gate, merge-master-approval, the lane-line pair, openreposhape-pin, openspec-cli-pin, wallet-validation, release-tag-gate, signed-execution-chain-gate, clearing-dispatch-gate, former-id-arrival-gate), Copilot Findings: None, 0 unresolved threads, 115 passed / 0 skipped, EXPECT_SKIPPED: "6" untouched, and the verdict unchanged throughout — including across the leg advance #1134 brought — at 14,849 bytes, sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735.
FLOOR PART 4 successor (#1115's registered items, § 5.5 CLAIM 5728621421, RULED Q-P5 (a) 5731951297): sys.pycache_prefix set before the legs are imported, the bytecode allowlist retires, the :608 wording; four Copilot rounds taken incl. the cyclic-symlink RuntimeError class and the PYTHONPYCACHEPREFIX bypass; verdict unmoved (14,849 B, sha256 764b077b…0735, exit 0, EXPECT_SKIPPED 6). Actor floor55c (helper openxfactory-4-b); Brett Heap's word 'land #1132 when green and keep going' (2026-09-22).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
The SUCCESSOR ACT to #1115 (landed
4101fbe9, 2026-09-18), carrying the two items its author registered rather than pushed — the registered list,#1115comment5736824535— under the same § 5.5 CLAIM#656comment5728621421and RULED Q-P5 = (a) (#656comment5731951297). Nothing else is in it.THE VERDICT DOES NOT MOVE, and for a hardening act that is the number that matters. At this head the equivalence runner still renders 14,849 bytes,
sha256 764b077b84031ec9bb13538f400904119141d954636cee6d53eee052b3840735, exit 0, andEXPECT_SKIPPED: "6"is untouched.1.
sys.pycache_prefix, set before the legs are imported — and the bytecode allowlist retiresr4049745762. An allowlisted__pycache__/*.pycis trusted BY PATHNAME, and CPython validates a cached.pycagainst the mtime and size recorded in its own HEADER — so a crafted cache still matching the tracked source is loaded and EXECUTED. The legs are imported inpost_stack(), beforeverify_pins()sweeps anything, so that bytecode would have rendered the post side while the verdict named a commit it did not come from; and the sweep could not have caught it even if it had looked, because the class was allowlisted precisely on the grounds that this runner's own imports created it.sys.pycache_prefixremoves the condition rather than policing it: with it set CPython neither READS nor writes a__pycache__beside the source.sys.dont_write_bytecodeis not the remedy and was not proposed as one — it stops the writing and leaves the reading, which is the half the finding is about.It is set in two places, and the second is not belt and braces
post_stack(), beforeimport carved_reach— for the reason theGIT_NO_LAZY_FETCHguard three lines above it is set there: a guarantee this runner's verdict rests on is made BY this runner, on the process, before the shared reader is imported, rather than inherited from a reader that could stop providing it.carved_reach.install()— because the registered item's premise, that this runner creates those files, is true but not exhaustive, and the difference is a red required gate. MEASURED:tests/ideation-dashboard/test_lens.pyon its own left 46.pycfiles under the twosrc/roots, andtests/ideation-dashboardsorts BEFOREtests/snapshot_equivalencein the singlepytest tests/processpytest-suiteruns. Retiring the allowlist in the runner alone would have made every end-to-end run in that gate refuse — on bytecode a sibling suite wrote. Proven before it was fixed: with the allowlist stubbed out and the legs carrying that suite's bytecode,python3 scripts/verify-snapshot-equivalence.pyrefusesequivalence-reach-unavailableand lists!! src/opendox/__pycache__/….install()is the one gate every route into the legs passes through (module()calls it), so it is where the guarantee belongs, and it covers the importers a conftest cannot:tests/ideation-dashboard/test_cli_column_split.py'sBOOTSTRAPandtests/domain_profile's probe each bootstrap the reach in a FRESH interpreter.A prefix the process has already chosen —
PYTHONPYCACHEPREFIX, or a host — is left alone: any prefix satisfies the requirement, and one pointed INTO a leg is caught by the sweep it would be trying to fool.Where the cache goes, and why inside the checkout
<repo>/.pycache. The exposure needs a writer in the working tree, and such a writer could editscripts/carved_reach.pyitself — the threat-model argument already on this lane's record — while a fixed path under a shared/tmpis a directory another user can create FIRST and fill with exactly the crafted caches above. The root.gitignorealready carries*.py[cod], so every file written there is ignored andgit status --porcelain -unormalis unchanged (measured); nothing is added to it. If the directory cannot be written, CPython silently skips caching — the failure mode is a slower import, never a broken one.The allowlist does not retire — it is RE-FOUNDED, and the gate is why
This is the one place the act departs from the registered wording, and it departs because the premise failed a measurement. Item 1 expected that once the runner stops writing bytecode into the legs there is nothing left to pass over. It was retired outright at
e85d15384, andpytest-suitefailed 23 tests — all intests/snapshot_equivalence, all cascading fromequivalence-reach-unavailable … !! src/opendox/__pycache__/{__init__,corpus_adapter}.cpython-312.pyc(run 35660132139). Those two files come from a second, independent reach:scripts/corpus_adapter_openxfactory/putsopenDox/code/srconsys.pathitself and never mentionscarved_reach(RULED OQ-Q,#872). Reproduced exactly here —import corpus_adapter_openxfactory.adapterwith no prefix set leaves precisely those two.pycfiles.That is the second time the premise failed (the first was
test_lens.py's 46 files, answered by fixinginstall()), and it settles the question: the enumeration of importers is not closable by inspection — any consumer, any future script, a developer running the leg's own suite inside the leg — and a required gate must not rest on "nothing anywhere ever writes a.pycinto a pinned checkout".So what changes is the GROUND, which is what the finding was actually about:
__pycache__/<name>.pyc__pycache__/<name>.pycsys.pycache_prefixis set before any leg import, so CPython consults no__pycache__beside a sourcetest_a_leg_module_is_never_cached_beside_its_source, throughimportlib.util.cache_from_source()on a real leg moduleIt is the rule this file has already applied three times to scope — the spec mounts, the flag scan, the untracked read: a state that cannot change this run's result must not refuse it. And everything the pass-over does not cover stays dirt, tested: an ignored
.pyundersrc, and a sourcelesssrc/shadow.pycat a module's own path, which the prefix does NOT make unreachable because it moves cache lookups and not the module search path.Three texts this act made stale are corrected with it, in round 6's idiom:
worktree_dirt()'s "THREE READS" (it asks FOUR, and the ignored read was missing from its own list), and the two places —unmaterialized_legs()andmain()— that said composing the stack writes__pycache__into the tree whose cleanliness the next check asserts. Runbook § 2.3 takes the same correction and states what the sweep passes over and why. It promises no one-time cleanup, and this sentence used to (Copilot at34ab803e4, "previously missed"): the cleanup was owed by the version of this act that retired the pass-over outright, and it stopped being owed when the pass-over came back atd45522ddc— a checkout carrying bytecode from before this change is passed over, not reported. The runbook was corrected in that commit; the description was not, until now. (A stale description is fixed in the description: it costs no push, on #1115 round 9's precedent.)2.
:608— the refusal that exists so as not to overclaim stops opening with an overclaimCopilot's suppressed finding at
50a3e574, with the remedy exactly as registered. The branch is the one added two rounds earlier so that a FAILED tree read would stop delivering a diagnosis it cannot support, and its first clause then saidgit archive"matched none of" the two archive paths — which asserts that NEITHER matched.git archivefails as soon as ONE pathspec matches nothing, and_absence()returningNoneis precisely the state in which this runner cannot say which; the next sentence of the same refusal says so outright. It now reads "did not match at least one of", with" and "joining the list rather than" or ", since the two are no longer being offered as alternatives. The code, the remedy and thels-treethe operator is sent to are unchanged.Measured
pytest tests/snapshot_equivalenceOK — 1 of 1 corpus state(s) equivalent, exit 0, 14,849 bytes /764b077b…0735.pyc, 0__pycache__directoriesopendox/__pycache__/{__init__,corpus_adapter}.cpython-312.pycpresent, the runner isokat the same digest and the suite is 109 passedpytest tests/ideation-dashboard tests/domain_profile tests/snapshot_equivalence2529c10a→ab04453d, openDox-code →d816cf06)OK, same 14,849 bytes /764b077b…0735— the floor doing exactly what it exists for, across a real leg bumpdocs/opendox-cutover-runbook.mdnor any file this PR touchesThe six new tests: the ORDER (a fake reach records
sys.pycache_prefixatrequire(),install()and the firstmodule()— the real reach sets the same prefix, so only a fake can say which of the two did it); a host's own prefix left alone; a real end-to-end run leaving both pinned trees byte for byte as it found them;cache_from_source()for a leg module landing outside the leg, which is the exposure stated the way CPython states it; the runner's and the reach's spellings of the cache home held together; and the reach taking every importer's bytecode out of the legs, probed in two fresh interpreters.A note on the sweep, because it went wrong first and the second run is the one quoted. The mutant that puts the cache home INSIDE a leg leaves
.pycfiles there that restoring the SOURCE does not remove, so the three mutants after it were "caught" by their predecessor's mess rather than by their own defect (24 failures each, in 17s). The harness now clears both__pycache__and a stray.pycachefrom the legs before every run; in the honest sweep those same mutants fail exactly one test each. 12 of 12, with each result its own.Copilot, two rounds, both FACT and both taken
Round 1 — keeping every non-
Noneprefix was a hole:PYTHONPYCACHEPREFIXinside a pinned mount defeats the guarantee it is being kept for, a LEG-ROOT prefix puts the cache inside the pin and outside thesrcthe sweep scans, and even an in-srcprefix is read duringpost_stack(), which imports the legs BEFOREverify_pins()sweeps anything — so "caught later" is not caught for an exposure whose content is that code ran. A chosen prefix is now kept only while it resolves outside every pinned mount; relative prefixes go too (CPython resolves a relative head at WRITE time against a working directory this runner does not control) and symlinks are resolved on both sides.Round 2 — the fallback was not held to the rule it enforces: a pre-existing
<repo>/.pycachethat is a SYMLINK into a pinned mount lands the cache exactly where the function exists to keep it out of. Both are checked now, with a freshly createdmkdtemp()as the last resort — a directory this process just made cannot hold a crafted cache to read, andinstall()runs in every conftest here, so a stray symlink in one checkout must not become an ImportError in all of them.Round 3 — and this one is a defect one commit old: round 2 promised that a stray symlink must not become an ImportError in every conftest here, then asked
Path.resolve()for an answer it RAISES on. Measured on this repository's own interpreter, CPython 3.12.3:Path("a").resolve()on a cyclic link raisesRuntimeError: Symlink loop, withstrict=Falseas well asstrict=True— whileos.path.realpath()swallows it and returns the path unresolved, which is exactly why reading one's behaviour off the other is wrong._resolved()answersNonewhere the filesystem will not answer and the caller fails safe on it: a path that cannot be SHOWN to be outside every pinned mount is treated as inside.Round 4 — and this is the one that looked safe:
PYTHONPYCACHEPREFIX=/passed the predicate as "outside every pin", and is the opposite. In prefix mode CPython does not put the cache AT the prefix —cache_from_source()appends the source's OWN absolute directory and drops the__pycache__component — so the filesystem root maps a leg module straight back beside its own source. Measured: withPYTHONPYCACHEPREFIX=/,cache_from_source(<leg>/src/openxdox/generator.py)is<leg>/src/openxdox/generator.cpython-312.pyc, inside the pin and read beforeverify_pins()sweeps. The predicate now maps each mount through CPython's own rule and refuses a prefix whose cache would LAND in the pin, so the root is refused as the case it is rather than as a special case.Replacing rather than refusing, in all four rounds, is
GIT_ATTR_NOSYSTEM's precedent in this same file: an ambient variable that would weaken a guarantee is overridden, never turned into a required gate's refusal.Round 5 is REGISTERED, not taken (comment 5769773339), and the head stops moving for this class as
d815f2970said it would. Its first half is true — honouring a host prefix trusts whoever can write inside it, andinside_a_pinned_mount()is a LOCATION predicate, never a trust one. Its second half is what round 4 closed: no accepted prefix can redirect a lookup into a pinned leg. What remains is environment trust, which an actor who can setPYTHONPYCACHEPREFIXdefeats throughPYTHONPATHorPYTHONSTARTUPin the same breath — this lane's own threat model, on the record atr4049745762. Remedy registered with both options and a recommendation.The naming nit is answered rather than taken:
every_importers_bytecodeis the quantifier the test is about — EVERY importer's bytecode, not all of some bytecode — andall_importers_bytecodemoves the quantifier onto the wrong noun.Summary by Sourcery
Keep compiled bytecode out of pinned legs before imports and make equivalence refusals accurately describe indeterminate archive reads.
Bug Fixes:
Enhancements:
Documentation:
Tests:
🤖 Generated with Claude Code