> 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/phase25-session01-mission-write-contract-preview-commit/tasks.md).

# Task Checklist

**Session ID**: `phase25-session01-mission-write-contract-preview-commit` **Total Tasks**: 22 **Estimated Duration**: 3-4 hours **Created**: 2026-06-08

***

## Legend

* `[x]` = Completed
* `[ ]` = Pending
* `[P]` = Parallelizable (can run with other \[P] tasks)
* `[SNNMM]` = Session reference (NN=phase number, MM=session number)
* `TNNN` = Task ID

***

## Progress Summary

| Category       | Total  | Done   | Remaining |
| -------------- | ------ | ------ | --------- |
| Setup          | 3      | 3      | 0         |
| Foundation     | 5      | 5      | 0         |
| Implementation | 9      | 9      | 0         |
| Testing        | 5      | 5      | 0         |
| **Total**      | **22** | **22** | **0**     |

***

## Setup (3 tasks)

Initial verification and session note setup.

* [x] T001 \[S2501] Verify current mission optimize, create, tick, clear, parser, hook, and component call paths (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T002 \[S2501] Record the optimize silent-success regression, selected preview/commit contract, and implementation decisions (`.spec_system/specs/phase25-session01-mission-write-contract-preview-commit/implementation-notes.md`)
* [x] T003 \[S2501] Create the session security and compliance note shell for the new commit write endpoint (`.spec_system/specs/phase25-session01-mission-write-contract-preview-commit/security-compliance.md`)

***

## Foundation (5 tasks)

Core contracts and failing coverage before behavior changes.

* [x] T004 \[S2501] Add bridge regression coverage proving optimize returns success today without a persisted active mission (`scripts/lib/__tests__/hermes-admin-bridge.test.ts`)
* [x] T005 \[S2501] Define optimize preview, commit request, and commit response TypeScript contracts with types matching declared contract and exhaustive discriminator handling (`src/lib/hermes-admin-types.ts`)
* [x] T006 \[S2501] Add admin parser tests for preview, commit, null mission rejection where applicable, and malformed discriminator cases (`src/lib/__tests__/hermes-admin-types.test.ts`)
* [x] T007 \[S2501] Extend the admin bridge mission endpoint registry expectation for `POST /__hermes_missions/commit` (`scripts/lib/__tests__/hermes-admin-bridge.test.ts`)
* [x] T008 \[S2501] Extend hook test setup for a distinct optimize preview response and commit persisted response (`src/hooks/__tests__/use-hermes-admin.test.tsx`)

***

## Implementation (9 tasks)

Main preview-to-commit bridge, type, hook, and UI call-site behavior.

* [x] T009 \[S2501] Change `handleMissionOptimizeRequest` to return `{ ok: true, preview: true, mission }` without reading or writing `missions.json` (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T010 \[S2501] Add `handleMissionCommitRequest` with full preflight, schema-validated input, ID confinement, atomic store write, active pointer update, and explicit error mapping (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T011 \[S2501] Reuse `createMissionDocument`, `readMissionStore`, and `writeMissionStore` in commit to avoid a parallel mission validation path (`scripts/lib/hermes-admin-bridge.ts`)
* [x] T012 \[S2501] Export parse helpers for optimize preview and commit/write responses with strict `preview: true` validation (`src/lib/hermes-admin-types.ts`)
* [x] T013 \[S2501] Add `commitMission` and commit mutation state to `HermesMissionActions` with duplicate-trigger prevention while in-flight (`src/hooks/use-hermes-admin.ts`)
* [x] T014 \[S2501] Remove optimize success mission-query invalidation and keep invalidation only for persisted write paths (`src/hooks/use-hermes-admin.ts`)
* [x] T015 \[S2501] Update Mission Control optimize feedback and handler behavior so preview generation does not claim active persistence or force mission refresh (`src/components/hermes/hermes-mission-control.tsx`)
* [x] T016 \[S2501] Update bridge mission tests for optimize no-write, commit persistence, active pointer replacement, and rejected malformed candidates (`scripts/lib/__tests__/hermes-admin-bridge.test.ts`)
* [x] T017 \[S2501] Update implementation notes with changed files, contract decisions, and deferred preview UI work (`.spec_system/specs/phase25-session01-mission-write-contract-preview-commit/implementation-notes.md`)

***

## Testing (5 tasks)

Verification and quality assurance.

* [x] T018 \[S2501] Add hook tests proving optimize returns preview without invalidation and commit persists with invalidation (`src/hooks/__tests__/use-hermes-admin.test.tsx`)
* [x] T019 \[S2501] Add bridge tests for commit rejection when admin mode, token, loopback, method, body size, or payload validation fails (`scripts/lib/__tests__/hermes-admin-bridge.test.ts`)
* [x] T020 \[S2501] Add component coverage for optimize preview feedback without active-state claim if Mission Control copy changed (`src/components/hermes/__tests__/hermes-mission-control.test.tsx`)
* [x] T021 \[S2501] Run focused mission contract tests and record command results (`package.json`)
* [x] T022 \[S2501] Validate ASCII encoding, LF endings, and security note completeness for all session-touched files (`.spec_system/specs/phase25-session01-mission-write-contract-preview-commit/security-compliance.md`)

***

## Completion Checklist

Before marking session complete:

* [x] All tasks marked `[x]`
* [x] All tests passing
* [x] All files ASCII-encoded
* [x] implementation-notes.md updated
* [x] security-compliance.md updated
* [x] Ready for the validate workflow step

***

## Next Steps

Run the validate workflow step to verify session completeness.


---

# 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/phase25-session01-mission-write-contract-preview-commit/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.
