DAEMON's docs/adr/0013-task-state-machine-ownership.md needs a wire signal
for the difference between a paused task the daemon entered unilaterally
(auth_required, server_file_changed, disk_full) and one that was requested
(user, schedule, queue stop, admission reconcile) -- without it, DAEMON's §3
resume rule ("resume only when the reason matches the event that justifies
resuming") has nothing correctness-preserving to key on, and would have to
guess from timing. CORE has already accepted the ADR; this was the sole
remaining blocker per DAEMON's own status line on it.
No retype, no new field -- error was already TaskError | null on both
event.task.state and TaskSummary, exactly as DAEMON characterized the ask.
Only the *description* of when it is populated widens: previously "failed or
retry_wait", now also "paused, when the daemon entered it on its own
initiative". A deliberate pause still carries error: null. TaskError's own
top-level description gets the same widening, since it previously also said
"failed or retry_wait" and would otherwise contradict the field that embeds
it.
New fixture (event.task.state.auto-paused.json) exercises the case directly:
an auth_required pause with error populated, contrasted in its own
description against download.pause.json's error: null for a requested pause.
The existing event.task.state.json fixture's first assertion was stale
("error is present exactly when failed or retry_wait") and is corrected.
Minor bump, 1.2.0 -> 1.3.0: a description widening on an already-nullable,
already-optional field changes no JSON Schema shape, but it is a real
behavioral commitment change worth a version bump so downstream regenerates
and notices, per the same reasoning ADR 0010 applied to TaskErrorCode.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012fgjnqFCS5h5L7gZTZo3rV
58 lines
2.4 KiB
JSON
58 lines
2.4 KiB
JSON
{
|
|
"name": "event.task.state \u2014 the daemon auto-pauses on a 401",
|
|
"description": "The CORE-auto-pause case ADR 0013 (docs/adr/) needs a wire signal for: the daemon paused this task on its own initiative -- not because the user clicked pause, a schedule window closed, or admission control reconciled a lowered cap -- and error explains why. Compare download.pause.json, where the same target state (paused) carries error: null because that pause was requested.",
|
|
"notification": {
|
|
"jsonrpc": "2.0",
|
|
"method": "event.task.state",
|
|
"params": {
|
|
"taskId": "8c1d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
|
|
"state": "paused",
|
|
"previousState": "connecting",
|
|
"summary": {
|
|
"taskId": "8c1d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
|
|
"filename": "film.mkv",
|
|
"saveDir": "/home/sami/Downloads/Video",
|
|
"url": "https://example.org/film.mkv",
|
|
"effectiveUrl": "https://example.org/film.mkv",
|
|
"sizeBytes": 1503238553,
|
|
"downloadedBytes": 0,
|
|
"state": "paused",
|
|
"speedBps": 0,
|
|
"etaSeconds": null,
|
|
"resumable": true,
|
|
"segments": 4,
|
|
"categoryId": "video",
|
|
"queueId": null,
|
|
"queuePosition": null,
|
|
"description": null,
|
|
"createdAt": "$isoDate",
|
|
"lastTryAt": "$isoDate",
|
|
"completedAt": null,
|
|
"error": {
|
|
"code": "auth_required",
|
|
"message": "the server asked for credentials (401)",
|
|
"httpStatus": 401,
|
|
"retryable": false,
|
|
"cause": null,
|
|
"attempt": 1,
|
|
"nextRetryAt": null
|
|
}
|
|
},
|
|
"error": {
|
|
"code": "auth_required",
|
|
"message": "the server asked for credentials (401)",
|
|
"httpStatus": 401,
|
|
"retryable": false,
|
|
"cause": null,
|
|
"attempt": 1,
|
|
"nextRetryAt": null
|
|
}
|
|
}
|
|
},
|
|
"assertions": [
|
|
"error is set here specifically because the daemon paused this task itself, not the user -- the trigger is event.auth.required on the same task shortly before",
|
|
"the scheduler must not resume this task on a schedule window or queue restart: only download.provideAuth (or the user explicitly resuming) may clear it -- resuming blindly re-fails immediately and looks like a flapping bug",
|
|
"a client distinguishes an auto-pause from a deliberate one by this field being non-null, not by inspecting previousState or any other heuristic"
|
|
]
|
|
}
|