> 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-session09-source-death-baseline-alarm/implementation-notes.md).

# Implementation Notes

**Session ID**: `phase29-session09-source-death-baseline-alarm` **Started**: 2026-06-20 23:30 **Last Updated**: 2026-06-21 00:01

***

## Session Progress

| Metric              | Value     |
| ------------------- | --------- |
| Tasks Completed     | 20 / 20   |
| Estimated Remaining | 0 minutes |
| Blockers            | 0         |

***

### Task T020 - Run focused checks and validation

**Started**: 2026-06-20 23:54 **Completed**: 2026-06-21 00:01 **Duration**: 7 minutes

**Notes**:

* Ran focused Vitest suites for helper, collector, trace, view-model, Sources view, and Engine Source Rail coverage.
* Ran app and script TypeScript checks.
* Ran private runtime artifact scan.
* Ran payload byte check for the source-death fixture and committed example Trend Finder payload against the 1 MB budget.
* Ran ASCII validation for touched code, tests, docs, and session files.
* Ran `git diff --check`.
* Updated source-death behavior docs listed by the session spec.

**Files Changed**:

* `docs/extensions/trend-finder-pipeline.md` - Documented the private source-death baseline pipeline boundary.
* `docs/extensions/trend-finder-sources.md` - Documented source-death warning semantics and excluded states.
* `docs/extensions/trend-finder-runtime-and-provenance.md` - Documented Engine Replay source-death surfacing and privacy limits.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T020 and completion checklist complete.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged final verification.

**BQC Fixes**:

* Contract alignment: Type checks and focused tests passed across browser and script contracts.
* Error information boundaries: Private artifact scan, payload checks, ASCII validation, and source-death privacy assertions passed.

***

## Verification Summary

* `bun run test -- scripts/extensions/trend-finder/__tests__/source-death-baseline.test.ts scripts/extensions/trend-finder/__tests__/collector.test.ts scripts/extensions/trend-finder/__tests__/engine-trace.test.ts src/extensions/trend-finder/__tests__/view-model.test.ts src/extensions/trend-finder/__tests__/visibility-views.test.tsx src/extensions/trend-finder/components/__tests__/engine-source-rail.test.tsx` - passed, 6 files / 121 tests.
* `bun run typecheck` - passed.
* `bun run typecheck:scripts` - passed.
* `bun run runtime:check-private` - passed.
* Payload byte check - passed; source-death fixture 96805 bytes, example Trend Finder payload 2 bytes.
* ASCII validation for touched files - passed.
* `git diff --check` - passed.

***

### Task T019 - Add schema, view-model, Sources, and Engine Replay tests

**Started**: 2026-06-20 23:51 **Completed**: 2026-06-20 23:54 **Duration**: 3 minutes

**Notes**:

* Extended view-model tests for legacy source-death defaults and active source-death warning projection.
* Added Sources view rendering coverage for the source-death tile and warning copy.
* Extended Engine Source Rail component coverage for the source-death metric and node warning label.

**Files Changed**:

* `src/extensions/trend-finder/__tests__/view-model.test.ts` - Added source-death default and warning projection assertions.
* `src/extensions/trend-finder/__tests__/visibility-views.test.tsx` - Added Sources view source-death rendering assertions.
* `src/extensions/trend-finder/components/__tests__/engine-source-rail.test.tsx` - Added source-death metric and node warning rendering assertions.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T019 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged UI/model test work.

**BQC Fixes**:

* Accessibility and platform compliance: Component tests assert accessible source-death metric labels.
* Error information boundaries: UI tests assert private baseline and path strings are not rendered.

***

### Task T018 - Add collector and Engine Replay trace tests

**Started**: 2026-06-20 23:49 **Completed**: 2026-06-20 23:51 **Duration**: 2 minutes

**Notes**:

