> 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-session14-ministry-builder-and-pantheon/implementation-notes.md).

# Implementation Notes

**Session ID**: `phase40-session14-ministry-builder-and-pantheon` **Started**: 2026-07-03 08:59 **Last Updated**: 2026-07-03 09:30

***

## Session Progress

| Metric              | Value   |
| ------------------- | ------- |
| Tasks Completed     | 23 / 23 |
| Estimated Remaining | 0 hours |
| Blockers            | 0       |

***

## Task Log

### 2026-07-03 - Session Start

**Environment verified**:

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

***

### Task T001 - Verify existing Pantheon, model-intelligence, provider asset, and demo fixture contracts before edits

**Started**: 2026-07-03 08:59 **Completed**: 2026-07-03 08:59 **Duration**: 1 minute

**Notes**:

* Confirmed `HermesPantheon` currently owns persona CRUD, template seeding, default model selection, and GitHub mirror sync state.
* Confirmed `HermesReadOnlyPage` already resolves `modelIntelligence` through `useHermes` or demo fixtures, so Pantheon integration should receive the view by prop instead of fetching.
* Confirmed provider assets expose safe logo lookup, uncovered provider fallbacks, and `HERMES_MINISTRY_HERO_ASSET`.
* Confirmed demo data includes four Ministry model-intelligence rows plus benchmark, cost, and speed rankings.

**Files Changed**:

* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - initialized implementation evidence log.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T001 complete.

**Verification**:

* Command/check: `if [ -d ".spec_system/scripts" ]; then bash .spec_system/scripts/analyze-project.sh --json; else bash scripts/analyze-project.sh --json; fi`
  * Result: PASS - active session resolved.
  * Evidence: `current_session` was `phase40-session14-ministry-builder-and-pantheon`.
* Command/check: `if [ -d ".spec_system/scripts" ]; then bash .spec_system/scripts/check-prereqs.sh --json --env; else bash scripts/check-prereqs.sh --json --env; fi`
  * Result: PASS - environment prerequisites available.
  * Evidence: overall status was `pass` with spec system, `jq`, and `git` available.
* Command/check: inspected `src/components/hermes/hermes-pantheon.tsx`, `src/components/hermes/hermes-read-only-page.tsx`, `src/lib/hermes-model-intelligence.ts`, `src/lib/hermes-provider-assets.ts`, `src/lib/hermes-demo-data.ts`, `src/components/hermes/__tests__/hermes-sections.test.tsx`, and `tests/e2e/hermes-agent.spec.ts`.
  * Result: PASS - existing contracts match the session approach.
  * Evidence: Pantheon persona workflows are local to `HermesPantheon`, read-only page owns model-intelligence view creation, and provider assets expose safe logo/hero helpers.
* UI product-surface check: N/A - inspection-only task.
* UI craft check: N/A - inspection-only task.

**BQC Fixes**:

* None.

***

### Task T003 - Create shared Ministry seat, draft, action, and component prop types from Hermes model intelligence contracts

**Started**: 2026-07-03 09:02 **Completed**: 2026-07-03 09:03 **Duration**: 1 minute

**Notes**:

* Added shared Ministry draft, seat, assignment-result, component-prop, and model-intelligence view types derived from `HermesModelIntelligenceBody` and `HermesModelIntelligenceRow`.
* Fixed the initial assigned-seat type to use a union intersection so TypeScript can represent core and expert seat rows correctly.

**Files Changed**:

* `src/components/hermes/ministry/ministry-types.ts` - added shared Ministry type contracts.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T003 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - TypeScript contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0 after correcting the union extension issue.
* UI product-surface check: N/A - type-only task.
* UI craft check: N/A - type-only task.

**BQC Fixes**:

* Contract alignment: corrected `MinistryAssignedSeat` from an invalid interface extension to a type intersection (`src/components/hermes/ministry/ministry-types.ts`).

***

### Task T004 - Create pure lineup helpers for recommended reset, core assignment, expert assignment, duplicate prevention, max expert enforcement, removal, and stable ordering

**Started**: 2026-07-03 09:03 **Completed**: 2026-07-03 09:05 **Duration**: 2 minutes

**Notes**:

* Added pure helpers for empty and normalized drafts, seat materialization, assigned-seat row resolution, assigned model IDs, expert count checks, duplicate detection, assignment, removal, ranking order, and recommended reset.
* Recommended reset now uses the aggregator row for core when present, then fills expert seats from benchmark, cost, and speed rankings with stable fallback ordering.

**Files Changed**:

