> For the complete documentation index, see [llms.txt](https://faction-os.gitbook.io/faction-os-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/sessions/phase19-session15-metrics-and-notifications/validation.md).

# Validation Report

**Session ID**: `phase19-session15-metrics-and-notifications` **Package**: cross-cutting **Validated**: 2026-06-28 **Result**: PASS

## Validation Summary

| Check                     | Status | Notes                                                                                                                                                        |
| ------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Code Review               | PASS   | `code-review.md` exists, scope says all uncommitted changes were reviewed, and `Result: RESOLVED`.                                                           |
| Tasks Complete            | PASS   | 22/22 tasks complete.                                                                                                                                        |
| Files Exist               | PASS   | 45/45 deliverables exist and are non-empty.                                                                                                                  |
| ASCII Encoding            | PASS   | Fixed non-ASCII comments/test literals in `apps/web/src/lib/useNotifications.ts` and `apps/web/tests/useNotifications.test.tsx`; final scan has no findings. |
| Tests Passing             | PASS   | 2945/2946 tests passed; 1 skipped; 0 failed.                                                                                                                 |
| Database/Schema Alignment | N/A    | No DB-layer, migration, schema, SQL, ORM, or persisted schema artifact changes.                                                                              |
| Quality Gates             | PASS   | Protocol/server/web typechecks, format, lint, full tests, whitespace, ASCII, and LF checks pass.                                                             |
| Conventions               | PASS   | Biome, TypeScript, Vitest, bounded payloads, local-first routes, and no-claim docs match conventions.                                                        |
| Security & GDPR           | PASS   | See `security-compliance.md`; no security or GDPR findings.                                                                                                  |
| Behavioral Quality        | PASS   | Trust boundaries, cleanup, mutation safety, failure paths, and contract alignment spot-check passed.                                                         |
| UI Product Surface        | PASS   | Metrics panel and command-center surfaces are product-facing; diagnostics/raw payload copy is absent from primary UI.                                        |

**Overall**: PASS

## Evidence Ledger

| Check                      | Command or Inspection                                                                                                                             | Result                                                                                  | Evidence / Blocker                                                                                                                    |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| Project state              | `if [ -d ".spec_system/scripts" ]; then bash .spec_system/scripts/analyze-project.sh --json; else bash .../scripts/analyze-project.sh --json; fi` | PASS                                                                                    | Current session is `phase19-session15-metrics-and-notifications`; monorepo is true; package is cross-cutting (`Package: null`).       |
| Runtime version            | `source "$HOME/.nvm/nvm.sh" && nvm use 26.2.0 && node -v && npm -v`                                                                               | PASS                                                                                    | Node `v26.2.0`, npm `11.16.0`.                                                                                                        |
| Code review                | `sed -n '1,320p' .spec_system/specs/phase19-session15-metrics-and-notifications/code-review.md`                                                   | PASS                                                                                    | `Result: RESOLVED`; scope says all uncommitted changes were reviewed.                                                                 |
| Task completion            | `rg -n '^\- \[[ x]\] T[0-9]{3}' .spec_system/specs/phase19-session15-metrics-and-notifications/tasks.md`                                          | PASS                                                                                    | 22 task rows, all `[x]`; progress summary says 22/22.                                                                                 |
| Deliverables               | `awk -F'\`' '/^\| \`\[^\`]+\` \|/ {print $2}' .../spec.md                                                                                         | while ... \[ -s "$path" ]\`                                                             | PASS                                                                                                                                  |
| ASCII/LF                   | `awk -F'\`' ...                                                                                                                                   | while ... LC\_ALL=C grep -n '\[^\[:print:]\[:space:]]' "$path"; grep -l $'\r' "$path"\` | PASS                                                                                                                                  |
| Whitespace                 | `git diff --check`                                                                                                                                | PASS                                                                                    | No whitespace errors.                                                                                                                 |
| Format                     | `source "$HOME/.nvm/nvm.sh" && nvm use 26.2.0 >/dev/null && npm run format:check`                                                                 | PASS                                                                                    | Biome checked 747 files; no fixes applied.                                                                                            |
| Lint                       | `source "$HOME/.nvm/nvm.sh" && nvm use 26.2.0 >/dev/null && npm run lint`                                                                         | PASS                                                                                    | Biome checked 749 files; no fixes applied.                                                                                            |
| Protocol typecheck         | `source "$HOME/.nvm/nvm.sh" && nvm use 26.2.0 >/dev/null && npm --workspace packages/protocol run typecheck`                                      | PASS                                                                                    | `tsc --noEmit` exited 0.                                                                                                              |
| Server typecheck           | `source "$HOME/.nvm/nvm.sh" && nvm use 26.2.0 >/dev/null && npm --workspace apps/server run typecheck`                                            | PASS                                                                                    | `tsc --noEmit` exited 0.                                                                                                              |
| Web typecheck              | `source "$HOME/.nvm/nvm.sh" && nvm use 26.2.0 >/dev/null && npm --workspace apps/web run typecheck`                                               | PASS                                                                                    | `tsc -b --noEmit` exited 0.                                                                                                           |
| Targeted touched-file test | `source "$HOME/.nvm/nvm.sh" && nvm use 26.2.0 >/dev/null && npm test -- useNotifications`                                                         | PASS                                                                                    | 1 file passed; 8 tests passed.                                                                                                        |
| Full tests                 | `source "$HOME/.nvm/nvm.sh" && nvm use 26.2.0 >/dev/null && npm test`                                                                             | PASS                                                                                    | 259 test files passed, 1 skipped; 2945 tests passed, 1 skipped.                                                                       |
| Database/schema            | \`git diff --name-only HEAD                                                                                                                       | rg -n '(migrations?                                                                     | schema                                                                                                                                |
| Dependency security        | \`git diff --name-only HEAD                                                                                                                       | rg -n '(^package(-lock)?.json$                                                          | pnpm-lock                                                                                                                             |
| Security/GDPR              | \`rg -n "(api\[\_-]?key                                                                                                                           | secret                                                                                  | token                                                                                                                                 |
| Behavioral quality         | Targeted inspection of notification/metrics route, helper, API, hook, and panel files                                                             | PASS                                                                                    | Validation, authorization inheritance, duplicate-trigger guards, cleanup, timeouts, failure states, and parser alignment are present. |
| UI product surface         | \`rg -n "debug                                                                                                                                    | telemetry                                                                               | seed                                                                                                                                  |

## 1. Code Review Gate

### Status: PASS

**Report**: `code-review.md` **Result**: RESOLVED **Issues**: None unresolved. `creview` fixed one medium `expirationTime` validation issue and one low Web Push subscription status issue before validation.

## 2. Task Completion

### Status: PASS

**Tasks**: 22/22 complete **Incomplete tasks**: None

## 3. Deliverables Verification

### Status: PASS

45/45 files listed in `spec.md` exist and are non-empty. The verification command checked every deliverable path from the Files To Create and Files To Modify tables.

**Missing deliverables**: None

## 4. ASCII Encoding Check

### Status: PASS

| File                | Encoding | Line Endings | Status |
| ------------------- | -------- | ------------ | ------ |
| All 45 deliverables | ASCII    | LF           | PASS   |

**Encoding issues fixed during validation**:

* `apps/web/src/lib/useNotifications.ts` - replaced em dash and arrow characters in comments with ASCII text.
* `apps/web/tests/useNotifications.test.tsx` - replaced em dash and arrow characters in comments and emoji test literals with ASCII escape form `\u{1F3C6}`.

Final deliverable scan emitted no non-ASCII or CRLF findings.

## 5. Test Results

### Status: PASS

| Metric      | Value                        |
| ----------- | ---------------------------- |
| Total Tests | 2946                         |
| Passed      | 2945                         |
| Failed      | 0                            |
| Skipped     | 1                            |
| Coverage    | Not reported by this command |

**Failed tests**: None

## 6. Database/Schema Alignment

### Status: N/A

**Evidence**: `git diff --name-only HEAD | rg -n '(migrations?|schema|prisma|drizzle|typeorm|sequelize|sql|database|db)' || true` returned no files.

**Issues found**: None

## 7. Success Criteria

From `spec.md`:

**Functional requirements**:

* PASS - Operators can see task, hero, plan, queue, executor, attention, approval, review, provider, and cost metrics in the Orchestration Metrics tab. Evidence: `MetricsAndNotificationsPanel.test.tsx`, `OrchestrationPanel.test.tsx`, and full `npm test`.
* PASS - Metrics include duration, events, tool-use count, estimated tokens/cost, lines changed, failures, retries, throughput, stalled tasks, blocked age, review backlog, pending approvals age, latency, queue age, executor utilization, provider usage imports, and plan/hero/task rollups where source data exists. Evidence: `usageMetricsManager.test.ts`, protocol parser tests, and full `npm test`.
* PASS - Attention summary shows compact counts, risk/severity distribution, age buckets, and mobile filters. Evidence: `commandCenterMetrics.test.ts`, `OrchestrationPanel.test.tsx`, and full `npm test`.
* PASS - Local notification routing handles approvals, questions, blocked tasks, failed tasks, and review gates with duplicate-trigger prevention. Evidence: `commandCenterNotifications.test.ts`, `useNotifications.test.tsx`, `notifications.test.ts`, and full `npm test`.
* PASS - Web Push subscribe/unsubscribe reports ready only with consent and VAPID readiness; default posture remains disabled or unavailable without hosted push claims. Evidence: `notificationRouting.test.ts`, `commandCenterNotifications.test.ts`, `hostedOperations.test.ts`, docs inspection, and full `npm test`.

**Testing requirements**:

* PASS - Protocol tests cover metric kinds, notification channels, subscription/readiness fields, routing categories, payload categories, and blocked raw fields.
* PASS - Server tests cover aggregation, provider imports, usage routes, notification preferences, subscription validation, readiness states, WebSocket updates, duplicate triggers, and no raw echo.
* PASS - Web tests cover API clients, store normalization, metrics panel, attention header, mobile filters, local notification routing, hidden-tab delivery, readiness copy, and accessibility labels.

**Quality gates**:

* PASS - ASCII and LF checks pass after validation fix.
* PASS - `npm --workspace packages/protocol run typecheck` passes.
* PASS - `npm --workspace apps/server run typecheck` passes.
* PASS - `npm --workspace apps/web run typecheck` passes.
* PASS - `npm run format:check`, `npm run lint`, and `npm test` pass.

## 8. Conventions Compliance

### Status: PASS

**Categories spot-checked**: naming, file structure, error handling, comments, testing, and database conventions.

**Convention violations**: None. New code follows npm workspace structure, TypeScript package boundaries, Biome formatting/linting, Vitest testing, protocol-led contract changes, bounded payloads, and local-first no-claim route behavior.

## 9. Security & GDPR Compliance

### Status: PASS

**Full report**: See `security-compliance.md` in this session directory.

#### Summary

| Area     | Status | Findings |
| -------- | ------ | -------- |
| Security | PASS   | 0 issues |
| GDPR     | PASS   | 0 issues |

**Critical violations**: None

## 10. Behavioral Quality Spot-Check

### Status: PASS

**Checklist applied**: Yes **Files spot-checked**:

* `apps/server/src/lib/notificationRouting.ts`
* `apps/server/src/routes/commandCenterNotifications.ts`
* `apps/web/src/lib/orchestrationApi.ts`
* `apps/web/src/lib/commandCenterNotifications.ts`
* `apps/web/src/components/orchestration/MetricsAndNotificationsPanel.tsx`

**Categories spot-checked**: trust boundaries, resource cleanup, mutation safety, failure paths, and contract alignment.

**Violations found**: None

**Fixes applied during validation**: ASCII-only cleanup in `apps/web/src/lib/useNotifications.ts` and `apps/web/tests/useNotifications.test.tsx`.

## 11. UI Product-Surface Spot-Check

### Status: PASS

**Surfaces inspected**: `MetricsAndNotificationsPanel`, `OrchestrationHeader`, `AttentionWorkbench`, `SettingsDrawer`, plus `MetricsAndNotificationsPanel.test.tsx` and `OrchestrationPanel.test.tsx`.

**Diagnostics found in primary UI**: None. The Metrics panel uses product-facing operational copy for costs, readiness, consent, local notifications, and unavailable Web Push states. Raw payload, endpoint, token, and VAPID details are not shown in the primary panel.

**Allowed debug/admin surfaces**: Existing provider diagnostics/settings copy outside the Metrics panel remains scoped to product settings and diagnostic posture.

**Fixes applied during validation**: None for UI copy.

## Validation Result

### PASS

Session 15 satisfies its workflow gates. Validation fixed a repo-fixable ASCII issue in two deliverable files, then reran the affected test, full tests, typechecks, lint, format, whitespace, and final encoding checks successfully.

### Unresolved Failures And Blockers

None

## Next Steps

Next command: `updateprd`


---

# 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://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/sessions/phase19-session15-metrics-and-notifications/validation.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.
