> 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_38/session_03_aggregate_and_dream_health.md).

# Session 03: Aggregate and Dream Health

**Session ID**: `phase38-session03-aggregate-and-dream-health` **Status**: Complete **Estimated Tasks**: \~12-25 **Estimated Duration**: 2-4 hours **Completed**: 2026-06-29

***

## Objective

Port Windows-aware aggregation and expose Dream health metadata through AI OS live data.

***

## Non-Negotiable Delivery Bar

This session is done only when a real aggregate run produces inspectable `src/data/live-data.json` output with the intended Windows-safe behavior and Dream health fields. Unit tests alone are not enough.

***

## Source Items

* 1.2 `ADAPT`: Windows-aware aggregation.
* Confirmed gap: `dream.healthStatus` and `dream.fixHint` are missing from AI OS live data and must be mapped from AI OS Dream observability.

***

## Scope

### In Scope (MVP)

* Adapt Windows app detection, terminal detection, path normalization, Obsidian discovery, and username/path redaction into existing AI OS aggregate modules.
* Populate `dream.healthStatus` and `dream.fixHint` in `src/data/live-data.json`.
* Map Dream health from AI OS Dream observability rather than copying upstream heuristics.
* Add graceful degradation for missing registries, unreadable directories, and unavailable Windows app locations.
* Add per-concern tests and aggregate-output tests.

### Out of Scope

* New Dream execution runners.
* Windows Task Scheduler install mechanics.
* Setup Dream engine selector.
* Dashboard Dream engine UI.
* Request-time bridge CLI resolution.

***

## Detailed Port Item

### 1.2 Windows-Aware Aggregation

Upstream `scripts/aggregate.ts` grew about 196 lines of cross-platform logic: `toPosix()` path normalization, Windows app detection from Start Menu `.lnk`, `%LOCALAPPDATA%\Programs`, Program Files (x86), Windows terminal inference, Obsidian vault discovery from the Obsidian registry, and Windows username or full-name redaction including PowerShell `Get-CimInstance`.

* Upstream sources: `/home/aiwithapex/projects/claudeos/claude-os-v2.7/scripts/aggregate.ts` and `/home/aiwithapex/projects/claudeos/claude-os-v2.8.1/scripts/aggregate.ts`.
* Patch line: 548.
* AI OS app-detection target: `/home/aiwithapex/projects/aios/scripts/lib/app-detection.ts`.
* AI OS tool/CLI detection target: `/home/aiwithapex/projects/aios/scripts/lib/tool-detection.ts`.
* AI OS path and scan helper targets: `/home/aiwithapex/projects/aios/scripts/lib/scan-helpers.ts`, `/home/aiwithapex/projects/aios/scripts/lib/session-scanner.ts`, and `/home/aiwithapex/projects/aios/scripts/lib/skill-scanner.ts`.
* AI OS redaction target: `/home/aiwithapex/projects/aios/scripts/lib/sanitize.ts`.
* AI OS Obsidian discovery targets: `/home/aiwithapex/projects/aios/scripts/lib/memory-scanner.ts` and, if UI prefill or validation should consume registry-discovered vaults, `/home/aiwithapex/projects/aios/src/components/hermes/hermes-obsidian-bridge.tsx`.
* AI OS orchestration target: `/home/aiwithapex/projects/aios/scripts/lib/aggregate-orchestration.ts`.
* AI OS live-data writer target: `/home/aiwithapex/projects/aios/scripts/lib/aggregate-live-data-write.ts`.
* Dream observability targets: `/home/aiwithapex/projects/aios/scripts/lib/dream/observability.ts` and `/home/aiwithapex/projects/aios/scripts/lib/dream/material-readiness.ts`.
* Confirmed gap: current `src/data/live-data.json` Dream shape has `date`, `model`, `generatedAt`, `prescriptions`, and `metadata`, but lacks `healthStatus` and `fixHint`.
* Required health values: `healthy`, `never_ran`, `silent_failure`, and `stale`, plus actionable fix hints.
* Risk: medium due to wide aggregate surface area.

***

## Implementation Notes

* Route each upstream concern to the matching AI OS module. Do not recreate upstream monolithic `aggregate.ts`.
* Use the Session 02 platform module for path normalization and app-data paths.
* Treat missing Windows registries, missing Obsidian registry, and unreadable directories as degraded data, not aggregate failure.
* Preserve macOS/Linux aggregate behavior as the regression baseline.
* Redaction must cover usernames, emails, and platform-specific private paths.
* Dream health must be live-data visible because Session 07 dashboard empty states consume it.

***

## Prerequisites

* [x] Session 02 platform helper exists.
* [x] Aggregate live-data writer and Dream observability modules are mapped.
* [x] Existing tests under `scripts/lib/__tests__/` are identified, especially `tool-detection.test.ts` or nearby aggregate tests.

***

## Deliverables

1. Windows-aware aggregate behavior in app, tool, scan, session, skill, memory, sanitize, and orchestration modules where applicable.
2. `dream.healthStatus` and `dream.fixHint` written to live data for never-ran, healthy, stale, and silent-failure states.
3. Graceful degradation for missing registries and unreadable directories.
4. Tests covering Windows path normalization, app detection, Obsidian fallback, redaction, and Dream health mapping.

***

## Success Criteria

* [x] A real aggregate run writes `src/data/live-data.json` with `dream.healthStatus` and `dream.fixHint`.
* [x] Dream health mapping is proven for never-ran, healthy, stale, and silent-failure states by manipulating Dream output timestamps or equivalent faithful fixtures.
* [x] Windows-specific tests prove backslash paths do not inflate counts.
* [x] Sensitive user data is redacted in generated aggregate output.
* [x] Missing Obsidian registry and unreadable directories degrade gracefully.
* [x] macOS/Linux aggregate behavior regression-checks against the current baseline.


---

# 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_38/session_03_aggregate_and_dream_health.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.
