> 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/phases/phase_33/session_03_harden_trend_finder_projection.md).

# Session 03: Harden Trend Finder Projection

**Session ID**: `phase33-session03-harden-trend-finder-projection` **Status**: Not Started **Estimated Tasks**: \~12-25 **Estimated Duration**: 2-4 hours

***

## Objective

Preserve the useful real Trend Finder demo fields while enforcing public-safety and reference coherence.

***

## Scope

### In Scope (MVP)

* Audit and update `scripts/lib/pages-demo-snapshot.ts` Trend Finder projection behavior.
* Audit the Trend Finder side of `scripts/lib/pages-demo-snapshot.ts` for frozen real fixture policy.
* Preserve safe public topic, evidence, source, score, movement, watchlist, prediction, retro, and Brief-supporting fields.
* Preserve public evidence fields, source summaries, scoring fields, movement fields, Brief data, watchlist data, prediction summaries, and retro summaries needed by the demo.
* Preserve or reconstruct sanitized `engineTrace` with run, section, source, evidence, runtime, artifact, decision, warning, note, and narration state.
* Preserve or reconstruct sanitized Trend Finder `engineTrace` from the local generated payload. If the local branch lacks trace data, make the acceptance failure explicit rather than silently shipping `missing`.
* Preserve safe `collectionHealth`, `runNarratives`, `demandClusters`, `industryEvents`, `movementAnalyses`, and `backtestAggregateSummary` when present.
* Preserve `collectionHealth`, `runNarratives`, `demandClusters`, `industryEvents`, `movementAnalyses`, and `backtestAggregateSummary` when safe and coherent after array trimming.
* Make array trimming relationship-aware across retained topics, evidence, sources, watchlist rows, movement rows, run narratives, clusters, events, predictions, retros, and story-log rows.
* Choose retained topics first, then retain cited evidence, source summaries for retained evidence, watchlist rows for retained topics, movement rows for retained topics, run narratives whose topic and evidence references still exist, demand clusters and industry events whose references still exist, and prediction/retro/story rows whose topic references still exist.
* Retain up to 8 ranked topics.
* Retain every evidence item cited by retained topics plus a top-evidence reserve capped at 32 total evidence items.
* Retain up to 12 source summaries for retained evidence.
* Retain up to 12 watchlist rows.
* Retain up to 6 run narratives.
* Retain up to 6 demand clusters.
* Retain up to 6 industry events.
* Retain up to 25 movement analyses.
* Retain up to 10 recent predictions.
* Retain up to 10 recent retros.
* Retain up to 50 story-log rows.
* Filter every dependent artifact to retained topic and evidence IDs.
* Use schema-valid Trend Finder provenance states while carrying frozen-real meaning in labels and notes.
* Use `dataState: "fixture-demo"` for the public snapshot unless the schema and tests intentionally migrate to new frozen-state strings.
* Preserve the selected run's `analysisState` when it is valid.
* Use labels or notes such as `Frozen real Trend Finder snapshot`, `Reviewed public-source snapshot`, and `AI runtime disabled on hosted demo` to carry frozen-real-demo meaning.
* Preserve original source-run truth in notes when the local run was degraded, blocked, fallback, AI-analyzed, or deterministic fallback.
* Replace generic fallback labels with frozen-real-demo labels when source Trend Finder payloads are populated and pass privacy scans, while keeping serialized state values schema-valid.
* Add positive and coherence regression coverage for exported Trend Finder content.
* Add or update tests for frozen real Trend Finder fixture policy.
* Add a positive fixture regression test to `scripts/lib/__tests__/pages-demo-snapshot.test.ts` or the established nearby test file that starts from a populated Trend Finder fixture and asserts non-empty exported trace, topics, evidence, source health, watchlist, and Brief-supporting data.
* Add a schema/coherence assertion that the exported Trend Finder branch still passes `parseTrendFinderData()` with expected positive counts and no missing retained references.
* Keep array limits intentional, but verify they do not hide the main demo story.

### Out of Scope

* Adding hosted collectors or hosted AI runtime.
* Emitting new provenance state strings without schema and test migration.
* Expanding Trend Finder source adapters.

***

## Prerequisites

* [ ] Sessions 01 and 02 revealed the selected input and exported fixture shape.
* [ ] `engineTrace` is present and sanitized in the selected local input.
* [ ] Existing Trend Finder schema limits and provenance states are respected.

***

## Deliverables

1. Updated Trend Finder public projection code.
2. Updated Trend Finder snapshot tests in `scripts/lib/__tests__/pages-demo-snapshot.test.ts` or the established nearby test file.
3. Schema-valid frozen-public labels or notes.
4. Reference-coherence assertions for retained Trend Finder artifacts.
5. Projection behavior that preserves or fails explicitly on sanitized Engine Replay state instead of silently exporting missing trace data.

***

## Success Criteria

* [ ] Real public evidence URLs and titles survive projection.
* [ ] Sanitized Engine Replay fields survive projection when present.
* [ ] Sanitized Engine Replay fields survive projection: trace state, run ID, section statuses, source summaries, evidence counts, runtime summary, artifact summaries, decision timeline, and stage narrations.
* [ ] Brief-supporting data and story-log rows survive projection when safe and coherent.
* [ ] Brief-supporting data survives projection: run narratives, demand clusters, industry events, prediction story log, and watchlist rows when present in the selected input.
* [ ] Exported Trend Finder data parses and passes positive count assertions.
* [ ] Exported Trend Finder data passes parsing and reference-coherence assertions.
* [ ] Tests fail if trimming leaves retained topics, evidence, or artifacts pointing at missing IDs.
* [ ] Private fields, local paths, credentials, raw logs, prompts, and provider bodies are removed or rejected by the overall snapshot policy.
* [ ] Tests fail if a private field leaks into the public demo snapshot.


---

# 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/phases/phase_33/session_03_harden_trend_finder_projection.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.
