Skip to content

feat(dashboard): sync goal drafts across devices - #10132

Open
rubencu wants to merge 1 commit into
kirodotdev:mainfrom
rubencu:fix/mobile-goal-state-consistency
Open

rubencu wants to merge 1 commit into
kirodotdev:mainfrom
rubencu:fix/mobile-goal-state-consistency

Conversation

@rubencu

@rubencu rubencu commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Keep inactive Set a goal drafts consistent across devices so only the latest confirmed text can start autonomous work and failures remain recoverable.

The form stored executable goal instructions only in browser-local storage. The same session could show different drafts on desktop and mobile, and a stale copy could overwrite the latest edit.

Why it matters

Pressing Start turns this text into unattended agent instructions. A stale or silently lost draft can launch the wrong goal, while a sync or clear failure must leave the latest local edit recoverable.

Not a goal

  • Synchronize chat, comment, or other non-goal drafts.
  • Change live goal-loop scheduling, pause, resume, or stop behavior.
  • Replace main's server validation or raw number-field behavior.

What changed (motivation → approach → change)

Inactive goal forms share an owner-only canonical server record behind GET and PUT /api/autonudge/draft/slot/{slot_key}. Every write carries base_updated_at, the version its edit was made on; the store compares it under the write lock and returns 409 goal_draft_conflict if another write won. A re-sent save whose content the record already holds answers that record, so a save whose answer was lost is not a conflict. A Clear is a tombstone, so a stale device cannot bring the goal back. Capacity pruning never evicts the record a write just stored. On a conflict, Use newer goal (Keep it cleared after a Clear) shows the stored record and writes nothing; only Replace with my text replaces it, on a freshly read base.

The browser keeps one record per slot: the latest edit (or Clear) the server has not confirmed, and the version it was made on. A confirmed save drops it. There is no server migration route: a draft from before this change uploads once into an empty server slot as a normal save, then is deleted.

What users notice:

  • On open, the form is read-only for up to 5 seconds while it checks the server copy.
  • Start enables once the save of the text in the form is confirmed; until then the line beside it shows Saving…. Unsaved text never starts.
  • Reopening in the same tab shows another device's newer copy as Updated, with no write. After a reload, the first open shows the latest text without Updated.
  • An old browser draft whose upload races another device's save gets the normal conflict notice.

Both defaults are deliberate: Start waits for the confirmed save so unsaved text can never start, and the form is read-only during the bounded open check so typing cannot race it. Maintainers may prefer otherwise.

The create names the version the form shows; the server answers the same 409 if another device saved other text since. Clear reads the canonical stamp before removing the loop, so a second device's tombstone is accepted. It registers before its DELETE; an editor the removed frame remounts first waits for it, for at most 5 s. A DELETE with no answer, timed out or dropped, leaves the failed Clear with Retry, which re-sends it; until one is answered, the cleared goal is never restored and cannot start. Goal text is clamped to MAX_NUDGE_MESSAGE_CHARS. Sync failures show localized ErrorNotice copy beside Retry, and Start's description names that notice.

