Wrap #3106's mkdtemp fixture roots in realpathSync, matching the existing
atomic-write tests, so CodeQL no longer traces shared-temp paths from
these fixtures into read handles. Assertions are unchanged.
The hook proposes a correct absolute checkpoint path on Windows, but the
tests located that line with /^\s+[/\\].*\.md$/, which only matches paths
starting with a slash. Windows paths start with a drive letter (C:\...),
so every case that read the proposed path saw undefined and failed.
- Extract the proposed checkpoint as the indented line that ends in .md
and satisfies path.isAbsolute, so POSIX and Windows paths both match.
- Include the hook output in the "both fires should propose" assertion
so a genuine decline is diagnosable from CI logs.
- Write transcript fixtures into private fs.mkdtempSync directories
instead of predictable names directly under os.tmpdir() (CodeQL
js/insecure-temporary-file) in context-gate, context-gate-state and
ecc-context-monitor tests.
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.