Orchestrate semantic nudge on the on-task path

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 18:00:32 -04:00
parent b96319d847
commit b43ba5179d
3 changed files with 321 additions and 13 deletions
@@ -109,11 +109,14 @@ New fields on `Controller` (all reset per session in `resetDriftLocked`):
- `nudgeMessage string` — the current soft advisory ("" = none).
- `lastNudgedAt time.Time` — debounce timestamp.
The session-identity guard reuses the existing `driftGen` counter: it is
incremented only at session boundaries (`resetDriftLocked`), so a single
generation value correctly discards both stale drift *and* stale nudge results.
A nudge in flight when the user clicks "This is on task" / "Back to task"
remains valid — those actions do not change `driftGen` and the nudge is about
The nudge needs a session-identity guard, but `driftGen` cannot serve it:
`driftGen` is bumped on every drift-judgment launch (not only at session
boundaries), so an interleaved drift judgment within the same session would
wrongly discard a valid in-flight nudge. The nudge therefore uses a dedicated
`sessionGen` counter, incremented only in `resetDriftLocked`, so it survives an
interleaved drift judgment yet is still discarded when the session ends. A nudge
in flight when the user clicks "This is on task" / "Back to task" likewise
remains valid — those actions do not change `sessionGen` and the nudge is about
the session trajectory, not a single class.
New constants alongside the drift ones: