Repository navigation
Description
Lane: openreposhape-2 (openRepoShape-2)
What is wrong. tests/test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies
(lines 697-703) passes or fails depending on what happens to be checked out
beside the repository on the machine running the suite — it is not
deterministic.
def test_cli_reports_an_unread_link_as_a_warning_and_still_classifies():
"""Offline is the ordinary case, so it is a WARNING and exit 0."""
result = run_script(VALIDATOR, "--role", "assembly", "--pins", "openXdox",
"--referent-chain", "openXdox,openDox", "codexDox")
assert result.returncode == 0, result.stderr
assert "domain-descendant/assembly" in result.stdout
assert "WARNING codexDox: declared-unverified" in result.stderrIt calls run_script with no cwd=, so the subprocess inherits whatever
directory pytest itself was invoked from. scripts/validate-repository-naming.py
reads that inherited directory at here = Path.cwd() (line 333) and hands it
to every Target as root. link_pins_from_trees passes root straight
into resolve_link_source (scripts/repo_shape.py:1449), whose rule 3 —
"a checkout sitting BESIDE this project" — does
Path(root).resolve().parent / product (line 1466): it looks for a directory
named openXdox beside wherever pytest's cwd was.
On this workstation, ~/projects/openXdox and ~/projects/openDox are real
checkouts:
$ ls -d ~/projects/openXdox ~/projects/openDox
/home/brett/projects/openDox
/home/brett/projects/openXdox
So running the suite from any checkout or worktree under ~/projects
satisfies rule 3, the link resolves against that real tree, and the
declared-unverified warning the test expects never prints:
$ cd ~/projects/openRepoShape--naming-test-isolation && python3 -m pytest \
tests/test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies -q
F
AssertionError: assert 'WARNING codexDox: declared-unverified' in ''
+ where '' = CompletedProcess(...).stderr
1 failed in 0.50s
The identical test, run against the identical file, from a neutral directory
with no openXdox sibling (e.g. /tmp), passes:
$ cd /tmp/... && python3 -m pytest \
/home/brett/projects/openRepoShape--naming-test-isolation/tests/test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies -q
.
1 passed in 0.40s
scripts/repo_shape.py's rule 3 is deliberate — a digest-pinned shape file,
and "read a sibling checkout when one exists" is the ordinary workspace
layout validate-pins.py already relies on elsewhere. The bug is entirely
in the test's isolation: it asserts the OFFLINE branch (no link tree
reachable at all) while leaving the one input that decides which branch
runs — the process's cwd — unset, so the outcome silently depends on the
machine.
I audited every other CLI invocation in this file that supplies a
--referent-chain (grep -n "referent-chain" tests/test_naming_policy.py):
test_cli_classifies_a_chain_given_on_the_command_line and
test_cli_reports_a_broken_link_as_a_finding_naming_it both pass an explicit
--link-source <product>=<tmp_path>/..., which is rule 1 and is checked
before rule 3 is ever reached, so neither depends on cwd.
test_cli_reads_the_chain_out_of_a_project_manifest and
test_cli_finds_a_recorded_chain_that_does_not_hold go through --project <manifest>, where root is derived from the manifest's own path
(path.resolve().parent, always inside tmp_path) rather than from
Path.cwd(). This test is the only one that falls through to the
cwd-derived root with nothing isolating it.
What would fix it. Give this test (and only this test — it is the only
one exercising the unisolated fallback) a cwd with no openXdox sibling
on any machine, the same way sibling tests in this file already isolate
state with pytest's tmp_path fixture (see _tree() and its callers a few
lines above this test). Passing run_script(..., cwd=<a fresh directory under tmp_path>) makes rule 3's sibling lookup resolve against a directory
tmp_path itself controls, which is guaranteed empty and unique per test
run, so the test's outcome no longer depends on what is checked out on the
workstation. scripts/repo_shape.py's resolver is out of scope: its rule 3
is a deliberate, working feature and the fix belongs entirely in the test's
own isolation.
Activity
brettheap commentedon Sep 11, 2026
(lane openreposhape-2 (openRepoShape-2), 2026-09-11T20:13Z) CLAIMED — session 3b1ab8cf, on Brett Heap's word 'go, fan out on all of it'. Branch fix/naming-test-isolated-from-sibling-checkouts, worktree ~/projects/openRepoShape--naming-test-isolation on Eagle, from origin/main cd57c4b. Scope: isolate test_cli_reports_an_unread_link_as_a_warning_and_still_classifies from any sibling openXdox/openDox checkout on the host, plus the two named Sonar findings in tests/test_naming_policy.py (composite assertion at line 1188, assertion-order review at line 99).
brettheap commentedon Sep 11, 2026
(lane openreposhape-2 (openRepoShape-2), 2026-09-11T20:33Z) PULL REQUEST OPEN: #120 (head 0007cef).
tests/test_naming_policy.py: the unread-link-warning test also saniti…
tests/test_naming_policy.py: the unread-link-warning test also saniti…
brettheap commentedon Sep 11, 2026
(lane openreposhape-2 (openRepoShape-2), 2026-09-11T22:07:43Z) MERGED — #120 → 8f72237 (squash), on Brett Heap's word 'go, fan out on all of it, hold the doctor refactor'. tests/test_naming_policy.py: the unread-link-warning test runs from its own tmp_path (so a sibling ~/projects/openXdox checkout no longer satisfies resolve_link_source rule 3) and pins SHAPE_PIN_SOURCE_OPENXDOX to a path with no manifest (so rule 2, the environment override Copilot found, cannot verify the link either); the composite workspace-name assertion is split; first branch to make the whole suite green from a worktree under ~/projects; Copilot's one real finding taken, two clean rounds after; 1132 passed / 1 skipped. Object complete.