> 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-session06-moa-save-endpoint/tasks.md).

# Task Checklist

**Session ID**: `phase40-session06-moa-save-endpoint` **Total Tasks**: 20 **Estimated Duration**: 3-4 hours **Created**: 2026-07-03

***

Legend: `[x]` completed; `[ ]` pending; `[P]` parallelizable; `[SNNMM]` session ref; `TNNN` task ID.

***

## Setup (3 tasks)

* [x] T001 \[S4006] Verify Session 03-05 handoff artifacts, current worktree status, and MoA save owners (`.spec_system/specs/phase40-session05-command-endpoint/IMPLEMENTATION_SUMMARY.md`)
* [x] T002 \[S4006] Run focused baseline bridge, parser, and hook tests before edits (`bunx vitest run scripts/lib/__tests__/hermes-admin-bridge.test.ts src/lib/__tests__/hermes-admin-types.test.ts src/hooks/__tests__/use-hermes-admin.test.tsx`)
* [x] T003 \[S4006] Inspect current Hermes admin bridge endpoint registration, config/YAML helpers, parser owner, hook owner, and admin hook mock fixtures (`scripts/lib/hermes-admin-bridge.ts`)

***

## Foundation (6 tasks)

* [x] T004 \[S4006] Add MoA save request/response contracts, `setup_required` error-code support, and response parser (`src/lib/hermes-admin-types.ts`)
* [x] T005 \[S4006] Add MoA save parser tests for valid responses and malformed response rejection (`src/lib/__tests__/hermes-admin-types.test.ts`)
* [x] T006 \[S4006] Add bridge-side MoA preset payload validation for preset names, aggregator model, one to three reference models, bounded temperature, bounded `max_tokens`, and exact allowed keys (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T007 \[S4006] Add config path, bounded read, YAML object parsing, safe backup-label, temp-write, and atomic rename helpers with controlled failure-path handling (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T008 \[S4006] Add bridge tests proving invalid MoA payloads, unknown fields, oversized values, and bad JSON are rejected before file writes (`scripts/lib/__tests__/hermes-admin-bridge.test.ts`)
* [x] T009 \[S4006] Add bridge tests for missing config, malformed YAML, non-object YAML root, and no raw private path leakage (`scripts/lib/__tests__/hermes-admin-bridge.test.ts`)

***

## Implementation (5 tasks)

* [x] T010 \[S4006] Register POST `/__hermes_moa_save` in the Hermes admin endpoint list with loopback, Host-header, token, admin, method, and body-size gates enforced at the bridge boundary (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T011 \[S4006] Implement MoA config merge that writes only `moa.presets[name]` and `moa.default_preset` while preserving unrelated config keys and existing presets (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T012 \[S4006] Return browser-safe MoA save success and controlled setup/validation/write failure responses with preset and backup labels only (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T013 \[S4006] Add `useHermesAdmin().moa.savePreset` mutation state and action with duplicate-trigger prevention while in-flight (`src/hooks/use-hermes-admin.ts`)
* [x] T014 \[S4006] Update existing admin hook test fixtures for the new `moa` action group without adding visible Ministry UI (`src/components/hermes/__tests__/hermes-sections.test.tsx`)

***

## Testing (6 tasks)

* [x] T015 \[S4006] Add MoA save success tests for backup creation, safe backup label, default preset update, unrelated config preservation, and existing preset preservation (`scripts/lib/__tests__/hermes-admin-bridge.test.ts`)
* [x] T016 \[S4006] Add MoA save failure tests for backup/write failures, no partial-success responses, and sanitized errors (`scripts/lib/__tests__/hermes-admin-bridge.test.ts`)
* [x] T017 \[S4006] Add hook tests for MoA save request serialization, disabled/token/offline states, parser failures, and duplicate in-flight prevention (`src/hooks/__tests__/use-hermes-admin.test.tsx`)
* [x] T018 \[S4006] Run the focused MoA save suite (`bunx vitest run scripts/lib/__tests__/hermes-admin-bridge.test.ts src/lib/__tests__/hermes-admin-types.test.ts src/hooks/__tests__/use-hermes-admin.test.tsx`)
* [x] T019 \[S4006] Run script and app typechecks for bridge, parser, hook, and fixture shape changes (`bun run typecheck:scripts && bun run typecheck`)
* [x] T020 \[S4006] Validate ASCII, LF, and diff whitespace requirements for session changes (`git diff --check`)

***

## Completion Checklist

* [x] All tasks marked `[x]`
* [x] All tests and checks passing
* [x] All files ASCII-encoded with LF line endings
* [x] implementation-notes.md updated
* [x] Ready for `creview` (next step in the implement -> creview -> validate sequence)

***

## Next Steps

Run the `implement` workflow step.


---

# 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-session06-moa-save-endpoint/tasks.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.
