> 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/phase19-session03-web-shell-and-store/code-review.md).

# Code Review and Repair Report

**Session ID**: `phase19-session03-web-shell-and-store` **Package**: `apps/web` **Reviewed**: 2026-06-26 **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/phase19-session03-web-shell-and-store/spec.md` - untracked
* `.spec_system/specs/phase19-session03-web-shell-and-store/tasks.md` - untracked
* `.spec_system/specs/phase19-session03-web-shell-and-store/implementation-notes.md` - untracked
* `.spec_system/specs/phase19-session03-web-shell-and-store/code-review.md` - untracked generated report
* `apps/web/src/components/OrchestrationPanel.tsx` - tracked-modified
* `apps/web/src/components/orchestration/CommandCenterPanes.tsx` - untracked
* `apps/web/src/components/orchestration/OrchestrationCurrentState.tsx` - untracked
* `apps/web/src/components/orchestration/OrchestrationDrawer.tsx` - untracked
* `apps/web/src/components/orchestration/OrchestrationHeader.tsx` - untracked
* `apps/web/src/components/orchestration/OrchestrationShell.tsx` - untracked
* `apps/web/src/components/orchestration/OrchestrationTabs.tsx` - untracked
* `apps/web/src/components/orchestration/index.ts` - untracked
* `apps/web/src/components/orchestration/shared.tsx` - untracked
* `apps/web/src/lib/commandCenterUi.ts` - untracked
* `apps/web/src/lib/orchestrationApi.ts` - tracked-modified
* `apps/web/src/lib/orchestrationUi.ts` - tracked-modified
* `apps/web/src/store/useGameStore.ts` - tracked-modified
* `apps/web/src/store/useWsClient.ts` - tracked-modified
* `apps/web/tests/OrchestrationPanel.test.tsx` - tracked-modified
* `apps/web/tests/commandCenterStore.test.ts` - untracked
* `apps/web/tests/commandCenterUi.test.ts` - untracked
* `apps/web/tests/orchestrationApi.test.ts` - tracked-modified
* `apps/web/tests/orchestrationStore.test.ts` - tracked-modified
* `apps/web/tests/wsClientPrivacy.test.ts` - tracked-modified

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

## Findings by Severity

### Critical

* No findings.

### High

* `apps/web/src/store/useWsClient.ts:359` - Command-center WebSocket frames only required top-level arrays and then coerced missing or invalid compact entry fields into empty strings and zeroes. A malformed live frame could therefore clear an existing command-center slice instead of being ignored, violating the malformed-frame preservation requirement. | Fix: Added protocol-backed compact-entry validation for every `command_center_*` event family, stricter top-level counts/generatedAt/change validation, blocked-payload rejection before mapping, and regression coverage for malformed enum/missing-field frames preserving state. | Status: FIXED

### Medium

* `apps/web/src/lib/orchestrationApi.ts:718` - Successful JSON responses were parsed after slicing to `MAX_ERROR_TEXT_LENGTH`, so normal bounded command-center snapshots larger than 8 KB could become unreadable. | Fix: Parse successful JSON bodies in full while keeping the cap for error-body parsing, and added a large snapshot regression test. | Status: FIXED
* `apps/web/src/components/orchestration/CommandCenterPanes.tsx:18` - Several hydrated command-center slices were not counted or reachable from panes (`permissions`, `fileIntents`, `workpads`, `evidence`, `verification`, `reviewGates`, `heroes`), leaving started session requirements invisible in the UI. | Fix: Expanded `commandCenterTabCounts` and pane groups so all command-center collections contribute to tabs and have product-facing rows; updated helper tests. | Status: FIXED
* `apps/web/src/components/orchestration/OrchestrationShell.tsx:143` - Command-center hydration could still write results after the shell unmounted or after a newer load superseded it. | Fix: Added a `shouldApply` guard before store hydration and a component regression test that resolves a delayed command-center request after unmount. | Status: FIXED

### Low

* No findings.

## Assumptions and Deliberate Non-Fixes

* The shared JSON parsing helper existed before this session, but the new command-center route family makes larger successful snapshots an expected path. Fixing the helper was required to make the new session deliverable reliable.
* No byte-level binary inspection was needed because all untracked files are text source, tests, or spec artifacts.

## Behavior Changes

* Malformed `command_center_*` WebSocket frames are now rejected before store mutation instead of being coerced into empty records.
* Successful large command-center JSON snapshots now parse fully; error bodies remain bounded before display.
* All command-center collections now contribute to tab counts and have a visible pane path.
* Stale command-center hydration after shell unmount is ignored.

## Verification

* Tests: `npm test -- apps/web/tests/orchestrationApi.test.ts apps/web/tests/commandCenterUi.test.ts apps/web/tests/commandCenterStore.test.ts apps/web/tests/orchestrationStore.test.ts apps/web/tests/OrchestrationPanel.test.tsx apps/web/tests/wsClientPrivacy.test.ts` - PASS - 6 files, 43 tests passed.
* Linter: `npm run lint` - PASS - Biome checked 664 files.
* Formatter: `npm run format:check` - PASS - Biome checked 662 files.
* Type checker: `npm --workspace apps/web run typecheck` - PASS - `tsc -b --noEmit`.
* Whitespace: `git diff --check -- apps/web .spec_system/specs/phase19-session03-web-shell-and-store` - PASS.
* ASCII/LF/trailing whitespace scans: `rg -nP '[^\x00-\x7F]'`, `rg -nU $'\r'`, and `rg -n '[ \t]+$'` over uncommitted files - PASS.
* Final diff re-read: no remaining issues found.

## Summary

1. Reviewed 24 implementation/spec files plus this generated review report across the active `apps/web` command-center session.
2. Findings: 0 critical, 1 high, 3 medium, 0 low; all fixed.
3. Deliberate non-fixes: none.
4. Verification: focused web tests, web typecheck, root Biome format check, root Biome lint, diff whitespace, ASCII, LF, and trailing-whitespace checks passed.


---

# 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/phase19-session03-web-shell-and-store/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.
