Commit Graph
4429 Commits
Author SHA1 Message Date
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 a438c2e24f Merge reviewed PR #3670
# Conflicts:
#	manifests/context-packs/skill-triggers@1.json
2026-11-05 23:10:37 -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 932d83073e Merge reviewed PR #3858 2026-11-05 23:10:32 -05:00
haelyra a222e0091b Merge reviewed PR #3849 2026-11-05 23:10:32 -05:00
haelyra 1289b49df2 Merge reviewed PR #3835
# Conflicts:
#	.pi/extensions/index.ts
2026-11-05 23:10:20 -05:00
haelyra 02e99f5be4 Merge reviewed PR #3833 2026-11-05 23:09: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
haelyra 14221ef652 Merge reviewed PR #3881 2026-11-05 23:09:32 -05:00
haelyra 9ac25823ff Merge reviewed PR #3857 2026-11-05 23:09:32 -05:00
haelyra a608b1f798 Merge reviewed PR #3827 2026-11-05 23:09:32 -05:00
haelyra b2018455d5 Merge reviewed PR #3855 2026-11-05 23:09:32 -05:00
haelyra 612cba644a Merge reviewed PR #3824 2026-11-05 23:09:31 -05:00
Cheese 4385863e56 fix(scripts): reject inherited package manager names 2026-11-06 11:52:10 +08: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
Rahul Selvaraj feac4f52ba fix(hooks): match the full classifier notice, isolate test env
CLASSIFIER_NOTICE matched by prefix, so a pasted notice followed by a
user question was dropped from both summary paths. Anchor it to the
whole message so trailing user text is kept, and add a regression test.

Also pass ECC_SKIP_LLM_SUMMARY=1 in the withTranscript fixture helper so
an inherited ECC_LLM_SUMMARY_INTERVAL=1 cannot trigger claude -p.

Refs #3867

Assisted-by: Claude <noreply@anthropic.com>
2026-11-06 08:47:21 +08: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
Karim Masmoudi f0f68e6307 fix(continuous-learning-v2): redact short-payload JWTs and suffixed sk- keys
A JWT with a short claims segment such as e30 ({}) matched neither the
full JWT branch nor the cut-tail branch and was saved as is. The payload
segment now only needs one character.

A generic sk- key followed by "-" or "_" failed its lookahead and was
skipped whole. It is now redacted to the end of the token. Branch names
like sk-learn-upgrade stay readable because they have fewer than 20
alphanumerics after the prefix.

