Maintainer carry-forward of the four edge cases reproduced on 5a565cf:
- Same-named project roots: bind the proposal to a SHA-256 owner key of
the full real project root plus the raw session ID, and put that key in
both the file name and the ownership marker.
- Sanitized session-ID aliasing: hash the raw session ID before filename
sanitization so IDs such as owner/a and owner?a no longer share a path.
- Linked or special destinations: probe with lstat, open read-only with
O_NOFOLLOW and O_NONBLOCK, require a regular single-link file whose
complete first-line marker matches, and decline linked handoff
directories. A FIFO at the destination previously hung the prompt.
- Literal resume arguments: emit the resume prompt as one single-quoted
POSIX (or PowerShell on Windows) argument.
Also merge the UserPromptSubmit registration into the existing event
array. The main merge left a duplicate UserPromptSubmit key in
hooks.json and hooks.metadata.json, and JSON.parse kept only the last,
which silently dropped prompt:hookify-runtime.
Adds tests/hooks/context-gate-ownership.test.js, which fires the hook
through the registered run-with-flags.js entry: 12/12 pass here, 1/12
pass on 5a565cf.
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.
These hooks set no timeout in hooks.json, so with the second Node process
gone they lost the bootstrap's 30s spawnSync cap. Put the same bound back
in hooks.json, where the harness enforces it. Fingerprints regenerated.
Address bot review on the Stop delivery path: the stop:evaluate-session
registration no longer carries async (an async Stop registration cannot
block), so delivery is synchronous, and the metadata fingerprint for the
changed entry is regenerated with the repo's own function; the delivery
marker is now claimed atomically with exclusive create and any write
failure fails closed instead of delivering without once-per-session
protection; the skill doc now marks the shell entry as counting-only,
requires the JavaScript evaluator through the plugin hooks for delivery,
and clarifies that Stop fires whenever Claude finishes responding; test
spawn helpers no longer coerce a failed spawn to exit 0.
Test plan:
- tests/hooks/evaluate-session.test.js: 25 passed, 0 failed (2 new:
marker write failure skips delivery, registration is synchronous);
pristine comparison: 22 passed, 3 failed (delivery, marker, registration)
- tests/hooks/hooks.test.js: 260 passed
- tests/hooks/stop-hooks-stdout.test.js: 48 passed
- tests/hooks/cursor-hook-dispatchers.test.js: 27 passed
- tests/integration/hooks.test.js: 27 passed
- scripts/ci/check-unicode-safety.js: passed
On native Windows, Claude Code runs each hook as `bash.exe -c "<command>"`
through the Windows command line. That extra unescape layer collapses the
backslashes in the WSL path conversion of the inline plugin-root resolver,
so `.replace(/\\/g,'/')` reaches node as `.replace(/\/g,'/')` and every hook
fails with `SyntaxError: missing ) after argument list`.
Build the backslash separator with String.fromCharCode(92) and split/join
instead of regex escapes, so the resolver contains no backslash. Conversion
behaviour is unchanged. Regenerate every embedded copy (hooks.json,
codex-hooks.json, commands/*.md) and refresh hooks.metadata.json
fingerprints.
Add a test that the resolver and each hook `node -e` program are
backslash-free, and run the shipped SessionStart command through bash with
backslashes collapsed the way Windows does.
Fixes#3746
- bash-hook-dispatcher: honor the reader's truncated flag. pre-Bash
blocks (exit 2) because safety checks need the complete request;
post-Bash skips its hooks and does not echo a partial payload.
- resolveStdinIdleTimeout: treat whitespace-only values as unset instead
of Number(' ') === 0 silently disabling the deadline.
- isCompleteJsonObject: do not accept a JSON array as a hook payload.
- tests: wait for the child's close event so stdio is drained before
asserting; cover both bash-hook-dispatcher modes.
- hooks/README.md: keep the example below the 5 s per-hook timeout.
Refs #3665
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readStdinRaw() only settled on end, error or close. If the parent kept
stdin open without writing EOF, every hook that reads through it waited
until the harness killed it (an 8-10 s stall per call).
Add an idle deadline (default 3000 ms, ECC_HOOK_INPUT_IDLE_TIMEOUT_MS,
0 disables). It is reset on each chunk, unref()ed, and on expiry detaches
from and pauses the stream so a held-open pipe cannot keep the hook alive.
Input that already parses as a complete JSON object is accepted; anything
else is marked truncated so fail-closed safety hooks still block.
bash-hook-dispatcher.js now reads through the shared reader instead of its
own end/error-only loop.
Fixes#3665
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve six conflicts:
- hooks/hooks.metadata.json: keep this branch's gateguard description and
fingerprint, add upstream's hookify-runtime entries.
- package.json: keep both gateguard-report.js and github-coordination.js.
- scripts/hooks/gateguard-fact-force.js, tests/hooks/gateguard-fact-force.test.js,
skills/gateguard/SKILL.md: upstream added a simpler session denial cap; this
branch already has the fuller one (cap threaded through
markCheckedAndCountDenial, malformed-value warning, miss and target notes),
so keep it. Upstream's taskset and su wrapper handling, fail-closed
recursion limit and soft-hyphen sanitising merged cleanly and their tests pass.
- manifests/context-packs/skill-triggers@1.json: take upstream's file and
recompute registryDigest for the merged registry.
Carry forward PR #3055 at 92f53c4c onto ef648e01, preserving contributor attribution and current main. Focused maintainer fixes reuse shared input ceilings, preserve late root context through outer bootstrap, bound frontmatter before immutable parsing, and assert real oversized input in the limits workflow.
- Ask class-specific first-touch questions (instruction, test, prose,
config, code); code questions are unchanged.
- Credit a completed Glob/Grep/LS or shell search from the current human
turn that covered the target; Read and exclusion globs never count.
- Collapse same-class new-file creations in one directory within a turn.
- Add opt-in GATEGUARD_FACT_FORCE_MAX_DENIALS session cap (from #2755).
- Always gate sensitive targets, judged on lexical and real paths.
- Canonicalize checked-path keys.
Closes#2608
Co-authored-by: SulimanAbdulrazzaq <suliman9000a@gmail.com>
hooks/hooks.json already ships only schema-valid keys with metadata in the
hooks.metadata.json sidecar. Add scripts/ci/check-hooks-schema-keys.js, a
strict allowlist check that fails when hooks/hooks.json or
hooks/codex-hooks.json carry any key outside their loader's documented set,
wire it into the npm test chain, and cover it with fixture tests.
Refs #3138, #3114
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.
Deterministic UserPromptSubmit gate: at >=90% context occupancy, inject a
mandatory checkpoint protocol (clean stopping point, structured RESUME.md,
one-line resume command, close session) instead of per-turn advisory
stop suggestions. Escalates to immediate checkpoint at >=96%. Silent below
threshold; fails open silent. Reuses transcript-context.js for measurement.
Move stable hook metadata to a validated sidecar while preserving hook commands and installer identity. Reject moved fingerprints and duplicate IDs, and validate before updating metadata. Independent local review passed at c315271624a1fd055b992f2bff889ad2a0ff8a6b; CI run 34678210149 passed. Rollback: revert this squash commit.
Greptile + CodeRabbit review of #3019:
- config-protection: compare basenames case-insensitively (macOS/Windows
resolve ESLINT.CONFIG.JS to the protected eslint.config.js) and use lstat
so a dangling symlink to a protected name still blocks (os.path.exists
follows the link and returns False).
- Both hooks: fail-open stays, silence goes — every swallowed path now
writes a one-line stderr diagnostic.
- config-protection: sys.stdout.write instead of print() per repo Python
style; block decisions carry a trailing newline.
- New tests/hermes-hooks.test.js: 13 cases through the real scripts via
spawnSync — block (all names, case variants, dangling symlink, edits[],
per-tool), allow (normal source, new config, non-edit tools), fail-open
with diagnostics (malformed payload, missing path, unreadable file).
- docs: absolute-path copy-paste block via $HOME (CodeRabbit: /Users/YOU
placeholders were unverifiable), self-contained block-case proof that
creates its target, pointer to the committed suite.
Hermes ships its own shell-hook system (hooks: block in config.yaml,
Claude-compatible JSON payloads, per-tool matchers, consent allowlist),
and the hermes install target deliberately ships no hook runtime — so
Hermes operators get rules/skills/commands with zero hooks. This ports
the two harness-independent ECC hooks as self-contained Python scripts
with no ECC runtime dependency:
- config-protection: blocks edits to existing lint/format configs and
ratchet baselines (pre_tool_call)
- check-console-log: warns on console.log() in edited TS/JS (post_tool_call)
Includes install, consent, and verification steps in docs/HERMES-HOOKS.md.
The guided installer asks how ECC hooks should run, but that consent
lived only in the wizard path. Running install-apply directly with a
profile that includes hooks-runtime still materialized the hook runtime
with no disclosure and no decision.
Gate the apply layer instead, so every entry point is covered:
- disclose the six hook capability groups when a plan would materialize
the hook runtime, and refuse to apply until the caller decides
- --enable-hooks confirms the hook runtime; --no-hooks installs the rest
of the selection without it and records the reduced module closure in
install-state
- surface the pending decision as a dry-run warning
- show the same capability disclosure in the guided installer's plan
preview, so the wizard's hook question states what it is asking about
Plans that never materialize hooks (Kimi, --profile minimal,
--without baseline:hooks) are unaffected and need no flag. Repair and
uninstall operate on already-recorded state and stay unchanged.
The capability taxonomy and the held-materialization behavior come from
Samarjeet Singh Tomar's PR #2634, reworked to fit the single-decision
consent model that shipped with the guided installer in #2649.
Co-Authored-By: Samarjeet Singh Tomar <samar_tomar@hotmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(skill-evolution): wire Skill PostToolUse tracker so skill-health shows real runs (#2463)
recordSkillExecution() had no production callers, so
~/.claude/state/skill-runs.jsonl was never written and
`scripts/skills-health.js --dashboard` always reported 0 runs.
Adds scripts/hooks/skill-run-tracker.js and registers it as an async
PostToolUse hook (matcher: Skill) in posttooluse-dispatcher.js, which is now
the single PostToolUse entrypoint on main.
Addresses the privacy and bounds review on #2555's sibling PR:
- No prompt text is persisted. task_description is synthesized as
"Skill invocation: <skill_id>"; tool_input.task_description/description/
prompt are never read.
- Every persisted string is bounded and charset-restricted. A skill id is an
identifier, so free text, newlines, or an over-long value are dropped rather
than truncated and written through.
- The JSONL sink is created 0600 and re-tightened on each append, repairing
files written before this bound existed.
- The sink is capped at MAX_RUN_RECORDS (5000), trimmed oldest-first, so the
append-only file can no longer grow without limit.
Tests cover the privacy guarantee (no prompt text reaches a record), the
identifier bounds, the file mode on POSIX, and the retention cap.
* fix(skill-evolution): re-register the tracker for PostToolUseFailure
The rebase onto current main dropped the hooks.json entry, which silently
resurrected the P1 from the earlier review round: deriveOutcome() still
branches on hook_event_name === 'PostToolUseFailure', but the PostToolUse
dispatcher does not fan that event out, so the branch was unreachable in
production. Hard Skill failures were dropped from telemetry entirely, which
inflates the dashboard success rate — the opposite of what #2463 asks for.
Restores the dedicated PostToolUseFailure entry (matcher Skill, id
post:skill:track, same run-with-flags wrapper and standard,strict gating as
the dispatcher registration). Verified end-to-end: a PostToolUseFailure
payload piped through run-with-flags now records outcome "failure".
Adds a regression test asserting the registration so a future rebase cannot
quietly drop it again.
---------
Co-authored-by: haelyra <49814733+haelyra@users.noreply.github.com>
Feedback sent from the canvas only reached an agent through a live
/api/await long poll. When a turn ended with no await parked,
queueFeedback wrote the message to sessions.json and nothing ever
consumed it, so sending appeared to do nothing at all. The presence pill
made it worse: workingKeys had no expiry and the feedback handler never
broadcast presence, so it froze on "agent working" while nobody was
listening.
Delivery:
- Add the stop:plan-canvas-pending hook. It drains undelivered feedback
and blocks the Stop, handing the messages to the agent, so a canvas
message lands even when no await is running. Scoped to sessions under
cwd so parallel agents cannot swallow each other's feedback; set
ECC_PLAN_CANVAS_STOP_SCOPE=all to widen. Honors stop_hook_active and
fails open on every error path.
- run-with-flags.js did not await a hook's run(), so any async hook
silently degraded to pass-through. Fixed; plan-canvas-pending is the
only async hook today.
Presence and indicators:
- Presence is now ended/typing/thinking/listening/queued/waiting.
thinking and typing self-expire (90s/30s) and a 5s sweep pushes the
decay to an idle browser, so the pill can no longer stick.
- Broadcast presence when feedback is queued, and clear the activity
state when an agent reply lands.
- Add POST /api/session/:key/typing so agents can drive the indicator.
- Chat shows an animated dots bubble for thinking and typing, plus an
explicit note when a message is queued with nobody listening.
Respects prefers-reduced-motion.
- Send status reports what actually happened instead of always claiming
the agent will pick it up.
CLI and skill:
- Add `ecc-plan-canvas pending` and `typing <file> --state ...`.
- SKILL.md documents background await as the primary pattern and makes
replying in the canvas mandatory.
Tests: 6 new server cases covering queued presence, the typing endpoint,
state expiry and the sweep, plus a new hook suite covering delivery,
drain-once, stop_hook_active, cwd scoping and fail-open.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Preserve complete Stop-hook stdout through lifecycle wrappers, wait for queued output to flush before exiting, bound child output with a larger explicit buffer, and add end-to-end regressions for large, multibyte, dry-run, and failure cases.