@codedrifters/configulator 0.0.409 → 0.0.411

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/lib/index.mjs CHANGED
@@ -877,6 +877,53 @@ function buildTitlePrefixTypeMap() {
877
877
  return map;
878
878
  }
879
879
 
880
+ // src/agent/bundles/origin-label.ts
881
+ var ORIGIN_ISSUE_WORKER_LABEL = "origin:issue-worker";
882
+ var ORIGIN_AGENT_LABEL = "origin:agent";
883
+ var DELEGATION_ELIGIBLE_ORIGIN_PHRASE = `an origin label (\`${ORIGIN_ISSUE_WORKER_LABEL}\` or \`${ORIGIN_AGENT_LABEL}\`)`;
884
+ var DELEGATION_ELIGIBLE_ORIGIN_LIST = `\`${ORIGIN_ISSUE_WORKER_LABEL}\` or \`${ORIGIN_AGENT_LABEL}\``;
885
+ function renderOriginStampSection() {
886
+ return [
887
+ "## Origin label",
888
+ "",
889
+ `Every PR you open must carry the \`${ORIGIN_AGENT_LABEL}\` label. It is`,
890
+ "the umbrella origin label for **agent-opened** PRs: the `pr-reviewer`",
891
+ "reads it to decide whether it may autonomously delegate in-scope",
892
+ "review fixes back to the `issue-worker`. A PR that reaches the",
893
+ "reviewer with no origin label looks human-authored, so the reviewer",
894
+ "skips the delegation hand-off and the PR sits waiting for a human",
895
+ "instead of being self-healed by the pipeline.",
896
+ "",
897
+ "Pass the label on the `gh pr create` invocation:",
898
+ "",
899
+ "```bash",
900
+ 'gh pr create --title "<type>(<scope>): <description>" \\',
901
+ ` --label '${ORIGIN_AGENT_LABEL}' \\`,
902
+ ' --body "<summary>',
903
+ "",
904
+ 'Closes #<issue-number>"',
905
+ "```",
906
+ "",
907
+ "If your project's PR workflow opens the PR for you and the label is",
908
+ "missing afterwards, add it immediately \u2014 before handing the PR to",
909
+ "review:",
910
+ "",
911
+ "```bash",
912
+ `gh pr edit <pr-number> --add-label '${ORIGIN_AGENT_LABEL}'`,
913
+ "```",
914
+ "",
915
+ `Stamp \`${ORIGIN_AGENT_LABEL}\`, never \`${ORIGIN_ISSUE_WORKER_LABEL}\` \u2014`,
916
+ `\`${ORIGIN_ISSUE_WORKER_LABEL}\` means the PR was opened by the`,
917
+ "`issue-worker` agent specifically, and claiming it on an analyst PR",
918
+ "would be false. Both labels are delegation-eligible, so the umbrella",
919
+ "label buys the same autonomous fix hand-off without the false claim.",
920
+ "",
921
+ `The \`${ORIGIN_AGENT_LABEL}\` label ships with the \`pr-review\` bundle's`,
922
+ "label set, so it is already present in the repository's label",
923
+ "registry \u2014 you never need to create it."
924
+ ];
925
+ }
926
+
880
927
  // src/agent/bundles/project-context.ts
881
928
  var PROJECT_CONTEXT_PATH = "docs/src/content/docs/project-context.md";
