Repository navigation
Description
Follows #4392 (closed). Parent: #4373. Found by the 2026-09-29 audit of the unattended Cursor run.
What #4392 required
The triage brief: "a PostToolBatch fire with no zone change costs 1 process whether or not the snapshot was rewritten", plus a Windows/WSL re-run of the census.
What shipped (#5050, #5088)
zone-crossing-inject.sh (cg_try_coalesce) reuses the cached body only when cached_body equals SNAP_BODY, or, with no zones.json, when only used_percentage moved inside the same shipped band and every other byte is equal.
Between two PostToolBatch fires a model call happens, so the token fields and current_usage normally move and the body differs. The rewritten-snapshot case therefore probably still starts the resolver. This is an inference from the code and the synthetic fixtures; there is no live measurement either way, and both closing PRs verified fixtures on a Linux host only.
Fix PR #5297 (Refs, not Closes) makes Windows-shaped payloads (backslashes in transcript_path and cwd) eligible for the no-jq path and pins the hook's copies of the shipped bands and staleness window to the resolver. It does not change how the rewritten-snapshot case skips the resolver.
Owner steps (operator action, not doable unattended)
- On the Windows Git Bash host, run
scripts/hook-census.sh context-guard PostToolBatch zone-crossing-inject.shwith a real payload whosetranscript_pathandcwdcarry backslashes, on main and onfix/audit-context-guard(harness lineage melodic-software/dotfiles#873). - In a live session, compare
zone-crossing-injectPostToolBatch hook durations before and after the 0.7.85 release from the local OTEL store (/claude-ops:observabilityhook latency). The resolver path measured about 90 ms on Windows and the fast path a few ms, so the distribution shows the share of fires that still resolve.
Decision packet (owner-reserved)
Question: how should the rewritten-snapshot case skip the resolver?
- A) The hook computes bands itself from
used_percentageplus token occupancy, window class and version gate. A third copy of resolver logic, parity-test burden, no cross-plugin sync. - B) Resolver-owned reuse bounds: change the canonical
scripts/context-zone.shto expose the interval in which the zone cannot change. Single authority, butsync-context-zone.shcopies it intoplugins/plugin-qualityand--check-bumpforces that plugin's bump, so it is a cross-plugin change. - C) The tee computes and caches the zone at write time (the issue's option 2). Moves cost into the statusline process that perf(context-guard): stop spawning a dozen processes on every statusline render #4675 just slimmed, and needs the resolver or a copy there.
- D) Measure first with the steps above and change nothing until the share of resolving fires is known.
RECOMMENDED: D, then B if the share of resolving fires is high. Basis: judgment plus the code reading above (A duplicates logic the resolver owns, C works against #4675, and no measurement exists yet).
Unblocks: the rewritten-snapshot acceptance criterion of #4392.
Two conditional deletions that wait on the same measurement
They point in opposite directions:
- Delete the
captured_at-only coalesce arm if it fires rarely (the tee's 60 s no-change floor already suppresses that non-event, so three layers suppress it). - Delete the percentage-band branch
cg_pct_placeholder/cg_same_percentage_bandif it never fires live (used_percentagederives from token fields that also change), or keep it if option A or B builds on it.
Informational
The PLAN.md k x S bands (p50 <= 4 x S, p95 <= 5 x S) were written by the implementing agent and the owner merged #5088. Edit here if different values are wanted.
Acceptance
- The owner picks A, B, C or D on this issue.
- Windows census and hook-duration numbers are recorded here, with the share of PostToolBatch fires that still start the resolver.
- The rewritten-snapshot criterion of perf(context-guard): zone-crossing-inject fires 16 times per turn on PostToolBatch #4392 is met or explicitly waived.
Activity
kyle-sexton commentedon Sep 29, 2026
Owner decision (2026-09-29): Option D, measure first and change nothing yet, then Option B (resolver-owned reuse bounds in
scripts/context-zone.sh, synced intoplugins/plugin-quality) if the share of PostToolBatch fires that still start the resolver is high. The owner accepted the recommendation with no note.Next: the measurement needs the Windows Git Bash host and the local OTEL store, so the owner runs the two steps under "Owner steps" and records the census and hook-duration numbers, with the resolving-fire share, on this issue. The issue keeps
needs-human. Once the share is recorded, an agent implements B (or A/C) and the two conditional deletions.kyle-sexton commentedon Sep 30, 2026
Resolution (2026-09-29, owner-approved consensus)
Ran the approved plan (fleet run, read-only) on melo-desk-001. It answers part of the plan and leaves the acceptance criteria open. Nothing was installed, deleted, fetched or changed; the only write was a scratch dir,
C:\Users\KyleSexton\claude-lane-sandbox\issue5298\(SQL files).Reach. The
windows-shellalias to this same host fails from the WSL lane:ssh.exe melo-desk-001reaches sshd, thenHost key verification failed.(no pinned key for the host itself). Fixing it editsknown_hosts, which I did not do. I ran the same read-only commands through WSL interop instead (powershell.exe, Windows lane,hostname=melo-desk-001).Probe. Git Bash 2.55 is present (
C:\Program Files\Git\bin\bash.exe), as areduckdb.exe(WinGet Links) andjq. CheckoutD:\repos\github.com\melodic-software\claude-code-pluginsexists but ismain...origin/main [behind 436]atbf8aaca78(2026-09-24). Bringing it current is a fetch/pull, so I left it. OTEL store:C:\ProgramData\local-otel\cc-store\cc-logs.json(hot, 2026-09-22 to now) plus a cold parquet.Step 2, census: cannot be run on Windows.
scripts/hook-census.shneeds Linuxstrace -ff -qq -s 400 -e signal=none -o ...(the script marks itself Linux-only, lines 65-66). Git Bash ships cygwin strace 3.6.9:So there is no spawns-per-fire number for backslash payloads from this host, and the Windows census that #4392 asked for is not met. It needs a Windows-capable counter, or a WSL-lane run with a Windows-shaped payload, which does not measure Windows process cost.
Step 3, hook durations: the store cannot isolate this hook.
hook_execution_completeforPostToolBatchcarriestotal_duration_msandnum_hooks(always 2) with no hook script name. The two registered PostToolBatch hooks areclaude-opssession-event-log.shandcontext-guardzone-crossing-inject.sh, run in parallel, so the value is the slower of the two. Batchtotal_duration_ms, split at merge times (#5088 merged 2026-09-29T00:10Z, #5297 at 14:57:54Z; I found no separate release timestamp for 0.7.85, so merge times stand in for it):Every Windows batch is over 40 ms, even the 5th percentile, so the proposed 40 ms fast/resolving cut-off cannot separate the paths: node +
exec-bash.mjs+ bash startup alone costs more than that on Windows, for both hooks. The resolving-fire share is not computable from this store. Only 98 Windows fires fall after #5297, and the 0.7.90 install landed 2026-09-29T20:07Z, so the sample after the real fix is smaller still. The WSL rows mix this session with others and show the batch getting slower after #5088, but that is not attributable to one hook.Against the acceptance criteria
The issue stays open with
needs-human. What would produce the number: (1) a per-hook duration source, for examplezone-crossing-inject.shrecording its own elapsed time and path (fast, coalesced or resolving), or hook-level spans ifcc-traces.jsonstarts carrying them (it is empty now); or (2) a Windows-capable spawn counter forhook-census.sh. Either is a code change and an owner decision, so option B is not started.kyle-sexton commentedon Oct 1, 2026
Owner decision (2026-10-01): approved the recommendation ("go with recommended", the owner's reply to the batch decision page that listed this question and its recommendation).
Question: the measure-first step cannot run as planned (the Windows census fails and the OTEL store cannot isolate this hook), so which route gets the resolving-fire share?
Chosen: option A. A small instrumentation PR (Refs #5298, not Closes) makes
plugins/context-guard/hooks/zone-crossing-inject.shlog one telemetry record per fire with its path (fast, coalesced or resolving) and elapsed ms, reusingSTART_EPOCHandhook::emit_telemetry. After a few days of data on melo-desk-001, the share is recorded here, and the 2026-09-29 decision (then option B if the share is high) governs from there.Next: an agent opens the draft instrumentation PR and bumps the context-guard version. Labels changed to
agent-ready.perf(context-guard): release 0.7.95 with the per-fire path field docu…
docs(context-guard): describe both coalesced arms and the per-fire re…
perf(context-guard): log path and duration for every zone-crossing-in…
kyle-sexton commentedon Oct 1, 2026
Measurement attempt, 2026-10-01. I could not produce the Windows share, and a few days of data would not produce it either until a sink change lands. Nothing from the 2026-09-29 decision (option B if the share is high) follows yet. This issue stays open.
The 2026-10-01 decision chose option A: the instrumentation PR (#5667, merged 14:01Z today, shipped as context-guard 0.7.96) plus a few days of data on melo-desk-001, then the share is recorded here.
What I checked on melo-desk-001
D:\repos\github.com\melodic-software\claude-code-plugins, atbf8aaca78from 2026-09-24) hasHOOK_TELEMETRY_SINKwired in its settings but no.observability/claudefolder at all, so no hook telemetry has ever been written there.zone-crossing-injectrow. That lane's user-scope context-guard is 0.8.0, which includes the instrumentation, but it was updated at 16:23Z today, so sessions that started earlier ran older code. I did not establish why no row exists yet.The finding that matters most: the reference sink drops
path..claude/hooks/hook-telemetry-sink.sh(and the claude-ops copy) store onlyhook,exit_code,subject,toolandchangedfrom the envelope'sdata. The hook'sdata.path(fast,coalescedorresolving) never reaches the store. I confirmed it by running the installed 0.8.0 hook once with a capture sink, then feeding that envelope to the repo's sink:So with the sink as it is, the store keeps each fire's own
duration_msand nothing about which path it took. The share could only be inferred from the duration distribution. The 2026-09-29 comment found that the batch-level duration cannot separate the paths on Windows, because it includes node and bash startup. The hook's ownduration_msleaves that startup out and might separate them, but there is no Windows data yet to show it.What is left, in order
data.pathinto its record aspath, in both the repo-local sink and the claude-ops reference sink; or (b) the hook also sends the path asdata.subject, which the sink already stores. The owner picks, or says "agent's choice".claude plugin update context-guard@melodic-software). I did not do this: it is a user-scope change on that host, the task did not name it, and it cannot produce the share until step 1 is released. Sessions must then run in a checkout that wires the sink; the D: checkout is far behind main, and bringing it current is the owner's call.kyle-sexton commentedon Oct 4, 2026
This was generated by AI during work-loop.
Which work class should this item carry?
This item carries
agent-readybut nowork-class:label, so the admission gate fails closed and human-gates it. The lane removedagent-readyand appliedneeds-human. Stamping one dispatchable class (read-only, mechanical, or scoped) and flipping the role back through/work-items:attend-queuemakes it dispatchable.Lane: work-loop, instance melo-worker-1, cycle 1.
kyle-sexton commentedon Oct 4, 2026
kyle-sexton commentedon Oct 4, 2026
This was generated by AI during attend-queue.
Operator direction (2026-10-04): "go with the recommendations." This records that decision.
Escalation answered: park behind draft PR #6152, priority low, no class stamped. #6152 deletes
zone-crossing-inject.shand its PostToolBatch registration, which removes this cost entirely. Close this as superseded when #6152 merges. Revisit, and do not start option B, only if #6152 is abandoned.The hypothesis holds by code reading and a sandbox probe.
cg_try_coalesce(zone-crossing-inject.sh:689-727) reuses the cached zone only when the snapshot is byte-identical or onlyused_percentagechanged. The status line rewrites the token fields after each model call, so most PostToolBatch fires resolve. The share is unmeasured: the telemetry sink still dropsdata.path(.claude/hooks/hook-telemetry-sink.sh:76-78,133).Found: the percentage-band arm can never fire on real snapshots, because
remaining_percentagealways moves withused_percentage. The test fixture holdsremaining_percentagefixed (zone-crossing-inject.test.sh:48), which hides this. If #6152 is abandoned, fix it together with the sink change, as a C3 item. Research: attend-queue sliceintake-5298.kyle-sexton commentedon Oct 13, 2026
Decision recorded. The owner approved applying independently verified recommendations on 2026-10-12.
Asked how the PostToolBatch zone hook could skip the resolver when the snapshot was rewritten. #6152 (merged 2026-10-04) moved context-guard onto mods and deleted the shell hook, which removes the cost the issue measured.
Verified by an independent fresh-context check (confirmed, risk low): gh issue view 5298 (OPEN; owner direction 2026-10-04: close as superseded when #6152 merges); gh pr view 6152 MERGED 2026-10-04; origin/main plugins/context-guard/hooks: no zone-crossing-inject.sh; hooks.json registers only PostCompact and SessionStart plus modules; register.tsx resolves the zone in-process; origin/main plugins/context-guard/CHANGELOG.md:210
Closing: Superseded: #6152 merged and deleted zone-crossing-inject.sh; the owner's 2026-10-04 decision said close when #6152 merges