loopctl-mcp-server 3.20.3 → 3.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,15 +95,12 @@ first and answers with `code: "insufficient_role"` and `required_roles: ["orches
95
95
  which names the problem correctly.
96
96
 
97
97
  `report_story` and `review_complete` are NOT in this table: their gates take a role RANGE
98
- (`exact_role: [:agent, :orchestrator]` and `[:orchestrator, :user]`), so the
99
- `LOOPCTL_API_KEY` fallback is what makes the common agent configuration work — that is
100
- `LOOPCTL_API_KEY` set to an agent key. **`LOOPCTL_AGENT_KEY` alone is not that configuration
101
- for these two**: the priority above never consults `LOOPCTL_AGENT_KEY` by name, only a tool's
102
- own key, and `report_story` and `review_complete` both name `LOOPCTL_ORCH_KEY` as theirs — so
103
- with only `LOOPCTL_AGENT_KEY` set they answer "No API key configured" before reaching their
104
- gate. Most agent-facing tools do name `LOOPCTL_AGENT_KEY` as their own key and so do work
105
- under it alone; these two are the exception, and `story_stage` reads it explicitly for the
106
- same reason. The conditional pin in the first row is that same reasoning applied to the
98
+ (`exact_role: [:agent, :orchestrator]` and `[:orchestrator, :user]`), so they are not pinned
99
+ and take the default order (`lib/default-key.js`): `LOOPCTL_API_KEY`, then their own key
100
+ (`LOOPCTL_ORCH_KEY`), then the session's agent key (its holder credential once registered,
101
+ else `LOOPCTL_AGENT_KEY`). With only `LOOPCTL_AGENT_KEY` set they therefore send the agent key
102
+ and loopctl's gate decides: `report_story` accepts an agent key, `review_complete` refuses it
103
+ 403. The conditional pin in the first row is that same reasoning applied to the
107
104
  single-role gates.
108
105
 
109
106
  ## First-time setup — provision your BYO LLM keys
@@ -249,7 +246,7 @@ Epic 39 Repo Coordination Bus — a lightweight, tenant-isolated channel for age
249
246
  | `list_stories` | List stories for a project, optionally filtered by agent_status, verified_status, epic_id, or `issue_number` (the stories an intake issue with that number produced; 400 unless an integer in 1..2147483647) and `repo` (owner/name: an issue number is unique only within one repository). Pass `include_token_totals=true` for per-story token data. |
250
247
  | `list_ready_stories` | List stories that are ready to be contracted and worked on (`pending`, dependencies met, delivery stage not held). |
251
248
  | `list_blocked_stories` | List stories with an unverified dependency (their own, or their epic's), whatever their own status, each with what blocks it (`GET /api/v1/stories/blocked`). The queued ones are what the dispatch driver skips and `place_dispatch` refuses `409 dependencies_not_met`. Optional `project_id` (422 if not a UUID), `page`, `page_size`. Agent key or higher. |
252
- | `get_story` | Get full details for a single story by ID. |
249
+ | `get_story` | Get full details for a single story by ID, including its claim: `assigned_holder_id`, `claim_epoch`, `claimed_until`, and `assigned_holder` (`id`, `kind`, `host`, `session_id`, `lease_until`, `ended_at`, `ended_reason`), the session that holds it (US-52.20). |
253
250
  | `create_story` | Create a single story inside an existing epic. Use instead of wrapping a story in a bulk import. Accepts either `epic_id` (UUID) or (`project_id` + `epic_number`). |
254
251
  | `update_story` | **Correct a filed story** (`PATCH /api/v1/stories/:id`) — its `title`, `description`, `acceptance_criteria`, `estimated_hours` or `metadata`, and nothing else. `number` is fixed at creation and the two status fields are custody state with their own gated endpoints. **Sending `metadata` REPLACES THE WHOLE MAP** — there is no merge on this path, so a partial send silently drops every key you left out and answers 200. Read the story first (`get_story`), then send the complete map; `acceptance_criteria` is replaced whole for the same reason. The one key it can no longer erase is `lifecycle_entered_at`, which is a COLUMN precisely because it used to live in metadata and one ordinary PATCH erased it, restoring the claim -> force-unclaim -> backfill-to-verified launder. A field cannot be set to `null` either: the controller drops every nil before the changeset, so `null` is refused here rather than answering 200 unchanged, and so is an `estimated_hours` no decimal parser accepts. Requires orchestrator role or higher (`LOOPCTL_ORCH_KEY`, or `LOOPCTL_API_KEY` of that role) on a human-anchored tenant. |
255
252
  | `list_epics` | **List a project's epics** (`GET /api/v1/projects/:project_id/epics`, loopctl #876): each epic's `id`, `number`, `title`, `description`, `phase`, `position`, `metadata`, `story_count` and `completion_percentage`, paginated, optionally filtered by `phase`. The way to learn an epic id, e.g. an intake source's `target_epic_id`. Any key. |
@@ -267,8 +264,8 @@ Epic 39 Repo Coordination Bus — a lightweight, tenant-isolated channel for age
267
264
  | Tool | Description |
268
265
  |---|---|
269
266
  | `contract_story` | Agent acknowledges a story's acceptance criteria. Transitions pending -> contracted. Refused 409 `story_held` when the story's delivery stage is `escalated`, `done` or `failed` — it is not available to agents even when it reads `pending`; an escalated story becomes available again only after `resolve_escalation` sends it to `queued`. |
270
- | `claim_story` | Agent claims a contracted story with pessimistic locking. Transitions contracted -> assigned. On a loopctl with claim leases the result leads with the claim's `claim_epoch` and `claimed_until`; keep the epoch for `renew_story_claim`. Both are absent on an older server. Refused 409 `story_held` when the story's delivery stage is `escalated`, `done` or `failed` — even when it reads `pending` or `contracted`; an escalated story is claimable again only after `resolve_escalation` sends it to `queued`, a done or failed one never is. Refused 409 `chg_root_review_only` when the key descends from an intake source's `chg_root_dispatch_id`: chg-server's keys may only review. |
271
- | `renew_story_claim` | Renew your claim's lease (`POST /stories/:id/renew-claim`, agent key). A claim not renewed before `claimed_until` (default 24 hours, `STORY_CLAIM_LEASE_SECONDS`) is released back to `pending` under you, so renew well inside it on any story held longer. A driver-placed claim — one a placement took for a runner dispatch — is capped at its dispatch deadline (`claim_lease_cap`: placed_at + `wall_clock_seconds` + `DISPATCH_LEASE_GRACE_SECONDS` at the claim, sent to the runner as `deadline_at`; moved forward to a resume's time or the runner's acceptance + `wall_clock_seconds` + the grace, only while the claim is live; never earlier than a `deadline_at` already sent), and its `claimed_until` already IS that cap: renewing it writes nothing and returns the claim as it stands, never moving `claimed_until` past it. Required: `story_id`, `claim_epoch` (from the claim). Refusals pass through: 400 epoch missing or malformed, 422 `not_claimed`, 409 `stale_claim_epoch` (the claim has ended: stop working it), 409 `not_claimant`, 409 `lease_cap_reached` (a driver-placed claim already at its cap: nothing is renewed, stop working it). Needs a loopctl server with claim leases. |
267
+ | `claim_story` | Agent claims a contracted story with pessimistic locking. Transitions contracted -> assigned. On a loopctl with claim leases the result leads with the claim's `claim_epoch` and `claimed_until`; keep the epoch for `renew_story_claim`. Both are absent on an older server. Refused 409 `story_held` when the story's delivery stage is `escalated`, `done` or `failed` — even when it reads `pending` or `contracted`; an escalated story is claimable again only after `resolve_escalation` sends it to `queued`, a done or failed one never is. Refused 409 `chg_root_review_only` when the key descends from an intake source's `chg_root_dispatch_id`: chg-server's keys may only review. A claim by a holder credential takes the holder's `lease_until` and no cap (US-52.19); `409 holder_lease_expired` when that lease has run out or the holder ended. |
268
+ | `renew_story_claim` | Renew your claim's lease (`POST /stories/:id/renew-claim`, agent key). A claim not renewed before `claimed_until` (default 24 hours, `STORY_CLAIM_LEASE_SECONDS`) is released back to `pending` under you, so renew well inside it on any story held longer. A driver-placed claim — one a placement took for a runner dispatch — is capped at its dispatch deadline (`claim_lease_cap`: placed_at + `wall_clock_seconds` + `DISPATCH_LEASE_GRACE_SECONDS` at the claim, sent to the runner as `deadline_at`; moved forward to a resume's time or the runner's acceptance + `wall_clock_seconds` + the grace, only while the claim is live; never earlier than a `deadline_at` already sent), and its `claimed_until` already IS that cap: renewing it writes nothing and returns the claim as it stands, never moving `claimed_until` past it. Required: `story_id`, `claim_epoch` (from the claim). Refusals pass through: 400 epoch missing or malformed, 422 `not_claimed`, 409 `stale_claim_epoch` (the claim has ended: stop working it), 409 `not_claimant`, 409 `lease_cap_reached` (a driver-placed claim already at its cap: nothing is renewed, stop working it). A claim taken by a holder credential (US-52.19) lives by the holder's lease instead: renewing it writes the holder's `lease_until`, and the heartbeat already moves it; `409 holder_lease_expired` when the holder has lapsed. Needs a loopctl server with claim leases. |
272
269
  | `escalate_story` | Park a story you hold for a HUMAN and stop (`POST /stories/:id/escalate`, agent key). This is what an unattended session calls INSTEAD of asking a question — a headless run has no way to ask, so escalating is the affordance. Use it when the request contradicts an existing story, KB decision or documented behaviour, when it inverts or removes behaviour a previous story deliberately added, when it is a workflow change rather than a defect fix, or when it needs a business call — not for an ordinary blocker. ONE-WAY from your side: only a human moves the story off `escalated`, so on success STOP and report. Required: `story_id`, `claim_epoch`, `reason` (verbatim, treated as untrusted data, length capped by the server in codepoints — a 400 names the bound); optional `payload` object. Idempotent under the same epoch. Refusals pass through: 409 `stale_claim_epoch`, 409 `not_claimant`, 404 `unknown_story_stage`, 400 for a malformed epoch or reason. An orchestrator or user key is 403'd on purpose. |
273
270
  | `start_story` | Agent starts work on a claimed story. Transitions assigned -> implementing. |
274
271
  | `request_review` | Agent signals implementation is complete and ready for review. |
@@ -547,7 +544,7 @@ The order to wire it up, the stage machine these tools move a story through, and
547
544
  | `resolve_escalation` | **Move an escalated story off `escalated`, as a human** (`POST /api/v1/stories/:id/stage/resolve`): `to` is `detected` (triage it again), `queued` (work it again), `done` or `failed`. `detected` is for a story triage escalated, such as `triage_verdict:verdict_invalid`. It is refused 409 `not_retriageable`, with what the story holds in `held`, for a story an implementer was assigned or worked. `queued` on a triage escalation skips triage. The other half of `escalate_story` — without it a parked story stays parked for ever. Requires `LOOPCTL_USER_KEY` on a key no dispatch minted: a session cannot resolve the escalation it raised. Optional: `reason`. |
548
545
  | `escalation_list` | **The escalation inbox** (`GET /api/v1/escalations`, loopctl US-48.11): every story of your tenant parked at `escalated`, newest escalation first, so a timed-out or failed implementation can be found and worked again. **Reads only** — `resolve_escalation` with `to: "queued"` is what works a row again. Each row: `story_id`, `project_id`, `escalated_at`, `edge`, `reason_class`, `spec` (`{id, version}` of the dispatch that parked it, or null), `dispatch_id`, and `escalation_reason`, which is untrusted session text: read `escalation_reason_fenced`. `reason_class` comes from the stage-machine edge, never from text: `budget_exhausted`, `session_failed`, `triage_escalated`, `gate_refused`, `operator_released`, `other`. A `budget_exhausted` row carries `run`: `elapsed_seconds`, `wall_clock_seconds`, `turns_used` against `max_turns` (the budget it was placed under), `branch`, `session_ended_reason`, `work_left_behind` (from the ledger and the runner's session-end report: `"true"` or `"false"` as the runner reported unpushed commits at exit, `"unknown"` when it did not say — a runner older than contract 1.27.0, or one that could not tell; `turns_used` is then null too). Optional: `reason_class`, `project_id` (UUID), `since` (ISO8601), `cursor` (a page's `next_cursor`, verbatim), `limit` (default 50, at most 100). Any tenant key reads it (`role: :agent` with the hierarchy): `LOOPCTL_API_KEY` when set, else `LOOPCTL_AGENT_KEY`, else `LOOPCTL_ORCH_KEY`. 400 for an unknown `reason_class`, a bad `since` or `limit`, or a foreign or tampered cursor; 422 for a malformed `project_id`; no role is refused. The MCP server adds `remedies` to the page, holding each present `reason_class`'s text once (`meaning`, `options`: which `resolve_escalation` target fits, in order, and `take_over`), and a `remedy` to every row: `see` (its `remedies` key), a `warning` when the change already merged, and `salvage` when the runner left unpushed commits. |
549
546
  | `escalation_playbook` | **What to do with a stuck story**, from finding it to closing it: what each `reason_class` means, which `resolve_escalation` target fits (`queued` run again, `detected` triage again, `done` accept, `failed` drop), and the steps to take a story over in this session: leave it escalated, do not `claim_story`, salvage the runner's branch when `run.work_left_behind` is `"true"`, fix it through the normal delivery loop with a PR that says `Fixes #<issue>`, then `resolve_escalation` `to: "done"` citing the PR. Optional: `reason_class`. Local: sends nothing, needs no key. Same text as the `stuck_story` prompt. |
