> For the complete documentation index, see [llms.txt](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/sessions/phase29-session07-per-stage-validation-narration/tasks.md).

# Task Checklist

**Session ID**: `phase29-session07-per-stage-validation-narration` **Total Tasks**: 20 **Estimated Duration**: 3-4 hours **Created**: 2026-06-20

***

## 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          | 2      | 2      | 0         |
| Foundation     | 5      | 5      | 0         |
| Implementation | 9      | 9      | 0         |
| Testing        | 4      | 4      | 0         |
| **Total**      | **20** | **20** | **0**     |

***

## Setup (2 tasks)

Initial configuration and environment preparation.

* [x] T001 \[S2907] Verify analyzer state, completed prerequisites, and Session 07 stub scope before implementation (`.spec_system/PRD/phase_29/session_07_per_stage_validation_narration.md`)
* [x] T002 \[S2907] Inspect current collector enrichment, trace sanitization, Engine Replay model, and view contracts before adding narration (`scripts/extensions/trend-finder/collector.ts`)

***

## Foundation (5 tasks)

Core structures and base implementations.

* [x] T003 \[S2907] \[P] Create stage-validation helper contract with bounded stage IDs, statuses, issue codes, retry counts, degradation paths, and sanitized messages (`scripts/extensions/trend-finder/stage-validation.ts`)
* [x] T004 \[S2907] Add `stageNarrations` trace types, enums, defaults, Zod schemas, and legacy-safe parsing with exhaustive enum handling (`src/extensions/trend-finder/engine-trace.ts`)
* [x] T005 \[S2907] Add script-side trace event mapping for stage narration with schema-validated input and explicit unsafe key/value rejection (`scripts/extensions/trend-finder/engine-trace.ts`)
* [x] T006 \[S2907] Prepare Engine Replay model projection for stage narration rows with loading, empty, error, offline, and legacy states (`src/extensions/trend-finder/engine-replay-model.ts`)
* [x] T007 \[S2907] Prepare fixtures and payload reporting for accepted, degraded, retry-once, unsafe-dropped, and legacy narration cases (`src/extensions/trend-finder/fixtures.ts`)

***

## Implementation (9 tasks)

Main feature implementation.

* [x] T008 \[S2907] Implement retry-once-then-degrade wrapper with abort-signal propagation, retry cap enforcement, explicit error mapping, and deterministic degraded output (`scripts/extensions/trend-finder/stage-validation.ts`)
* [x] T009 \[S2907] Wrap AI-analysis result handling or validation with stage narration without changing analyst runtime behavior or fallback semantics (`scripts/extensions/trend-finder/collector.ts`)
* [x] T010 \[S2907] Wrap source-breakdown derivation with stage narration, deterministic fallback preservation, and sanitized trace emission (`scripts/extensions/trend-finder/collector.ts`)
* [x] T011 \[S2907] Wrap run narrative and outlier idea enrichment paths with stage narration, duplicate warning prevention, and bounded retry behavior (`scripts/extensions/trend-finder/collector.ts`)
* [x] T012 \[S2907] Emit `stage-validation.recorded` trace events with safe stage ID, status, issue code, retry count, degradation path, and sanitized message (`scripts/extensions/trend-finder/collector.ts`)
* [x] T013 \[S2907] Map stage narration trace records into browser-safe Engine Replay output with caps, deterministic ordering, and unsafe sentinel exclusion (`scripts/extensions/trend-finder/engine-trace.ts`)
* [x] T014 \[S2907] Project stage narration rows into Engine Replay view models with tones, labels, counts, and accessible descriptions (`src/extensions/trend-finder/engine-replay-model.ts`)
* [x] T015 \[S2907] Render compact stage validation notices in Engine Replay with platform-appropriate accessibility labels, focus-safe layout, and stable empty/legacy states (`src/extensions/trend-finder/views/engine-replay-view.tsx`)
* [x] T016 \[S2907] Document shipped stage narration behavior and retained privacy boundaries after implementation (`docs/extensions/trend-finder-pipeline.md`)

***

## Testing (4 tasks)

Verification and quality assurance.

* [x] T017 \[S2907] \[P] Add stage-validation helper tests for first-try success, retry success, retry failure, explicit degraded result, abort handling, and unsafe message stripping (`scripts/extensions/trend-finder/__tests__/stage-validation.test.ts`)
* [x] T018 \[S2907] \[P] Add collector and engine-trace tests for forced enrichment failure, retry-at-most-once behavior, degraded narration, caps, legacy defaults, and private/raw sentinel exclusion (`scripts/extensions/trend-finder/__tests__/engine-trace.test.ts`)
* [x] T019 \[S2907] \[P] Add Engine Replay model/view tests for degraded stage rows, empty legacy payloads, offline parsed state, accessible labels, and no private leak rendering (`src/lib/__tests__/trend-finder-engine-replay.test.tsx`)
* [x] T020 \[S2907] Run focused Vitest suites, type checks as needed, payload-size check, privacy scan, and ASCII validation for session files (`package.json`)

***

## 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 begin AI-led implementation.


---

# 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://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/sessions/phase29-session07-per-stage-validation-narration/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.
