Repository navigation
fix(autonudge): make the stale-goal 409 reachable from the goal popover - #19592
Conversation
04171d0 to
16a4780
Compare
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS The refusal tells users to press "Save edits and nudge now", but that button has only an icon on screen and its name appears only in a tooltip. Watch
Suggestions
[UX-REVIEWED] ff18c4b Description read[DESCRIPTION-READ] 9c661c43b1b6672689455ade883c82aea909c9f9a5709b69c652e5da03485c49 That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check one thing: the new refusal text also goes to the agent's What this change shipsInventory (9 items) — 9 justifiedIntent: a goal saved in one window can no longer be silently overwritten by an out-of-date save from another window's goal popover. This is a FIX (#11786).
Root-cause depth: [FIRST-PRINCIPLES-REVIEWED] ff18c4b Description read[DESCRIPTION-READ] 2449b65b70fa990fd298426851df2e49bc5e23301cd4a2aa2cc794afbd0866bf That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check one thing before merge: after the 409, the user's next press replaces a newer goal they were never shown, and the refusal text asks them to press again. [DESIGN-REVIEWED] ff18c4b Description read[DESCRIPTION-READ] 6b0fa8b21b5080ed48cbb9732ee1b8c12cf7cf53569eecc385c4c0a48a50f30a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
16a4780 to
ffcc2e2
Compare
GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)GPT 6.1 flagged blocking issues on This comment is updated in place on each push. Review detailsBLOCKING -- website/src/components/AutoNudgePopover.tsx:199 -- Baseline-read failures are silently discarded
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1: DOWNGRADE. I rate the harm LOW.
False positive or not applicable? A repository writer can comment: |
ffcc2e2 to
7f26e89
Compare
|
UX review on ffcc2e2, addressed in 7f26e89:
All 12 catalogs were updated in the same commit. |
The store's stale-baseline check (#10973) never fired for dashboard saves: PATCH /api/autonudge/{id} did not forward expect_fingerprint, and the popover never sent a baseline, so a goal saved in another window was overwritten last-write-wins. - The PATCH route forwards a string expect_fingerprint (400 not_a_string otherwise) and codes the stale refusal goal_stale_baseline. - The popover reads the stored goal_token from the slot route when it opens (the record it is handed is often a websocket frame with no token), sends it only on saves that carry the goal, takes the next one from the write's answer, and re-reads after a 409 so the next press replaces the goal. A stored goal that already differs from the seeded text at open is sent as "" so the save is refused, not landed. - The refusal text no longer claims another window: the token is re-minted on every load, so the first save after a gateway restart is refused with no other writer. The popover words it through the i18n catalog. Closes #11786 Supersedes #11027 Co-authored-by: Robert Noack <69695077+rnoack1@users.noreply.github.com>
7f26e89 to
ff18c4b
Compare
|
UX review on ff18c4b (CONCERNS, advisory), dispositioned without a push:
|
|
GPT 6.1 on ff18c4b, F1 (downgraded to advisory): a failed open-time baseline read is silent. Kept as is. A failed read leaves the save unfenced, which is exactly how every dashboard save behaved before this PR, so the failure loses nothing that was protected. An error banner for an optional background read would put a failed-state notice in an editable form that the user cannot act on. This agrees with the adjudication. |
iamwhatever
left a comment
There was a problem hiding this comment.
This PR makes the store's existing stale-goal check work for dashboard saves. Before, PATCH /api/autonudge/{loop_id} dropped expect_fingerprint and the popover had no baseline, so two windows were last-write-wins. That root cause is fixed. The route now forwards a string baseline (a non-string is 400), and the stale refusal carries code: goal_stale_baseline. On open, the popover reads goal_token from the slot route, because the websocket frame carries none. It sends the token only on a save that includes message, adopts the next token from the write's answer, and re-reads after a 409 so the next press replaces the goal. I tried to break the fence. The "already differs at open" case sends "", and the real store (autonudge_service/mutations.py:672) refuses an empty fingerprint under its lock, so it cannot slip through as "absent". Cadence-only saves and pause send no baseline and never move it. A late open-read is dropped by baselineGen, and a press that beats the read falls back to the old unfenced save, so nothing that was protected before loses protection. The GPT finding (a failed open-read is silent) was correctly downgraded and answered, because that path is the pre-PR behaviour. The UX CONCERNS (the notice quotes an icon button's accessible name) is advisory and was answered with reasoning. PR Readiness is green on the current head after a transient publish-job failure, and the PR is mergeable on main. — crew-pr-reviewer (deep re-check)
Problem / Motivation
Goal: A goal saved in one window is no longer silently overwritten by a stale save from another window's goal popover.
The store's stale-baseline check (#10973) never fired for dashboard saves.
PATCH /api/autonudge/{loop_id}did not forwardexpect_fingerprint, and the popover never sent a baseline. So two open popovers on the same goal were last-write-wins, and the 409 the check was built to raise was unreachable. Its text was also wrong: "The goal changed in another window" is false on the first save after a gateway restart, becausegoal_tokenis re-minted on every load.Why it matters
A user editing a goal loses a newer goal written from another tab with no sign that anything happened. The recurring instruction that drives unattended turns then runs on text nobody chose last.
Not a goal
goal_token. Plain and gated loops already serve it on the REST reads; structured monitors keep withholding it and never use this route.goal_tokenon theautonudge_statewebsocket frame.idle_secs,max_cycles,active): the token identifies the goal text.What changed (motivation → approach → change)
Symptom: a second window's save always lands. Root cause: the route dropped
expect_fingerprintand the client had no baseline to send. The client also cannot take one from theloopprop, because that record is usually a websocket frame, which carries no token.dashboard/handlers/autonudge.py: the PATCH route forwards a stringexpect_fingerprinttoauthorize_and_update_nudge(a non-string is 400not_a_string, sincestr(123)would read as a concurrent edit that never happened). The stale refusal is answered withcode: goal_stale_baselineso the client can tell it from every other 409.autonudge_authz.py: the refusal text is nowSTALE_GOAL_BASELINE_ERROR, "Not saved: the goal was changed or reloaded since you opened it…", which is true for both causes.AutoNudgePopover.tsx: on open, readsGET /api/autonudge/slot/{slot_key}for the storedgoal_token. If the stored goal already differs from the text the form was seeded from, it records"", a baseline that never matches, so that save is refused instead of landing. It sends the baseline only on a save that carriesmessage, takes the next token from the write's answer, and after agoal_stale_baseline409 keeps the typed text, shows the refusal through the i18n catalog, and re-reads the stored token so the reader's next press replaces the goal. The refusal names that press by the button's own label, interpolated as{{action}}(for a running loop "Save edits and nudge now"), so the reader knows which control saves and that it also nudges. A press that beats the open read saves unfenced, as every save did before, rather than waiting on a read.autoNudgeLoop.ts: typesgoal_token.components.autoNudgePopover.goal_stale_baseline, in all 12 catalogs plus the regenerated pseudolocale.learn-cron-dashboard.md: the AutoNudge section records the contract.Supersedes #11027 by @rnoack1 (co-author). Review of #11027: it had the root cause right (forward
expect_fingerprint, keep the servedgoal_tokenas the client baseline, do not lose it to a tokenless frame), but it sits 1,300+ commits behind main on a popover since rewritten and bundles a redaction notice and an overwrite-confirm dialog beyond this issue's T2 scope. This PR rebuilds only that core on current main.Backwards compatibility
Compatible: a PATCH without
expect_fingerprintbehaves exactly as before; only a non-string value, which no caller sends, is newly refused (400), and a client that ignores the newcodestill reads theerrorstring.Removes nothing: the change adds a forwarded field, a response code and one catalog key; no field, route, key or reader goes away.
Tests
test/test_autonudge_patch_stale_baseline.py(real route over a realAutoNudgeService): a goal saved elsewhere after the baseline read is 409goal_stale_baselineand the newer goal stays stored; a current baseline lands and the answer carries the next token; no baseline keeps the unfenced save; a baseline read before a restart is refused with text that says reloaded and not "another window"; non-string baselines are 400 and write nothing. Removing the forward in the handler reddens 2 of 8.website/src/test/AutoNudgePopover.staleBaseline.test.tsx(fake gateway that compares the fingerprint the way the store does): the open read supplies the baseline for a frame record; a goal saved elsewhere after open is refused, text kept, nothing fired, and the next press replaces it with the re-read token; a stored goal that already differs at open sends""and is refused; a second save uses the token the first handed back; a cadence-only save carries no baseline; a gateway serving no token stays unfenced. Mutations: not sending the field reddens 4 of 6; adopting the token without the message check reddens the differs-at-open case; dropping the post-409 re-read reddens the replace-on-next-press case.AutoNudgePopover.test.tsx,SessionAutomationPopover.test.tsx,test_autonudge_fingerprint.py,test_autonudge_banner.py,test_autonudge_handlers_cov80.py,test_r9_owner_gate_refusals.py,test_r9_owner_gate_positive_controls.py;npm run i18n:check,tsc -p tsconfig.app.json, eslint on the changed files.Manual verification
On a pod booted from this branch (Chromium, headless Playwright): created a session, armed a goal, opened the popover, then saved a newer goal from a second client with that client's own baseline. Typing an edit in the popover and pressing Save edits and nudge now sent
{"message": …, "expect_fingerprint": "<token served at open>"}, got the 409, showed the refusal below, kept the typed text, fired nothing, and the stored goal stayed the other client's. Pressing the same button again sent the re-read token, replaced the stored goal with the typed text, fired one nudge and cleared the notice. The restart case is covered by the Python test above, not driven on the pod. Pod torn down afterwards.Screenshots / video
The refusal in the popover after another client saved a newer goal; it names the button that saves:
The second press of that button replaced the stored goal and nudged (cycle 1, notice gone):
Related Issues
Closes #11786
Supersedes #11027
Pattern harvest
Rule candidate: review-prompt
Pattern: a concurrency or authorization field added to a store/authorizer chokepoint must also be threaded through every transport route and client that calls it, with a route-level test, or the check is dead code.
Decision for the owner
The decision is how the dashboard goal popover should get a concurrency baseline for its saves, given that the record it is handed is usually a token-less websocket frame. This draft keeps the shipped design: the popover reads the already-served
goal_tokenfrom the slot route at open and the PATCH route forwards it, rather than putting the token on the ungated frame or replacing the token model.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.