> 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/phase40-session15-ministry-config-analytics-and-save-ux/code-review.md).

# Code Review and Repair Report

**Session ID**: `phase40-session15-ministry-config-analytics-and-save-ux` **Reviewed**: 2026-07-03 **Base Commit**: `3af25ba69902c9208e493d415bb12d7d41f06b33` **Scope**: All changes since the base commit (uncommitted work plus mid-session commits) **Result**: RESOLVED

## Review Surface

**Files reviewed** (all changes since the base commit):

* `.spec_system/state.json` - tracked-modified session state
* `.spec_system/specs/phase40-session15-ministry-config-analytics-and-save-ux/spec.md` - untracked session spec
* `.spec_system/specs/phase40-session15-ministry-config-analytics-and-save-ux/tasks.md` - untracked task checklist
* `.spec_system/specs/phase40-session15-ministry-config-analytics-and-save-ux/implementation-notes.md` - untracked implementation notes
* `src/components/hermes/chat/__tests__/hermes-chat-tab.test.tsx` - tracked-modified chat selector coverage
* `src/components/hermes/hermes-pantheon.tsx` - tracked-modified admin prop pass-through
* `src/components/hermes/ministry/__tests__/ministry-builder.test.tsx` - tracked-modified builder/save/copy coverage
* `src/components/hermes/ministry/__tests__/ministry-analytics.test.ts` - untracked analytics helper coverage
* `src/components/hermes/ministry/__tests__/ministry-config.test.ts` - untracked config helper coverage
* `src/components/hermes/ministry/index.ts` - tracked-modified Ministry exports
* `src/components/hermes/ministry/ministry-analytics.ts` - untracked analytics helper
* `src/components/hermes/ministry/ministry-analytics-shell.tsx` - tracked-modified analytics UI
* `src/components/hermes/ministry/ministry-builder.tsx` - tracked-modified builder wiring
* `src/components/hermes/ministry/ministry-config.ts` - untracked config/YAML helper
* `src/components/hermes/ministry/ministry-save-copy-shell.tsx` - tracked-modified save/copy UI
* `src/components/hermes/ministry/ministry-types.ts` - tracked-modified types
* `src/hooks/__tests__/use-hermes-admin.test.tsx` - tracked-modified hook invalidation coverage
* `tests/e2e/hermes-agent.spec.ts` - tracked-modified Pantheon smoke coverage

**Report artifact**:

* `.spec_system/specs/phase40-session15-ministry-config-analytics-and-save-ux/code-review.md` - untracked creview report created after review

**Inventory commands**: `git status`, `git log --oneline "$BASE"..HEAD`, `git diff "$BASE"`, `git diff --cached "$BASE"`, `git ls-files --others --exclude-standard`

Notes:

* `git log --oneline "$BASE"..HEAD` returned no mid-session commits.
* No binary or generated-private files were present in the review inventory.
* All untracked text files in the initial review surface were read.

## Findings by Severity

### Critical

* No findings.

### High

* No findings.

### Medium

* `src/components/hermes/ministry/ministry-config.ts:319` - The generated Ministry config path previously tied YAML preview generation to the strict direct-save request. That meant known seated rows with quote or whitespace model identifiers could pass the lower-level YAML roundtrip test but still leave the actual UI without a copyable YAML preview, missing the session requirement for safe copy fallback. | Fix: split preview-safe YAML generation from endpoint-valid direct save generation, kept direct save blocked when validation fails, added copy prompt text for review-only YAML, blocked path-like preview strings, and changed the YAML preview header to show the preset name when YAML exists. Added regression assertions in `src/components/hermes/ministry/__tests__/ministry-config.test.ts:214`. | Status: FIXED

### Low

* No findings.

## Assumptions and Deliberate Non-Fixes

* Direct admin saves remain constrained by the existing Hermes MoA endpoint parser. Quote/whitespace model identifiers are now supported for copy-only YAML preview when the seated row data is known and preview-safe; they are not sent through `admin.moa.savePreset` unless the strict validation result is clean.
* `.spec_system/state.json` session activation and planned-history changes were treated as session workflow state and preserved.

## Behavior Changes

* Copy-only YAML remains available for known preview-safe model IDs containing quote or whitespace characters, while direct save remains disabled until the strict Hermes MoA save contract is satisfied.
* The YAML preview label now shows the preset name whenever YAML exists, even if the direct-save request is intentionally blocked.

## Verification

* Tests: `bunx vitest run src/components/hermes/ministry/__tests__/ministry-config.test.ts src/components/hermes/ministry/__tests__/ministry-analytics.test.ts src/components/hermes/ministry/__tests__/ministry-builder.test.tsx src/hooks/__tests__/use-hermes-admin.test.tsx src/components/hermes/chat/__tests__/hermes-chat-tab.test.tsx` - PASS - 106 tests across 5 files passed.
* Browser smoke: `bunx playwright test tests/e2e/hermes-agent.spec.ts` - PASS - 10 Chromium tests passed.
* Linter: `bun run lint` - PASS - ESLint completed with exit code 0.
* Formatter: `bunx prettier --check [session and touched implementation/test files]` - PASS - all matched files use Prettier style.
* Type checker: `bun run typecheck` - PASS - `tsc --noEmit` completed with exit code 0.
* Whitespace: `git diff --check` - PASS - no tracked whitespace errors.
* ASCII/LF: `perl -ne 'exit 1 if /\r|[^\x00-\x7F]/' [session and touched implementation/test files]` - PASS.
* Final diff re-read: PASS - no remaining review issues found.

## Summary

1. Reviewed 18 initial implementation/session files plus this creview report artifact, covering all tracked and untracked changes since base commit `3af25ba69902c9208e493d415bb12d7d41f06b33`.
2. Findings: 0 Critical, 0 High, 1 Medium, 0 Low; the Medium YAML fallback finding was fixed with helper and test updates.
3. Direct-save strictness was deliberately preserved; copy-only YAML was widened only for known preview-safe seated rows.
4. Verification passed for focused Vitest coverage, Hermes Playwright smoke, lint, formatting, typecheck, whitespace, and ASCII/LF scans.


---

# 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/phase40-session15-ministry-config-analytics-and-save-ux/code-review.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.
