fix(workflows): recover terminal artifact commits - #386
Conversation
|
CI status note: Node 22/24 completed this PR's repository checks and failed only at the final fresh-install I reproduced the packed install independently: npm now admits Pi 0.85.0 through OpenPI's published No dependency workaround is mixed into this feature PR. |
tt-a1i
left a comment
There was a problem hiding this comment.
需要改:「已提交」不要用整份 workflow.json 字节当身份
文档写 crash 在 unlink 之后是 harmless,因为 recovery 认得 already-committed manifest。实现用 整份 workflow.json 字节相等 判断 already-committed。
这不是无害窗口:persistWorkflowDeliveryState、#382 的 delivery owner、#379 的 resourceRefs 都会改同一份文件。下一轮 recoverPendingWorkflowCommit 会把收据里更旧的 manifest 写回去。
请用 run id + 终态 + artifact 引用(名字/digest)判断 already-committed,不要比整文件字节。和 #379/#382 叠在 artifacts.ts 上之前,先把这个身份修好。
Problem
Workflow terminal persistence writes
result.json,transcripts.json, optionaljournal.json, and the final referencingworkflow.jsonas separate atomic replacements. A process crash after the side artifacts but before the final manifest can leave the earlier manifest without references and the terminal evidence orphaned.Current
mainalready publishes a reference-free terminal manifest first, which prevents a known terminal run from remainingrunning, but it cannot prove that an otherwise orphaned artifact belongs to a complete terminal commit.Closes #110.
Value
Restart recovery can now distinguish a fully prepared terminal artifact set from partial, stale, substituted, or malformed files. Exact terminal results remain discoverable after the crash window without treating an arbitrary
result.jsonas completion evidence.Approach
.workflow-commit.jsonreceipt before the terminal side-artifact sequence. It records the exact final manifest plus the fixed artifact names, byte counts, and SHA-256 digests.workflow.jsoncanonical: publish the existing reference-free terminal projection first, prepare every side artifact, atomically commit the exact recorded manifest last, then remove the receipt.result.jsonalone never proves completion.docs/architecture/WORKFLOW_ARTIFACT_COMMIT.md, linked to workflows: terminal artifact set (result.json + workflow.json) is not committed atomically #110.Validation
bun run check— passed.bun run test— Node tests: 1247 passed, 0 failed, 1 skipped; Vitest: 30 passed.Impact
.workflow-commit.json; successful writes remove it, and legacy artifacts remain readable.writeFileAtomic.