Parent
Source: PLAN Phase A2, topic plugin-audit-port — plan locked at commit 40a64b5c on
feat/plugin-audit-port.
What to build
context-zone.sh <session_id>: reads that session's snapshot plus optional machine-scope
~/.claude/context-guard/zones.json and prints exactly one word — smart / acceptable / dumb
/ unknown. Absent, stale, or unparsable snapshot → unknown; used_percentage null or outside
0–100 → unknown (fail-open, mirroring the rate-limit-guard reader-contract posture). Shipped
default bands live in the script (zones.json absent = zero-config): approved defaults smart ≤ 50,
acceptable 50–75, dumb > 75 used_percentage. Malformed zones.json → shipped defaults + visible
stderr notice. Test-first, sandboxed HOME.
Grounding context (verified 2026-07-23): NO auto-compaction threshold percentage is documented
anywhere official (how-claude-code-works, context-window, settings autoCompactEnabled, costs
pages all say only "as you approach the limit") — the defaults are declared judgment values, owner
approved 2026-07-24. Two follow-through tasks in this slice:
- Re-check the docs for a published threshold at implementation; the reader contract (next slice)
cites the absence with fetch date.
- Empirical ordering check: drive a session toward the limit, record the last
used_percentage
before auto-compact fires, and confirm the dumb band starts below it with declared margin (the
dumb tripwire is useless if auto-compact fires first). Also determine whether
used_percentage/remaining_percentage are pre- or post-output-buffer values, and document the
autoCompactEnabled: false variant.
Acceptance criteria
Blocked by
Parent
Source: PLAN Phase A2, topic
plugin-audit-port— plan locked at commit40a64b5confeat/plugin-audit-port.What to build
context-zone.sh <session_id>: reads that session's snapshot plus optional machine-scope~/.claude/context-guard/zones.jsonand prints exactly one word —smart/acceptable/dumb/
unknown. Absent, stale, or unparsable snapshot →unknown;used_percentagenull or outside0–100 →
unknown(fail-open, mirroring the rate-limit-guard reader-contract posture). Shippeddefault bands live in the script (zones.json absent = zero-config): approved defaults smart ≤ 50,
acceptable 50–75, dumb > 75
used_percentage. Malformed zones.json → shipped defaults + visiblestderr notice. Test-first, sandboxed HOME.
Grounding context (verified 2026-07-23): NO auto-compaction threshold percentage is documented
anywhere official (how-claude-code-works, context-window, settings
autoCompactEnabled, costspages all say only "as you approach the limit") — the defaults are declared judgment values, owner
approved 2026-07-24. Two follow-through tasks in this slice:
cites the absence with fetch date.
used_percentagebefore auto-compact fires, and confirm the dumb band starts below it with declared margin (the
dumb tripwire is useless if auto-compact fires first). Also determine whether
used_percentage/remaining_percentageare pre- or post-output-buffer values, and document theautoCompactEnabled: falsevariant.Acceptance criteria
bash plugins/context-guard/scripts/context-zone.test.shexits 0 (band edges, zones.jsonoverride, malformed zones.json fallback + stderr notice, absent/stale → unknown, absurd and
null
used_percentage/ nullcurrent_usage→ unknown)for the reader-contract slice to cite
Blocked by