Skip to content

context-mode alignment: credential twins, order-keeping settings merge and practice docs (fix plan steps 7-8) - #374

Merged
seathatflowsinourveins merged 1 commit into
mainfrom
claude/context-mode-alignment-20260926
Sep 27, 2026
Merged

seathatflowsinourveins merged 1 commit into
mainfrom
claude/context-mode-alignment-20260926

Conversation

@seathatflowsinourveins

Copy link
Copy Markdown
Collaborator

Scope

  • What this PR changes, in one or two sentences: the repository half of the 2026-09-26 context-mode fix plan (steps 7 and 8). Claude settings gain Read(**/…) twins of the credential deny rules, which Context Mode 1.0.169's server-side path check needs; the settings applier now keeps rule order when it merges; and the handbook, recipe, bootstrap, token-practice and example-workflow docs describe the aligned practice and the upstream-intended behaviour at the reviewed revision, with pinned-source citations.
  • Base commit: 8de669dae57425bd5d1597ac25f6f661e592e4a6 (rebased onto it; written against 015c4702 and rebased twice, at 59dfe49f and 4a32e646)
  • Lane: lane:shared (manifests/evidence.json and adoption/* change). Lane consolidation: on 2026-09-26 the user shut down the other lane sessions and assigned this work to the workstation coordinator ("no other peers live, i shut them with the token save repos install into our native workflow and github workflow , harness update and sota foundation of our session as main task"); this quote stands in for the trading lane's ack.
  • Owned paths touched: .claude/settings.json, adoption/templates/claude.settings.template.json, tools/adoption/apply_claude_settings.py, adoption/bootstrap.md, adoption/README.md, adoption/platforms/macos-arm64.md, docs/secret-storage.md, docs/token-session-handbook.md, docs/token-practice.md, docs/token-efficiency-stack.md, docs/token-efficiency-stack.json, recipes/README.md, examples/claude-native/workflows/README.md, tools/token-report/token_manifest.py, tests, manifests/evidence.json (re-registration). This touches adoption/templates and new-host pages: hold the merge during a release window.

Step 7, credential twins. Context Mode 1.0.169 compiles a Read glob literally, without expanding ~/ or //, and tests it against a path's raw, resolved and canonical absolute forms (src/security.ts:101-135, 616-655), while Claude Code bounds **/ to the current directory. Each form is inert in the other engine, so each of the nine ~//// store rules and the two .env rules gets a **/ twin right after it; the .env twins sit before Read(!.env.example) and Read(!.env.*.example), because a ! carve-out reaches only the rules listed before it. apply_claude_settings.py used to append a missing template entry at the end, which would put the twins after a host's carve-outs and deny .env.example again; it now inserts it after its nearest template neighbour already present (else before the next one, else at the end). docs/secret-storage.md carries the twins in its hand-merge block, the reason, and the ctx_execute/ctx_batch_execute code-read residual (MCP servers run outside the built-in sandbox).

Step 8, practice docs. Patch A2 regenerated at this base, then reworded source-anchored: the handbook subsection "Context Mode executor and session store" (linked from the tool table) gives coordinators, children and Codex workers the working rules: writes persist; which directory code runs in; files outside the server root (no Read(...) allow rules; ctx_index then ctx_search, native Read, or one ctx_execute); the batch NODE_OPTIONS prefix; MCP calls on Claude Code (the bare mcp__ matcher is compared as an exact string; no local capture hook); Codex workers (user-scope start.mjs server, -C per worker, deny parity through CLAUDE_PROJECT_DIR, never context-mode upgrade); session memory, retention, compaction and settings; and the label for ctx_stats figures. Every quoted ctx_stats figure carries that label (row 24b). docs/token-practice.md separates the persisted tokens_saved/tokens_saved_lifetime from the rendered bytes_avoided, and the token report's boundary text says the same. The bootstrap step 4a and handbook registry checks accept a default-branch context-mode install only when gh api repos/mksglu/context-mode/compare/<reviewed>...<installed> reports ahead with stats.json as the only changed file. The recipe's project-scoped Codex form adds default_tools_approval_mode = "approve" and CLAUDE_PROJECT_DIR, as upstream start.mjs sets, and names the user-scope form as the default (D3 remainder). The example workflows README replaces "Context Mode has no child hook" with a dated note (D1). D4 goes in the handbook only; docs/ultracode-token-routing-20260921.md is a dated receipt guide and is unchanged.

D2, u3 bridge. Nothing to withdraw: no remote branch or PR carries it, the local branch claude/context-mode-ultracode-children-20260926 points at ca8e37f1, an ancestor of main with no commits of its own, and the bridge exists only as uncommitted files in a scratch worktree (removing that worktree is its owner's call). The only context-mode-bridge paths on main are the unrelated wave-2 MCPorter receipt.

Nothing was filed, commented on or opened upstream. Upstream issue numbers in the docs are read-only references. No host configuration was edited; the host steps (plugin reinstall, Codex binding, user-settings twins, pinned-checkout restore) are applied later by the coordinator.

SOTA sources

Evidence-class table

Claim Evidence class Command / receipt
With this PR's deny list, context-mode's own matcher (hooks/security.bundle.mjs, byte-identical to the pin) denies every store-shaped fake path, .env and .env.local, and passes in.txt; with origin/main's list it passes all of them local_integration (unchanged upstream code on fake paths), no committed receipt yet node check.mjs over both lists (scratch cm-align-live/twin-check/check.out)
Claude Code 2.1.283 with the committed 36-rule deny list as a --settings overlay reads .env.example and denies .env.local Native observation, no committed receipt (below native_proven) claude -p Sonnet 5 headless, 2 Read calls (scratch cm-align-live/live-order/live-order.out)
origin/main's applier puts the twins after the carve-outs; this applier puts them before, and keeps a host-only rule local_integration apply_claude_settings.py --dry-run on a scratch host file with both appliers (scratch applier_cli_check.out); tests/test_apply_claude_settings.py
The recipe's project form as changed binds the configured project from a session started elsewhere, reads its own file, enforces the project Bash(echo DENYPROBE*) deny and is not refused for approval; without approve every call is refused ("requires approval, but approval policy is never"); without CLAUDE_PROJECT_DIR the deny probe runs Native observation, no committed receipt (below native_proven) 3 concurrent codex exec --ephemeral -s workspace-write -C <other dir> (codex-cli 0.157.1) with -c overrides, bare CLI from a copy of the pinned npm install, adversary CODEX_HOME (scratch cm-align-live/runs/SUMMARY.txt); host config, hooks, cache and npm files unchanged
The documented registry checks print ok for the reviewed revision and for a stats.json-only ahead head, and MISMATCH for any other compare result, a failed compare, a tag-installed plugin, or no install local_integration RevisionCheckByContentTests runs the documented Python with a gh stand-in and a scratch registry
Docs claims about upstream behaviour source_review Pinned file:line citations above; no upstream test suite was run, so there is no upstream-acceptance evidence

Provider usage of the live checks, per counter and not summed across counters: Codex RF input 70,347, cached 64,128, output 500, reasoning 90; RFNA 70,168 / 64,000 / 390 / 35; RFNC 35,062 / 29,312 / 430 / 132. Claude -p run: input 6, cache creation 30,388, cache read 59,987, output 318.

Local commands run

All with the CI dependency venv (ci-venv/bin/python3, Python 3.13.15), in the branch worktree:

$ python3 scripts/validate.py
rc=0  {"components": 69, "hashed_files": 7113, "profiles": 4, "receipts": 159, "status": "passed"}
$ python3 scripts/evidence_manifest.py --check
rc=0  {"files": 7113, "status": "passed"}
$ python3 scripts/component_matrix.py --check
rc=0  {"rows": 32, "status": "checked"}
$ python3 scripts/new_host_grand_list.py --check
rc=0  {"status": "passed", "layers": 32, "winners": 66}
$ python3 scripts/build_ecosystem.py --check
rc=0  {"status": "passed", ...}
$ python3 scripts/validate_catalogs.py
rc=0
$ python3 scripts/host_receipts.py validate
rc=0  {"receipts": 167, "status": "passed"}
$ python3 scripts/release_due.py --strict-if-repinned origin/main
rc=0  report only (the pin is unchanged): 44 new-machine files differ from v2026.09.26.2
$ git diff --check origin/main HEAD
rc=0
$ python3 -m unittest tests.test_adoption_docs_consistency tests.test_install_claude_profile tests.test_context_mode_practice_docs tests.test_render_config tests.test_secret_path_guard tests.test_apply_claude_settings tests.test_ecosystem_manifest tests.test_adoption_status tests.test_catalog_freshness_propose
rc=0  Ran 353 tests, OK (skipped=1: the profile-cell release-note check, "no profile's coverage differs")   (on the final head)
$ (cd tools/token-report && python3 -m unittest test_token_manifest)
rc=0  Ran 56 tests, OK
$ (cd examples/claude-native/workflows && sha256sum --check --strict SHA256SUMS && node test-envelope.mjs && node test-contract-mutations.mjs)
rc=0
$ python3 -m unittest            # full suite, summary read from stderr
run 1 (base 59dfe49f): Ran 6357 tests, FAILED (failures=1): the publication validator saw a stale README hash
                       because I edited examples/claude-native/workflows/README.md while the suite ran;
                       re-registered, and that module passed on rerun
run 2 (base 4a32e646, after the review fixes): rc=0  Ran 6364 tests in 671.309s, OK (skipped=644)

Fail-first: before the implementation, the new checks failed on the tree without it (12 failures across the step-7 tests, 13 in the docs module, the recipe and boundary tests, and the stats-only case of the revision check); two regression guards (template rule order, user-scope approve) already held. After the final rebase onto 8de669da (upstream changed tests/test_adoption_docs_consistency.py, tests/test_install_claude_profile.py and manifests/evidence.json), manifests/evidence.json was re-registered on the new base and the checks above re-ran; the full suite ran on the previous base and runs again in CI.

Decision record

This PR carries no repository decision record. The plan's step 10 adds the addendum to docs/decisions/2026-09-25-codex-mcp-scope.md and the receipt evidence/artifacts/context-mode-audit-20260926/, which will also carry the live outputs above. Until then the decisions live in the scratch plan: cm-deep/PLAN.md (2026-09-26) decides H2's replacement by the twins, H1's withdrawal, the npm start.mjs Codex form and the D1-D4 targets, with its evidence index and residuals. Overturn conditions stay as recorded there, for example: a re-pin to a release whose src/security.ts expands ~/ and // lets the store twins go (the .env twins stay); a cache-installed context-mode PostToolUse hook that fires for an MCP tool on Claude Code 2.1.283 would change the MCP-capture note.

Cross-family review (GPT-6)

One read-only codex exec -m gpt-6-astra -c model_reasoning_effort=max --sandbox read-only review of the frozen pre-fix diff (197,350 tokens; scope file and report kept in scratch as codex-rev/scope-cm-align.txt and codex-rev/review-cm-align.md). Verdict: DEFECTS FOUND, 2 medium and 2 low. All four held against the pinned source and were fixed in one repair round; there was no second review.

Severity Finding Fix
medium The handbook said every ctx_execute language runs in the project root or cwd; Rust compiles and runs in the temporary directory (src/executor.ts:290-292, 406) The bullet names the Rust exception and asks for absolute project paths in Rust code
medium docs/secret-storage.md said no deny rule inspects ctx code; the server checks shell code and recognised embedded shell commands against Bash(...) denies (src/server.ts:1137-1150, 1744-1750, 3779-3782) The residual now names what is unmediated: a file that the code opens itself
low The D1 note said each tip shows once per session; the large-Read tip repeats for every Read over 50,000 bytes (hooks/core/routing.mjs:848-866) The note distinguishes the once-per-session tips from the large-Read tip
low CONTEXT_MODE_SESSION_SUFFIX renames the database, the events file and the cleanup flag, not only the database (hooks/session-helpers.mjs:78-92, 391-427) The handbook names all three

Residuals from the review: none open.

Residuals

  • The live checks are scratch outputs until the step-10 receipt PR carries them; this PR claims no native_proven status.
  • In Context Mode the **/.env.* twin also denies .env.example (no ! carve-outs in 1.0.169); native Read still serves it. Documented in docs/secret-storage.md.
  • ctx_execute/ctx_batch_execute code reads stay an accepted residual until OS-level containment of the whole session is measured (plan step 11).
  • Codex interactive, app-server and spawn_agent sessions under the npm start.mjs form are not exercised; the npm bundle bytes differ from the pin's and are unreviewed (plan residuals R1, R2).

Host evidence

Not applicable: no file under evidence/hosts/ changes.

Checklist

  • No GitHub Actions or workflows changed.
  • No secrets are printed, logged or committed; the live checks used fake store paths and fixture files.
  • No new paid hosting, subscription or billing surface was introduced.
  • Peer-owned untracked files and worktrees were preserved (the scratch wt-u3 worktree is untouched).

🤖 Generated with Claude Code

@seathatflowsinourveins seathatflowsinourveins added the lane:shared Touches files owned by both lanes; needs both lanes' acknowledgement label Sep 26, 2026
@seathatflowsinourveins

Copy link
Copy Markdown
Collaborator Author

Unit prc verification pass (no new build/review stage)

On pickup, this PR's body, review section and receipts were already complete and
the branch already matched origin at f6f01601 — the unit's starting brief
("builder paused mid-body") did not match that state, so no new GPT-6 builder or
reviewer stage was run. Independently re-verified instead, without relying on the
existing self-report:

  • The four fixes from the recorded review (codex-rev/review-cm-align.md, 2
    medium / 2 low, one repair round, no second review) are present in the current
    file content: the Rust tmpDir exception (docs/token-session-handbook.md:159),
    the three CONTEXT_MODE_SESSION_SUFFIX targets (:168), the narrowed
    secret-storage.md residual (:658-669), and the once-per-session-vs-large-Read
    distinction (examples/claude-native/workflows/README.md:240).
  • bash rec/validate.sh <ci-venv python> → FAILS=0.
  • python -m unittest tests.test_adoption_docs_consistency tests.test_install_claude_profile tests.test_context_mode_practice_docs tests.test_render_config tests.test_secret_path_guard tests.test_apply_claude_settings tests.test_ecosystem_manifest tests.test_adoption_status tests.test_catalog_freshness_propose → Ran 353 tests, OK (skipped=1).
  • (cd tools/token-report && python -m unittest test_token_manifest) → Ran 56 tests, OK.
  • gh pr view 374: mergeable=MERGEABLE, mergeStateStatus=CLEAN, all CI checks
    SUCCESS/SKIPPED at head f6f01601 (unchanged by this pass).

Running a second GPT-6 review was withheld: no code changed since the recorded
review, and the repo's bounded-review-loop practice is one review plus one repair
round, already closed here. Reopening it is a call for whoever changes this diff
next, not for a no-op verification pass.

One deviation from the unit brief, recorded rather than applied: the brief said
"exactly one label, lane:foundation"; this PR keeps lane:shared, which
docs/lanes.md:29-30,145 requires because it touches manifests/evidence.json
and adoption/*. Changing the label would contradict the repository's own lane
policy, so it was left as-is.

No commit, rebase or push was made: nothing in the tree changed.

🤖 Generated with Claude Code

@seathatflowsinourveins
seathatflowsinourveins force-pushed the claude/context-mode-alignment-20260926 branch from f6f0160 to 8d3e3b5 Compare September 27, 2026 03:18
@seathatflowsinourveins

Copy link
Copy Markdown
Collaborator Author

Trading-lane ack (lane:shared), 2026-09-27, at 8d3e3b5.

  • .claude/settings.json and the Claude settings template only ADD deny rules. There are 11 Read(**/…) twins of the existing ~/, // and .env credential rules, because Context Mode's server-side path check does not expand ~/ or //. One twin covers the per-user native-agent-stack config directory, where the 0600 paper-broker stores live. That matches the paper-lane boundary: workers pass pointer variables, the broker SDK reads the store in-process, and no Claude tool reads it. No rule is removed or loosened.
  • docs/secret-storage.md records one more accepted residual: code run inside Context Mode's ctx_execute can open files itself. It changes no credential location or procedure.
  • No catalogs/us-equities, blueprints/us-equities, observability/paper-trading-live or trading-test path is touched.
  • Replayed onto main 881164e with a 3-way squash, keeping Telemetry writer identity (G1): one writer per token series, integrity alerts and a committed host recipe #364's writer-identity note beside this PR's settings sentence. validate.py FAILS=0. 519 related tests OK.

Merge on green CI, after #376. It will need one more manifest replay then.

🤖 Generated with Claude Code

…e and practice docs (fix plan steps 7-8)

Replayed onto main 881164e (after #364 and #375) with a 3-way squash. Main had
changed three of this PR's files:
- The settings template and the macOS page merged cleanly; the template keeps
  #364's OTEL_METRICS_INCLUDE_SESSION_ID and this PR's 11 Read(**/...) twins.
- adoption/bootstrap.md conflicted on one note: it keeps this PR's extended
  settings-template sentence, followed by #364's writer-identity paragraph.
manifests/evidence.json was re-registered, and the matrix and grand list were
regenerated.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@seathatflowsinourveins
seathatflowsinourveins force-pushed the claude/context-mode-alignment-20260926 branch from 8d3e3b5 to a4a0942 Compare September 27, 2026 03:41
@seathatflowsinourveins

Copy link
Copy Markdown
Collaborator Author

Trading-lane ack confirmed. This PR doesn't touch the trading lane, and it strengthens the paper-broker credential boundary.

Scope: a read-only look at head a4a09422 from the trading-lane side (session token-save-status-macos-launch). This is not a full code review.

  • Trading paths: none touched. Nothing changes under blueprints/us-equities/ or catalogs/us-equities/.
  • Deny twins in .claude/settings.json and the template: each existing home-anchored rule gains a **/ twin. The twin for the native-agent-stack config directory covers the per-provider paper-broker store directory described in docs/secret-storage.md, even when it is reached by a non-tilde path.
  • The dotenv twins block no repository file. git ls-tree -r origin/main shows no tracked dotenv-style file anywhere, including trading paths. The example-file exceptions still apply only at the root, and no nested example file exists that they would need to cover.
  • Scope of the rules: they govern Claude's tools only. The paper runner still reads its private env file itself through its env-file pointer, as blueprints/us-equities/adaptive-paper/README.md describes, so paper operation is unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lane:shared Touches files owned by both lanes; needs both lanes' acknowledgement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant