6.2 KiB
6.2 KiB
PRD: MACP Phase 1 Core Protocol Implementation
Metadata
- Owner: Jarvis
- Date: 2026-03-27
- Status: in-progress
- Best-Guess Mode: true
Problem Statement
The current orchestrator-matrix rail can queue shell-based worker tasks, but it does not yet expose a standardized protocol for dispatch selection, worktree-aware execution, structured results, or manual MACP queue operations. MACP Phase 1 extends the existing rail so orchestrators can delegate to multiple runtimes through a consistent task model while preserving current behavior for legacy tasks.
Objectives
- Extend the existing orchestrator-matrix protocol and controller to support MACP-aware task dispatch and status tracking.
- Add a dispatcher layer that manages worktree lifecycle, runtime command generation, and standardized results.
- Provide a CLI entrypoint for manual MACP submission, status inspection, queue draining, and history review.
Scope
In Scope
- Extend the orchestrator task and event schemas and add a result schema.
- Add a Python dispatcher module under
tools/orchestrator-matrix/dispatcher/. - Update the controller to use the dispatcher for MACP-aware tasks while preserving legacy execution paths.
- Update orchestrator config templates, task markdown sync logic, and CLI routing/scripts for MACP commands.
- Add verification for backward compatibility, schema validity, imports, and basic MACP execution flow.
Out of Scope
- Rewriting the orchestrator controller architecture.
- Changing Matrix transport behavior beyond schema compatibility.
- Implementing real OpenClaw
sessions_spawnexecution beyond producing the config payload/command for callers. - Adding non-stdlib Python dependencies or npm-based tooling.
User/Stakeholder Requirements
- MACP must evolve the current orchestrator-matrix implementation rather than replace it.
- Legacy task queues without
dispatchfields must continue to run exactly as before. - MACP-aware tasks must support dispatch modes
yolo,acp, andexec. - Results must be written in a structured JSON format suitable for audit and orchestration follow-up.
- A manual
mosaic macpCLI must expose submit, status, drain, and history flows.
Functional Requirements
- Task schema must include MACP dispatch, worktree, result, retry, branch, brief, issue/PR, and dependency fields.
- Event schema must recognize
task.gated,task.escalated, andtask.retry.scheduled, plus adispatchersource. - Dispatcher functions must set up worktrees, build commands, execute tasks, collect results, and clean up worktrees.
- Controller
run_single_task()must route MACP-aware tasks through the dispatcher and emit the correct lifecycle events/status transitions. tasks_md_sync.pymust map optional MACP table columns only when those headers are present indocs/TASKS.md; absent MACP headers must not inject MACP fields into legacy tasks.bin/mosaicmust routemosaic macp ...to a newbin/mosaic-macpscript.
Non-Functional Requirements
- Security: no secrets embedded in generated commands, config, or results.
- Performance: controller remains deterministic and synchronous with no async or thread-based orchestration.
- Reliability: worktree creation/cleanup failures must be surfaced predictably and produce structured task failure/escalation states.
- Observability: lifecycle events, logs, and result JSON must clearly show task outcome, attempts, gates, and errors.
Acceptance Criteria
- Existing legacy tasks without
dispatchstill run through the old shell path with unchanged behavior. - MACP-aware
exectasks run through the dispatcher and produce result JSON with gate outcomes. - New schemas validate task/event/result payload expectations for MACP fields and statuses.
mosaic macp submit,status, andhistorywork from a bootstrapped repo state, anddraindelegates to the existing orchestrator runner.- Python imports for the updated controller, dispatcher, and sync code complete without errors on Python 3.10+.
Constraints and Dependencies
- Python implementation must use stdlib only and support Python 3.10+.
- Shell tooling must remain bash-based and fit the existing Mosaic CLI style.
- Dispatch fallback rules must use
execwhendispatchis absent and config/default runtime whenruntimeis absent. - Worktree convention must derive from the repository name and task metadata unless explicitly overridden by task fields.
Risks and Open Questions
- Risk: yolo command execution requires a PTY, so the dispatcher needs a safe wrapper that still behaves under
subprocess. - Risk: worktree cleanup could remove a path unexpectedly if task metadata is malformed.
- Risk: old queue consumers may assume only the original task statuses and event types.
- Open Question: whether
task.gatedshould be emitted by the dispatcher or controller once worker execution ends and quality gates begin.
Testing and Verification Expectations
- Baseline checks: Python import validation, targeted script execution checks, JSON syntax/schema validation, and any repo-local validation applicable to changed code paths.
- Situational testing: legacy orchestrator run with old-style tasks, MACP
execflow including result file generation, CLI submit/status/history behavior, and worktree lifecycle validation. - Evidence format: command-level results captured in the scratchpad and summarized in the final delivery report.
Milestone / Delivery Intent
- Target milestone/version: 0.0.x bootstrap enhancement
- Definition of done: code merged to
main, CI terminal green, issue#8closed, and verification evidence recorded against all acceptance criteria.
Assumptions
- ASSUMPTION: A single issue can track the full Phase 1 implementation because the user requested one bounded feature delivery rather than separate independent tickets.
- ASSUMPTION: For
acpdispatch in Phase 1, the controller must escalate the task immediately with a clear reason instead of pretending work ran before OpenClaw integration exists. - ASSUMPTION:
task.gatedshould be emitted by the controller as the transition into quality-gate execution, which keeps gate-state ownership in one place alongside the existing gate loop.