Skip to content

fix(consistency): a Stop hook that could not run is a failed step - #1405

Merged
napetrov merged 6 commits into
intel:mainfrom
napetrov:fix/stop-hook-error
Nov 30, 2026
Merged

napetrov merged 6 commits into
intel:mainfrom
napetrov:fix/stop-hook-error

Conversation

@napetrov

Copy link
Copy Markdown
Contributor

Summary

A Stop hook that cannot start gives no feedback, so the reader saw a clean stop:

stop hook command resolves from the agent's cwd?
  yes -> runs; blocks -> "Stop hook feedback" -> Hook:Stop (failed)   [already handled]
  no  -> exit 127, non-blocking -> system notification key=stop-hook-error
         before: no step (stop looks clean)
         after:  Hook:Stop-error (failed)
  • consistency.py: a stop-hook-error notification with no blocked-stop feedback in the same stop becomes a failed Hook:Stop-error step. A notification right after a blocked stop's feedback stays part of Hook:Stop.
  • parse_run split into _record, _result, _finish to stay under the complexity ratchet (cap 10).
  • docs/run-consistency.md: hook commands should be sh "$CLAUDE_PROJECT_DIR"/.claude/hooks/stop.sh; a relative path follows the agent's cd.
  • Changelog fragment (Fixed).

Evidence

Red then green (tests/test_context_consistency.py):

  • Before the fix: 2 failed (the two error tests), 113 passed.
  • After: 115 passed; after the ratchet refactor, test_growth_ratchet and the consistency tests: 160 passed.

Full suite on 8a51d7dba: 31053 passed, 42 skipped, 0 failed. make ci-local (pre-push): 0 failed, 17 passed, 3 skipped.

Real traces (the degrade Stop-hook arm, haiku-4-5, read with read_run): the 5 runs whose procedure failed with no feedback now show Hook:Stop-error (para_0 twice, para_2, repeat_0, repeat_1). Runs with a blocked stop (para_1, repeat_2) and all 12 rename runs still show Hook:Stop only.

Merge Danger

Door: two-way. Reader output only; no persisted input format changes. A new step kind Hook:Stop-error can appear in consistency results.

Blast Radius: only runs whose Stop hook could not run. Their failed-step count goes up by one per such stop, which can move a pass rate. Other runs are unchanged (their traces have no stop-hook-error notification).

🤖 Generated with Claude Code

A Stop hook whose command does not start (a relative path such as
`sh .claude/hooks/stop.sh` after the agent ran `cd` into a subdirectory)
gives no feedback. Claude Code shows only a `stop-hook-error`
notification and the stop passes. The reader counted that as a hook that
passed.

A stop-hook-error notification with no feedback in the same stop is now a
failed `Hook:Stop-error` step (not a tool call). A notification right
after a blocked stop's feedback is that block's own and adds nothing.

The docstring and docs/run-consistency.md say what each step means and
show the `$CLAUDE_PROJECT_DIR` form for hook commands.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov
napetrov requested a review from a team as a code owner November 29, 2026 05:51
@exai-bot

exai-bot commented Nov 29, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 4 selected item(s).

CI at 6b5043c: 21 passing, 4 skipped.

Review details
  • Commit reviewed: 6b5043c against merge base c8ee1b7
  • Coverage: 4 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 89k tokens (41k from cache), 22s
  • Tool calls: 9 (4 file_read, 1 ci_log_search, 1 ci_status, 1 code_search, 1 local_check_results, 1 pr_comments)
  • Consistency stop-hook error handling, tests, and documentation: 4 files

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

46 mutants of the lines this PR changes, at 6b5043c: 33 killed, 13 survived, 0 waived, 0 inconclusive, 0 timed out, 0 errors, 0 not run.

A survivor is a change to that line that the tests covering it do not notice: add an assertion that fails on it or, if the change cannot alter behaviour, put # mutation-ok[<operator>]: <reason> at the end of the line or alone on the line above.

Line Operator Was Became Tests run
dokimi/dokimi/context/consistency.py:141 flip-bool False True 131
dokimi/dokimi/context/consistency.py:164 flip-bool False True 6
dokimi/dokimi/context/consistency.py:187 delete-statement run.num_turns = rec.get("num_turns") if isinstance(rec.get("num_turns"), int) el pass 129
dokimi/dokimi/context/consistency.py:213 drop-clause main and any(_text(b).startswith("Stop hook feedback") for b in content) (any(_text(b).startswith("Stop hook feedback") for b in content)) 129
dokimi/dokimi/context/consistency.py:180 take-branch json.loads(line) if line.strip() else None (json.loads(line)) 131
dokimi/dokimi/context/consistency.py:187 take-branch rec.get("num_turns") if isinstance(rec.get("num_turns"), int) else None (None) 129
dokimi/dokimi/context/consistency.py:188 drop-clause rec.get("subtype") == "success" and not rec.get("is_error") (not rec.get("is_error")) 129
dokimi/dokimi/context/consistency.py:160 drop-clause kind == "system" and main and rec.get("key") == "stop-hook-error" (main and rec.get('key') == 'stop-hook-error') 129
dokimi/dokimi/context/consistency.py:183 take-branch rec if isinstance(rec, dict) else None (rec) 131
dokimi/dokimi/context/consistency.py:187 take-branch rec.get("num_turns") if isinstance(rec.get("num_turns"), int) else None (rec.get("num_turns")) 129
dokimi/dokimi/context/consistency.py:188 drop-clause rec.get("subtype") == "success" and not rec.get("is_error") (rec.get("subtype") == "success") 129
dokimi/dokimi/context/consistency.py:187 negate-condition isinstance(rec.get("num_turns"), int) not (isinstance(rec.get("num_turns"), int)) 129
dokimi/dokimi/context/consistency.py:188 swap-boolop rec.get("subtype") == "success" and not rec.get("is_error") rec.get('subtype') == 'success' or not rec.get('is_error') 129

