Skip to content

test: drop the #726 sanctioned-divergence pair #744 stranded on main - #746

Merged
fdaviddpt merged 1 commit into
mainfrom
fix/746-stranded-726-tuple
Sep 25, 2026
Merged

fdaviddpt merged 1 commit into
mainfrom
fix/746-stranded-726-tuple

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Part of #740: repairs main after #744.

Problem

main at ba2a592 (the #744 merge) is red on 8 legs, all failing on one test: tests/test_case_divergence_298.py:135, "neither the old nor the new code of this sanctioned substitution is on origin/main".

The scripts/lib-memory-dir.sh pair for pre-#726 → #726 (strip_last_haiku) no longer matches either state. Once #744 landed on top of it, origin/main holds neither side. This is the same stranding #734 fixed for #662's pair. PR #744's own CI could not see it, because it compared against the old origin/main, which still held the #726 form.

Fix

Drop the stranded pair. The #726 → #740 pair right below it still pins the site, and its one-line-filter / spawn-count note is kept as a comment.

Tests

Red on a local checkout of ba2a592: test_case_divergence_298.py + test_sanctioned_divergence_state_440.py gave 1 failed, 25 passed. With this change: 26 passed. Test-only change, so no changelog fragment.

🤖 Generated with Claude Code

[AI-generated]

main at ba2a592 fails test_case_divergence_298 on 8 legs: the pre-#726 ->
#726 pair's old AND new code are both gone from origin/main once #744
landed on top of it -- the same "neither old nor new" state #734 fixed
for #662's pair. PR CI could not see it: it compared against the old
origin/main, where the #726 form was still present. Drop the pair;
the #726 -> #740 pair below it covers the site.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@fdaviddpt fdaviddpt added the no-changelog Change is invisible to users label Sep 25, 2026
@fdaviddpt
fdaviddpt merged commit 6559162 into main Sep 25, 2026
16 of 17 checks passed
@fdaviddpt
fdaviddpt deleted the fix/746-stranded-726-tuple branch September 25, 2026 08:31
fdaviddpt added a commit that referenced this pull request Sep 25, 2026
trap.d's queue (18 pre-existing plus 3 stray uncommitted, from the primary clone's
own working tree) plus two new fragments logged for this pass (#739, #746) --
21 total, all decided, none deferred.

New fragments added and curated in this same pass:
- 746: two PRs (#734 then #746) each stranded a sanctioned-divergence pair in
  test_case_divergence_298.py by stacking a new pair on a site an earlier PR had
  already pinned, going red on origin/main invisibly to either PR's own CI.
- 739: a targeted local pytest run missed a Python 3.9 str|None annotation and
  a new shell bracket-range pattern, both caught only by the full CI matrix.

Promoted (12 new rules, all firing-proven both directions via pre-path-hook.sh /
pre-tool-hook.sh, plus a known-good control):
- paths/00-manual: bash-locale-pin-byte-and-case-ops, dollar-paren-lt-file-is-a-
  special-case, hand-kept-completeness-list-goes-stale, kill-a-subshell-not-its-
  forked-child, per-session-value-shared-channel, security-check-three-states-
  not-two, simulating-tool-absence-on-macos, spawn-counter-splits-on-embedded-
  newlines, case-divergence-pin-fold-dont-stack
- tools/00-manual: supertool-cwd-verify-tree, raw-append-write-unguarded
  (interim, filed claude-supertool#2699), targeted-pytest-misses-py39-and-scanners

Merged into existing rules:
- 630, 695.outward-walk-assumes-lexical-scope -> folded into
  bash-locale-pin-byte-and-case-ops.md as supporting evidence
- 705.edit-toml-literal-double-escape -> appended to supertool-literal-
  backslashes.md

Declined, each recorded in the owning layer's 00-README.md:
- 695.emit-read-max-is-an-unvalidated-knob (still true, filed #758)
- 719.silent-exclude-mkdir-failure (still true, filed #759)
- 721.git-dir-symlink-bypasses-tracked-check (still true, filed #761,
  low-priority: attacker already needs a stronger primitive)
- 660.promo-installed-key-array-plugins-shape (still true, filed #762)
- 722.edit-tool-cannot-write-raw-unicode-literal (not a code claim; narrow,
  workaround already obvious)
- 725.recon-reads-dirty-sibling-clone-not-origin-main (not this repo's code;
  filed claude-oss#1745 against oss:recon itself)

721.git-command-failure-reads-as-untracked and 721.case-fold-helper-not-pinned-
to-c-locale were promoted rather than declined: both describe a generalizable
class (git-gated security checks folding failure into the permissive branch;
missing LC_ALL=C pinning) worth teaching beyond the one call site, so each
became -- or was folded into -- a promoted rule above, alongside filing the
underlying code issue.

Co-authored-by: Claude Sonnet 5 <[email protected]>
fdaviddpt added a commit that referenced this pull request Sep 26, 2026
…ugins before to_entries (#786)

* fix(#761,#762): fail closed on a symlinked .git; guard non-object .plugins before to_entries

#761: _remember_config_tracked_status resolved PROJECT_DIR/.git the
ordinary way, following whatever it pointed to. A pre-planted symlink
swapping it for a DIFFERENT repository's git directory (its own,
independent objects and index) would answer the whole tracked-check
against that unrelated repo instead of the real one. Now refuses to
trust the result (fails closed, same as every other ambiguous case in
this function) when the repository's own toplevel .git is a symlink --
a shape neither an ordinary checkout nor a linked git worktree ever
produces, so it is only ever a pre-planted swap.

#762: the up-front installed_plugins.json probe used to_entries on
.plugins, which (unlike the per-candidate query it replaced) does not
error on a non-object shape. A JSON array there was silently read as
"no installed keys" instead of "cannot tell", firing the plugin promo
in exactly the situation the #574 design meant to suppress it in. The
probe now checks .plugins' type before calling to_entries, falling
back to the same cannot-tell suppression as every other malformed-file
case.

Both regression tests fail red against the pre-fix code and pass green
after. tests/test_case_divergence_298.py's sanctioned-divergence pair
for lib-memory-dir.sh is folded forward to the #761 shape, per the
#734/#746 precedent already used there.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(#761): correct stale spawn-count comment; fix Windows symlink typing in test

Self-review findings on 88b6bde:

- scripts/lib-memory-dir.sh's `_remember_config_tracked_status` header
  comment still claimed "two spawns at most" and described only the
  `rev-parse --is-inside-work-tree` / `ls-files` pair -- stale after
  #761 added a third `rev-parse --show-toplevel` spawn on the
  already-in-a-work-tree path. Comment now names all three.

- tests/test_migration_trust_757.py's new symlinked-.git regression
  test created a directory-target symlink without
  `target_is_directory=True`, unlike every sibling directory-symlink
  call in this suite -- flagged as a Windows-portability nit by the
  audit pass. Matches the established pattern now.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* trap: log the divergence-fold-replaces-old-not-extends-new lesson (#761)

Co-Authored-By: Max <noreply>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
fdaviddpt added a commit that referenced this pull request Sep 27, 2026
…ide it

CI on PR #818 caught tests/test_sanctioned_divergence_state_440.py red on
windows-latest 3.10/3.11 -- a pure Python string-substitution bug, not a
platform flake, so it would have reproduced on every leg. My own commit
comments already cited case-divergence-pin-fold-dont-stack.md, but I only
quoted its convention rather than following it: I stacked a third tuple onto
tests/test_case_divergence_298.py's `_SANCTIONED_DIVERGENCE` list whose
old_code duplicated the existing #804 tuple's new_code, instead of folding
the transition into that tuple in place. `_apply_sanctioned_divergence` runs
substitutions in list order and stacking meant the #815 pair rewrote the
#804 pair's own output out from under it once both were live together,
exactly the "old AND new code both vanish" failure the fold-don't-stack doc
describes for #734/#746.

Replaced the separate #804 and #815 tuples with a single folded pair: old_code
is now the #804 steady state (what origin/main ships today, moved here
verbatim per the doc's own worked example), new_code is the full #815 form
including the round-2 self-review's widened warning text. No production code
changed -- scripts/lib-memory-dir.sh is untouched by this commit.

Verified genuinely red on the pre-fold (stacked) shape: temporarily restored
it via `git stash` and ran `pytest tests/test_sanctioned_divergence_state_440.py`,
which failed 3 of 4 with the "neither the old nor the new code ... is on
origin/main" / "new_code not found in result" assertions the reviewer's
report predicted. Restoring the fold: 4/4 pass, and the full targeted set
(this file + test_case_divergence_298.py + test_untrusted_project_haiku_config_726.py)
is 71 passed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
fdaviddpt added a commit that referenced this pull request Sep 27, 2026
… untrusted-layer disclosure (#818)

* fix(#815): disclose a malformed TRUSTED config layer the same way #804 discloses an untrusted one

`lib-memory-dir.sh`'s no-jq Python-fallback merge loaded every TRUSTED config
source (bundled config, user-global config, or the project config when it is
not the untrusted-haiku source) with no error handling. A malformed file
there raised uncaught, exiting the subprocess with a code that is neither 0
nor 3, so the shell's own bundled-only fallback fired silently -- #804's
disclosure gate only checks the drop-marker file or `rc == 3`, neither of
which this path ever touches. A caller saw the identical "fell back to
bundled config" behaviour whether nothing but bundled config ever existed, or
a trusted file the operator actually wrote was corrupt and silently
discarded.

This is the exact gap #804's own self-review logged to trap.d/ and #815 was
filed from. Wraps the trusted-source load in the same fail-CLOSED shape the
untrusted branch already uses (skip just that layer, keep merging the rest),
and adds two new exit codes -- 4 for a trusted-only drop, 5 for both a
trusted and the untrusted layer dropping in the same run -- so the shell can
print a second, distinct WARNING without a second marker file.

Adds a paired positive/negative test (malformed user-global config warns and
drops just that layer; a well-formed one does not warn), and folds a new
`_SANCTIONED_DIVERGENCE` entry for the byte-pin guard in
tests/test_case_divergence_298.py to match.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(#815): self-review -- widen the trusted-layer WARNING and strengthen its test

Both spawned reviewers (Explore and oss:auditor) independently flagged the same
gap: the new rc-4/5 WARNING said only "bundled or user-global config," but the
branch it fires for also covers project config in external-storage mode (when
it is not the untrusted-haiku source) -- an operator on that layout debugging a
malformed project config would be pointed at the wrong two files. Widened the
message to name all three trusted sources the branch actually reaches.

Explore separately found the positive test's merged-value assertion did not
discriminate fixed from pre-fix behaviour: the bundled-config fixture and the
`_bundled_cfg` fallback target were the same file, so a value that survived
under a full wholesale fallback looked identical to one that survived under a
per-layer drop. Added a third, well-formed project-config layer read AFTER the
malformed one in merge order -- confirmed against the true pre-#815 baseline
that this addition alone goes red (asserting `extra_layer` survives) and green
against the fix, which the prior assertion did not.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(#815): correct a class docstring left stale by the second self-review commit

Both second-pass reviewers (Explore and oss:auditor) independently found the
same gap: 8df6cae added a well-formed project-config layer to the first test
in TestMalformedTrustedConfigDisclosure as a fixed-vs-broken discriminator,
but never updated the class's own docstring, which still claimed neither
test holds a project config and both go through the trusted-load branch this
class is about. Traced (as both reviewers did independently): in this file's
default legacy layout, that project layer is the untrusted-haiku source and
is processed by the pre-existing #744 branch, not the #815 trusted-load
branch -- it is there purely as an order-dependent discriminator, which the
in-method docstring already explained correctly. Corrected the class
docstring to match.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(#815): fold the #815 divergence pair into #804's, don't stack beside it

CI on PR #818 caught tests/test_sanctioned_divergence_state_440.py red on
windows-latest 3.10/3.11 -- a pure Python string-substitution bug, not a
platform flake, so it would have reproduced on every leg. My own commit
comments already cited case-divergence-pin-fold-dont-stack.md, but I only
quoted its convention rather than following it: I stacked a third tuple onto
tests/test_case_divergence_298.py's `_SANCTIONED_DIVERGENCE` list whose
old_code duplicated the existing #804 tuple's new_code, instead of folding
the transition into that tuple in place. `_apply_sanctioned_divergence` runs
substitutions in list order and stacking meant the #815 pair rewrote the
#804 pair's own output out from under it once both were live together,
exactly the "old AND new code both vanish" failure the fold-don't-stack doc
describes for #734/#746.

Replaced the separate #804 and #815 tuples with a single folded pair: old_code
is now the #804 steady state (what origin/main ships today, moved here
verbatim per the doc's own worked example), new_code is the full #815 form
including the round-2 self-review's widened warning text. No production code
changed -- scripts/lib-memory-dir.sh is untouched by this commit.

Verified genuinely red on the pre-fold (stacked) shape: temporarily restored
it via `git stash` and ran `pytest tests/test_sanctioned_divergence_state_440.py`,
which failed 3 of 4 with the "neither the old nor the new code ... is on
origin/main" / "new_code not found in result" assertions the reviewer's
report predicted. Restoring the fold: 4/4 pass, and the full targeted set
(this file + test_case_divergence_298.py + test_untrusted_project_haiku_config_726.py)
is 71 passed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

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

Labels

no-changelog Change is invisible to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant