Files
pipelines/app/notes/S1a.md
T
alan b9639650e5 feat(app): add saved-schedule repository and domain record
Port the web client's list/save/delete schedule request shapes and reply checks, with a typed record that preserves the whole server payload including unknown fields. Revision stays the CAS token; server refusals propagate unchanged.
2026-10-21 15:15:47 +01:00

5.5 KiB

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.