> 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/phase23-session02-ranking-and-presentation-selectors/tasks.md).

# Task Checklist

**Session ID**: `phase23-session02-ranking-and-presentation-selectors` **Total Tasks**: 16 **Estimated Duration**: 2-3 hours **Created**: 2026-07-05

***

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

***

## Setup (2 tasks)

* [x] T001 \[S2302] Verify Session 01 helper exports and current ranking baseline (`apps/web/src/lib/legionCamps.ts`)
* [x] T002 \[S2302] Verify existing focused test fixtures and package commands (`apps/web/tests/legionCamps.test.ts`)

***

## Foundation (4 tasks)

* [x] T003 \[S2302] Extend ranking input and output types for roster size, selected context, rank, mode, limit, and placement metadata with types matching declared contract (`apps/web/src/lib/legionCamps.ts`)
* [x] T004 \[S2302] Add Champion Mode visible limit constants and roster-mode helpers for zero, solo, duo, squad, and army counts (`apps/web/src/lib/legionCamps.ts`)
* [x] T005 \[S2302] Add pure selected-context sector resolution from sector id, safe sector key, or file path with fallback behavior (`apps/web/src/lib/legionCamps.ts`)
* [x] T006 \[S2302] Add presentation metadata helpers for entrenched muted and edge placement without mutating camp records (`apps/web/src/lib/legionCamps.ts`)

***

## Implementation (5 tasks)

* [x] T007 \[S2302] Update `rankVisibleLegionCamps` to prioritize selected-context sector matches before general camp ordering (`apps/web/src/lib/legionCamps.ts`)
* [x] T008 \[S2302] Update camp comparator to rank tier, HP, lower entrenchment, newest timestamp, and stable camp id deterministically (`apps/web/src/lib/legionCamps.ts`)
* [x] T009 \[S2302] Apply roster-size visible trimming while preserving the caller-owned full camp census (`apps/web/src/lib/legionCamps.ts`)
* [x] T010 \[S2302] Preserve newest timestamp fallback to selector snapshot time when issue timestamps are absent or invalid (`apps/web/src/lib/legionCamps.ts`)
* [x] T011 \[S2302] Ensure returned ranked camps clone camp, issue id, and sector data so callers cannot mutate projection inputs (`apps/web/src/lib/legionCamps.ts`)

***

## Testing (5 tasks)

* [x] T012 \[S2302] \[P] Add tests for zero-hero, solo, duo, squad, and army visible limits (`apps/web/tests/legionCamps.test.ts`)
* [x] T013 \[S2302] \[P] Add tests for selected-context priority and unmappable-context fallback (`apps/web/tests/legionCamps.test.ts`)
* [x] T014 \[S2302] \[P] Add tests for lower-entrenchment priority, newest timestamp fallback, and stable camp-id tie-breaking (`apps/web/tests/legionCamps.test.ts`)
* [x] T015 \[S2302] \[P] Add tests for muted or edge-placement metadata and input immutability (`apps/web/tests/legionCamps.test.ts`)
* [x] T016 \[S2302] Run focused Vitest, web typecheck, and ASCII/LF checks (`npm test -- apps/web/tests/legionCamps.test.ts`, `npm --workspace @factionos/web run typecheck`, `apps/web/src/lib/legionCamps.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/phase23-session02-ranking-and-presentation-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.
