Repository navigation
fix: check the task before tasks complete --artifact writes any file - #91
Conversation
`tasks complete --artifact path=text` wrote each file while the arguments for completeTask were being built, before the task was read and before any of completeTask's checks. Found 2026-11-09: - completing a finished task again replaced its artifact, then was refused; `results artifact` failed from then on with "Result artifact changed after finalization"; - a mistyped task id did the same to whichever answer lived at the path; - an open task completed with another task's artifact path replaced that task's answer and was accepted; - a path refused as not a result artifact was written anyway. The new BridgeStore.writeResultArtifactTexts reads the task first (so a missing id fails before anything is written), checks the stored paths with the same fetchable and distinct checks completeTask uses, leaves a finished task's files alone (completeTask then refuses, or accepts the same result again), and writes each file exclusively: a path that already holds other text is refused, the same text is accepted for a retry. Verified: tests/task-complete-artifact-order.test.ts fails 4 of 5 against main and passes here (the fifth guards the accepted path); tests/duplicate-result-artifacts.test.ts still passes with the new signature; npx tsc --noEmit; full suite 1874 passed, 3 skipped. Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
What this touches
5 file(s), 133 line(s) changed. Tests changed. Worth a look
This is an automated first pass, not a review. CI is the gate; a person decides. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3d3436212
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const artifacts: BridgeFile[] = texts.map((text) => ({ path: this.relativeToRoot(this.resolveArtifactPath(text.path)), role: "result" })); | ||
| assertFetchableResultArtifacts(artifacts); | ||
| assertDistinctArtifactPaths(artifacts); | ||
| if (task.status === "done" || task.status === "blocked") return artifacts; |
There was a problem hiding this comment.
Validate artifact text before accepting a terminal-task retry
When a done task has a missing or untrusted completion receipt, completeTask permits a matching retry to repair it. This early return discards the supplied artifact text, while assertResultMatchesRetry compares artifacts only by path and role. Consequently, retrying with the original summary and artifact path but different --artifact path=text content succeeds and signs the old answer, silently ignoring the requested text. Keep terminal-task files untouched, but compare their contents with the supplied text and reject a mismatch before allowing receipt repair.
Useful? React with 👍 / 👎.
…t writes any file) to the container image Same change as main PR #91 (merge 33a7e0a), released in 0.40.51, applied to src, tests and docs without changes. The CHANGELOG lines are main's with the PR noted. Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
Problem
prodex tasks complete <task> --artifact path=textwrote each file before reading the task. The writes happened while the arguments forcompleteTaskwere being built, so any refusal came after the file was already replaced. Found 2026-11-09:prodex results artifact <task>then failed with "Result artifact changed after finalization", and the original answer was gone..bridge/artifacts/pro-consults/<task>.md, had already been overwritten..bridge/artifacts/notes/...): the file was written anyway.Change
BridgeStore.writeResultArtifactTexts(taskId, texts)runs before anything is written, and the CLI calls it:completeTaskuses.completeTaskthen refuses, or accepts the same result again, as before.writeArtifactText(..., { exclusive: true })). A path that already holds other text is refused; the same text is accepted, so a retry still works.writeTaskCompleteArtifactsnow takes the task id.Verification
tests/task-complete-artifact-order.test.ts: 5 cases throughrunCli. 4 fail against main; the fifth checks that an accepted completion still writes its artifact. All 5 pass here.tests/duplicate-result-artifacts.test.tspasses with the new signature.npx tsc --noEmitpasses. Full suite: 1874 passed, 3 skipped.