Round 5 review (haelyra): enforcement must be opt-in and the enabled
checkpoint must preserve ownership.
- Add ECC_CONTEXT_GATE_MODE (advisory default | enforce | off) in
context-gate-state.js; isGateEnabled is true only in enforce mode, so a
default install is inert and adds no advisory suppression (suggest-compact
and ecc-context-monitor keep their normal behavior). A mistyped mode falls
back to advisory with a one-time stderr note.
- context-gate.js returns '' before any transcript work unless enforce is
set (no per-prompt checkpoint cost by default).
- In enforce mode the order now targets a collision-safe, identity-bearing
path under the session-handoff dir
(getSessionsDir()/resume/<project>-<sessionId>.md) instead of a fixed
project-root RESUME.md: never collides with an operator file, repeated
fires in one session are idempotent, the resume command is the receipt,
and the order states that observed usage is not itself permission to stop.
- Tests: default-inert, mode resolution, handoff-path/preserve/idempotent,
explicit disable; advisory-hook suppression tests set enforce and add a
default-does-not-suppress case. Bounded reader + threshold tests retained.
- Docs: hooks/README.md, README.md, hooks.metadata.json, header comment.
Full suite 4762/4762 (serial). validate-hooks: 25 matchers.
Two boundary cases in threshold resolution raised in review:
- Clamp emergencyPct to at least gatePct+1 in run(). A gate threshold set
at/above the emergency default (e.g. ECC_CONTEXT_GATE_PCT=98 vs the 96
default) previously made every fire count as EMERGENCY, permanently
skipping step 1 (bring in-flight work to a clean stopping point). The
clamp preserves the two-tier order.
- resolvePct emits a one-time stderr note when an env override is present
but rejected (e.g. "50.5", "abc", "150"). The return stays the
deterministic fallback, so the contract is unchanged, but a typo'd
override no longer silently re-arms the default gate unnoticed.
Regression tests added for both. Full suite 4751/4751.
Round-2 review fixes:
- ecc-context-monitor no longer suppresses its context warnings on
configuration + bridge percentage alone. Deference now requires
CONFIRMED gate activity via the shared gateOwnsTranscript (moved from
suggest-compact into lib/context-gate-state.js): transcript readable,
usage resolved, occupancy at/above threshold. When the gate cannot
evaluate usage (missing/unreadable transcript) it cannot fire, so the
monitor's CONTEXT CRITICAL warning survives as the fallback — an
8%-remaining session is never left with no guidance. The transcript
read only happens when a context warning is possible (<=35% remaining).
run()-level tests encode both the fallback and suppression paths.
- resolveContextWindow accepts an env argument; context-gate and
suggest-compact pass their (possibly injected) env through, so an
options.env ECC_CONTEXT_WINDOW_TOKENS override now reaches window
resolution instead of silently falling back to process.env. Regression
tests cover the injected form and the registered-path process.env form.
- hooks/README.md: 'At or above the gate threshold' (deferral is
inclusive at 90%), plus the fallback behavior.
- New tests/lib/context-gate-state.test.js covering threshold resolution,
enabled/active checks, and gateOwnsTranscript semantics.
Full suite: 4748/4748.
Conflict management (the gate previously had none):
- New scripts/lib/context-gate-state.js — single source of truth for gate
thresholds plus isGateEnabled/isGateActive; context-gate.js now imports
from it (public exports unchanged).
- suggest-compact defers to the gate: both the context-size and tool-count
/compact suggestions stay silent at/above the gate threshold. The gate
orders checkpoint-and-restart there; suggesting the lossy /compact path
in the same band was a contradictory instruction. The transcript-reading
gate check on the count path only runs when a count message would fire.
- ecc-context-monitor defers to the gate: the context warnings (including
the critical 'ask the user / do NOT write handoff files' text, which
directly contradicted the gate's checkpoint order) are suppressed inside
the gate band; cost/scope/loop warnings unaffected.
- Header + hooks/README.md now state the real auto-compact interaction:
with auto-compact ON, compaction (~83.5% used per ecc-statusline's
16.5% buffer) precedes the 90% gate, so autoCompactEnabled:false (or a
raised window) is required for the gate to be reachable — the previous
'safe with auto-compact left on' claim was wrong.
Inferred-window softening (review feedback):
- When the window size is inferred (unrecognized model), the gate fires as
a strong recommendation instead of an order and flags the inference plus
the ECC_CONTEXT_WINDOW_TOKENS override, so a possibly-wrong 200k
denominator never forces a restart on a larger-window model. Known
models keep the mandatory wording.
Tests: inferred-softening case; gate-deference pairs for both advisory
hooks; ecc-context-monitor test summary switched to the parseable
'Passed:/Failed:' tokens run-all.js requires.