Repository navigation
Conversation
…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]>
…hen 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]>
…view 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]>
…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]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
lib-memory-dir.sh's no-jq Python-fallback config merge loaded every TRUSTED config source (bundled config, user-global config, or project config when it is not the untrusted-haiku source) with no error handling. A malformed file there raised an uncaught JSONDecodeError, the subprocess exited nonzero-but-not-3, and the shell's bundled-only fallback fired with zero disclosure, since #804's disclosure gate only checks the drop-marker file or rc == 3, both reserved for the sibling untrusted-project-layer case.
This closes the exact gap #804's own self-review flagged as a trap.d fragment and #815 was filed from.
Design decision
Gave the malformed-trusted-layer case the same disclosure treatment #804 already gives the untrusted layer, rather than declaring it out of scope (the issue's own "What would settle it" section left this open). Reasoning: more consistent with the shipped sibling case, favoured by the issue's own framing, and cheaper than writing an explicit out-of-scope boundary comment. Flagging this as a real judgment call in case the maintainer would have preferred "operator error, out of scope" instead.
What changed
_dropped_trusted_layerflag +continueon failure instead of the layer taking down the whole merge subprocess.TestMalformedTrustedConfigDisclosureclass, paired positive/negative test with a genuine red/green discriminator (verified against the true pre-lib-memory-dir.sh: malformed TRUSTED config JSON silently falls back to bundled config, no disclosure #815 baseline)._SANCTIONED_DIVERGENCEentry for the byte-pin guard, matching the existing lib-memory-dir.sh and lib-env-cache.sh carry the same predictable-tmp truncation class #427 fixed, and one of them writes a config that can hold an OAuth token #429/security(scan-20260918): repo-local .remember/config.json selects summarizer credential and key-stripping policy #726/lib-memory-dir.sh's no-jq Python-fallback drop marker can itself fail silently if mktemp fails #804 convention.Self-review
Two rounds, each with Explore and oss:auditor spawned in parallel. Round 1 (over the initial fix): both reviewers independently found the new WARNING text named only two of the three trusted sources, and Explore additionally found the positive test's main assertion didn't actually discriminate fixed-vs-broken behaviour -- both fixed, and the test fix was mechanically verified against the true pre-#815 baseline (red, then green). Round 2 (triggered by a >=3-file second-pass check): both reviewers independently found a class-level docstring left stale by round 1's own fix -- fixed. Tree snapshot clean throughout.
Tests
Targeted run only (never the full
pytestsuite, per repo convention):-> 67 passed.
Cross-platform
Reasoned, not observed: both touched test files carry a pre-existing, unchanged
skipif(sys.platform == 'win32', ...)(#79) covering the new material by position, and the diff reuses the existing(OSError, ValueError)exception shape with no new path/encoding/subprocess construct. Not run on Windows or macOS/Linux CI directly.Closes #815.
🤖 Generated with Claude Code
[AI-generated]