šŸ› fix(pr-autocreate): the push hook is quiet about Auto-fix once sarathi's list shows it on, 0.6.25

Merged
AT
15d ago
+132-5

Slice: #415
State: #441

With "prAutocreate": { "autofixList": true }, niyam pr-autocreate's Claude hook now says nothing about Auto-fix for a pull request whose latest state on the session's sarathi Auto-fix list is on. Before this, autofixMessage checked only its own once-per-session ack and never read the list. So in athya-hq/athya_mono#3729 the Stop after a successful set_monitor was still held (exit 2) with the "Autofix must be ON" reminder (athya-hq/athya_mono#3718, comment 6909884198, point 4). This releases 0.6.25.

  • The reader. New autofixState(sys, session, url) reads <dir>/<session id>.jsonl and folds it as sarathi 0.6.15's readRows and fold do. It keeps rows whose pr and event are strings and matches the pull request by lower-cased owner/repo#N, parsing each row, so #10 never matches #100. It skips warned, lets opened only add the pull request, and lets any other event set its state.
  • Quiet when on. In autofixMessage, when the pull request is on the list, autofixList is set and its state is on, the message is empty. This is decided before the ack is written, so an off row later gets the reminder at a later Stop. It applies to the PostToolUse half too. There, as before, state.notes go out when there is no instruction.
  • Unchanged. A state of opened, refused or off keeps today's reminder, because the tag and bind_pr steps are what fix a refusal. A missing or unreadable list, or a session id that names none, also keeps it (fail-open). With autofixList off, nothing changes, even with an on row.
  • One trade-off. A pull request this hook opened, whose list already shows on before the hook's first instruction, also loses that instruction's placeholder-body note. That needs set_monitor to have run before niyam told the session anything, which the listed flow does not do.

Tests (src/pr-autocreate.test.ts)

  • on at Stop: exit 0, no output, no ack, no row added. The list also holds a partial line, another PR (#10), the PR in other letters, then warned and opened rows.
  • off after on: the next Stop exits 2 with the listed reminder (no step 4) and writes the ack, and the Stop after it is quiet.
  • After a push (PostToolUse) with on: no Auto-fix instruction and no ack.
  • refused after on gets the reminder, and so does a session with no list, which the hook starts with an opened row.
  • autofixList off with an on row: the whole reminder, step 4 included.
  • autofixState directly: the fold order, non-object and non-string rows, no list, a folder where the list goes, and a bad session id or URL.
  • The earlier "no second row" test now seeds a refused row instead of on, since an on row now makes the push quiet.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes pr-autocreate's Claude hook so it stays quiet about Auto-fix when the session's sarathi Auto-fix list already shows the pull request as on, releasing 0.6.25. Previously the hook checked only its own once-per-session ack and never read the list, so a Stop after a successful set_monitor was still held (exit 2) with the "Autofix must be ON" reminder.

Behavior

  • New autofixState reads <dir>/<session id>.jsonl and folds the rows as sarathi does: matches the pull request by lower-cased owner/repo#N, skips warned, lets opened only add the pull request, and lets any other event set its state.
  • With autofixList on, a pull request whose latest list state is on gets no instruction and no ack, decided before the ack is written, so an off later is told at a later Stop. The push (PostToolUse) half is quiet too: the test asserts no output, no error, and exit 0.
  • opened, refused, off, or an unreadable or missing list keeps today's reminder (fail-open). With autofixList off, nothing changes.
  • Trade-off: a pull request the hook opened whose list already shows on before the hook's first instruction loses that instruction's placeholder-body note.