Queue MoonMind Workflows
Overview
Queue child MoonMind workflows through the durable execution API and verify
their visibility before reporting success. This skill is for workflow fan-out:
creating more MoonMind executions from a running MoonMind workflow, not for
planning future work in an agent-local task list.
Non-Negotiables
- Do not claim workflows were queued unless each successful item has a
workflowId returned by POST /api/executions and verified by
GET /api/executions/{workflowId}.
- Do not satisfy queueing requests by writing only a markdown file, a local JSON
manifest, an in-session task list, or a proposal.
- Use
MOONMIND_URL and the execution API. Do not write directly to the
database, call Temporal CLI directly for creation, or infer success from
agent stdout.
- Use stable idempotency. Prefer a parent workflow/run scope plus the child ref;
fail when idempotency cannot be established unless the operator explicitly
asks for non-idempotent submission.
- Keep child request bodies compact. Large source briefs, story files, logs, or
generated context must be artifact refs or issue refs, not embedded blobs.
Manifest
Write a manifest containing one complete /api/executions request per child:
{
"batchScope": "mm:parent-workflow-or-run",
"workflows": [
{
"ref": "github:MoonLadderStudios/MoonMind#722",
"request": {
"type": "task",
"priority": 0,
"maxAttempts": 3,
"payload": {
"repository": "MoonLadderStudios/MoonMind",
"runtimeInheritance": "caller",
"requiredCapabilities": ["git", "gh"],
"task": {
"title": "Implement GitHub issue #722",
"instructions": "Implement GitHub issue MoonLadderStudios/MoonMind#722.",
"skill": {"name": "github-issue-implement"},
"inputs": {
"github_issue_ref": "MoonLadderStudios/MoonMind#722"
},
"publish": {"mode": "pr"}
}
}
}
}
]
}
The helper supports both execution API shapes:
- task-shaped wrapper:
{"type": "task", "payload": {...}}
- direct execution create body:
{"workflowType": "MoonMind.UserWorkflow", ...}
When MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN_FILE or the direct
MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN value is present, only the task-shaped
child form is accepted and the helper binds it to the caller with
runtimeInheritance="caller"; direct create and schedule shapes remain available
only to ordinary authenticated API users.
For task-shaped requests, idempotency is stored at request.payload.idempotencyKey.
For direct create requests, idempotency is stored at request.idempotencyKey.
Workflow
Resolve the child targets and write the manifest to a managed artifact path,
usually artifacts/queue-moonmind-workflows-manifest.json.
Run the helper:
python3 .agents/skills/queue-moonmind-workflows/scripts/queue_moonmind_workflows.py \
--manifest artifacts/queue-moonmind-workflows-manifest.json \
--max-workflows 25
Read the helper output. A successful queue has:
submitted > 0
verified == submitted
errors == []
- one
workflowId per queued item
Report queued workflow IDs and the summary artifact path. If any item failed
submission or verification, report the run as failed/partial and include the
specific failing ref values.
Helper Behavior
scripts/queue_moonmind_workflows.py:
- requires
MOONMIND_URL;
- reads
MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN_FILE when present and fails
closed if that lease-owned file is missing or empty; otherwise accepts the
direct MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN value for portable hosts;
- sends the scoped value as a bearer with the fan-out v1 marker and never
substitutes a broader API token when scoped authority is configured;
- forwards supported API auth from
MOONMIND_AUTH_HEADER,
MOONMIND_API_TOKEN, MOONMIND_AUTH_TOKEN, MOONMIND_BEARER_TOKEN, or
MOONMIND_API_KEY when present, and also forwards
MOONMIND_WORKER_TOKEN or MOONMIND_WORKER_TOKEN_FILE for deployments that
still accept the legacy worker header;
- forwards parent workflow/agent headers from
MOONMIND_TASK_WORKFLOW_ID,
MOONMIND_WORKFLOW_ID, TEMPORAL_WORKFLOW_ID, MOONMIND_AGENT_RUN_ID,
MOONMIND_RUN_ID, or AGENT_RUN_ID;
- derives idempotency keys from
batchScope, child ref, and the request body;
- submits each child with
POST /api/executions;
- verifies each returned
workflowId with bounded retries against
GET /api/executions/{workflowId};
- writes
queue-moonmind-workflows-result.json under the managed session
artifact spool when available, otherwise under --artifacts-dir;
- exits non-zero when submission or verification errors occur.
Use --dry-run to validate and summarize the manifest without submitting. Use
--allow-empty only when a no-op is an acceptable outcome.
Result Standard
Treat these as failures:
MOONMIND_URL is missing.
- The manifest has zero workflows and
--allow-empty was not set.
- The manifest exceeds
--max-workflows; cap skips are reported as partial
failures instead of silent success.
- Any child request lacks a stable idempotency key and the helper cannot derive
one from parent scope.
- A
POST /api/executions response lacks workflowId.
- A returned
workflowId cannot be fetched through GET /api/executions/{id}
within the retry window.
- The helper exits non-zero.
When queueing from an already-running workflow, prefer
runtimeInheritance: "caller" in the child payload and include a fallback
runtime only when the parent task context supplies one. Do not silently switch
model, effort, provider profile, repository, publish mode, or credentials.
1---2name: queue-moonmind-workflows3description: Queue additional MoonMind workflows from inside an existing workflow by submitting explicit `/api/executions` requests, applying stable idempotency, verifying every returned `workflowId` with the execution API, and writing a durable queue summary. Use when a workflow needs to fan out follow-up MoonMind executions, create child implementation workflows, replace local task-list or manifest-only handoffs, or prove that downstream workflows were actually queued.4---56# Queue MoonMind Workflows78## Overview910Queue child MoonMind workflows through the durable execution API and verify11their visibility before reporting success. This skill is for workflow fan-out:12creating more MoonMind executions from a running MoonMind workflow, not for13planning future work in an agent-local task list.1415## Non-Negotiables1617- Do not claim workflows were queued unless each successful item has a18 `workflowId` returned by `POST /api/executions` and verified by19 `GET /api/executions/{workflowId}`.20- Do not satisfy queueing requests by writing only a markdown file, a local JSON21 manifest, an in-session task list, or a proposal.22- Use `MOONMIND_URL` and the execution API. Do not write directly to the23 database, call Temporal CLI directly for creation, or infer success from24 agent stdout.25- Use stable idempotency. Prefer a parent workflow/run scope plus the child ref;26 fail when idempotency cannot be established unless the operator explicitly27 asks for non-idempotent submission.28- Keep child request bodies compact. Large source briefs, story files, logs, or29 generated context must be artifact refs or issue refs, not embedded blobs.3031## Manifest3233Write a manifest containing one complete `/api/executions` request per child:3435```json36{37 "batchScope": "mm:parent-workflow-or-run",38 "workflows": [39 {40 "ref": "github:MoonLadderStudios/MoonMind#722",41 "request": {42 "type": "task",43 "priority": 0,44 "maxAttempts": 3,45 "payload": {46 "repository": "MoonLadderStudios/MoonMind",47 "runtimeInheritance": "caller",48 "requiredCapabilities": ["git", "gh"],49 "task": {50 "title": "Implement GitHub issue #722",51 "instructions": "Implement GitHub issue MoonLadderStudios/MoonMind#722.",52 "skill": {"name": "github-issue-implement"},53 "inputs": {54 "github_issue_ref": "MoonLadderStudios/MoonMind#722"55 },56 "publish": {"mode": "pr"}57 }58 }59 }60 }61 ]62}63```6465The helper supports both execution API shapes:6667- task-shaped wrapper: `{"type": "task", "payload": {...}}`68- direct execution create body: `{"workflowType": "MoonMind.UserWorkflow", ...}`6970When `MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN_FILE` or the direct71`MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN` value is present, only the task-shaped72child form is accepted and the helper binds it to the caller with73`runtimeInheritance="caller"`; direct create and schedule shapes remain available74only to ordinary authenticated API users.7576For task-shaped requests, idempotency is stored at `request.payload.idempotencyKey`.77For direct create requests, idempotency is stored at `request.idempotencyKey`.7879## Workflow80811. Resolve the child targets and write the manifest to a managed artifact path,82 usually `artifacts/queue-moonmind-workflows-manifest.json`.832. Run the helper:8485 ```bash86 python3 .agents/skills/queue-moonmind-workflows/scripts/queue_moonmind_workflows.py \87 --manifest artifacts/queue-moonmind-workflows-manifest.json \88 --max-workflows 2589 ```90913. Read the helper output. A successful queue has:92 - `submitted > 0`93 - `verified == submitted`94 - `errors == []`95 - one `workflowId` per queued item964. Report queued workflow IDs and the summary artifact path. If any item failed97 submission or verification, report the run as failed/partial and include the98 specific failing `ref` values.99100## Helper Behavior101102`scripts/queue_moonmind_workflows.py`:103104- requires `MOONMIND_URL`;105- reads `MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN_FILE` when present and fails106 closed if that lease-owned file is missing or empty; otherwise accepts the107 direct `MOONMIND_EXECUTION_FANOUT_BEARER_TOKEN` value for portable hosts;108- sends the scoped value as a bearer with the fan-out v1 marker and never109 substitutes a broader API token when scoped authority is configured;110- forwards supported API auth from `MOONMIND_AUTH_HEADER`,111 `MOONMIND_API_TOKEN`, `MOONMIND_AUTH_TOKEN`, `MOONMIND_BEARER_TOKEN`, or112 `MOONMIND_API_KEY` when present, and also forwards113 `MOONMIND_WORKER_TOKEN` or `MOONMIND_WORKER_TOKEN_FILE` for deployments that114 still accept the legacy worker header;115- forwards parent workflow/agent headers from `MOONMIND_TASK_WORKFLOW_ID`,116 `MOONMIND_WORKFLOW_ID`, `TEMPORAL_WORKFLOW_ID`, `MOONMIND_AGENT_RUN_ID`,117 `MOONMIND_RUN_ID`, or `AGENT_RUN_ID`;118- derives idempotency keys from `batchScope`, child `ref`, and the request body;119- submits each child with `POST /api/executions`;120- verifies each returned `workflowId` with bounded retries against121 `GET /api/executions/{workflowId}`;122- writes `queue-moonmind-workflows-result.json` under the managed session123 artifact spool when available, otherwise under `--artifacts-dir`;124- exits non-zero when submission or verification errors occur.125126Use `--dry-run` to validate and summarize the manifest without submitting. Use127`--allow-empty` only when a no-op is an acceptable outcome.128129## Result Standard130131Treat these as failures:132133- `MOONMIND_URL` is missing.134- The manifest has zero workflows and `--allow-empty` was not set.135- The manifest exceeds `--max-workflows`; cap skips are reported as partial136 failures instead of silent success.137- Any child request lacks a stable idempotency key and the helper cannot derive138 one from parent scope.139- A `POST /api/executions` response lacks `workflowId`.140- A returned `workflowId` cannot be fetched through `GET /api/executions/{id}`141 within the retry window.142- The helper exits non-zero.143144When queueing from an already-running workflow, prefer145`runtimeInheritance: "caller"` in the child payload and include a fallback146runtime only when the parent task context supplies one. Do not silently switch147model, effort, provider profile, repository, publish mode, or credentials.