* `src/components/hermes/ministry/ministry-lineup.ts` - added pure Ministry lineup rules and reset helpers.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T004 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - lineup helper contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - pure helper task.
* UI craft check: N/A - pure helper task.

**BQC Fixes**:

* Duplicate action prevention: assignment now routes through a single duplicate check that rejects rows already assigned outside the target seat (`src/components/hermes/ministry/ministry-lineup.ts`).
* State freshness on re-entry: reset helper derives a fresh normalized draft from the current model-intelligence body (`src/components/hermes/ministry/ministry-lineup.ts`).

***

### Task T005 - Create safe provider logo renderer using getHermesProviderAsset with accessible label fallback for uncovered providers

**Started**: 2026-07-03 09:05 **Completed**: 2026-07-03 09:06 **Duration**: 1 minute

**Notes**:

* Added a provider logo component that resolves approved assets through `getHermesProviderAsset`.
* Added accessible fallback initials for uncovered providers, including stable screen-reader labels and no raw path exposure.

**Files Changed**:

* `src/components/hermes/ministry/provider-logo.tsx` - added safe logo renderer and fallback state.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T005 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - provider logo component compiles against asset helper contracts.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - isolated renderer not yet mounted in a product route.
* UI craft check: N/A - isolated renderer not yet mounted in a product route.

**BQC Fixes**:

* Accessibility and platform compliance: uncovered provider fallback renders an explicit provider `aria-label` instead of a broken or unlabeled image (`src/components/hermes/ministry/provider-logo.tsx`).

***

### Task T006 - Create model palette component with draggable rows, click-select state, bounded metric labels, product-facing copy, accessibility labels, focus management, and input support

**Started**: 2026-07-03 09:06 **Completed**: 2026-07-03 09:08 **Duration**: 2 minutes

**Notes**:

* Added the model palette component with draggable row buttons, click-to-arm behavior, Escape cancel support, assigned/unavailable disabled states, and product-facing metrics.
* Rows use approved provider logos, stable text fallbacks, bounded benchmark/speed/pricing labels, and accessible labels for select/assigned/unavailable states.

**Files Changed**:

* `src/components/hermes/ministry/model-palette.tsx` - added model palette UI and input handling.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T006 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - palette props, drag handlers, and row contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - isolated component not yet mounted in Pantheon route.
* UI craft check: N/A - isolated component not yet mounted in Pantheon route.

**BQC Fixes**:

* Duplicate action prevention: assigned rows are disabled in the palette so the click and drag entry points cannot arm a duplicate row (`src/components/hermes/ministry/model-palette.tsx`).
* Accessibility and platform compliance: row buttons expose state-specific `aria-label`, `aria-pressed`, Escape cancel, and native button keyboard behavior (`src/components/hermes/ministry/model-palette.tsx`).

***

### Task T007 - Create council seats component for core and bounded expert targets with click assignment, drop assignment, remove controls, empty states, and accessibility support

**Started**: 2026-07-03 09:08 **Completed**: 2026-07-03 09:09 **Duration**: 1 minute

**Notes**:

* Added council seat targets for one core seat and bounded expert seats with click-to-seat, drop-to-seat, Delete/Backspace removal, Escape cancel, and explicit remove controls.
* Seat content uses product-facing role copy, provider logo rendering, stable empty states, and accessible target/remove labels.

**Files Changed**:

* `src/components/hermes/ministry/council-seats.tsx` - added council seat targets and interaction handlers.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T007 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - seat component callback and event contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - isolated component not yet mounted in Pantheon route.
* UI craft check: N/A - isolated component not yet mounted in Pantheon route.

**BQC Fixes**:

* Accessibility and platform compliance: seat targets expose accessible assignment labels, keyboard removal, Escape cancel, and separate remove controls (`src/components/hermes/ministry/council-seats.tsx`).
* Contract alignment: click and drop paths both route through the same `onAssignSeat` callback contract (`src/components/hermes/ministry/council-seats.tsx`).

***

### Task T008 - Create analytics shell and save/copy shell that summarize current lineup state without final MoA config or direct save claims

**Started**: 2026-07-03 09:09 **Completed**: 2026-07-03 09:12 **Duration**: 3 minutes

**Notes**:

* Added a draft analytics shell that summarizes selected model rows with seat coverage, average benchmark, speed, and blended snapshot pricing.
* Added a save/copy preview shell that lists the current core and expert lineup while keeping config export and direct save controls disabled for the next Ministry session.

**Files Changed**:

