# control-plane

> Read-only project control plane, management-by-exception view, and referenced summary scheduler.

| field | value |
|-------|-------|
| version | 0.0.2 |
| type | bundle |
| license | Apache-2.0 |
| repo | https://github.com/iii-hq/workers |
| author | iii |

## installation

```sh
iii call compose::add worker=control-plane@0.0.2
```

## dependencies

- `configuration` @ `latest`
- `harness` @ `latest`
- `iii-directory` @ `latest`
- `kanban` @ `latest`
- `session-manager` @ `latest`
- `state` @ `latest`

## readme

# control-plane 0.0.1

The `control-plane` worker owns the Control plane page, read model and summary
schedule. Open it from the console navigation, via `#/workspace/control-plane`,
or on its own at `#/worker/control-plane`. It aggregates harness roots and asks,
kanban projects, cards, releases and questions, and pull requests from repositories
declared on projects.

The worker requires configuration, harness, session-manager, kanban, state and
iii-directory. ADE hosts its page. The optional GitHub worker supplies pull
requests for repositories set on a Kanban project's Overview.

## Configuration

The worker registers the id provided by Compose in `III_CONFIG_NAME`, with
`control-plane` as the default. Open the gear in the Control plane page to set the
summary model and stall timeout.

| Key | Default |
| --- | --- |
| `stall_after_min` | `30` |
| `summary.model` | unset |
| `summary.interval_min` | `10` |
| `summary.reasoning` | unset (the model's default effort) |
| `summary.language` | `English` |
| `summary.guidance` | unset (free text: what the summary should focus on, its tone and length) |
| `prs.watched_interval_min` | `5` |
| `prs.idle_interval_min` | `30` |
| `escalate` | `{}` |
| `needs_you.card_labels` | `human-only`, `só humano`, `decisão` (open cards with one of these labels, or the "needs you" pill, show up in Needs you) |

An unset project escalation list means `security`, `publish`, `external_cost`
and `data`. To enable the summary, apply the `control-plane` kit so iii-directory
can resolve its `control-plane-writer` profile, then set `summary.model` to an
available `provider::model`.

## Functions and event

- `control-plane::overview {scope}` returns the Overview facts (tiles, Needs you, releases, runs, PRs, board), the latest valid summary and
  `prs_interval_min` (the watched PR interval used by the page freshness label).
- `control-plane::needs-you::list {scope}` returns questions and stalled roots.
- `control-plane::runs::list {scope}` returns scoped roots and context sizes.
- `control-plane::prs::list {scope}` returns cached open pull requests.
- `control-plane::decided::list {scope, cursor?}` pages settled questions.
- `control-plane::assumptions::list {scope, since?}` filters recorded assumptions by comment time.
- `control-plane::watch {scope}` watches the scope for two minutes.
- `control-plane::summary::refresh {scope}` requests a rate-limited writer turn.
- `control-plane::configuration-id {}` returns `{id}` for the worker's settings entry.
- `control-plane::on-changed {scope, as_of, parts}` announces changed read-model parts.

`scope` is `all` or a project id. `availability.github` indicates whether the
GitHub pull request functions are available.

## Source boundaries

Root metadata comes from `session::list`; context size comes from verbose
`harness::status`, with a cached messages-tail estimate when unavailable.
The read model does not call `session::get` or `harness::metrics`: revision 5's
explicit source allowance omits both, so run usage metrics remain absent.

The current GitHub wrappers expose `headRefName` and `updatedAt`, not a head
SHA. The source hash uses those fields plus check state.

Writer state uses scope `control-plane`, key `summary:<scope>`. Alongside `result`,
`valid_hash` and `checked_at`, it persists `pending_turn`, `send_order`,
`failures`, `last_attempt_at` and `last_send_at`. Scheduled sends and Refresh
reserve the same send budget. On startup, the worker reconciles a pending turn
with the writer session's current Harness status.

## Development

Run from this directory:

```sh
pnpm install
pnpm typecheck
pnpm lint
pnpm test
pnpm build:bundle
```

The worker uses the lockfile in this directory. The UI uses the root pnpm
workspace and its `@iii-dev/console-ui` package. `build:bundle` installs those UI
dependencies from the frozen root lockfile, runs the strict design lint and
build, and copies `page.js` and `styles.css` into `dist/bundle/` beside the worker.
The release lists all bundled files explicitly. Build from the monorepo
source or start the published artifact.

Run UI checks from `ui/` with the same environment:

```sh
pnpm --dir ../.. --filter @iii-workers/control-plane-ui run typecheck
pnpm --dir ../.. --filter @iii-workers/control-plane-ui run build
pnpm --dir ../.. --filter @iii-workers/control-plane-ui run test
```

Actions are console calls to the target workers.
Decision side chats use the optional host capabilities, and are hidden when the
host lacks them. Browsers sharing an engine can create duplicate copies if they
open the same decision concurrently, since the creation lock is browser-local.
The Overview follows the design canvas; the summary model is chosen with the chat's model picker.
Run usage metrics were removed because the read model does not supply them.
The worker UI has no Storybook setup; fixture tests and captures replace the
old ADE-only stories.

## skills

This version ships 1 skill file for agents, also browsable on the worker page:

- [`SKILL.md`](https://iii.dev/registry/workers/control-plane?tab=skills&skill=SKILL.md&version=0.0.2)

### SKILL.md

# control-plane

Control plane combines harness, kanban, session and optional GitHub facts into a
read-only project view. Use it when an agent needs the same scoped portrait as
the console without reproducing the aggregation and urgency rules.

The summary writer is optional and runs only when a model is configured. Pull
request data is unavailable when the GitHub worker is absent.

## When to Use

- Read the management-by-exception overview for one project or all projects.
- Find open decisions, assumptions, stalled roots or active runs in control plane order.
- Observe scoped changes instead of polling every underlying worker.

## Boundaries

- Control plane reads facts and refreshes its own summary.
- Use harness to resume runs, harness or kanban to answer questions, and GitHub
  for pull request actions.

## Functions

- `control-plane::overview` — read the Overview facts, live work and summary freshness for a scope.
- `control-plane::needs-you::list` — list urgent and non-urgent questions plus stalled roots.
- `control-plane::runs::list` — list scoped root runs with state and context size.
- `control-plane::prs::list` — list cached pull requests from configured project repositories.
- `control-plane::decided::list` — page through settled project decisions.
- `control-plane::assumptions::list` — list recorded assumptions, optionally since a timestamp.
- `control-plane::watch` — keep a scope actively refreshed for two minutes.
- `control-plane::summary::refresh` — request one rate-limited summary writer turn.
- `control-plane::on-changed` — emit the scope, timestamp and read-model parts that changed.

## Observing events

Observe `control-plane::on-changed` when another function should refetch only the parts
of a scope whose read model changed. It avoids polling all source workers.

Register the target function, then observe the event for the desired scope:

```typescript
iii.observe(
  {
    function_id: 'control-plane::on-changed',
    filters: { 'input.scope': { $eq: 'all' } },
    capture: ['output'],
  },
  'consumer::on-control-plane-changed',
)
```

Call `control-plane::watch` while a view is open; observing the change event alone does
not establish a repository watch lease. See the API reference for the event
payload and schemas.

## api reference

```json
{
  "functions": [
    {
      "description": "Read recorded assumptions, filtering since against the board comment creation time.",
      "metadata": {},
      "name": "control-plane::assumptions::list",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          },
          "since": {
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "as_of": {
            "type": "string"
          },
          "questions": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "questions",
          "as_of"
        ],
        "type": "object"
      }
    },
    {
      "description": "",
      "metadata": {
        "internal": true
      },
      "name": "control-plane::availability-updated",
      "request_schema": {
        "description": "The engine event payload.",
        "type": "object"
      },
      "response_schema": {
        "properties": {},
        "required": [],
        "type": "object"
      }
    },
    {
      "description": "",
      "metadata": {
        "internal": true
      },
      "name": "control-plane::config-updated",
      "request_schema": {
        "description": "The engine event payload.",
        "type": "object"
      },
      "response_schema": {
        "properties": {},
        "required": [],
        "type": "object"
      }
    },
    {
      "description": "Read the configuration id for this Control plane worker.",
      "metadata": {},
      "name": "control-plane::configuration-id",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {},
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "type": "object"
      }
    },
    {
      "description": "Open the scope's controller chat: one per project (and one for All projects) that reads everything and acts for the person after they confirm, with every function an agent may call. Creates the session on first use (and after the person deleted it) and returns its id for the console chat.",
      "metadata": {},
      "name": "control-plane::controller::open",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "created": {
            "type": "boolean"
          },
          "session_id": {
            "type": "string"
          },
          "thinking_level": {
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "created"
        ],
        "type": "object"
      }
    },
    {
      "description": "Read the board decision log and median decision wait over seven days, with an opaque next cursor.",
      "metadata": {},
      "name": "control-plane::decided::list",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "cursor": {
            "type": "string"
          },
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "as_of": {
            "type": "string"
          },
          "cursor": {
            "type": "string"
          },
          "median_decision_wait_ms": {
            "type": [
              "number",
              "null"
            ]
          },
          "questions": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "questions",
          "median_decision_wait_ms",
          "as_of"
        ],
        "type": "object"
      }
    },
    {
      "description": "Read one scope's bounded digest: board counts, releases, active and changed cards, the last day of activity, runs with their last message, what needs the person with its evidence, and open PRs. Start here instead of listing the board.",
      "metadata": {},
      "name": "control-plane::digest",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "type": "object"
      }
    },
    {
      "description": "Read what waits on the person: questions, stalled runs, cards marked for a person, chats ending on a question, and decisions the summary agent found; each with the agent check and recommendation when the writer has one. Ordered by urgency, cards blocked and age.",
      "metadata": {},
      "name": "control-plane::needs-you::list",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "as_of": {
            "type": "string"
          },
          "items": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "no_rush": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "now": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "items",
          "now",
          "no_rush",
          "as_of"
        ],
        "type": "object"
      }
    },
    {
      "description": "A cached Control plane view or summary changed. Refetch the named parts for this scope.",
      "metadata": {},
      "name": "control-plane::on-changed",
      "request_schema": {
        "properties": {
          "as_of": {
            "format": "date-time",
            "type": "string"
          },
          "parts": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "scope": {
            "type": "string"
          }
        },
        "required": [
          "scope",
          "as_of",
          "parts"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "as_of": {
            "format": "date-time",
            "type": "string"
          },
          "parts": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "scope": {
            "type": "string"
          }
        },
        "required": [
          "scope",
          "as_of",
          "parts"
        ],
        "type": "object"
      }
    },
    {
      "description": "Read the project portrait: factual tiles, questions, runs, PRs, releases, board and last valid summary.",
      "metadata": {},
      "name": "control-plane::overview",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "as_of": {
            "type": "string"
          },
          "availability": {
            "type": "object"
          },
          "board": {
            "type": [
              "object",
              "null"
            ]
          },
          "items": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "prs": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "prs_interval_min": {
            "type": "number"
          },
          "questions": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "releases": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "runs": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "summary": {
            "type": "object"
          },
          "tiles": {
            "type": "object"
          }
        },
        "required": [
          "as_of",
          "tiles",
          "items",
          "runs",
          "prs",
          "questions",
          "releases",
          "board",
          "summary",
          "availability",
          "prs_interval_min"
        ],
        "type": "object"
      }
    },
    {
      "description": "Read open PRs from Project.repos with per-PR as_of and deterministic wait reasons.",
      "metadata": {},
      "name": "control-plane::prs::list",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "as_of": {
            "type": "string"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "prs": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "prs",
          "as_of",
          "error"
        ],
        "type": "object"
      }
    },
    {
      "description": "Read root runs and their context_size in estimated tokens.",
      "metadata": {},
      "name": "control-plane::runs::list",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "as_of": {
            "type": "string"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "runs": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "runs",
          "as_of",
          "error"
        ],
        "type": "object"
      }
    },
    {
      "description": "",
      "metadata": {
        "internal": true
      },
      "name": "control-plane::source-changed",
      "request_schema": {
        "description": "The engine event payload.",
        "type": "object"
      },
      "response_schema": {
        "properties": {},
        "required": [],
        "type": "object"
      }
    },
    {
      "description": "Request a read-only writer turn now. If one is already running for the scope, join it (writing: true) instead of starting another.",
      "metadata": {},
      "name": "control-plane::summary::refresh",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "checked_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "result": {
            "type": [
              "object",
              "null"
            ]
          },
          "unavailable": {
            "type": "boolean"
          },
          "valid_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "writing": {
            "type": "boolean"
          }
        },
        "required": [
          "result",
          "valid_hash",
          "checked_at",
          "error",
          "unavailable",
          "writing"
        ],
        "type": "object"
      }
    },
    {
      "description": "",
      "metadata": {
        "internal": true
      },
      "name": "control-plane::turn-completed",
      "request_schema": {
        "description": "The engine event payload.",
        "type": "object"
      },
      "response_schema": {
        "properties": {},
        "required": [],
        "type": "object"
      }
    },
    {
      "description": "",
      "metadata": {
        "internal": true
      },
      "name": "control-plane::turn-started",
      "request_schema": {
        "description": "The engine event payload.",
        "type": "object"
      },
      "response_schema": {
        "properties": {},
        "required": [],
        "type": "object"
      }
    },
    {
      "description": "Mark a scope watched for two minutes and immediately refresh stale repository reads.",
      "metadata": {},
      "name": "control-plane::watch",
      "request_schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "additionalProperties": false,
        "properties": {
          "scope": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "scope"
        ],
        "type": "object"
      },
      "response_schema": {
        "properties": {
          "watched_until": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "watched_until"
        ],
        "type": "object"
      }
    }
  ]
}
```
