> 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/phase22-session04-camp-link-boundaries/code-review.md).

# Code Review and Repair Report

**Session ID**: `phase22-session04-camp-link-boundaries` **Package**: apps/web **Reviewed**: 2026-07-05 **Base Commit**: b2353754d7fd4bfe81642428f043a565e5794b6f **Scope**: All changes since the base commit (uncommitted work plus mid-session commits) **Result**: RESOLVED

## Review Surface

**Files reviewed** (all changes since the base commit):

* `.spec_system/state.json` - tracked-modified
* `apps/web/src/lib/gameProjection.ts` - tracked-modified
* `apps/web/tests/gameProjection.test.ts` - tracked-modified
* `.spec_system/specs/phase22-session04-camp-link-boundaries/spec.md` - untracked
* `.spec_system/specs/phase22-session04-camp-link-boundaries/tasks.md` - untracked
* `.spec_system/specs/phase22-session04-camp-link-boundaries/implementation-notes.md` - untracked
* `.spec_system/specs/phase22-session04-camp-link-boundaries/code-review.md` - generated review report

**Inventory commands**: `git status --short`, `git log --oneline "$BASE"..HEAD`, `git diff "$BASE"`, `git diff --cached "$BASE"`, `git ls-files --others --exclude-standard`

No mid-session commits were present after the base commit.

## Findings by Severity

### Critical

* None.

### High

* None.

### Medium

* `apps/web/src/lib/gameProjection.ts:1594` and `apps/web/src/lib/gameProjection.ts:1605` - Replayed `mission_complete` and terminal `mission_update` events could clear live `campLinks`. The session spec and design docs require replay traffic to avoid game-state accumulation or progress effects, and clearing live links during replay would mutate current linkage state from historical traffic. Fix: added `ctx.isReplaying` guards to both terminal clearing reducers and added focused assertions at `apps/web/tests/gameProjection.test.ts:1127` and `apps/web/tests/gameProjection.test.ts:1138`. Status: FIXED.

### Low

* None.

## Assumptions and Deliberate Non-Fixes

* `.spec_system/state.json` history changed during session setup. Targeted inspection of the state diff and current `next_session_history` showed active-session bookkeeping plus a bounded history rollover; no repair was needed.
* Pending-link IDs deliberately use the reducer's safe-token vocabulary instead of hashing unsafe raw IDs. Targeted inspection of current mission and hero producer patterns showed current generated IDs use safe underscore, hash, UUID, hyphen, colon, or compact token forms. Rejecting unsafe pending-link IDs preserves the session's real-caller and privacy boundary.

## Behavior Changes

* Replayed `mission_complete` and terminal `mission_update` events now preserve existing `campLinks` instead of clearing them. This matches the replay no-accumulation contract and prevents historical traffic from mutating live camp linkage.

## Evidence Ledger