* `src/components/hermes/ministry/ministry-analytics-shell.tsx` - added draft analytics summary.
* `src/components/hermes/ministry/ministry-save-copy-shell.tsx` - added save/copy preview shell with disabled deferred controls.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T008 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - analytics and save/copy shell contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0 after nullable expert-seat lookup was corrected.
* UI product-surface check: N/A - isolated shells not yet mounted in Pantheon route.
* UI craft check: N/A - isolated shells not yet mounted in Pantheon route.

**BQC Fixes**:

* Product surface discipline: visible shell copy describes draft preview behavior and explicitly avoids final config or direct-save claims (`src/components/hermes/ministry/ministry-save-copy-shell.tsx`).
* Contract alignment: expert preview lookup now accepts nullable open seats instead of treating every expert slot as a model ID (`src/components/hermes/ministry/ministry-save-copy-shell.tsx`).

***

### Task T009 - Create Ministry builder composer with hero asset, query states, armed/drag state cleanup on re-entry, reset behavior, and responsive layout constraints

**Started**: 2026-07-03 09:12 **Completed**: 2026-07-03 09:13 **Duration**: 1 minute

**Notes**:

* Added the full Ministry builder section with the approved hero asset, model-intelligence query states, recommended reset, palette/seats/analytics/save-shell composition, and responsive grid constraints.
* Added re-entry cleanup for new model-intelligence bodies and Escape cleanup for an armed model selection.
* Added Ministry barrel exports for components, pure helpers, and shared types.

**Files Changed**:

* `src/components/hermes/ministry/ministry-builder.tsx` - added composed Ministry builder section and state orchestration.
* `src/components/hermes/ministry/index.ts` - added Ministry exports.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T009 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - builder composition and exported contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - builder not yet mounted in Pantheon route.
* UI craft check: N/A - builder not yet mounted in Pantheon route.

**BQC Fixes**:

* State freshness on re-entry: builder resets draft, armed model, dragged model, and status when the model-intelligence body changes (`src/components/hermes/ministry/ministry-builder.tsx`).
* Resource cleanup: Escape key listener is registered only while a model is armed and removed on cleanup (`src/components/hermes/ministry/ministry-builder.tsx`).

***

### Task T010 - Pass live/demo model-intelligence view into Pantheon without changing existing Hermes bridge fetch ownership

**Started**: 2026-07-03 09:13 **Completed**: 2026-07-03 09:14 **Duration**: 1 minute

**Notes**:

* Added `modelIntelligence` to the `HermesPantheon` prop contract.
* Passed the already-resolved live/demo `modelIntelligence` view from `HermesReadOnlyPage` into Pantheon.
* Updated Pantheon test props to include the Ministry model-intelligence view without adding new fetch ownership.

**Files Changed**:

* `src/components/hermes/hermes-pantheon.tsx` - added Pantheon prop contract for model intelligence.
* `src/components/hermes/hermes-read-only-page.tsx` - passed the existing view into Pantheon.
* `src/components/hermes/__tests__/hermes-sections.test.tsx` - updated Pantheon fixture props.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T010 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - all Pantheon call sites include the new view prop.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - data handoff only; builder mount follows in T011.
* UI craft check: N/A - data handoff only.

**BQC Fixes**:

* Contract alignment: Pantheon callers and tests now match the new required `modelIntelligence` prop (`src/components/hermes/hermes-pantheon.tsx`, `src/components/hermes/hermes-read-only-page.tsx`, `src/components/hermes/__tests__/hermes-sections.test.tsx`).

***

### Task T011 - Integrate Ministry builder as the first full-width Pantheon section without decorative nested cards or persona grid regressions

**Started**: 2026-07-03 09:14 **Completed**: 2026-07-03 09:16 **Duration**: 2 minutes

**Notes**:

* Mounted `MinistryBuilder` before the existing Pantheon persona catalog panel as a sibling section.
* Kept the persona catalog, templates, draft editor, default model select, and sync panel in their existing owner component.

**Files Changed**:

* `src/components/hermes/hermes-pantheon.tsx` - rendered Ministry builder before existing persona catalog and sync content.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T011 complete.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - Pantheon JSX and Ministry import compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* Command/check: `bunx vitest run src/components/hermes/__tests__/hermes-sections.test.tsx`
  * Result: PASS - existing Hermes section and persona tests still pass.
  * Evidence: 1 test file passed, 89 tests passed.
* UI product-surface check: N/A - route-level browser inspection follows after interaction tests and E2E smoke are added.
* UI craft check: N/A - route-level browser inspection follows after interaction tests and E2E smoke are added.

**BQC Fixes**:

* Product surface discipline: Ministry is a sibling product section before Pantheon personas, avoiding a decorative card nested inside the existing persona catalog panel (`src/components/hermes/hermes-pantheon.tsx`).

