> 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_06_scan_build_and_deploy.md).

# Session 06: Scan Build And Deploy

**Session ID**: `phase33-session06-scan-build-and-deploy` **Status**: Not Started **Estimated Tasks**: \~12-25 **Estimated Duration**: 2-4 hours

***

## Objective

Verify, package, and publish the updated static demo without leaking private data or running local-only workflows in production.

***

## Scope

### In Scope (MVP)

* Run snapshot, Pages build, privacy scan, and bundle budget commands.
* Run the snapshot exporter.
* Run the Pages build.
* Run the Pages privacy scan and bundle budget.
* Run focused tests for snapshot exporter, metadata, endpoint selection, Trend Finder demo states, Engine Replay, Dream transforms, and Dream run-button public demo behavior.
* Run focused unit tests around `pages-demo-snapshot`, public demo metadata, `use-live-data` public demo endpoint selection, Trend Finder Engine Replay, Trend Finder dashboard/demo states, Dream transforms, and Dream run-button public demo disabling.
* Smoke-test the static preview and deployed Cloudflare Pages routes.
* Spot-check `/`, Trend Finder Trends, Engine Replay, Hidden Gems, Sources, Watchlist, and Brief.
* Spot-check the hosted routes that matter most: `/`, `/extensions/trend-finder/trends`, `/extensions/trend-finder/engine`, `/extensions/trend-finder/hidden-gems`, `/extensions/trend-finder/sources`, `/extensions/trend-finder/watchlist`, and `/extensions/trend-finder/brief`.
* Confirm Cloudflare Pages build uses committed fixtures and does not run collectors, schedulers, local bridge reads, uploads, account auth, admin mutations, or Dream Review.
* Review final public snapshot and Pages output for local paths, credentials, private identifiers, raw prompts, provider bodies, and misleading live-runtime claims.
* Confirm Cloudflare Pages build does not run source ingestion, account auth, local bridge reads, uploads, admin mutations, Dream Review, or private Dream output reads.
* Deploy with the existing Cloudflare Pages project name after local verification passes:

  ```sh
  bun run demo:deploy:pages --project-name <real-pages-project-name> --branch main --execute
  ```
* Before using `--execute`, run the dry-run deploy command and confirm it prints the expected Wrangler command without secret values:

  ```sh
  bun run demo:deploy:pages --project-name <real-pages-project-name> --branch main
  ```

### Out of Scope

* Changing fixture projection policy after release gates start, except for fixes required by failed privacy or coherence checks.
* Committing Cloudflare credentials or project secrets.
* Adding Pages Functions or hosted runtime behavior.

***

## Prerequisites

* [ ] Sessions 02 through 05 are complete.
* [ ] Local `.env.local` contains Cloudflare account/token variables for deploy.
* [ ] The real Cloudflare Pages project name is supplied as a deploy argument.
* [ ] Cloudflare deployment is performed from this repository.
* [ ] `.env.local` supplies `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` to Bun/Wrangler locally; do not expose values in logs or docs.
* [ ] The Pages project name remains an operator deploy argument, not a committed config value.

***

## Deliverables

1. Passing local verification results for snapshot, scan, budget, build, and focused tests.
2. Updated `demo-website/dist` from the Pages build when generated locally.
3. Deployed or deployment-ready Cloudflare Pages demo using updated committed fixtures.
4. Deployment verification notes with final Pages URL, branch, source commit, and route HTTP status results.
5. Static preview and hosted smoke-test notes for the core route set.

***

## Success Criteria

* [ ] `bun run demo:snapshot --dry-run` passes before writing the final snapshot.
* [ ] `bun run demo:snapshot --dry-run` passes against the selected local input before writing.
* [ ] `bun run demo:scan:pages`, `bun run demo:budget:pages`, and `bun run demo:build:pages` pass.
* [ ] `bun run demo:scan:pages` passes.
* [ ] `bun run demo:budget:pages` passes.
* [ ] `bun run demo:build:pages` passes.
* [ ] Pages output contains `demo/live-data.snapshot.json`, `demo/snapshot-metadata.json`, and `demo/graphs/index.json`.
* [ ] `demo-website/dist` contains `demo/live-data.snapshot.json`, `demo/snapshot-metadata.json`, and `demo/graphs/index.json`.
* [ ] The deployed Pages URL serves the updated frozen snapshot.
* [ ] Hosted routes return HTTP 200 and no public demo route calls local bridge, scheduler, source mutation, graph mutation, or protected asset endpoints.
* [ ] Hosted route checks return HTTP 200.
* [ ] Browser smoke confirms no public demo route requests `/__live-data`, `/__run_trend_finder`, `/__run_dream`, `/__token`, source setup mutation endpoints, scheduler endpoints, graph mutation endpoints, or protected Trend Finder asset bridge endpoints.
* [ ] Dry-run deploy prints the expected Wrangler command without secret values before `--execute` is used.
* [ ] Manual review finds no private data, local paths, credentials, or misleading live-collection claims.
* [ ] Manual review finds no private data, local paths, credentials, or misleading live-collection or live-Dream-runtime claims.
* [ ] Hosted deployment verification records the final Pages URL, deployment branch, source commit, and HTTP status results for `/`, Trend Finder Trends, Engine Replay, Hidden Gems, Sources, Watchlist, and Brief.


---

# 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_06_scan_build_and_deploy.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.
