Slot Outcome Taxonomy
Business-purpose: “没有内容可发布”不是系统故障。
no_candidate / duplicate_exhausted / filter_exhausted are normal business endpoints. System failures (pixiv API, network, download, processing, delivery) are a separate set and must be monotone — it is illegal for a business no-content verdict to transition into internal_error.
Two dimensions — never conflate
slot.status = execution lifecycle (pending / running / success / partial / failed)
business_status = business result (success / partial_success / no_candidate / duplicate_only / failed)Rule (documented contract):
禁止使用
business_status驱动 scheduler 状态转换。slot.status描述执行是否结束;business_status描述业务结果。 把duplicate_only当作失败去驱动调度/重试,会把正常空结果变成事故。
Derived business status
classifySlotBusinessStatus projects the durable terminal cell ledger into one verdict (stored slot phase machine is untouched for compatibility):
| business_status | rule | admin meaning |
|---|---|---|
success | every cell submitted | all good |
partial_success | some submitted + others no-content or system | partially good |
no_candidate | nothing submitted, all cells business no-content (no_match, maybe + duplicate) | no new work |
duplicate_only | nothing submitted, every non-submitted cell duplicate | all candidates already published |
failed | system failure (executor_failed/delivery_failed) and nothing submitted | needs attention |
Legal transitions
success ─────────────── fine
partial_success ─────── fine
no_candidate/duplicate_only ── never -> internal_error
(these are terminal business no-ops)
failed ─────────────── system retry/backoffPixiv timeout/5xx ── retry (retryable=true)
Pixiv 429 ──────── backoff (retryable=true)
Pixiv 403/401 ──── PIXIV_AUTH_FAILED (retryable=false)
download 404 ───── PIXIV_NOT_FOUND (retryable=false)
candidate all duplicate ── duplicate_exhausted, no fallbackWhy duplicate-only must NOT fallback
A fallback is only legal when it can surface NEW candidates. If the scan attempted 0 and every skip is duplicate, the same stale duplicate pool is returned every retry — retrying only burns the scheduler budget and ends in a misleading OperationCancelledError/internal_error. See isDuplicateOnlyDeadEnd / candidate_exhaustion event.
User-facing copy (never leak internal names)
| outcome | user message |
|---|---|
success | 任务完成,已发布本轮内容。 |
partial_success | 任务部分完成,部分内容已发布。 |
no_candidate | 本轮没有找到符合条件的新作品,任务已正常结束。 |
duplicate_only | 本轮没有找到新的作品:搜索结果中的候选均已发布过。任务已正常结束。 |
cancelled | 本轮任务已被取消,不会继续发布。 |
failed | 本轮任务遇到系统异常,请稍后重试或检查日志。 |
Admin still sees full stack / trace_id / pixiv_id / stage / retryable in logs and system_errors.
Liveness terminal reasons(不再有无限 RUNNING)
一个 slot 不允许「永远 RUNNING」。常驻调度器的 liveness 扫掠(默认 60 s 一次)会把 超过预算且没有推进的 slot 终结为 failed,并把原因码写进 durable ledger:
| reason code | 触发条件 | 用户文案 |
|---|---|---|
queued_too_long | 仍是 pending 且超过 schedulerRuntime.queuedTimeoutMs(默认 30 min)仍未开始执行(如账户容量一直忙) | 排队超时,未能开始执行 |
stalled_no_heartbeat | running 且 heartbeat_at(回落 started_at/created_at)超过 schedulerRuntime.stallTimeoutMs(默认 15 min)没有推进,且执行租约已死 | 执行中断,长时间没有进展 |
delivery_abandoned | cell 已到投递阶段却没有任何可执行投递,也没有其它运行中的租约 | 投稿未被处理,已放弃 |
规则:同一 tick 先恢复被中断的 slot(crash-resume),再终结超预算的 slot,刚恢复 的 slot 本轮不参与终结判定;只终结 pending/selected 的 cell,已被下游 ACK 的 submitted cell 不改写;终结后用同一条 deriveSlotStatus 投影派生 slot 状态(因此部分 投递过的 occurrence 可能报 partial 而不是 failed)。这三类都算系统失败 (business_status = failed,alertable),与 no_candidate/duplicate_only 这类正常业务 空结果严格分开。对外只暴露封闭的协议错误码(见本仓 vendored 副本 protocol/v1/error-mapping.json,权威与校验清单 SOURCES.sha256 同目录),内部原因码仅用于诊断。
Consumer cancel(cancelled_by_consumer)
消费者(TelePost / 人工)主动停止一个 job 时,ledger 用同一个 FSM 状态 failed 终结该 cell(协议明确禁止发明新的 cell 状态),但带上专门的内部原因码 cancelled_by_consumer,与「系统/上游失败」严格区分:
| reason code | 触发条件 | 用户文案 |
|---|---|---|
cancelled_by_consumer | POST /jobs/{job_id}/cancel(或运维主动取消):同一事务里终结未完成的 cell 并取消其可执行的 outbox 投递 | 任务已被取消 |
规则:
- 不是故障:
retryable: false,business_status = cancelled(仅当该 occurrence 没有 其它真实失败时才这样报;有真实失败仍报failed),因此 绝不 alertable——否则每次 取消都会叫醒运维。userMessageForSlotBusinessStatus('cancelled')给出上面那句文案。 - 幂等:重复取消返回当前投影(HTTP 200),不会重复终结、不会报错;已终结的 cell 不改写。
- 对外映射为协议
Job.status = cancelled+error.code = cancelled_by_consumer, 内部原因码只出现在error.detail.internal_code。
告警规则(alertable)
alertable 只在 business_status === 'failed' 为 true。监控只对 failed 报警;success / partial_success / duplicate_only / no_candidate / cancelled 都不是故障。
| business_status | alertable | 说明 |
|---|---|---|
| success | false | 正常 |
| partial_success | false | 部分投递成功,其余为无内容(不报警) |
| duplicate_only | false | 无新内容,业务正常 |
| no_candidate | false | 无新内容,业务正常 |
| cancelled | false | 消费者主动取消,无故障(不报警) |
| failed | true | 含 pixiv/network/download/processing/delivery 失败 |
Events
candidate_exhaustion(INFO): structured business event emitted when a scheduled target terminatesno_candidate:{stage, result, reason, searched, duplicates, filtered, attempted, slot_ids}.schedule.outcomeadds:outcome_version: 2(taxonomy version; v2 =business_status增加cancelled;无消费者读取该字段,升级不影响既有消费者)business_statusderived verdictalertable: boolean(onlyfailed= system failure)
system_errorsis reserved for SYSTEM failures;duplicate_exhausted/no_candidateare never recorded there as ERROR.
Manual recovery outcome (「放宽条件重试」)
小说的全文语言检查在候选锁定之前完成;空正文、语言不匹配或无法满足严格语言规则的 候选不产生持久锁定和文件,可以继续检查下一篇。通过检查后,先锁定作品再写文件, 重启仍恢复同一作品。旧版本留下的锁定作品若不符合语言规则,保留原身份并报告 filter_exhausted,不会把它伪装成“内部错误”,也不会自动换稿。
需要补回失败的小说时,使用下述单目标恢复入口;不要重跑整个计划或修改执行数据库。
A manual recovery (POST /internal/targets/:targetId/recover) opens a dedicated <schedule>@recover-<requestId> slot and reports through the normal schedule-outcome channel. The recovery business verdict is NOT the raw cell status — the UI (Mini App / Telegram card) must translate via RecoveryOutcome.recoveryOutcomeFor:
| recovery_state | raw cell evidence | user copy |
|---|---|---|
recovery_pending | no cell yet | 正在等待恢复任务... |
recovery_running | pending/selected/artifact_ready/delivery_pending | 正在尝试扩大搜索范围... |
recovery_success | submitted | 恢复成功,已找到并发布新作品。 |
recovery_no_candidate | no_candidate (other) | 扩大搜索范围后,仍未找到符合条件的新作品。任务已正常结束。 |
recovery_duplicate_only | no_candidate/duplicate with duplicate_exhausted | 扩大搜索范围后,找到的作品均已发布过。没有新的内容可发布。 |
recovery_failed | failed | 恢复任务执行失败。请查看日志或稍后重试。 |
Idempotency: the slot id is deterministically derived from requestId (<scheduleId>@recover-<requestId.lower>); a repeated click with the SAME requestId converges to the same slot and returns already_completed when it already terminated — it never opens a second task, so a double tap cannot double-publish. A DIFFERENT requestId is a distinct new business request by design.