***

### Task T012 - Wire click model then click seat assignment through shared lineup helpers with duplicate-trigger prevention while assignment state changes

**Started**: 2026-07-03 09:16 **Completed**: 2026-07-03 09:17 **Duration**: 1 minute

**Notes**:

* Verified the palette click path arms a model and the seat click path assigns through `assignMinistrySeat`.
* Assignment status is updated from the builder after helper results, and duplicate assignments are rejected by the shared helper before state changes.

**Files Changed**:

* `src/components/hermes/ministry/model-palette.tsx` - click-to-arm row behavior and assigned-row disable state.
* `src/components/hermes/ministry/council-seats.tsx` - click-to-seat target behavior.
* `src/components/hermes/ministry/ministry-builder.tsx` - centralized assignment state updates and status messages.
* `src/components/hermes/ministry/ministry-lineup.ts` - shared duplicate-preventing assignment helper.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T012 complete.

**Verification**:

* Command/check: `rg -n "onArmModel|onAssignSeat|assignMinistrySeat|setAssignmentStatus|armedModelId" src/components/hermes/ministry/ministry-builder.tsx src/components/hermes/ministry/council-seats.tsx src/components/hermes/ministry/model-palette.tsx src/components/hermes/ministry/ministry-lineup.ts`
  * Result: PASS - click assignment path is present from palette to builder to seats to helper.
  * Evidence: matches found for palette arm, seat click assignment, builder assignment status, and `assignMinistrySeat`.
* Command/check: `bun run typecheck`
  * Result: PASS - click assignment contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - browser route inspection follows after E2E smoke.
* UI craft check: N/A - browser route inspection follows after E2E smoke.

**BQC Fixes**:

* Duplicate action prevention: click assignment uses the same helper-level duplicate rejection as all other assignment paths (`src/components/hermes/ministry/ministry-lineup.ts`).

***

### Task T013 - Wire drag-to-seat assignment through shared lineup helpers with duplicate-trigger prevention while assignment state changes

**Started**: 2026-07-03 09:17 **Completed**: 2026-07-03 09:17 **Duration**: 1 minute

**Notes**:

* Verified palette rows write the model id to `dataTransfer` and set builder drag state on drag start.
* Verified council seats accept drops and route the dropped model id through the same `onAssignSeat` callback used by click assignment.

**Files Changed**:

* `src/components/hermes/ministry/model-palette.tsx` - drag source behavior and drag-state callback.
* `src/components/hermes/ministry/council-seats.tsx` - drop target behavior.
* `src/components/hermes/ministry/ministry-builder.tsx` - drag state and shared assignment callback.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T013 complete.

**Verification**:

* Command/check: `rg -n "onDragStart|onDrop|dataTransfer|draggedModelId|onDragModel" src/components/hermes/ministry/ministry-builder.tsx src/components/hermes/ministry/council-seats.tsx src/components/hermes/ministry/model-palette.tsx`
  * Result: PASS - drag source, drag state, and drop target paths are present.
  * Evidence: matches found for `dataTransfer.setData`, `draggedModelId`, seat `onDrop`, and drag callbacks.
* Command/check: `bun run typecheck`
  * Result: PASS - drag/drop contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - browser route inspection follows after E2E smoke.
* UI craft check: N/A - browser route inspection follows after E2E smoke.

**BQC Fixes**:

* Duplicate action prevention: drag/drop assignment resolves through the same duplicate-checking helper as click assignment (`src/components/hermes/ministry/ministry-builder.tsx`, `src/components/hermes/ministry/ministry-lineup.ts`).

***

### Task T014 - Implement Escape cancel, remove seat, and recommended reset behavior with state reset or revalidation on re-entry

**Started**: 2026-07-03 09:17 **Completed**: 2026-07-03 09:18 **Duration**: 1 minute

**Notes**:

* Verified Escape cancel exists on palette rows, seat targets, and the builder-level armed-selection listener.
* Verified remove controls route through `removeMinistrySeat` and clear armed selection.
* Verified recommended reset uses `createRecommendedMinistryDraft`, and builder re-entry resets draft, armed state, drag state, and status when model-intelligence data changes.

**Files Changed**:

* `src/components/hermes/ministry/ministry-builder.tsx` - Escape listener, recommended reset, remove handling, and body-change reset.
* `src/components/hermes/ministry/council-seats.tsx` - Escape and keyboard/remove controls.
* `src/components/hermes/ministry/model-palette.tsx` - Escape cancel on armed rows.
* `src/components/hermes/ministry/ministry-lineup.ts` - remove and recommended reset helpers.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T014 complete.

