Skip to content

fix(#804): give the no-jq drop-marker a second signal independent of mktemp - #812

Merged
fdaviddpt merged 2 commits into
mainfrom
fix-804
Sep 26, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix-804

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

What

scripts/lib-memory-dir.sh's no-jq Python-fallback config merge signalled a dropped untrusted project-config layer via a marker file alone. If the marker file's own mktemp call also failed (full/read-only $TMPDIR), the drop happened with nothing logged -- a compound gap #748 left open and #804 asked for a maintainer call on.

Fix

  • The Python subprocess now sets _dropped_project_layer = True in the same except (OSError, ValueError) branch that already attempts the marker-file write, and calls sys.exit(3) after the merged config is written if that flag is set. Exit 3 is distinct from 0 (clean) and any other nonzero (a genuine merge failure).
  • The shell captures the subprocess exit code via _py_merge_rc=0; ... <<'PYMERGE' || _py_merge_rc=$? so it survives a set -e caller (this file is sourced by callers that set -e).
  • The bundled-config fallback (cp "$_bundled_cfg" "$_merged_cfg") now only fires when rc is neither 0 nor 3 (previously: any nonzero).
  • The WARNING disclosure now fires when EITHER the marker file exists OR rc == 3, so the marker's own mktemp failing no longer silences the disclosure.
  • Folded the two pinned old/new code-shape pairs in tests/test_case_divergence_298.py for this site, per this repo's own case-divergence pin-fold-don't-stack convention, rather than stacking new pairs.

Tests

Added to tests/test_untrusted_project_haiku_config_726.py: a PATH-shim helper that forces mktemp to fail only for the drop-marker template (delegating to the real mktemp for every other template) plus:

Confirmed red before the fix (temporarily restoring the pre-#804 file): AssertionError: assert 'lib-memory-dir' in '', positive control unaffected. Green after: 2 passed. Full related suites (test_untrusted_project_haiku_config_726.py, test_case_divergence_298.py, test_jq_free_config.py, test_layered_config.py) all green: 83 passed.

Did not run the full repo pytest suite -- this repo's own convention is that CI across three OSes and four interpreters is the actual merge gate, not a local full run.

Self-review

Two reviewers (Explore, oss:auditor), before/after tree snapshot taken and compared (post-review diff was entirely this lane's own subsequent commit, not a reviewer mutation). Both findings addressed:

  1. (Explore, fixed) A stale release-audit: sanitize failure on the project config layer drops settings silently, with nothing logged (misreports, non-blocking) #748 comment directly above the marker's mktemp call claimed a real subprocess exit code and the marker file 'cannot be told apart from success' -- falsified by this very fix. Corrected in this PR.
  2. (oss:auditor, logged, below-bar) Pre-existing, non-blocking: the trusted-config json.load() path can still raise uncaught and fall back to the bundled config with no disclosure -- the same silent shape this fix only partially closes (it covers the untrusted-haiku path only). Logged as trap.d/804.trusted-config-json-load-uncaught-misreports.md for a future maintainer call, not fixed here.

Also logged (not blocking): trap.d/804.edit-op-defaulted-to-main-clone-not-worktree.md, a worktree-discipline near-miss caught and fully recovered before any commit.

Closes #804

🤖 Generated with Claude Code

[AI-generated]

fdaviddpt and others added 2 commits September 26, 2026 23:58
…mktemp

lib-memory-dir.sh's no-jq Python-fallback merge signalled an untrusted
project config drop only via a marker file, whose own mktemp call could
itself fail (a full or read-only $TMPDIR), leaving the drop unreported
whenever both that mktemp and the project config load failed in the same
run -- the compound case #748 left open. The merge subprocess's own exit
code (3, distinct from 0 and from a genuine merge failure) now carries the
same disclosure independently of the marker file succeeding at all.

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

Self-review (Explore) found the #748 comment directly above the marker's
mktemp call still claimed "a real subprocess exit ... cannot be told apart
from success", which #804 itself falsifies a few lines below -- updated to
describe both signals. Self-review (oss:auditor) found the trusted-config
json.load() path can still raise uncaught and fall back to the bundled
config with no disclosure; pre-existing, non-blocking, logged to trap.d/
per its own "ship behind a trap.d fragment" verdict.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@fdaviddpt
fdaviddpt merged commit 590fb03 into main Sep 26, 2026
16 checks passed
@fdaviddpt
fdaviddpt deleted the fix-804 branch September 26, 2026 22:58
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.

lib-memory-dir.sh's no-jq Python-fallback drop marker can itself fail silently if mktemp fails

1 participant