> 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/phase01-session04-server-routes-and-authorization-boundaries/tasks.md).

# Task Checklist

**Session ID**: `phase01-session04-server-routes-and-authorization-boundaries` **Total Tasks**: 21 **Estimated Duration**: 3-4 hours **Created**: 2026-05-29

***

## Legend

* `[x]` = Completed
* `[ ]` = Pending
* `[P]` = Parallelizable (can run with other \[P] tasks)
* `[SNNMM]` = Session reference (NN=phase number, MM=session number)
* `TNNN` = Task ID

***

## Progress Summary

| Category       | Total  | Done   | Remaining |
| -------------- | ------ | ------ | --------- |
| Setup          | 3      | 3      | 0         |
| Foundation     | 5      | 5      | 0         |
| Implementation | 10     | 10     | 0         |
| Testing        | 3      | 3      | 0         |
| **Total**      | **21** | **21** | **0**     |

***

## Setup (3 tasks)

Initial configuration and environment preparation.

### Cross-package

* [x] T001 \[S0104] Verify current server route map, recovered route inventory, and route-family status gaps (`docs/api/event-api-hook-contracts.md`)
* [x] T002 \[S0104] Verify current route, auth, permission, and high-risk POST validation test coverage (`apps/server/tests/routes.test.ts`)
* [x] T003 \[S0104] Create route-hardening test scaffold for validation, auth boundaries, and unsupported historical paths (`apps/server/tests/unsupportedRoutes.test.ts`)

***

## Foundation (5 tasks)

Core structures and base implementations.

### packages/protocol

* [x] T004 \[S0104] \[P] Define shared REST route status, capability, request, and error-envelope contracts (`packages/protocol/src/rest.ts`)
* [x] T005 \[S0104] Add protocol tests for REST route status vocabulary and exported contract shapes (`packages/protocol/tests/rest.test.ts`)
* [x] T006 \[S0104] Export REST route contracts from the protocol package (`packages/protocol/src/index.ts`)

### apps/server

* [x] T007 \[S0104] \[P] Create request validation helper for route inputs with schema-validated input and explicit error mapping (`apps/server/src/lib/requestValidation.ts`)
* [x] T008 \[S0104] \[P] Create unsupported route classifier with deterministic 501 capability payloads and no request-body echoing (`apps/server/src/lib/unsupportedRoutes.ts`)

***

## Implementation (10 tasks)

Main feature implementation.

### apps/server

* [x] T009 \[S0104] Wire unsupported route helper into the Express catch-all with authorization enforced before response generation (`apps/server/src/server.ts`)
* [x] T010 \[S0104] Harden notice creation with non-empty body, validated severity, bounded targets, and duplicate-trigger-safe state mutation (`apps/server/src/routes/heroes.ts`)
* [x] T011 \[S0104] Harden mission list reads with bounded pagination, validated query filters, and deterministic ordering (`apps/server/src/routes/heroes.ts`)
* [x] T012 \[S0104] Harden scroll collection and local War Room stub responses with schema-validated input and separate-surface status metadata (`apps/server/src/routes/heroes.ts`)
* [x] T013 \[S0104] Harden permission and plan approval routes with non-empty IDs, optional boolean validation, and duplicate-trigger-safe pending-map cleanup (`apps/server/src/routes/permission.ts`)
* [x] T014 \[S0104] Align `/event` invalid-body responses with shared route error conventions while preserving tolerant hook ingest (`apps/server/src/routes/event.ts`)
* [x] T015 \[S0104] Add auth-boundary coverage for read, write, and unsupported route families when bearer auth is configured (`apps/server/tests/authBoundaries.test.ts`)
* [x] T016 \[S0104] Add unsupported historical route tests for file, git, terminal, local War Room, and unknown route paths (`apps/server/tests/unsupportedRoutes.test.ts`)

### Documentation

* [x] T017 \[S0104] Update concise API docs for route status, validation errors, auth boundaries, unsupported routes, and War Room separation (`docs/api/README_api.md`)
* [x] T018 \[S0104] Update detailed contract docs with route classifications, source traceability, and retained Phase 01 hardening gaps (`docs/api/event-api-hook-contracts.md`)

***

## Testing (3 tasks)

Verification and quality assurance.

### apps/server

* [x] T019 \[S0104] Extend route tests for notice validation, mission pagination, scroll collect validation, and War Room stub metadata (`apps/server/tests/routes.test.ts`)
* [x] T020 \[S0104] Extend permission tests for malformed IDs, invalid booleans, omitted approvals, and duplicate-safe responses (`apps/server/tests/permission.test.ts`)

### Validation

* [x] T021 \[S0104] Run focused protocol/server tests, package typecheck, Biome checks, and ASCII/LF validation, then record results (`.spec_system/specs/phase01-session04-server-routes-and-authorization-boundaries/implementation-notes.md`)

***

## Completion Checklist

Before marking session complete:

* [x] All tasks marked `[x]`
* [x] All tests passing
* [x] All files ASCII-encoded
* [x] implementation-notes.md updated
* [x] Ready for the validate workflow step

***

## Next Steps

Run the validate workflow step to verify session completeness.


---

# 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/phase01-session04-server-routes-and-authorization-boundaries/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.
