S021: queue schedules, pause and limits, dependencies, power actions
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
parent
293b91fecb
commit
4407404b85
2 changed files with 591 additions and 21 deletions
|
|
@ -199,3 +199,8 @@ Verified: `nice cargo test -j 2 -p medlar --test add` green (14, four with the r
|
|||
Not done: the desktop's file chooser (portal) was never tried, only that it fails plainly is in the code; links of a batch are not asked about; what is known is found when the fields change, not when the list does; a start time is kept but queue schedules are S021's, and time asleep doesn't count; a metalink file is refused as a list (`read_metalink` is not wired, 3.3); files already on disk but not in the list are not noticed (the engine numbers names); no hidden release run.
|
||||
Later: `App` doesn't set `ClientOptions::known_hosts` yet (S011).
|
||||
Seen: boxes were ticked together after the tests, against rule 3.
|
||||
|
||||
## S021 — Queues, schedule, power (compiled, not tested)
|
||||
- `schedule::{Clock, SystemClock, ManualClock, open, opened_between, Grid, cycle}`; set `Config.clock`. The manager's `choose` now reads queue `paused`, `max_active`, `schedule` and task `after` (a forced start overrides them); `Edit` of `after` refuses loops (`Error::Cycle`).
|
||||
- `power::{Watcher, WhenDone, Action, Scope, Power, Logind, Inhibitor}` (countdown, conditions, failure blocks unless `even_failed`); `run::{RunSpec, Vars, run}`.
|
||||
- Not done: no UI or app wiring for these, the `Grid` is not applied to the limiter, `start_at` stays on `Hold::Until` (asleep time not counted). Tests: `docs/tests/S021-queues-schedule-power.md`.
|
||||
|
|
|
|||
45
docs/tests/S021-queues-schedule-power.md
Normal file
45
docs/tests/S021-queues-schedule-power.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# S021 — Queues, schedule, power: test file
|
||||
|
||||
Written by the worker that built it, run by the test phase. Nothing here has been tested until its Result says so.
|
||||
|
||||
## Built
|
||||
`crates/core/src/schedule.rs` · `Clock`, `SystemClock`, `ManualClock`, `Schedule::contains`, `open`, `opened_between`, `Grid`, `cycle`.
|
||||
`crates/core/src/power.rs` · `Action`, `Scope`, `WhenDone`, `Watcher::{arm,cancel,step}` (countdown, conditions), `Power` trait, `Logind`, `Inhibitor`.
|
||||
`crates/core/src/run.rs` · `RunSpec`, `Vars`, `expand`, `run` (no shell, timeout, output to log).
|
||||
`crates/core/src/manager/{actor,pick}.rs` · `choose` reads queue `paused`, `max_active`, `schedule` and task `after`; `Config.clock`; `Error::Cycle` on `Edit`.
|
||||
|
||||
## Checks
|
||||
Risk: HIGH = data loss, security, crash, wrong result · MED = feature broken · LOW = looks or comfort.
|
||||
|
||||
| # | Risk | Do this | Expect | How | Result |
|
||||
|---|---|---|---|---|---|
|
||||
| 1 | HIGH | Queue with `paused`, add a task to it | task stays Queued, nothing downloads; unpause starts it | integration (testserver, `Config.clock` default) | — |
|
||||
| 2 | HIGH | Queue `max_active = 1`, three tasks, global max 4 | only one runs at a time, the others follow in order | integration | — |
|
||||
| 3 | HIGH | Queue schedule Mon 22:00-06:00 on a ManualClock at Mon 21:59, then advance 2 minutes | task starts within one look (~15 s real, or send a command to force choose) | integration | — |
|
||||
| 4 | HIGH | Running task, clock leaves the window | task goes back to Queued, not Failed; returns when the window opens | integration | — |
|
||||
| 5 | HIGH | Start by hand (`forced`) in a paused or closed queue | it runs | integration | — |
|
||||
| 6 | HIGH | Task B `after` A; A Running | B stays Queued; when A is Done, B starts | integration | — |
|
||||
| 7 | HIGH | `after` pointing at itself, at a chain that returns, at a removed task | first two give `Error::Cycle` and nothing is saved; the last is accepted and B isn't held | integration | — |
|
||||
| 8 | HIGH | `Watcher` with `even_failed = false`, one Done and one Failed | `Step::Blocked`, disarmed, never fires | unit | — |
|
||||
| 9 | HIGH | Same with `even_failed = true` | countdown starts, fires after the countdown | unit | — |
|
||||
| 10 | MED | Cancel during the countdown; a task of the scope starts again | `Idle` after cancel; a new running task resets the countdown | unit | — |
|
||||
| 11 | MED | Scope Queue(2) while queue 1 still runs | fires when queue 2 is done | unit | — |
|
||||
| 12 | HIGH | `ManualClock` zone with +1 h at the 2026-03-29 01:00 UTC step (Europe), window 02:00-03:00 | `contains` follows local time: closed before, open after; no panic in the skipped hour | unit | — |
|
||||
| 13 | MED | Zone change (offset +0 to +9 h) while window 22:00-06:00 | open/closed follows the new wall time at once | unit | — |
|
||||
| 14 | MED | `opened_between` over a 10-hour sleep that spans a window start, and one that spans none or only an end | true for the first; false for the others; scan capped at 8 days | unit | — |
|
||||
| 15 | MED | Night window Mon 22:00-06:00 | Tuesday 05:59 open, 06:00 closed, Monday 05:00 closed; `from == to` is the whole day | unit | — |
|
||||
| 16 | MED | `Grid::new` with 167 and 168 cells; `at` on Monday 00:30 and Sunday 23:30 | None for 167; first and last cell | unit | — |
|
||||
| 17 | HIGH | `expand` with `{file}` = `/a b/c; rm -rf /` | one argument, unchanged; no shell run | unit | — |
|
||||
| 18 | MED | `run` with `sleep 5`, timeout 1 s; with `echo hi`; with a missing program; with exit code 1 | timeout error naming seconds; Ok("hi\n"); "did not start"; "ended with" error | integration | — |
|
||||
| 19 | HIGH | Fake `Power` that records calls: drive a `Fire(Shutdown)` through the caller | only the fake is called; `Logind` is never used in tests | unit | — |
|
||||
| 20 | LOW | `Logind::can` on this PC (capabilities only, no perform) | Shutdown/Suspend answer without calling the methods; Quit and Run always true | by hand | — |
|
||||
|
||||
## Needs
|
||||
`crates/testserver` on 127.0.0.1; a throwaway home; a `ManualClock` in `Config.clock`. Never call `Logind::perform` or `Inhibitor::take` for real in tests except by hand on check 20 (capabilities only).
|
||||
|
||||
## Doubts
|
||||
- Not wired yet: the app's UI for queues, schedules and when-done; nothing calls `Watcher`, `Logind`, `Inhibitor` or `run::run` outside tests; the speed `Grid` is not applied to the limiter; no model fields for once-only schedules (a task's `start_at` is the once rule and is still `Hold::Until`, untouched).
|
||||
- `schedule` is read when `choose` runs; a clock jump is seen at most 15 s later (`SCHEDULE_LOOK`), and `Hold::Until` still uses `Instant`, so time asleep does not count for a start time.
|
||||
- A closed or paused queue pushes running tasks back to Queued; a task running in a queue that gets paused is suspended, not paused.
|
||||
- `pick` and `Candidate` got a field and a parameter; the unit tests in pick.rs were edited to match, not run.
|
||||
- Fall-back hour: the window counts twice (documented); not covered by a check.
|
||||
Loading…
Reference in a new issue