You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cowork): report ground-truth health; don't claim unverifiable hooks work
Claude Code's settings watcher only watches dirs that already had a settings
file when the session started. Cowork does not pre-create one, so writing the
first settings.json into a session whose CLI is already running never takes
effect — yet health marked it hooked. That is the silent miss relocated into
the health log.
Split the signal:
- written — wrote (or found current) our hook AND have reason to believe it
loads: a new session we seeded before its CLI started, or a re-merge of a
hook already present (that dir was watched at session start, so the change
hot-reloads).
- unverified — wrote a first-time hook onto a possibly-already-running session
(the startup pass). The watcher may never load it, so it is best-effort and
must not read as working. The heartbeat warns about these explicitly.
- confirmed — a spool arrived: ground truth the hook fires. A spool promotes a
session from unverified to written.
reinjectExisting now trusts only sessions that already carried our hook (the
safe mode-switch re-merge); a first-time hook on a pre-existing session is
written best-effort but recorded as unverified. Steady-state inject still
trusts its writes (it wins the race before the CLI starts).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
"cowork observe: warning: %d pre-existing session(s) had a hook written but unconfirmed — their CLI likely started before the hook existed, so it will not fire until the session restarts\n",
opts.Diagnostic.Printf("cowork observe: injected hook into %s\n", settingsPath)
463
+
ifhadOurHook||trustFresh {
464
+
h.written[dir] =true
465
+
opts.Diagnostic.Printf("cowork observe: injected hook into %s\n", settingsPath)
466
+
return
467
+
}
468
+
h.unverified[dir] =true
469
+
opts.Diagnostic.Printf("cowork observe: wrote hook into pre-existing session %s (unverified; will not fire until the session restarts unless its dir was already watched)\n", settingsPath)
470
+
}
471
+
472
+
// hasOurHook reports whether settings.json already carries a PreToolUse hook the
473
+
// injector installed (i.e. one whose command references the spool). Used to tell
474
+
// a mode-switch re-merge (the dir was watched at session start, so the change
475
+
// hot-reloads) apart from a first-time hook on an already-running session.
0 commit comments