**Verification**:

* Command/check: `rg -n "Escape|removeMinistrySeat|Reset recommended|Recommended lineup restored|createRecommendedMinistryDraft|resetMinistryDraft" src/components/hermes/ministry/ministry-builder.tsx src/components/hermes/ministry/council-seats.tsx src/components/hermes/ministry/model-palette.tsx src/components/hermes/ministry/ministry-lineup.ts`
  * Result: PASS - cleanup, removal, reset, and re-entry reset paths are present.
  * Evidence: matches found for Escape handlers, remove helper, reset helper, and reset UI copy.
* Command/check: `bun run typecheck`
  * Result: PASS - cleanup/reset contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - browser route inspection follows after E2E smoke.
* UI craft check: N/A - browser route inspection follows after E2E smoke.

**BQC Fixes**:

* State freshness on re-entry: model-intelligence body changes reset draft and transient interaction state (`src/components/hermes/ministry/ministry-builder.tsx`).
* Resource cleanup: builder-level Escape listener unregisters when no model is armed or the component unmounts (`src/components/hermes/ministry/ministry-builder.tsx`).

***

### Task T015 - Enforce max expert count and no duplicate core/expert seats across pointer and keyboard paths with clear disabled states

**Started**: 2026-07-03 09:18 **Completed**: 2026-07-03 09:19 **Duration**: 1 minute

**Notes**:

* Verified duplicate assignment is rejected in `assignMinistrySeat` when a model is already assigned outside the target seat.
* Verified expert capacity is bounded by `MINISTRY_EXPERT_SEAT_COUNT` and exposed through builder status and palette availability.
* Verified palette rows are disabled when already assigned or when no open seat is available.

**Files Changed**:

* `src/components/hermes/ministry/ministry-lineup.ts` - duplicate and max-expert enforcement.
* `src/components/hermes/ministry/model-palette.tsx` - assigned/unavailable disabled states.
* `src/components/hermes/ministry/ministry-builder.tsx` - expert count status and shared max-expert state.
* `src/components/hermes/ministry/ministry-types.ts` - fixed expert-seat count and assignment status types.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T015 complete.

**Verification**:

* Command/check: `rg -n "duplicate|max-experts|isMaxExpertCountReached|isAssignedOutsideSeat|MINISTRY_EXPERT_SEAT_COUNT|isMinistryModelAssigned" src/components/hermes/ministry/ministry-builder.tsx src/components/hermes/ministry/council-seats.tsx src/components/hermes/ministry/model-palette.tsx src/components/hermes/ministry/ministry-lineup.ts src/components/hermes/ministry/ministry-types.ts`
  * Result: PASS - duplicate and max-expert enforcement paths are present.
  * Evidence: matches found for assignment statuses, helper checks, fixed expert count, and palette assigned-state disable logic.
* Command/check: `bun run typecheck`
  * Result: PASS - enforcement contracts compile.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* UI product-surface check: N/A - browser route inspection follows after E2E smoke.
* UI craft check: N/A - browser route inspection follows after E2E smoke.

**BQC Fixes**:

* Duplicate action prevention: duplicate rows are rejected in the pure helper and disabled in the palette once assigned (`src/components/hermes/ministry/ministry-lineup.ts`, `src/components/hermes/ministry/model-palette.tsx`).
* Contract alignment: the UI reads the same fixed expert-seat count used by the helper rules (`src/components/hermes/ministry/ministry-types.ts`, `src/components/hermes/ministry/ministry-builder.tsx`).

***

### Task T016 - Preserve existing persona create, edit, delete, install defaults, validate, model selection, template seeding, and sync state after Ministry mounts

**Started**: 2026-07-03 09:19 **Completed**: 2026-07-03 09:20 **Duration**: 1 minute

**Notes**:

* Verified the existing Hermes section test suite still covers and passes Pantheon persona row rendering, model catalog options, template draft seeding, validate/create/update/delete/install actions, admin disabled state, sync confirmation, and bounded sync errors.
* Ministry remains mounted as a sibling section before the persona catalog, so existing persona state ownership remains in `HermesPantheon`.

**Files Changed**:

* `src/components/hermes/hermes-pantheon.tsx` - Ministry mounted as a sibling before persona workflows.
* `src/components/hermes/__tests__/hermes-sections.test.tsx` - Pantheon fixtures include model-intelligence data for the mounted builder.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T016 complete.

**Verification**:

