Skip to content

fix: give #429's sanctioned-divergence guard a third state so it survives its own merge - #441

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/440
Aug 29, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/440

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #440

main was red on every ubuntu leg and macos 3.11 the instant #429's own sanctioned-divergence allowance (PR #436) merged. test_the_per_tool_call_path_is_not_touched in tests/test_case_divergence_298.py compares scripts/lib-memory-dir.sh against origin/main and allows one keyed old-to-new substitution (_SANCTIONED_DIVERGENCE), guarded by an integrity check that the old code must still be findable on origin/main. That check was correct while #436 was open and unsatisfiable the moment it merged: origin/main then held the new code, the old code was gone, and the guard asserted on the default branch itself.

The guard recognized only two states (old code present: substitute; neither present: stale) and needed a third: old code absent and new code present is the post-merge steady state, not staleness. _apply_sanctioned_divergence() now checks for the new code before asserting, and passes the comparison through unchanged when it is already there. Only genuine staleness (neither found) still asserts.

Pinned with three tests that construct both shapes directly from _SANCTIONED_DIVERGENCE's own recorded strings, not from wherever origin/main happens to sit when they run: test_sanctioned_divergence_applies_pre_merge_shape, test_sanctioned_divergence_accepts_post_merge_shape, test_sanctioned_divergence_still_asserts_when_genuinely_stale.

Reproduction

git fetch -q origin
python3 -m pytest tests/test_case_divergence_298.py::test_the_per_tool_call_path_is_not_touched -q

Red before the fix, with the exact CI assertion. Green after.

A second commit on this branch, from self-review

The spawned auditor found that the three new unit tests, as first written inside tests/test_case_divergence_298.py, would themselves inherit that module's whole-file pytest.mark.skipif(sys.platform == "win32") -- a skip that exists for the file's bash-spawning tests and does not describe these three, which are pure Python string manipulation. Confirmed against a real windows-latest job log (the whole file collects as one skip block). Fixed by relocating the three tests to a new file, tests/test_sanctioned_divergence_state_440.py, which imports _SANCTIONED_DIVERGENCE and _apply_sanctioned_divergence from the guarded module. They now run on every platform.

A third finding, reported for filing rather than fixed here

Both the reviewer's own investigation and the auditor independently confirmed, from real CI job logs (PR #436 -- the PR that introduced the now-repaired allowance -- and PR #439, an unrelated currently-open PR), that test_the_per_tool_call_path_is_not_touched silently self-skips ("origin/main not available") on every pull_request-triggered CI run in this repository. actions/checkout's default behaviour on pull_request events never makes origin/main a resolvable ref (only the synthetic merge-ref commit is fetched), so this guard has only ever exercised its assertions after a squash-merge lands on main via a push event -- structurally too late to block a bad merge, and exactly how #429's allowance shipped unverified through its own PR review (PR #436 was itself 13/13 green while silently skipping the very check it claims to guard).

Not fixed in this diff: it needs a CI workflow fetch-depth/trigger design decision (a full fetch-depth: 0 costs matrix-wide clone time on every job; a narrower explicit git fetch origin main step is untested here and would need its own CI verification cycle before landing), it touches a different file (.github/workflows/tests.yml) with repo-wide blast radius, and it deserves its own review rather than a rider on this fix.

Tests

Full suite: 1804 passed, 43 skipped, both before and after the relocation commit (net test count unchanged -- three tests moved files). Changelog fragment validated with .oss/assemble_changelog.py --check.

Review

Spawned reviewer (Explore): NO FINDINGS, checked three-state edge cases, tautology risk on the new tests, refactor-preserves-behaviour, stale docstrings, other call sites.

Spawned auditor (oss:auditor): FINDINGS: 2 (both class B, "a guard that did not run", both ranked misreports) -- the Windows-skip-inheritance defect above (fixed) and the PR-skip defect above (report-for-filing, agreed with my classification).

…ives its own merge (#440)

The guard compared origin/main's lib-memory-dir.sh against a keyed
old->new allowance and asserted whenever old_code was not found. That
was correct while #436 was open and unsatisfiable the moment it
merged: origin/main then held new_code, old_code was gone, and the
guard failed on the default branch itself. _apply_sanctioned_divergence()
now recognizes old-absent/new-present as the post-merge steady state
rather than staleness, only asserting when neither side is found.

Co-Authored-By: Max <noreply>
…ile Windows skip (#440)

Self-review on #440 found that the three new _apply_sanctioned_divergence
regression tests, added inside tests/test_case_divergence_298.py, silently
inherited that module's whole-file `pytestmark` skip on win32 -- a skip
that exists for the file's bash-spawning tests and does not describe these
three, which are pure Python string manipulation. Relocated them to a new
file, tests/test_sanctioned_divergence_state_440.py, so they actually run
on windows-latest CI instead of reporting green while never executing.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit 61f5bce into main Aug 29, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/440 branch August 29, 2026 04:08
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.

main is RED: the #429 sanctioned-divergence allowance in test_case_divergence_298.py cannot survive its own merge

1 participant