| Check                               | Command or Inspection                                                                                                                                                                                                                                                                                                                                                                                    | Result | Evidence / Blocker                                                                                                        |
| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| Deterministic state                 | `if [ -d .spec_system/scripts ]; then bash .spec_system/scripts/analyze-project.sh --json; else bash /home/aiwithapex/.codex/plugins/cache/apexdev/apex-spec/2.2.18-codex/skills/apex-spec/scripts/analyze-project.sh --json; fi`                                                                                                                                                                        | PASS   | Current session resolved to `phase22-session04-camp-link-boundaries`; monorepo true; package apps/web.                    |
| Source context                      | Read `.spec_system/CONVENTIONS.md`, `.spec_system/CONSIDERATIONS.md`, session `spec.md`, `tasks.md`, `implementation-notes.md`, `apps/web/README_web.md`, `docs/game-design/10-technical-design-and-game-projection.md`, and `docs/privacy-and-security.md`                                                                                                                                              | PASS   | Confirmed reducer-only scope, replay guard posture, local-first privacy posture, and apps/web conventions.                |
| Inventory                           | `git status --short`; `git log --oneline "$BASE"..HEAD`; `git diff --stat "$BASE"`; `git diff --name-status "$BASE"`; `git diff --cached --name-status "$BASE"`; `git ls-files --others --exclude-standard`                                                                                                                                                                                              | PASS   | Review surface was three tracked files and the untracked session directory; no staged changes and no mid-session commits. |
| Targeted code inspection            | `git diff --unified=40 "$BASE" -- apps/web/src/lib/gameProjection.ts`; `git diff --unified=35 "$BASE" -- apps/web/tests/gameProjection.test.ts`; targeted line-number reads with `nl -ba`                                                                                                                                                                                                                | PASS   | Found and fixed replay terminal-clearing gap; no remaining changed-hunk issues found.                                     |
| Tests                               | `npm test -- apps/web/tests/gameProjection.test.ts`                                                                                                                                                                                                                                                                                                                                                      | PASS   | Focused reducer suite passed: 1 file, 24 tests.                                                                           |
| Tests                               | `npm test`                                                                                                                                                                                                                                                                                                                                                                                               | PASS   | Full Vitest suite passed: 275 files passed, 1 skipped; 3183 tests passed, 1 skipped.                                      |
| Type checker                        | `npm --workspace @factionos/web run typecheck`                                                                                                                                                                                                                                                                                                                                                           | PASS   | Web package `tsc -b --noEmit` exited 0.                                                                                   |
| Type checker                        | `npm run typecheck --workspaces --if-present`                                                                                                                                                                                                                                                                                                                                                            | PASS   | adapters, server, warroom, web, protocol, and public-website typechecks passed.                                           |
| Linter                              | `npm run lint`                                                                                                                                                                                                                                                                                                                                                                                           | PASS   | Biome lint checked 775 files with no fixes applied.                                                                       |
| Formatter                           | `npm run format:check`                                                                                                                                                                                                                                                                                                                                                                                   | PASS   | Biome format checked 773 files with no fixes applied.                                                                     |
| Formatter and linter, changed files | `npm exec -- biome check apps/web/src/lib/gameProjection.ts apps/web/tests/gameProjection.test.ts`                                                                                                                                                                                                                                                                                                       | PASS   | Biome checked 2 changed files with no fixes applied after the test formatting repair.                                     |
| Whitespace                          | `git diff --check`                                                                                                                                                                                                                                                                                                                                                                                       | PASS   | No whitespace errors.                                                                                                     |
| ASCII                               | \`grep -nP '\[^\x00-\x7F]' apps/web/src/lib/gameProjection.ts apps/web/tests/gameProjection.test.ts .spec\_system/specs/phase22-session04-camp-link-boundaries/spec.md .spec\_system/specs/phase22-session04-camp-link-boundaries/tasks.md .spec\_system/specs/phase22-session04-camp-link-boundaries/implementation-notes.md .spec\_system/specs/phase22-session04-camp-link-boundaries/code-review\.md |        | true\`                                                                                                                    |
| LF line endings                     | \`rg -nU $'\r' apps/web/src/lib/gameProjection.ts apps/web/tests/gameProjection.test.ts .spec\_system/specs/phase22-session04-camp-link-boundaries/spec.md .spec\_system/specs/phase22-session04-camp-link-boundaries/tasks.md .spec\_system/specs/phase22-session04-camp-link-boundaries/implementation-notes.md .spec\_system/specs/phase22-session04-camp-link-boundaries/code-review\.md             |        | true\`                                                                                                                    |
| Final diff re-read                  | `git diff --stat "$BASE"`; `git diff --unified=40 "$BASE" -- apps/web/src/lib/gameProjection.ts`; `git diff --unified=35 "$BASE" -- apps/web/tests/gameProjection.test.ts`; `git diff "$BASE" -- .spec_system/state.json`; `wc -l` and file metadata for untracked session files                                                                                                                         | PASS   | Final review surface re-read after fixes; no remaining issues found.                                                      |

## Summary

1. Reviewed 7 files in the final review surface: 3 tracked files, 3 session artifacts, and this generated report.
2. Findings: 0 Critical, 0 High, 1 Medium, 0 Low. The Medium replay terminal-clearing finding was fixed with reducer guards and tests.
3. Deliberate non-fixes: state history rollover and strict safe-token pending-link IDs were left unchanged based on targeted evidence.
4. Evidence: focused reducer tests, full Vitest suite, web and workspace typechecks, root Biome format/lint, changed-file Biome check, whitespace, ASCII, LF, and final diff re-read all 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/phase22-session04-camp-link-boundaries/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.