* Command/check: `bunx vitest run src/components/hermes/__tests__/hermes-sections.test.tsx`
  * Result: PASS - existing Hermes and Pantheon behavior still passes with Ministry mounted.
  * Evidence: 1 test file passed, 89 tests passed.
* UI product-surface check: N/A - browser route inspection follows after E2E smoke.
* UI craft check: N/A - browser route inspection follows after E2E smoke.

**BQC Fixes**:

* Contract alignment: existing persona and sync tests continue passing with the new required Ministry data prop and mounted section (`src/components/hermes/__tests__/hermes-sections.test.tsx`).

***

### Task T017 - Test pure lineup helpers for recommended lineup, assignment, duplicate prevention, max expert enforcement, removal, reset, empty input, and stable ordering

**Started**: 2026-07-03 09:20 **Completed**: 2026-07-03 09:21 **Duration**: 1 minute

**Notes**:

* Added pure helper tests for recommended lineup derivation, core and expert assignment, duplicate rejection, missing model rejection, bounded expert seats, assigned row resolution, removal, reset, empty body handling, and stable ranking fallback.

**Files Changed**:

* `src/components/hermes/ministry/__tests__/ministry-lineup.test.ts` - added focused lineup helper tests.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T017 complete.

**Verification**:

* Command/check: `bunx vitest run src/components/hermes/ministry/__tests__/ministry-lineup.test.ts`
  * Result: PASS - pure helper behavior is covered.
  * Evidence: 1 test file passed, 6 tests passed.
* UI product-surface check: N/A - pure helper tests.
* UI craft check: N/A - pure helper tests.

**BQC Fixes**:

* Contract alignment: tests now lock helper behavior that the click, keyboard, and drag/drop component paths share (`src/components/hermes/ministry/__tests__/ministry-lineup.test.ts`).

***

### Task T018 - Test Ministry builder rendering, hero alt text, provider logo fallback, loading/empty/error/demo states, and product-facing copy boundaries

**Started**: 2026-07-03 09:21 **Completed**: 2026-07-03 09:22 **Duration**: 1 minute

**Notes**:

* Expanded builder tests to render the hero, recommended lineup, provider logos, uncovered OpenRouter fallback, loading/error/offline/token-failure states, empty state, demo state, and product-copy boundaries.
* Adjusted assertions for repeated model/logo appearances across palette, seats, and preview shells.

**Files Changed**:

* `src/components/hermes/ministry/__tests__/ministry-builder.test.tsx` - added builder render and query-state coverage.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T018 complete.

**Verification**:

* Command/check: `bunx vitest run src/components/hermes/ministry/__tests__/ministry-builder.test.tsx`
  * Result: PASS - builder render and query-state coverage passes.
  * Evidence: 1 test file passed, 8 tests passed.
* UI product-surface check: PASS - component tests verify hero alt text, demo state, product copy, and absence of path/source/debug copy in normal render.
* UI craft check: N/A - browser viewport inspection follows after E2E smoke.

**BQC Fixes**:

* Product surface discipline: tests assert normal builder render does not expose path-like asset metadata or debug/source labels (`src/components/hermes/ministry/__tests__/ministry-builder.test.tsx`).

***

### Task T019 - Test click assignment, Escape cancel, remove seat, reset, duplicate prevention, and max expert disabled state

**Started**: 2026-07-03 09:22 **Completed**: 2026-07-03 09:23 **Duration**: 1 minute

**Notes**:

* Added interaction tests for max-filled disabled rows, removing an expert seat, clicking an unassigned model, Escape cancel, click-to-seat assignment, removing core, recommended reset, and assigned-row duplicate disabled state.

**Files Changed**:

* `src/components/hermes/ministry/__tests__/ministry-builder.test.tsx` - added click, Escape, remove, reset, duplicate, and max-disabled interaction tests.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T019 complete.

**Verification**:

* Command/check: `bunx vitest run src/components/hermes/ministry/__tests__/ministry-builder.test.tsx`
  * Result: PASS - builder rendering and click interaction coverage passes.
  * Evidence: 1 test file passed, 10 tests passed.
* UI product-surface check: PASS - tests use accessible product labels for selection, seating, disabled rows, and reset states.
* UI craft check: N/A - browser viewport inspection follows after E2E smoke.

**BQC Fixes**:

* Duplicate action prevention: tests verify assigned rows and rows unavailable because all seats are filled are disabled before duplicate actions can be triggered (`src/components/hermes/ministry/__tests__/ministry-builder.test.tsx`).

***

### Task T020 - Test drag/drop assignment event paths and shared duplicate/max expert rules