Scope Purpose
docs/feature-map/README.md and docs/system-specs/modules/learn-cron-dashboard.md Map the route; document drafts, conflicts, retries and tombstones.
src/kiro_crew/dashboard/handlers/autonudge.py, server_runtime/mcp_routes.py, and src/kiro_crew/goal_drafts.py Implement the owner-only routes, validation, conflicts and storage.
src/kiro_crew/constants.py and src/kiro_crew/autonudge_authz.py Define the one loop-message bound the draft store and both loop authorizers read.
src/kiro_crew/sandbox_leaves.py, src/kiro_crew/sandbox_precreate.py, and src/kiro_crew/security/paths_lists.py Precreate the store and fence it from agents.
test/link_screen_sites.py and test/test_*.py Pin routes, storage, bounded bodies, composition (_MCP_TABLE_ROWS 332 to 335: aiohttp's HEAD, two lazy imports), security counters and sandbox behavior.
website/src/components/AutoNudgePopover.tsx, website/src/utils/goalDrafts.ts and useGoalDraftSync.ts (its sync hook) Check and save drafts, render sync states, gate Start on the confirmed text.
website/src/i18n/locales/ Localize the status, conflict and Retry copy.
website/src/test/ Cover sync, conflicts, Retry, Start, clears and the pending edit.

Backwards compatibility

Compatible: a browser draft from before this change fills an empty server slot once (a slot that already holds a record keeps it), live loops keep current-main behavior, and an unavailable server leaves the local edit visible instead of starting stale text.

Tests

  • Server (test_goal_drafts.py, test_goal_drafts_lost_answer.py, test_goal_drafts_start_fence.py): a write on a stale base is a 409 that writes nothing; a re-sent identical save or Clear answers the stored record; a tombstone refuses an older-base write; capacity pruning keeps the record just written (fails if the prune may evict it); a Start naming an older version over other text is refused; one message bound for the store and both loop authorizers; invalid and unparseable bodies erase nothing.
  • goalDrafts.test.ts: one pending edit per slot with its base; a confirmed save drops it and an edit typed meanwhile moves to the answer's version; a conflict or failure keeps it; writes per slot go out one at a time; the pre-sync draft is read and deleted per slot; requests end at the 5 s bound.
  • Popover suites (AutoNudgePopover.<name>): goalSync (read-only check, Start disabled with Saving… through the debounce and the save, then runs the confirmed text, opening never writes, Updated, one-shot legacy upload, failed save or read keeps the edit with Retry, close flush then reopen), goalConflictActions (both actions, no Retry, Use newer goal writes nothing, a 409 never changes the editor), goalLostAnswer (a committed save whose answer was lost confirms on Retry or reopen), goalStartFence, goalClear and goalClearDeadline (tombstone base, Retry, remount waits read-only, stalled DELETE ends at 5 s; Retry re-sends a timed-out or dropped DELETE, before or after the server deleted, and an unanswered re-send keeps the notice).
  • On this patch, 7,356 backend and 1,404 vitest tests, TypeScript, i18n:check, docs lint, the feature-map test and the static gates passed, host-only failures aside.

Manual verification

Synthetic-data screenshots below.

Screenshots / video

State Desktop Mobile
Checking saved goal: form read-only, Start disabled Desktop checking Mobile checking
Updated from another device Desktop updated Mobile updated
Sync failed, Retry Desktop sync failed Mobile sync failed
Clear failed, Retry Desktop clear failed Mobile clear failed
Newer goal elsewhere: Use newer goal or Replace with my text Desktop conflict Mobile conflict
Cleared elsewhere: Keep it cleared or Replace with my text Desktop cleared conflict Mobile cleared conflict
Saving…: Start disabled Desktop saving Mobile saving

Related Issues

Part of #9052 (review follow-up)

Checklist

  • At most two commits, with a Conventional Commits title
  • Existing tests pass and regression tests cover synchronization and recovery
  • Self-review completed and code follows project style guidelines
  • Documentation and locales updated
  • Current-head desktop and mobile evidence captured and attached by the maintainer
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the repository's Apache 2.0 license.

@rubencu
rubencu requested review from a team and cixuuz September 11, 2026 15:02
@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Sep 11, 2026
@rubencu

rubencu commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Intent: Make one session’s Set a goal draft converge to the latest user edit across desktop and mobile while preserving the existing offline local fallback.
Not a goal: Change goal-loop scheduling, the popover’s visual design, or synchronize ordinary chat composer drafts.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 7e75a247779eace2d17265be084acbc79f4987d4 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 7e75a247779eace2d17265be084acbc79f4987d4 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The server-side compare-and-set with tombstones is the right shape, and the only reader of the removed loadGoalDraft/saveGoalDraft helpers is AutoNudgePopover.tsx, which this patch updates.

Notes

  • Start now depends on the draft store as well as the loop service. If goal-drafts/ throws OSError (503 goal_draft_unavailable), no goal can start even though POST /api/autonudge would still work. Retry is the only remedy. This can be reverted, but the spec should say so.
  • The client keeps its own copy of the bounds (GOAL_DRAFT_MIN_IDLE_SECS = 15 and GOAL_DRAFT_MAX_MESSAGE_CHARS = 8_000 in goalDrafts.ts), while the server reads MAX_NUDGE_MESSAGE_CHARS and allows idle_secs ≥ 1. Nothing ties the two together, which is the same drift the new constant was added to prevent.

[DESIGN-REVIEWED] 7e75a24

Description read

[DESCRIPTION-READ] fb928d645ecfc3c79d797d9267e109ee2af208b43fb9a4b4848dd97d6092dcc9

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — 🔴 changes requested (blocking)

Reviewed 7e75a247779eace2d17265be084acbc79f4987d4 via the fork AI-review pipeline; updated in place on each push.

2 of 3 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

BLOCKING -- src/kiro_crew/dashboard/handlers/autonudge.py:683 -- Draft snapshots expose credentials to Shared Crew teammates

return web.json_response(snapshot.to_public_dict())
Trigger: The owner saves goal text containing a credential, then an admitted teammate GETs that slot’s draft. _require_monitor_owner admits teammates; redaction_audience_middleware sets scanning context but does not transform responses, and to_public_dict() returns the stored text unchanged.
Outcome: The teammate receives the raw credential. Successful PUT responses and both draft-conflict responses expose snapshots through the same unredacted projection, reversing the recorded non-owner redaction boundary.
Anchor: recorded-decisions-are-not-regressions
Fix: Apply audience-aware redaction to every outbound draft snapshot, preserving the stored original and preventing an unchanged projected value from overwriting it.

BLOCKING -- src/kiro_crew/dashboard/handlers/autonudge.py:1298 -- Start’s draft fence releases before the loop commits

get_goal_draft_store().superseding,
Trigger: Device A starts goal A and passes superseding(), whose get() releases the draft lock. While authorize_and_add_nudge awaits its mandatory SEL audit, device B successfully PUTs goal B. A then reaches svc.add(); its commit-time admission predicate checks the session, not the draft.
Outcome: The server commits and arms goal A after confirming the different canonical goal B, without returning the draft conflict. Unattended work runs the superseded instructions.
Anchor: defect
Fix: Serialize draft PUTs against Start’s version check and loop commit through a shared transaction boundary; another unlocked check retains the race.

BLOCKING -- website/src/components/AutoNudgePopover.tsx:510 -- A lost Clear response lets the cleared goal return after reload

const resp = await pendingClear.removeLoop(clearUrl, clearBase, loop.message)
Trigger: A confirmed goal has no pending local edit. Clear’s DELETE durably removes its paused loop, but the response is dropped. The handler never reaches savePendingGoalDraft or the tombstone PUT; removeLoop retains the unanswered Clear only in module memory. Reloading then reads the unchanged canonical draft.
Outcome: The cleared goal reappears with Start enabled, and Start succeeds against its unchanged version. The failed Clear also loses its Retry state after reload; another device likewise receives the old goal.
Anchor: defect
Fix: Durably record the Clear intent on the server before publishing loop removal, and make draft reads and Start honor it until removal and tombstone persistence are resolved.

[BLOCK-MERGE] 7e75a24
[GPT-REVIEWED] 7e75a24

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F3: Low-harm, visible, and needs a user action to cause damage, so it's downgraded. The real fix needs new server-side state and coordination between modules.

  • Conditions confirmed in the patch: the DELETE gets no answer within the 5 s deadline (website/src/utils/goalDrafts.ts at patch lines 4876–4884 and 4908–4915). The unanswered Clear is held only in module memory (patch line 4706). The tombstone savePendingGoalDraft call is only reached after a response (AutoNudgePopover.tsx at patch line 1798). The page must then be reloaded before Retry.
  • Outcome: the DELETE already removed the loop, so nothing runs on its own. The old goal text reappears in the editor, where the user can see it, and it runs only if the user deliberately presses Start again (gate at patch line 1856). The user can recover by clearing or editing the text.
  • Cost of the fix: a server-side record of the Clear intent, which draft reads, Start and every other device would all have to respect. That is new cross-module state kept for one rare path, and it outweighs a rare harm that a person can see.

[ADJUDICATION] 7e75a24 total=1 uphold=0 downgrade=1
DOWNGRADE F3 website/src/components/AutoNudgePopover.tsx:510 reason=disproportionate-remedy
[GPT-ADJUDICATED] 7e75a24

[ADJUDICATION-FENCED] 7e75a24 fenced=2 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/dashboard/handlers/autonudge.py:683 -- An owner pasting a credential into goal text and an admitted teammate opening the same slot is ordinary Shared Crew use, so exposing credentials to non-owners is plausible and not acceptable residual risk.
UPHOLD-FENCED F2 src/kiro_crew/dashboard/handlers/autonudge.py:1298 -- Two devices editing the same slot while one Start waits on its audit write is a reachable race, and its outcome (a loop running instructions the user already replaced) cannot be ruled extreme from code opened here.
[GPT-ADJUDICATED-FENCED] 7e75a24

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🔴 BLOCK

Premise-level review of 7e75a247779eace2d17265be084acbc79f4987d4 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: BLOCK

product-shape change without accepted RFC: Start on the goal form now waits for a server-confirmed save, and the form is read-only on open. The description itself says "Maintainers may prefer otherwise".

Notes

  • Item 6 — duplicate of src/kiro_crew/autonudge_service/model.py:62 (_MAX_IDLE_SECS = 86400): MAX_GOAL_IDLE_SECS = 86_400 re-spells the bound. 1 existing definition (grepped 86_?400). Subtraction: delete MAX_GOAL_IDLE_SECS and import the existing bound, the way this PR already shares MAX_NUDGE_MESSAGE_CHARS.

What this change ships

Inventory (8 items) — 5 justified

Intent: a person editing a goal on desktop and mobile always starts the latest confirmed text, and doesn't lose an edit when sync fails. ADDITION.

  1. Goal drafts sync across devices through an owner-only GET/PUT draft route — justified
  2. A stale device's edit gets a conflict notice with Use newer goal / Replace with my text — justified
  3. Start stays disabled until the save of the form's text is confirmed (Saving…) — changed default, no recorded decision
  4. The form is read-only for up to 5 s on open while it checks the server copy — changed default, no recorded decision
  5. Start refuses with a 409 when another device saved different text since — justified
  6. The draft store applies its own idle/cycle bounds — duplicate of autonudge_service/model.py _MAX_IDLE_SECS
  7. The goal-drafts directory is masked from agents and precreated by the sandbox — justified
  8. The 8000-char message limit becomes the shared constant MAX_NUDGE_MESSAGE_CHARS — justified

Blockers

product-shape change without accepted RFC: default gating of goal Start and of goal-form editing — items 3, 4
Trigger: the description says "Start enables once the save of the text in the form is confirmed" and "the form is read-only for up to 5 seconds", and adds "Both defaults are deliberate… Maintainers may prefer otherwise." The base RFC list has no non-draft RFC covering goal-draft sync or Start gating. rfc-goal-popover-pause-play-controls (implemented) covers pause and play only.
Outcome: everyone who sets a goal gets a slower, gated Start and a locked editor on open, and nobody recorded that decision.
Clears when: an RFC covering the goal form's server-confirmed Start gate and read-only open check is merged on the base with a non-draft status (then push or rebase), or a maintainer posts /ai-review override first-principles 7e75a247779eace2d17265be084acbc79f4987d4 product-shape: <decision>.

[FIRST-PRINCIPLES-REVIEWED] 7e75a24

Description read

[DESCRIPTION-READ] 2147e7db19276e49555228c50075a3d49d12b06ed16b6459a7d6665249dd4d84

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 7e75a247779eace2d17265be084acbc79f4987d4 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 7e75a24

@rubencu
rubencu force-pushed the fix/mobile-goal-state-consistency branch 3 times, most recently from 6fe8200 to f5ccc36 Compare September 13, 2026 23:19
@rubencu

rubencu commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: agent-fenced canonical goal-draft directory

  • Fixed agent-writable goal store span=7a51058d7a46

Canonical goal text now lives under the top-level goal-drafts directory. That whole directory is on both the shared file-tool sensitive floor and every agent process sandbox hidden set.
The gateway opens the store directly, creates it owner-only, and still uses atomic owner-restricted writes. A prompt-injected same-UID agent can no longer forge the next goal through the file, lock, or atomic-write sibling.

Fixed in f5ccc36. Focused store and sandbox parity tests pass.

@rubencu

rubencu commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: explicit draft-record validation before tombstone dispatch

  • Fixed malformed draft erasure span=d9852f0154e8

A tombstone now requires the JSON draft member to be explicitly present and null. Every non-null draft must contain message, idle_secs, and max_cycles, and a null message is rejected before GoalDraftStore.put runs.
The regression test seeds a valid canonical draft, submits omitted, empty, and null-message objects, and proves all return 400 while the original goal remains.

Fixed in f5ccc36.

@rubencu

rubencu commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: structured goal-draft sync error notice

  • Fixed sync failures bypassing ErrorNotice span=f9eb25b1dcc6

The failed reconciliation branch now renders ErrorNotice with role=alert instead of a hand-styled status paragraph. The adjacent no-hand-off comment records that this popover owns the unsaved goal draft and recovery must preserve it in place.
Checking and updated remain non-error status messages. The focused component test proves the failure is an alert and the local draft remains unchanged.

Fixed in f5ccc36.

@github-actions

github-actions Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — ✅ PASS

Which legitimate operations does 7e75a247779eace2d17265be084acbc79f4987d4 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

adjudicated, zero confirmed regressions

Scope-Verdict: PASS

Reason: The tightening adds one new directory, goal-drafts, to three places: the file-tool path fence (_CREW_SECRET_LEAVES), the sandbox hidden leaves and the sandbox precreate list. No sensitive-bash, exfil or deny-rules matcher changed, and is_sensitive_bash_command deliberately does not match paths in command text, so the shell candidates should not flip. The real tightening is in the path gate and the OS sandbox, which this classifier cannot judge; that gap is named below and does not block.

TIGHTENING: goal-drafts added to _CREW_SECRET_LEAVES (src/kiro_crew/security/paths_lists.py), to _CREW_HIDDEN_LEAVES (sandbox_leaves.py) and to _CREW_PRECREATE_HIDDEN_DIR_LEAVES (sandbox_precreate.py) -- it refuses a prompt-injected same-UID agent writing the canonical goal-draft store directly to forge the next loop prompt: "A prompt-injected same-UID agent must not be able to forge that next prompt by writing the backing file directly; the owner-gated dashboard route is the only writer."

ADJUDICATED: 14 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix and windows, plus one any row (git log). The new leaf is spliced into every crew-home prefix as <prefix>/goal-drafts, so the posix rows use ~/.kiro/crew/goal-drafts/... and the windows rows use %USERPROFILE%\.kiro\crew\goal-drafts\... with \ separators. Both sides cover a direct read of the store, a grep of the declaration that names the leaf (grep / findstr), and the PR's own backend and frontend test runs (python/py, npx/npx.cmd). The posix rows also cover the new /api/autonudge/draft/slot/{slot_key} GET and PUT routes reached with curl on loopback. I wrote no candidate for the legacy .kirocrew crew-home prefix, and none for a Windows curl.exe call to the draft routes.

UNADJUDICATED: The tightening is in the agent file-tool path gate. A tool's resolved path goes through is_sensitive_path / is_sensitive_write_path → _matches_gate_rows(..., _SENSITIVE_HOME_DIRS ...); _SENSITIVE_HOME_DIRS now includes <crew-prefix>/goal-drafts, and _KEYSTONE_ARTIFACT_PARENTS fences .tmp/.lock files beside it. It is also in the OS sandbox, which masks and precreates the goal-drafts directory before each namespace launch. Neither is a shell command line, so there is no verdict for these inputs I would have submitted:

  • an agent file-tool read of any path whose name only begins with goal-drafts, such as a sibling goal-drafts-archive/ or a file goal-drafts.md under the crew data home. This tests whether the leaf match is a prefix match or a whole path segment.
  • an agent file-tool read or write of goal-drafts under a project workspace rather than the crew data home.
  • the .tmp/.lock sibling rule, which now also covers the crew home root because goal-drafts sits there. Other root-level leaves already put the root in that set, so this is expected to add nothing new.
  • a sandboxed shell in an agent session needing anything under the data home's goal-drafts directory. The patch says no in-sandbox process reads it, and the gateway opens it directly.

Neither GoalDraftStore._slot nor the draft_updated_at check on POST /api/autonudge is a security fence. Both are request validation, and the second runs only when the field is present.

[SCOPE-REVIEWED] 7e75a24

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 9 classified, 0 newly refused, 8 still allowed.
  • ubuntu-latest (platform posix): 9 classified, 0 newly refused, 8 still allowed.
  • windows-latest (platform windows): 6 classified, 0 newly refused, 6 still allowed.

No candidate flipped from allowed to refused.

@rubencu
rubencu force-pushed the fix/mobile-goal-state-consistency branch from f5ccc36 to d7369c8 Compare September 14, 2026 02:07
@rubencu

rubencu commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Disposition for an earlier head, kept for the record (no longer a ledger record):

  • fixed live-slot capacity pruning span=7ca377344eb3

The accepted live slot is now protected through count and byte pruning; capacity pressure evicts the oldest other slot, and regressions cover 50 future-skewed migrations. Fixed in d7369c8.

  • fixed uncached reconciliation span=1bda1fe2ef82

Goal-draft reads and writes now use React Query query/mutation state with one process-wide per-slot write queue and bounded requests. Fixed in d7369c8.

@rubencu

rubencu commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Disposition for an earlier head, kept for the record (no longer a ledger record):

  • fixed remotely-invalid local values span=2cbfa926034e

Every locally accepted idle/cycle value is normalized to the server integer bounds before persistence, so reopen cannot enter a permanent 400 loop. Fixed in d7369c8.

  • fixed pre-launch sandbox exposure span=356c4e6acf32

goal-drafts is precreated before namespace launch and remains on both hidden/sensitive floors, closing the absent-mask race. Fixed in d7369c8.

  • fixed remount write ordering and failed-write recovery span=2cbfa926034e

Per-slot tails live at module scope across remounts; failures render ErrorNotice with Retry while preserving the local copy. Fixed in d7369c8.

  • fixed timestamp/body rollback span=7b7188e85e08

If body persistence fails after the sidecar write, both disk and in-memory timestamps roll back, preventing an old body from carrying a failed write's newer conflict stamp. Fixed in d7369c8.

@rubencu

rubencu commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Disposition for an earlier head, kept for the record (no longer a ledger record):

  • fixed unbounded reconciliation gate span=732998da0365

Both GET and PUT abort after five seconds and enter the existing failed state, so Start cannot remain disabled on a stalled gateway. Fixed in d7369c8.

  • rebutted remove committed evidence span=08fa92f52fa4

temp-screenshots is this repository's established review-evidence convention, confirmed by First Principles against more than 80 existing files; the two bounded images document user-visible states and current raw links are in the PR body.

  • rebutted extract a reusable hook now span=732998da0365

This is the only synchronized draft form. Extracting a second abstraction before another consumer exists would widen the PR without reducing a concrete correctness risk; focused tests pin the state machine in place.

@rubencu

rubencu commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Disposition for an earlier head, kept for the record (no longer a ledger record):

  • fixed failed-state Retry span=c7dc47ca3b86

Failed live writes now use the popover's ErrorNotice plus in-place Retry pattern while retaining the local draft. Fixed in d7369c8.

  • fixed indefinite checking state span=c7dc47ca3b86

Remote reads and writes have a five-second abort bound and failures re-enable Start through the explicit failed state. Fixed in d7369c8.

  • rebutted reserve permanent status height span=c7dc47ca3b86

The checking line is intentionally immediate and transient; reserving empty height on every normal form open adds persistent whitespace to avoid a minor one-line transition.

  • rebutted attachment-only evidence requirement span=cde01ba37907

The repository-standard committed screenshots are linked from the current public fork head; the failed path uses the established ErrorNotice component and is directly regression-tested with the local draft preserved.

  • rebutted replace draft with goal in failure copy span=184517a7b0d1

The message distinguishes the unsent draft from the running goal and immediately states that this device's copy remains; changing that noun would blur the recovery contract.

@rubencu

rubencu commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Disposition for an earlier head, kept for the record (no longer a ledger record):

  • fixed feature framing span=01b392f0c13b

The single commit is typed feat and the refreshed body explicitly inventories the canonical store, endpoints, ordering, status UI, and recovery behavior.

  • fixed undeclared edit-time accessor span=82eea35ddf2d

The body and owning spec now state that first-sync migration uses bounded browser edit times while live writes use server arrival order; the accessor exists only to carry that declared conflict timestamp.

@rubencu

rubencu commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author
  • rebutted legitimate-operation regression span=23712bc79af1

goal-drafts is introduced by this PR specifically as executable prompt text whose only writer is the owner-gated dashboard route. Refusing agent file-tool and sandbox access is the declared security contract, while owner recovery remains available through the route; no pre-existing operation was removed.

@rubencu rubencu changed the title fix(dashboard): sync goal drafts across devices feat(dashboard): sync goal drafts across devices Sep 14, 2026
@rubencu
rubencu force-pushed the fix/mobile-goal-state-consistency branch from d7369c8 to 03b45aa Compare September 14, 2026 02:47
@rubencu

rubencu commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author
  • fixed live edit timestamp regression span=615a397dbf1e

A live browser edit now defaults to max(Date.now(), previous canonical/local timestamp + 1), while explicit server timestamps remain unchanged. Clock lag can no longer let stale remote text outrank a newer failed-PUT edit.
The monotonic regression fails when the max rule is removed and passes in 03b45aa.

@rubencu

rubencu commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author
  • fixed sidecar-write in-memory divergence span=53b12cb5cd39

A failed timestamp-sidecar write now restores the prior in-memory timestamp map before returning; body-write failure still restores both memory and persisted sidecar.
The sidecar-failure regression observes the advanced timestamp when this restore is removed and passes in 03b45aa.

@rubencu

rubencu commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author
  • fixed Retry erasing the only edit span=f9eb25b1dcc6

Failed local persistence records the current editor snapshot in a module-owned per-slot fallback. Retry/remount reconciles from that snapshot before localStorage and clears it only after the server accepts a canonical value.
The local+remote failure regression loses the second PUT when this preference is removed and passes in 03b45aa.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main d1997282 (head ee30bbc4). Conflicts, each resolved by keeping both sides:

  • src/kiro_crew/sandbox_precreate.py: the hidden-leaf list keeps main's browser-harness-ipc and browser-profile (feat: add the live browser harness to chat #26950), then this PR's goal-drafts.
  • src/kiro_crew/dashboard/handlers/autonudge.py: main's api_monitor_contract (feat(monitoring): serve the monitor kind list at runtime so contributed kinds are not blocked #28367) and this PR's goal-draft handlers both stay.
  • Pins: MCP route table 335 rows (main's 332 plus this PR's 3), lazy imports 131 (main's 129 plus this PR's 2), protected names 325/332/333 (main's plus this PR's 3 per tier), and the security budget 34,530 (main's 34,523 plus this PR's 7; the package measures 34,525, the 5 spare lines are main's own). test_json_object_body_guard.py keeps both sides' register entries.
  • docs/feature-map/README.md: the "Monitor loops" row keeps main's useMonitorContract and GET /api/monitor-contract entries next to this PR's goal-draft entries.

AutoNudgePopover.tsx, goalDraftStartGate.ts and the rest of the web changes have the same patch as before. The description's _MCP_TABLE_ROWS line now reads 332 to 335.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the loop create names the draft version the form showed, and the server refuses a goal saved since with other text

  • span=f9eb25b1dcc6 website/src/components/AutoNudgePopover.tsx:1055: Start can launch a draft superseded on another device

fixed in f467651: Start's POST /api/autonudge now carries draft_updated_at, the draft version the form showed. When the stored draft is newer and holds different text, the server answers the draft PUT's 409 goal_draft_conflict and arms nothing, and the form shows the existing conflict notice with its text kept as a pending edit on that version. Identical text is never a conflict, and a create without the field is not checked. test_start_over_a_newer_different_draft_answers_the_draft_conflict (test_goal_drafts_start_fence.py) and all three cases in AutoNudgePopover.goalStartFence.test.tsx (refused with the notice, starts with no newer goal, starts over a newer goal with the same text) fail on ee30bbc.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: a stale base is compared by content before it counts as a conflict, in the store and in the editor

  • span=2920aea95aff website/src/utils/goalDrafts.ts:796: Start can be blocked by a false "changed on another device" conflict over the user's own saved text

fixed in f467651: a save that committed but whose answer was lost no longer reads as a conflict. The draft store answers a live PUT on a stale base with the stored record, unchanged, when that record already holds the submitted content, and migrateLocalGoalDraft adopts a canonical draft or Clear that already holds the pending edit. Different content on a stale base is still a 409. test_resent_live_put_with_identical_content_answers_the_stored_record and test_resent_clear_on_a_stale_base_answers_the_stored_tombstone (test_goal_drafts_lost_answer.py), the two adopt cases in goalDrafts.lostAnswer.test.ts, and both cases in AutoNudgePopover.goalLostAnswer.test.tsx fail on ee30bbc.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed f467651, rebased onto main 538e438b27 without conflicts. It carries three changes.

  • The Opus lane's finding on ee30bbc (goalDrafts.ts:796, a false "changed on another device" conflict over the user's own saved text). A save that committed but whose answer was lost no longer reads as a conflict. The draft store answers a live PUT on a stale base with the stored record, unchanged, when that record already holds the submitted content, and the editor adopts a canonical record that already holds its pending edit. Different content on a stale base is still a 409. One side effect: a pending Clear over an empty server slot is now adopted instead of shown as a conflict. Six cases in test_goal_drafts_lost_answer.py, goalDrafts.lostAnswer.test.ts and AutoNudgePopover.goalLostAnswer.test.tsx fail on ee30bbc; two more check that different content still conflicts.
  • The GPT lane's finding on ee30bbc (AutoNudgePopover.tsx:1055, Start can launch a goal another device superseded). Start's POST /api/autonudge now carries draft_updated_at, the draft version the form showed. A newer stored draft with different text answers the draft PUT's 409 goal_draft_conflict and arms nothing. The form then shows the existing conflict notice and keeps its text as a pending edit on that version, so Use newer goal and Replace with my text settle it like any other conflict. Identical text is never a conflict, and a create without the field is not checked. The check runs in the create handler just before the loop is armed and does not hold the draft store's lock across the create, so a save landing inside that one request is not refused. Three exact-body assertions in AutoNudgePopover.test.tsx and AutoNudgePopover.goalSync.test.tsx now allow the new field. In AutoNudgePopover.goalStartFence.test.tsx the refused Start, the Start with no newer goal and the Start over identical text each fail on ee30bbc, as do two cases in test_goal_drafts_start_fence.py.
  • AutoNudgePopover.tsx is split under the 1,600-line rule. Its goal-draft sync state and effects moved, unchanged, into utils/useGoalDraftSync.ts, and the popover is now 1,324 lines. goalDraftStartGate.ts is unchanged, and no existing test changed for the split.
  • On d1997282f8, the PR's tests and every test naming a module it changes passed (7,357 backend, 1,497 vitest), with TypeScript, i18n:check and the static gates. After the rebase onto 538e438b27, the parts main also changed passed again: the composition contracts and the feature map (112), vitest including src/i18n (1,507), docs-lint and i18n:check. The only failures also fail on main on this host.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the Clear's loop removal is waited on for at most the editor's 5-second sync bound
resolution: narrowed -- only the Clear's DELETE wait is bounded, plus a Retry that finishes a late removal; nothing else changes

  • span=aa2a48254923 website/src/utils/useGoalDraftSync.ts:302: A stalled DELETE blocks reopened editors without recovery

fixed in be5528c: the Clear's loop removal is now waited on for at most GOAL_DRAFT_SYNC_TIMEOUT_MS (5 s), the editor's existing request bound. A stall ends through the existing failure path, so the remounted editor shows the clear-failure notice with Retry instead of staying on "Checking saved goal". The request itself is not cancelled; if it succeeds after the bound, Retry on that editor finds no loop, writes the Clear's tombstone on the base it captured and closes with no goal shown. Both cases in AutoNudgePopover.goalClearDeadline.test.tsx fail on f467651.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed be5528c, rebased onto main f3c97e5094 without conflicts. It carries two changes on top of f467651.

  • Frontend Lint on f467651. CI's eslint src/ --max-warnings 0 failed on two react-hooks/exhaustive-deps warnings in useGoalDraftSync.ts: the close-flush cleanup read the popover's refs through the hook's arguments. The effect now holds the two ref objects before it returns the cleanup, which still reads their current values at close. No behaviour changes. The Coverage Gate failed only because lint did, so CI ran no tests on f467651.
  • The GPT lane's upheld finding on f467651 (useGoalDraftSync.ts:302, a stalled Clear DELETE leaves a reopened editor waiting). The Clear's loop removal is now waited on for at most GOAL_DRAFT_SYNC_TIMEOUT_MS (5 s), the editor's existing request bound. A stall ends through the existing failure path, so the remounted editor shows the clear-failure notice with Retry. The request is not cancelled, because an existing test pins the exact DELETE call. If it succeeds after the bound, Retry on that editor finds no loop, writes the Clear's tombstone on the base the Clear captured and closes with no goal shown. Both cases in AutoNudgePopover.goalClearDeadline.test.tsx fail on f467651. The downgraded companion finding at line 307 is unchanged.
  • The full eslint run over src/ is clean; vitest passes 1,509 tests (the one failure is an i18next version check that fails the same way on main on this host), and TypeScript and i18n:check show nothing new.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 1f3c6bc, rebased onto main 3736af2d38 without conflicts. This push narrows the PR: it removes most of the browser-side draft code instead of patching it again.

What users will notice:

  • Start enables once the save of the form's text is confirmed. Unsaved text never starts, including during the save's debounce.
  • When the form opens, it is read-only for up to 5 seconds while it checks the server copy.
  • Reopening in the same tab shows another device's newer copy as "Updated". After a reload, the first open shows the latest text without "Updated".
  • An old browser draft whose upload races another device's save gets the normal conflict notice.

What changed:

  • The 11-second save-and-wait before Start and goalDraftStartGate.ts are gone. The server's check of the draft version Start sends stays.
  • The browser keeps one record per slot: the latest edit or Clear the server has not confirmed, and the version it was made on. goalDrafts.ts drops from 873 to about 400 lines.
  • The PR's own server migration route is gone. A draft from before this change uploads once, into an empty server slot, as a normal save. The server's prune keeps the record it just wrote.
  • The browser no longer adopts a lost save's answer itself; the server's content compare answers a re-sent identical save.
  • AutoNudgePopover.tsx's pinned count of raw fetch('/api/…') calls drops from 2 to 1, which was the frontend red on be5528c.
  • All twelve screenshots are retaken on this head: main's feat(dashboard): add a run first cycle now box to start loop #25774 added the "Run first cycle now" checkbox they lacked, and 01 now shows the read-only check.

Size, counted the way pr_findings.py --rounds counts it: be5528c changed 2,518 code and 6,103 test lines in 66 files; this head changes 1,745 code and 2,256 test lines in 58 files.

Every invariant the retrospective kept has a test: the server compare-and-set, content compare, tombstones and Start check; the open check that never writes; the conflict notice and its actions; the Clear deadline; the error notice with Retry; the shared message limit, body parser and sandbox fence; and every catalog string. The full frontend suite passed on the narrowed code, apart from 10 files that fail the same way on main on this host. After the rebase, the affected frontend tests, docs lint, feature map, i18n check and goal-draft server tests pass again.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: one rule for a Clear whose loop removal gets no answer: it is kept until a re-sent removal is answered

  • span=615a397dbf1e website/src/utils/goalDrafts.ts:374: Preserve Clear intent when the DELETE response is lost

fixed in 2070b29: a Clear whose loop removal gets no answer, whether the 5-second bound passed or the connection dropped, is now kept with the base it captured. The editor shows the failed Clear with Retry, never the goal it cleared, and Start stays disabled; on a loop that is still there, its fire control is disabled too. Retry re-sends the DELETE, and only an answer finishes the Clear: the tombstone is written on the captured base and the popover closes. A re-send that also gets no answer keeps the notice. Three cases in AutoNudgePopover.goalClearDeadline.test.tsx fail on 1f3c6bc: the connection drops after the server deleted, it drops before the server processed the DELETE, and the re-send also gets no answer.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 2070b29, rebased onto main bd9c87744b without conflicts. It fixes GPT's Clear finding with one rule for a Clear whose request gets no answer, timed out or dropped: the failed Clear stays with Retry, Retry re-sends it, and only an answer finishes it, so the cleared goal never comes back and cannot start meanwhile. Start's row now shows the existing "Saving…" text while Start waits for the save, with a new desktop and mobile screenshot of that state. The description now gives the reasons for the two defaults First Principles asked about.

Known edge, unchanged: an unconfirmed Clear is held in memory only, so a reload, or reopening a paused loop's popover, shows the server's current state again.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: every edit is kept in this browser on each change; only the network save waits for the previous answer

  • span=aa2a48254923 website/src/utils/useGoalDraftSync.ts:345: Preserve newer edits while a save is in flight

fixed in f2ec672: the editor's text now goes to this browser's pending record on every change, also while an earlier save is still in flight. Only the network save waits for that save's answer. A confirmed save drops the record only when it holds the saved text, so an edit typed after it stays pending on the version that save returned and is saved next. A reload during a slow or hung save finds the newest edit. AutoNudgePopover.goalSync.test.tsx "stores text typed during an unanswered save here at once, and only a confirmed save of that text drops it" fails on 2070b29: the stored record still held goal A while goal B was on screen.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: a pending write that browser storage refuses is held in memory for the page's life

  • span=615a397dbf1e website/src/utils/goalDrafts.ts:143: Retain the unsynced edit when local persistence fails

fixed in f2ec672: savePendingGoalDraft and clearPendingGoalDraft now check the storage result. A write the browser refuses is held in memory for that slot, a refused removal as "nothing pending", and every read takes that copy first. So a refused write never loses an edit and never brings back one already settled. Retry re-sends the text on screen on the version it was made on and never replaces it with the previous goal. AutoNudgePopover.goalSync.test.tsx "an edit this browser refuses to store and the server misses is kept on screen, and Retry sends it" fails on 2070b29: Retry showed the previous goal instead of the unsynced edit and sent nothing.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the open edge reads a paused loop's held Clear from the module record instead of resetting it
resolution: removed -- the open edge no longer resets a paused, unchanged loop's held Clear to idle; it reads the hold from the module record that owns it. After a reload the editor shows the server's current state (unchanged; the note asks the maintainers)

  • span=f9eb25b1dcc6 website/src/components/AutoNudgePopover.tsx:337: Keep unanswered Clear holds across reopen and reload

fixed in f2ec672 for reopening: a paused loop whose Clear got no answer now opens with the failed-Clear notice and Retry, and Resume stays disabled, until a re-sent removal is answered. The hold applies only while the loop record is the one the Clear was made on, so its Retry never removes a goal edited on another device since. Reload is left as it is: the hold lives in memory only, so after a reload the editor shows the server's current state, the loop if it is still there and otherwise the stored goal. Nothing hidden can start, because Resume and Start act only on what the editor shows. The push note asks the maintainers whether they accept that or want a durable Clear hold. AutoNudgePopover.goalClearDeadline.test.tsx "reopening a paused loop whose Clear got no answer keeps the failed Clear and Resume disabled until Retry finishes it" fails on 2070b29: the reopened loop showed no notice.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed f2ec672, rebased onto main 942ab8b155 without conflicts. It fixes four findings, each with a test that fails on 2070b29:

  • Retry after a Clear that got no answer re-sends that removal on the version the Clear captured, so it cannot erase a goal another device saved since.
  • Text typed while a save is still running is stored in this browser at once, and only a confirmed save of that same text clears it. A reload during a slow save keeps the newest edit.
  • Retry never replaces the editor's text. If this browser refuses to store an edit, the edit is held in memory and Retry sends what is on screen.
  • Reopening a paused loop whose Clear got no answer keeps the failed-Clear notice, and Resume stays disabled, until Retry finishes the Clear. This holds only while the loop is unchanged, so Retry never removes a goal edited on another device since.

Two decisions for the maintainers:

  1. The two defaults, which is the First Principles product decision.

    • Start waits for the confirmed save, so text the server has not confirmed never starts. The alternative is to keep Start enabled and save the text as part of the press; a failed or conflicting save then shows after the press instead of before it.
    • The form is read-only for up to 5 seconds while the open check reads the server copy, so typing cannot race that check. The alternative is an editable form during the check: text typed then is saved on the version this browser last saw, and a newer copy from another device comes back as the conflict notice.

    We'll change either one if you prefer. First Principles clears with an accepted RFC or a maintainer's product-shape decision.

  2. The reload edge. An unanswered Clear is held in memory only, so after a reload the editor shows the server's current state: the loop if it is still there, otherwise the stored goal. Nothing hidden can start, because Resume and Start act only on what the editor shows. Do you accept this, or do you want a durable Clear hold? A durable hold would bring back browser-stored state that this PR removed, and that state can disagree with other devices.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • span=615a397dbf1e website/src/utils/goalDrafts.ts:399: Reload forgets an unanswered Clear and restores the cleared goal

Kept as is: the hold on an unanswered Clear lives in memory only, so after a reload the editor shows the server's current state, the loop if it is still there and otherwise the stored goal. Nothing hidden can start, because Start and Resume act only on what the editor shows, and pressing Clear again removes it. A durable Clear hold would bring back browser-stored state that this PR removed, and that state can disagree with other devices. The adjudicator downgraded this finding for the same cost. The push note on f2ec672 asks the maintainers whether they accept this edge or want a durable Clear hold.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed e7b249e, rebased onto main d12604cc03 without conflicts. It makes two changes:

  • Each pending goal edit now records the browser tab that wrote it. A save confirmed in one tab moves only that tab's own pending edit onto the new version. Another tab's edit keeps the version its editor loaded, so its next save gets the conflict notice instead of overwriting the goal.
  • The test "a refused Start writes no draft beyond the confirmed save" now advances a fake clock instead of waiting 600 ms of real time.

The two decisions asked of the maintainers in the earlier note still stand.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: each pending edit records the tab that wrote it, and a confirmed save moves only that tab's own edit onto its answer
resolution: removed -- a confirmed save no longer moves another tab's pending edit onto its answer: only the tab that wrote an edit moves it, and an edit's default version ignores another tab's record

  • span=615a397dbf1e website/src/utils/goalDrafts.ts:321: A save acknowledgment silently rebases another tab’s stale edit

fixed in e7b249e: each pending edit now records the tab that wrote it, using the page's existing tab id. A confirmed save moves only that tab's own pending edit onto the new version. Another tab's edit keeps the version its editor loaded, so that tab's next save meets the conflict notice instead of overwriting the goal. An edit's default version is now this tab's own pending edit's, else the version this tab confirmed, else the stored edit's, so a new edit never takes another tab's newer version either. AutoNudgePopover.goalSync.test.tsx "a save confirmed in another tab leaves this tab's edit on its own version, so its next save is a conflict" fails on f2ec672: tab B's edit was moved onto tab A's version 1001.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the absence check after a refused Start advances a fake clock past twice the debounce

  • span=33c4ac1a4976 website/src/test/AutoNudgePopover.test.tsx:869: a real-time sleep is the barrier before an absence assertion

fixed in e7b249e: the test installs fake timers before it renders, advancing with real time only so its earlier waitFor steps still run, and advances the fake clock by twice the debounce with vi.advanceTimersByTimeAsync before it checks that no second draft save went out. Any save the refused Start scheduled has therefore run before the check. The suite's afterEach restores real timers.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • span=615a397dbf1e website/src/utils/goalDrafts.ts:407: Reloading discards an unanswered Clear and restores the cleared goal

Kept as is, the answer given on f2ec672, where this was goalDrafts.ts:399 and the Clear code is the same: the hold on an unanswered Clear lives in memory only, so after a reload the editor shows the server's current state, the loop if it is still there and otherwise the stored goal. Nothing hidden can start, because Start and Resume act only on what the editor shows, and pressing Clear again removes it. A durable Clear hold would bring back browser-stored state that this PR removed, and that state can disagree with other devices. This round's adjudicator upheld the finding as an ordinary combination, so the choice stays with the maintainers: the push note on f2ec672 asks whether they accept this edge or want a durable Clear hold.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 0387bc5 for GPT's upheld finding on e7b249e (goalDrafts.ts:149). When the open check shows another tab's unsaved edit in this tab's editor, this tab now takes that edit over on the version it was made on. Text typed over it is saved on that version too, so a newer goal saved elsewhere meets the conflict notice instead of being overwritten, and the tab that wrote the edit keeps saving on its own version. Two new tests in AutoNudgePopover.goalSync.test.tsx fail on e7b249e.

The E2E (stub ACP backend) failure on e7b249e was the suite reaching its 1,200 s bound with every test passing; it matches the CI runner slowdown other PRs have shown since 2026-11-04 23:05Z, docs-only ones included.

The maintainer questions in the f2ec672f note still stand.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 3cefeb8, rebased onto main b764e20635. The rebase resolved a conflict in test/test_security_gate_liveness.py: #30662 raised _PACKAGE_LINE_BUDGET by one, to 34,524, for the Railway consent host, and this PR raised it from 34,523 by 7 lines. Both are kept: main's comment line stays, the budget is now 34,531, and this PR's comment says it was raised from 34,524. The rest of the PR's diff is unchanged.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • span=615a397dbf1e website/src/utils/goalDrafts.ts:407: Reload forgets an unanswered Clear and restores the cleared goal

Kept as is, the answer given on f2ec672 and again on e7b249e. This head only rebased the PR onto main, and the Clear code is the same: the hold on an unanswered Clear lives in memory only, so after a reload the editor shows the server's current state, the loop if it is still there and otherwise the stored goal. Nothing hidden can start, because Start and Resume act only on what the editor shows, and pressing Clear again removes it. A durable Clear hold would bring back browser-stored state that this PR removed, and that state can disagree with other devices. This round's adjudicator downgraded the finding as a disproportionate remedy. The question in the push note on f2ec672, whether maintainers accept this edge or want a durable Clear hold, still stands.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

GPT's review of 3cefeb8 (the rebase) raised two new findings, both in code that has not changed since earlier rounds:

  • Moving a goal draft saved by an older version of the dashboard deletes the old copy before its replacement is saved. If this browser's storage is full and the upload to the server also fails, a reload loses that goal.
  • If the server's error reply to a Clear stalls partway through, Clear stays on "Saving..." until the page is reloaded.

Both are small. The fix for the first is ready on a local branch: the old copy is deleted only after the new one is stored, with a test that fails on 3cefeb8. Both go into the next round once the questions in this earlier note are answered, or now if a maintainer prefers.

@rubencu

rubencu commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 67f388e, a conflict-only rebase onto main 1123abf22b. Each conflict and its resolution:

  • handlers/autonudge.py: main now refuses any start-request field it does not list (_AUTONUDGE_START_FIELDS, 400 unknown_field). This PR's Start sends draft_updated_at, so the set lists it too. Without it, every Start from the goal form would be refused, which this PR's start-fence tests show. The docstring keeps main's judge and unknown-field text and this PR's draft_updated_at text.
  • The feature map keeps main's new Schedule row and this PR's edit to the Monitor loops row.
  • Pins that count both sides: 152 lazy imports (main's 150 plus this PR's 2), 355 MCP route rows with the table digest re-measured, protected-name holds of 339, 346 and 347 (main's counts plus this PR's 3), and a security package budget of 35,811 (main's 35,804 plus this PR's 7 lines).

No other code, test or description changed. The two fixes described in the earlier note are not in this push.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider raised 1 possible problem and estimates a 60% chance that this change introduces a defect; a person should check it.

The server design is sound. The store is owner-only, compare-and-set under a file lock, uses tombstones, prunes without evicting the record just written, and adds a version fence on Start. The client is complex and well tested. But the PR ties Start on every inactive goal form to the new draft store: any store failure (including the reachable 1 MiB cap, which pruning never reduces) disables Start, where main always allowed it. That, plus the 5 s read-only open, changes the defaults of a first-class loop. The PR says maintainers may prefer otherwise, and the decision the repo's lens-9 rule requires has not been recorded (First Principles BLOCK, needs-author-decision label). The head also had merge conflicts and no CI test runs at decision time. I recommend requesting changes: record the decision, or fail toward Start with the server fence when the store is unavailable and prune by size.

Things to check (possible problems the decider raised; at this confidence many turn out to be fine):

  • On main, Start on an inactive Set a goal form always reaches POST /api/autonudge. With this PR, Start depends on a new storage component. If the draft store cannot be read or written, every inactive form on every slot keeps Start disabled, even for the default template, and Retry only reads again. O (website/src/components/AutoNudgePopover.tsx, medium)

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit c6443063c0 · 4457 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@rubencu

rubencu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Pushed db21ad0, a conflict-only rebase onto main a02e90c019. Two pins that count both sides conflicted:

No other code, test or description changed. The two fixes described in the earlier note are not in this push.

@rubencu

rubencu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Pushed c8b380e, rebased onto main 0587a401f7.

No other code, test or description changed.

The inactive Set a goal form kept its draft only in browser storage, so
desktop and mobile could show different executable goal text for the
same session. Add an owner-only canonical goal-draft store behind
GET/PUT /api/autonudge/draft/slot/{slot_key}, masked from every agent
sandbox and refused by the file tools, and check the popover against it
on open with a five-second bound, the form read-only meanwhile.

Start runs only the text the store confirmed: it stays disabled during
that check, while a save is pending or in flight, and whenever the form
differs from the last confirmed answer. A draft the check shows becomes
the form's pristine baseline. Start's create request keeps the existing
goal fencing unchanged. Clear writes a timestamped tombstone after the
loop record is gone and closes once it is canonical. Pause, Play, the
cycle count, the Done state and changed-field saves keep their current
behaviour; loop writes still send the typed values and adopt what the
loop service stored, while a saved draft is held to the store's bounds.

GoalDraftStore._read_unlocked joins the link-screen baseline as a site
that refuses every link: it reads a gateway-owned file in a directory
no sandboxed process can see, and it never traverses a link it found.
@rubencu

rubencu commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 7e75a24, rebased onto main 0d68cae9e6. The conflicts were all in pins main has since moved to new formats, so each is resolved in main's format:

  • Main now caps the security package with one row file per change instead of editing _PACKAGE_LINE_BUDGET. The pin is main's again, and this PR's 7 lines of hidden-leaf declarations are now test/security_line_budget/goal-drafts-hidden-leaf.txt (+7).
  • Main replaced the MCP route table's count and digest with test/fixtures/dashboard_mcp_route_table.txt. The PR's three routes (HEAD, GET and PUT /api/autonudge/draft/slot/{slot_key}) are now rows there.
  • Main's lazy-import check now scans the owners' function bodies, and its leaf-only test accepts any name at a crew-home root. So the PR's two lazy-import table rows and its goal-drafts leaf-only count are dropped; both tests pass unchanged with this PR's code.
  • AutoNudgePopover.tsx: main moved runModel to components/workflows (refactor: move the workflow run views out of the workflows app #36348), so the import uses the new path.

No other code, test or description changed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) needs-author-decision PR blocked on author input readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants