> 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-session05-store-folding-and-selectors/tasks.md).

# Task Checklist

**Session ID**: `phase22-session05-store-folding-and-selectors` **Total Tasks**: 18 **Estimated Duration**: 2-3 hours **Created**: 2026-07-05

***

Legend: `[x]` completed; `[ ]` pending; `[P]` parallelizable; `[SNNMM]` session ref; `TNNN` task ID.

***

## Setup (3 tasks)

* [x] T001 \[S2205] Verify Session 04 artifacts, current store structure, and projection helper exports (`.spec_system/specs/phase22-session04-camp-link-boundaries/validation.md`, `apps/web/src/store/useGameStore.ts`, `apps/web/src/lib/gameProjection.ts`)
* [x] T002 \[S2205] \[P] Create the focused store integration test file and shared event fixtures (`apps/web/tests/gameProjectionStore.test.ts`)
* [x] T003 \[S2205] \[P] Add projection imports and type imports needed by the store integration (`apps/web/src/store/useGameStore.ts`)

***

## Foundation (4 tasks)

* [x] T004 \[S2205] Add `gameProjection: GameProjection` to the `GameStore` interface with a narrow store-state type for selectors (`apps/web/src/store/useGameStore.ts`)
* [x] T005 \[S2205] Initialize `gameProjection` from `loadPersistedGameProjection()` during store creation with malformed-storage recovery through the projection parser (`apps/web/src/store/useGameStore.ts`)
* [x] T006 \[S2205] Export `selectGameProjection`, `selectGameAlertFocus`, and `selectGameLegion` with `Pick`-based inputs (`apps/web/src/store/useGameStore.ts`)
* [x] T007 \[S2205] Add selector tests proving projection, alert focus, and Legion reads do not require the full store contract (`apps/web/tests/gameProjectionStore.test.ts`)

***

## Implementation (7 tasks)

* [x] T008 \[S2205] Add a store-local `foldGameProjection` helper near replay persistence helpers with context derived from current time, `replayingSinceMs`, and `useSettingsStore.getState().mockEnabled` (`apps/web/src/store/useGameStore.ts`)
* [x] T009 \[S2205] Wire `foldGameProjection` into `applyEvent(e)` after replay capture and before the existing event switch with exactly one reducer call per server event (`apps/web/src/store/useGameStore.ts`)
* [x] T010 \[S2205] Preserve existing `applyEvent` branch behavior for roster, hero, mission, Quest Board, command-center, toast, and default events while projection folding runs first (`apps/web/src/store/useGameStore.ts`)
* [x] T011 \[S2205] Add `resetToSeed()` memory reset to create a fresh projection without removing `localStorage["factionos-game-v1"]` (`apps/web/src/store/useGameStore.ts`)
* [x] T012 \[S2205] Add hydration tests for valid persisted projection and malformed persisted storage fallback with explicit loading, empty, error, and unavailable-storage handling at the store seam (`apps/web/tests/gameProjectionStore.test.ts`)
* [x] T013 \[S2205] Add one-event folding tests proving `applyEvent` changes projection state without depending on later switch mutations (`apps/web/tests/gameProjectionStore.test.ts`)
* [x] T014 \[S2205] Add replay-context and mock-context tests proving `replayingSinceMs` and `mockEnabled` are passed into reducer behavior without persistence writes (`apps/web/tests/gameProjectionStore.test.ts`)

***

## Testing (4 tasks)

* [x] T015 \[S2205] Add reset memory tests proving `resetToSeed()` returns a fresh in-memory projection and leaves storage removal deferred (`apps/web/tests/gameProjectionStore.test.ts`)
* [x] T016 \[S2205] Run focused projection store and reducer tests (`npm test -- apps/web/tests/gameProjectionStore.test.ts apps/web/tests/gameProjection.test.ts`)
* [x] T017 \[S2205] Run web package typecheck and changed-file Biome check (`npm --workspace @factionos/web run typecheck`, `npm exec -- biome check apps/web/src/store/useGameStore.ts apps/web/src/lib/gameProjection.ts apps/web/tests/gameProjectionStore.test.ts`)
* [x] T018 \[S2205] Validate ASCII and LF requirements for session artifacts and changed files (`.spec_system/specs/phase22-session05-store-folding-and-selectors`, `apps/web/src/store/useGameStore.ts`, `apps/web/src/lib/gameProjection.ts`, `apps/web/tests/gameProjectionStore.test.ts`)

***

## Completion Checklist

* [x] All tasks marked `[x]`
* [x] All tests and checks passing
* [x] All files ASCII-encoded with LF line endings
* [x] implementation-notes.md updated
* [x] Ready for `creview` (next step in the implement -> creview -> validate sequence)

***

## Next Steps

Run the `implement` workflow step.


---

# 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-session05-store-folding-and-selectors/tasks.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.