882
929
  var SUBPROJECT_ROLE_GUIDANCE = [
@@ -1150,6 +1197,8 @@ var agendaAnalystSubAgent = {
1150
1197
  " label.",
1151
1198
  "4. Commit, push, open a PR, and transition the issue to",
1152
1199
  " `status:ready-for-review` per your project's PR workflow.",
1200
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
1201
+ " **Origin label** section below.",
1153
1202
  "",
1154
1203
  "---",
1155
1204
  "",
@@ -1157,6 +1206,10 @@ var agendaAnalystSubAgent = {
1157
1206
  "",
1158
1207
  "---",
1159
1208
  "",
1209
+ ...renderOriginStampSection(),
1210
+ "",
1211
+ "---",
1212
+ "",
1160
1213
  "## Phase 1: Draft (`agenda:draft`)",
1161
1214
  "",
1162
1215
  "**Goal:** Produce a well-structured `agenda.md` in the meeting's",
@@ -5973,6 +6026,8 @@ function buildBcmWriterSubAgent(paths, issueDefaults) {
5973
6026
  "3. Execute the phase handler that matches the issue's `bcm:*` label.",
5974
6027
  "4. Commit, push, open a PR (if applicable), and close the issue per",
5975
6028
  " your project's PR workflow.",
6029
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
6030
+ " **Origin label** section below.",
5976
6031
  "",
5977
6032
  "---",
5978
6033
  "",
@@ -5980,6 +6035,10 @@ function buildBcmWriterSubAgent(paths, issueDefaults) {
5980
6035
  "",
5981
6036
  "---",
5982
6037
  "",
6038
+ ...renderOriginStampSection(),
6039
+ "",
6040
+ "---",
6041
+ "",
5983
6042
  "## Phase 1: Outline (`bcm:outline`)",
5984
6043
  "",
5985
6044
  "**Goal:** Identify the capability (name-as-noun, business object, tier)",
@@ -7277,6 +7336,8 @@ function buildBusinessModelsAnalystSubAgent(paths) {
7277
7336
  " `business-models:*` label.",
7278
7337
  "4. Commit, push, open a PR (if applicable), and close the issue per",
7279
7338
  " your project's PR workflow.",
7339
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
7340
+ " **Origin label** section below.",
7280
7341
  "",
7281
7342
  "---",
7282
7343
  "",
@@ -7284,6 +7345,10 @@ function buildBusinessModelsAnalystSubAgent(paths) {
7284
7345
  "",
7285
7346
  "---",
7286
7347
  "",
7348
+ ...renderOriginStampSection(),
7349
+ "",
7350
+ "---",
7351
+ "",
7287
7352
  "## Phase 1: Scan (`business-models:scan`)",
7288
7353
  "",
7289
7354
  "**Goal:** Read upstream industry and profile artifacts to identify",
@@ -8180,6 +8245,8 @@ function buildCompanyProfileAnalystSubAgent(paths, issueDefaults, tier) {
8180
8245
  " label.",
8181
8246
  "4. Commit, push, open a PR (if applicable), and close the issue per",
8182
8247
  " your project's PR workflow.",
8248
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
8249
+ " **Origin label** section below.",
8183
8250
  "",
8184
8251
  "---",
8185
8252
  "",
@@ -8187,6 +8254,10 @@ function buildCompanyProfileAnalystSubAgent(paths, issueDefaults, tier) {
8187
8254
  "",
8188
8255
  "---",
8189
8256
  "",
8257
+ ...renderOriginStampSection(),
8258
+ "",
8259
+ "---",
8260
+ "",
8190
8261
  "## Phase 1: Research (`company:research`)",
8191
8262
  "",
8192
8263
  "**Goal:** Gather public sources into a bounded research-notes file.",
@@ -9625,6 +9696,8 @@ function buildCustomerProfileAnalystSubAgent(paths, issueDefaults, tier) {
9625
9696
  " label.",
9626
9697
  "4. Commit, push, open a PR (if applicable), and close the issue per",
9627
9698
  " your project's PR workflow.",
9699
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
9700
+ " **Origin label** section below.",
9628
9701
  "",
9629
9702
  "---",
9630
9703
  "",
@@ -9632,6 +9705,10 @@ function buildCustomerProfileAnalystSubAgent(paths, issueDefaults, tier) {
9632
9705
  "",
9633
9706
  "---",
9634
9707
  "",
9708
+ ...renderOriginStampSection(),
9709
+ "",
9710
+ "---",
9711
+ "",
9635
9712
  "## Phase 1: Discover (`customer:discover`)",
9636
9713
  "",
9637
9714
  "**Goal:** Identify and segment the customer archetypes relevant to",
@@ -12577,6 +12654,8 @@ function buildIndustryDiscoveryAnalystSubAgent(paths, issueDefaults) {
12577
12654
  " label.",
12578
12655
  "4. Commit, push, open a PR (if applicable), and close the issue per",
12579
12656
  " your project's PR workflow.",
12657
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
12658
+ " **Origin label** section below.",
12580
12659
  "",
12581
12660
  "---",
12582
12661
  "",
@@ -12584,6 +12663,10 @@ function buildIndustryDiscoveryAnalystSubAgent(paths, issueDefaults) {
12584
12663
  "",
12585
12664
  "---",
12586
12665
  "",
12666
+ ...renderOriginStampSection(),
12667
+ "",
12668
+ "---",
12669
+ "",
12587
12670
  "## Phase 1: Discover (`industry:discover`)",
12588
12671
  "",
12589
12672
  "**Goal:** Enumerate candidate industry verticals into a bounded",
@@ -13136,6 +13219,8 @@ function buildMaintenanceAuditSubAgent(paths, tier) {
13136
13219
  " label.",
13137
13220
  "4. Commit, push, open a PR (if applicable), and close the issue per",
13138
13221
  " your project's PR workflow.",
13222
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
13223
+ " **Origin label** section below.",
13139
13224
  "",
13140
13225
  ...renderIssueTypeAssignmentBlanket(),
13141
13226
  "",
@@ -13145,6 +13230,10 @@ function buildMaintenanceAuditSubAgent(paths, tier) {
13145
13230
  "",
13146
13231
  "---",
13147
13232
  "",
13233
+ ...renderOriginStampSection(),
13234
+ "",
13235
+ "---",
13236
+ "",
13148
13237
  "## Phase 1: Scan (`maint:scan`)",
13149
13238
  "",
13150
13239
  "**Goal:** Walk the configured doc tree, check every cross-reference",
@@ -14037,6 +14126,10 @@ function buildMeetingAnalystSubAgent(tier) {
14037
14126
  "",
14038
14127
  "---",
14039
14128
  "",
14129
+ ...renderOriginStampSection(),
14130
+ "",
14131
+ "---",
14132
+ "",
14040
14133
  "## Phase 1: Extract (`meeting:extract`)",
14041
14134
  "",
14042
14135
  "**Goal:** Read the available meeting inputs (notes, transcript, or both)",
@@ -20071,6 +20164,8 @@ function buildPeopleProfileAnalystSubAgent(paths, issueDefaults, tier) {
20071
20164
  " label.",
20072
20165
  "4. Commit, push, open a PR (if applicable), and close the issue per",
20073
20166
  " your project's PR workflow.",
20167
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
20168
+ " **Origin label** section below.",
20074
20169
  "",
20075
20170
  "---",
20076
20171
  "",
@@ -20078,6 +20173,10 @@ function buildPeopleProfileAnalystSubAgent(paths, issueDefaults, tier) {
20078
20173
  "",
20079
20174
  "---",
20080
20175
  "",
20176
+ ...renderOriginStampSection(),
20177
+ "",
20178
+ "---",
20179
+ "",
20081
20180
  "## Phase 1: Research (`people:research`)",
20082
20181
  "",
20083
20182
  "**Goal:** Gather public sources into a bounded research-notes file.",
@@ -20972,6 +21071,573 @@ var pnpmBundle = {
20972
21071
  ]
20973
21072
  };
20974
21073
 
21074
+ // src/agent/bundles/pr-babysitting.ts
21075
+ var BABYSIT_R1_RETIRING_ISSUE = 916;
21076
+ var BABYSIT_STALL_WINDOW_FLOOR_MINUTES = 30;
21077
+ function renderCiVerificationLines(policy) {
21078
+ const workflows = policy.ciVerification.requiredWorkflows;
21079
+ const gate = workflows.length === 0 ? [
21080
+ " This project configures **no** explicit required-workflow list,",
21081
+ " so treat **every** workflow run observed for the head SHA as",
21082
+ " required \u2014 the conservative zero-config default."
21083
+ ] : [
21084
+ " This project gates on the following required workflows; a",
21085
+ " listed workflow with no run for the head SHA counts as",
21086
+ " pending, never green:",
21087
+ "",
21088
+ ...workflows.map((name) => ` - \`${name}\``)
21089
+ ];
21090
+ return [
21091
+ "- **CI status.** Read it exactly the way the `pr-reviewer` does \u2014",
21092
+ " never invent a second contract. The primary read is the check-runs",
21093
+ " rollup (`gh pr checks <n>`). When the token is a **fine-grained**",
21094
+ " PAT that read returns",
21095
+ " `HTTP 403: Resource not accessible by personal access token`;",
21096
+ " fall back to the Actions runs API, which a fine-grained PAT with",
21097
+ " `Actions: Read-only` can read:",
21098
+ "",
21099
+ " ```bash",
21100
+ ' gh api "repos/{{repository.owner}}/{{repository.name}}/actions/runs?head_sha=<SHA>&per_page=100" \\',
21101
+ " --jq '.workflow_runs[] | {name, status, conclusion}'",
21102
+ " ```",
21103
+ "",
21104
+ ...gate,
21105
+ "",
21106
+ " A 403 is a **visibility failure, not a green signal**. Never treat",
21107
+ " an unreadable rollup as passing."
21108
+ ];
21109
+ }
21110
+ function buildBabysitPrsSkill(policy) {
21111
+ return {
21112
+ name: "babysit-prs",
21113
+ description: "Operator sweep over the open-PR queue: confirm the autonomous pipeline is merging the clean majority and intervene only on the states it cannot self-heal",
21114
+ disableModelInvocation: true,
21115
+ userInvocable: true,
21116
+ platforms: { cursor: { exclude: true } },
21117
+ instructions: [
21118
+ "# Babysit Open Pull Requests",
21119
+ "",
21120
+ "One **operator cycle** over the open-PR queue in",
21121
+ "**{{repository.owner}}/{{repository.name}}**. This skill is the",
21122
+ "operator layer that sits *above* the autonomous PR pipeline \u2014 it",
21123
+ "confirms the pipeline is keeping up and intervenes only on the",
21124
+ "small set of states the pipeline **cannot self-heal**.",
21125
+ "",
21126
+ "It is **not** a second reviewer and **not** a second orchestrator.",
21127
+ "Review and arming belong to `pr-reviewer`; issue-queue scanning and",
21128
+ "dispatch belong to `orchestrator`. See **Composability** below for",
21129
+ "the exact boundaries.",
21130
+ "",
21131
+ "## Usage",
21132
+ "",
21133
+ "```",
21134
+ "/babysit-prs [--interval <minutes>] [--once] [--dry-run]",
21135
+ "```",
21136
+ "",
21137
+ "### Flags",
21138
+ "",
21139
+ "- **`--interval <minutes>`** \u2014 pin the cycle cadence instead of",
21140
+ " self-pacing. Also sets the stall window (see **Cadence**).",
21141
+ "- **`--once`** \u2014 run a single cycle and stop without emitting a",
21142
+ " next-check recommendation. The default already runs exactly one",
21143
+ " cycle per invocation; `--once` additionally suppresses the",
21144
+ " `NEXT_CHECK_IN` line for callers that drive their own schedule.",
21145
+ "- **`--dry-run`** \u2014 classify every open PR and report the action",
21146
+ " each class *would* take, without running any of them. Nothing is",
21147
+ " pushed, armed, labelled, or commented. Use it to inspect the",
21148
+ " queue before letting the skill act.",
21149
+ "",
21150
+ "One invocation is **one cycle**. To babysit continuously, drive the",
21151
+ "skill from a loop or a scheduled task at the cadence it recommends.",
21152
+ "",
21153
+ "## Core principle \u2014 don't do redundant work",
21154
+ "",
21155
+ "The pipeline reliably reviews, arms `--auto --squash`, and merges",
21156
+ "clean PRs on its own. **Do not** re-review, re-arm, rebase, or",
21157
+ "otherwise drive a PR that is already progressing \u2014 you only race",
21158
+ "the pipeline, restart CI, and burn tokens. In the reference session",
21159
+ "this skill was distilled from, roughly **4 of every 5 cycles needed",
21160
+ "no intervention at all**.",
21161
+ "",
21162
+ "Your job is the stuck classes in **Handlers** below. For everything",
21163
+ "else: confirm it is defect-free, let the pipeline merge it, and",
21164
+ "re-check next cycle. A cycle whose entire output is",
21165
+ "`no action needed` is a **successful** cycle, not a wasted one.",
21166
+ "",
21167
+ "Two corollaries that decide most judgement calls:",
21168
+ "",
21169
+ "1. **Every act-on branch is gated on a stall window.** No PR is",
21170
+ " touched on the first cycle a signal appears. A signal must have",
21171
+ " held for at least the stall window before it counts as stuck.",
21172
+ "2. **When in doubt, report and re-check.** Reporting a PR you did",
21173
+ " not understand costs one line of output. Acting on a PR the",
21174
+ " pipeline was already handling costs a restarted CI run, a",
21175
+ " contended lease, or a lost commit.",
21176
+ "",
21177
+ "## Prerequisites & environment",
21178
+ "",
21179
+ "- **`gh` must be on `PATH`.** Some non-interactive sessions start",
21180
+ " with a minimal `PATH` that omits the package-manager prefix.",
21181
+ " Resolve it **once** per session with `command -v gh`; if that",
21182
+ " fails, prepend the platform's package prefix (for example",
21183
+ ' `export PATH="/opt/homebrew/bin:$PATH"` on Homebrew macOS,',
21184
+ " `/usr/local/bin` or `/home/linuxbrew/.linuxbrew/bin` elsewhere)",
21185
+ " and re-check. Abort the cycle with a clear diagnostic if `gh` is",
21186
+ " still unresolvable \u2014 never fall back to raw `curl`.",
21187
+ "- **Resolve the default branch from the repo, never hard-code it:**",
21188
+ "",
21189
+ " ```bash",
21190
+ " default_branch=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')",
21191
+ " ```",
21192
+ "",
21193
+ ...renderCiVerificationLines(policy),
21194
+ "- **Foreground git only.** Run every git command as a discrete",
21195
+ " foreground invocation. Do not background them and do not build",
21196
+ " sleep-loops inside a cycle \u2014 the cadence between cycles is the",
21197
+ " only waiting this skill does.",
21198
+ "- **Isolated worktree for all git surgery.** Never touch the user's",
21199
+ " working checkout. Create one detached worktree per session, reuse",
21200
+ " it across handlers, and remove it before the cycle ends:",
21201
+ "",
21202
+ " ```bash",
21203
+ ' wt="${TMPDIR:-/tmp}/babysit-prs-wt"',
21204
+ ' git worktree add --detach "$wt" "origin/$default_branch"',
21205
+ ' # \u2026reuse: git -C "$wt" <cmd> \u2026',
21206
+ ' git worktree remove --force "$wt" # always, even on abort',
21207
+ " ```",
21208
+ "",
21209
+ "- **Never force-push.** Not `--force`, not `--force-with-lease`, on",
21210
+ " any branch, for any reason. Every recipe in this skill produces a",
21211
+ " fast-forward-pushable merge commit precisely so a plain",
21212
+ " `git push` suffices.",
21213
+ "- **Scope of edits.** Only ever modify paths that the PR's **own",
21214
+ " diff already touches**. Never introduce a file the PR did not",
21215
+ " already carry, and never edit a lockfile (`pnpm-lock.yaml`,",
21216
+ " `yarn.lock`, `package-lock.json`, `**/*.lock`), anything under",
21217
+ " `**/.projen/**`, or any file whose first five lines carry a",
21218
+ " `~~ Generated by projen` / `// Generated by` marker. Those are",
21219
+ " regenerated by synth, not merged by hand.",
21220
+ "- **Merge model.** Squash. Where the default branch is protected",
21221
+ " **strict** (require-up-to-date), armed PRs legitimately sit at",
21222
+ " `BEHIND` until refreshed \u2014 that is the protection working, not a",
21223
+ " defect. An armed `--auto --squash` survives a branch refresh.",
21224
+ "",
21225
+ "## Per-cycle procedure",
21226
+ "",
21227
+ "### Step 1 \u2014 Sweep",
21228
+ "",
21229
+ "```bash",
21230
+ "gh pr list --state open --limit 100 \\",
21231
+ " --json number,title,isDraft,mergeable,mergeStateStatus,autoMergeRequest,labels,headRefName,updatedAt \\",
21232
+ " --jq '.[] | {n: .number, draft: .isDraft, mergeable, merge_state: .mergeStateStatus, armed: (.autoMergeRequest != null), labels: [.labels[].name], branch: .headRefName, updated: .updatedAt}'",
21233
+ "```",
21234
+ "",
21235
+ "One JSON object per line, all filtering done **jq-side**. Do not",
21236
+ "reformat the sweep into tab- or space-separated records and parse",
21237
+ "them in the shell: a record whose fields can be empty (labels, most",
21238
+ "commonly) collapses under the shell's default word-splitting and",
21239
+ "silently shifts every later field. Keep the data in JSON from the",
21240
+ "`gh` call to the classification decision.",
21241
+ "",
21242
+ "If the queue is empty, report `no open PRs`, emit the next-check",
21243
+ "recommendation, and stop.",
21244
+ "",
21245
+ "### Step 2 \u2014 Compute the stall window",
21246
+ "",
21247
+ `The stall window is **2 \xD7 the cycle interval**, floored at **${BABYSIT_STALL_WINDOW_FLOOR_MINUTES} minutes**.`,
21248
+ "A signal counts as *stalled* only when the PR's `updatedAt` is older",
21249
+ "than the window. `updatedAt` is deliberately conservative \u2014 any",
21250
+ "activity at all (a commit, a label, a comment, a reviewer pass)",
21251
+ "resets it, which biases the skill toward waiting rather than acting.",
21252
+ "That is the intended bias.",
21253
+ "",
21254
+ "### Step 3 \u2014 Classify each PR",
21255
+ "",
21256
+ "Assign **exactly one** class per PR, taking the first match walking",
21257
+ "the table top to bottom:",
21258
+ "",
21259
+ "| # | Class | Signal | Action |",
21260
+ "|---|-------|--------|--------|",
21261
+ "| 1 | `DRAFT` | `isDraft` is true | none \u2014 the author has not asked for review |",
21262
+ "| 2 | `IN-FLIGHT-DELEGATION` | `review:fixing` **and** `review:needs-worker` | none \u2014 a worker pull is queued (**D2**) |",
21263
+ "| 3 | `CONFIRM-PENDING` | `review:fixing` without `review:needs-worker` | none unless stalled (**D2**) |",
21264
+ "| 4 | `NEEDS-WORKER` | `review:needs-worker` without `review:fixing` | none unless stalled (**D2**) |",
21265
+ "| 5 | `LABEL-ANOMALY` | `review:awaiting-human` **and** (`review:fixing` or `review:needs-worker`) | re-invoke the reviewer (**D2**) |",
21266
+ "| 6 | `AWAITING-HUMAN` | `review:awaiting-human` alone | report, and check **R1** eligibility |",
21267
+ "| 7 | `CI-RED` | required CI concluded `failure` / `timed_out` / `cancelled` | report only (**D4**) |",
21268
+ "| 8 | `CONFLICT-SHARED-INDEX` | `mergeable` is `CONFLICTING` **and** every conflict is a shared-index row-insert race | **R1** surgery |",
21269
+ "| 9 | `CONFLICT-OTHER` | `mergeable` is `CONFLICTING`, anything else | report only (**D4**) |",
21270
+ "| 10 | `BEHIND-STALLED` | armed **and** `merge_state` is `BEHIND` **and** stalled | chase the branch (**D3**) |",
21271
+ "| 11 | `UNREVIEWED-STALLED` | not armed, no `review:*` label, no reviewer-notes comment, **and** stalled | hand to `pr-reviewer` (**D1**) |",
21272
+ "| 12 | `PROGRESSING` | anything else | none \u2014 the pipeline has it |",
21273
+ "",
21274
+ "Rows 2\u20134 are the pipeline's own legitimate intermediate states. They",
21275
+ "are listed **above** the conflict and BEHIND rows on purpose: a PR",
21276
+ "with a delegation in flight is being worked on right now, whatever",
21277
+ "else its merge state says, and touching it contends the lease.",
21278
+ "",
21279
+ "### Step 4 \u2014 Act",
21280
+ "",
21281
+ "Run the handler named in the Action column. Under `--dry-run`,",
21282
+ "print the handler that would run and move on without executing it.",
21283
+ "",
21284
+ "### Step 5 \u2014 Report and recommend a cadence",
21285
+ "",
21286
+ "Emit the report described in **Output**, then the next-check",
21287
+ "recommendation from **Cadence** (unless `--once` was passed).",
21288
+ "",
21289
+ "## Handlers",
21290
+ "",
21291
+ "Four **durable** handlers (D1\u2013D4) and one **residual** handler (R1).",
21292
+ "The durable handlers reflect permanent properties of the pipeline",
21293
+ "and branch protection; they do not go away. The residual handler is",
21294
+ "isolated behind its own heading and annotated with the issue that",
21295
+ "retires it, so deleting it is a mechanical edit.",
21296
+ "",
21297
+ "### D1 \u2014 Unreviewed and stalled \u2192 hand to `pr-reviewer` *(durable)*",
21298
+ "",
21299
+ "A PR that is not armed, carries no `review:*` label, has no sticky",
21300
+ "`## Reviewer notes` comment, and has been idle past the stall window",
21301
+ "was never picked up by a reviewer pass. Hand it to the reviewer \u2014",
21302
+ "**do not** review or arm it yourself:",
21303
+ "",
21304
+ "```",
21305
+ "/review-pr <n>",
21306
+ "```",
21307
+ "",
21308
+ "The reviewer applies the project's PR-review policy, decides",
21309
+ "`auto-merge` vs `human-required`, and arms only when the policy",
21310
+ "allows. Operator-arming an **unreviewed** PR bypasses that policy",
21311
+ "entirely and is an anti-pattern (see **Anti-patterns**).",
21312
+ "",
21313
+ "Most PRs *do* get picked up on their own. Only hand over one that",
21314
+ "has genuinely stalled.",
21315
+ "",
21316
+ "### D2 \u2014 Review-label states: classify and route, never hand-clear *(durable)*",
21317
+ "",
21318
+ "The delegation loop spans three passes and is coordinated entirely",
21319
+ "by two labels: the `review:fixing` lease and the",
21320
+ "`review:needs-worker` marker. Every combination below is a **valid**",
21321
+ "position in that loop, not a deadlock:",
21322
+ "",
21323
+ "| Labels present | Meaning | Operator action |",
21324
+ "|----------------|---------|-----------------|",
21325
+ "| `review:fixing` + `review:needs-worker` | delegation in flight; a top-level `issue-worker` pass will pull it | **none** |",
21326
+ "| `review:fixing` alone | worker finished and cleared its marker; a reviewer confirm pass owns the PR | none; if stalled, re-invoke `/review-pr <n>` |",
21327
+ "| `review:needs-worker` alone | a fix-list is queued and unconsumed | none; if stalled, **report** \u2014 the worker's own scan pulls it |",
21328
+ "| `review:awaiting-human` + either delegation label | **invariant violation** \u2014 a PR is either in the delegation loop or handed to a human, never both | re-invoke `/review-pr <n>` |",
21329
+ "",
21330
+ "**The operator never runs `gh pr edit --remove-label review:*`.**",
21331
+ "This is the single most important rule in this handler, and it is a",
21332
+ "deliberate reversal of how a human operator used to clear these.",
21333
+ "",
21334
+ "Hand-clearing was correct when a reviewer pass could hold the lease",
21335
+ "with no mechanism to ever release it. That is no longer the shape of",
21336
+ "the system. Three owners now reconcile these labels, and each one",
21337
+ "clears exactly the label it owns:",
21338
+ "",
21339
+ "- The **reviewer's confirm pass** releases `review:fixing` after the",
21340
+ " worker's report lands.",
21341
+ "- The **`issue-worker`** clears `review:needs-worker` as the",
21342
+ " mandatory, atomic completion of its hand-off \u2014 including when",
21343
+ " every fix-list item failed.",
21344
+ "- The **maintenance sweep** reconciles both stuck states without a",
21345
+ " human: it re-arms `review:needs-worker` on an orphaned lease, and",
21346
+ " removes `review:needs-worker` on a consumed-but-uncleared wedge,",
21347
+ " posting an audit-trail comment either way.",
21348
+ "",
21349
+ "An operator who strips a label out from under those owners destroys",
21350
+ "the state they key on: clearing `review:needs-worker` by hand makes",
21351
+ "an unconsumed fix-list look consumed, so the confirm pass merges a",
21352
+ "PR whose fixes were never applied; clearing `review:fixing` by hand",
21353
+ "invites a second delegation on top of a live one. Re-invoking the",
21354
+ "reviewer is strictly better in every case \u2014 its **Phase 2.8 label",
21355
+ "reconciliation** step resolves genuine invariant violations",
21356
+ "canonically, logs each correction on a `**Label reconciliation:**`",
21357
+ "line in the sticky notes comment, and only ever *removes* a",
21358
+ "contradicting label.",
21359
+ "",
21360
+ "So the durable operator capability here is **classification and",
21361
+ "routing**, not clearing. If a label state persists across several",
21362
+ "cycles even after a reviewer re-invocation, that is a pipeline bug \u2014",
21363
+ "report it and file an issue rather than papering over it by hand.",
21364
+ "",
21365
+ "### D3 \u2014 Armed but `BEHIND` past the stall window \u2192 chase *(durable)*",
21366
+ "",
21367
+ "Inherent to strict branch protection, not a bug: an armed PR must be",
21368
+ "up to date with the default branch before it can merge, and a busy",
21369
+ "default branch can outrun it. Give every freshly-armed or `BEHIND`",
21370
+ "PR **one** convergence window first \u2014 they usually self-merge.",
21371
+ "",
21372
+ "Past the stall window, refresh the branch. Prefer the API, which",
21373
+ "produces a merge commit server-side and needs no worktree:",
21374
+ "",
21375
+ "```bash",
21376
+ "gh pr update-branch <n>",
21377
+ "```",
21378
+ "",
21379
+ "If that is unavailable, do the same thing locally in the worktree",
21380
+ "and push **without** force:",
21381
+ "",
21382
+ "```bash",
21383
+ 'git -C "$wt" fetch origin',
21384
+ 'git -C "$wt" checkout -B "<branch>" "origin/<branch>"',
21385
+ 'git -C "$wt" merge --no-edit "origin/$default_branch"',
21386
+ 'git -C "$wt" push origin "<branch>"',
21387
+ "```",
21388
+ "",
21389
+ "**Merge, never rebase.** The PR branch is already published and",
21390
+ "diverged, so a rebase rewrites history that others have fetched and",
21391
+ "forces a `--force-with-lease` push this skill forbids. A merge",
21392
+ "commit is fast-forward-pushable with a plain `git push`. Squash-merge",
21393
+ "collapses the merge commit at merge time anyway, so it costs nothing",
21394
+ "in the final history.",
21395
+ "",
21396
+ "If the merge conflicts, **abort it** (`git merge --abort`) and",
21397
+ "re-classify the PR as a conflict class \u2014 do not resolve conflicts in",
21398
+ "this handler.",
21399
+ "",
21400
+ "### D4 \u2014 Report-only classes *(durable)*",
21401
+ "",
21402
+ "Some classes are genuinely not operator work. Report them with one",
21403
+ "line each and take no action:",
21404
+ "",
21405
+ "- **`CI-RED`** \u2014 a required workflow concluded red. A permanent",
21406
+ " failure is the author's or the reviewer's to fix, and the reviewer",
21407
+ " already flags it with `status:needs-attention`. Never rerun CI to",
21408
+ " see if it goes away, and never refresh the branch to restart it.",
21409
+ "- **`CONFLICT-OTHER`** \u2014 a conflict outside the shared-index class.",
21410
+ " The reviewer's typed generic recipe delegates these to",
21411
+ " `issue-worker`; hand-merging one here duplicates that path and",
21412
+ " risks resolving it differently than the pipeline would.",
21413
+ "- **`AWAITING-HUMAN`** \u2014 the reviewer finished and handed the merge",
21414
+ " decision to a human. Surface it so the human sees it. (Check **R1**",
21415
+ " eligibility first \u2014 a hand-off caused by a *failed* shared-index",
21416
+ " fix is the one case where the pipeline explicitly asked for this",
21417
+ " kind of help.)",
21418
+ "- **`DRAFT`** \u2014 the author has not asked for review yet.",
21419
+ "",
21420
+ `### R1 \u2014 Shared-index merge conflict *(residual \u2014 retires with #${BABYSIT_R1_RETIRING_ISSUE})*`,
21421
+ "",
21422
+ `> **Deleting this handler.** When #${BABYSIT_R1_RETIRING_ISSUE} lands, delete this`,
21423
+ "> entire `### R1` section, drop row 8 (`CONFLICT-SHARED-INDEX`) from",
21424
+ "> the classification table, and delete the matching eval. Nothing",
21425
+ "> else in this skill references it.",
21426
+ "",
21427
+ "Two PRs raced to insert a row into the same shared registry, index,",
21428
+ "or feature-matrix page and the loser is `CONFLICTING`. The pipeline",
21429
+ "handles the common case on its own: the reviewer classifies the",
21430
+ "conflict, emits a `synthetic:rebase-shared-index` fix-list item, and",
21431
+ "an `issue-worker` applies the typed re-insert recipe. **This handler",
21432
+ "exists only for the cases where that delegation could not run.**",
21433
+ "",
21434
+ "#### Eligibility \u2014 all four must hold",
21435
+ "",
21436
+ "1. **Every** conflicting path matches one of the shared-index globs:",
21437
+ "",
21438
+ ...DEFAULT_SHARED_INDEX_PATHS.map((p) => ` - \`${p}\``),
21439
+ "",
21440
+ "2. **Every** conflict hunk touches data rows only. Inspect each",
21441
+ " `<<<<<<<` / `=======` / `>>>>>>>` hunk: every conflicting line",
21442
+ " must start with `| ` and be neither the table header row nor the",
21443
+ " `|---|---|` separator. If any hunk touches the frontmatter block,",
21444
+ " the page H1, surrounding prose, the header row, or the separator",
21445
+ " row, this is **not** a row-insert race \u2014 re-classify as",
21446
+ " `CONFLICT-OTHER` and report.",
21447
+ "3. No conflicting path is a lockfile, lives under `**/.projen/**`, or",
21448
+ " carries a generated-file marker in its first five lines.",
21449
+ "4. The PR does **not** carry `review:human-required`, and one of:",
21450
+ " - it carries `review:awaiting-human` **and** its most recent",
21451
+ " worker-report comment records a",
21452
+ " `synthetic:rebase-shared-index` item as `failed` \u2014 the pipeline",
21453
+ " tried, could not finish, and explicitly asked for a human; **or**",
21454
+ " - it has been `CONFLICTING` past the stall window with **neither**",
21455
+ " `review:fixing` nor `review:needs-worker` \u2014 no delegation is in",
21456
+ " flight and none fired.",
21457
+ "",
21458
+ "If any check fails, report the PR and move on. In particular a",
21459
+ "`review:human-required` PR is never resolved here: pushing",
21460
+ "operator-merged content into it expands the diff the human is",
21461
+ "reviewing without their consent.",
21462
+ "",
21463
+ "#### Recipe",
21464
+ "",
21465
+ "Deliberately **identical** to the worker's typed",
21466
+ "`synthetic:rebase-shared-index` recipe, so an operator resolution and",
21467
+ "a pipeline resolution can never produce different content.",
21468
+ "",
21469
+ "```bash",
21470
+ 'git -C "$wt" fetch origin',
21471
+ 'git -C "$wt" checkout -B "<branch>" "origin/<branch>"',
21472
+ 'git -C "$wt" merge --no-edit "origin/$default_branch"',
21473
+ "```",
21474
+ "",
21475
+ "For each conflicting file, resolve by **union**: the `<<<<<<< HEAD`",
21476
+ "side carries this PR's row and the other side carries the row that",
21477
+ "already merged. Keep **both**, re-inserted in the file's declared",
21478
+ "sort order (alphabetical on the first column unless the page",
21479
+ "documents otherwise), remove the conflict markers, and stage it:",
21480
+ "",
21481
+ "```bash",
21482
+ 'git -C "$wt" add "<path>"',
21483
+ "```",
21484
+ "",
21485
+ "Then verify each re-inserted row appears **exactly once** in the",
21486
+ "staged content \u2014 zero means the row was dropped, more than one means",
21487
+ "the merge duplicated it:",
21488
+ "",
21489
+ "```bash",
21490
+ 'count=$(git -C "$wt" show ":<path>" | grep -Fc "<row-unique-marker>")',
21491
+ '[ "$count" = "1" ] || { echo "BLOCKED verification failed for <path>"; exit 1; }',
21492
+ "```",
21493
+ "",
21494
+ "On any `BLOCKED` result, run `git merge --abort`, report the PR as",
21495
+ "`BLOCKED <reason>`, and leave it for a human. Otherwise complete the",
21496
+ "merge and push \u2014 plain push, never force:",
21497
+ "",
21498
+ "```bash",
21499
+ 'git -C "$wt" commit --no-edit',
21500
+ 'git -C "$wt" push origin "<branch>"',
21501
+ "```",
21502
+ "",
21503
+ "Do **not** arm the PR afterwards. Resolving the conflict returns it",
21504
+ "to a state the pipeline can act on; the next reviewer pass decides",
21505
+ "whether it merges. If the PR carried `review:awaiting-human`, leave",
21506
+ "that label alone (**D2**) and note the resolution in the report so",
21507
+ "the human can act on a now-mergeable PR.",
21508
+ "",
21509
+ "A PR in this class may need re-resolving after each sibling merges",
21510
+ "into the same page. That is expected; it converges.",
21511
+ "",
21512
+ "## Anti-patterns",
21513
+ "",
21514
+ "- **Don't refresh or rebase an armed PR that is merely `BLOCKED` on a",
21515
+ " queued CI run.** You will restart CI and push the merge further",
21516
+ " away. Diagnose the merge state before touching the branch.",
21517
+ "- **Don't operator-arm an unreviewed PR.** Arming is the reviewer's",
21518
+ " decision, made under the project's PR-review policy. Hand it to",
21519
+ " `/review-pr` instead (**D1**).",
21520
+ "- **Don't hand-clear `review:*` labels** (**D2**). Route to the owner",
21521
+ " that clears each one.",
21522
+ "- **Don't force-push.** Ever, on any branch.",
21523
+ "- **Don't hand-merge a non-shared-index conflict.** The pipeline has",
21524
+ " a typed recipe for those; duplicating it here invites divergence.",
21525
+ "- **Don't edit a path the PR's own diff does not already touch**, and",
21526
+ " never a lockfile or generated file.",
21527
+ "- **Don't act on the first sighting of a signal.** Every act-on",
21528
+ " branch is stall-window gated for a reason.",
21529
+ "- **Don't scan the issue queue and don't dispatch `issue-worker` on",
21530
+ " an issue.** That is the orchestrator's job, not this skill's.",
21531
+ "",
21532
+ "## Composability",
21533
+ "",
21534
+ "This skill composes with the pipeline; it never reimplements it.",
21535
+ "",
21536
+ "- **`pr-reviewer` owns review and arming.** Every path in this skill",
21537
+ " that needs a PR reviewed, re-confirmed, or armed invokes",
21538
+ " `/review-pr <n>` and lets the reviewer apply the policy. This skill",
21539
+ " contains no acceptance-criteria checking, no policy evaluation, and",
21540
+ " no `gh pr merge --auto` call.",
21541
+ "- **`orchestrator` owns the issue queue.** This skill never runs the",
21542
+ " queue scan, never claims or labels an issue, never creates a",
21543
+ " branch for an issue, and never dispatches `issue-worker` on one. It",
21544
+ " reads **open PRs** only.",
21545
+ "- **`issue-worker` owns fix-list application.** This skill never",
21546
+ " posts a fix-list, never applies one, and never writes a",
21547
+ " worker-report comment.",
21548
+ "- **The maintenance sweep owns stale-lease reconcile.** This skill",
21549
+ " observes lease states; it does not reconcile them.",
21550
+ "",
21551
+ "The only writes this skill makes are: `gh pr update-branch` (**D3**),",
21552
+ "a non-force `git push` of a conflict resolution (**R1**), and its own",
21553
+ "report. Everything else is a read or a delegation.",
21554
+ "",
21555
+ "Origin labels are **not** an eligibility gate here. Sweep and",
21556
+ `auto-merge eligibility have never been origin-gated, and ${DELEGATION_ELIGIBLE_ORIGIN_LIST}`,
21557
+ "both mark a PR bot-authored for fix-delegation purposes. Classify",
21558
+ "every open PR regardless of origin label \u2014 including PRs carrying",
21559
+ "none. Origin labels matter only where this skill quotes the",
21560
+ "reviewer's delegation guard, which admits",
21561
+ `${DELEGATION_ELIGIBLE_ORIGIN_PHRASE}.`,
21562
+ "",
21563
+ "## Output",
21564
+ "",
21565
+ "One line per PR, then a summary, then the cadence recommendation:",
21566
+ "",
21567
+ "```",
21568
+ "Cycle <ISO-8601 UTC> (stall window: <n>m)",
21569
+ " PR #<n> <CLASS> <action taken, or 'no action'>",
21570
+ " PR #<n> <CLASS> <action taken, or 'no action'>",
21571
+ "Summary: <total> open, <acted> acted on, <left> left to the pipeline",
21572
+ "NEXT_CHECK_IN <minutes>",
21573
+ "```",
21574
+ "",
21575
+ "Under `--dry-run`, the action column reads `would: <handler>` and the",
21576
+ "summary reports `0 acted on`.",
21577
+ "",
21578
+ "## Cadence",
21579
+ "",
21580
+ "The workload is **bursty** \u2014 quiet stretches punctuated by batches of",
21581
+ "related PRs \u2014 and mostly idle. A fixed 15-minute cadence was measured",
21582
+ "as too frequent for it: it multiplies no-op cycles without landing",
21583
+ "stuck PRs meaningfully sooner.",
21584
+ "",
21585
+ "**Preferred \u2014 dynamic self-pacing.** End each cycle by choosing the",
21586
+ "next delay from what the sweep actually saw:",
21587
+ "",
21588
+ "| Observation | `NEXT_CHECK_IN` |",
21589
+ "|-------------|-----------------|",
21590
+ "| Any conflict class, label anomaly, or a batch actively landing | 15 minutes |",
21591
+ "| All open PRs clean, armed, or converging | 25\u201330 minutes |",
21592
+ "| Queue empty | 45\u201360 minutes |",
21593
+ "",
21594
+ "**Simple \u2014 fixed interval.** Pass `--interval 30`. Thirty minutes",
21595
+ "halves the idle-cycle overhead versus fifteen and still catches stuck",
21596
+ "PRs well inside a tolerable window, because the default branch keeps",
21597
+ "advancing around a stuck PR regardless.",
21598
+ "",
21599
+ "Drop to 15 minutes only when you specifically want stuck PRs cleared",
21600
+ "as fast as possible during a heavy burst and accept the idle",
21601
+ "overhead."
21602
+ ].join("\n"),
21603
+ referenceFiles: [
21604
+ {
21605
+ path: "evals/evals.json",
21606
+ content: JSON.stringify(
21607
+ {
21608
+ skill_name: "babysit-prs",
21609
+ evals: [
21610
+ {
21611
+ id: 1,
21612
+ prompt: "/babysit-prs \u2014 there are three open PRs. #101 is armed for squash auto-merge and reports mergeStateStatus BEHIND, last updated four minutes ago. #102 carries review:fixing and review:needs-worker. #103 is MERGEABLE, armed, and CI is green.",
21613
+ expected_output: "The skill takes no action on any of the three and says so explicitly. #101 classifies as PROGRESSING, not BEHIND-STALLED: it was updated four minutes ago, well inside the stall window (2 x the interval, floored at 30 minutes), so it gets its convergence window and is left alone \u2014 no `gh pr update-branch`, no worktree, no push. #102 classifies as IN-FLIGHT-DELEGATION and is left untouched; the skill does not clear `review:fixing` or `review:needs-worker`, does not post a fix-list, and does not invoke the reviewer. #103 classifies as PROGRESSING and is left for the pipeline to merge. The report lists one line per PR with `no action`, a summary reading 3 open / 0 acted on / 3 left to the pipeline, and a NEXT_CHECK_IN recommendation of 25-30 minutes because everything is clean or converging. The skill never scans the issue queue and never calls `gh pr merge --auto`.",
21614
+ files: [],
21615
+ product_context_refs: []
21616
+ },
21617
+ {
21618
+ id: 2,
21619
+ prompt: "/babysit-prs \u2014 PR #204 is CONFLICTING. The only conflicting file is docs/src/content/docs/profiles/companies/index.md and the conflict is a single pair of table rows that two PRs inserted at the same position. The PR has carried review:awaiting-human for two hours with no review:fixing or review:needs-worker, and its latest worker-report comment records the synthetic:rebase-shared-index item as failed.",
21620
+ expected_output: "The skill classifies #204 as CONFLICT-SHARED-INDEX and runs the R1 handler, having confirmed all four eligibility checks: the path matches the shared-index glob set, every conflict hunk touches only `| ` data rows (not the frontmatter, H1, table header, or separator row), no conflicting path is a lockfile or projen-generated file, and the PR lacks `review:human-required` while carrying `review:awaiting-human` alongside a failed `synthetic:rebase-shared-index` worker report. It creates or reuses a detached worktree outside the user's checkout, checks out the PR branch there, merges the default branch in (merge, never rebase), resolves the conflict by union \u2014 keeping both rows, re-inserted in the file's declared sort order \u2014 stages the file, and verifies with `git show :<path> | grep -Fc` that each re-inserted row appears exactly once. On success it completes the merge commit and pushes with a plain non-force `git push`. It does NOT arm the PR, does NOT remove the `review:awaiting-human` label, and does NOT force-push. It removes the worktree before finishing and reports the resolution so the human sees a now-mergeable PR. Had any verification returned a count other than 1, the expected behaviour is `git merge --abort` plus a `BLOCKED` report line rather than a push.",
21621
+ files: [],
21622
+ product_context_refs: []
21623
+ },
21624
+ {
21625
+ id: 3,
21626
+ prompt: "/babysit-prs --interval 30 \u2014 PR #305 has been armed for squash auto-merge and stuck at mergeStateStatus BEHIND for the last three hours with no other activity. PR #306 carries both review:awaiting-human and review:needs-worker.",
21627
+ expected_output: "#305 classifies as BEHIND-STALLED: it is armed, BEHIND, and its updatedAt is older than the 60-minute stall window (2 x the 30-minute interval). The skill chases it by refreshing the branch, preferring `gh pr update-branch 305`; if that is unavailable it falls back to a worktree checkout plus `git merge --no-edit origin/<default-branch>` and a plain `git push`. It never rebases and never force-pushes, and if the local merge conflicts it aborts the merge and re-classifies rather than resolving. #306 classifies as LABEL-ANOMALY \u2014 `review:awaiting-human` together with a fix-delegation label is a mutually-exclusive invariant violation \u2014 and the skill re-invokes `/review-pr 306` so the reviewer's Phase 2.8 label reconciliation resolves it canonically and logs the correction. The skill explicitly does NOT run `gh pr edit --remove-label` on either `review:awaiting-human` or `review:needs-worker`, because the reviewer confirm pass, the issue-worker, and the maintenance sweep each own clearing their own label. The cadence line reports the pinned 30-minute interval.",
21628
+ files: [],
21629
+ product_context_refs: []
21630
+ }
21631
+ ]
21632
+ },
21633
+ null,
21634
+ 2
21635
+ )
21636
+ }
21637
+ ]
21638
+ };
21639
+ }
21640
+
20975
21641
  // src/agent/bundles/pr-review-policy.ts
20976
21642
  var DEFAULT_PATHS_EXEMPT_FROM_SIZE = [
20977
21643
  "docs/**"
@@ -21040,14 +21706,14 @@ var prReviewerSubAgent = {
21040
21706
  "",
21041
21707
  "- **`--allow-human-author`** \u2014 opt-in flag that allows the reviewer to",
21042
21708
  " process PRs authored by humans in addition to bot-authored PRs",
21043
- " (those carrying the `origin:issue-worker` label). When absent, the",
21709
+ ` (those carrying ${DELEGATION_ELIGIBLE_ORIGIN_LIST}). When absent, the`,
21044
21710
  " reviewer only processes bot-authored PRs; when present, human-authored",
21045
21711
  " PRs are also eligible for this invocation only. The flag does **not**",
21046
21712
  " persist across invocations.",
21047
21713
  "",
21048
21714
  "Phase 4's invocation guard enforces the bot-only default and the",
21049
- "`--allow-human-author` opt-out. PRs without the `origin:issue-worker`",
21050
- "label are still classified, commented on, reacted to, and (in",
21715
+ "`--allow-human-author` opt-out. PRs carrying **no** origin label are",
21716
+ "still classified, commented on, reacted to, and (in",
21051
21717
  "`auto-merge` mode) auto-merged when the AC/CI checks pass \u2014 only the",
21052
21718
  "delegation hand-off to `issue-worker` is gated.",
21053
21719
  "",
@@ -21778,12 +22444,17 @@ var prReviewerSubAgent = {
21778
22444
  "Before delegating any in-scope fix to `issue-worker`, verify the",
21779
22445
  "delegation is permitted by author identity:",
21780
22446
  "",
21781
- "- If the PR carries the `origin:issue-worker` label, delegation is",
21782
- " permitted.",
22447
+ `- If the PR carries the \`${ORIGIN_ISSUE_WORKER_LABEL}\` label **or** the`,
22448
+ ` \`${ORIGIN_AGENT_LABEL}\` label, delegation is permitted. Both are`,
22449
+ " agent-origin labels and both are delegation-eligible:",
22450
+ ` \`${ORIGIN_ISSUE_WORKER_LABEL}\` marks a PR opened by the \`issue-worker\``,
22451
+ ` agent specifically; \`${ORIGIN_AGENT_LABEL}\` is the umbrella label the`,
22452
+ " phased analyst/writer family stamps on the PRs it opens. Treat them",
22453
+ " identically for this guard \u2014 neither requires `--allow-human-author`.",
21783
22454
  "- If the invocation prompt contains the literal flag",
21784
22455
  " `--allow-human-author`, delegation is permitted for this invocation",
21785
22456
  " only.",
21786
- "- Otherwise (human-authored PR with no opt-in flag) the reviewer",
22457
+ "- Otherwise (no agent-origin label and no opt-in flag) the reviewer",
21787
22458
  " **must not delegate**. It still classifies comments (Phase 3.5),",
21788
22459
  " posts replies, applies reactions, updates the sticky summary, and",
21789
22460
  " (when in `auto-merge` mode and the AC/CI checks pass) enables",
@@ -22315,9 +22986,11 @@ var prReviewerSubAgent = {
22315
22986
  " reviewed diff than the clean merge-commit `gh pr update-branch`",
22316
22987
  " performs on a no-conflict branch.)",
22317
22988
  "2. **Delegation invocation guard permits the hand-off** \u2014 the PR",
22318
- " carries the `origin:issue-worker` label, **or** the reviewer was",
22989
+ ` carries the \`${ORIGIN_ISSUE_WORKER_LABEL}\` label or the`,
22990
+ ` \`${ORIGIN_AGENT_LABEL}\` label, **or** the reviewer was`,
22319
22991
  " invoked with `--allow-human-author`. The same guard used for the",
22320
- " in-scope-fix delegation flow applies here unchanged.",
22992
+ " in-scope-fix delegation flow applies here unchanged \u2014 both",
22993
+ " agent-origin labels are delegation-eligible.",
22321
22994
  "3. **The `review:fixing` lease is currently free.** If",
22322
22995
  " `review:fixing` is already on the PR, another delegation is",
22323
22996
  " in-flight; skip conflict-resolution delegation, log the contention",
@@ -22748,7 +23421,7 @@ var prReviewerSubAgent = {
22748
23421
  " to `human-required`, Phase 4 applies `review:awaiting-human` and",
22749
23422
  " exits. Even if every acceptance criterion is met and CI is green,",
22750
23423
  " `gh pr merge --auto` is forbidden in that mode.",
22751
- "6. **Never push commits to the PR's branch yourself.** The reviewer is a decision-maker and orchestrator, not an implementer. When in-scope review comments require code changes **and** the PR carries the `origin:issue-worker` label (or the invocation prompt explicitly allows human-authored PRs via `--allow-human-author`), delegate the fix **by marker, not by spawn**: post a fix-list comment on the PR, apply the `review:needs-worker` label, hold the `review:fixing` lease, and exit returning `delegated`. Do **not** invoke `issue-worker` via the `Agent` tool \u2014 the reviewer often runs at depth-1 where nested sub-agent spawning is forbidden, so an in-session dispatch would silently abort. A top-level `issue-worker` session pulls the marker and applies the fix; a later reviewer confirm pass releases the lease. You must never call `git commit`, `git push`, `git rebase`, or `gh pr edit` against the head branch from this agent \u2014 all branch mutations belong to `issue-worker`.",
23424
+ `6. **Never push commits to the PR's branch yourself.** The reviewer is a decision-maker and orchestrator, not an implementer. When in-scope review comments require code changes **and** the PR carries ${DELEGATION_ELIGIBLE_ORIGIN_PHRASE} (or the invocation prompt explicitly allows human-authored PRs via \`--allow-human-author\`), delegate the fix **by marker, not by spawn**: post a fix-list comment on the PR, apply the \`review:needs-worker\` label, hold the \`review:fixing\` lease, and exit returning \`delegated\`. Do **not** invoke \`issue-worker\` via the \`Agent\` tool \u2014 the reviewer often runs at depth-1 where nested sub-agent spawning is forbidden, so an in-session dispatch would silently abort. A top-level \`issue-worker\` session pulls the marker and applies the fix; a later reviewer confirm pass releases the lease. You must never call \`git commit\`, \`git push\`, \`git rebase\`, or \`gh pr edit\` against the head branch from this agent \u2014 all branch mutations belong to \`issue-worker\`.`,
22752
23425
  "7. **Do not implement code.** You review, decide, and orchestrate. If",
22753
23426
  " the PR needs code changes and delegation is not permitted by Rule",
22754
23427
  " #6, comment and stop \u2014 do not attempt to fix it yourself.",
@@ -22848,8 +23521,8 @@ var reviewPrSkill = {
22848
23521
  "",
22849
23522
  "- **`--allow-human-author`** \u2014 opt the reviewer into processing",
22850
23523
  " human-authored PRs for **this invocation only**. By default, the",
22851
- " reviewer only processes bot-authored PRs (those carrying the",
22852
- " `origin:issue-worker` label); pass this flag to review a",
23524
+ " reviewer only processes bot-authored PRs (those carrying",
23525
+ ` ${DELEGATION_ELIGIBLE_ORIGIN_LIST}); pass this flag to review a`,
22853
23526
  " human-authored PR. The flag does not persist \u2014 subsequent",
22854
23527
  " invocations return to the bot-only default.",
22855
23528
  "",
@@ -22868,7 +23541,7 @@ var reviewPrSkill = {
22868
23541
  "",
22869
23542
  "Passing `--allow-human-author` opts the reviewer into processing",
22870
23543
  "human-authored PRs for this invocation only (the default scope is",
22871
- "bot-authored PRs labeled `origin:issue-worker`).",
23544
+ `bot-authored PRs carrying ${DELEGATION_ELIGIBLE_ORIGIN_LIST}).`,
22872
23545
  "",
22873
23546
  "## Input",
22874
23547
  "",
@@ -22910,8 +23583,8 @@ var reviewPrsSkill = {
22910
23583
  "",
22911
23584
  "- **`--allow-human-author`** \u2014 opt the reviewer into processing",
22912
23585
  " human-authored PRs for **this invocation only**. By default, the",
22913
- " loop only processes bot-authored PRs (those carrying the",
22914
- " `origin:issue-worker` label); pass this flag to include",
23586
+ " loop only processes bot-authored PRs (those carrying",
23587
+ ` ${DELEGATION_ELIGIBLE_ORIGIN_LIST}); pass this flag to include`,
22915
23588
  " human-authored PRs in the queue. The flag does not persist \u2014",
22916
23589
  " subsequent invocations return to the bot-only default.",
22917
23590
  "",
@@ -22963,7 +23636,7 @@ var reviewPrsSkill = {
22963
23636
  "",
22964
23637
  "Passing `--allow-human-author` opts the reviewer into including",
22965
23638
  "human-authored PRs in the queue for this invocation only (the default",
22966
- "scope is bot-authored PRs labeled `origin:issue-worker`).",
23639
+ `scope is bot-authored PRs carrying ${DELEGATION_ELIGIBLE_ORIGIN_LIST}).`,
22967
23640
  "",
22968
23641
  "## Output",
22969
23642
  "",
@@ -23005,7 +23678,11 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
23005
23678
  // `agentConfig.additionalRulePaths`.
23006
23679
  filePatterns: [
23007
23680
  ".claude/agents/pr-reviewer.md",
23008
- ".claude/skills/review-pr/**"
23681
+ ".claude/skills/review-pr/**",
23682
+ // The operator skill quotes the policy's CI-verification
23683
+ // contract verbatim; loading the policy when it is edited
23684
+ // keeps the two from drifting.
23685
+ ".claude/skills/babysit-prs/**"
23009
23686
  ],
23010
23687
  content: [
23011
23688
  "# PR Review Policy",
@@ -23309,7 +23986,10 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
23309
23986
  // `agentConfig.additionalRulePaths`.
23310
23987
  filePatterns: [
23311
23988
  ".claude/agents/pr-reviewer.md",
23312
- ".claude/agents/issue-worker.md"
23989
+ ".claude/agents/issue-worker.md",
23990
+ // The operator skill's D2 handler routes on the label states
23991
+ // this protocol defines; it must load alongside them.
23992
+ ".claude/skills/babysit-prs/**"
23313
23993
  ],
23314
23994
  content: [
23315
23995
  "# PR Review Feedback Protocol",
@@ -23609,7 +24289,7 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
23609
24289
  "",
23610
24290
  "### Label Glossary",
23611
24291
  "",
23612
- "Six review-workflow labels drive the feedback loop. They are",
24292
+ "Seven review-workflow labels drive the feedback loop. They are",
23613
24293
  "**contributed by the pr-review bundle's label set** and auto-sync",
23614
24294
  "into every consumer's label registry \u2014 the same way the",
23615
24295
  "`type:*` / `priority:*` / `status:*` taxonomy ships. Consumers do",
@@ -23619,7 +24299,8 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
23619
24299
  "",
23620
24300
  "| Label | Purpose |",
23621
24301
  "|-------|---------|",
23622
- "| `origin:issue-worker` | PR was opened by the `issue-worker` agent. Eligible for auto-delegation of in-scope fixes. Human-authored PRs lack this label and will not trigger delegation unless the reviewer is invoked with `--allow-human-author`. |",
24302
+ `| \`${ORIGIN_ISSUE_WORKER_LABEL}\` | PR was opened by the \`issue-worker\` agent specifically. Eligible for auto-delegation of in-scope fixes. |`,
24303
+ `| \`${ORIGIN_AGENT_LABEL}\` | **Umbrella origin label for agent-opened PRs.** Stamped by every phased analyst/writer agent (people-profile, company-profile, software-profile, customer-profile, bcm-writer, industry-discovery, business-models, standards-research, regulatory-research, maintenance-audit, meeting-analysis, agenda, research-pipeline, requirements-analyst, requirements-reviewer, requirements-writer) on the PRs it opens. Delegation-eligible on exactly the same terms as \`${ORIGIN_ISSUE_WORKER_LABEL}\` \u2014 the analyst family stamps this instead of \`${ORIGIN_ISSUE_WORKER_LABEL}\` because claiming the latter on a non-worker PR would be false. Human-authored PRs carry neither origin label and will not trigger delegation unless the reviewer is invoked with \`--allow-human-author\`. This label gates fix-**delegation** only; sweep and auto-merge eligibility have never been origin-gated. |`,
23623
24304
  "| `review:human-required` | Force human review regardless of what the policy would otherwise decide. The reviewer never enables auto-merge on a PR carrying this label. |",
23624
24305
  "| `review:auto-ok` | Force auto-merge regardless of what the policy would otherwise decide. **Also resolves outstanding `thinking_face` pushbacks** as an explicit maintainer override; the reviewer logs the override in the sticky summary. |",
23625
24306
  "| `review:awaiting-human` | Set by the reviewer when it completes its work on a `human-required` PR and is handing off the final merge decision. Cleared by a human (or by `review:auto-ok` flipping the PR back to `auto-merge` mode). |",
@@ -23629,8 +24310,8 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
23629
24310
  "### Reviewing Human-Authored PRs: the `--allow-human-author` Flag",
23630
24311
  "",
23631
24312
  "By default the reviewer only **delegates** in-scope fixes on",
23632
- "bot-authored PRs \u2014 those carrying the `origin:issue-worker`",
23633
- "label. Running `/review-pr <n>` or `/review-prs` on a",
24313
+ `bot-authored PRs \u2014 those carrying ${DELEGATION_ELIGIBLE_ORIGIN_PHRASE}.`,
24314
+ "Running `/review-pr <n>` or `/review-prs` on a",
23634
24315
  "human-authored PR still produces a full review (reactions,",
23635
24316
  "replies, sticky summary, and auto-merge when the policy allows",
23636
24317
  "it) but skips the delegation hand-off to `issue-worker` \u2014 the",
@@ -23655,7 +24336,12 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
23655
24336
  tags: ["workflow"]
23656
24337
  }
23657
24338
  ],
23658
- skills: [reviewPrSkill, reviewPrsSkill],
24339
+ // `babysit-prs` is built from the resolved policy here rather than
24340
+ // declared as a module-level const, so the consumer's
24341
+ // `ci-verification.required-workflows` is baked into the rendered
24342
+ // skill at bundle-build time. Nothing rewrites skill content after
24343
+ // the bundle is assembled.
24344
+ skills: [reviewPrSkill, reviewPrsSkill, buildBabysitPrsSkill(policy)],
23659
24345
  subAgents: [prReviewerSubAgent],
23660
24346
  labels: [
23661
24347
  {
@@ -23664,10 +24350,15 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
23664
24350
  description: "PR review tasks"
23665
24351
  },
23666
24352
  {
23667
- name: "origin:issue-worker",
24353
+ name: ORIGIN_ISSUE_WORKER_LABEL,
23668
24354
  color: "5319E7",
23669
24355
  description: "PR opened by the issue-worker agent"
23670
24356
  },
24357
+ {
24358
+ name: ORIGIN_AGENT_LABEL,
24359
+ color: "5319E7",
24360
+ description: "PR opened by an agent in this project's pipeline; eligible for autonomous fix delegation"
24361
+ },
23671
24362
  {
23672
24363
  name: "review:auto-ok",
23673
24364
  color: "0E8A16",
@@ -24319,6 +25010,8 @@ function buildRegulatoryResearchAnalystSubAgent(paths, issueDefaults) {
24319
25010
  " label.",
24320
25011
  "4. Commit, push, open a PR (if applicable), and close the issue per",
24321
25012
  " your project's PR workflow.",
25013
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
25014
+ " **Origin label** section below.",
24322
25015
  "",
24323
25016
  "---",
24324
25017
  "",
@@ -24326,6 +25019,10 @@ function buildRegulatoryResearchAnalystSubAgent(paths, issueDefaults) {
24326
25019
  "",
24327
25020
  "---",
24328
25021
  "",
25022
+ ...renderOriginStampSection(),
25023
+ "",
25024
+ "---",
25025
+ "",
24329
25026
  "## Phase 1: Scan (`regulatory:scan`)",
24330
25027
  "",
24331
25028
  "**Goal:** Enumerate regulations applicable to a given scope \u2014",
@@ -27526,6 +28223,8 @@ function buildRequirementsWriterSubAgent(paths) {
27526
28223
  "4. Commit, push, open a PR, and close the issue per your project's",
27527
28224
  " PR workflow. Closing the PR transitions the issue to",
27528
28225
  " `status:done` per the standard label conventions.",
28226
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
28227
+ " **Origin label** section below.",
27529
28228
  "",
27530
28229
  "---",
27531
28230
  "",
@@ -27533,6 +28232,10 @@ function buildRequirementsWriterSubAgent(paths) {
27533
28232
  "",
27534
28233
  "---",
27535
28234
  "",
28235
+ ...renderOriginStampSection(),
28236
+ "",
28237
+ "---",
28238
+ "",
27536
28239
  "## The `req:write` Issue Schema",
27537
28240
  "",
27538
28241
  "This section is the **authoritative schema** for `req:write` issue",
@@ -28168,6 +28871,8 @@ function buildRequirementsAnalystSubAgent(paths, issueDefaults) {
28168
28871
  "3. Execute the phase handler that matches the issue's `req:*` label.",
28169
28872
  "4. Commit, push, open a PR (if applicable), and close the issue per your",
28170
28873
  " project's PR workflow.",
28874
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
28875
+ " **Origin label** section below.",
28171
28876
  "",
28172
28877
  "---",
28173
28878
  "",
@@ -28175,6 +28880,10 @@ function buildRequirementsAnalystSubAgent(paths, issueDefaults) {
28175
28880
  "",
28176
28881
  "---",
28177
28882
  "",
28883
+ ...renderOriginStampSection(),
28884
+ "",
28885
+ "---",
28886
+ "",
28178
28887
  "## Phase 1: Scan (`req:scan`)",
28179
28888
  "",
28180
28889
  "**Goal:** Read source documents, identify where requirements are missing,",
@@ -28771,6 +29480,10 @@ function buildRequirementsReviewerSubAgent(paths, issueDefaults) {
28771
29480
  "",
28772
29481
  "---",
28773
29482
  "",
29483
+ ...renderOriginStampSection(),
29484
+ "",
29485
+ "---",
29486
+ "",
28774
29487
  "## Phase Router",
28775
29488
  "",
28776
29489
  "Before reading any documents, classify the session by reading the",
@@ -30150,6 +30863,8 @@ function buildResearchAnalystSubAgent(paths) {
30150
30863
  " label.",
30151
30864
  "4. Commit, push, open a PR (if applicable), and close the issue per",
30152
30865
  " your project's PR workflow.",
30866
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
30867
+ " **Origin label** section below.",
30153
30868
  "",
30154
30869
  "---",
30155
30870
  "",
@@ -30157,6 +30872,10 @@ function buildResearchAnalystSubAgent(paths) {
30157
30872
  "",
30158
30873
  "---",
30159
30874
  "",
30875
+ ...renderOriginStampSection(),
30876
+ "",
30877
+ "---",
30878
+ "",
30160
30879
  "## Phase 1: Scope (`research:scope`)",
30161
30880
  "",
30162
30881
  "**Goal:** Turn a natural-language research question into a bounded",
@@ -30895,6 +31614,8 @@ function buildSoftwareProfileAnalystSubAgent(paths, issueDefaults, tier) {
30895
31614
  " label.",
30896
31615
  "4. Commit, push, open a PR (if applicable), and close the issue per",
30897
31616
  " your project's PR workflow.",
31617
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
31618
+ " **Origin label** section below.",
30898
31619
  "",
30899
31620
  "---",
30900
31621
  "",
@@ -30902,6 +31623,10 @@ function buildSoftwareProfileAnalystSubAgent(paths, issueDefaults, tier) {
30902
31623
  "",
30903
31624
  "---",
30904
31625
  "",
31626
+ ...renderOriginStampSection(),
31627
+ "",
31628
+ "---",
31629
+ "",
30905
31630
  "## Phase 1: Research (`software:research`)",
30906
31631
  "",
30907
31632
  "**Goal:** Gather public sources into a bounded research-notes file.",
@@ -32033,6 +32758,8 @@ function buildStandardsResearchAnalystSubAgent(paths, issueDefaults) {
32033
32758
  " label.",
32034
32759
  "4. Commit, push, open a PR (if applicable), and close the issue per",
32035
32760
  " your project's PR workflow.",
32761
+ " Stamp every PR you open with the `origin:agent` label \u2014 see the",
32762
+ " **Origin label** section below.",
32036
32763
  "",
32037
32764
  "---",
32038
32765
  "",
@@ -32040,6 +32767,10 @@ function buildStandardsResearchAnalystSubAgent(paths, issueDefaults) {
32040
32767
  "",
32041
32768
  "---",
32042
32769
  "",
32770
+ ...renderOriginStampSection(),
32771
+ "",
32772
+ "---",
32773
+ "",
32043
32774
  "## Phase 1: Scope (`standards:scope`)",
32044
32775
  "",
32045
32776
  "**Goal:** Plan the research campaign for a standard \u2014 identify which",