loopctl-mcp-server 3.40.1 → 3.41.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/index.js CHANGED
@@ -263,6 +263,8 @@ function sessionWorktree() {
263
263
  const branchItemOpener = createBranchItemOpener({
264
264
  apiCall: (...args) => apiCall(...args),
265
265
  worktree: sessionWorktree,
266
+ // US-54.9: LOOPCTL_BASE_BRANCH names the branch the session's work merges into.
267
+ env: process.env,
266
268
  git: (args) =>
267
269
  new Promise((resolve) => {
268
270
  execFile("git", args, { encoding: "utf8", timeout: 2000 }, (err, stdout) =>
@@ -3200,13 +3202,14 @@ async function interventionTool(verb, args) {
3200
3202
  }
3201
3203
 
3202
3204
  // US-52.18: open (or reopen) the work item for a branch, on the session's own key: the
3203
- // route accepts only a holder credential (lib/branch-item.js).
3205
+ // route accepts only a holder credential (lib/branch-item.js). Its answer tells the heartbeat's
3206
+ // opener whether the branch is finished (lib/branch-item.js, "A finished branch").
3204
3207
  async function workItemOpenTool(args) {
3205
- return toContent(
3206
- await openWorkItem(args, {
3207
- apiCall: (method, path, body) => apiCall(method, path, body, agentKey()),
3208
- }),
3209
- );
3208
+ const result = await openWorkItem(args, {
3209
+ apiCall: (method, path, body) => apiCall(method, path, body, agentKey()),
3210
+ });
3211
+ branchItemOpener.noteOpen(args && args.branch, result);
3212
+ return toContent(result);
3210
3213
  }
3211
3214
 
3212
3215
  async function workItemNotesTool(args) {
@@ -8683,7 +8686,11 @@ const TOOLS = [
8683
8686
  "holder's credential and revokes every earlier key, including another MCP process of " +
8684
8687
  "this session's (an /mcp reconnect). You do not need it after a 401: a request on the " +
8685
8688
  "holder credential that gets 401 takes up the newer key that process wrote, or " +
8686
- "registers, and is retried once by itself. REFUSES: 403 " +
8689
+ "registers, and is retried once by itself. Such a recovery registers at most once per " +
8690
+ "heartbeat interval: a second refusal inside it, with no newer key in the file, falls " +
8691
+ "back to LOOPCTL_AGENT_KEY (logged to stderr) instead of revoking the other process's " +
8692
+ "key, and the next heartbeat takes up that key from the file. This tool is never held " +
8693
+ "back. REFUSES: 403 " +
8687
8694
  "custody_tier_required on an agent-rooted tenant, 403 holder_mint_forbidden for a " +
8688
8695
  "dispatch-minted key, 422 agent_required for a key naming no agent. On any refusal the " +
8689
8696
  "session keeps using LOOPCTL_AGENT_KEY.",
@@ -8698,7 +8705,9 @@ const TOOLS = [
8698
8705
  "It also moves every uncapped claim the holder holds to the new lease. A 401, 404 or " +
8699
8706
  "409 (credential revoked or expired, holder ended) first takes up a newer credential " +
8700
8707
  "another MCP process of this session wrote to the holder key file and beats once with " +
8701
- "it; only without one, or when that beat is refused too, does it register again. 409 " +
8708
+ "it; only without one, or when that beat is refused too, does it register again, and " +
8709
+ "at most once per heartbeat interval (inside it the session stays on LOOPCTL_AGENT_KEY " +
8710
+ "and the next beat takes up the file's key when one appears). 409 " +
8702
8711
  "holder_lease_expired means the lease ran out first, so loopctl ended the holder and " +
8703
8712
  "released its claims: the session registers as a NEW holder and must re-claim.",
8704
8713
  inputSchema: { type: "object", properties: {} },
@@ -8823,17 +8832,32 @@ const TOOLS = [
8823
8832
  "`branch` becomes one story in the project `repo_url` resolves to, already " +
8824
8833
  "implementing and held by this session, with a stage row naming the branch. The MCP " +
8825
8834
  "server already does this on each heartbeat for the worktree's non-default branch; " +
8826
- "call it to name a title or an epic. The epic is `epic_id`, else the target epic of " +
8827
- "the project's live intake source. Reopening your own item returns it (200, outcome " +
8835
+ "call it to name a title, an epic or a base branch. `base_branch` is the branch the " +
8836
+ "work merges into: it selects the project's live intake source with exactly that " +
8837
+ "base_branch and records it as the item's source; without base_branch the item " +
8838
+ "belongs to the project's primary (unlabelled) source. The epic is `epic_id`, else " +
8839
+ "that source's target epic. Reopening your own item returns it (200, outcome " +
8828
8840
  "existing), an unheld item on the branch is claimed back for you (200, claimed), and " +
8829
- "your one held item with no branch takes this one (200, branch_recorded). Needs this " +
8841
+ "your one held item with no branch takes this one (200, branch_recorded). A branch with " +
8842
+ "no open item whose most recent item ended at done (its pull request merged, or you " +
8843
+ "closed it) while YOUR holder held it answers that item (200, finished) and creates " +
8844
+ "nothing (another holder's finished item gets you a new item of your own); the heartbeat then " +
8845
+ "stops opening that branch. For NEW work on a finished branch name pass `new_item: " +
8846
+ "true`, which creates the next item. Needs this " +
8830
8847
  "session's holder credential: 403 holder_credential_required for any other key. 409 " +
8831
8848
  "branch_held (another session's open item has the branch; names story_id and " +
8832
- "holder_id), 409 holder_ended, 409 story_held (the item is escalated). 404 " +
8833
- "project_not_found (no project of your tenant has the repo), 404 epic_not_found. 422 " +
8834
- "no_target_epic (pass epic_id), 422 invalid_branch (empty, whitespace, HEAD, over 255 " +
8835
- "bytes). The item reaches verified only through report, review and verify like any " +
8836
- "story; you cannot report it yourself.",
8849
+ "holder_id), 409 holder_ended, 409 story_held (the item is escalated), 409 " +
8850
+ "base_branch_mismatch (the branch's open item merges into another base branch; it is " +
8851
+ "never relinked). 404 project_not_found (no project of your tenant has the repo), 404 " +
8852
+ "epic_not_found. 422 no_source_for_base (no live intake source of the repo's project " +
8853
+ "merges into base_branch), 422 no_target_epic (pass epic_id), 422 invalid_branch / " +
8854
+ "invalid_base_branch (empty, whitespace, HEAD, over 255 bytes). HOW THE ITEM ENDS, " +
8855
+ "with no second session and no human: when the branch's pull request MERGES, loopctl " +
8856
+ "ends the item at done as the system actor (from GitHub's merge, naming the PR and " +
8857
+ "merge sha); with no pull request, you end it yourself with work_item_close and " +
8858
+ "`evidence` (done over :self_closed). Neither verifies it: the item reaches verified " +
8859
+ "only through report, review and verify like any story, and you cannot report it " +
8860
+ "yourself.",
8837
8861
  inputSchema: {
8838
8862
  type: "object",
8839
8863
  properties: {
@@ -8841,6 +8865,20 @@ const TOOLS = [
8841
8865
  branch: { type: "string", description: "The branch the work is on." },
8842
8866
  title: { type: "string", description: "Optional: the item's title (default: the branch)." },
8843
8867
  epic_id: { type: "string", description: "Optional: the UUID of the epic to file it under." },
8868
+ new_item: {
8869
+ type: "boolean",
8870
+ description:
8871
+ "Optional, default false: open a NEW item even when the branch's most recent " +
8872
+ "item ended at done (new work on a branch name whose earlier work merged or was " +
8873
+ "closed). Without it such a branch answers its finished item.",
8874
+ },
8875
+ base_branch: {
8876
+ type: "string",
8877
+ description:
8878
+ "Optional: the branch the work merges into (e.g. e2e/sandbox). Omitted: the " +
8879
+ "project's primary (unlabelled) intake source. 422 no_source_for_base when no " +
8880
+ "live source of the project merges into it.",
8881
+ },
8844
8882
  },
8845
8883
  required: ["repo_url", "branch"],
8846
8884
  },
@@ -8879,12 +8917,33 @@ const TOOLS = [
8879
8917
  {
8880
8918
  name: "work_item_close",
8881
8919
  description:
8882
- "CLOSE A WORK ITEM AS NOT ACTIONABLE (POST /api/v1/stories/:id/close): end it at " +
8883
- "failed over :closed, from the same stages as work_item_cancel; this is the only " +
8884
- "verb that closes the linked issue, as not actionable. 409 already_landed for " +
8885
- "merged, deployed or verified; 409 already_finished for done or failed.",
8920
+ "CLOSE A WORK ITEM (POST /api/v1/stories/:id/close). On ANOTHER holder's item: end " +
8921
+ "it at failed over :closed as not actionable, from the same stages as " +
8922
+ "work_item_cancel; this is the only verb that closes the linked issue, as not " +
8923
+ "actionable. On YOUR OWN INTERACTIVE item (one work_item_open opened, held by this " +
8924
+ "session): a SELF-CLOSE, allowed, ending it at done over :self_closed with the " +
8925
+ "`evidence` you give (REQUIRED: 400 evidence_required) recorded on the stage event " +
8926
+ "and the audit log. Use it for work with no pull request (an investigation, an ops " +
8927
+ "task). It never verifies anything: verified_status is untouched, and the item " +
8928
+ "reads as self-closed, not verified. Refused 409 open_pull_request (names " +
8929
+ "pr_number) while the branch has an open pull request, because merging it ends the " +
8930
+ "item on its own; 503 pull_request_state_unavailable when GitHub could not be read " +
8931
+ "(retry), and a retry with the same intervention_id answers without asking it again; 409 " +
8932
+ "change_bound while a chg change is bound to the item (it lands through chg, and its " +
8933
+ "landing ends the item); 409 " +
8934
+ "not_self_closable at queued, escalated or a pre-queue stage (detected, triaged). " +
8935
+ "409 already_landed for merged, deployed or verified; 409 already_finished for done " +
8936
+ "or failed.",
8937
+ extraProperties: {
8938
+ evidence: {
8939
+ type: "string",
8940
+ description:
8941
+ "What was done and where, 1 to 4000 characters. REQUIRED to close your own " +
8942
+ "interactive item; optional otherwise.",
8943
+ },
8944
+ },
8886
8945
  },
8887
- ].map(({ name, description }) => ({
8946
+ ].map(({ name, description, extraProperties = {} }) => ({
8888
8947
  name,
8889
8948
  description:
8890
8949
  description +
@@ -8893,7 +8952,8 @@ const TOOLS = [
8893
8952
  "and a held chg landing on an independent path is 409 independent_verification until " +
8894
8953
  "a host-separated verify closes its hold; only a human resolves either. " +
8895
8954
  "Uses this session's own key: 409 self_intervention_blocked when this session's " +
8896
- "holder holds the item (escalate or unclaim instead), 409 holder_required for a " +
8955
+ "holder holds the item (escalate or unclaim instead; the one exception is " +
8956
+ "work_item_close on your own interactive item), 409 holder_required for a " +
8897
8957
  "non-human key with no holder, 409 stage_moved when the item moved while the verb ran " +
8898
8958
  "(nothing changed), 403 on an agent-rooted tenant. A reason is required " +
8899
8959
  "(400 reason_required). Pass the same intervention_id to retry after a lost " +
@@ -8908,6 +8968,7 @@ const TOOLS = [
8908
8968
  type: "string",
8909
8969
  description: "Optional UUID naming this intervention, so a retry applies it once.",
8910
8970
  },
8971
+ ...extraProperties,
8911
8972
  },
8912
8973
  required: ["story_id", "reason"],
8913
8974
  },
@@ -9260,7 +9321,8 @@ const TOOLS = [
9260
9321
  "(`parent_branch`, `head_sha`, `round_count`, `ceiling`: wait for the parent to merge or " +
9261
9322
  "recut from the base), 422 `attestation_reason_required`, 422 `head_sha_required` (a " +
9262
9323
  "security record with no head), 404 `work_item_not_found` (no item of this tenant on " +
9263
- "that repo and branch: open one with `work_item_open`), 403 " +
9324
+ "that repo and branch, or only ended items your holder never held: open one with " +
9325
+ "`work_item_open`), 403 " +
9264
9326
  "`holder_credential_required`, 400 `repo_and_branch_required`, 409 `ambiguous_project`, " +
9265
9327
  "422 `invalid_round_id` / `invalid_kind` / `invalid_diff_kind` / `invalid_head_sha` / " +
9266
9328
  "`invalid_ancestor_shas` / `invalid_branch`, 503 `busy` (retry).",
@@ -9362,16 +9424,19 @@ const TOOLS = [
9362
9424
  {
9363
9425
  name: "intake_pause",
9364
9426
  description:
9365
- "PAUSE A PROJECT'S INTAKE (POST /api/v1/projects/:id/intake/pause): new issues stay " +
9427
+ "PAUSE ONE INTAKE SOURCE OF A PROJECT (POST /api/v1/projects/:id/intake/pause): its new issues stay " +
9366
9428
  "pending_triage and get no triage until intake_resume. " +
9367
9429
  "A pause stops PROMOTION and TRIAGE only: it never stops work already past detected " +
9368
9430
  "(placement, implementation and merges carry on) and never the webhook, which keeps " +
9369
- "verifying and recording every delivery, so nothing reported is lost. Acts on the " +
9370
- "project's one live intake source: 404 no_intake_source when it has none or is " +
9371
- "another tenant's, 409 ambiguous_intake_source for more than one, 403 on an " +
9372
- "agent-rooted tenant. A call that changes nothing, or repeats an intervention_id, " +
9373
- "writes nothing and answers 200 with the source; one intervention_id is generated " +
9374
- "when absent, so pass the first one again to retry after a lost response.",
9431
+ "verifying and recording every delivery, so nothing reported is lost. Acts on ONE " +
9432
+ "intake source of the project: the one source_id names, or WITHOUT source_id the " +
9433
+ "project's primary (unlabelled) source, so pausing an e2e source never pauses master " +
9434
+ "and a pause without source_id never pauses a labelled source. " +
9435
+ "404 no_intake_source when source_id is not a live source of this project in your " +
9436
+ "tenant, or without it the project has no primary source or is another tenant's; " +
9437
+ "403 on an agent-rooted tenant. A call that changes nothing, or repeats an " +
9438
+ "intervention_id, writes nothing and answers 200 with the source; one intervention_id " +
9439
+ "is generated when absent, so pass the first one again to retry after a lost response.",
9375
9440
  inputSchema: {
9376
9441
  type: "object",
9377
9442
  properties: {
@@ -9381,6 +9446,12 @@ const TOOLS = [
9381
9446
  type: "string",
9382
9447
  description: "Optional UUID naming this call, so a retry applies it once.",
9383
9448
  },
9449
+ source_id: {
9450
+ type: "string",
9451
+ description:
9452
+ "Optional UUID of the intake source to pause (intake_source_list). Without it, " +
9453
+ "the project's primary (unlabelled) source.",
9454
+ },
9384
9455
  },
9385
9456
  required: ["project_id", "reason"],
9386
9457
  },
@@ -9389,16 +9460,19 @@ const TOOLS = [
9389
9460
  {
9390
9461
  name: "intake_resume",
9391
9462
  description:
9392
- "RESUME A PROJECT'S INTAKE (POST /api/v1/projects/:id/intake/resume): the minute " +
9463
+ "RESUME ONE INTAKE SOURCE OF A PROJECT (POST /api/v1/projects/:id/intake/resume): the minute " +
9393
9464
  "promotion run picks up every issue that arrived while paused. " +
9394
9465
  "A pause stops PROMOTION and TRIAGE only: it never stops work already past detected " +
9395
9466
  "(placement, implementation and merges carry on) and never the webhook, which keeps " +
9396
- "verifying and recording every delivery, so nothing reported is lost. Acts on the " +
9397
- "project's one live intake source: 404 no_intake_source when it has none or is " +
9398
- "another tenant's, 409 ambiguous_intake_source for more than one, 403 on an " +
9399
- "agent-rooted tenant. A call that changes nothing, or repeats an intervention_id, " +
9400
- "writes nothing and answers 200 with the source; one intervention_id is generated " +
9401
- "when absent, so pass the first one again to retry after a lost response.",
9467
+ "verifying and recording every delivery, so nothing reported is lost. Acts on ONE " +
9468
+ "intake source of the project: the one source_id names, or WITHOUT source_id the " +
9469
+ "project's primary (unlabelled) source, so resuming master never resumes a paused " +
9470
+ "e2e source. " +
9471
+ "404 no_intake_source when source_id is not a live source of this project in your " +
9472
+ "tenant, or without it the project has no primary source or is another tenant's; " +
9473
+ "403 on an agent-rooted tenant. A call that changes nothing, or repeats an " +
9474
+ "intervention_id, writes nothing and answers 200 with the source; one intervention_id " +
9475
+ "is generated when absent, so pass the first one again to retry after a lost response.",
9402
9476
  inputSchema: {
9403
9477
  type: "object",
9404
9478
  properties: {
@@ -9407,6 +9481,12 @@ const TOOLS = [
9407
9481
  type: "string",
9408
9482
  description: "Optional UUID naming this call, so a retry applies it once.",
9409
9483
  },
9484
+ source_id: {
9485
+ type: "string",
9486
+ description:
9487
+ "Optional UUID of the intake source to resume (intake_source_list). Without it, " +
9488
+ "the project's primary (unlabelled) source.",
9489
+ },
9410
9490
  },
9411
9491
  required: ["project_id"],
9412
9492
  },
@@ -10182,7 +10262,10 @@ const TOOLS = [
10182
10262
  "left assigned/implementing: nothing was pushed or written and the claim is not revived. " +
10183
10263
  "Place the story again with a NEW dispatch_id once it is placeable. 409 " +
10184
10264
  "`dependencies_not_met` means a story it depends on, or one in an epic its epic depends on, " +
10185
- "is not verified: nothing was minted, claimed or pushed; place it once they are.\n\n" +
10265
+ "is not verified: nothing was minted, claimed or pushed; place it once they are. 409 " +
10266
+ "`base_branch_mismatch` means the `repo` or `base_branch` you passed is not the story's " +
10267
+ "own intake source's (`expected_repo`, `expected_base_branch` in the body): nothing was " +
10268
+ "minted, claimed or pushed; omit both or send those values.\n\n" +
10186
10269
  "422 `not_placeable_kind` means the `kind` is not one whose agent spec CLAIMS a story " +
10187
10270
  "(the `:build` archetype; `implement` is the only one today). Placement claims the story " +
10188
10271
  "and mints the custody lineage, so a kind that must not hold a claim — `triage`, or a " +
@@ -10216,13 +10299,14 @@ const TOOLS = [
10216
10299
  repo: {
10217
10300
  type: "string",
10218
10301
  description:
10219
- "Optional. `owner/name` of the repository the session works in, OVERRIDING the " +
10220
- "repository loopctl would derive from the project's intake source. Pass " +
10221
- "`base_branch` alongside it: the derivation supplies both from one intake " +
10222
- "source, so naming a repository whose base branch loopctl still has to guess " +
10223
- "is how a session gets cut from the wrong trunk. Required in practice on a " +
10224
- "project bound to NO intake source (409 `no_intake_source`) or to TWO (409 " +
10225
- "`ambiguous_intake_source`) — both refusals name these two parameters.",
10302
+ "Optional; leave it out. `owner/name` of the repository the session works in. " +
10303
+ "loopctl derives it, with `base_branch`, from the STORY'S OWN intake source " +
10304
+ "(US-54.3), so an e2e/sandbox story and a master story of one project each go " +
10305
+ "to their own base. On a story that has a source, a value that differs from the " +
10306
+ "source's (compared case-insensitively) is refused 409 `base_branch_mismatch`, " +
10307
+ "whose body names `expected_repo` and `expected_base_branch`; nothing is " +
10308
+ "claimed. Needed only for a story bound to NO intake source (409 " +
10309
+ "`no_intake_source`), and then pass `base_branch` alongside it.",
10226
10310
  },
10227
10311
  branch: {
10228
10312
  type: "string",
@@ -10243,8 +10327,9 @@ const TOOLS = [
10243
10327
  base_branch: {
10244
10328
  type: "string",
10245
10329
  description:
10246
- "Optional. The ref the session cuts FROM; defaults to the project's intake " +
10247
- "source. Judged as a git ref name exactly as `branch` is (422 " +
10330
+ "Optional. The ref the session cuts FROM; defaults to the story's own intake " +
10331
+ "source's `base_branch`, and on a story that has a source any other value is 409 " +
10332
+ "`base_branch_mismatch` with nothing claimed. Judged as a git ref name exactly as `branch` is (422 " +
10248
10333
  "`invalid_branch_name`, nothing claimed), but NOT story-unique — every dispatch " +
10249
10334
  "cutting from master is the normal case.",
10250
10335
  },
@@ -10618,6 +10703,13 @@ const TOOLS = [
10618
10703
  "`refuse` (the story is escalated before this returns), `already_merged`, `head_moved` " +
10619
10704
  "(back to implementing), `unevaluated` (503 with Retry-After: a transient forge fault; " +
10620
10705
  "retry after the delay, nothing transitioned).\n\n" +
10706
+ "WRONG BASE BRANCH. The pull request must target exactly the base branch of the " +
10707
+ "story's own intake source (`base_branch` on the answer; case-sensitive). A pull " +
10708
+ "request into any other branch, open or already merged, is a `refuse` with reason " +
10709
+ "`pr_base_mismatch` (never `already_merged`), and one whose base cannot be read is a " +
10710
+ "`refuse` with `pr_base_unreadable`. The story is escalated like any refusal; the " +
10711
+ "remedy is to retarget the pull request (`gh pr edit --base <base_branch>`) before " +
10712
+ "the escalation is resolved. There is no override.\n\n" +
10621
10713
  "REFUSALS. Needs an ORCHESTRATOR- or USER-role key: the action is `exact_role: " +
10622
10714
  "[:orchestrator, :user]`, so an agent key is 403'd. LOOPCTL_ORCH_KEY is sent when set, " +
10623
10715
  "else LOOPCTL_API_KEY. 403 `custody_tier_required` on a tenant without a human anchor, " +
@@ -10712,9 +10804,9 @@ const TOOLS = [
10712
10804
  "BIND A GITHUB REPOSITORY TO A WORK PROJECT and mint its webhook secret (POST " +
10713
10805
  "/api/v1/intake/sources). This is how the agent delivery loop gets an input at all: " +
10714
10806
  "until a repository has an intake source, no webhook anywhere points at loopctl and no " +
10715
- "issue can reach a queue. It is also the binding place_dispatch reads — a project bound " +
10716
- "to no source refuses 409 `no_intake_source`, and one bound to two refuses 409 " +
10717
- "`ambiguous_intake_source`; this tool is what those two refusals mean by enrolling a " +
10807
+ "issue can reach a queue. It is also the binding place_dispatch reads — each story " +
10808
+ "resolves through its own source, and a story with none refuses 409 " +
10809
+ "`no_intake_source`; this tool is what that refusal means by enrolling a " +
10718
10810
  "source. Bind the repository to the project that already holds its repo_url; a pr or chg source on that repo's kb scope promotes the scope to a work project (US-52.3). " +
10719
10811
  "A repo has one project: a repo_url another active project of the tenant already holds is refused 409 repo_already_has_project, and error.existing_project_id names the project to use instead (resolve_project({repo_url}) finds it too). " +
10720
10812
  "And a project holds one repo: a project whose repo_url names a DIFFERENT repo is refused 422 on repo_full_name (#1072)." +
@@ -10756,11 +10848,20 @@ const TOOLS = [
10756
10848
  "privileged ephemeral key does not get past it. 403 `custody_tier_required` on an " +
10757
10849
  "agent-rooted tenant, which may not open an intake surface for itself (an intake source " +
10758
10850
  "admits outside text into the queue of a project whose stories an implementer will act " +
10759
- "on). 422 when the repository is not `owner/name`, when an ACTIVE source already binds " +
10760
- "that repository (revoke it first — the uniqueness is partial on not-yet-revoked), when " +
10851
+ "on). 422 when the repository is not `owner/name`, when " +
10761
10852
  "the project is missing, archived or the wrong kind for the mode (a work project for " +
10762
10853
  "`pr`/`chg`; a KB scope or a work project for `ledger`), or when `target_epic_id` names " +
10763
10854
  "an epic outside that project. 429 when rate limited.\n\n" +
10855
+ "ONE SOURCE PER REPOSITORY AND BASE BRANCH (US-54.1). A repository may have a second " +
10856
+ "live source — for a release, staging or e2e branch — on the SAME project, named by " +
10857
+ "`base_branch` and carrying its own `issue_label`. Three refusals, each 422 naming the " +
10858
+ "field (revoke the blocking source first; the indexes are partial on not-yet-revoked): " +
10859
+ "`repo_full_name` `already has a live intake source on base branch <b>` when a live " +
10860
+ "source of this repository already has that base branch; `issue_label` `is already the " +
10861
+ "label of another live source on this repository` when a sibling has that label " +
10862
+ "(case-insensitively); `issue_label` `is required: this project already has a source " +
10863
+ "with no issue label` when the source would be a second primary of its project — give " +
10864
+ "it a label.\n\n" +
10764
10865
  "NAME `base_branch` AT ENROLMENT for a repository whose trunk is not `master`. It is the " +
10765
10866
  "branch every dispatch for this repository is cut FROM, it defaults to `master` when the " +
10766
10867
  "body does not name it, and GitHub has created repositories with `main` since 2020 — so " +
@@ -10826,6 +10927,29 @@ const TOOLS = [
10826
10927
  "here rather than silently taking the default. Changed later with " +
10827
10928
  "intake_source_update.",
10828
10929
  },
10930
+ issue_label: {
10931
+ type: "string",
10932
+ description:
10933
+ "Optional (US-54.1). The GitHub label that marks THIS source's issues, 1-50 " +
10934
+ "characters, compared case-insensitively. Leave it out to enrol the project's " +
10935
+ "PRIMARY source; a project has one live pr/chg source with no label, so a second " +
10936
+ "source of the repository (another base_branch) must carry one. Null and blank " +
10937
+ "are refused here; intake_source_update changes or clears it.",
10938
+ },
10939
+ deploy_environment: {
10940
+ type: "string",
10941
+ description:
10942
+ "Optional (US-54.7). The GitHub deployment environment post-deploy verification " +
10943
+ "reads this source's stories' deployments from, e.g. `e2e-sandbox` for a branch " +
10944
+ "whose deploy workflow writes that environment. LEAVE IT OUT for the default: the " +
10945
+ "operator's fleet-wide DELIVERY_DEPLOY_ENVIRONMENT (`production` when unset), which " +
10946
+ "is what every source used before the field existed. 1-255 characters with no " +
10947
+ "control character; spaces and punctuation are fine, as GitHub allows them. Null, " +
10948
+ "blank, a control character or a longer name is refused here (422 on " +
10949
+ "`deploy_environment` at the server). A wrong name is not a silent pass: no " +
10950
+ "deployment matches it and the story escalates at the sweep's bound. " +
10951
+ "intake_source_update changes or clears it.",
10952
+ },
10829
10953
  mode: {
10830
10954
  type: "string",
10831
10955
  enum: ["pr", "chg", "ledger"],
@@ -10915,7 +11039,11 @@ const TOOLS = [
10915
11039
  description:
10916
11040
  "LIST THE TENANT'S GITHUB INTAKE SOURCES (GET /api/v1/intake/sources): per source its " +
10917
11041
  "`id` (the webhook URL is /api/v1/intake/github/<id>), `project_id`, `repo_full_name`, " +
10918
- "`base_branch`, `mode` (`pr`, `chg` or `ledger`), `chg_root_dispatch_id`, `target_epic_id`, " +
11042
+ "`base_branch`, `issue_label` (null on the project's primary source), " +
11043
+ "`deploy_environment` (the GitHub deployment environment its stories are verified " +
11044
+ "against; null means the operator's fleet-wide DELIVERY_DEPLOY_ENVIRONMENT, " +
11045
+ "`production` when unset), `mode` (`pr`, " +
11046
+ "`chg` or `ledger`), `chg_root_dispatch_id`, `target_epic_id`, " +
10919
11047
  "`revoked_at` and " +
10920
11048
  "timestamps. Active sources only " +
10921
11049
  "unless `include_revoked` is true.\n\n" +
@@ -10923,9 +11051,15 @@ const TOOLS = [
10923
11051
  "change-events secret, which is never returned at all. The webhook secret is returned once by " +
10924
11052
  "intake_source_enroll and the column is redacted on the schema, so this is not the way " +
10925
11053
  "to recover one — revoking and enrolling again is. Use this to find the source behind a " +
10926
- "409 `no_intake_source` (the project is bound to none) or a 409 " +
10927
- "`ambiguous_intake_source` (bound to two, so revoke the one that no longer applies), to " +
10928
- "check a repository's `base_branch` before placing work, and to identify a source left " +
11054
+ "409 `no_intake_source` (the story belongs to no live source) or a 409 " +
11055
+ "`base_branch_mismatch` (the story's own source names another base), to " +
11056
+ "check a repository's `base_branch` before placing work, to see every source of one " +
11057
+ "repository side by side with its `base_branch` and `issue_label` before enrolling " +
11058
+ "another (US-54.1: an enrolment or update is refused 422 on `repo_full_name` " +
11059
+ "`already has a live intake source on base branch <b>`, on `issue_label` `is already " +
11060
+ "the label of another live source on this repository`, or on `issue_label` `is " +
11061
+ "required: this project already has a source with no issue label`), and to identify a " +
11062
+ "source left " +
10929
11063
  "behind by an enrolment whose outcome was unknown. Requires LOOPCTL_USER_KEY; this read " +
10930
11064
  "is the one action of the four that does not need a human-anchored tenant.",
10931
11065
  inputSchema: {
@@ -10943,7 +11077,14 @@ const TOOLS = [
10943
11077
  description:
10944
11078
  "SET WHERE A SOURCE'S WORK LANDS (PATCH /api/v1/intake/sources/:id): `target_epic_id`, " +
10945
11079
  "the epic triaged stories are created in, `base_branch`, the branch every dispatch " +
10946
- "for this repository is cut FROM and carries, `mode`, the merge route (`pr` or `chg`, " +
11080
+ "for this repository is cut FROM and carries, `issue_label`, the GitHub label that " +
11081
+ "marks this source's issues (null clears it and makes the source its project's " +
11082
+ "primary), `deploy_environment`, the GitHub deployment environment post-deploy " +
11083
+ "verification reads this source's stories against (US-54.7; null clears it, returning " +
11084
+ "the source to the fleet-wide DELIVERY_DEPLOY_ENVIRONMENT, `production` when unset; " +
11085
+ "read on every sweep, so it reaches stories already waiting at `merged` or `deployed`; " +
11086
+ "an empty string, a control character or more than 255 characters is refused here and " +
11087
+ "422 on `deploy_environment` at the server), `mode`, the merge route (`pr` or `chg`, " +
10947
11088
  "or `ledger` on a KB scope or a work project), and the `change_events_secret` and " +
10948
11089
  "`chg_root_dispatch_id` " +
10949
11090
  "that authenticate a source's chg ledger and change events.\n\n" +
@@ -10961,6 +11102,13 @@ const TOOLS = [
10961
11102
  "`base_branch` is BOUND to each implement dispatch when it is placed: a story already " +
10962
11103
  "placed is merge-gated against the base branch its dispatch was sent with. `mode` is " +
10963
11104
  "NOT bound that way: the merge gate reads the source's current mode.\n\n" +
11105
+ "A SOURCE IS ITS REPOSITORY AND BASE BRANCH (US-54.1), so a `base_branch` or " +
11106
+ "`issue_label` change meets the same three refusals as an enrolment, each 422 naming " +
11107
+ "the field: `repo_full_name` `already has a live intake source on base branch <b>` " +
11108
+ "when a sibling source of this repository already has that base branch; `issue_label` " +
11109
+ "`is already the label of another live source on this repository` when a sibling has " +
11110
+ "that label (case-insensitively); `issue_label` `is required: this project already has " +
11111
+ "a source with no issue label` when clearing the label would make a second primary.\n\n" +
10964
11112
  "SWITCHING TO `chg` closes the PR route for EVERY story on the source at once: " +
10965
11113
  "merge_precondition reads the source's current mode and answers 409 " +
10966
11114
  "`change_protocol_enrolled` (land with `chg submit`). The switch is itself refused 409 " +
@@ -11018,6 +11166,22 @@ const TOOLS = [
11018
11166
  "The branch dispatches for this repository are cut from, e.g. `main`. 1-255 " +
11019
11167
  "characters, not nullable. Omit to leave the current value alone.",
11020
11168
  },
11169
+ issue_label: {
11170
+ type: ["string", "null"],
11171
+ description:
11172
+ "The GitHub label that marks this source's issues, 1-50 characters, compared " +
11173
+ "case-insensitively. An explicit null CLEARS it, which makes the source its " +
11174
+ "project's primary (422 while the project has another). Omit to leave it alone.",
11175
+ },
11176
+ deploy_environment: {
11177
+ type: ["string", "null"],
11178
+ description:
11179
+ "The GitHub deployment environment post-deploy verification reads this source's " +
11180
+ "stories' deployments from (US-54.7), e.g. `e2e-sandbox`. 1-255 characters with no " +
11181
+ "control character. An explicit null CLEARS it, which returns the source to the " +
11182
+ "fleet-wide DELIVERY_DEPLOY_ENVIRONMENT (`production` when unset). Omit to leave " +
11183
+ "it alone.",
11184
+ },
11021
11185
  mode: {
11022
11186
  type: "string",
11023
11187
  enum: ["pr", "chg", "ledger"],
@@ -11102,11 +11266,12 @@ const TOOLS = [
11102
11266
  "exactly as a wrong secret is — so the GitHub webhook does not know it has been cut off " +
11103
11267
  "and should be deleted on the repository too. IDEMPOTENT: revoking twice answers 200 " +
11104
11268
  "with the original `revoked_at`.\n\n" +
11105
- "TWO THINGS IT UNBLOCKS. It frees the repository's uniqueness slot, so a source with a " +
11106
- "lost secret, a wrong project or a typo'd repository is corrected by revoking and " +
11107
- "enrolling again — the active-repository index is partial on not-yet-revoked, so the " +
11108
- "422 `an active intake source already binds this repository` clears the moment this " +
11109
- "returns. And it CLEARS `target_epic_id`, which is what makes that epic deletable: the " +
11269
+ "TWO THINGS IT UNBLOCKS. It frees the source's uniqueness slots (its repository and " +
11270
+ "base branch, its `issue_label`, and its project's primary slot when it has no label), " +
11271
+ "so a source with a lost secret, a wrong project or a typo'd repository is corrected by " +
11272
+ "revoking and enrolling again — every identity index is partial on not-yet-revoked, so " +
11273
+ "the 422 `already has a live intake source on base branch <b>` (and the two " +
11274
+ "`issue_label` refusals) clear the moment this returns. And it CLEARS `target_epic_id`, which is what makes that epic deletable: the " +
11110
11275
  "reference blocks an epic delete, and this is the remedy that refusal names.\n\n" +
11111
11276
  "Requires LOOPCTL_USER_KEY and a human-anchored tenant (403 `custody_tier_required`). " +
11112
11277
  "404 for an unknown source or another tenant's; a `source_id` that is not a UUID is " +