loopctl-mcp-server 3.49.0 → 3.50.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
@@ -661,6 +661,7 @@ Key distribution for the dispatch pattern (Epic 26): per-dispatch ephemeral keys
661
661
  | `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`. Every note carries a client UUIDv7 `event_id` (US-52.62); when loopctl does not answer (network error, timeout, 502/503/504) the note is journaled (`LOOPCTL_JOURNAL_DIR`) and answered `{queued: true, event_id}`, then replayed in order through `holder_replay`; while the journal holds entries a new note queues behind them. The journal entry needs the `claim_epoch` (optional argument; else the one the session last saw, else read from the story once). |
662
662
  | `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. |
663
663
  | `work_item_checkpoint` | **Checkpoint a work item** (`POST /api/v1/stories/:id/checkpoints`, US-52.41): computes from `worktree` the branch, the commit its work applies to (the pushed head, else the merge-base with origin's default branch) and `git diff --binary` on top of it with untracked files, without writing to the worktree, and records them with one progress note from `done` and `next` and a `checkpointed` event. Sends this session's own key (its holder credential): only the current holder at the story's `claim_epoch` (read from the story when omitted) with a live lease. `409 not_holder` (names the holder), `409 stale_claim_epoch`, `409 claim_lease_expired`, `409 checkpoint_id_conflict`, `403 holder_credential_required`, `404` for another tenant's story; `413 diff_over_bound` over 4 MiB (push a `wip/...` branch and pass `wip_branch` instead); `422 secret_in_diff` (names the files), `422 diff_and_wip_branch`, `422 invalid_wip_branch`. A repeated `checkpoint_id` with the same content returns the stored checkpoint (`replayed: true`). A checkpoint from a claim that has ended (the epoch you held, after the item moved on) is stored fenced and answered `202` (`fenced: true`, `current_holder_id`), with no note and no change to the item, for the current holder to resolve (US-52.42). Past 5 unresolved fenced checkpoints from you on one item, or 10 on the item from all late holders, a late checkpoint is `409 fenced_checkpoint_limit` (`limit_scope`, `max_unresolved_fenced`) and nothing is stored: push a `wip/...` branch instead. The checkpoint id is a client UUIDv7 unless given (US-52.62); one that gets no answer from loopctl is journaled under the epoch the session last saw and answered `{queued: true, event_id}`, unless it is too large for one replay body (about 1.5 MB encoded): then push a `wip/...` branch. |
664
+ | `work_item_checkpoints_fenced` | **List the tenant's unresolved fenced checkpoints** (`GET /api/v1/checkpoints?fenced=unresolved`, #1298): every fenced checkpoint a late holder left on any work item that nobody has applied or ignored yet, oldest first, each with `checkpoint_id`, `story_id`, `project_id`, `title`, `holder_id` and `host` of the late holder, `head_sha`, `wip_branch`, `diff_bytes`, `summary` (`summary_untrusted: true`) and `inserted_at`. Never the diff; `work_item_checkpoints` with a `checkpoint_id` reads it. Paged: pass `next_cursor` back as `cursor`; `limit` 1..200, default 50. Read-only on any key of the tenant. `400` for a bad `limit` or a cursor not issued to this tenant. |
664
665
  | `work_item_checkpoints` | **Read a work item's checkpoints**: the newest 20, newest first, without diffs (`GET /api/v1/stories/:id/checkpoints`), with `fenced: "unresolved"` the fenced ones nobody resolved yet, oldest first, or with `checkpoint_id` one checkpoint with its diff base64 (`GET .../checkpoints/:checkpoint_id`), which `git apply` takes on a checkout of its `head_sha`. Any key of the tenant. `404` for another tenant's story or checkpoint. |
665
666
  | `work_item_checkpoint_resolve` | **Apply or ignore a fenced checkpoint** (`POST /api/v1/stories/:id/checkpoints/:checkpoint_id/resolve`, US-52.42): `resolution` (`applied` or `ignored`) and a `reason`, on this session's own key; only the story's current holder with a live lease. The same resolution again is `200` and writes nothing. `409 not_holder` (names `holder_id`), `409 already_resolved`, `422 not_fenced`, `403 holder_credential_required`, `404` for a checkpoint not on this tenant's story. |
666
667
  | `work_item_move` | **Move a work item** to a host, a holder, the cloud or the loop (`POST /api/v1/stories/:id/move`, US-52.43), on this session's own key; the server picks the path from who calls. The holder (live lease) names its own `checkpoint_id` at the current epoch and the claim is released at once over the uncounted `:moved` edge: `200 released`. Anyone else REQUESTS it: the holder is told on the item's thread and has `MOVE_RELEASE_SECONDS` to answer with the same `move_id`, after which the deadline worker releases it: `202 requested`. An unheld item is released at once: `200`. While reserved only the target claims it (`409 reserved_for_move`); a move to a host, holder or the cloud unpulled after `MOVE_PULL_SECONDS` expires to the loop, and a move to the loop never expires: implement@1 places it with the move's checkpoint as `resume`, on a runner of contract 1.40.0 or later (US-52.46). An item an interactive session released is reserved for any interactive session until someone moves it on. A move to a host whose runner joined on contract 1.40.0 or later is placed there and resumes from the move's checkpoint (US-52.44); a runner session holding the item is asked over its runner's socket. The same `move_id` and target answers the first result. `400 move_id_required`/`reason_required`/`invalid_reason`, `404` (incl. `unknown_story_stage`), `409 holder_ended`/`item_closed`/`item_escalated`/`move_pending`/`item_changed`, `422 invalid_target`/`unknown_host`/`unknown_holder`/`holder_cannot_pull` (a runner_session holder claims nothing after its own placement: move to its host)/`target_unavailable`/`already_held_by_target`/`checkpoint_not_current`, `403 boundary_move_needs_mark` only when ANOTHER session holds the item on a live lease, the move crosses the interactive boundary (that holder or the target holder is an interactive session), and the caller is not Mark's own user key (fleet_dash; US-52.45): a holder moves its own item anywhere, the loop included, and an item nobody is working is anyone's to move on; a key with no holder omits `checkpoint_id`; and `403` without the human anchor. |
@@ -668,7 +669,7 @@ Key distribution for the dispatch pattern (Epic 26): per-dispatch ephemeral keys
668
669
  | `work_item_timeline` | **Read a work item's timeline** (`GET /api/v1/stories/:id/timeline`): `item` (stage and its age, holder, lease, issue, PR, runner, newest 20 CI runs, newest 20 runner dispatches (`dispatch_id`, `kind`, `runner_id`, `status`), thread count and newest 20 messages, and `triage_escalation`: null when triage never escalated the item, else its newest triage escalation at any stage: `verdict`, `escalation_reasons` and `missing_information` (`untrusted: true`, fenced in `fenced`), `escalated_at`, and `current`, true while the item is still escalated in it) and one page of `events`, the event log and audit log merged oldest first. Optional `cursor` (a page's `next_cursor`) and `limit` (default 100, max 500). Read-only on any key; never moves a thread cursor. Every reason and message body is untrusted session text, flagged `untrusted: true`. `404` for another tenant's story, `400` for a bad limit or cursor. |
669
670
  | `holder_list` | **List the holders and what each holds** (`GET /api/v1/holders`, #1297): the tenant's live session holders, newest `last_seen_at` first, each with `id`, `agent_id`, `kind`, `host`, `session_id`, `worktree`, `registered_at`, `last_heartbeat_at`, `lease_expires_at`, `ended_at`, `ended_reason` and `items` (the work items it holds now: `story_id`, `number`, `project_id`, `title`, `stage`, `branch`, `pr_number`). Join a live session to its holder on `session_id`. A holder whose lease ran out but the sweep has not ended yet is still listed. Optional `include_ended: true` adds the holders that ended in the last day. At most 200 holders; `truncated: true` says there were more. Read-only on any key: no heartbeat, no lease move, never a credential. |
670
671
  | `decisions` | **Read the decided-on-default notes** (`GET /api/v1/decisions`): live messages whose `idempotency_key` starts `decision-default:`, on a repo channel or a work item thread (never a DM), newest first, without expired, quarantined or superseded ones. Each row carries `idempotency_key`, `project_id`, `story_id`, `host`, a bounded `body_preview` and `untrusted: true`; `has_more` says the limit cut the list. Optional `since` (ISO 8601, default 48 hours ago) and `limit` (1..100, default 25). Read-only on any key. `400` for a bad `since` or `limit`. |
671
- | `factory_overview` | **Read the factory overview** (`GET /api/v1/factory/overview`): per project and summed for the fleet, `in_flight` counts per stage (claimed through verified), `waiting` counts (detected, triaged, queued, and escalated per reason class) with the oldest item's age, `throughput` over the window (done count, median seconds opened to done) and `failure_classes` (moves into escalated or failed, by edge). Counts come from the stage machine; drill into an item with `work_item_timeline`. Optional `project_id` and `window_days` (default 7, 1..30). Read-only on any key. `400` for a bad window, `404` for another tenant's project, `503` when the read times out. |
672
+ | `factory_overview` | **Read the factory overview** (`GET /api/v1/factory/overview`): per project and summed for the fleet, `in_flight` counts per stage (claimed through verified), `waiting` counts (detected, triaged, queued, and escalated per reason class) with the oldest item's age, `throughput` over the window (done count, median seconds opened to done) and `failure_classes` (moves into escalated or failed, by edge), `reserved` (queue items a released move reserves for one host, holder or the cloud, with the oldest age and `by_kind`, not counted again under `waiting`; a released move to the loop stays under `waiting`) and `interactive` (`in_flight` items an interactive holder holds, a subset of `in_flight`, and `waiting` items reserved for an interactive session after a lapsed claim, with the oldest age). Counts come from the stage machine; drill into an item with `work_item_timeline`. Optional `project_id` and `window_days` (default 7, 1..30). Read-only on any key. `400` for a bad window, `404` for another tenant's project, `503` when the read times out. |
672
673
  | `factory_policy` | **Read the factory policy** (`GET /api/v1/factory/policy`, US-52.51): every delivery-loop rule value, compiled into loopctl from `factory/policy.toml` — review-round `normal` and `ceiling` per diff kind (`prose`, `code`), `open_prs_per_session`, `epics_open_per_repo`, `pr_body.required_sections`, `review.default_level` and `review.max_level`, `epic_merge.new_tip_seconds`, `protected_branches`. Returns `{schema, version, rules}`; `version` is the file's sha256 (the endpoint's ETag, so a client that kept a copy gets `304` on `If-None-Match`). The same for every tenant. Any tenant key; refuses nothing else (`401` only without a valid key). No arguments. |
673
674
  | `review_round_open` | **Open a review round** (`POST /api/v1/review_rounds`, US-52.53): counts one round on the work item for `repo_url` and `branch` and answers from the factory policy's `review_rounds.<diff_kind>` limits — `201 {round_id, round, normal, ceiling, verdict, message, attested}`, `verdict` `allow` while round <= normal and `warn` up to the ceiling. A repeated `round_id` counts nothing and answers `200` with the first answer. `attested: true` with a `reason` counts a review the hook could not see. `kind: "security"` with a `head_sha` records a /security-review at that head instead (`201 {round_id, kind, head_sha, message, attested}`), never counted against the ceiling. `ancestor_shas` (the branch's commits outside the base, at most 500) refuses a round whose branch carries another unmerged item's ceiling-round head (claude-config#810). Holder credential (the round's actor is its holder). `409 review_ceiling_reached` (nothing counted; the session decides a redesign or a narrower merge), `409 inherited_ceiling_reached` (`parent_branch`, `head_sha`, `round_count`, `ceiling`), `422 attestation_reason_required`, `422 head_sha_required`, `404 work_item_not_found` (no item, or only ended items your holder never held: open one with `work_item_open`), `403 holder_credential_required`, `400 repo_and_branch_required`, `409 ambiguous_project`, `422 invalid_round_id`/`invalid_kind`/`invalid_diff_kind`/`invalid_head_sha`/`invalid_ancestor_shas`/`invalid_branch`, `503 busy`. |
674
675
  | `review_round_void` | **Void a review round** that did not review (`POST /api/v1/review_rounds/:round_id/void`, US-52.53): it stops counting on its item. `201 {round_id, voided, round, count}`; a second void is `200`. Holder credential. `404 review_round_not_found`, `409 ambiguous_round_id`, `403 holder_credential_required`, `422 invalid_reason`, `503 busy`. |
package/index.js CHANGED
@@ -63,7 +63,12 @@ import {
63
63
  renameAuthenticator,
64
64
  updateTenant,
65
65
  } from "./lib/tenant-admin.js";
66
- import { readCheckpoints, recordCheckpoint, resolveCheckpoint } from "./lib/checkpoints.js";
66
+ import {
67
+ readCheckpoints,
68
+ readFencedCheckpoints,
69
+ recordCheckpoint,
70
+ resolveCheckpoint,
71
+ } from "./lib/checkpoints.js";
67
72
  import { moveWorkItem } from "./lib/work-item-move.js";
68
73
  import { pullWorkItem } from "./lib/work-item-pull.js";
69
74
  import {
@@ -3714,6 +3719,15 @@ async function workItemCheckpointsTool(args) {
3714
3719
  );
3715
3720
  }
3716
3721
 
3722
+ // #1298: the tenant's unresolved fenced checkpoints, read on the session's own key.
3723
+ async function workItemCheckpointsFencedTool(args) {
3724
+ return toContent(
3725
+ await readFencedCheckpoints(args, {
3726
+ apiCall: (method, path, body) => apiCall(method, path, body, agentKey()),
3727
+ }),
3728
+ );
3729
+ }
3730
+
3717
3731
  // US-52.42: resolving a fenced checkpoint is the current holder's act, on its own key.
3718
3732
  async function workItemCheckpointResolveTool(args) {
3719
3733
  return toContent(
@@ -9989,6 +10003,30 @@ const TOOLS = [
9989
10003
  },
9990
10004
  },
9991
10005
 
10006
+ {
10007
+ name: "work_item_checkpoints_fenced",
10008
+ description:
10009
+ "LIST THE TENANT'S UNRESOLVED FENCED CHECKPOINTS (GET /api/v1/checkpoints?fenced=" +
10010
+ "unresolved): every fenced checkpoint a late holder left on any work item that nobody " +
10011
+ "has applied or ignored yet, oldest first, each with checkpoint_id, story_id, " +
10012
+ "project_id, title, holder_id and host of the late holder, head_sha, wip_branch, " +
10013
+ "diff_bytes, summary (summary_untrusted: true, the late holder's own text) and " +
10014
+ "inserted_at. Never the diff: read one with work_item_checkpoints {story_id, " +
10015
+ "checkpoint_id}. Paged: pass next_cursor back as cursor; limit 1..200, default 50. " +
10016
+ "READ-ONLY on any key of the tenant. 400 for a bad limit or a cursor this endpoint did " +
10017
+ "not issue to this tenant.",
10018
+ inputSchema: {
10019
+ type: "object",
10020
+ properties: {
10021
+ cursor: {
10022
+ type: "string",
10023
+ description: "Optional: a previous page's next_cursor, verbatim.",
10024
+ },
10025
+ limit: { type: "integer", description: "Optional: rows, 1..200 (default 50)." },
10026
+ },
10027
+ },
10028
+ },
10029
+
9992
10030
  {
9993
10031
  name: "work_item_checkpoint_resolve",
9994
10032
  description:
@@ -11702,7 +11740,13 @@ const TOOLS = [
11702
11740
  "verified; `waiting` counts for detected, triaged and queued and for escalated per " +
11703
11741
  "reason class, each with its oldest item's age in seconds; `throughput` (items reaching " +
11704
11742
  "done in the window, median seconds from opened to done); `failure_classes` (moves into " +
11705
- "escalated or failed in the window, by the stage machine's edge). Every count is read " +
11743
+ "escalated or failed in the window, by the stage machine's edge); `reserved` (queue " +
11744
+ "items a released move reserves for one host, holder or the cloud: count, oldest age, " +
11745
+ "`by_kind`), counted there and not again under `waiting` (a released move to the loop " +
11746
+ "is loop work and stays under `waiting`); `interactive` (`in_flight`: items an " +
11747
+ "interactive holder holds at an in-flight stage, a subset of `in_flight`; " +
11748
+ "`waiting`: items reserved for an interactive session after its claim lapsed, with the " +
11749
+ "oldest age). Every count is read " +
11706
11750
  "from loopctl's stage machine at request time; drill into one item with " +
11707
11751
  "work_item_timeline. Optional `project_id` narrows it to one project; `window_days` " +
11708
11752
  "defaults to 7, 1..30. READ-ONLY on any key. 400 for a window outside 1..30; 404 for a " +
@@ -14954,6 +14998,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
14954
14998
 
14955
14999
  case "work_item_checkpoints":
14956
15000
  return await workItemCheckpointsTool(args);
15001
+ case "work_item_checkpoints_fenced":
15002
+ return await workItemCheckpointsFencedTool(args);
14957
15003
 
14958
15004
  case "work_item_checkpoint_resolve":
14959
15005
  return await workItemCheckpointResolveTool(args);
@@ -138,6 +138,33 @@ export async function readCheckpoints({ story_id, checkpoint_id, fenced } = {},
138
138
  return apiCall("GET", `${checkpointsPath(story_id)}/${encodeURIComponent(checkpoint_id)}`, null);
139
139
  }
140
140
 
141
+ /**
142
+ * `work_item_checkpoints_fenced` (loopctl #1298): `GET /api/v1/checkpoints?fenced=unresolved`,
143
+ * the tenant's unresolved fenced checkpoints across every work item, oldest first, without
144
+ * diffs. `cursor` is a previous page's `next_cursor`, verbatim; `limit` is 1..200.
145
+ */
146
+ export const FENCED_LIMIT_MAX = 200;
147
+
148
+ export async function readFencedCheckpoints({ cursor, limit } = {}, { apiCall } = {}) {
149
+ if (cursor !== undefined && cursor !== null && typeof cursor !== "string") {
150
+ return refuse("`cursor` must be the string a previous page returned as next_cursor.");
151
+ }
152
+
153
+ if (
154
+ limit !== undefined &&
155
+ limit !== null &&
156
+ !(Number.isInteger(limit) && limit >= 1 && limit <= FENCED_LIMIT_MAX)
157
+ ) {
158
+ return refuse(`\`limit\` must be an integer from 1 to ${FENCED_LIMIT_MAX}.`);
159
+ }
160
+
161
+ const params = new URLSearchParams({ fenced: "unresolved" });
162
+ if (cursor) params.set("cursor", cursor);
163
+ if (Number.isInteger(limit)) params.set("limit", String(limit));
164
+
165
+ return apiCall("GET", `/api/v1/checkpoints?${params.toString()}`, null);
166
+ }
167
+
141
168
  const RESOLUTIONS = ["applied", "ignored"];
142
169
 
143
170
  /** `POST .../checkpoints/:checkpoint_id/resolve`: the current holder applies or ignores one. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopctl-mcp-server",
3
- "version": "3.49.0",
3
+ "version": "3.50.1",
4
4
  "description": "MCP server for loopctl — structural trust for AI development loops",
5
5
  "type": "module",
6
6
  "main": "index.js",