* Added collector propagation coverage using an injected source-death evaluation result.
* Added Engine Replay trace sanitizer coverage for source-death collection-health fields and per-source warning projection.
* Helper tests from T017 cover disabled, unconfigured, credential-missing, restricted, placeholder, skipped-fallback, corrupt-baseline, and baseline update behavior at the eligibility/persistence boundary.

**Files Changed**:

* `scripts/extensions/trend-finder/__tests__/collector.test.ts` - Added source-death collector propagation test.
* `scripts/extensions/trend-finder/__tests__/engine-trace.test.ts` - Added source-death sanitized trace mapping test.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T018 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged collector and trace test work.

**BQC Fixes**:

* Contract alignment: Tests assert browser data and Engine Replay trace share source-death labels/counts.
* Error information boundaries: Tests assert private baseline filenames, private paths, and prior-count fields stay out of serialized outputs.

***

### Task T017 - Add source-death baseline helper tests

**Started**: 2026-06-20 23:47 **Completed**: 2026-06-20 23:49 **Duration**: 2 minutes

**Notes**:

* Added helper tests for zeroed-live alarms, first-run no-op, baseline update, ineligible source exclusions, corrupt-baseline suppression, atomic write cleanup, and privacy sentinels.

**Files Changed**:

* `scripts/extensions/trend-finder/__tests__/source-death-baseline.test.ts` - Added focused helper unit tests.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T017 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged helper test work.

**BQC Fixes**:

* Failure path completeness: Tests cover corrupt baseline and write failure paths.
* Error information boundaries: Tests assert private paths, baseline filename, prior count field, and token-shaped sentinels stay out of result projections.

***

### Task T016 - Surface source-death metric in Engine Replay source rail

**Started**: 2026-06-20 23:44 **Completed**: 2026-06-20 23:47 **Duration**: 3 minutes

**Notes**:

* Added a source-death source rail metric from sanitized trace/payload collection health.
* Source rail nodes now prefer safe source-death labels when present.
* Added aria labels to source rail metric tiles.

**Files Changed**:

* `src/extensions/trend-finder/engine-replay-model.ts` - Added source-death source rail metric and node warning label projection.
* `src/extensions/trend-finder/components/engine-source-rail.tsx` - Added accessible metric labels.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T016 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged Engine Replay source rail work.

**BQC Fixes**:

* Accessibility and platform compliance: Source rail metrics now expose label, value, and detail through `aria-label`.
* Error information boundaries: Source rail uses sanitized trace/payload labels only.

***

### Task T015 - Surface source-death warnings in Sources view

**Started**: 2026-06-20 23:43 **Completed**: 2026-06-20 23:46 **Duration**: 3 minutes

**Notes**:

* Added a source-death health tile with warning tone only when alarms are active.
* Source warning panel now receives source-death warnings through the shared warning view model.
* Source table warning cells use the safe source-death label and tooltip.

**Files Changed**:

* `src/extensions/trend-finder/views/sources-view.tsx` - Added source-death health tile and source warning label support.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T015 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged Sources view work.

**BQC Fixes**:

* Accessibility and platform compliance: Source warning labels remain visible text and tooltip text without private details.
* Error information boundaries: View renders only safe view-model labels and counts.

***

### Task T014 - Project source-death warnings into view models

**Started**: 2026-06-20 23:42 **Completed**: 2026-06-20 23:46 **Duration**: 4 minutes

**Notes**:

* Added collection-health source-death view-model fields for count, label, detail, and active state.
* Added source-summary source-death label and active-state projection.
* Updated source warning aggregation to include source-death warnings even when no separate source error message exists.
* Carried source-death trace projection into Engine Replay source rail models.

**Files Changed**:

* `src/extensions/trend-finder/view-model.ts` - Added source-death collection-health and source-summary view-model projections.
* `src/extensions/trend-finder/engine-replay-model.ts` - Projected source-death trace and payload fields into source rail metrics and node labels.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T014 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged view-model projection work.

**BQC Fixes**:

* Accessibility and platform compliance: View models expose explicit labels for UI and aria text.
* Contract alignment: View models default missing source-death fields to neutral states.