550
- | `force_unclaim_story` | **Take a story back from the agent holding it** (`POST /api/v1/stories/:id/force-unclaim`). Resets it to `agent_status: pending` with `assigned_agent_id` cleared AND makes the delivery stage row follow the release back to `queued`. **A delivery story then goes to `escalated`, not back to the queue** (loopctl US-44.4): an operator taking a story back is a human decision, so a release that leaves the stage row at `queued` escalates it over `operator_released` in the same transaction, spending no attempt against the retry ceiling — it is not left in the queue behind the human's back. Put it back to work with `resolve_escalation` `to: queued`, which releases (a no-op by then) AND re-contracts. A story with no delivery stage row is simply left `pending`. A story parked at `claimed` with nobody on it is the residue of a compensation that did not complete, not what a refused dispatch normally leaves: placement releases the claim inline when a runner refuses, and the claim lease releases it unattended once `claimed_until` passes — reach for this to get it back now, or when both of those left it held. Requeues from any stage a claim holds; a stage no claim holds keeps its stage and is rebound to the new epoch; `done` and `failed` are untouched. For an ESCALATED story use `resolve_escalation` instead — that one releases AND re-contracts, so its `queued` really is placeable. Requires an orchestrator-ROLE key: the action is `exact_role: :orchestrator`, so a user or superadmin key is 403'd like any other non-member. Put it in `LOOPCTL_ORCH_KEY` (which is then the key sent, and a global `LOOPCTL_API_KEY` does not displace it) or, with no orchestrator key set, in `LOOPCTL_API_KEY`. The orchestrator key must be linked to a registered agent (400 otherwise) and the tenant must be human-anchored (403 `custody_tier_required` otherwise). Does not touch `verified_status`. Run again on an already-pending story it is still an operator's release: a row stranded behind the story's claim epoch is rebound, an in-flight row is requeued, and a row then at `queued` — including one already sitting there — is escalated over `operator_released`, as on the first run; a row already escalated, or anywhere else at that epoch, is left alone. Every 500 means the whole release rolled back and the story is still claimed: `audit_chain_append_failed` (the escalation's chain entry was refused) is a server-side condition a re-run meets again until an operator acts; `force_unclaim_failed` (the server log names the step) — call it again. A 422 means the release write itself was rejected. No request body. Required: `story_id` (refused locally if it is not a UUID). |
547
+ | `force_unclaim_story` | **Take a story back from the agent holding it** (`POST /api/v1/stories/:id/force-unclaim`). Resets it to `agent_status: pending` with `assigned_agent_id` cleared AND makes the delivery stage row follow the release back to `queued`. **A delivery story then goes to `escalated`, not back to the queue** (loopctl US-44.4): an operator taking a story back is a human decision, so a release that leaves the stage row at `queued` escalates it over `operator_released` in the same transaction, spending no attempt against the retry ceiling — it is not left in the queue behind the human's back. Put it back to work with `resolve_escalation` `to: queued`, which releases (a no-op by then) AND re-contracts. A story with no delivery stage row is simply left `pending`. A story parked at `claimed` with nobody on it is the residue of a compensation that did not complete, not what a refused dispatch normally leaves: placement releases the claim inline when a runner refuses, and the claim lease releases it unattended once `claimed_until` passes — reach for this to get it back now, or when both of those left it held. Requeues from any stage a claim holds; a stage no claim holds keeps its stage and is rebound to the new epoch; `done` and `failed` are untouched. For an ESCALATED story use `resolve_escalation` instead — that one releases AND re-contracts, so its `queued` really is placeable. Requires an orchestrator-ROLE key: the action is `exact_role: :orchestrator`, so a user or superadmin key is 403'd like any other non-member. Put it in `LOOPCTL_ORCH_KEY` (which is then the key sent, and a global `LOOPCTL_API_KEY` does not displace it) or, with no orchestrator key set, in `LOOPCTL_API_KEY`. The orchestrator key must be linked to a registered agent (400 otherwise) and the tenant must be human-anchored (403 `custody_tier_required` otherwise). Does not touch `verified_status`. Run again on an already-pending story it is still an operator's release: a row stranded behind the story's claim epoch is rebound, an in-flight row is requeued, and a row then at `queued` — including one already sitting there — is escalated over `operator_released`, as on the first run; a row already escalated, or anywhere else at that epoch, is left alone. Every 500 means the whole release rolled back and the story is still claimed: `audit_chain_append_failed` (the escalation's chain entry was refused) is a server-side condition a re-run meets again until an operator acts; `force_unclaim_failed` (the server log names the step) — call it again. A 422 means the release write itself was rejected. Required: `story_id` (refused locally if it is not a UUID). Optional: `reason`, recorded on the story's event log as `force-unclaimed: <reason>` (at most 2000 characters); without it the log says `force-unclaimed: operator`. |
551
548
  | `merge_precondition` | **Run the merge gate over a story's real pull request** (`POST /api/v1/stories/:id/merge-precondition`). Both delivery gates run again over the diff that exists, plus custody, the 12-file / 1000-line hard bound, the head-has-not-moved check and the self-deploy exclusion; the story must be at stage `ci`. **Gate A reads what triage persisted, never the caller**: the lens verdicts recorded with the story's most recent triage, or a human's re-queue of a Gate A escalation — `gate_a_inputs` on the answer says which, and `missing` refuses with `gate_a_inputs_missing`. This tool sends no trio. Decisions: `allow` (recorded against the head; the only thing that licenses a merge), `refuse` (the story is escalated before this returns), `already_merged`, `head_moved`, `unevaluated` (503 with `Retry-After`). Requires an orchestrator- or user-ROLE key (`exact_role: [:orchestrator, :user]`, so an agent key is 403'd); `LOOPCTL_ORCH_KEY` is sent when set, else `LOOPCTL_API_KEY`. 403 `custody_tier_required` without a human anchor, 404 for an unknown story, 409 `change_protocol_enrolled` when the story's intake source is in mode `chg` (the PR route is closed; land with `chg submit` — decided before any GitHub read, nothing escalated), 422 when the story is not at `ci`. Required: `story_id` (refused locally if not a UUID) and `claim_epoch` (a non-negative integer, refused locally otherwise); optional `effect_proof`. |
552
549
  | `intake_source_enroll` | **Bind a GitHub repository to a work project and mint its webhook secret** (`POST /api/v1/intake/sources`) — the step that gives the delivery loop an input, and the row `place_dispatch` reads `repo` and `base_branch` from (its 409 `no_intake_source` means this has not been done; 409 `ambiguous_intake_source` means it has been done twice). **The secret is returned ONCE and can never be read again** — the column is encrypted at rest and redacted on the schema, so no other tool carries it and losing it costs a revoke, a re-enrolment and a reconfigured GitHub webhook. **This tool does not return it either:** a tool result lands in the transcript and the audit log, so it is written to the required `secret_file` with mode 0600 (the handling `runner_enroll` gives a runner credential) and the result carries the source row, the `webhook_url` and that path. The path is reserved before the request, so an existing file or an unwritable directory is refused with nothing enrolled, and any outcome that is not a clean creation withholds the response body — an unparsed 2xx body IS the secret. A 2xx carrying the source and the secret but no webhook path is RECOVERED rather than discarded (the path is derived from the source id, flagged `webhook_url_derived`), and an outcome that proves a source id but no usable secret REVOKES that source rather than leaving it holding the repository's unique slot. Then configure GitHub: Payload URL = the returned `webhook_url`, content type `application/json`, Secret = the contents of the file, and the **Issues** and **Pull requests** events (a merged pull request queues a read of its `## Review findings` section) — `gh api repos/OWNER/REPO/hooks -f name=web -f config[url]=<webhook_url> -f config[content_type]=json -f config[secret]="$(cat <secret_file>)" -f 'events[]=issues' -f 'events[]=pull_request'`. Every later delivery failure is the SAME 401 `invalid_signature` — unknown or revoked source, suspended tenant, missing or wrong signature, or a payload whose `repository.full_name` does not match — so the webhook's Recent Deliveries tab cannot tell you which. `base_branch` is set HERE: it defaults to `master` when the body does not name it, so name `main` for a repository created on GitHub since 2020 or every dispatch is cut from a trunk that does not exist. It is not nullable (a dispatch must name a branch), so null or blank is refused rather than falling back to the default, and `intake_source_update` changes it afterwards. Refusals: 403 `api_key_mint_forbidden` if your key was minted by a dispatch (this mints a credential belonging to no lineage, so only an unlineaged operator key may), 403 `custody_tier_required` on an agent-rooted tenant, 422 for a repository that is not `owner/name`, an ACTIVE source already binding it, a project that is missing / archived / the wrong kind for the mode, or a `target_epic_id` outside that project. `mode` is the merge route: `pr` (the default when omitted; the merge gate reads a pull request) or `chg` (Epic 47: the change protocol lands the repository's changes with `chg submit`, and `merge_precondition` refuses every story on the source with 409 `change_protocol_enrolled`), both on a work project; or `ledger` (loopctl #1047), which enrols a repository for the chg ledger alone: `project_id` is then its active KB scope (`create_kb_scope`), or its active work project when that project has no intake route (its stories stay unbound), the source is never a dispatch binding (`place_dispatch` and candidate selection skip it), and GitHub deliveries to it are refused. Any other value, null included, is refused. **Sending is not routing:** the two chg credentials authenticate the ledger and change-event endpoints in every mode, so a `pr` source holding them sends its ledger too and stays `pr` — its events are recorded and move no story. A `chg` or `ledger` enrolment needs `change_events_secret` (or, preferred, `change_events_secret_file`, a path the tool reads so the value never enters the transcript) AND a root in the same call — `mint_chg_root: true` (preferred: loopctl mints a keyless, agentless root in the same write and returns its id) or `chg_root_dispatch_id` — refused locally and 422 at the server without them, and 422 with both. A root minted with `dispatch` takes its agent's one orchestrator-key slot, so it is 422 when that agent already holds a live key; the expiry sweep never revokes the row of a root a live source names. A named root that is not a parentless, unrevoked, orchestrator-role dispatch of this tenant with more than 300 s left before it expires is 422 `chg_root_invalid` (a child, a revoked or agent-role dispatch, another tenant's and an unknown id all alike). The change-events secret is write-only: no response and no tool result ever carries it. `required_checks` are the CI checks story verification judges a story's commit by, GitHub Actions job names, bounded in number and length by the server; `local-gate` is refused because whoever pushed posts it. Story verification judges a story's commit against the same `required_checks` in EITHER mode, satisfied only by a job of a push run of the story's branch; it first needs a GitHub credential for this tenant, its own token (`set_github_credential`) or an entry in the operator's `VERIFICATION_OPERATOR_TOKEN_TENANTS` (`credential_unavailable` otherwise, whatever the list holds); then a `pr` source that names none records `no_required_checks` and reads nothing, so naming them is how a pr source opts in, and a source that names some has its (tenant, repository) credential resolved before any GitHub read (`credential_unavailable` if there is none). Required: `repo_full_name`, `project_id`, `secret_file`. `triage_requires_ticket` decides which issues are triaged at all: false (the default), every issue the webhook delivers; true, only an issue HomeCareBilling filed from a support ticket (its single `#HCB-xxxxxxxx` Ticket line confirmed by the HomeCareBilling footer, which intake records as `ticket_id`), and every other issue stays an intake record with no story until it gains a ticket; anything but a boolean is refused. It filters on the format, it does not authenticate: anyone who can open an issue can type it. Optional: `base_branch`, `mode`, `required_checks`, `triage_requires_ticket`, `change_events_secret` / `change_events_secret_file`, `chg_root_dispatch_id` or `mint_chg_root`, and `target_epic_id` — **omitting the epic is not a neutral default**: with no epic every triaged report is escalated to a human and every record stays `pending_triage` until `intake_source_update` names one. Requires `LOOPCTL_USER_KEY`. |
553
550
  | `intake_source_list` | List the tenant's intake sources (`GET /api/v1/intake/sources`): `id` (the webhook URL is `/api/v1/intake/github/<id>`), `project_id`, `repo_full_name`, `base_branch`, `mode` (`pr`, `chg` or `ledger`), `required_checks`, `triage_requires_ticket`, `chg_root_dispatch_id`, `target_epic_id`, `revoked_at`, timestamps. **The webhook secret is not here and is not anywhere**, and neither is a `chg` source's change-events secret — it is returned once by `intake_source_enroll`, so this is not how to recover one. Use it to find the source behind a 409 `no_intake_source` or `ambiguous_intake_source`, to check a repository's `base_branch` before placing work, and to identify a source left behind by an enrolment whose outcome was unknown. Optional: `include_revoked`. Requires `LOOPCTL_USER_KEY`; the only one of the four that does not also need a human-anchored tenant. |
@@ -562,6 +559,12 @@ Key distribution for the dispatch pattern (Epic 26): per-dispatch ephemeral keys
562
559
  |---|---|
563
560
  | `signup` | **US-26.7.1.** Create a NEW **agent-rooted (KB-tier)** tenant and mint its one-time root API key — entirely through this call, no human operator, no hardware authenticator, no existing API key required. The tenant gets the FULL knowledge-wiki surface but **cannot** perform work-breakdown / chain-of-custody operations (those require a separate human-anchored tenant via the WebAuthn ceremony at `https://loopctl.com/signup`). Rate-limited per client IP (<= 5/hour). The `raw_key` is shown ONCE — save it immediately (e.g. as `LOOPCTL_USER_KEY`). Required: `name`, `slug`, `email`. |
564
561
  | `dispatch` | Mint an ephemeral, scoped api_key for a sub-agent dispatch, carrying its lineage path. The `raw_key` is returned ONCE — pass it to the sub-agent's launch args, never store it in env vars; it expires after `expires_in_seconds` (default 3600, max 14400). Required: `role` (`agent`/`orchestrator`), `agent_id`, and `parent_dispatch_id` for every caller a dispatch minted — a dispatch may only be minted INSIDE the caller's own lineage. Omitting `parent_dispatch_id` requests a ROOT dispatch (a new independent lineage tree), which only the tenant's `user`-role operator key may create; anyone else gets `403 root_dispatch_forbidden` with their own dispatch id in `remediation.your_dispatch_id`. A parent outside the caller's lineage is `403 parent_outside_caller_lineage`. Optional: `story_id`. **LCP-1 §9.2 signed profile:** optionally enroll an agent key via `agent_pubkey` (hex) + `alg` + an `attestation` (from `custody_sign_attestation`) + `attestation_conditions`. |
562
+ | `holder_register` | **Register this session as a holder** (`POST /api/v1/holders`, US-52.13). The server does this at startup and heartbeats on a timer; call it to re-register after `holder_end`. Sends `LOOPCTL_AGENT_KEY` exactly, with `kind: interactive`, the session id (`CLAUDE_CODE_SESSION_ID`, else `CLAUDE_SESSION_ID`, else a per-process uuid), the host and the git top level. A live holder of the same session answers with the SAME holder and a new credential, which this process keeps in memory and sends on every agent-key request; the raw key is never returned to the caller. `403 custody_tier_required` on an agent-rooted tenant, `403 holder_mint_forbidden` for a dispatch-minted key, `422 agent_required` for a key naming no agent; on any refusal the session keeps using `LOOPCTL_AGENT_KEY`. |
563
+ | `holder_heartbeat` | **Renew this session holder's lease now** (`POST /api/v1/holders/:id/heartbeat`), by the holder's own credential. Runs on its own every `heartbeat_seconds`. Also moves every uncapped claim this holder holds to the new lease (US-52.19). A 401, 404 or 409 (credential expired, holder ended) registers again; a `409 holder_lease_expired` means the lease ran out first, so loopctl ended the holder and released its claims: the session registers as a NEW holder (logged to stderr) and must re-claim. |
564
+ | `holder_end` | **End this session holder** (`POST /api/v1/holders/:id/end`): sets `ended_at`, revokes its credential and releases every uncapped claim it holds (a `released` item event, reason "holder ended"), then falls back to `LOOPCTL_AGENT_KEY`. Runs on its own when stdin closes or on SIGTERM. A repeated end writes nothing. |
565
+ | `work_item_note` | **Write a note on a work item** (`POST /api/v1/stories/:id/notes`, US-52.17): `section` (plan, progress, decision, question) and `body`, appended and never edited, plus a `note_written` event on the story log in the same transaction. Sends this session's own key (its holder credential). Only the story's current holder writes one: `409 held_by_other_holder` when another session holds it, `409 not_holder` when nobody does, `404` for another tenant's story, `422` for an unknown section, an empty body, a body over 16384 bytes or a credential-shaped body. A writer repeating its own `idempotency_key` gets its first note back; a key another writer's note already carries is `409 idempotency_key_reused`. |
566
+ | `work_item_notes` | **Read a work item's notes** (`GET /api/v1/stories/:id/notes`), oldest first; the first page carries `current`, the newest note of each section. Optional `section`, `limit` (default 50, max 200) and `after` (a page's `next_cursor`). `404` for another tenant's story, `422` for an unknown section or a cursor it did not return. |
567
+ | `work_item_open` | **Open the work item for a branch** (`POST /api/v1/work_items`, US-52.18): `repo_url` and `branch`, optional `title` (default: the branch) and `epic_id` (default: the target epic of the project's live intake source). Creates one story already implementing and held by this session, with a stage row naming the branch; the MCP server also does it on each heartbeat for the worktree's non-default branch, once per branch per holder. Reopening your own item, or an unheld one, returns it (200). Needs this session's holder credential: `403 holder_credential_required` otherwise. `409 branch_held` (another session's open item has the branch), `409 holder_ended`, `409 holder_lease_expired`, `409 story_held`, `404 project_not_found`, `404 epic_not_found`, `422 no_target_epic` (pass `epic_id`), `422 invalid_branch`. |
565
568
  | `revoke_dispatch` | **Revoke a dispatch AND ITS WHOLE SUBTREE** (`POST /api/v1/dispatches/:id/revoke`), plus the ephemeral api_key each one minted — the revoke matches the dispatch OR any row carrying it in `lineage_path`, so name a LEAF unless you mean the subtree. Reach for it when a dead session's key is blocking new work: an un-revoked key OCCUPIES its agent's slot in the partial unique index `api_keys_one_role_per_agent_idx` (`(tenant_id, agent_id, role)` WHERE `revoked_at IS NULL`), which cannot also test `expires_at` — a partial-index predicate must be IMMUTABLE and `now()` is STABLE — so even an EXPIRED key holds it and the next mint answers `422 agent already has an active key with this role`. Waiting works too, slowly: the expired-dispatch sweep runs every minute and the expired-api-key sweep every five, so the slot clears at the TTL (four hours for a placement session dispatch). For a PARKED STORY prefer `force_unclaim_story`, which revokes that story's own session dispatch and frees the stage as well. It does NOT clear `implementer_dispatch_id`: that is custody provenance, and a revoked dispatch still resolves, so verify/report/review-complete compare the same lineage afterwards. `role: :orchestrator` WITH the hierarchy (orchestrator, user or superadmin all pass; an agent key is `403 insufficient_role`), so no env var is pinned — `LOOPCTL_USER_KEY` is merely PREFERRED, for the ceiling reason next. `403 dispatch_outside_caller_lineage` when the target is not in your lineage — a dispatch may only be revoked by a caller it descends from, because the revoke cascades; the body carries `remediation.your_dispatch_id`, and the tenant's `user`-role operator key may revoke anywhere in its tenant. `403 unlineaged_revoke_forbidden` when your key was minted by no dispatch and is below `user` role — a legacy `LOOPCTL_ORCH_KEY` is exactly that, and with no lineage there is no subtree that would bound a cascading revoke, so it could otherwise revoke the tenant's root; use the operator key, or `force_unclaim_story` for a parked story, or mint a dispatch under an active parent and revoke from inside that lineage. `403 custody_tier_required` on an agent-rooted tenant, `503 tenant_halted` under a custody halt, 404 for an unknown dispatch or another tenant's. Idempotent: an already-revoked dispatch answers 200 with `revoked_count: 0` and its ORIGINAL `revoked_at`. Required: `dispatch_id` (refused locally if it is not a UUID). |
566
569
  | `register_custody_owner_key` | **LCP-1 §9.2.** Register/rotate the tenant custody OWNER key — the root of trust the attestation chain hangs from. Private half stays with you; requires `LOOPCTL_USER_KEY` and a human-anchored tenant. Required: `owner_pubkey` (hex). ROTATION additionally requires `rotation_proof` (from `custody_sign_owner_rotation`); first registration needs none. |
567
570
  | `list_enrolled_agent_keys` | **LCP-1 §9.1.1 transparency.** List the agent public keys enrolled under your tenant, reconstructed from the tamper-evident audit chain (not a mutable listing). Compare against the keys you generated; any excess is operator-minted. Keyset-paged (`limit`, `cursor`). |