> For the complete documentation index, see [llms.txt](https://faction-os.gitbook.io/faction-os-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/sessions/phase20-session05-campaign-dag-recovery/code-review.md).

# Code Review and Repair Report

**Session ID**: `phase20-session05-campaign-dag-recovery` **Package**: cross-cutting (`packages/protocol`, `apps/server`, `apps/web`) **Reviewed**: 2026-06-28 **Scope**: All uncommitted changes in the working tree **Result**: RESOLVED

## Review Surface

**Files reviewed** (all uncommitted changes):

* `.spec_system/state.json` - tracked-modified
* `.spec_system/specs/phase20-session05-campaign-dag-recovery/implementation-notes.md` - untracked
* `.spec_system/specs/phase20-session05-campaign-dag-recovery/spec.md` - untracked
* `.spec_system/specs/phase20-session05-campaign-dag-recovery/tasks.md` - untracked
* `apps/server/README_server.md` - tracked-modified
* `apps/server/src/managers/orchestrationCommandCenter.ts` - tracked-modified
* `apps/server/src/managers/planCampaignManager.ts` - tracked-modified
* `apps/server/src/routes/commandCenter.ts` - tracked-modified
* `apps/server/tests/commandCenterRoutes.test.ts` - tracked-modified
* `apps/server/tests/planCampaignDagRecovery.test.ts` - untracked
* `apps/server/tests/planCampaignManager.test.ts` - tracked-modified
* `apps/web/README_web.md` - tracked-modified
* `apps/web/src/components/orchestration/CampaignWorkbench.tsx` - tracked-modified
* `apps/web/src/components/orchestration/OrchestrationShell.tsx` - tracked-modified
* `apps/web/src/lib/commandCenterUi.ts` - tracked-modified
* `apps/web/src/lib/orchestrationApi.ts` - tracked-modified
* `apps/web/tests/CommandCenterPanes.test.tsx` - tracked-modified
* `apps/web/tests/OrchestrationPanel.test.tsx` - tracked-modified
* `apps/web/tests/commandCenterUi.test.ts` - tracked-modified
* `apps/web/tests/orchestrationApi.test.ts` - tracked-modified
* `docs/api/README_api.md` - tracked-modified
* `packages/protocol/src/orchestrationCommandCenter.ts` - tracked-modified
* `packages/protocol/src/rest.ts` - tracked-modified
* `packages/protocol/tests/orchestrationCommandCenter.test.ts` - tracked-modified
* `tests/e2e/orchestration-command-center.e2e.ts` - tracked-modified
* `.spec_system/specs/phase20-session05-campaign-dag-recovery/code-review.md` - untracked report output

**Inventory commands**: `git status`, `git diff HEAD`, `git diff --cached`, `git ls-files --others --exclude-standard`

## Findings by Severity

### Critical

No findings.

### High

* `apps/server/src/managers/planCampaignManager.ts:431` - Dependency-held tasks stayed `blocked` after a failed prerequisite was retried successfully, so the second dispatch skipped the dependent task forever. | Fix: Re-evaluate blocked executable tasks that have no own execution summary, dispatch them once dependencies are ready, and include retry outcome buckets in `retryFailed` responses. Added regression coverage for fail -> retry -> dependent completion. | Status: FIXED

### Medium

* `apps/web/src/lib/commandCenterUi.ts:1827` - A dependent task whose prerequisite was planning-only was labeled as "Waiting on dependency" even though the server treats planning-only prerequisites as terminal dependency blocks. | Fix: Treat `planning_only` readiness as a blocked prerequisite in graph row copy and add a helper test for the planning-only dependency case. | Status: FIXED

### Low

* `apps/server/README_server.md:586` and `docs/api/README_api.md:362` - Documentation implied `retryFailed` itself creates fresh retry evidence, but the implemented contract resets tasks and the next dispatch creates queue/execution evidence. | Fix: Updated server/API docs and session notes to state that retry evidence is created by the next dispatch. | Status: FIXED

## Assumptions and Deliberate Non-Fixes

* Retry remains a reset/stage operation, followed by dispatch. Evidence: existing route and UI names, tests, and shell copy use "retry staged"; the corrected docs now describe the two-step contract.
* No unrelated committed code was modified except where required by the uncommitted DAG recovery behavior and its tests.

## Behavior Changes

* Dispatch now re-evaluates dependency-blocked executable tasks after prerequisites recover, while still avoiding automatic reruns of tasks with their own failed or unavailable execution evidence.
* Retry responses now include DAG outcome buckets (`blockedTaskIds`, `waitingTaskIds`, `retryableTaskIds`, and related existing buckets) when available.
* Campaign graph copy now labels planning-only prerequisites as dependency-blocked instead of waiting.

## Verification

* Tests: `PATH="$HOME/.nvm/versions/node/v26.2.0/bin:$PATH" npx vitest run packages/protocol/tests/orchestrationCommandCenter.test.ts apps/server/tests/planCampaignDagRecovery.test.ts apps/server/tests/planCampaignManager.test.ts apps/server/tests/commandCenterRoutes.test.ts apps/web/tests/commandCenterUi.test.ts apps/web/tests/CommandCenterPanes.test.tsx apps/web/tests/orchestrationApi.test.ts apps/web/tests/OrchestrationPanel.test.tsx` - PASS - 8 files, 125 tests passed.
* Tests: `PATH="$HOME/.nvm/versions/node/v26.2.0/bin:$PATH" npx playwright test tests/e2e/orchestration-command-center.e2e.ts --project=app-desktop --project=app-mobile` - PASS - 8 tests passed.
* Formatter: `PATH="$HOME/.nvm/versions/node/v26.2.0/bin:$PATH" npm run format` - PASS - fixed 1 file.
* Formatter: `PATH="$HOME/.nvm/versions/node/v26.2.0/bin:$PATH" npm run format:check` - PASS - 759 files checked.
* Linter: `PATH="$HOME/.nvm/versions/node/v26.2.0/bin:$PATH" npm run lint` - PASS - 761 files checked.
* Type checker: `PATH="$HOME/.nvm/versions/node/v26.2.0/bin:$PATH" npm run typecheck --workspaces --if-present` - PASS - adapters, server, warroom, web, protocol, and public-website.
* Tests: `PATH="$HOME/.nvm/versions/node/v26.2.0/bin:$PATH" npm test` - PASS - 266 files passed, 1 skipped; 3030 tests passed, 1 skipped.
* Whitespace: `git diff --check` - PASS.
* Encoding: modified/untracked file ASCII and CRLF scan - PASS.
* Final diff re-read: no remaining issues.

## Summary

1. Reviewed 25 implementation/session files plus this generated report output across protocol, server, web, docs, tests, e2e, and spec artifacts.
2. Findings: 0 critical, 1 high, 1 medium, 1 low; all resolved with focused code, tests, and documentation updates.
3. Deliberately preserved the existing retry-then-dispatch flow and documented it as the intended contract.
4. Verification passed across focused Vitest, Playwright desktop/mobile, format, lint, workspace typecheck, full Vitest, whitespace, and encoding checks.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/sessions/phase20-session05-campaign-dag-recovery/code-review.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