***

### Task T013 - Map sanitized source-death fields through Engine Replay trace

**Started**: 2026-06-20 23:41 **Completed**: 2026-06-20 23:42 **Duration**: 1 minute

**Notes**:

* Mapped `sourceDeathAlarmCount` and `sourceDeathAlarmLabel` from `sources.collected.collectionHealth`.
* Mapped per-source `sourceDeathWarning` objects into sanitized Engine Replay source summaries.
* Used existing unsafe-value filtering and bounded label sanitization.

**Files Changed**:

* `scripts/extensions/trend-finder/engine-trace.ts` - Added source-death collection-health and source-summary trace mapping.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T013 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged trace mapping work.

**BQC Fixes**:

* Error information boundaries: Trace mapping rejects unsafe collection-health objects and sanitizes source warning labels.
* Contract alignment: Script-side trace output now matches the Engine Replay trace schema fields.

***

### Task T012 - Update source summaries and collection health

**Started**: 2026-06-20 23:40 **Completed**: 2026-06-20 23:41 **Duration**: 1 minute

**Notes**:

* Alarmed sources now carry degraded status/warning state and a safe source-death warning projection.
* Existing source error messages are preserved; the source-death label is used only when no message exists.
* Collection health now carries source-death alarm count/label and moves to warning state when alarms are active.

**Files Changed**:

* `scripts/extensions/trend-finder/source-death-baseline.ts` - Applied safe alarm projections to source summaries and collection health.
* `scripts/extensions/trend-finder/collector.ts` - Published post-alarm source summaries and collection health to trace/browser assembly.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T012 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged summary/health projection behavior.

**BQC Fixes**:

* Contract alignment: Collector publishes source and collection-health projections matching the schema defaults.
* Error information boundaries: Existing safe source messages are preserved; no private baseline details are added to browser payloads.

***

### Task T011 - Wire collector source-death evaluation

**Started**: 2026-06-20 23:40 **Completed**: 2026-06-20 23:41 **Duration**: 1 minute

**Notes**:

* Called source-death baseline evaluation after source setup enrichment and initial collection-health creation.
* Ran evaluation before `sources.collected` trace emission and before browser payload assembly.
* Reused accepted-evidence counts from the collector source boundary and appended safe helper warnings to source collection warnings.
* Added a safe trace warning event when source-death alarms are present.

**Files Changed**:

* `scripts/extensions/trend-finder/collector.ts` - Imported and called source-death baseline evaluation at the source collection boundary.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T011 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged collector wiring.

**BQC Fixes**:

* Duplicate action prevention: Evaluation is executed once in the source assembly path and writes a deterministic baseline snapshot for the run.
* State freshness on re-entry: The helper reads current private baseline state during each collector run before deriving alarms.
* Error information boundaries: Trace warning data includes only source IDs/names and safe labels.

***

### Task T010 - Implement browser-safe warning projection

**Started**: 2026-06-20 23:36 **Completed**: 2026-06-20 23:40 **Duration**: 4 minutes

**Notes**:

* Added bounded per-source source-death warning labels.
* Added aggregate collection-health source-death alarm count and label.
* Preserved existing source error messages when present and only filled the safe source-death message when no safer message existed.

**Files Changed**:

* `scripts/extensions/trend-finder/source-death-baseline.ts` - Added source warning and collection-health alarm projections.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T010 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged safe projection behavior.

**BQC Fixes**:

* Error information boundaries: Projection excludes baseline file names, private paths, prior accepted-evidence counts, raw diagnostics, tokens, and credential-shaped values.
* Contract alignment: Projection matches the browser schema fields added in this session.

***

### Task T009 - Implement zeroed-live alarm derivation

**Started**: 2026-06-20 23:36 **Completed**: 2026-06-20 23:39 **Duration**: 3 minutes

**Notes**:

