Repository navigation
Conversation
…xternal-storage migration In external-storage mode, the one-shot migration in bootstrap-dirs.sh moved a project's whole legacy .remember/, config.json included, into the new external REMEMBER_DIR -- where lib-memory-dir.sh trusts it unconditionally from then on. A repository that committed .remember/config.json before a clone ever switched to external storage could pick the summarizer's OAuth credential/model, force ANTHROPIC_API_KEY to be stripped, or turn the refusal gate off (reject_pattern: "none") or into a ReDoS surface. A config.json that is git-tracked in the legacy dir is now left behind during migration -- still tracked, doing nothing for the new external store -- logged in both MIGRATED-TO.txt and hook-errors.log rather than silently. An untracked legacy config (the user's own) still migrates and is still trusted, as before. Also extends the #726/#740 untrusted-project-layer strip (jq del(...) and its Python fallback) to cover `model` and `reject_pattern`, not just `haiku`, in the ordinary (non-migrated) legacy layout. Two existing config-key tests picked `.model` as their incidental "some real key reads through" example; updated to `.timezone`, which the #757 strip does not touch. Closes #757 Co-Authored-By: Claude Sonnet 5 <[email protected]>
… git-tracked; fix migration's tracked check for subdirectories and git failures Review of 43827e7 found two problems, both fixed here: 1. model/reject_pattern were stripped from EVERY legacy-layout per-project config.json, tracked or not -- #726's "untrusted by LAYOUT alone" rule is right for haiku (a credential), but broke every single-user project's own untracked model/reject_pattern override, since #726 already distrusts every legacy per-project config regardless of authorship. Neither key can redirect where transcripts go, only which model is billed or whether the refusal gate runs at all -- severe enough to strip from a file the REPOSITORY committed, not severe enough to break an ordinary untracked override. Now gated on _remember_config_tracked_status(): stripped only when the project config.json is git-tracked (or its tracked status could not be determined -- fail CLOSED); an untracked in-project config keeps both, same as before #757. haiku's own unconditional-in-legacy-layout strip is unchanged. Kept to one jq call and one Python argv shape either way -- only the filter/drop-set varies. 2. The migration's tracked check, `[ -e "$_mem_proj/.git" ]` + a same-shape ls-files call, missed a project started from a repo SUBDIRECTORY (#754: no .git in the project dir itself, even though the enclosing repo can have committed the file two levels up) and read ANY git failure as "untracked", letting the file migrate as trusted by default on a broken git (#760). Both call sites now share one helper, _remember_config_tracked_status() in lib-memory-dir.sh: `git rev-parse --is-inside-work-tree` walks up to any enclosing work tree (fixes #754), and distinguishes three states -- tracked / untracked / could-not-tell -- rather than two. could-not-tell fails CLOSED in both callers: the migration leaves the file behind, the strip treats it as tracked. The common "no git at all" case still costs exactly one spawn (rev-parse's own exit status, matched against its own untranslated fatal text via LC_ALL=C/LANGUAGE=C rather than trusting the ambient locale); a second spawn (ls-files) is paid only inside a real work tree. Spawn budget measured, not assumed: the post-tool-hook spawn count goes 18 -> 19 (one rev-parse, gated on the same "project config exists in the untrusted layout" condition the existing haiku sanitize spawn already pays for) -- documented and pinned in tests/test_post_tool_hook_spawns.py rather than absorbed silently into its existing +2 slack. Case-insensitive-filesystem fallback (a differently-cased Config.json escaping the tracked check) intentionally not added -- it would cost a second git spawn on every check and was left for a follow-up rather than paid on this path; noted in docs/external-storage-mode.md. tests/test_config_key_injection_539.py and tests/test_jq_free_config.py are reverted back to their original `.model`/"sonnet" fixtures (an untracked per-project config, so model still takes effect under the tracked-only rule) -- the #757-vs-review-round-1 key swap to `.timezone` papered over the very regression this round fixes rather than fixing it. 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.
Closes #757.
Problem
bootstrap-dirs.sh,mv "$_legacy_dir" "$REMEMBER_DIR") carried a repository-committed.remember/config.jsoninto the external store, where it is trusted. The repository'shaiku.oauth_tokenthen became the summarizer's credential, and underautoit stripped the operator'sANTHROPIC_API_KEY. The External storage: first-session migration makes a repo-tracked .remember/config.json haiku block trusted #757 comment has the code analysis: no config key can change the destination or execute anything, but it can choose the account.haiku. A repo-committed legacy config could still setmodelandreject_pattern(noneturns the refusal gate off).Fix
_remember_config_tracked_status(dir, name)inscripts/lib-memory-dir.shreturnstracked,untrackedorcould-not-tell:git rev-parse --is-inside-work-treewalks up to any enclosing work tree, which covers subdirectory launches (the #721 tracked-handoff guard is bypassed when Claude starts from a repo subdirectory #754 shape).LC_ALL=C) counts asuntracked. Any other git failure iscould-not-tell, which fails closed (the _remember_handoff_is_tracked folds a git command failure into the permissive (untracked) branch #760 shape).ls-files --error-unmatchdecides.trackedorcould-not-tellconfig.jsonis left behind, still tracked, and never moved into the trusted store. This is logged inMIGRATED-TO.txtand on stderr. An untracked config migrates as before.modelandreject_patternare stripped only when the project config is git-tracked orcould-not-tell. A user's own untracked in-project config keeps them. Thehaikustrip is unchanged. Still one jq call, and the Python fallback matches.tests/test_case_divergence_298.py: folded into the existing release-audit: multi-document project config lets a repo-shipped .remember/config.json leak haiku.oauth_token/api_key into the nested summarizer (discloses, BLOCKING) #740 pair, not stacked (the main is red at 7ba7609 (#732): stale _SANCTIONED_DIVERGENCE entry in test_case_divergence_298.py for lib-memory-dir.sh's elif/python branch #734/test: drop the #726 sanctioned-divergence pair #744 stranded on main #746 lesson).git rev-parse, only when a legacy project config exists, alongside the existing sanitize spawn. It is documented rather than absorbed into slack.Tests (red first)
tests/test_migration_trust_757.py:haikutoken never reaches the merged configtests/test_untrusted_project_haiku_config_726.py: tracked project config hasmodelandreject_patternstripped. Paired controls: the same keys untracked are honoured, and so are the keys with no repo at all. The broken-git shim strips.test_config_key_injection_539.pyandtest_jq_free_config.pyare back to their original.modelfixtures (untracked config), and still pass.Full suite on macOS: 2631 passed, 59 skipped. Both changelog checks pass. shellcheck is clean.
Known limits
.remember/Config.json: it would cost another spawn. Documented indocs/external-storage-mode.md.gitbinary inside a legacy project reads ascould-not-tell, so its projectmodel/reject_patternare stripped. This fails closed and is rare for Claude Code users.Platform
Observed: macOS. Reasoned: Linux and Windows Git Bash (same
git -Cconventions as the rest of the repo).🤖 Generated with Claude Code
[AI-generated]