Adds a test that the two pattern copies in observe.sh are identical and
that they run in linear time on 300 KB of adversarial input (#2278).
2026-11-05 14:15:21 +01:00
L4XB 32284723b2 test(hooks): move the output summary tests into their own file
The redaction and privacy cases grew session-activity-tracker.test.js to 845 lines, past the 800 that AGENTS.md allows. They move to session-activity-tracker-output.test.js; the original file is back to 758 lines.
2026-11-05 13:29:55 +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
L4XB 49b390d243 fix(docs-governance): hide only comments that cannot cross a container
A comment that opened after text in a list item and closed in a later
block quote hid the live link between them, because the paragraph check
only looked for blank lines. Read a comment across lines only where
CommonMark makes it a top-level HTML block, a `<!--` at column 0 after a
blank line, which only its closer ends. Elsewhere a comment is hidden
only when it closes on the line it opens on, so every other line stays
audited Markdown. The fence pass uses the same rule for comment blocks.

Drop the container and ordered-list heuristics this replaces, refresh
the registry digest, and keep the three copies of the script identical.
2026-11-05 11:17:47 +01:00
L4XB 0d12254a25 Merge remote-tracking branch 'origin/main' into fix/docs-governance-html-comments
# Conflicts:
#	manifests/context-packs/skill-triggers@1.json
2026-11-05 11:14:20 +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
L4XB 04f32e06e7 Merge remote-tracking branch 'origin/main' into fix/shell-split-newlines 2026-11-05 10:27:19 +01:00
L4XB 80a26c2ceb fix(hooks): read $$ as the process ID before looking for $'...'
In `echo $$'\'; npm run dev`, Bash reads `$$` as the process-ID parameter
and the quote after it as an ordinary single quote, so it runs
`npm run dev`. The splitter took the second `$` as the start of ANSI-C
quoting, which hid the semicolon, and a here-document delimiter such as
`$$'EOF'` was read as `$EOF`, so the body never ended. Consume the `$$`
pair first in both places.
2026-11-05 10:27:19 +01:00
haelyra 7a0188db61 fix(hooks): honor Bash quote boundaries in dev guard
(cherry picked from commit f4bf43c550)
2026-11-05 10:23:23 +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
Rahul Selvaraj a08d5da8c9 fix(hooks): skip safety-classifier notices in session summaries
When a response is stopped by the safety classifier, the harness records
a notice ("Your response above was stopped by a safety classifier ...")
as a user entry in the transcript. session-end.js kept it as a user
message, so it was written under "### Tasks" and re-injected by
session-start.js on the next session.

userMessageText() now drops entries that start with that notice, next
to the existing HARNESS_NOISE filter. User messages that only mention
the phrase are kept, since the match is anchored to the start.

Fixes #3867

Assisted-by: Claude <noreply@anthropic.com>
2026-11-04 19:29:32 +08:00
Karim Masmoudi 0cc2864818 fix(continuous-learning-v2): redact PEM blocks before the keyword matcher
With a label in front, as in secret=-----BEGIN RSA PRIVATE KEY-----, the
keyword matcher replaced only "-----BEGIN" and the PEM pattern could no
longer find its opening marker, so the key body was persisted. This was
already the case on main. Move the PEM pattern into _PEM_RE and run it
first in both the observation path and the parse-error fallback.
2026-11-04 12:08:44 +01:00
Karim Masmoudi caeb65b1ee fix(continuous-learning-v2): redact keyword-labeled values to the end of the token
Running the shape patterns first left suffixes visible: in
password=sk-...<dot>suffix or token=ghp_.../suffix the shape match stopped
at the separator and the inserted "[REDACTED]" kept the keyword matcher
from covering the rest.

Go back to keyword-first and drop the 256-char cap on the keyword value
instead. Its class is disjoint from the separators, so it can run to the
end of the token in linear time. A long labeled key, a labeled password
that starts with a shaped token, and a labeled JWT cut inside a long
payload are now redacted whole.
2026-11-04 11:56:35 +01:00
Karim Masmoudi 16a23737f2 fix(continuous-learning-v2): run shape patterns before the keyword matcher
_SECRET_RE stops after 256 value chars. With it first, a longer
keyword-labeled key such as OPENAI_API_KEY=sk-proj-... lost its prefix
and the shape pattern could no longer see the rest, so the tail was
persisted. Running _SECRET_VALUE_RE first fixes both the observation
path and the parse-error fallback; "[REDACTED]" is outside the keyword
value class, so the second pass leaves it alone.
2026-11-04 11:43:29 +01:00
Karim Masmoudi ac89d627b4 fix(continuous-learning-v2): redact long sk- keys and JWTs whole, cut tails only when cut
The sk- and JWT branches capped their token classes at 512 and 1024
chars, so a longer value was only partly replaced. Their classes do not
overlap with the separators, so they can run to the end of the token
and still match in linear time.

The end-of-text match for a key or JWT cut by truncation moves to its
own pattern, applied only when the capture was actually shortened.
Short output that happens to end in "sk-learn" or a one-segment eyJ
blob stays readable.
2026-11-04 11:27:24 +01:00
AlexisLeDain 676f3f3daf docs: exempt deliberate boundaries from the second-caller rule
As written, the bullet banned any interface with a single implementation,
which contradicts the Repository Pattern in rules/common/patterns.md: it
requires business logic to depend on an abstract repository interface,
and a project backed by one database has exactly one implementation.

Scope the rule to speculative abstractions and name the exemption, so the
two files in rules/common/ no longer give opposite instructions.
2026-11-04 09:42:54 +01:00
Gaurav DubeyandClaude Opus 5.5 4d3e66e0ab fix(hooks): redact joined-fragment secret values and make JWT scan linear
- Replace the secret=/api_key= value regex with a single-pass, quote-aware
  scanner so the whole Bash word is redacted when quoted and unquoted
  fragments are joined (e.g. --secret='prefix-'suffix), while a value inside
  an enclosing quoted string stops at that string's closing quote.
- Searching for the keyword itself (grep -n "secret =" file,
  rg 'api_key:' dir) no longer redacts the rest of the command.
- Use a lookbehind instead of \b before the JWT header so long dot-free
  ey-ey-... runs are scanned in linear time instead of quadratic.
- Add regression tests for joined fragments, keyword searches, and the
  ey- performance case.

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