**Started**: 2026-07-03 09:23 **Completed**: 2026-07-03 09:24 **Duration**: 1 minute

**Notes**:

* Added drag/drop coverage with a `dataTransfer` mock.
* Verified duplicate rejection on drop uses the shared assignment helper and that a valid drag/drop seats the unassigned model before disabling it as already seated.

**Files Changed**:

* `src/components/hermes/ministry/__tests__/ministry-builder.test.tsx` - added drag/drop assignment and duplicate rejection test.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T020 complete.

**Verification**:

* Command/check: `bunx vitest run src/components/hermes/ministry/__tests__/ministry-builder.test.tsx`
  * Result: PASS - builder rendering, click, keyboard, and drag/drop coverage passes.
  * Evidence: 1 test file passed, 11 tests passed.
* UI product-surface check: PASS - drag/drop test uses the same accessible seat and row labels exposed to users.
* UI craft check: N/A - browser viewport inspection follows after E2E smoke.

**BQC Fixes**:

* Duplicate action prevention: test verifies a duplicate dropped model returns the helper-level duplicate message instead of changing the draft (`src/components/hermes/ministry/__tests__/ministry-builder.test.tsx`).

***

### Task T021 - Test Pantheon integration and existing persona workflow preservation after Ministry renders

**Started**: 2026-07-03 09:24 **Completed**: 2026-07-03 09:25 **Duration**: 1 minute

**Notes**:

* Added a direct Pantheon integration regression that verifies the Ministry builder appears before the persona catalog.
* The same test drives persona template validation/create/install and Pantheon sync confirmation after Ministry has rendered.

**Files Changed**:

* `src/components/hermes/__tests__/hermes-sections.test.tsx` - added Ministry-before-Pantheon integration regression and persona action preservation checks.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T021 complete.

**Verification**:

* Command/check: `bunx vitest run src/components/hermes/__tests__/hermes-sections.test.tsx`
  * Result: PASS - Hermes section and Pantheon integration tests pass.
  * Evidence: 1 test file passed, 90 tests passed.
* UI product-surface check: PASS - integration test verifies Ministry product section is visible before persona workflow content.
* UI craft check: N/A - browser viewport inspection follows after E2E smoke.

**BQC Fixes**:

* Contract alignment: integration test verifies Ministry mount order and existing persona action callbacks in the same render (`src/components/hermes/__tests__/hermes-sections.test.tsx`).

***

### Task T022 - Test Hermes Pantheon route smoke for Ministry visibility and mobile layout stability

**Started**: 2026-07-03 09:25 **Completed**: 2026-07-03 09:27 **Duration**: 2 minutes

**Notes**:

* Added a mocked Hermes model-intelligence payload and bridge route for Playwright tests.
* Added a Pantheon route smoke that verifies Ministry visibility, hero visibility, model candidate visibility, and no horizontal overflow at desktop and mobile viewports.

**Files Changed**:

* `tests/e2e/fixtures/hermes-mission-control.ts` - added safe model-intelligence payload and `/__hermes_model_intelligence` mock route.
* `tests/e2e/hermes-agent.spec.ts` - added desktop/mobile Ministry Pantheon smoke test.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T022 complete.

**Verification**:

* Command/check: `bunx playwright test tests/e2e/hermes-agent.spec.ts --grep "shows Ministry builder"`
  * Result: PASS - Ministry route smoke passed in Chromium.
  * Evidence: 1 test passed; desktop and mobile assertions completed with no horizontal overflow.
* UI product-surface check: PASS - Playwright verifies the product-facing Ministry heading, hero, reset action, and model candidate are visible in Pantheon.
* UI craft check: PASS - Playwright verifies no horizontal overflow at 1280x900 and 390x840 viewports.

**BQC Fixes**:

* Failure path completeness: E2E mock now serves model intelligence so the Pantheon route exercises the intended Ministry success path instead of an endpoint-error fallback (`tests/e2e/fixtures/hermes-mission-control.ts`).

***

### Task T023 - Run focused checks and ASCII/LF validation for touched files

**Started**: 2026-07-03 09:27 **Completed**: 2026-07-03 09:30 **Duration**: 3 minutes

**Notes**:

* Formatted touched source and test files with Prettier before final checks.
* Ran the focused Ministry/Hermes/provider Vitest suite, repository typecheck, ASCII/LF validation, lint, and the Ministry Playwright smoke.

**Files Changed**:

* `src/components/hermes/hermes-pantheon.tsx` - formatted after Ministry integration.
* `src/components/hermes/ministry/ministry-lineup.ts` - formatted after helper implementation.
* `src/components/hermes/ministry/ministry-builder.tsx` - formatted after builder composition.
* `src/components/hermes/ministry/__tests__/ministry-lineup.test.ts` - formatted after test creation.
* `src/components/hermes/ministry/__tests__/ministry-builder.test.tsx` - formatted after test creation.
* `tests/e2e/hermes-agent.spec.ts` - formatted after E2E smoke update.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded final task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T023 and completion checklist complete.

**Verification**:

* Command/check: `bunx prettier --write src/components/hermes/hermes-pantheon.tsx src/components/hermes/hermes-read-only-page.tsx src/components/hermes/__tests__/hermes-sections.test.tsx src/components/hermes/ministry/ministry-types.ts src/components/hermes/ministry/ministry-lineup.ts src/components/hermes/ministry/provider-logo.tsx src/components/hermes/ministry/model-palette.tsx src/components/hermes/ministry/council-seats.tsx src/components/hermes/ministry/ministry-analytics-shell.tsx src/components/hermes/ministry/ministry-save-copy-shell.tsx src/components/hermes/ministry/ministry-builder.tsx src/components/hermes/ministry/index.ts src/components/hermes/ministry/__tests__/ministry-lineup.test.ts src/components/hermes/ministry/__tests__/ministry-builder.test.tsx tests/e2e/fixtures/hermes-mission-control.ts tests/e2e/hermes-agent.spec.ts`
  * Result: PASS - touched source/test files formatted.
  * Evidence: Prettier completed with exit code 0.
* Command/check: `bunx vitest run src/components/hermes/ministry/__tests__/ministry-lineup.test.ts src/components/hermes/ministry/__tests__/ministry-builder.test.tsx src/components/hermes/__tests__/hermes-sections.test.tsx src/lib/__tests__/hermes-model-intelligence.test.ts src/lib/__tests__/hermes-provider-assets.test.ts`
  * Result: PASS - focused test suite passed.
  * Evidence: 5 test files passed, 115 tests passed.
* Command/check: `bun run typecheck`
  * Result: PASS - repository TypeScript check passed.
  * Evidence: `tsc --noEmit` completed with exit code 0.
* Command/check: `perl -ne 'exit 1 if /[^\x00-\x7F]/' ... && perl -ne 'exit 1 if /\r/' ...`
  * Result: PASS - touched spec/source/test files are ASCII and LF.
  * Evidence: command completed with exit code 0.
* Command/check: `bun run lint`
  * Result: PASS - repository lint passed.
  * Evidence: `eslint .` completed with exit code 0.
* Command/check: `bunx playwright test tests/e2e/hermes-agent.spec.ts --grep "shows Ministry builder"`
  * Result: PASS - Ministry route smoke passed after formatting.
  * Evidence: 1 Chromium test passed; desktop and mobile no-overflow checks completed.
* UI product-surface check: PASS - component and Playwright checks verify product-facing Ministry copy, hero, row labels, and no path/debug/source metadata.
* UI craft check: PASS - Playwright verifies desktop and mobile Pantheon views avoid horizontal overflow.

**BQC Fixes**:

* None.

***

### Task T002 - Prepare Ministry test fixtures for live/demo model intelligence, uncovered provider logo fallback, empty lineup, and existing Pantheon admin actions

**Started**: 2026-07-03 09:00 **Completed**: 2026-07-03 09:01 **Duration**: 1 minute

**Notes**:

* Added reusable Ministry model-intelligence fixture builders for cloned live/demo data, empty lineups, and an uncovered OpenRouter provider row.
* Added a Pantheon-side Ministry fixture body next to the existing Pantheon admin-action fixtures so integration tests can pass the new prop once `HermesPantheon` is wired.

**Files Changed**:

* `src/components/hermes/ministry/__tests__/ministry-builder.test.tsx` - added Ministry fixture helpers and a fixture sanity test.
* `src/components/hermes/__tests__/hermes-sections.test.tsx` - prepared a cloned Ministry body near Pantheon fixtures.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/implementation-notes.md` - recorded task evidence.
* `.spec_system/specs/phase40-session14-ministry-builder-and-pantheon/tasks.md` - marked T002 complete.

**Verification**:

* Command/check: `bunx vitest run src/components/hermes/ministry/__tests__/ministry-builder.test.tsx`
  * Result: PASS - fixture scaffold is valid.
  * Evidence: 1 test file passed, 1 test passed.
* UI product-surface check: N/A - fixture-only task.
* UI craft check: N/A - fixture-only task.

**BQC Fixes**:

* None.


---

# 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-session14-ministry-builder-and-pantheon/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.
