189 Commits

Author SHA1 Message Date
Affaan Mustafa
940135ea47 feat: add ECC statusline observability hooks
Salvages the useful statusline/context monitor work from stale PR #1504 while preserving the current continuous-learning hook runner wiring.

Adds the metrics bridge, context monitor, statusline script, shared cost/session bridge utilities, and tests. Fixes the reviewed false loop-detection hash collision for non-file tools, avoids default-session cost inflation, sanitizes statusline task lookup, and records hook payload session IDs in cost-tracker.
2026-05-11 23:44:06 -04:00
Affaan Mustafa
e9c8845833 feat: add Astraflow provider support 2026-05-11 23:21:46 -04:00
Affaan Mustafa
03108bea62 fix: scope SessionStart context injection 2026-05-11 22:56:29 -04:00
Affaan Mustafa
67a8b914ee test: harden mcp health port readiness 2026-05-11 22:40:19 -04:00
Affaan Mustafa
4220f1b064 test: relax InsAIts monitor timeout 2026-05-11 19:38:21 -04:00
Affaan Mustafa
c45aeee57f
fix: salvage remaining stale queue fixes (#1754) 2026-05-11 16:41:08 -04:00
Affaan Mustafa
f442bac8c9
fix: port Windows hook safety fixes (#1719) 2026-05-11 03:56:51 -04:00
Affaan Mustafa
12e1bc424d
fix: port continuous-learning observer fixes
Ports continuous-learning observer signal, storage, remote normalization, and v1 deprecation fixes onto current main.
2026-05-11 03:35:42 -04:00
Affaan Mustafa
1abc3fb381
fix: port hook session and dashboard safety fixes
Ports suggest-compact session_id isolation and dashboard terminal/document launch safety onto current main.
2026-05-11 02:53:28 -04:00
Affaan Mustafa
7b964402ee
fix: bypass GateGuard file gates in subagents (#1710) 2026-05-11 01:51:24 -04:00
Michael
600072ebd8
fix(hooks): resolve MCP health-check spawn ENOENT on Windows (#1456)
* fix(hooks): resolve MCP health-check spawn ENOENT on Windows

On Windows, commands like 'npx' are batch files (npx.cmd) that require
shell expansion to resolve via PATH. Without shell: true, Node.js
spawn() fails with ENOENT.

However, absolute paths (e.g. C:\Program Files\nodejs\node.exe) must
NOT use shell mode because cmd.exe misparses paths containing spaces.

Fix: enable shell mode only for non-absolute commands on Windows, using
path.isAbsolute() to distinguish. This matches how attemptReconnect()
already handles the shell option.

Fixes #1455

* fix(hooks): harden Windows shell spawn — validate command for metacharacters

Addresses bot review feedback on PR #1456:

- Add UNSAFE_SHELL_CHARS regex to guard against shell injection when
  needsShell=true: cmd.exe operators (&, |, <, >, ^, %, !, (), ;,
  whitespace) are rejected before shell mode is enabled
- Add typeof command === 'string' check so path.isAbsolute() cannot
  throw on malformed non-string command values
- Rename test to 'via PATH resolution' (not Windows-only; runs all platforms)
- Fix misleading test comment: 'node' resolves via PATH like npx.cmd but
  does not itself use .cmd; comment now accurately reflects the intent

* fix(hooks): kill full process tree on Windows when shell mode is used

When needsShell=true, the spawned child is cmd.exe. Calling child.kill()
only terminates the shell, leaving the real server process orphaned.

Use taskkill /PID <pid> /T /F on Windows+shell to kill the entire
process tree rooted at cmd.exe. Fall back to SIGTERM+SIGKILL on all
other platforms or when shell mode is not active.

* fix(hooks): fall back to child.kill() when taskkill fails

Windows taskkill can fail if it's not on PATH, the process already
exited, or permissions are denied. Previously the failure was silently
ignored and no kill signal reached the child.

Now: capture the spawnSync result and fall back to child.kill('SIGKILL')
on any taskkill error or non-zero status. This still may leak a
detached server process but at least guarantees the cmd.exe shell is
signaled.
2026-05-11 01:13:37 -04:00
Affaan Mustafa
bb40978e31 fix: show correct gateguard hook recovery id 2026-04-30 11:26:15 -04:00
Affaan Mustafa
7c5452f4fa fix: keep gateguard destructive gate strict 2026-04-30 11:26:15 -04:00
Affaan Mustafa
cfe770a735 fix: add gateguard recovery escape hatch 2026-04-30 11:26:15 -04:00
Affaan Mustafa
b1456bd954 fix: cap session-start context injection 2026-04-30 08:41:52 -04:00
Affaan Mustafa
95bef977c1 fix: fail open on gateguard state write errors 2026-04-30 08:15:27 -04:00
Affaan Mustafa
d26d66fd3b fix: inject learned skills at session start 2026-04-30 01:31:41 -04:00
Affaan Mustafa
9627c201c7 test: harden mcp health http probe fixture 2026-04-29 23:05:17 -04:00
Affaan Mustafa
1188aeafc4 fix: refine gateguard destructive git detection 2026-04-29 22:41:22 -04:00
Affaan Mustafa
0dcde13384 fix: parse block-no-verify flags by shell words 2026-04-29 21:59:12 -04:00
Affaan Mustafa
3fadc37802 fix: route continuous learning observe hooks through node 2026-04-29 21:28:59 -04:00
Affaan Mustafa
c3ea7a1e5e
fix: preserve gateguard concurrent state writes (#1623) 2026-04-29 19:31:11 -04:00
Affaan Mustafa
468c755abd test: extend insaits monitor subprocess timeout 2026-04-29 19:25:18 -04:00
Affaan Mustafa
8c7e6611e0 test: cover gateguard edge paths 2026-04-29 19:08:47 -04:00
Affaan Mustafa
b5bdd9352f fix: run pre-bash linters through windows wrappers 2026-04-29 18:59:10 -04:00
Affaan Mustafa
ebf0d4322b test: support windows pre-bash linter shims 2026-04-29 18:36:33 -04:00
Affaan Mustafa
015b00b8fc test: stabilize mcp health crash probes 2026-04-29 18:29:02 -04:00
Affaan Mustafa
51511461f6 test: cover pre-bash commit quality edges 2026-04-29 18:28:56 -04:00
Affaan Mustafa
33edfd3bb3 test: cover session activity tracker edge paths 2026-04-29 18:15:51 -04:00
Affaan Mustafa
f92dc544c4 test: cover mcp health edge paths 2026-04-29 18:08:45 -04:00
Affaan Mustafa
1c2d5dd389 fix: fail open on insaits monitor errors 2026-04-29 18:03:33 -04:00
Affaan Mustafa
63485a26bf fix: support windows insaits python shims 2026-04-29 17:53:07 -04:00
Affaan Mustafa
fe40a3d27b test: cover hook bootstrap and InsAIts monitor 2026-04-29 17:45:22 -04:00
Affaan Mustafa
fd95cf6b29 fix: retry observer wait after signal 2026-04-28 22:11:47 -04:00
Affaan Mustafa
601c626b03
Merge pull request #1495 from ratorin/fix/session-end-transcript-path-isolation
fix(hooks): isolate session-end.js filename using transcript_path UUID (#1494)
2026-04-21 18:14:23 -04:00
Vishnu Pradeep
b27551897d
fix(hooks): wrap SessionStart summary with stale-replay guard (#1536)
The SessionStart hook injects the most recent *-session.tmp as
additionalContext labelled only with 'Previous session summary:'.
After a /compact boundary, the model frequently re-executes stale
slash-skill invocations it finds inside that summary, re-running
ARGUMENTS-bearing skills (e.g. /fw-task-new, /fw-raise-pr) with the
last ARGUMENTS they saw.

Observed on claude-opus-4-7 with ECC v1.9.0 on a firmware project:
after compaction resume, the model spontaneously re-enters the prior
skill with stale ARGUMENTS, duplicating GitHub issues, Notion tasks,
and branches for work that is already merged.

ECC cannot fix Claude Code's skill-state replay across compactions,
but it can stop amplifying it. Wrap the injected summary in an
explicit HISTORICAL REFERENCE ONLY preamble with a STALE-BY-DEFAULT
contract and delimit the block with BEGIN/END markers so the model
treats everything inside as frozen reference material.

Tests: update the two hooks.test.js cases that asserted on the old
'Previous session summary' literal to assert on the new guard
preamble, the STALE-BY-DEFAULT contract, and both delimiters. 219/219
tests pass locally.

Tracked at: #1534
2026-04-21 18:02:19 -04:00
Taro Kawakami
01d816781e review: apply sanitizeSessionId to UUID shortId, fix test comment
- Route the transcript-derived shortId through sanitizeSessionId so the
  fallback and transcript branches remain byte-for-byte equivalent for any
  non-UUID session IDs that still land in CLAUDE_SESSION_ID (greptile P1).
- Clarify the inline comment in the first regression test: clearing
  CLAUDE_SESSION_ID exercises the transcript_path branch, not the
  getSessionIdShort() fallback (coderabbit P2).

Refs #1494
2026-04-19 14:30:00 +09:00
Taro Kawakami
93cd5f4cff review: address P1/P2 bot feedback on shortId derivation
- Use last-8 chars of transcript UUID instead of first-8, matching
  getSessionIdShort()'s .slice(-8) convention. Same session now produces the
  same filename whether shortId comes from CLAUDE_SESSION_ID or transcript_path,
  so existing .tmp files are not orphaned on upgrade.
- Normalize extracted hex prefix to lowercase to avoid case-driven filename
  divergence from sanitizeSessionId()'s lowercase output.
- Explicitly clear CLAUDE_SESSION_ID in the first regression test so the env
  leak from parent test runs cannot hide the fallback path.
- Add regression tests for the lowercase-normalization path and for the case
  where CLAUDE_SESSION_ID and transcript_path refer to the same UUID (backward
  compat guarantee).

Refs #1494
2026-04-19 14:19:29 +09:00
Taro Kawakami
a35b2d125d fix(hooks): isolate session-end.js filename using transcript_path UUID
When session-end.js runs and CLAUDE_SESSION_ID is unset, getSessionIdShort()
falls back to the project/worktree name. If any other Stop-hook in the chain
spawns a claude subprocess (e.g. an AI-summary generator using 'claude -p'),
the subprocess also fires the full Stop chain and writes to the same project-
name-based filename, clobbering the parent's valid session summary with a
summary of the summarization prompt itself.

Fix: when stdin JSON (or CLAUDE_TRANSCRIPT_PATH) provides a transcript_path,
extract the first 8 hex chars of the session UUID from the filename and use
that as shortId. Falls back to the original getSessionIdShort() when no
transcript_path is available, so existing behavior is preserved for all
callers that do not set it.

Adds a regression test in tests/hooks/hooks.test.js.

Refs #1494
2026-04-19 11:37:32 +09:00
Affaan Mustafa
ccecb0b9f4 fix: restore string hook commands for Claude Code schema 2026-04-15 17:25:33 -07:00
Affaan Mustafa
1fabf4d2cf fix: consolidate bash hooks without fork storms 2026-04-14 21:23:57 -07:00
Affaan Mustafa
5427c27930
Merge pull request #1445 from affaan-m/fix/plugin-installed-hook-root-resolution
fix: resolve plugin-installed hook root on marketplace installs
2026-04-14 20:43:40 -07:00
Affaan Mustafa
1b7c5789fc fix: bootstrap plugin-installed hook commands safely 2026-04-14 20:24:21 -07:00
Affaan Mustafa
8776c4f8f3 fix: harden urgent install and gateguard patch 2026-04-14 19:44:08 -07:00
Affaan Mustafa
76b6e22b4d fix: unblock urgent install and gateguard regressions 2026-04-14 19:23:07 -07:00
Affaan Mustafa
e0ddb331f6
Merge pull request #1367 from ozoz5/feat/gateguard
feat(hooks,skills): add gateguard fact-forcing pre-action gate
2026-04-13 01:05:20 -07:00
Affaan Mustafa
6c67566767 fix: keep gateguard session state alive 2026-04-13 00:58:50 -07:00
Affaan Mustafa
2e44beabc1 test: isolate gateguard state dir cleanup 2026-04-13 00:53:57 -07:00
seto
dd2962ee92 fix: 5 bugs + 2 tests from 3-agent deep bughunt
Bugs fixed:
- B1: JS gate messages still said "cat one real record" -> redacted/synthetic
- B2: Destructive bash key used 200-char truncation (collision bypass) -> SHA256 hash
- B3: sanitizePath only stripped \n\r -> now strips null bytes, bidi overrides, all control chars
- B4: Tool name matching was case-sensitive (latent bypass) -> lookup map normalization
- B5: SKILL.md Gate Types missing MultiEdit -> added with explanation

Tests added:
- T1: MultiEdit gate denies first unchecked file (CRITICAL - was untested)
- T2: MultiEdit allows after all files gated

11/11 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 16:32:46 +09:00
seto
5540282dcb fix: remove unnecessary disk I/O + fix test cleanup
- isChecked() no longer calls saveState() — read-only operation
  should not write to disk (was causing 3x writes per tool call)
- Test cleanup uses fs.rmSync(recursive) instead of fs.rmdirSync
  which failed with ENOTEMPTY when .tmp files remained

9/9 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:41:58 +09:00