merge(app): bring main into flutter/t1-data candidate

Keep main's landed retry action and saved-schedules slices alongside the
templates data slice. Resolve app/.gitignore by keeping the single
test/**/data/ negation both sides added, with the explanatory comment.

Checks after merge: dart format clean, flutter analyze clean, 111 tests pass,
flutter build web succeeds.
This commit is contained in:
2026-10-21 15:32:48 +01:00
21 changed files with 2133 additions and 3 deletions
+114
View File
@@ -0,0 +1,114 @@
# R2c — native retry / restart action
Small app-only addition, new files only. `RetryRunAction(run, gateway,
onRunChanged)` is the deliberate retry entry point for a stopped failed run; it
does not add a screen or controller and is not wired into the shell.
## What changed
| File | Lines | Responsibility |
| --- | --- | --- |
| `lib/features/runs/actions/retry_action.dart` | 123 | `RetryRunAction`, gating, send/refusal/resync orchestration |
| `lib/features/runs/actions/retry_dialog.dart` | 207 | Native resume/restart confirmation, refusal display, key lifetime |
| `lib/features/runs/actions/retry_eligibility.dart` | 16 | `canRetryRun` mirroring the web `canRetry` |
| `lib/features/runs/actions/retry_intent.dart` | 29 | Mode, confirmed intent and idempotency-key generation |
| `lib/features/runs/actions/retry_wording.dart` | 33 | Web-verbatim words, titles, error wording and test keys |
| `test/.../retry_test_support.dart` | 112 | Fake gateway and Material/Cupertino hosts |
| `test/.../retry_action_test.dart` | 245 | Eligibility, both platforms, modes and key fields |
| `test/.../retry_resilience_test.dart` | 223 | Immediate refusals, recheck outcomes, key retention |
| `test/.../retry_safety_test.dart` | 133 | Double submit, late replies, narrow 2x layout |
No repository, gateway, socket, controller, shell, main, pubspec, web, server or
device file was edited.
## Behavior
Eligibility is exactly the browser's rule: a loaded run that is not executing and
whose status is `failed` (`run != null && !run.executing && status == "failed"`).
A stale `failed` status while execution is still in flight, a running/waiting/
succeeded/canceled run, and a malformed run render nothing.
The button is a Material `FilledButton` or a Cupertino `CupertinoButton.filled`,
labelled `Retry`. Opening the prompt sends nothing, and `Keep` only closes it.
The first confirmation is the browser's retry copy: title `Retry run {id}?`,
message `Only failed runs can be retried. The server starts a new run from the
same input.`, confirm `Retry`, dismiss `Keep`, plus the browser-only secondary
`Restart from start` that leads to a distinct confirmation. That second prompt
uses title `Restart run {id}?`, message `This replays the whole pipeline from the
start instead of resuming the failed stage.` and confirm `Restart from start`;
the resume actions are gone, so the more destructive choice cannot be mistaken
for resume.
Resume calls `RunsRepository.retryRun` with only `run_id` and `request_key`, so
`retry_mode` is omitted and the server's `resume` default applies. Restart sends
`retry_mode: "restart"` with the same two required fields.
A `request_key` is created on the first confirm of an open prompt, not on opening
or `Keep`. It survives a refusal, so pressing confirm again for the same
uncertain request reuses the key and the server can dedupe it. Closing the prompt
and opening it again is a fresh deliberate intent and gets a new key, so a resume
attempt followed by a restart attempt never shares a key. Switching to the
restart confirmation before any send simply confirms restart with that prompt's
first key. Keys are bounded and run-scoped (`app-retry-{runId}-…`, well under the
server's 128-character cap).
A server refusal returns to the prompt immediately: the exact server words are
visible and `Keep`/back are available while the detached `get_run` recheck is
still pending. One bounded re-read is issued per refusal, single-flight through a
retained future, with no retry loop or polling. If server truth says the run is no
longer retryable, confirm is disabled and an attempted tap sends nothing; the
refusal stays visible until dismissal. If the recheck itself fails, truth is
unknown, so confirm is re-enabled and a deliberate retry uses the retained key.
Late retry replies and late rechecks after disposal or navigation are ignored.
Construction, controls and error colour are standard Material/Cupertino defaults;
there is no custom palette, fixed control size or dependency. The narrow layout
relies on the native dialog's own scrolling/wrapping.
## Acceptance checks
Fake-gateway widget tests, both platforms, no socket or real server:
- eligibility table for stopped failed vs executing failed, running, waiting,
succeeded and canceled runs, plus the same visibility table under both apps;
- `Retry` opens the native `AlertDialog`/`CupertinoAlertDialog`, `Keep` closes it
and the recorded gateway calls are still empty;
- resume sends exactly `{run_id, request_key}` and no `retry_mode`; restart sends
exactly `{run_id, request_key, retry_mode: "restart"}`;
- key format is deterministic under an injected clock/entropy, bounded, fresh per
call, retained across an uncertain retry (resume and restart), and different
after a deliberate reopen or mode change;
- refusal message appears while `get_run` is deliberately unresolved, with Keep
enabled, confirm disabled and no callback yet; Keep then closes and the late
recheck still delivers server truth safely;
- ineligible recheck (`succeeded`) blocks a repeat action; failed recheck leaves
the same key and a working deliberate retry;
- two confirm taps while in flight produce one `retry_run`; both the retry reply
and the recheck are safe after disposal;
- 320×480 at 2× text: both resume and restart confirmations render on both apps
with no exception, and Keep sends nothing.
## Checks actually run
```
dart format lib/features/runs/actions test/features/runs/actions # clean
flutter analyze # No issues found!
flutter test test/features/runs/actions # 40 passed
flutter test # 69 passed
flutter build web # Built build/web (14.5s)
```
## Honest limits
- **Not wired into a run-detail screen.** This branch has no runs screen or
controller; the manager owns that integration. There is no browser interaction
or rendered capture for this widget, and `flutter build web` proves compilation
only, not rendered behavior.
- Browser parity is by source/word/request-shape comparison with
`web/src/actions.js` and `web/src/repository.js`; the web client itself was not
changed and no live web retry was performed.
- **Mobile unverified.** No Android/iOS build, emulator, ADB or device was used.
- No real server or run was retried, canceled or otherwise mutated; all evidence
uses local fakes.
- The candidate is committed, not pushed or deployed.
+94
View File
@@ -0,0 +1,94 @@
# S1a — saved-schedule repository and record
## What changed
New, app-only files (no existing feature, shell, transport, `main` or pubspec
source edited):
| File | Lines | Responsibility |
| --- | --- | --- |
| `lib/features/schedules/data/schedules_repository.dart` | 116 | `list_schedules`, `save_schedule`, `delete_schedule` envelopes and reply checks |
| `lib/features/schedules/domain/saved_schedule.dart` | 87 | typed view over one saved run configuration; exact raw record retained |
| `lib/features/schedules/domain/schedule_rule.dart` | 41 | interval/clock/timezone/weekday fields of `rule` |
| `lib/features/schedules/domain/schedule_json.dart` | 22 | deep JSON copy used by every round trip |
| `test/features/schedules/data/schedules_repository_test.dart` | 132 | list/create/update envelopes, unchanged input, CAS revision |
| `test/features/schedules/data/schedules_delete_test.dart` | 131 | delete envelope, confirmations, refusals, missing/empty replies |
| `test/features/schedules/data/schedules_protocol_bounds_test.dart` | 81 | web-mirrored ID/revision/request-key bounds |
| `test/features/schedules/data/saved_schedule_record_test.dart` | 101 | provenance, unknown fields, deep-copy and absent-field behavior |
| `test/features/schedules/data/schedule_test_support.dart` | 83 | recording fake gateway and server-shaped fixtures |
`app/.gitignore` also gained the missing `!/test/**/data/` exception. The root
`.gitignore` ignores every `data/` directory, so without it these assigned tests
would silently disappear from a fresh checkout. The existing `!/lib/**/data/`
exception is for the same reason.
## Behavior copied from the current web client
Requests are exactly the ones in `web/src/repository.js`:
- `list_schedules` with no field, or `pipeline_id` for one pipeline. A positive
safe integer is required before sending; `{type:"schedules"}` or
`schedules:null` is an empty list, while a reply without `type:"schedules"` is
an error, not "no schedules".
- `save_schedule` with `schedule` unchanged. A non-empty `request_key` (at most
128 characters) is added only for a create retry; updates omit it, as the web
editor does. Creation keeps the web sentinel `id: 0` and no revision. Updates
send the record read from the server, whose `revision` is the server's
compare-and-swap token. The reply is only accepted when it contains
`schedule`.
- `delete_schedule` with exactly `schedule_id` and `expected_revision`; only
`{type:"schedule_deleted", schedule_id:<same id>}` counts as success.
Server refusals are not wrapped or translated. `ApiGateway` already turns an
`error` envelope into `ProtocolError` with the server's text, and the repository
lets that object through unchanged (conflict and unknown-command coverage in
`server refusals and conflicts propagate verbatim`). The repository has no
capability flags, no "not supported" substitution and no local fallback.
Saved schedules are run configurations, never pipeline definitions. `SavedSchedule`
keeps the complete server map, including unknown future nested fields, and
exposes pipeline, version, prompt/input, workspace, rule (every/times/days/
timezone), enabled, model/stage models, notify mode, write paths/tools, title,
output format, due time and timestamps. `toJson()` is a deep copy; `withEnabled`
preserves identity, revision and unknowns. Missing identity/revision stays
`null` rather than becoming a fabricated `0`. There is no timer execution,
polling, rule parsing into due dates or timezone conversion in this slice.
## Checks actually run
```
flutter pub get
dart format lib/features/schedules test/features/schedules # 9 files, 5 changed, then clean
flutter test test/features/schedules/data # 18 passed
flutter analyze # No issues found! (1.4s)
flutter test # 70 passed
```
Focused coverage maps to the requested acceptance:
- exact `list_schedules`/`save_schedule`/`delete_schedule` bodies recorded by a
fake gateway, including `expected_revision` only on delete and no invented
create revision/key;
- untouched caller record on save; deep equality of returned records with the
server reply including unknown top-level/rule/input fields;
- update reuses revision 3, accepts server revision 4 and leaves the stale draft
at 3; a mismatch is the server's refusal, propagated verbatim;
- empty list vs missing/unsupported schedules reply, missing/invalid saved
schedule, and delete confirmation for the wrong id/type;
- preflight bounds match the web client: pipeline id, schedule id, revision and
129-character request keys send nothing; 128 characters is accepted;
- no fabricated identity when a reply contains an empty schedule object.
## Honest limits
- **No UI or wiring.** There is no schedules screen, editor, pause/delete control
or shell registration in this slice; the manager owns later UI integration.
No browser interaction or screenshot applies to this nonvisual item.
- **No live server used.** All checks use local recording fakes; no production
schedule, run or workflow was created, changed or deleted. No polling or
scheduler was touched.
- **Mobile unverified.** Only web-targeted Flutter tests and analysis ran. No
Android/iOS build, emulator, ADB or device was used; the code is pure Dart.
- **Not committed.** The stage instruction for this visit forbids commit, push
and deploy, so the candidate remains in the `flutter/s1-data` worktree for the
manager to inspect and commit. No deployment or preview was performed.