Implements the manual coordinator workflow for multi-session agent orchestration. Agents stop after one milestone (confirmed limitation); these tools let the human coordinator check status, generate continuation prompts, and chain sessions together. New: - tools/orchestrator/ — 5 scripts + shared library (_lib.sh) - mission-init.sh: initialize mission with milestones and state files - mission-status.sh: dashboard showing milestones, tasks, sessions - session-status.sh: check if agent is running/stale/dead - continue-prompt.sh: generate paste-ready continuation prompt - session-resume.sh: crash recovery with dirty state detection - guides/ORCHESTRATOR-PROTOCOL.md: agent-facing mission lifecycle guide - templates/docs/: mission manifest, scratchpad, continuation templates - templates/repo/.mosaic/orchestrator/mission.json: state file template Modified: - bin/mosaic: add 'coord' subcommand + resume advisory on launch - AGENTS.md: conditional loading for protocol guide + rule 37 - bin/mosaic-doctor: checks for new coordinator files - session hooks: mission detection on start, cleanup on end Usage: mosaic coord init|mission|status|continue|resume Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8.8 KiB
Orchestrator Protocol — Mission Lifecycle Guide
Operational guide for agent sessions. Distilled from the full specification at
jarvis-brain/docs/protocols/ORCHESTRATOR-PROTOCOL.md(1,066 lines).Load this guide when: active mission detected, multi-milestone orchestration, mission continuation. Load
ORCHESTRATOR.mdfor per-session execution protocol (planning, coding, review, commit cycle).
1. Relationship to ORCHESTRATOR.md
| Concern | Guide |
|---|---|
| How to execute within a session (plan, code, test, review, commit) | ORCHESTRATOR.md |
| How to manage a mission across sessions (resume, continue, handoff) | This guide |
| Both guides are active simultaneously during orchestration missions. |
2. Mission Manifest
Location: docs/MISSION-MANIFEST.md
Owner: Orchestrator (sole writer)
Template: ~/.config/mosaic/templates/docs/MISSION-MANIFEST.md.template
The manifest is the persistent document tracking full mission scope, status, milestones, and session history. It survives session death.
Update Rules
- Update Phase when transitioning (Intake → Planning → Execution → Continuation → Completion)
- Update Current Milestone when starting a new milestone
- Update Progress after each milestone completion
- Append to Session History at session start and end
- Update Status to
completedonly when ALL success criteria are verified
Hard Rule
The manifest is the source of truth for mission scope. If the manifest says a milestone is done, it is done. If it says remaining, it remains.
3. Scratchpad Protocol
Location: docs/scratchpads/{mission-id}.md
Template: ~/.config/mosaic/templates/docs/mission-scratchpad.md.template
Rules
- First action — Before ANY planning or coding, write the mission prompt to the scratchpad
- Append-only — NEVER delete or overwrite previous entries
- Session log — Record session start, tasks done, and outcome at session end
- Decisions — Record all planning decisions with rationale
- Corrections — Record course corrections from human or coordinator
- Never deleted — Scratchpads survive mission completion (archival reference)
4. TASKS.md as Control Plane
Location: docs/TASKS.md
Owner: Orchestrator (sole writer). Workers read but NEVER modify.
Table Schema
| id | status | milestone | description | pr | notes |
Status Values
not-started → in-progress → done (or blocked / failed)
Planning Tasks Are First-Class
Include explicit planning tasks (e.g., PLAN-001: Break down milestone into tasks). These count toward progress.
Post-Merge Tasks Are Explicit
Include verification tasks after merge: CI check, deployment verification, Playwright test. Don't assume they happen automatically.
5. Session Resume Protocol
When starting a session and an active mission is detected, follow this checklist:
Detection (5-point check)
docs/MISSION-MANIFEST.mdexists → read Phase, Current Milestone, Progressdocs/scratchpads/*.mdexists → read latest scratchpad for decisions and correctionsdocs/TASKS.mdexists → read task state (what's done, what's next)- Git state → current branch, open PRs, recent commits
- Provider state → open issues, milestone status (if accessible)
Resume Procedure
- Read the mission manifest FIRST
- Read the scratchpad for session history and corrections
- Read TASKS.md for current task state
- Identify the next
not-startedorin-progresstask - Continue execution from that task
- Update Session History in the manifest
Dirty State Recovery
| State | Recovery |
|---|---|
| Dirty git working tree | Stash changes, log stash ref in scratchpad, resume clean |
| Open PR in bad state | Check PR status, close if broken, re-create if needed |
| Half-created issues | Audit issues against TASKS.md, reconcile |
| Tasks marked in-progress | Check if work was committed; if so, mark done; if not, restart task |
Hard Rule
Session state is NEVER automatically deleted. The coordinator (human or automated) must explicitly request cleanup.
6. Mission Continuation
When a milestone completes and more milestones remain:
Agent Handoff (at ~55-60% context)
If context usage is high, produce a handoff message:
- Update TASKS.md with final task statuses
- Update mission manifest with session results
- Append session summary to scratchpad
- Commit all state files
- The coordinator will generate a continuation prompt for the next session
Continuation Prompt Format
The coordinator generates this (via mosaic coord continue):
## Continuation Mission
Continue **{mission}** from existing state.
- Read docs/MISSION-MANIFEST.md for scope and status
- Read docs/scratchpads/{id}.md for decisions
- Read docs/TASKS.md for current state
- Continue from task {next-task-id}
Between Sessions (r0 manual)
- Agent stops (expected — this is the confirmed stamina limitation)
- Human runs
mosaic coord missionto check status - Human runs
mosaic coord continueto generate continuation prompt - Human launches new session and pastes the prompt
- New agent reads manifest, scratchpad, TASKS.md and continues
7. Failure Taxonomy Quick Reference
| Code | Type | Recovery |
|---|---|---|
| F1 | Premature Stop | Continuation prompt → new session (most common) |
| F2 | Context Exhaustion | Handoff message → new session |
| F3 | Session Crash | Check git state → mosaic coord resume → new session |
| F4 | Error Spiral | Kill session, mark task blocked, skip to next |
| F5 | Quality Gate Failure | Create QA remediation task |
| F6 | Infrastructure Failure | Pause, retry when service recovers |
| F7 | False Completion | Append correction to scratchpad, relaunch |
| F8 | Scope Drift | Kill session, relaunch with scratchpad ref |
| F9 | Subagent Failure | Orchestrator retries or creates remediation |
| F10 | Deadlock | Escalate to human |
F1: Premature Stop — Detailed Recovery
This is the confirmed, most common failure. Every session will eventually trigger F1.
- Session ends with tasks remaining in TASKS.md
- Run
mosaic coord mission— verify milestone status - If milestone complete: verify CI green, deployed, issues closed
- Run
mosaic coord continue— generates scoped continuation prompt - Launch new session, paste prompt
- New session reads state and continues from next pending task
8. r0 Manual Coordinator Process
In r0, the Coordinator is Jason + shell scripts. No daemon. No automation.
Commands
| Command | Purpose |
|---|---|
mosaic coord init --name "..." --milestones "..." |
Initialize a new mission |
mosaic coord mission |
Show mission progress dashboard |
mosaic coord status |
Check if agent session is still running |
mosaic coord continue |
Generate continuation prompt for next session |
mosaic coord resume |
Crash recovery (detect dirty state, generate fix) |
mosaic coord resume --clean-lock |
Clear stale session lock after review |
Typical Workflow
init → launch agent → [agent works] → agent stops →
status → mission → continue → launch agent → repeat
9. Operational Checklist
Pre-Mission
- Mission initialized:
mosaic coord init - docs/MISSION-MANIFEST.md exists with scope and milestones
- docs/TASKS.md scaffolded
- docs/scratchpads/{id}.md scaffolded
- Success criteria defined in manifest
Session Start
- Read manifest → know phase, milestone, progress
- Read scratchpad → know decisions, corrections, history
- Read TASKS.md → know what's done and what's next
- Write session start to scratchpad
- Update Session History in manifest
Planning Gate (Hard Gate — No Coding Until Complete)
- Milestones created in provider (Gitea/GitHub)
- Issues created for all milestone tasks
- TASKS.md populated with all planned tasks (including planning + verification tasks)
- All planning artifacts committed and pushed
Per-Task
- Update task status to
in-progressin TASKS.md - Execute task following ORCHESTRATOR.md cycle
- Update task status to
done(orblocked/failed) - Commit, push
Milestone Completion
- All milestone tasks in TASKS.md are
done - CI/pipeline green
- PR merged to
main - Issues closed
- Update manifest: milestone status → completed
- Update scratchpad: session log entry
- If deployment target: verify accessible
Mission Completion
- ALL milestones completed
- ALL success criteria verified with evidence
- manifest status → completed
- Final scratchpad entry with completion evidence
- Release tag created and pushed (if applicable)