{"record":{"id":"5b60be7558315d17","repo":"Hmbown/CodeWhale","slug":"review-pass-arrived-out-of-order-or-does-not-match-the","errorCode":null,"errorMessage":"Review pass arrived out of order or does not match the immutable manifest; expected pass {expected}","messagePattern":"Review pass arrived out of order or does not match the immutable manifest; expected pass (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/review.rs","lineNumber":704,"sourceCode":"\npub(crate) struct PrReviewAccumulator {\n    manifest: PrReviewManifest,\n    outputs: Vec<ReviewOutput>,\n    raw_outputs: Vec<String>,\n}\n\nimpl PrReviewAccumulator {\n    pub(crate) fn new(plan: &PrReviewPlan) -> Self {\n        Self {\n            manifest: plan.manifest.clone(),\n            outputs: Vec::new(),\n            raw_outputs: Vec::new(),\n        }\n    }\n\n    pub(crate) fn accept(&mut self, pass: &PrReviewPass, raw: String) -> anyhow::Result<()> {\n        let expected = self.outputs.len() + 1;\n        anyhow::ensure!(\n            pass.manifest.number == expected\n                && self.manifest.passes.get(expected - 1) == Some(&pass.manifest),\n            \"Review pass arrived out of order or does not match the immutable manifest; expected pass {expected}\"\n        );\n        let output = ReviewOutput::from_structured_str(&raw).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Review pass {expected}/{} did not return valid structured JSON; the partial review was not accepted or posted.\",\n                self.manifest.passes.len()\n            )\n        })?;\n        self.outputs.push(output);\n        self.raw_outputs.push(raw);\n        Ok(())\n    }\n\n    pub(crate) fn finish(\n        self,\n        complete_diff: &str,","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/review.rs#L686-L722","documentation":"The multi-pass review accumulator accepts passes strictly in order: pass N must carry manifest.number == N and its manifest must exactly match the immutable manifest entry at index N-1. Anything else (missing, reordered, or manifest-drifted pass) is rejected so partial usage is returned without coverage.","triggerScenarios":"Model responses returned out of order; a pass was retried after the manifest was regenerated (revision drift); caller skipped a failed pass and submitted the next one; manifest was mutated between plan and accept.","commonSituations":"Parallel pass execution completing out of order; a retried pass built against an older manifest after the PR head moved; dropping one pass's output on a transient model error.","solutions":["Submit passes strictly in manifest order; if one fails, rebuild the plan/manifest before retrying","Re-run all passes from the current manifest instead of mixing old and new","Buffer out-of-order passes and feed them to accept in order","Check that the PR revision did not change between planning and accepting"],"exampleFix":"// before\nfor pass_result in join_all(pass_futures).await { acc.accept(&pass_result.manifest, pass_result.raw)?; }\n// after\nlet mut results: Vec<_> = join_all(pass_futures).await;\nresults.sort_by_key(|r| r.manifest.number);\nfor r in results { acc.accept(&r.manifest, r.raw)?; } // strict order enforced","handlingStrategy":"validation","validationCode":"// before calling accept\nif pass.manifest.number != expected_next { queue_for_later(pass); }","typeGuard":null,"tryCatchPattern":"match acc.accept(&pass.manifest, raw) { Err(e) if e.to_string().contains(\"out of order\") => rebuild_plan_and_rerun(pr).await, ... }","preventionTips":["Sort pass results by manifest.number before accepting","Regenerate the whole manifest and rerun all passes if any pass fails","Never mutate the manifest after planning"],"tags":["review","ordering","manifest"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}