* Added source-ID sorted alarm derivation from current accepted evidence counts and loaded last-good baselines.
* Required a positive private last-good count and zero current accepted evidence before alarming.
* Suppressed alarms when the prior baseline is missing or corrupt.

**Files Changed**:

* `scripts/extensions/trend-finder/source-death-baseline.ts` - Added deterministic source-death alarm derivation and alarm summaries.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T009 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged alarm derivation behavior.

**BQC Fixes**:

* State freshness on re-entry: Each evaluation reads the current baseline and current accepted counts before deriving alarms.
* Concurrency safety: Alarm derivation uses local immutable snapshots and deterministic ordering.

***

### Task T008 - Implement baseline read/write behavior

**Started**: 2026-06-20 23:35 **Completed**: 2026-06-20 23:39 **Duration**: 4 minutes

**Notes**:

* Implemented missing-baseline neutral reads and corrupt-baseline safe fallback warnings.
* Implemented private atomic writes through temp file, chmod, rename, and cleanup.
* Preserved existing last-good entries while updating current sources that produced accepted evidence.

**Files Changed**:

* `scripts/extensions/trend-finder/source-death-baseline.ts` - Added baseline read, validation, write, and cleanup behavior.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T008 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged baseline persistence behavior.

**BQC Fixes**:

* Resource cleanup: Failed writes remove temp files before returning safe warnings.
* Failure path completeness: Corrupt baseline state suppresses alarms instead of failing the collector.
* External dependency resilience: File IO failures return safe warnings for the caller to surface without private detail.

***

### Task T007 - Add source-death fixture variants

**Started**: 2026-06-20 23:37 **Completed**: 2026-06-20 23:39 **Duration**: 2 minutes

**Notes**:

* Added normal, zeroed-live, first-run, disabled-source, and skipped-fallback fixture variants.
* Added neutral and warning source-death projections to support UI and parser tests.
* Added fixture collection-health and trace collection-health alarm count/label projections.

**Files Changed**:

* `src/extensions/trend-finder/fixtures.ts` - Added source-death fixture helpers and exported data variants.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T007 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged fixture work.

**BQC Fixes**:

* Contract alignment: Fixtures include both payload and trace source-death projections for UI tests.
* Error information boundaries: Fixture warning copy uses safe labels only.

***

### Task T006 - Define deterministic source eligibility rules

**Started**: 2026-06-20 23:36 **Completed**: 2026-06-20 23:37 **Duration**: 1 minute

**Notes**:

* Implemented `isSourceDeathEligible` against source setup state and current source summary state.
* Excluded missing setup, unconfigured, disabled, credential-missing, restricted, placeholder, offline, blocked, fallback, and skipped direct-fallback cases.
* Required current source rows to be active or degraded before an alarm can fire.

**Files Changed**:

* `scripts/extensions/trend-finder/source-death-baseline.ts` - Added explicit source-death eligibility rules.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T006 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged eligibility rules.

**BQC Fixes**:

* Trust boundary enforcement: Alarm eligibility is rechecked at the collector helper boundary using setup state, not upstream assumptions.
* Failure path completeness: Ineligible or ambiguous sources remain neutral instead of producing false-positive alarms.

***

### Task T005 - Add Engine Replay trace schema defaults

**Started**: 2026-06-20 23:36 **Completed**: 2026-06-20 23:37 **Duration**: 1 minute

**Notes**:

* Added aggregate source-death alarm count and label to Engine Replay collection health.
* Added a bounded per-source source-death warning object to Engine Replay source summaries.
* Added neutral defaults in the trace input parser for older sanitized traces.

**Files Changed**:

* `src/extensions/trend-finder/engine-trace.ts` - Added source-death trace types, defaults, and Zod parser fields.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T005 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged Engine Replay trace schema work.

**BQC Fixes**:

* Contract alignment: Trace input parsing now accepts missing legacy source-death fields with neutral defaults.
* Error information boundaries: Trace schema allows only bounded labels and counts.

***