Warn-only: a survivor does not fail the job yet. Updated on every push; the full report is in the ci run summary.

@codecov-commenter

codecov-commenter commented Nov 29, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.27%. Comparing base (c8ee1b7) to head (6b5043c).
⚠️ Report is 15 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1405      +/-   ##
==========================================
+ Coverage   96.25%   96.27%   +0.01%     
==========================================
  Files         512      513       +1     
  Lines       68234    68486     +252     
  Branches    11844    11887      +43     
==========================================
+ Hits        65680    65932     +252     
- Misses       1568     1570       +2     
+ Partials      986      984       -2     
Files with missing lines Coverage Δ
dokimi/dokimi/context/consistency.py 97.43% <100.00%> (+0.31%) ⬆️

... and 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

napetrov added a commit to napetrov/dokimi that referenced this pull request Nov 29, 2026
…esults

The degrade-task hook arm is now valid: hook 5/6 vs none 0/7 (p = 0.005),
vs prose 3/6 (p = 0.55). Pooled over both real tasks, hook 10/18 vs none
0/19 (p < 0.001) and vs prose 5/18 (p = 0.18). The hook beats no guidance
on both tasks; a hook vs prose skill difference is not shown.

Replaces the untested-arm note with the detection point: dokimi reads
stop-hook errors (intel#1405), and a relative hook path fails silently.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
…not block

Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 LGTM · re-checked 6b5043c · nothing required from @napetrov

🔀 Merge: safe now · merges cleanly into current main, 8 commits behind, and its tests pass on the merge · after it, #1408 needs a rebase (context/consistency.py)

✅ make ci-local --offline: 0 failed, 27 passed (30,983 tests) · ✅ mutation: every mutant of the new reset line (155) is killed · ✅ the subagent repro gives one Hook:Stop

The earlier points are fixed; a Stop hook that failed without blocking is now a failed step.

Fixed in this branch, up to 6b5043c:

  • A subagent message ended a blocked stop: 7841ea4 resets only on a main-thread message; 6b5043c pins both cases with tests.
  • The docs said every stop-hook-error means the check did not run: 35d9a17 names all non-blocking failures.
  • Run.calls() docstring: b62f48f covers Hook:Stop-error.

@napetrov
napetrov merged commit 443be99 into intel:main Nov 30, 2026
25 checks passed
napetrov added a commit that referenced this pull request Dec 2, 2026
…1398)

* docs: measured findings on invocation, verifiers and path stability

Add what the skill-evaluation experiments measured to the two guides:
- evaluating-treatments: report invocation and split done-right by
  invoked / not invoked; pointer placement (CLAUDE.md vs README);
  trigger-heavy descriptions; Stop-hook gates, and checking the hook
  fired before crediting it.
- run-consistency: the harness result is not a verdict (use a verifier
  for --outcomes); path distances at n = 6 are noisy and the paraphrase
  effect did not replicate on real tasks.

Numbers are haiku-4-5 on one toy task and two real tasks, directional.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

* docs: estimate path-distance contrasts directly

Thread: PRRT_kwDOVBg7g869LCA1
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

* docs: report the fixed degrade hook rerun and pooled real-task hook results

The degrade-task hook arm is now valid: hook 5/6 vs none 0/7 (p = 0.005),
vs prose 3/6 (p = 0.55). Pooled over both real tasks, hook 10/18 vs none
0/19 (p < 0.001) and vs prose 5/18 (p = 0.18). The hook beats no guidance
on both tasks; a hook vs prose skill difference is not shown.

Replaces the untested-arm note with the detection point: dokimi reads
stop-hook errors (#1405), and a relative hook path fails silently.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

* docs: clarify how to verify Stop-hook errors

Thread: PRRT_kwDOVBg7g869Li0E
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

* Correct the rename comparison p-value

Thread: PRRT_kwDOVBg7g86-G2OF
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

* Describe standalone Stop-hook errors

Thread: PRRT_kwDOVBg7g86-G2Oe
Thread: IC_kwDOVBg7g88AAAABs3UqIA
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

* Identify the fixed-path degrade rerun

Thread: PRRT_kwDOVBg7g86-G2O1
Thread: PRR_kwDOVBg7g88AAAABbZXZrw
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

* Identify the agent as the source of the pass claim

PRRT_kwDOVBg7g86-K44r

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

---------

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants