Repository navigation
docs(context-guard): record the cloud/headless capture verdict and make the gap legible - #3074
Conversation
|
Claude finished @kyle-sexton's task in 1m 12s —— View job Security review (
|
|
Claude finished @kyle-sexton's task in 4m 41s —— View job Code review complete
This repo carries a Finding (1, Important) — posted inlineThe structural-vs-defect discriminator is missing a branch for the exact case this PR measured: a correctly-wired statusline in a terminal-less session.
But the PR's own headline measurement is a fourth case none of the three above actually cover: a The practical consequence is in Left inline comments on all three files with the specific line ranges:
Notes
|
|
Last security-reviewed head: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16a5d3b07f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Claude has reviewed this PR 2 times. The lane skips further automatic reviews after 5; deleting this comment resets the count. |
…2957) Step 1 of #2957: establish the current state empirically inside a live Claude Code on the web container rather than reasoning about it. Confirmed: no statusLine is configured in any settings scope, no per-session snapshot exists, and context-zone.sh resolves `unknown`. Corrected: ~/.claude/context-guard/ DOES exist in cloud — created by the PostCompact hook. Plugin hooks run here; only the statusline writer is silent. That is the finding the fix will build on.
…urces (#2957) Step 2 of #2957: check every documented channel against the live docs (all read 2026-08-21) and record the verdict with per-channel evidence. Verdict: no documented channel other than the status line carries per-session context-window telemetry. Hook stdin — the named candidate — carries session_id, prompt_id, transcript_path, cwd, permission_mode, effort, hook_event_name and event-specific fields, and no context, token, usage, or window field on any event. Also rejected, with the reason recorded: subagentStatusLine (subagent rows only, and a status-line surface), non-interactive JSON/stream output (per-invocation, after the fact), OpenTelemetry (cumulative counter, no occupancy gauge), and the session transcript — reachable from every hook via the documented transcript_path, but its entry format is documented as internal and version-unstable, so parsing it would warrant a zone with nothing. A wrong zone is worse than unknown.
…sumers (#2957) Step 3 of #2957, no-viable-channel branch. The verdict is shipped; this makes the resulting degradation readable instead of indistinguishable from a broken install. reader-contract.md gains a cloud-and-headless section: a session with no configured statusLine has no instrument at all, so unknown is structural and permanent there. Consumers report it as "no instrument in this environment", never as a defect; never synthesize a zone from another source; and never read unknown as evidence of a full window. It also gives the discriminator between structural absence and breakage — read statusLine from every scope, because both states print unknown. The setup skill's check stops offering a remediation that cannot work: no statusLine in a session that refreshes none is INFO with the structural explanation, not FAIL with wiring instructions.
Bumps context-guard to 0.7.17 with the CHANGELOG entry for the cloud/headless capture verdict, the reader-contract consumer rule, and the setup-skill check branch. The entry is INSERTED above the 0.7.16 heading; 0.7.16 and every earlier release keep their notes intact.
…OT (#2957) check-changed-skills.sh resolves a bare `reference/...` citation relative to the SKILL DIRECTORY, and this plugin's reference/ sits at the plugin root, so the two new citations read as broken skill-internal refs and failed the gate. They now use the ${CLAUDE_PLUGIN_ROOT}/reference/ form the rest of the file already uses.
…2957) Measured in the same container: one synthetic statusline payload fed to the tee under a scratch HOME produced a snapshot and resolved `acceptable`, while the real session id resolved `unknown` moments earlier. That separates the two explanations a reader could otherwise reach for. Nothing in the resolver, the tee, jq, or the contract path is broken here — there is simply nothing calling the tee, because nothing calls a statusline.
…ud empirically (#2957) The verdict was falsifiable from its own citation. The OpenTelemetry row was titled "metrics and events" but rejected the channel on the ground that every documented metric is a cumulative counter — true of the metrics, false of the events. `claude_code.api_request` is a documented log event carrying input_tokens, output_tokens, cache_read_tokens and cache_creation_tokens per request, query_source naming the issuing subsystem, event.sequence for ordering, and session.id on by default. Filtered to the newest repl_main_thread event it yields exactly the three input addends the statusline page names as the used_percentage formula: live per-session occupancy, for a running interactive session. The channel now gets its own section and the disqualifiers that actually hold. It carries no denominator — no context_window_size and no percentage — and the resolver needs one: measured under a scratch HOME, a snapshot with a mapped current_usage, both token totals and a cli_version but no context_window_size resolves `unknown`, while adding one to the identical file resolves `acceptable`. And it has no local delivery: prometheus is metrics-only, console writes to Claude Code's own stdout, and Claude Code strips OTEL_* from every subprocess it spawns including hooks, so nothing hook-local can even find the receiver. The headline verdict narrows to what is true: no documented channel other than the status line *delivers per-session occupancy to a local writer*. Three more corrections in the same pass. Hook stdin's "no context, token, usage, or window field on any event" was false as written: PostToolUse on the Agent tool receives totalTokens and a usage breakdown in tool_response. It is subagent- and single-request-scoped so the conclusion is unchanged, but this is the load-bearing sentence of a document whose whole value is exhaustive channel accounting. The transcript rejection argued only the weak half of its case. A shape-validating reader degrades to writing nothing, which is `unknown` — the same fail-open posture this contract mandates everywhere else — not to a confident wrong zone. The decision stands on silent semantic drift, which no shape check detects, plus an unbounded re-verification obligation against a format its own docs call internal and unsupported. The structural-vs-broken discriminator missed the state that prints `unknown` with a statusLine present: the status line is turned off entirely under a managed disableAllHooks or an untrusted folder, and under allowManagedHooksOnly narrowing Claude Code runs a managed value if one is deployed and otherwise skips yours without warning. Managed settings join the scope list, the measured-facts grep covers the same scopes the rule names, and the upstream-change bullet that claimed "neither is documented today" now carries the statusline page as its anchor. Finally, the cloud half of "no statusline runs here" was inference: the earlier text verified only that none *is* configured. Measured from the other side — a statusLine written into the live cloud session's own user settings with refreshInterval 2, pointing at a probe that logs every invocation before teeing, exercised ~7 minutes, then restored. The probe was never invoked once; no log entry, no snapshot. statusLine is not among the keys documented as read once at session start, and settings reload covers user scope, so the value was live. The identical wiring under a scratch HOME exercised with `claude -p` behaved the same. Both rows are now measurements.
…ract (#2957) The contract restated the capture verdict in the form the capture reference has just abandoned, so it inherited the same two defects. "The absence of the only documented surface that carries per-session context-window telemetry" is not what was measured; the OpenTelemetry api_request event and the session transcript both carry live occupancy for the running session. What the status line uniquely does is deliver that occupancy to a local writer, so the sentence says that instead, and the "never synthesize a zone" rule now names what each near-substitute would force a reader to invent or trust rather than asserting a common failure direction they do not share. Hook stdin's absolute carries the Agent-tool exception. The discriminator listed three scopes and two branches. It now lists four scopes — managed settings carry statusLine too — and separates a configured statusLine whose status line is *disabled* from a genuine wiring defect. Under a managed disableAllHooks, an untrusted folder, or allowManagedHooksOnly narrowing with no managed value deployed, Claude Code skips the configured value without warning. That state prints `unknown` with a statusLine present, which the old two-branch rule sent straight to "real defect" and an operator chasing an install problem that does not exist. Its remediation is policy or trust, never wiring. The contract also records that cloud and headless are structural from both sides now: not merely that no statusLine is configured there, but that one configured there does not run.
…ocal install (#2957) Step 3's terminal-less exception is properly gated — it fires only "where you can tell you are in such a session". Step 4's matching branch was not: an absent snapshot with no statusLine in any scope reported "INFO, never FAIL … do not send the operator to fix an install that is not broken", unconditionally. On an ordinary local terminal machine that installed the plugin and has not yet wired the statusline — the single most common state this check exists to diagnose — step 3 printed the wiring instructions and step 4 said nothing was broken. Same report, opposite instructions, and the wrong one carried "never FAIL". Step 4's branch now splits on the same condition step 3 used. Where step 3 took the terminal-less exception the state is structural and `unknown` is permanent. Otherwise it is the ordinary not-yet-wired state, and the remediation is the wiring step 3 just printed — reported as such, and not called structural. Two related gaps close with it, both from the same missing scope. The statusLine scope list omitted managed settings, where statusLine is also a valid key and outranks the other three. And a status line can be turned off with a statusLine still configured — under a managed disableAllHooks, an untrusted folder, or allowManagedHooksOnly narrowing with no managed value deployed, where Claude Code skips the configured value without warning. That state was falling through to the wiring-defect FAIL; it is now an INFO naming which condition applies, with policy or trust as the remediation. Step 3's exception itself stops being an unlabelled inference. The claim that a non-terminal session refreshes no statusline "no matter what is wired" is now measured for Claude Code on the web and for a `claude -p` run, and marked as expected-not-measured for other non-terminal environments.
…2957) Amends the existing 0.7.17 text in place — no version bump, no new heading. The entry stated the verdict in the falsifiable form, repeated hook stdin's absolute without the Agent-tool exception, and rejected the transcript on the "it would break on a release" argument the reference no longer relies on. Now recorded: the verdict narrowed to delivery-to-a-local-writer; the Agent-tool exception on PostToolUse tool_response; the OTel api_request event as a real occupancy channel disqualified by a missing denominator (with the measured resolver behavior) and by having no local sink; the transcript declined on silent semantic drift rather than on shape breakage; managed settings and the policy- or trust-disabled status line in the discriminator; the `check` self-contradiction and its gating fix; and the cloud result as a measurement — a statusLine configured in a live cloud session was never invoked — rather than an inference from its absence.
…#2957) The terminal-less exception lived only under "no statusLine configured", so a correctly-wired shim in cloud or headless — the case this release measured — was PASS at step 3 and FAIL at step 4. Lift that check orthogonal to all four wiring states, exclude it from the snapshot-freshness FAIL the same way policy-disable already is, and make step 7 skip printing wiring those branches already forbade. Also: route a managed effective statusLine to the policy administrator instead of an operator edit; treat a stale leftover snapshot like an absent one when nothing is configured; and give the reader-contract and cloud-headless discriminators an explicit configured-but-terminal-less branch so the measured case no longer matches "real defect". Co-authored-by: Kyle Sexton <[email protected]>
16a5d3b to
d8ccf49
Compare
|
Claude finished @cursor[bot]'s task in 2m 55s —— View job Code review complete
No blocking findings. This lane scopes security out (the repo carries What changed since the last review on this PRThe previous review round (mine and Codex's, on commit Commit
I checked all three files against each other for numbering/consistency (the "FOUR wiring states" vs the two orthogonal environment states, and the reader-contract's four discriminator bullets vs cloud-headless-capture's five numbered branches) and didn't find any residual mismatch. No new issues found in this round of commits. |
Closes #2957
Summary
context-guard's context-zone snapshot is written by a statusline tee. In a session with noconfigured
statusLine— cloud and headless sessions by default — nothing writes the snapshot,context-zone.shresolvesunknown, and every zone consumer silently takes its conservative path.The instrument-driven handoff trigger is structurally silent exactly where sessions are most
disposable.
Verdict: no documented channel delivers per-session context-window occupancy to a local writer
the way the status line does. No capture path is shipped. What ships instead is the channel
inventory behind that verdict, plus the changes that make the resulting
unknownlegible asstructural rather than broken.
One correction to the issue's own premise, and the rest rests on it:
~/.claude/context-guard/does exist in cloud — the
PostCompacthook creates it. Plugin hooks run fine there; only thestatusline writer is silent. That is why hook stdin was the first channel checked, and it makes the
hooks-reference negative a measured result rather than an assumption.
Fix
reference/cloud-headless-capture.md(new) — every channel checked, each with the URL read andthe date, what it does and does not carry, and what would have to change upstream. The two that
came closest are documented as near-misses with the reason each fails:
claude_code.api_requestlog event does carry live per-session tokenoccupancy —
input_tokens+cache_read_tokens+cache_creation_tokens,session.id,query_source: "repl_main_thread"— the same addends the statusline page uses. It is rejectedbecause it carries no denominator: no
context_window_sizeand no percentage, and bothresolver shapes need one. Measured ablation, included in the doc: a snapshot with real tokens and
used_percentage: nullresolvesacceptablewhencontext_window_sizeis present andunknownwhen it is absent. A writer would have to invent a per-model window map. It also needs an
out-of-process OTLP receiver, and
OTEL_*variables are not passed to hooks or Bash subprocesses,so nothing hook-local can even discover where the telemetry goes.
transcript_pathand carrying exactlythe right numbers. A shape-validating reader would degrade to
unknownrather than to a wrongzone, so the "it would break" argument alone does not carry. It is declined on the ground that
does survive: silent semantic drift — field names surviving while ceasing to mean
full-context occupancy, which no shape check detects — against a format the docs mark internal and
version-unstable, plus an unbounded re-verification obligation.
reference/reader-contract.md— new cloud/headless section:unknownthere is structural andpermanent, reported as "no instrument in this environment" and never as a defect; no zone may be
synthesized from another source; and because
unknowncarries no direction, a fork or handofftrigger in such a session must come from elsewhere and must not be presented as instrument-backed.
A four-branch discriminator, because both a broken install and a structurally-absent instrument
print
unknown. It now includes the state that was missing: astatusLineconfigured but thestatus line disabled —
disableAllHooks,allowManagedHooksOnlynarrowing with no managed valuedeployed, or an untrusted workspace. Claude Code skips the value without warning, so that state
prints
unknownwith astatusLinepresent and would otherwise land on the "real defect" branch.The scope list now spans user / launcher / remote / policy-limits / project / local / managed, and
managed outranks all others.
skills/setup/SKILL.md—checkno longer contradicts itself. Its new INFO branch is gated onthe same condition step 3 uses: terminal-less → structural,
unknownis correct and permanent;otherwise → the ordinary not-yet-wired state, remediated by the wiring step 3 prints. Previously an
ordinary local install that simply had not wired the statusline was told nothing was broken.
Verification
The cloud question was settled empirically rather than inferred. A
statusLinewas wired intothis live cloud session's own settings pointing at a probe that logs stdin before teeing, and
exercised for ~7 minutes: never invoked once, no snapshot written. The probe was proven working by
hand-feeding it a payload. The same experiment under a scratch
HOMEwithclaude -p … --output-format jsongave the same result. Settings were restored byte-identicalafterwards, verified with
diff. Other non-terminal environments (self-hosted runners) are labelledas expected-but-not-measured rather than asserted.
Reader-side health confirmed in the same container: one synthetic statusline payload through the tee
produced a snapshot and resolved
acceptable, while the real session id resolvedunknownmomentsearlier. Nothing in the resolver, tee,
jq, or contract path is broken — there is simply nothingcalling the tee.
validate-plugins.sh, both generator--checkscheck-changelog-parity.sh× 4 modescheck-changed-skills.sh origin/mainmarkdownlint-cli2,typosplugin-quality/zones-inline-drift.test.shAn independent fresh-context audit fetched all cited pages itself rather than trusting the channel
table, reproduced all three container measurements verbatim, and found the original verdict
falsifiable — it had rejected OpenTelemetry on grounds true of its metrics and false of its events.
That, and five smaller defects, are fixed here. The audit's own proposed disqualifier for OTel was
in turn wrong in mechanism, and the correction above is the measured ablation that replaced it.
No behavior changed:
zones.json,context-zone.sh,statusline-tee.shand all hooks areuntouched; the diff is documentation plus one manifest version line and the setup-check wording.
Related
Refs #2994 (AI Hero course journey roadmap)
Refs #2901 (lane 3 — handoff trigger criteria, where this was surfaced)
Generated by Claude Code