Commit Graph
13 Commits
Author SHA1 Message Date
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
Muhammad Mirza f6357e73ee test(continuous-learning): override Windows temp vars in marker failure test
Both reviewers noted the marker write-failure test only overrides TMPDIR,
which Node ignores on Windows (os.tmpdir reads TEMP/TMP there), so the
test would fail in the Windows CI lane. Set TEMP and TMP alongside TMPDIR;
on POSIX the extra vars are ignored by os.tmpdir.

Test plan:
- tests/hooks/evaluate-session.test.js: 25 passed, 0 failed
- Windows behavior cannot be verified from this Linux host; the change
  follows both reviewers' prescription exactly.
2026-10-31 23:53:17 +07:00
Muhammad Mirza 3e7b4d74b9 fix(continuous-learning): sync Stop hook and fail-closed delivery marker
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
2026-10-31 23:36:38 +07:00
Muhammad Mirza Kurniawan f82eb1414b fix(continuous-learning): deliver v1 Stop nudge via native Stop contract behind explicit opt-in
The v1 evaluator computed the learning signal but wrote it to stderr, which Claude Code never forwards to the model, so the learned-skills folder was never populated through this path.

Delivery now follows the maintainer-endorsed shape: an explicit stop_nudge_opt_in flag (default off, so existing installs are unchanged), the native Stop block contract (decision block plus reason) instead of plain stdout text, at most one delivery per session via a temp-dir marker, Stop-loop protection via stop_hook_active, and delivery only for sessions with a registered lease from SessionStart.

Tests: 7 new evaluator tests (opt-in off, no lease, one valid block then silence on repeat, stop_hook_active, short session, non-Stop event, missing session id). Evaluator suite 23/23 with the fix, failing on pristine; hooks suite 260/260; Stop stdout contract suite 48/48.

Limits stated plainly: end-to-end delivery in a live Claude Code session is not certified from this host (unit-level spawn plus parse only), and the fix ships inert by default until a user opts in.
2026-10-31 22:40:13 +07:00
Muhammad Zubair b3b13350d1 test: isolate HOME in the test files that write to the real home directory 2026-10-28 12:20:21 +05:00
Pangerkumzuk Longkumer 3d97985559 fix: remove unused execFileSync import (no-unused-vars ESLint) 2026-02-18 07:15:53 +05:30
Affaan Mustafa b3e362105d test: add 3 tests for typeof guard, empty package.json, and learned_skills_path override (round 86)
- loadAliases resets to defaults when aliases field is a truthy non-object (string)
- detectFromPackageJson returns null for empty (0-byte) package.json
- evaluate-session uses learned_skills_path config override with ~ expansion
2026-02-13 12:23:34 -08:00
Affaan Mustafa 8cacf0f6a6 fix: use nullish coalescing for confidence default + add 3 tests (round 85)
Fix confidence=0 showing 80% instead of 0% in patterns() (|| → ??).
Test evaluate-session.js config parse error catch, getSessionIdShort
fallback at root CWD, and precise confidence=0 assertion.
2026-02-13 12:11:26 -08:00
Affaan Mustafa 485def8582 test: add 3 tests for evaluate-session regex, empty rules/skills dirs (Round 65)
- evaluate-session.js: verify regex whitespace tolerance around colon
  matches "type" : "user" (with spaces), not just compact JSON
- validate-rules.js: empty directory with no .md files yields Validated 0
- validate-skills.js: directory with only files, no subdirectories yields
  Validated 0

Total: 800 tests, all passing
2026-02-13 07:04:55 -08:00
Affaan Mustafa ad40bf3aad test: add env var fallback, console.log max matches, and format non-existent file tests
Round 53: Adds 3 hook tests — validates evaluate-session.js
falls back to CLAUDE_TRANSCRIPT_PATH env var when stdin JSON
is invalid, post-edit-console-warn.js truncates output to max
5 matches, and post-edit-format.js passes through data when
the target .tsx file doesn't exist.
2026-02-13 05:34:59 -08:00
Affaan Mustafa 253645b5e4 test: add 22 tests for readStdinJson, evaluate-session config, and suggest-compact hook
- utils.test.js: 5 tests for readStdinJson maxSize truncation, whitespace-only stdin, trailing whitespace, and BOM prefix handling
- evaluate-session.test.js: 4 tests for config file parsing, assistant-only transcripts, malformed JSON lines, and empty stdin
- suggest-compact.test.js: 13 new tests covering counter file creation/increment, threshold suggestion, interval suggestion, env var handling, corrupted/empty counter files, and session isolation
2026-02-13 03:11:51 -08:00
Affaan Mustafa c1919bb879 fix: greedy regex in validate-commands captures all refs per line, add 18 tests
The command cross-reference regex /^.*`\/(...)`.*$/gm only captured the
LAST command ref per line due to greedy .* consuming earlier refs.
Replaced with line-by-line processing using non-anchored regex to
capture ALL command references.

New tests:
- 4 validate-commands multi-ref-per-line tests (regression)
- 8 evaluate-session threshold boundary tests (new file)
- 6 session-aliases edge case tests (cleanup, rename, path matching)
2026-02-13 01:52:30 -08:00