Skip to content

fix(ctx_read,ctx_search,ctx_edit,ctx_refactor): mode handling, honest counts, honest digests - #1601

Merged
yvgude merged 2 commits into
mainfrom
fix/read-mode-batch-3920
Aug 29, 2026
Merged

fix(ctx_read,ctx_search,ctx_edit,ctx_refactor): mode handling, honest counts, honest digests#1601
yvgude merged 2 commits into
mainfrom
fix/read-mode-batch-3920

Conversation

@yvgude

@yvgude yvgude commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Batch fix for eight issues filed from a 3.9.20 field report. Each fix ships with a regression test; the test names are quoted in the answer comment on each issue.

ctx_read — mode handling

Issue Defect Fix
#1584 mode=diff rejected on the MCP path but accepted on the CLI path The instruction-file rule rewrote every mode to full; it now preserves diff. The unknown-mode branch dumped the raw file instead of naming the valid modes — it now lists READ_MODES. Both paths resolve modes identically.
#1587 A compressed read that returned the whole file said nothing The fallback is now stated, and the no-compression banner prints only above its threshold.
#1588 bounce-prevention / intent-target overrides had no escape hatch — 3 of 10 modes unreachable Overrides are escapable and name the reason they fired.
#1589 mode=task emitted blank-line floods, score-ordered fragments, no line numbers IB filter + MMR selection output is ordered by position and keeps line numbers.
#1590 An auto-inferred session task silently steered mode=task intent = "inferred" no longer steers a read; only an explicit task does.

ctx_search

#1591"13 matches in 40 files" counted files scanned, not files matched. Now "3 matches in 2 files … scanned 10": both numbers, each labelled.

ctx_edit / ctx_patch / ctx_handoff

#1592 — receipts labelled a 64-hex BLAKE3 digest as md5=, which matched neither MD5 nor SHA-256 and cost a user real time. Every receipt, error and struct field now says blake3=. expected_md5 stays accepted as a wire alias, and the on-disk handoff keys (content_md5, manifest_md5) are unchanged, so nothing breaks.

ctx_refactor

#1593replace_symbol returned NO_SYMBOL for files created after the index was built.

Also

.github/workflows/release.yml had a trailing blank line failing the whitespace gate since 4ffab8f. Removed.

Verification

  • cargo fmt --check clean on every file in this PR
  • cargo clippy --all-features -- -D warnings: exit 0
  • cargo test --lib --all-features: 10519 passed (+8 new tests)

Two pre-existing unit-test failures in rust/src/engine/operators.rs and the Windows cross-compile gate are not touched by this PR — they come from work in progress that is uncommitted on this branch and were failing before these changes.

Fixes #1584
Fixes #1587
Fixes #1588
Fixes #1589
Fixes #1590
Fixes #1591
Fixes #1592
Fixes #1593

🤖 Generated with Claude Code

yvgude and others added 2 commits August 29, 2026 08:10
… counts, honest digests

Batch fix for eight issues filed from a 3.9.20 field report.

ctx_read modes
- #1584 mode=diff was rejected on the MCP path only: the instruction-file rule
  rewrote every mode to full, and the unknown-mode branch dumped the file
  instead of naming the valid modes. The MCP handler and the CLI path now
  resolve modes identically.
- #1587 a compressed read that silently returned the whole file now says so;
  the no-compression banner prints only above its threshold.
- #1588 Context Gate overrides (bounce-prevention, intent-target,
  pressure-auto-downgrade) are escapable and name the reason they fired, so
  none of the ten modes is unreachable.
- #1589 mode=task no longer emits blank-line floods or score-ordered fragments,
  and keeps line numbers.
- #1590 an auto-inferred session task (intent="inferred") no longer steers a
  read; only an explicit task does.

ctx_search
- #1591 "N matches in M files" counted scanned files, not matched files. The
  scanned count is still reported, separately and labelled.

ctx_edit / ctx_patch / ctx_handoff
- #1592 receipts labelled a 64-hex BLAKE3 digest as md5=. Every receipt, error
  and field now says blake3=; expected_md5 stays accepted as a wire alias and
  the on-disk handoff keys are unchanged.

ctx_refactor
- #1593 replace_symbol returned NO_SYMBOL for files created after the index was
  built.

Also drops a trailing blank line in .github/workflows/release.yml that had been
failing the whitespace gate since 4ffab8f.

+8 regression tests; cargo test --lib --all-features: 10519 passed. fmt and
clippy -D warnings clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…contracts

Four red checks on this PR, four separate causes.

Test (ubuntu/windows) — `phase2_read_diff_after_edit` failed with
"[no cached version for diff — use mode=full first, then diff on re-read]".
The staleness guard invalidates a cache entry whose mtime/hash no longer match
the file on disk, which is right for every mode except `diff`: there the stale
entry *is* the baseline the delta is computed against, so an edit destroyed
exactly the thing the next `diff` read needed. `diff` is now exempt from that
invalidation; every other mode still refuses content that no longer matches
disk. The test only passed before #1584 by accident — the old MCP path answered
"[WARNING: unknown mode 'diff']" and returned the whole file, which happened to
contain the string the assertion looked for.

Clippy — the job's `loc-gate.sh` step: ctx_read.rs had grown to 1579 lines
(> 1500). Five leaf helpers (`record_attribution_result`, `apply_verdict`,
`auto_degrade_read_mode`, `extract_file_summary`, `task_intent_steers_read`)
move to `ctx_read_helpers.rs` behind the existing `#[path] mod` pattern the
file already uses for `engine`/`image`/`window`. No behaviour change; the
inline tests reach them unchanged via `super::`. ctx_read.rs is now 1496 lines.
The allowlist is untouched — it says shrink, never extend.

Delivery + Security Verification — self-inflicted: the previous commit dropped
a trailing blank line from `.github/workflows/release.yml` to satisfy the
whitespace gate, and `docs/contracts/delivery-evidence-v1.json` pins that
file's digest twice (as `release.workflow` and as the `engine-release` publish
channel). Both refreshed, contract re-emitted as canonical JSON.

cargo-deny — `chacha20 0.10.1` was yanked upstream (reached via `rand 0.10.2`
from both `rmcp` and `lopdf`). Lockfile bumped to 0.10.2; `cargo deny check
advisories` is ok. Unlike the arrayref case documented in deny.toml, this yank
resolves upward with no supply-chain concern, so no ignore entry is added.

Verification: cargo test --lib → 10497 passed, 0 failed, 22 ignored.
cargo test --test power_user_worksession → 24 passed, 0 failed.
cargo clippy --lib --all-features clean, cargo fmt --check clean,
loc-gate.sh ok, verify-delivery-evidence.py exit 0,
cargo deny check advisories ok.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@yvgude
yvgude merged commit bec662d into main Aug 29, 2026
29 checks passed
@yvgude
yvgude deleted the fix/read-mode-batch-3920 branch August 29, 2026 08:25
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.