Skip to content

fix: check the task before tasks complete --artifact writes any file - #91

Merged
youdie006 merged 2 commits into
mainfrom
fix/task-complete-artifact-order
Nov 9, 2026
Merged

youdie006 merged 2 commits into
mainfrom
fix/task-complete-artifact-order

Conversation

@youdie006

Copy link
Copy Markdown
Owner

Problem

prodex tasks complete <task> --artifact path=text wrote each file before reading the task. The writes happened while the arguments for completeTask were being built, so any refusal came after the file was already replaced. Found 2026-11-09:

  • Completing a finished task again: the artifact was replaced, then the completion was refused as "already done". prodex results artifact <task> then failed with "Result artifact changed after finalization", and the original answer was gone.
  • A task id that does not exist: "Task not found", but the answer at that path, for example .bridge/artifacts/pro-consults/<task>.md, had already been overwritten.
  • An open task given another task's artifact path: the other task's answer was replaced, and the completion was accepted.
  • A path refused as not a result artifact (.bridge/artifacts/notes/...): the file was written anyway.

Change

BridgeStore.writeResultArtifactTexts(taskId, texts) runs before anything is written, and the CLI calls it:

  • It reads the task first, so a missing id fails with nothing written.
  • It checks the stored paths with the same fetchable and distinct checks completeTask uses.
  • It leaves a finished task's files alone. completeTask then refuses, or accepts the same result again, as before.
  • It writes each file exclusively (writeArtifactText(..., { exclusive: true })). A path that already holds other text is refused; the same text is accepted, so a retry still works.

writeTaskCompleteArtifacts now takes the task id.

Verification

  • tests/task-complete-artifact-order.test.ts: 5 cases through runCli. 4 fail against main; the fifth checks that an accepted completion still writes its artifact. All 5 pass here.
  • tests/duplicate-result-artifacts.test.ts passes with the new signature.
  • npx tsc --noEmit passes. Full suite: 1874 passed, 3 skipped.

`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
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

What this touches

  • bridge store
  • CLI
  • tests

5 file(s), 133 line(s) changed. Tests changed.

Worth a look

  • Careful read: touches the receipt/integrity path.

This is an automated first pass, not a review. CI is the gate; a person decides.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T01:29:39.750654Z a3d3436 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/store.ts
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@youdie006
youdie006 merged commit 33a7e0a into main Nov 9, 2026
7 checks passed
youdie006 added a commit that referenced this pull request Nov 10, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant