---
name: mastermind-runorg
description: Mastermind runorg — load a saved org definition and start it as a persistent autonomous agent organization. The boss agent coordinates all roles, agents pick up tasks from a shared board, and the org runs until stopped.
type: domain-skill
default_mode: auto
---

# Mastermind Run Org

This skill is invoked by `mastermind:runorg` or directly via `/mastermind:runorg`.

---

## Inputs

- `brain_context`: BRAIN CONTEXT block (injected by command, or loaded below if standalone)
- `org_name`: name of the org to run (matches a file at `.monomind/orgs/<org_name>.json`)
- `session_id`: session ID generated by the command
- `task`: optional override task/goal for this run (if omitted, uses org's stored goal)
- `caller`: command | master (controls whether brain load/write runs here)

---

## Step 0 — Brain Load (standalone only)

If `caller` is not "command", load brain context following _protocol.md Brain Load Procedure with namespace: `ops`.

---

## Step 1 — Load Org Config

Read `.monomind/orgs/<org_name>.json`. If the file does not exist:
```bash
orgs=$(ls .monomind/orgs/*.json 2>/dev/null | grep -vE -- '-approvals|-state|-activity|-goals|-routines|-projects|-members|-issues|-workspaces|-worktrees|-environments|-plugins|-adapters|-bootstrap|-threads|-budgets|-project-workspaces|-approval-comments' | xargs -I{} basename {} .json)
if [ -z "$orgs" ]; then
  echo "No saved orgs found. Run /mastermind:createorg to define one."
else
  echo "Available orgs: $orgs"
fi
```
Return `status: blocked` with message: "Org '<org_name>' not found. Run /mastermind:createorg to define it."

Validate the config has at minimum: `name`, `goal`, `roles` (non-empty array), `communication`.

---

## Step 1.5 — Detect Scheduled Org

After loading the org config, check whether this is a scheduled (loop) org:

```bash
orgFile=".monomind/orgs/${org_name}.json"
has_schedule=$(jq -r 'if .loop.poll_interval_minutes then "yes" else "no" end' "$orgFile")
```

If `has_schedule == "yes"`, this is a **scheduled org**. Follow the **Scheduled Org Path** below (Steps 1.6 onward) instead of the standard Steps 2–8.

If `has_schedule == "no"`, skip to **Step 2** (standard persistent daemon path).

---

## Step 1.6 — Scheduled Org Path

This section handles orgs created with `--schedule`. The loop is owned by the org — it starts with `runorg`, runs each iteration via the loop prompt file, and stops with `stoporg`.

### 1.6.1 — Guard against double-activation, then set status to "active"

```bash
orgFile=".monomind/orgs/${org_name}.json"
current_loop_status=$(jq -r '.status // "stopped"' "$orgFile")
```

If `current_loop_status == "active"`:
- Print:
  ```
  WARNING: Org '<org_name>' is already active. Starting a second instance would create parallel loop chains.
  To restart cleanly: run /mastermind:stoporg --org <org_name> first, then /mastermind:runorg --org <org_name>.
  To force restart anyway, set status to "stopped" in .monomind/orgs/<org_name>.json and re-run.
  ```
- Return `status: blocked`. **STOP — do not proceed.**

If `current_loop_status == "paused"`:
- Print: "Org '<org_name>' was paused. Reactivating..."
- Proceed (set to "active" below).

For all other statuses (stopped, or absent):

```bash
tmp="${orgFile}.tmp"
jq '.status = "active"' "$orgFile" > "$tmp" && mv "$tmp" "$orgFile"
```

### 1.6.2 — Derive scheduled-org variables

```bash
orgName=$(jq -r '.name' "$orgFile")
goal="${task:-$(jq -r '.goal' "$orgFile")}"
sessionId="$session_id"
poll_interval_minutes=$(jq -r '.loop.poll_interval_minutes' "$orgFile")
poll_interval_seconds=$(( poll_interval_minutes * 60 ))
run_prompt_file=$(jq -r '.loop.run_prompt_file' "$orgFile")
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
```

### 1.6.3 — Emit org:start event

```bash
curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
  -H "Content-Type: application/json" \
  -d "$(jq -cn \
    --arg session "$sessionId" \
    --arg org "$orgName" \
    --arg goal "$goal" \
    --arg proj "$REPO_ROOT" \
    '{type:"org:start",session:$session,org:$org,goal:$goal,project:$proj,ts:(now*1000|floor)}')" || true
```

### 1.6.4 — Execute first iteration inline

Read the loop prompt file and execute its instructions directly (this IS the first iteration):

```bash
[ ! -f "$run_prompt_file" ] && {
  echo "ERROR: Loop prompt file '${run_prompt_file}' not found."
  echo "Re-run: /mastermind:createorg --name ${orgName} --schedule \"every ${poll_interval_minutes} minutes\" to regenerate it."
  exit 1
}
```

Execute the steps described in `$run_prompt_file` — the file contains the full iteration instructions for this org. Follow them exactly, starting from Step 0 (status gate) through the org-specific work steps.

Since this is the first run and status was just set to "active", Step 0 will pass. The org-specific iteration steps run normally.

### 1.6.5 — Schedule next iteration via ScheduleWakeup

After the iteration completes, re-check status and schedule the next wakeup:

```bash
LOOP_STATUS=$(jq -r '.status // "stopped"' "$orgFile" 2>/dev/null || echo "stopped")
```

If `LOOP_STATUS == "active"` or `LOOP_STATUS == "paused"`:

1. Read the loop prompt:
   ```bash
   LOOP_PROMPT=$(cat "$run_prompt_file")
   ```

2. Call `ScheduleWakeup` with:
   - `delaySeconds`: `$poll_interval_seconds`
   - `reason`: `"<orgName>: next scheduled poll (every <poll_interval_minutes> min)"`
   - `prompt`: full contents of `$LOOP_PROMPT`

3. Update `next_run` in org JSON:
   ```bash
   next_ts=$(( $(date +%s) + poll_interval_seconds ))
   next_iso=$(date -u -r "$next_ts" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null \
     || date -u -d "@$next_ts" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null \
     || python3 -c "import datetime; print(datetime.datetime.utcfromtimestamp($next_ts).strftime('%Y-%m-%dT%H:%M:%SZ'))")
   tmp="${orgFile}.tmp"
   jq --arg next "$next_iso" '.loop.next_run = $next' "$orgFile" > "$tmp" && mv "$tmp" "$orgFile"
   curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
     -H "Content-Type: application/json" \
     -d "$(jq -cn --arg org "$orgName" --arg next "$next_iso" --arg proj "$REPO_ROOT" \
       '{type:"org:loop:scheduled",org:$org,next_run:$next,project:$proj,ts:(now*1000|floor)}')" || true
   ```

If `LOOP_STATUS` is anything else → print "Org was stopped during this run — loop will not continue." No ScheduleWakeup.

### 1.6.6 — Report to user

```
╔══════════════════════════════════════════════════════════╗
║  ORG STARTED: <orgName>                                  ║
║  GOAL: <goal>                                            ║
║  MODE: scheduled loop                                    ║
╚══════════════════════════════════════════════════════════╝

SCHEDULE
────────
  Interval: every <poll_interval_minutes> minutes
  Status:   active
  Next run: <next_iso (or "see .monomind/orgs/<orgName>.json")>

To stop:  /mastermind:stoporg --org <orgName>
Status:   /mastermind:orgstatus --org <orgName>
All orgs: /mastermind:orgs
```

### 1.6.7 — Return (skip Steps 2–8)

```yaml
domain: ops
status: complete
decisions:
  - what: "Scheduled org <orgName> activated, first iteration complete, next wakeup in <poll_interval_minutes> min"
    why: "Loop started by runorg; ScheduleWakeup queued"
    confidence: 0.9
    outcome: pending
next_actions:
  - "Stop: /mastermind:stoporg --org <orgName>"
  - "Status: /mastermind:orgstatus --org <orgName>"
run_id: "<runId>"
```

**STOP HERE** — do not execute Steps 2–8 for scheduled orgs.

---

## Step 2 — Derive Variables

Before spawning any agents, derive all variables from the loaded config. These are used in Steps 3 and 4.

```
orgConfig  = parsed JSON from .monomind/orgs/<org_name>.json
orgName    = orgConfig.name
goal       = task (if provided) or orgConfig.goal
sessionId  = provided session_id input
stopFile   = `.monomind/orgs/.stops/${orgName}.stop`
memNs      = `org:${orgName}`
topology   = orgConfig.topology
checkpointMin = orgConfig.run_config?.checkpoint_interval_min ?? 30
```

Find the boss role — use filter to detect ambiguity before dereferencing:

```
rootRoles = orgConfig.roles.filter(r => r.reports_to === null || r.reports_to === undefined)
```

Abort with `status: blocked` if `rootRoles.length === 0` — message: "Org '<orgName>' has no root role; exactly one role must have reports_to: null."

Abort with `status: blocked` if `rootRoles.length > 1` — message: "Org '<orgName>' has multiple root roles; exactly one must have reports_to: null."

```
bossRole           = rootRoles[0]
bossRole_id        = bossRole.id
bossRole_title     = bossRole.title
bossRole_agent_type = bossRole.agent_type
directReports      = orgConfig.roles.filter(r => r.reports_to === bossRole.id)
runId              = new Date().toISOString()
```

Also validate that every role has non-empty `id`, `title`, `agent_type`, and `responsibilities` (array). Abort with `status: blocked` listing any malformed role — do this before Step 3 initializes infrastructure.

After the conceptual derivations above, extract them as real shell variables so downstream bash blocks can reference `$orgName`, `$sessionId`, etc.:

```bash
orgFile=".monomind/orgs/${org_name}.json"
orgName=$(jq -r '.name' "$orgFile")
goal="${task:-$(jq -r '.goal' "$orgFile")}"
sessionId="$session_id"
stopFile=".monomind/orgs/.stops/${orgName}.stop"
memNs="org:${orgName}"
topology=$(jq -r '.topology' "$orgFile")
checkpointMin=$(jq -r '.run_config.checkpoint_interval_min // 30' "$orgFile")
bossRole_id=$(jq -r '[(.roles // [])[] | select(.reports_to == null or .reports_to == "")][0].id' "$orgFile")
bossRole_title=$(jq -r '[(.roles // [])[] | select(.reports_to == null or .reports_to == "")][0].title' "$orgFile")
bossRole_agent_type=$(jq -r '[(.roles // [])[] | select(.reports_to == null or .reports_to == "")][0].agent_type' "$orgFile")
if [ -z "$bossRole_id" ] || [ "$bossRole_id" = "null" ]; then
  echo "ERROR: Org '${org_name}' has no root role (reports_to: null). Check the org config."
  exit 1
fi
board_id=$(jq -r '.board_id // empty' "$orgFile")
todo_col=$(jq -r '.todo_col_id // empty' "$orgFile")
doing_col=$(jq -r '.doing_col_id // empty' "$orgFile")
done_col=$(jq -r '.done_col_id // empty' "$orgFile")
runId=$(date -u +%Y-%m-%dT%H:%M:%SZ)
```

---

## Step 3 — Initialize Org Infrastructure

**Validate board IDs from org config:**

The board and column IDs were written into the org config by `createorg`. If missing, the org was not created correctly.

```bash
[ -z "$board_id" ]  && { echo "ERROR: org config missing board_id — re-run /mastermind:createorg --name ${orgName} to rebuild the org."; exit 1; }
[ -z "$todo_col" ]  && { echo "ERROR: org config missing todo_col_id — re-run /mastermind:createorg --name ${orgName}."; exit 1; }
[ -z "$doing_col" ] && { echo "ERROR: org config missing doing_col_id — re-run /mastermind:createorg --name ${orgName}."; exit 1; }
[ -z "$done_col" ]  && { echo "ERROR: org config missing done_col_id — re-run /mastermind:createorg --name ${orgName}."; exit 1; }
```

**Create stop-file and state directories:**
```bash
mkdir -p .monomind/orgs/.stops
```

**Initialize org state file** (tracks per-agent status, heartbeat timestamps, token usage):
```bash
stateFile=".monomind/orgs/${orgName}-state.json"
if [ ! -f "$stateFile" ]; then
  jq -n \
    --arg org "$orgName" \
    --arg runId "$runId" \
    '{org:$org,run_id:$runId,started_at:(now|todate),agents:{}}' \
    > "$stateFile"
else
  # Update run_id and started_at for this run
  tmp="${stateFile}.tmp"
  jq --arg runId "$runId" \
     '.run_id = $runId | .started_at = (now|todate)' \
     "$stateFile" > "$tmp" && mv "$tmp" "$stateFile"
fi
```

**Remove any stale stop file:**
```bash
rm -f "$stopFile"
```

**Emit `org:start` to dashboard:**
```bash
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
  -H "Content-Type: application/json" \
  -d "$(jq -cn \
    --arg session "$sessionId" \
    --arg org "$orgName" \
    --arg goal "$goal" \
    --arg proj "$(pwd)" \
    '{type:"org:start",session:$session,org:$org,goal:$goal,project:$proj,ts:(now*1000|floor)}')" || true
```

---

## Step 4 — Spawn Boss Agent

Using the variables derived in Step 2, spawn the boss agent via Task tool:

```javascript
Task({
  subagent_type: bossRole.agent_type,
  description: `You are the ${bossRole.title} of org "${orgName}". You run persistently until stopped.`,
  run_in_background: true,
  prompt: `You are the ${bossRole.title} of the autonomous organization "${orgName}".

ORG GOAL: ${goal}

YOUR ROLE: ${bossRole.title}
YOUR RESPONSIBILITIES: ${bossRole.responsibilities.join('; ')}

YOUR TEAM (direct reports):
${directReports.map(r => `• ${r.title} (subagent_type="${r.agent_type}") — ${r.responsibilities.join(', ')}`).join('\n')}

FULL COMMUNICATION TOPOLOGY:
${orgConfig.communication.map(e => `${e.from} → ${e.to} (${e.type})`).join('\n')}

SHARED INFRASTRUCTURE:
- Task board (monotask): board_id=${board_id}
  Columns: Todo=${todo_col}  Doing=${doing_col}  Done=${done_col}
- Memory namespace: ${memNs} (use: npx monomind@latest memory store/search --namespace ${memNs})
- Dashboard events: POST to mastermind control server via curl — see CTRL_URL resolution in DASHBOARD EVENTS section below
- Session ID for all events: ${sessionId}

TASK BOARD COMMANDS (use these for all task management):
  # List all unclaimed Todo cards for a specific role (server-side filters — fast):
  monotask card list ${board_id} --col ${todo_col} --label "role:<role_id>" --json

  # List all unclaimed Todo cards (any role):
  monotask card list ${board_id} --col ${todo_col} --json | jq '[.[] | select(.labels | index("claimed") | not)]'

  # List all in-progress cards:
  monotask card list ${board_id} --col ${doing_col} --json

  # List all cards for a role across all columns:
  monotask card list ${board_id} --label "role:<role_id>" --json

  # Create a new task in Todo (tagged for a specific role):
  CARD_ID=$(monotask card create ${board_id} ${todo_col} "Task title" --json | jq -r .id)
  monotask card label add ${board_id} $CARD_ID "role:<role_id>"

  # Break task into subtasks:
  monotask card subtask add ${board_id} $CARD_ID ${board_id} ${todo_col} "Subtask title" --json

  # Mark a task as blocked by a prerequisite (won't claim until prereq is Done):
  monotask card prerequisite add ${board_id} $BLOCKED_ID ${board_id} $PREREQ_ID

  # Claim a task (move to Doing + mark claimed):
  monotask card move ${board_id} $CARD_ID ${doing_col}
  monotask card label add ${board_id} $CARD_ID "claimed"

  # Complete a task:
  monotask card move ${board_id} $CARD_ID ${done_col}

ORG STATE FILE (update per agent per cycle for dashboard visibility):
  stateFile=".monomind/orgs/${orgName}-state.json"
  # Mark agent as running:
  jq --arg id "<role_id>" --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
     '.agents[$id].status = "running" | .agents[$id].last_heartbeat = $ts' \
     "$stateFile" > "${stateFile}.tmp" && mv "${stateFile}.tmp" "$stateFile"
  # Mark agent as idle after completing:
  jq --arg id "<role_id>" \
     '.agents[$id].status = "idle" | .agents[$id].last_heartbeat_complete = (now|todate)' \
     "$stateFile" > "${stateFile}.tmp" && mv "${stateFile}.tmp" "$stateFile"
  # Add token counts when known:
  jq --arg id "<role_id>" --argjson in <tokens_in> --argjson out <tokens_out> \
     '.agents[$id].tokens_in = ((.agents[$id].tokens_in // 0) + $in) | .agents[$id].tokens_out = ((.agents[$id].tokens_out // 0) + $out)' \
     "$stateFile" > "${stateFile}.tmp" && mv "${stateFile}.tmp" "$stateFile"

APPROVAL GATE (when governance.policy is "board" or "strict"):
  Before any external action (sending emails, posting content, making purchases, modifying infrastructure):
  approvalsFile=".monomind/orgs/${orgName}-approvals.json"
  [ ! -f "$approvalsFile" ] && echo '{"approvals":[]}' > "$approvalsFile"
  approval_id="req-$(date +%s)-$$-$RANDOM"
  jq --arg id "$approval_id" --arg agent "<role_id>" --arg title "<action summary>" \
     --arg action "<full action description>" --arg risk "medium" \
     '.approvals += [{"id":$id,"agent_id":$agent,"title":$title,"action":$action,"risk_level":$risk,"status":"pending","requested_at":(now|todate)}]' \
     "$approvalsFile" > "${approvalsFile}.tmp" && mv "${approvalsFile}.tmp" "$approvalsFile"
  # Emit approval request event so human sees it in dashboard
  curl -s -X POST "${CTRL_URL}/api/mastermind/event" -H "Content-Type: application/json" \
    -d "$(jq -cn --arg org "${orgName}" --arg id "$approval_id" --arg title "<title>" \
      '{type:"org:approval:requested",org:$org,approval_id:$id,title:$title,ts:(now*1000|floor)}')" || true
  # Poll until approved or rejected (max 30 min).
  # Check the approvals file first (updated by both dashboard UI and /mastermind:approve command),
  # then fall back to memory in case an external notifier wrote there.
  for i in $(seq 1 60); do
    status=$(jq -r --arg id "$approval_id" '(.approvals // [])[] | select(.id == $id) | .status // ""' "$approvalsFile" 2>/dev/null || echo "")
    if [ -z "$status" ] || [ "$status" = "pending" ]; then
      mem_status=$(npx monomind@latest memory get --key "approval:${approval_id}" --namespace "${memNs}" 2>/dev/null | jq -r '.status // ""' 2>/dev/null)
      [ -n "$mem_status" ] && status="$mem_status"
    fi
    [ "$status" = "approved" ] && break
    [ "$status" = "rejected" ] && { echo "Action rejected by governance policy — skip this action"; break; }
    sleep 30
  done

STOP DETECTION (check this FIRST in every loop iteration):
  [ -f "${stopFile}" ] && echo STOP_REQUESTED
If the file exists: emit org:complete event, clean up with "rm -f ${stopFile}", then exit.

OPERATING LOOP:
1. Check for stop signal (see above). Exit if found.
2. List unclaimed Todo cards: monotask card list ${board_id} --col ${todo_col} --json | jq '[.[] | select(.labels | index("claimed") | not)]'
3. For each Todo card without a "claimed" label, assign to the appropriate role based on its "role:<id>" label. Skip cards whose prerequisites (monotask card prerequisite list) are not yet in the Done column.
4. Spawn the assigned role agent via Task tool (run_in_background: true) with:
   - Full role briefing (title, responsibilities, who they report to, memory namespace)
   - The specific card title and card_id to work on
   - Move the card to Doing before spawning: monotask card move ${board_id} $CARD_ID ${doing_col}
   - Add label "claimed" to the card
   - Report output via: npx monomind@latest memory store --key "${memNs}:report:<card_id>" --namespace "${memNs}"
   - When complete, move card to Done: monotask card move ${board_id} $CARD_ID ${done_col}
   - Emit org:agent:online event to dashboard before starting (use curl, see below)
5. Collect completed results from memory (search "${memNs}:report:")
6. Synthesize reports, make decisions, create new cards in Todo column based on progress toward goal
7. Write a run-completion entry to the activity log (used by the health dashboard for 7-day success rate):
   activityFile=".monomind/orgs/${orgName}-activity.jsonl"
   # Count Todo cards not yet claimed as the pending_tasks metric
   pending_count=$(monotask card list ${board_id} --col ${todo_col} --json 2>/dev/null | jq '[.[] | select(.labels | index("claimed") | not)] | length' 2>/dev/null || echo 0)
   echo "{\"type\":\"run:complete\",\"org\":\"${orgName}\",\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"pending\":${pending_count:-0}}" >> "$activityFile"
   (On error/exception, write: {"type":"run:error","ts":"...", "org":"..."})
8. Emit org:checkpoint event with progress summary
9. Wait ${checkpointMin} minutes, then loop back to step 1

AGENT TYPES FOR YOUR TEAM:
${orgConfig.roles.filter(r => r.id !== bossRole.id).map(r =>
  `• ${r.title}: subagent_type="${r.agent_type}"`
).join('\n')}

DASHBOARD EVENTS — emit via curl (NOT WebFetch — WebFetch does not support POST):
  REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
  CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
  curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
    -H "Content-Type: application/json" \
    -d "$(jq -cn --arg type TYPE --arg session SESSION --arg org ORG --arg proj "$REPO_ROOT" '{type:$type,session:$session,org:$org,project:$proj,ts:(now*1000|floor)}')"
Payloads:
- org:agent:online → add fields: role, title, agent_type
- org:comms → add fields: from, to, msg
- org:checkpoint → add fields: progress, pending_tasks
- org:complete → no additional fields
Note: always include project:$REPO_ROOT in all event payloads for correct multi-project SSE filtering

START NOW: check for stop signal, assess the board, create initial tasks if none exist, then begin the operating loop.`
})
```

---

## Step 5 — Emit Boss Online Event

Emit `org:agent:online` for the boss role (team member events are emitted by the boss itself):

```bash
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
  -H "Content-Type: application/json" \
  -d "$(jq -cn \
    --arg session "$sessionId" \
    --arg org "$orgName" \
    --arg role "$bossRole_id" \
    --arg title "$bossRole_title" \
    --arg agent_type "$bossRole_agent_type" \
    --arg proj "$REPO_ROOT" \
    '{type:"org:agent:online",session:$session,org:$org,role:$role,title:$title,agent_type:$agent_type,project:$proj,ts:(now*1000|floor)}')" || true
```

(Use the scalar string variables `$bossRole_id`, `$bossRole_title`, `$bossRole_agent_type` derived by extracting fields from `bossRole` before constructing the curl call.)

---

## Step 6 — Report to User

Print the org startup summary:

```
╔══════════════════════════════════════════════════════════╗
║  ORG STARTED: <orgName>                                  ║
║  GOAL: <goal>                                            ║
║  MODE: persistent daemon                                 ║
╚══════════════════════════════════════════════════════════╝

ACTIVE ROLES
────────────
• [<bossRole.id>] <bossRole.title> → running as <bossRole.agent_type> agent
• [<each direct report>] <title> → will be spawned by boss on demand
  ... (all roles from config)

BOARD: <orgName>/org-tasks
MEMORY: org:<orgName>
DASHBOARD: see .monomind/control.json for URL (default http://localhost:4242)

To stop: click STOP in the dashboard Orgs panel
         or run: CTRL_URL=$(jq -r '.url // "http://localhost:4242"' .monomind/control.json 2>/dev/null || echo "http://localhost:4242"); curl -X POST "${CTRL_URL}/api/orgs/<orgName>/stop"
```

---

## Step 7 — Return Output Schema

```yaml
domain: ops
status: complete
artifacts: []
decisions:
  - what: "Org <orgName> started with <N> roles, boss agent running"
    why: "Loaded from .monomind/orgs/<orgName>.json"
    confidence: 0.9
    outcome: pending
lessons:
  - what_worked: "Boss agent spawned and org loop started"
  - what_didnt: ""
next_actions:
  - "Monitor in Mastermind Orgs panel (CTRL_URL from .monomind/control.json, default http://localhost:4242)"
  - "To stop: click STOP in dashboard or: CTRL_URL=$(jq -r '.url // \"http://localhost:4242\"' .monomind/control.json); curl -X POST \"${CTRL_URL}/api/orgs/<orgName>/stop\""
board_url: "monotask://<orgName>/org-tasks"
run_id: "<runId>"
```

---

## Step 8 — Brain Write (standalone only)

If `caller` is not "command", follow _protocol.md Brain Write Procedure for domain `ops`.
