Commit Graph
527 Commits
Author SHA1 Message Date
haelyra ae9ce433cd fix(hooks): harden context-gate checkpoint ownership (#3106)
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.
2026-11-16 21:11:56 -05:00
haelyra 9f770ae5a1 chore(hooks): merge main into context-gate carry-forward (#3106) 2026-11-16 20:55:33 -05:00
haelyra 4df78f0f64 fix: enforce read-only metadata and separate shell token data 2026-11-16 14:11:51 -05:00
haelyra 88b550f4b0 Merge remote-tracking branch 'origin/pr-3931' into stewardship/20261116 2026-11-16 13:37:29 -05:00
haelyra 0d5391a486 Merge remote-tracking branch 'origin/pr-3932' into stewardship/20261116 2026-11-16 13:24:55 -05:00
haelyra df287caae9 Merge remote-tracking branch 'origin/pr-3914' into stewardship/20261116 2026-11-16 13:24:34 -05:00
haelyra f2f3375838 Merge remote-tracking branch 'origin/pr-3921' into stewardship/20261116
# Conflicts:
#	manifests/context-packs/skill-triggers@1.json
2026-11-16 13:24:32 -05:00
haelyra 88e8a4db07 Merge remote-tracking branch 'origin/pr-3894' into stewardship/20261116 2026-11-16 13:20:47 -05:00
Neo e6538e2428 fix(hooks): scope MCP health cache to the resolved server 2026-11-13 15:17:12 -05:00
montjeffrey 00bd41a414 feat(context): list installed non-ECC skills next to ECC's selection
ECC's selection, candidates, fallback and receipt stay unchanged. Installed non-ECC skills that also match the task are listed as companions in the resolver result, the ecc profile run launch input and the opt-in suggestion hook, so the host can use ECC's skill and the user's own together. A companion clears the automatic-load score bar and either has a matched word in its name or leads every other neighbor by the existing auto-admission margin. No constant changes.

ecc profile neighbors snapshots the provider home's other skills, including the project's own .claude/skills for Claude, and --neighbors or ECC_CONTEXT_NEIGHBORS passes the snapshot in.
2026-11-13 10:42:21 -05:00
yuhoyuho 322e347a86 fix(gateguard): gate DROP DATABASE, DROP SCHEMA and ALTER TABLE ... DROP COLUMN
DESTRUCTIVE_SQL matched only DROP TABLE, DELETE FROM and TRUNCATE.
`psql -c "DROP DATABASE prod"`, `DROP SCHEMA public CASCADE` and
`ALTER TABLE users DROP COLUMN email` went to the routine gate instead
of the destructive gate, even though each loses at least as much data
as DROP TABLE.

Add DROP DATABASE, DROP SCHEMA and an ALTER TABLE ... DROP COLUMN arm
to the phrase check. The DROP COLUMN arm stops at `;` so it never
matches across two statements. It requires the COLUMN keyword so
ALTER COLUMN ... DROP DEFAULT / DROP NOT NULL stay passive. Existing
literal and quote stripping keeps SQL strings, commit messages and
echo mentions passive.

Update the gateguard trigger list (en, ja-JP, zh-CN) and rebind the
skill-triggers registry digest for the SKILL.md body edit. Skill
descriptions and triggers are unchanged.
2026-11-12 01:08:39 +09:00
Afloat 87b4eed5c1 fix(metrics): fingerprint and track native notebook edits 2026-11-11 21:39:50 +08:00
Angga Julyananda Pradana b37b73248b fix(hooks): preserve Git built-ins with same-name aliases 2026-11-08 12:20:15 +07:00
Angga Julyananda Pradana 69e9facd5a fix: block command-supplied Git alias invocations 2026-11-08 11:45:35 +07:00
haelyra f5ff589cd1 fix: close remaining integration security gaps 2026-11-06 00:10:49 -05:00
haelyra bfb4dbe7b0 fix: harden integration security findings 2026-11-06 00:03:44 -05:00
CarbonPyramid 5a565cf1d1 fix(hooks): bind context-gate checkpoint to real identity; frame handoff as a proposal
Round-6 ownership revision for the enforce-mode checkpoint (PR #3106,
@haelyra requested-changes on fffda19).

1. Require real handoff identity, preserve an occupied destination.
   - resolveCheckpointPath -> resolveCheckpointIdentity: drops the literal
     'project'/'session' fallbacks. A session id (input.session_id or a
     session env override) AND a project are now required; when neither
     resolves it returns null and the hook declines enforcement, so two
     same-named projects with no session id can no longer collide on one
     shared <sessions>/resume/project-session.md path.
   - New pickOwnedDestination + readOwnerSession: before targeting an
     existing destination the gate checks an ecc-handoff ownership marker.
     A file owned by this session is reused (idempotent); an unmarked,
     unreadable, or foreign-owned file is never overwritten — the gate
     disambiguates to a sibling (-2, -3, ...) or declines.
   - Missing-identity fire now emits a degraded advisory (buildDeclineText):
     it names no checkpoint path and orders no write, but still warns and
     tells the operator to set ECC_SESSION_ID — not a silent drop.

2. Report a proposed handoff until a write is verified.
   - buildOrderText no longer calls the resume command a completed "receipt".
     The checkpoint is a PROPOSAL; the resume command is gated on an explicit
     "verify the file exists and is non-empty" step. The model is instructed
     to stamp the exact ownership marker (session+project) and record the
     source revision (git rev-parse HEAD), binding the handoff to a revision.

Tests: existing buildOrderText case extended for proposal framing; three new
disposable, sandboxed (ECC_AGENT_DATA_HOME) ownership cases — missing-identity
same-named projects with a pre-existing destination that survives byte-for-byte,
foreign-owned destination disambiguated, same-owner destination reused. Full
suite 4765/4765 serial.
2026-11-05 22:51:16 -06:00
haelyra a032472448 Merge reviewed PR #2856
# Conflicts:
#	manifests/context-packs/skill-triggers@1.json
2026-11-05 23:28:21 -05:00
haelyra 001df488e5 fix: reconcile reviewed integration repairs and generated catalogs 2026-11-05 23:26:12 -05:00
haelyra c9ebc0f2d1 Merge reviewed PR #3853
# Conflicts:
#	scripts/hooks/run-with-flags.js
2026-11-05 23:24:32 -05:00
haelyra cf5c041ea8 Merge reviewed PR #3848 2026-11-05 23:24:06 -05:00
haelyra 8b19acc97d Merge reviewed PR #3819
# Conflicts:
#	tests/hooks/block-no-verify.test.js
2026-11-05 23:12:26 -05:00
haelyra 01e4f8bd44 Merge reviewed PR #3864 2026-11-05 23:11:09 -05:00
haelyra fceb970215 Merge reviewed PR #3862 2026-11-05 23:11:09 -05:00
haelyra 75322d5bb0 Merge reviewed PR #3675 2026-11-05 23:11:08 -05:00
haelyra 5d64ad64f3 Merge reviewed PR #3672
# Conflicts:
#	scripts/hooks/pre-bash-commit-quality.js
2026-11-05 23:10:59 -05:00
haelyra 912fc63c41 Merge reviewed PR #3671 2026-11-05 23:10:45 -05:00
haelyra 632aeb4d76 Merge reviewed PR #3663 2026-11-05 23:10:32 -05:00
haelyra ab10daba18 Merge reviewed PR #3870 2026-11-05 23:10:32 -05:00
haelyra a222e0091b Merge reviewed PR #3849 2026-11-05 23:10:32 -05:00
haelyra 22596737f7 Merge reviewed PR #3829 2026-11-05 23:09:32 -05:00
haelyra 759a3ba299 Merge reviewed PR #3822 2026-11-05 23:09:32 -05:00
haelyra 44de2e5996 Merge reviewed PR #3814 2026-11-05 23:09:32 -05:00
Gaurav DubeyandClaude Opus 5.5 f0eee4b543 fix(hooks): redact JWTs joined to an underscore-prefixed label
The JWT chain scanner only accepted a header at the start of a segment or
after `-`, so `session_<JWT>` reached the audit and cost logs unredacted.
Treat `_` as a prefix boundary too and cover it in the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 03:30:52 +00:00
CarbonPyramid fffda19ce6 fix(hooks): make context-gate enforcement opt-in; route checkpoint through handoff dir
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.
2026-11-05 12:30:26 -06:00
L4XB fee3d08666 fix(hooks): drop line continuations before checking text after a commit here-document
In double quotes Bash drops a backslash-newline before it expands
anything, so a tail of `$\<newline>HOME` after the substitution's `)` is
`$HOME` and expands. The expansion check read the tail with the
continuation still in it and saw an escaped newline, so the hook
validated `fix: a$HOME` with no warning. Continuations are now dropped
first, while other escapes stay for the check: `\$\<newline>HOME` is
still the literal `$HOME`.
2026-11-05 14:36:26 +01:00
L4XB 2ff19fafa0 fix(hooks): read text after a commit here-document's substitution
In `-m "$(cat <<'EOF' … EOF\n)."` Bash drops the body's trailing newlines
and adds the period, so Git records `fix: update input.`, but the hook
checked only the here-document and missed the trailing-period warning.
Read the rest of the quoted value after the substitution's `)` and add
it to the message as double-quoted text. Commands or an expansion after
the here-document make the message unverifiable, as an expansion in an
unquoted body already does. The here-document reading moves into
readHeredocMessage, which also returns the Bash 3.2 note.
2026-11-05 13:22:57 +01:00
L4XB 34e41430b1 perf(hooks): read the dev guard's segment queue by index
Since expanded here-document segments are queued too, a long substitution puts every segment in the queue, and shift() copied it each time: 130,000 segments took about 20 s, past the hook timeout. An index keeps the walk linear (under 0.3 s).
2026-11-05 13:14:48 +01:00
L4XB 30eb570117 fix(hooks): read NUL-ended delimiters, Bash blanks before #, and long bodies
Bash ends a decoded $'...' string at its first NUL, so `cat <<$'EOF\0X'`
ends at the line EOF, but the splitter looked for EOF\0X and swallowed
the commands after the body. A carriage return or a no-break space is
not a blank to Bash, so `echo foo\r# && npm run dev` runs the dev
server, but the splitter read the # as a comment. And spreading a long
substitution's segments into push() threw RangeError, which the hook's
catch turned into an allow. Truncate the decoded part at the NUL, use
Bash's blanks for word starts, and append the segments one at a time.
2026-11-05 13:07:21 +01:00
L4XB 31866936b9 fix(hooks): keep printf arguments literal, model descriptor copies, charge expansion
printf decoded escapes in %s arguments too, so `printf '%s' 'gi\t push
--no-verify' | sh` read as `gi<tab> push` and passed, while the shell
reads `gi\t` as `git`. Escapes are now decoded in the format and in %b
arguments only. `1<&3` and the move `1>&3-` copy a descriptor like
`1>&3`, so restoring a saved stdout is followed. The format-reuse loop
charges the work budget before each piece, so a short command cannot
expand into a huge string. The bash-backed tests now run what the shell
reads with a stub git, which also sees how the shell unescapes words.
2026-11-05 12:59:29 +01:00
L4XB bf71cdfff1 fix(hooks): follow each producer's descriptors into the shell
A group or pipeline producer counted whatever its redirections said, so
`{ echo 'git push --no-verify' >/dev/null | cat; } | bash` was blocked
although bash reads nothing, and printf filled no %s, so
`printf 'git %s --no-verify\n' push | sh` got through. shell-scan now
keeps a redirection's descriptor, and a stage's output counts only when
its descriptors, the stages after it and an `exec` earlier in its group
take it to the shell; an `exec` is carried only where it adds output.
printf fills %s, %b and %c and reuses its format; other conversions are
read like an unmodeled command. The header states what the model covers.
2026-11-05 12:27:55 +01:00
L4XB ae681a2a66 Merge remote-tracking branch 'origin/main' into fix/block-no-verify-group-piped-into-shell 2026-11-05 12:18:59 +01:00
L4XB a3ced7db06 fix(hooks): keep no structured tool result in activity history
The tracker serialized any structured result with JSON.stringify before
redaction, so an encoding nested in it, such as a double-escaped JSON
token, reached tool-usage.jsonl whole, and Claude Code's Bash stdout went
in as text. Keep text only from the adapter's tool_output, as main did,
and from Claude Code's tool_response only the sizes of stdout and stderr
and its interrupted and image flags. Any other structure is left out.
2026-11-05 11:35:43 +01:00
L4XB 6b9ff09542 Merge remote-tracking branch 'origin/main' into fix/hooks-read-tool-response
# Conflicts:
#	scripts/hooks/hook-input.js
#	tests/hooks/hook-input.test.js
2026-11-05 11:33:26 +01:00
Rahul Selvaraj 846a561a7b fix(hooks): drop classifier notices from LLM summary input
The safety-classifier notice filter only covered the mechanical summary.
When generateSessionSummary runs (low context or message interval),
extractConversationText read the raw transcript and passed the notice to
the LLM as a user turn, so it could still reach saved context.

Move the check into one shared isClassifierNotice() in
scripts/lib/llm-summary.js and use it in both userMessageText() and
extractConversationText(). Add LLM-path regression tests, and split the
session-end classifier-notice tests into small functions (<50 lines).

Refs #3867

Assisted-by: Claude <noreply@anthropic.com>
2026-11-05 18:06:51 +08:00
haelyra 94d2c659ba fix(hooks): scan substitutions nested in expanded here-document bodies
The dev-guard half of 7632669d from #3735: segments that the splitter
reads from an expanded here-document body are scanned again, so a dev
command in a substitution nested inside one is still found.

(split from commit 7632669d28)
2026-11-05 11:05:56 +01:00
L4XB 4ae1f0d812 Merge remote-tracking branch 'origin/main' into fix/commit-quality-subject-line 2026-11-05 10:49:41 +01:00
L4XB 8c67067582 fix(hooks): join continued lines of a commit here-document as bash does
In an unquoted here-document, Bash removes a backslash-newline before Git
receives the message, so `fix: \` followed by `Update input.` commits
`fix: Update input.`, and a delimiter line right after a continued line
does not end the body. Read the body that way, keep `<<-` from stripping
the tabs of a continued line, and drop the backslash before $, ` and \.

A quoted body stays literal, as Bash 4 and later and zsh read it. Inside
"$(...)", Bash 3.2 joins its lines too, so the hook now notes when that
would change the subject.
2026-11-05 10:49:40 +01:00
haelyra 950f8ce0f3 fix(hooks): validate Bash commit here-document substitutions
The commit-quality half of 7632669d from #3735: a single-quoted -m
message keeps its backslashes, and an unquoted here-document whose body
Bash would expand yields an advisory that the subject cannot be validated
from the literal command.

(split from commit 7632669d28)
2026-11-05 10:43:53 +01:00
Gaurav DubeyandClaude Opus 5.5 71084e0555 fix(hooks): redact JWTs joined to a hyphenated prefix
The lookbehind added to keep the JWT scan linear also skipped tokens right
after a `-`, so `--cookie "session=jwt-<JWT>"` reached the logs unredacted.
Scan each `[A-Za-z0-9_.-]` run once instead, checking every dot segment for
a header at its start or after a `-`, decoding at most once per segment so
long `ey-ey-...` runs stay linear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 03:31:50 +00:00