### Task T004 - Add browser-safe source-death schema fields

**Started**: 2026-06-20 23:35 **Completed**: 2026-06-20 23:36 **Duration**: 1 minute

**Notes**:

* Added neutral source-death defaults for collection-health alarm count and label.
* Added a bounded source warning projection with `none` and `warning` states.
* Kept source warning projection optional at the TypeScript output boundary so existing source literals remain compatible while new payloads can carry the safe projection.

**Files Changed**:

* `src/extensions/trend-finder/schema.ts` - Added source-death warning constants, schema, type, collection-health defaults, and collection-health fields.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T004 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged schema work.

**BQC Fixes**:

* Contract alignment: Added additive schema defaults so legacy payloads parse with neutral source-death state.
* Error information boundaries: Browser-safe fields contain only alarm count and bounded labels, not private paths or prior accepted-evidence counts.

***

### Task T003 - Create private source-death baseline helper contract

**Started**: 2026-06-20 23:32 **Completed**: 2026-06-20 23:36 **Duration**: 4 minutes

**Notes**:

* Added a script-only source-death baseline helper with schema-versioned private state keyed by source ID.
* Added dependency-injected read/write/rename/remove/chmod hooks for focused tests.
* Added private path resolution under the collector cache without using source IDs as path segments.
* Added corrupt-baseline fallback that suppresses alarms and emits a safe warning.

**Files Changed**:

* `scripts/extensions/trend-finder/source-death-baseline.ts` - Created private baseline helper contract, schema, path resolver, read/write primitives, and fallback behavior.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T003 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged helper contract work.

**BQC Fixes**:

* Resource cleanup: Atomic write removes the temp file on write/rename failure.
* Failure path completeness: Missing baselines are neutral; corrupt baselines emit a caller-visible safe warning and suppress alarms.
* Error information boundaries: Helper warnings do not expose cache paths, file names, prior counts, stack traces, or raw parse errors.

***

### Task T002 - Inspect collector source flow and related contracts

**Started**: 2026-06-20 23:31 **Completed**: 2026-06-20 23:32 **Duration**: 1 minute

**Notes**:

* Identified the insertion point after source setup enrichment and `buildCollectionHealth`, before the `sources.collected` trace event and browser payload assembly.
* Confirmed source setup carries `configured`, `enabled`, `credentialStatus`, `actorStatus`, `status`, `directReadiness`, and `fallbackLabel` fields for alarm eligibility.
* Confirmed private diagnostics already use sanitized path segments and atomic temp-file writes that the baseline helper can mirror.
* Confirmed Engine Replay trace mapping reads `sources.collected.collectionHealth` and `sources` with unsafe-value rejection.
* Confirmed Sources and Engine Replay already have warning chips, health tiles, and source rail metrics for additive surfacing.

**Files Changed**:

* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T002 complete and updated progress.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Logged source-flow inspection.

**BQC Fixes**:

* N/A - inspection only.

***

### Task T001 - Verify analyzer state and session scope

**Started**: 2026-06-20 23:30 **Completed**: 2026-06-20 23:31 **Duration**: 1 minute

**Notes**:

* Analyzer selected `phase29-session09-source-death-baseline-alarm` as the active session.
* Verified Phase 29 is `in_progress` with 18 planned sessions.
* Verified `phase29-session07-per-stage-validation-narration` is present in completed sessions.
* Confirmed Session 09 PRD stub scope matches the source-death baseline alarm objective.

**Files Changed**:

* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/implementation-notes.md` - Started the session implementation log.
* `.spec_system/specs/phase29-session09-source-death-baseline-alarm/tasks.md` - Marked T001 complete and updated progress.

**BQC Fixes**:

* N/A - setup verification only.

***

## Task Log

### 2026-06-20 - Session Start

**Environment verified**:

* [x] Prerequisites confirmed
* [x] Tools available
* [x] Directory structure ready

***


---

# 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-session09-source-death-baseline-alarm/implementation-notes.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.
