> 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-session06-llm-fallback-and-scan-privacy/tasks.md).

# Task Checklist

**Session ID**: `phase01-session06-llm-fallback-and-scan-privacy` **Total Tasks**: 22 **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     | 6      | 6      | 0         |
| Implementation | 9      | 9      | 0         |
| Testing        | 4      | 4      | 0         |
| **Total**      | **22** | **22** | **0**     |

***

## Setup (3 tasks)

Initial analysis and baseline confirmation.

* [x] T001 \[S0106] Verify Session 05 completion, server LLM docs, and current route validation baseline (`.spec_system/specs/phase01-session05-websocket-hydration-and-archive-export-privacy/validation.md`)
* [x] T002 \[S0106] Map LLM fallback, provider-transfer, scan, and memory privacy expectations into implementation notes (`.spec_system/specs/phase01-session06-llm-fallback-and-scan-privacy/implementation-notes.md`)
* [x] T003 \[S0106] Identify focused server verification commands before code changes (`.spec_system/specs/phase01-session06-llm-fallback-and-scan-privacy/implementation-notes.md`)

***

## Foundation (6 tasks)

Core validation, privacy, and provider-transfer helpers.

### apps/server

* [x] T004 \[S0106] \[P] Create LLM request validation helper with schema-validated input and compact no-echo errors (`apps/server/src/lib/llmRequestValidation.ts`)
* [x] T005 \[S0106] \[P] Create LLM privacy helper for provider-transfer state, approved scan roots, and deterministic text redaction (`apps/server/src/lib/llmPrivacy.ts`)
* [x] T006 \[S0106] Add explicit provider-transfer opt-in and timeout fallback to LLM client with redacted provider-bound call inputs (`apps/server/src/lib/llmClient.ts`)
* [x] T007 \[S0106] Sanitize on-demand analysis prompt inputs and returned issue fields while preserving deterministic fallback parsing (`apps/server/src/llm/engines/onDemandAnalysis.ts`)
* [x] T008 \[S0106] Sanitize plan, idle suggestion, and transcript-miner provider-bound inputs without changing local response contracts (`apps/server/src/llm/engines/planDecomposer.ts`, `apps/server/src/llm/engines/idleSuggestionEngine.ts`, `apps/server/src/llm/engines/transcriptMiner.ts`)
* [x] T009 \[S0106] Redact memory finding route output while preserving type filtering and stable response shape (`apps/server/src/routes/llm.ts`)

***

## Implementation (9 tasks)

Main route hardening and documentation updates.

### apps/server

* [x] T010 \[S0106] Validate `/llm/plan` bodies through shared LLM request validation with bounded prompt and conventions fields (`apps/server/src/routes/llm.ts`)
* [x] T011 \[S0106] Validate `/llm/analyze` file arrays with caps, malformed-entry rejection, and bounded anti-patterns (`apps/server/src/routes/llm.ts`)
* [x] T012 \[S0106] Validate `/llm/scan-codebase` root, limit, extensions, and anti-pattern options with approved-root enforcement (`apps/server/src/routes/llm.ts`)
* [x] T013 \[S0106] Redact scan progress events, scan metadata, and walker failure paths without echoing absolute roots or raw filesystem errors (`apps/server/src/routes/llm.ts`)
* [x] T014 \[S0106] Validate `/llm/idle-suggestion` bodies with bounded hero/task/activity fields and deterministic fallback behavior (`apps/server/src/routes/llm.ts`)
* [x] T015 \[S0106] Add provider privacy headers to LLM and memory routes without requiring provider configuration (`apps/server/src/routes/llm.ts`)
* [x] T016 \[S0106] Update server README with fallback, provider opt-in, scan allowlist, and memory retention behavior (`apps/server/README_server.md`)
* [x] T017 \[S0106] Update API docs for hardened LLM routes, provider-transfer status, scan roots, and retained gaps (`docs/api/README_api.md`, `docs/api/event-api-hook-contracts.md`)
* [x] T018 \[S0106] Update privacy docs for LLM provider transfer, scan content handling, memory exposure, and retained erasure limitations (`docs/privacy-and-security.md`)

***

## Testing (4 tasks)

Focused verification and contract coverage.

### apps/server

* [x] T019 \[S0106] \[P] Extend LLM route tests for no-key fallback, compact validation errors, provider-key-blocked behavior, scan allowlists, redacted scan output, and redacted memory output (`apps/server/tests/llm.test.ts`)
* [x] T020 \[S0106] \[P] Extend codebase walker tests for ignored historical directories, symlink avoidance, file caps, and truncation behavior (`apps/server/tests/codebaseWalker.test.ts`)
* [x] T021 \[S0106] Run focused server tests, server typecheck, Biome checks, ASCII validation, LF validation, and record results (`.spec_system/specs/phase01-session06-llm-fallback-and-scan-privacy/implementation-notes.md`)
* [x] T022 \[S0106] Run full workspace quality/test gates that are practical locally and record pass/fail evidence (`.spec_system/specs/phase01-session06-llm-fallback-and-scan-privacy/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 implement 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-session06-llm-fallback-and-scan-privacy/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.
