@codedrifters/configulator 0.0.287 → 0.0.289

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
@@ -10911,291 +10911,6 @@ var meetingAnalysisBundle = {
10911
10911
  ]
10912
10912
  };
10913
10913
 
10914
- // src/agent/bundles/preflight-pr.ts
10915
- var DEFAULT_DELEGATE_TO_PR_REVIEWER = true;
10916
- var DEFAULT_MERGE_METHOD = "squash";
10917
- var DEFAULT_REQUIRE_LINKED_ISSUE = true;
10918
- var PREFLIGHT_MERGE_METHOD_VALUES = [
10919
- "squash",
10920
- "merge",
10921
- "rebase"
10922
- ];
10923
- function resolvePreflightPr(config) {
10924
- const mergeMethod = config?.mergeMethod ?? DEFAULT_MERGE_METHOD;
10925
- assertValidMergeMethod(mergeMethod);
10926
- const eligibleLabels = config?.eligibleLabels ?? [];
10927
- assertValidEligibleLabels(eligibleLabels);
10928
- return {
10929
- enabled: config?.enabled ?? true,
10930
- delegateToPrReviewer: config?.delegateToPrReviewer ?? DEFAULT_DELEGATE_TO_PR_REVIEWER,
10931
- mergeMethod,
10932
- requireLinkedIssue: config?.requireLinkedIssue ?? DEFAULT_REQUIRE_LINKED_ISSUE,
10933
- eligibleLabels
10934
- };
10935
- }
10936
- function validatePreflightPrConfig(config) {
10937
- return resolvePreflightPr(config);
10938
- }
10939
- function renderPreflightPrSection(pf) {
10940
- const lines = [
10941
- "## Pre-flight PR merge",
10942
- "",
10943
- "The orchestrator runs a **pre-flight PR merge sweep** before its",
10944
- "triage walk so already-approved, CI-green PRs land before the",
10945
- "unblock and queue-scan phases read dependency state. Without",
10946
- "pre-flight, an issue whose only remaining blocker is an approved",
10947
- "PR stuck behind a branch-protection delay shows up as blocked on",
10948
- "every dispatch cycle \u2014 the pipeline thrashes on stale dependency",
10949
- "state.",
10950
- ""
10951
- ];
10952
- if (!pf.enabled) {
10953
- lines.push(
10954
- "**Pre-flight is disabled for this project.** The orchestrator",
10955
- "skips the pre-flight sweep entirely; PR merges land via the",
10956
- "existing batch PR review step on housekeeping runs or via a",
10957
- "human operator. Enable pre-flight via",
10958
- "`AgentConfigOptions.preflightPr.enabled = true` once the repo",
10959
- "is comfortable with automated merges.",
10960
- ""
10961
- );
10962
- return lines.join("\n");
10963
- }
10964
- lines.push(
10965
- "### When pre-flight runs",
10966
- "",
10967
- "Pre-flight runs on **every orchestrator invocation** \u2014",
10968
- "both dispatch and housekeeping runs \u2014 immediately after Phase A",
10969
- "(Startup) and before any other phase reads issue or PR state. The",
10970
- "sweep is idempotent: `gh pr merge` on an already-merged PR is a",
10971
- "no-op, so re-running pre-flight on back-to-back invocations is",
10972
- "safe and cheap.",
10973
- "",
10974
- "### Eligibility",
10975
- "",
10976
- "A PR is eligible for a pre-flight merge when **all** of the",
10977
- "following hold:",
10978
- "",
10979
- "- PR is not draft and not closed.",
10980
- "- PR is `MERGEABLE` (no branch conflicts).",
10981
- "- Every required CI check has passed (`SUCCESS` or `SKIPPED`).",
10982
- "- PR carries at least one `APPROVED` review **or** auto-merge is",
10983
- " already enabled on the PR.",
10984
- "- PR is not carrying `status:needs-attention`."
10985
- );
10986
- if (pf.requireLinkedIssue) {
10987
- lines.push(
10988
- "- PR body contains a `Closes #<n>` / `Fixes #<n>` / `Resolves`",
10989
- " `#<n>` keyword referencing an open issue."
10990
- );
10991
- } else {
10992
- lines.push(
10993
- "- Linked-issue check is **disabled** for this project \u2014 PRs",
10994
- " without a `Closes/Fixes/Resolves` keyword are eligible."
10995
- );
10996
- }
10997
- if (pf.eligibleLabels.length > 0) {
10998
- lines.push(
10999
- "- PR carries at least one of the following consumer-declared",
11000
- " eligibility labels:",
11001
- "",
11002
- ...pf.eligibleLabels.map((label) => ` - \`${label}\``)
11003
- );
11004
- }
11005
- lines.push(
11006
- "",
11007
- "PRs that fail any criterion are skipped with a one-line",
11008
- "diagnostic and left for the `pr-reviewer` or a human operator to",
11009
- "handle on the normal review path.",
11010
- "",
11011
- "### Execution mode",
11012
- ""
11013
- );
11014
- if (pf.delegateToPrReviewer) {
11015
- lines.push(
11016
- "**Delegate mode (default).** The orchestrator invokes the",
11017
- "`pr-reviewer` sub-agent to run the pre-flight sweep. This",
11018
- "mirrors vortex's step 0b contract: the merge workflow runs on",
11019
- "its own (cheaper) model rather than consuming the orchestrator's",
11020
- "more expensive model budget for mechanical merges.",
11021
- "",
11022
- "The sub-agent returns a one-line structured summary as the last",
11023
- "line of its response:",
11024
- "",
11025
- "```",
11026
- "Merged <n> (#<list>), skipped <m> (#<pr> \u2014 <reason>), <k> eligible left.",
11027
- "```",
11028
- "",
11029
- "If the sub-agent's final line is missing, malformed, or",
11030
- "indicates an error, the orchestrator **does not retry** \u2014 it",
11031
- "proceeds to the next phase anyway. PR merges are idempotent at",
11032
- "GitHub, so the next orchestrator session re-runs pre-flight.",
11033
- "The only cost of a skipped sub-agent pass is that dependency",
11034
- "issues stay open one more cycle."
11035
- );
11036
- } else {
11037
- lines.push(
11038
- "**Inline mode.** The orchestrator performs the pre-flight merge",
11039
- "itself \u2014 it does **not** delegate to the `pr-reviewer`",
11040
- "sub-agent. Use this mode in repos that prefer a single-process",
11041
- "pipeline or that have not wired a `pr-reviewer` sub-agent.",
11042
- "",
11043
- `For each eligible PR, the orchestrator runs \`gh pr merge --${pf.mergeMethod}\``,
11044
- "with `--delete-branch` and re-confirms that the linked issue",
11045
- "closes (applying `status:done` if the auto-close did not fire)."
11046
- );
11047
- }
11048
- lines.push(
11049
- "",
11050
- "### Post-merge verification",
11051
- "",
11052
- "After each successful merge, the orchestrator re-reads the linked",
11053
- "issue state. When the merge commit did **not** auto-close the",
11054
- "issue (closing-keyword typos, linked-issue keyword dropped during",
11055
- "a rebase), the orchestrator closes the issue explicitly and",
11056
- "applies `status:done` so the downstream unblock loop sees the",
11057
- "dependency as resolved. This is the only way pre-flight prevents",
11058
- "the stale-dependency thrash \u2014 without the verification step a",
11059
- "merged-but-not-closed issue still reads as blocking to",
11060
- "`check-blocked.sh unblock`."
11061
- );
11062
- return lines.join("\n");
11063
- }
11064
- function renderPreflightPrShellHelpers(pf) {
11065
- const requireIssueFlag = pf.requireLinkedIssue ? "1" : "0";
11066
- const hasLabelFilter = pf.eligibleLabels.length > 0;
11067
- const lines = [
11068
- "# Scan open PRs and emit one eligibility line per PR in the",
11069
- "# canonical `PREFLIGHT_MERGE PR #<n> issue:#<m> branch:<b> \u2014",
11070
- '# "<title>"` / `PREFLIGHT_SKIP PR #<n> \u2014 <reason> \u2014 "<title>"` /',
11071
- "# `NO_PREFLIGHT_PRS` format. Orchestrator-side loops read this",
11072
- "# output and either merge the PR inline or delegate the sweep to",
11073
- "# the pr-reviewer sub-agent.",
11074
- "cmd_preflight() {",
11075
- ' if [[ "$PREFLIGHT_ENABLED" != "1" ]]; then',
11076
- ' echo "NO_PREFLIGHT_PRS"',
11077
- " return 0",
11078
- " fi",
11079
- " local prs",
11080
- " prs=$(gh pr list --state open --json number,title,isDraft,mergeable,headRefName,labels,body,reviewDecision,autoMergeRequest \\",
11081
- ' --limit 50 2>/dev/null || echo "[]")',
11082
- "",
11083
- " local count",
11084
- ` count=$(echo "$prs" | jq 'length')`,
11085
- ' if [[ "$count" -eq 0 ]]; then',
11086
- ' echo "NO_PREFLIGHT_PRS"',
11087
- " return 0",
11088
- " fi",
11089
- "",
11090
- " # Stage 1: filter in jq on purely structural fields (draft,",
11091
- " # labels, linked-issue keyword). CI state lives outside the",
11092
- " # list endpoint so it is checked per-PR below.",
11093
- " local candidates",
11094
- ` candidates=$(echo "$prs" | jq -r --arg require_issue "$PREFLIGHT_REQUIRE_LINKED_ISSUE" '`,
11095
- " .[] |",
11096
- " select(.isDraft == false) |",
11097
- ' select(.labels | map(.name) | index("status:needs-attention") | not) |'
11098
- ];
11099
- if (hasLabelFilter) {
11100
- const jqArray = pf.eligibleLabels.map((label) => `"${label.replace(/"/g, '\\"')}"`).join(",");
11101
- lines.push(
11102
- ` select((.labels | map(.name)) as $names | [${jqArray}] | any(. as $l | $names | index($l))) |`
11103
- );
11104
- }
11105
- lines.push(
11106
- ' (.body | capture("(?:Closes|Fixes|Resolves) #(?<num>[0-9]+)"; "i") | .num) as $issue |',
11107
- ' select($require_issue == "0" or ($issue != null and $issue != "")) |',
11108
- ' "\\(.number)\\t\\(.title)\\t\\(.headRefName)\\t\\($issue // "")\\t\\(.mergeable // "UNKNOWN")\\t\\(.reviewDecision // "")\\t\\((.autoMergeRequest // null) != null)"',
11109
- " ' 2>/dev/null)",
11110
- "",
11111
- ' if [[ -z "$candidates" ]]; then',
11112
- ' echo "NO_PREFLIGHT_PRS"',
11113
- " return 0",
11114
- " fi",
11115
- "",
11116
- " local found_eligible=false",
11117
- " while IFS=$'\\t' read -r pr_num title branch issue_num mergeable review_decision auto_merge; do",
11118
- ' [[ -z "$pr_num" ]] && continue',
11119
- "",
11120
- " # Mergeable gate.",
11121
- ' if [[ "$mergeable" != "MERGEABLE" ]]; then',
11122
- ' echo "PREFLIGHT_SKIP PR #${pr_num} \u2014 not mergeable (${mergeable}) \u2014 \\"${title}\\""',
11123
- " continue",
11124
- " fi",
11125
- "",
11126
- " # Approval gate: APPROVED review OR auto-merge already",
11127
- " # enabled. Either signal means a human has signed off on the",
11128
- " # change; pre-flight only needs to wait for CI + branch",
11129
- " # protection to clear.",
11130
- ' if [[ "$review_decision" != "APPROVED" && "$auto_merge" != "true" ]]; then',
11131
- ' echo "PREFLIGHT_SKIP PR #${pr_num} \u2014 not approved and auto-merge not set \u2014 \\"${title}\\""',
11132
- " continue",
11133
- " fi",
11134
- "",
11135
- " # CI gate. `gh pr checks` returns one row per check; anything",
11136
- " # that is neither SUCCESS nor SKIPPED counts as failing or",
11137
- " # pending.",
11138
- " local failing_checks",
11139
- ' failing_checks=$(gh pr checks "$pr_num" --json name,state \\',
11140
- ` --jq '[.[] | select(.state != "SUCCESS" and .state != "SKIPPED")] | length' 2>/dev/null || echo "-1")`,
11141
- "",
11142
- ' if [[ "$failing_checks" == "-1" ]]; then',
11143
- ' echo "PREFLIGHT_SKIP PR #${pr_num} \u2014 could not read CI status \u2014 \\"${title}\\""',
11144
- " continue",
11145
- " fi",
11146
- "",
11147
- ' if [[ "$failing_checks" -gt 0 ]]; then',
11148
- ' echo "PREFLIGHT_SKIP PR #${pr_num} \u2014 ${failing_checks} CI check(s) not passing \u2014 \\"${title}\\""',
11149
- " continue",
11150
- " fi",
11151
- "",
11152
- " # Linked-issue state gate. A PR whose linked issue is already",
11153
- " # closed should not block pre-flight \u2014 skip it so the unblock",
11154
- " # loop picks up the dependency. This path also fires when the",
11155
- " # PR was merged but the closing keyword was dropped.",
11156
- ' if [[ -n "$issue_num" ]]; then',
11157
- " local issue_state",
11158
- ` issue_state=$(gh issue view "$issue_num" --json state --jq '.state' 2>/dev/null || echo "UNKNOWN")`,
11159
- ' if [[ "$issue_state" == "CLOSED" ]]; then',
11160
- ' echo "PREFLIGHT_SKIP PR #${pr_num} \u2014 linked issue #${issue_num} already closed \u2014 \\"${title}\\""',
11161
- " continue",
11162
- " fi",
11163
- " fi",
11164
- "",
11165
- " found_eligible=true",
11166
- ' echo "PREFLIGHT_MERGE PR #${pr_num} issue:#${issue_num:-none} branch:${branch} \u2014 \\"${title}\\""',
11167
- ' done <<< "$candidates"',
11168
- "",
11169
- " if ! $found_eligible; then",
11170
- ' echo "NO_PREFLIGHT_PRS"',
11171
- " fi",
11172
- "}"
11173
- );
11174
- void requireIssueFlag;
11175
- return lines.join("\n");
11176
- }
11177
- function assertValidMergeMethod(value) {
11178
- if (!PREFLIGHT_MERGE_METHOD_VALUES.includes(value)) {
11179
- throw new Error(
11180
- `PreflightPrConfig.mergeMethod must be one of ${PREFLIGHT_MERGE_METHOD_VALUES.join(
11181
- " | "
11182
- )}; got ${JSON.stringify(value)}`
11183
- );
11184
- }
11185
- }
11186
- function assertValidEligibleLabels(labels) {
11187
- for (let i = 0; i < labels.length; i += 1) {
11188
- const label = labels[i];
11189
- if (typeof label !== "string" || label.trim().length === 0) {
11190
- throw new Error(
11191
- `PreflightPrConfig.eligibleLabels[${i}] must be a non-empty string; got ${JSON.stringify(
11192
- label
11193
- )}`
11194
- );
11195
- }
11196
- }
11197
- }
11198
-
11199
10914
  // src/agent/bundles/run-ratio.ts
11200
10915
  var DEFAULT_DISPATCH_TO_HOUSEKEEPING_RATIO = 4;
11201
10916
  var DEFAULT_STATE_FILE_PATH = ".state/orchestrator-runs.json";
@@ -11282,23 +10997,18 @@ function renderRunRatioSection(ratio) {
11282
10997
  "### Dispatch-run pipeline",
11283
10998
  "",
11284
10999
  "1. Phase A \u2014 startup (fetch + checkout default branch).",
11285
- "2. Phase B0 \u2014 pre-flight PR merge sweep (land approved,",
11286
- " CI-green PRs before triage reads dependency state).",
11287
- "3. Phase C \u2014 triage unblock (resolve `Depends on:` chains).",
11288
- "4. Phase E \u2014 queue scan (pick the top `PICK` line, run the scope",
11000
+ "2. Phase C \u2014 triage unblock (resolve `Depends on:` chains).",
11001
+ "3. Phase E \u2014 queue scan (pick the top `PICK` line, run the scope",
11289
11002
  " gate, emit `NEXT_WORK_ITEM`).",
11290
- "5. Phase F \u2014 cleanup.",
11003
+ "4. Phase F \u2014 cleanup.",
11291
11004
  "",
11292
11005
  "### Housekeeping-run pipeline",
11293
11006
  "",
11294
11007
  "1. Phase A \u2014 startup.",
11295
- "2. Phase B0 \u2014 pre-flight PR merge sweep (same mechanics as the",
11296
- " dispatch run; runs before the batch review so already-approved",
11297
- " PRs land cleanly).",
11298
- "3. Phase B \u2014 batch PR review across every eligible open PR.",
11299
- "4. Phase D \u2014 maintenance scan (stale detection, orphaned branches,",
11008
+ "2. Phase B \u2014 batch PR review across every eligible open PR.",
11009
+ "3. Phase D \u2014 maintenance scan (stale detection, orphaned branches,",
11300
11010
  " needs-attention summary).",
11301
- "5. Phase F \u2014 cleanup.",
11011
+ "4. Phase F \u2014 cleanup.",
11302
11012
  "",
11303
11013
  "### Model recommendations",
11304
11014
  "",
@@ -11425,7 +11135,7 @@ var DEFAULT_SCHEDULED_TASK_ENTRIES = [
11425
11135
  recommendedModel: "sonnet",
11426
11136
  enabled: false,
11427
11137
  cron: null,
11428
- description: "End-to-end pipeline manager: pre-flight PR merge, triage, maintenance, queue scan, delegate the picked issue to the issue-worker, then cleanup."
11138
+ description: "End-to-end pipeline manager: triage, maintenance, queue scan, delegate the picked issue to the issue-worker, then cleanup."
11429
11139
  },
11430
11140
  // Tier 1 — research.
11431
11141
  {
@@ -11853,10 +11563,33 @@ function renderPipelineSkillBody(task, lines) {
11853
11563
  "filter issues by `type:*` or phase label. Each invocation runs the",
11854
11564
  `target sub-agent's full end-to-end cycle exactly once.`,
11855
11565
  "",
11856
- `Run \`.claude/agents/${task.agent}.md\` and follow its workflow`,
11857
- "from start to finish. The sub-agent is responsible for picking the",
11858
- "next unit of work, delegating implementation to other workers as",
11859
- "needed, and exiting cleanly.",
11566
+ "## Depth-0 execution contract",
11567
+ "",
11568
+ "**You \u2014 the scheduled-task session \u2014 are the pipeline manager.**",
11569
+ "Do **not** spawn the target sub-agent via the `Agent` tool. The",
11570
+ "Claude Code runtime forbids nested sub-agent spawning: a depth-1",
11571
+ "sub-agent cannot invoke `Agent` to reach depth-2, so a pipeline",
11572
+ "manager that delegates to other workers must run at depth-0 (this",
11573
+ "scheduled-task session). See",
11574
+ '<https://code.claude.com/docs/en/sub-agents> \u2014 *"Subagents cannot',
11575
+ "spawn other subagents. If your workflow requires nested delegation,",
11576
+ 'use Skills or chain subagents from the main conversation."*',
11577
+ "",
11578
+ "Therefore:",
11579
+ "",
11580
+ `1. **Read \`.claude/agents/${task.agent}.md\` in this session** and`,
11581
+ " execute its phase pipeline directly. Treat the agent file as a",
11582
+ " workflow runbook the scheduled-task session follows step-by-step,",
11583
+ " not as a sub-agent to spawn.",
11584
+ "2. **Use the `Agent` tool (with the `subagent_type` parameter set",
11585
+ " to the target worker name) to delegate one tier down.** From",
11586
+ " depth-0, you can spawn a depth-1 sub-agent (e.g. `issue-worker`,",
11587
+ " `pr-reviewer`) for the implementation, review, or merge step the",
11588
+ " pipeline calls out.",
11589
+ "3. **Never spawn the pipeline manager itself as a sub-agent.** Do",
11590
+ ` not call \`Agent(subagent_type: "${task.agent}", ...)\`. That`,
11591
+ " would put the pipeline manager at depth-1 and break every",
11592
+ " subsequent delegation step.",
11860
11593
  "",
11861
11594
  "## Recommended model",
11862
11595
  "",
@@ -12497,9 +12230,6 @@ function renderUnblockDependentsSection(ud) {
12497
12230
  "",
12498
12231
  "- The `pr-reviewer` sub-agent, Phase 5 (branch cleanup), after it",
12499
12232
  " applies `status:done` to the linked issue on a successful merge.",
12500
- "- The `orchestrator` sub-agent, Phase B0 (pre-flight PR merge)",
12501
- " post-merge verification, after it force-closes an issue whose",
12502
- " merge commit dropped its closing keyword.",
12503
12233
  "",
12504
12234
  "Any other agent that manually applies `status:done` should call",
12505
12235
  "`unblock-dependents.sh <closed-issue>` as its last step. The",
@@ -12805,12 +12535,11 @@ function shellSingleQuote(value) {
12805
12535
  }
12806
12536
 
12807
12537
  // src/agent/bundles/orchestrator.ts
12808
- function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
12538
+ function buildCheckBlockedScript(tiers, scopeGate, runRatio) {
12809
12539
  const tierCase = renderAgentTierCaseStatement(tiers);
12810
12540
  const scopeHelper = renderScopeGateShellHelpers(scopeGate);
12811
12541
  const scopeHelperIndented = scopeHelper.split("\n").map((line) => line.length > 0 ? line : "").join("\n");
12812
12542
  const runRatioHelper = renderRunRatioShellHelpers(runRatio);
12813
- const preflightHelper = renderPreflightPrShellHelpers(preflight);
12814
12543
  return [
12815
12544
  "#!/usr/bin/env bash",
12816
12545
  "# check-blocked.sh \u2014 Token-efficient issue triage for agent loops.",
@@ -12825,7 +12554,6 @@ function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
12825
12554
  "# .claude/procedures/check-blocked.sh prs",
12826
12555
  "# .claude/procedures/check-blocked.sh scope <issue-number>",
12827
12556
  "# .claude/procedures/check-blocked.sh tick",
12828
- "# .claude/procedures/check-blocked.sh preflight",
12829
12557
  "",
12830
12558
  "set -uo pipefail",
12831
12559
  "",
@@ -12840,10 +12568,6 @@ function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
12840
12568
  `RUN_RATIO_ENABLED=${runRatio.enabled ? "1" : "0"}`,
12841
12569
  `RUN_RATIO_DISPATCH_PER_HOUSEKEEPING=${runRatio.ratio}`,
12842
12570
  `ORCHESTRATOR_STATE_FILE="${runRatio.stateFilePath}"`,
12843
- `PREFLIGHT_ENABLED=${preflight.enabled ? "1" : "0"}`,
12844
- `PREFLIGHT_REQUIRE_LINKED_ISSUE=${preflight.requireLinkedIssue ? "1" : "0"}`,
12845
- `PREFLIGHT_MERGE_METHOD="${preflight.mergeMethod}"`,
12846
- `PREFLIGHT_DELEGATE_TO_PR_REVIEWER=${preflight.delegateToPrReviewer ? "1" : "0"}`,
12847
12571
  "",
12848
12572
  "# \u2500\u2500 helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
12849
12573
  "",
@@ -12876,8 +12600,6 @@ function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
12876
12600
  "",
12877
12601
  runRatioHelper,
12878
12602
  "",
12879
- preflightHelper,
12880
- "",
12881
12603
  "# \u2500\u2500 subcommands \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
12882
12604
  "",
12883
12605
  "cmd_unblock() {",
@@ -13242,26 +12964,24 @@ function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
13242
12964
  ' prs) shift; cmd_prs "$@" ;;',
13243
12965
  ' scope) shift; cmd_scope "$@" ;;',
13244
12966
  ' tick) shift; cmd_tick "$@" ;;',
13245
- ' preflight) shift; cmd_preflight "$@" ;;',
13246
12967
  " help|*)",
13247
- ' echo "Usage: check-blocked.sh <unblock|eligible|stale|orphaned|prs|scope|tick|preflight>"',
12968
+ ' echo "Usage: check-blocked.sh <unblock|eligible|stale|orphaned|prs|scope|tick>"',
13248
12969
  " exit 1",
13249
12970
  " ;;",
13250
12971
  "esac"
13251
12972
  ].join("\n");
13252
12973
  }
13253
- function buildCheckBlockedProcedure(tiers, scopeGate = resolveScopeGate(), runRatio = resolveRunRatio(), preflight = resolvePreflightPr()) {
12974
+ function buildCheckBlockedProcedure(tiers, scopeGate = resolveScopeGate(), runRatio = resolveRunRatio()) {
13254
12975
  return {
13255
12976
  name: "check-blocked.sh",
13256
- description: "Token-efficient issue triage script with subcommands: eligible, unblock, stale, orphaned, prs, scope, preflight, and (deprecated) tick. Sorts eligible issues by priority desc \u2192 funnel tier asc \u2192 issue number asc; the scope subcommand classifies a single issue against the scope-gate thresholds; the preflight subcommand emits one eligibility line per open PR that is mergeable, CI-green, approved (or auto-merge already enabled), and linked to an open issue. The tick subcommand is a deprecation no-op retained for one release (the orchestrator no longer maintains a dispatch/housekeeping run counter).",
13257
- content: buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight)
12977
+ description: "Token-efficient issue triage script with subcommands: eligible, unblock, stale, orphaned, prs, scope, and (deprecated) tick. Sorts eligible issues by priority desc \u2192 funnel tier asc \u2192 issue number asc; the scope subcommand classifies a single issue against the scope-gate thresholds. The tick subcommand is a deprecation no-op retained for one release (the orchestrator no longer maintains a dispatch/housekeeping run counter).",
12978
+ content: buildCheckBlockedScript(tiers, scopeGate, runRatio)
13258
12979
  };
13259
12980
  }
13260
12981
  var checkBlockedProcedure = buildCheckBlockedProcedure(
13261
12982
  DEFAULT_AGENT_TIERS,
13262
12983
  resolveScopeGate(),
13263
- resolveRunRatio(),
13264
- resolvePreflightPr()
12984
+ resolveRunRatio()
13265
12985
  );
13266
12986
  function buildUnblockDependentsProcedure(unblockDependents = resolveUnblockDependents()) {
13267
12987
  return {
@@ -13275,21 +12995,21 @@ var unblockDependentsProcedure = buildUnblockDependentsProcedure(
13275
12995
  );
13276
12996
  var orchestratorSubAgent = {
13277
12997
  name: "orchestrator",
13278
- description: "End-to-end pipeline manager that runs one full cycle every invocation: pre-flight PR merge \u2192 triage \u2192 maintenance \u2192 queue scan \u2192 delegate the picked issue to the issue-worker \u2192 cleanup",
12998
+ description: "End-to-end pipeline manager that runs one full cycle every invocation: triage \u2192 maintenance \u2192 queue scan \u2192 delegate the picked issue to the issue-worker \u2192 cleanup",
13279
12999
  model: AGENT_MODEL.POWERFUL,
13280
13000
  maxTurns: 100,
13281
- canDelegateToAgents: ["issue-worker", "pr-reviewer"],
13282
13001
  platforms: { cursor: { exclude: true } },
13283
13002
  prompt: [
13284
13003
  "# Orchestrator Agent",
13285
13004
  "",
13286
13005
  "You are the pipeline orchestrator for the **{{repository.owner}}/{{repository.name}}** repository.",
13287
- "Each invocation runs **one full end-to-end cycle**. The cycle merges",
13288
- "approved PRs, triages blocked issues, runs maintenance scans, picks the",
13289
- "next ready issue, and **delegates implementation to the `issue-worker`**",
13290
- "sub-agent in scheduled mode. The orchestrator itself never implements",
13291
- "code, creates branches, or pushes commits \u2014 it routes work to other",
13292
- "agents.",
13006
+ "Each invocation runs **one full end-to-end cycle**. The cycle triages",
13007
+ "blocked issues, runs maintenance scans, picks the next ready issue, and",
13008
+ "**delegates implementation to the `issue-worker`** sub-agent in scheduled",
13009
+ "mode. The orchestrator itself never implements code, creates branches, or",
13010
+ "pushes commits \u2014 it routes work to other agents. Approved-PR merging is",
13011
+ "owned by the `pr-reviewer` sub-agent (invoked via `/review-pr` /",
13012
+ "`/review-prs`); the orchestrator does not run a merge sweep.",
13293
13013
  "",
13294
13014
  "Run the phases below in order on every invocation. There is no",
13295
13015
  "dispatch/housekeeping fork \u2014 every phase runs every time.",
@@ -13297,20 +13017,23 @@ var orchestratorSubAgent = {
13297
13017
  "Phase ordering (each runs exactly once per invocation):",
13298
13018
  "",
13299
13019
  "1. **Phase A \u2014 Startup.** Pull the default branch.",
13300
- "2. **Phase B0 \u2014 Pre-flight PR Merge.** Land every eligible approved /",
13301
- " CI-green PR before triage reads dependency state.",
13302
- "3. **Phase C \u2014 Triage / Unblock.** Flip dependents that have all",
13020
+ "2. **Phase C \u2014 Triage / Unblock.** Flip dependents that have all",
13303
13021
  " their dependencies closed back to `status:ready`.",
13304
- "4. **Phase D \u2014 Maintenance.** Stale-issue and orphaned-resource scan",
13022
+ "3. **Phase D \u2014 Maintenance.** Stale-issue and orphaned-resource scan",
13305
13023
  " plus a needs-attention summary.",
13306
- "5. **Phase E \u2014 Queue Scan.** Pick the highest-priority `PICK` line",
13024
+ "4. **Phase E \u2014 Queue Scan.** Pick the highest-priority `PICK` line",
13307
13025
  " and run the scope gate. If the result is `large`, flag and stop.",
13308
- "6. **Phase G \u2014 Delegate Implementation.** Hand the picked issue off",
13026
+ "5. **Phase G \u2014 Delegate Implementation.** Hand the picked issue off",
13309
13027
  " to the `issue-worker` sub-agent in scheduled mode. The worker",
13310
13028
  " handles claim \u2192 branch \u2192 implement \u2192 commit \u2192 PR autonomously.",
13311
- "7. **Phase F \u2014 Cleanup.** Return to the default branch and log the",
13029
+ "6. **Phase F \u2014 Cleanup.** Return to the default branch and log the",
13312
13030
  " run summary.",
13313
13031
  "",
13032
+ "Phase letters are stable identifiers \u2014 letters skipped in the list",
13033
+ "above were used by earlier revisions of this pipeline and the gap",
13034
+ "is left intentionally so existing references in commit history and",
13035
+ "docs remain unambiguous.",
13036
+ "",
13314
13037
  "---",
13315
13038
  "",
13316
13039
  ...PROJECT_CONTEXT_READER_SECTION,
@@ -13322,100 +13045,6 @@ var orchestratorSubAgent = {
13322
13045
  "git checkout main && git pull origin main",
13323
13046
  "```",
13324
13047
  "",
13325
- "## Phase B0: Pre-flight PR Merge",
13326
- "",
13327
- "Before any other phase reads dependency state, land every",
13328
- "eligible PR. The sweep is idempotent \u2014 `gh pr merge` on an",
13329
- "already-merged PR is a no-op \u2014 so re-running on back-to-back",
13330
- "invocations is safe.",
13331
- "",
13332
- "List eligibility:",
13333
- "",
13334
- "```bash",
13335
- ".claude/procedures/check-blocked.sh preflight",
13336
- "```",
13337
- "",
13338
- "Expect one line per open PR:",
13339
- "",
13340
- "```",
13341
- 'PREFLIGHT_MERGE PR #<n> issue:#<m> branch:<b> \u2014 "<title>"',
13342
- 'PREFLIGHT_SKIP PR #<n> \u2014 <reason> \u2014 "<title>"',
13343
- "NO_PREFLIGHT_PRS",
13344
- "```",
13345
- "",
13346
- "If the output is `NO_PREFLIGHT_PRS`, continue to Phase B / C.",
13347
- "",
13348
- "For each `PREFLIGHT_MERGE` line, either **delegate** to the",
13349
- "`pr-reviewer` sub-agent (default) or **merge inline** depending",
13350
- "on the rendered pre-flight config. See the **Pre-flight PR",
13351
- "merge** section in `CLAUDE.md` for the project's mode.",
13352
- "",
13353
- "**Delegate mode (default).** Invoke the `pr-reviewer` sub-agent",
13354
- "with a single-pass brief covering every `PREFLIGHT_MERGE` line:",
13355
- "",
13356
- "> Run your merge pipeline once across these PRs: <list of",
13357
- "> `#<n>` numbers>. Merge every eligible PR (linked issue still",
13358
- "> open, AC satisfied, CI green, approval present) and comment on",
13359
- "> any PR you skip. Return a one-line summary as the final line of",
13360
- "> your response, e.g. `Merged 2 (#123, #124), skipped 1 (#125 \u2014",
13361
- "> AC not met), 0 eligible left.` or `No eligible PRs.`",
13362
- "",
13363
- "If the sub-agent's final line is missing, malformed, or indicates",
13364
- "an error, **do not retry** \u2014 proceed to the next phase anyway.",
13365
- "The next orchestrator session will re-run pre-flight and pick up",
13366
- "anything left behind.",
13367
- "",
13368
- "**Inline mode.** For each `PREFLIGHT_MERGE PR #<n> issue:#<m>`",
13369
- "line, merge the PR with the configured method (default",
13370
- "`--squash`) and `--delete-branch`:",
13371
- "",
13372
- "```bash",
13373
- 'gh pr merge <n> --squash --delete-branch --subject "<conventional-commit-title>" --body "<extended-description>"',
13374
- "```",
13375
- "",
13376
- "After every successful merge \u2014 whether delegated or inline \u2014 run",
13377
- "the post-merge verification step to close the stale-dependency",
13378
- "loop:",
13379
- "",
13380
- "```bash",
13381
- "gh issue view <m> --json state --jq '.state'",
13382
- "```",
13383
- "",
13384
- "If the linked issue's state is still `OPEN`, close it explicitly",
13385
- "and flip its status label to `status:done`:",
13386
- "",
13387
- "```bash",
13388
- "gh issue close <m>",
13389
- 'gh issue edit <m> --remove-label "status:ready-for-review" --add-label "status:done"',
13390
- "```",
13391
- "",
13392
- "After applying `status:done` \u2014 whether the auto-close fired or",
13393
- "you force-closed above \u2014 run the targeted unblock sweep so any",
13394
- "dependents that were only waiting on issue `<m>` flip to",
13395
- "`status:ready` immediately:",
13396
- "",
13397
- "```bash",
13398
- ".claude/procedures/unblock-dependents.sh <m>",
13399
- "```",
13400
- "",
13401
- "The script emits one line per processed dependent",
13402
- "(`UNBLOCKED #<n>` / `STILL_BLOCKED #<n>` / `NO_DEPENDENTS #<m>`)",
13403
- "so the run summary records what transitioned. See the",
13404
- "**Agent-driven unblocking** section in `CLAUDE.md` for the full",
13405
- "contract.",
13406
- "",
13407
- "This step is the reason pre-flight exists: it prevents the",
13408
- "orchestrator from reading a merged-but-not-auto-closed issue as",
13409
- "still blocking on the next unblock sweep.",
13410
- "",
13411
- "Log the pre-flight outcome (number merged, PRs skipped with",
13412
- "reasons, and any issues force-closed) so the run summary records",
13413
- "what landed.",
13414
- "",
13415
- "Skip lines starting with `PREFLIGHT_SKIP` \u2014 those PRs failed one",
13416
- "or more eligibility checks. The `pr-reviewer` or a human",
13417
- "operator picks them up on the normal review path.",
13418
- "",
13419
13048
  "## Phase C: Triage \u2014 Unblock",
13420
13049
  "",
13421
13050
  "Check for blocked issues whose dependencies have resolved:",
@@ -13611,40 +13240,31 @@ var orchestratorSubAgent = {
13611
13240
  "git fetch --prune origin",
13612
13241
  "```",
13613
13242
  "",
13614
- "Log completion: phases executed, PRs merged in pre-flight, issues",
13615
- "unblocked, stale issues flagged, the next work item picked, and",
13616
- "the outcome of Phase G's delegation (worker success / failure /",
13617
- "skipped because the queue was empty).",
13243
+ "Log completion: phases executed, issues unblocked, stale issues",
13244
+ "flagged, the next work item picked, and the outcome of Phase G's",
13245
+ "delegation (worker success / failure / skipped because the queue",
13246
+ "was empty).",
13618
13247
  "",
13619
13248
  "---",
13620
13249
  "",
13621
13250
  "## Rules",
13622
13251
  "",
13623
- "1. **Never implement code.** You merge, triage, scan, and delegate \u2014 you do not code.",
13252
+ "1. **Never implement code.** You triage, scan, and delegate \u2014 you do not code.",
13624
13253
  "2. **Never claim issues.** Do not add `status:in-progress` or create branches for issues. Phase G's `issue-worker` delegation is the only path that flips an issue's claim labels.",
13625
- "3. **Always use check-blocked.sh.** All triage queries go through the shell script for token efficiency.",
13626
- "4. **Follow CLAUDE.md conventions** for all git and gh operations.",
13627
- "5. **Priority order:** critical > high > medium > low > trivial, then **funnel tier asc** (lower tier wins ties), then FIFO by issue number.",
13628
- "6. **Never dispatch a `large` issue.** Always run the scope check",
13254
+ "3. **Never merge PRs.** Approved-PR merging is owned by the `pr-reviewer` sub-agent (invoked via `/review-pr` / `/review-prs`). The orchestrator does not run a merge sweep, does not call `gh pr merge`, and does not enable auto-merge.",
13255
+ "4. **Always use check-blocked.sh.** All triage queries go through the shell script for token efficiency.",
13256
+ "5. **Follow CLAUDE.md conventions** for all git and gh operations.",
13257
+ "6. **Priority order:** critical > high > medium > low > trivial, then **funnel tier asc** (lower tier wins ties), then FIFO by issue number.",
13258
+ "7. **Never dispatch a `large` issue.** Always run the scope check",
13629
13259
  " on the top `PICK` line before reporting `NEXT_WORK_ITEM`. A",
13630
13260
  " `large` issue must be flagged with `status:needs-attention` and",
13631
13261
  " handed a decomposition proposal \u2014 never claimed, never branched,",
13632
13262
  " never delegated to the `issue-worker`.",
13633
- "7. **Always run pre-flight before reading dependency state.**",
13634
- " Phase B0 (Pre-flight PR Merge) runs on every invocation,",
13635
- " immediately after Phase A. Never skip Phase B0: without it, an",
13636
- " issue whose only remaining blocker is an approved-but-not-yet-",
13637
- " merged PR reads as blocked on every cycle and the pipeline",
13638
- " thrashes. See the **Pre-flight PR merge** section in",
13639
- " `CLAUDE.md` for eligibility rules and the delegate-vs-inline",
13640
- " modes.",
13641
13263
  "8. **Sweep dependents whenever you apply `status:done`.** Every",
13642
13264
  " `status:done` transition must be immediately followed by",
13643
13265
  " `.claude/procedures/unblock-dependents.sh <n>` so downstream",
13644
13266
  " `Depends on: #<n>` issues flip to `status:ready` without",
13645
- " waiting for the next cycle. Phase B0's post-merge",
13646
- " verification (and any inline-mode merge) already calls the",
13647
- " sweep; don't skip it. See the **Agent-driven unblocking**",
13267
+ " waiting for the next cycle. See the **Agent-driven unblocking**",
13648
13268
  " section in `CLAUDE.md` for the contract.",
13649
13269
  "9. **Always invoke `issue-worker` in scheduled mode.** Phase G's",
13650
13270
  " delegation prompt must contain the literal phrase",
@@ -13658,8 +13278,7 @@ var issueWorkerSubAgent = {
13658
13278
  name: "issue-worker",
13659
13279
  description: "Selects the next ready issue from the queue, claims it, and implements the change end-to-end following repository conventions",
13660
13280
  model: AGENT_MODEL.POWERFUL,
13661
- maxTurns: 100,
13662
- canDelegateToAgents: [],
13281
+ maxTurns: 150,
13663
13282
  platforms: { cursor: { exclude: true } },
13664
13283
  prompt: [
13665
13284
  "# Issue Worker",
@@ -13888,6 +13507,35 @@ var issueWorkerSubAgent = {
13888
13507
  " `file` (and optional `line`). Track `comment_id` per item so you can",
13889
13508
  " report which items were handled and which (if any) failed.",
13890
13509
  "",
13510
+ " **Synthetic rebase items.** A `comment_id` of",
13511
+ " `synthetic:rebase-behind-main` is the reviewer's signal that the",
13512
+ " PR's head branch is BEHIND the default branch with merge conflicts",
13513
+ " that `gh pr update-branch` could not resolve. For this item only,",
13514
+ " the work is **not** an editorial change \u2014 it is a rebase plus",
13515
+ " conflict resolution. Run the following sequence:",
13516
+ "",
13517
+ " ```bash",
13518
+ " git fetch origin",
13519
+ " git pull --rebase origin {{repository.defaultBranch}}",
13520
+ " ```",
13521
+ "",
13522
+ " When the rebase produces conflicts, resolve each conflicting file",
13523
+ " in turn (read both sides, reconcile, stage), then run",
13524
+ " `git rebase --continue` until the rebase completes. Never run",
13525
+ " `git rebase --abort` on a synthetic-rebase item \u2014 aborting drops",
13526
+ " the work the reviewer delegated. If you cannot resolve a conflict",
13527
+ " (the change is editorial enough that it requires human judgement,",
13528
+ " or the conflict touches a generated file you should not hand-edit),",
13529
+ " record the item as `failed` with a clear reason, run",
13530
+ " `git rebase --abort`, and proceed to the report step. Do not",
13531
+ " force-push.",
13532
+ "",
13533
+ " When the rebase completes cleanly, treat the rebased commits",
13534
+ " themselves as the deliverable. Skip the conventional commit step",
13535
+ " in Phase 6 for this item \u2014 the rebase already produced the commit",
13536
+ " history. Push with a regular non-force `git push origin <branch>`",
13537
+ " and report the rebased head SHA as the worker's commit.",
13538
+ "",
13891
13539
  "4. When complete, prepare a short structured report (PR number, commit",
13892
13540
  " SHAs you will push, items handled by `comment_id`, items that failed",
13893
13541
  " to apply) \u2014 you will return this after Phase 6.",
@@ -13949,6 +13597,22 @@ var issueWorkerSubAgent = {
13949
13597
  "git push origin <branch-name>",
13950
13598
  "```",
13951
13599
  "",
13600
+ "**Synthetic-rebase items skip the `fix(review)` commit.** When the",
13601
+ "fix-list contained a `comment_id` of `synthetic:rebase-behind-main`",
13602
+ "and you completed the rebase in Phase 4, the rebased commit history",
13603
+ "is itself the deliverable \u2014 there is no per-item editorial change to",
13604
+ "wrap in a `fix(review)` commit. Skip `git add` / `git commit` /",
13605
+ "`git pull --rebase` for that item and push the rebased branch",
13606
+ "directly:",
13607
+ "",
13608
+ "```bash",
13609
+ "git push origin <branch-name>",
13610
+ "```",
13611
+ "",
13612
+ "If the fix-list mixed a synthetic-rebase item with editorial items,",
13613
+ "perform the editorial commit first (the rebase already preceded it",
13614
+ "in Phase 4), then push once at the end.",
13615
+ "",
13952
13616
  "**Normal mode:** Use conventional commit messages and push with `-u`",
13953
13617
  "to set up branch tracking:",
13954
13618
  "",
@@ -14082,15 +13746,21 @@ var ORCHESTRATOR_CONVENTIONS_PREAMBLE = [
14082
13746
  "",
14083
13747
  "When running the orchestrator agent (`.claude/agents/orchestrator.md`):",
14084
13748
  "",
14085
- "- The orchestrator runs **one full end-to-end cycle every invocation**: pre-flight PR merge \u2192 triage / unblock \u2192 maintenance \u2192 queue scan \u2192 delegate to `issue-worker` \u2192 cleanup",
14086
- "- The orchestrator **never** implements code, creates branches, or pushes commits \u2014 it merges PRs, triages issues, picks the next work item, and delegates implementation to other sub-agents",
13749
+ "- The orchestrator runs **one full end-to-end cycle every invocation**: triage / unblock \u2192 maintenance \u2192 queue scan \u2192 delegate to `issue-worker` \u2192 cleanup",
13750
+ "- The orchestrator **never** implements code, creates branches, pushes commits, **or merges PRs** \u2014 it triages issues, picks the next work item, and delegates implementation to other sub-agents. Approved-PR merging is owned by the `pr-reviewer` sub-agent (invoked via `/review-pr` / `/review-prs`).",
14087
13751
  "- All triage queries use `.claude/procedures/check-blocked.sh` for token efficiency",
14088
13752
  "- The queue scan reads only `priority:*` and `status:*` labels \u2014 type-routing (which typed agent handles a given `type:*` label) is the `issue-worker`'s concern, not the orchestrator's. The orchestrator's funnel-tier sort is a tie-breaker on `priority:*`, not a routing decision.",
14089
13753
  "- Priority order: critical > high > medium > low > trivial, then **funnel tier asc** (lower tier wins ties), then FIFO by issue number",
14090
13754
  "- Stale thresholds: 72h for in-progress, 168h for blocked",
14091
- "- Flagged issues get `status:needs-attention` \u2014 they are not auto-reset"
13755
+ "- Flagged issues get `status:needs-attention` \u2014 they are not auto-reset",
13756
+ "",
13757
+ "## Depth-0 invocation requirement",
13758
+ "",
13759
+ 'The orchestrator agent **must run as the top-level (depth-0) session** when its Phase G needs to delegate work to the `issue-worker` sub-agent. The Claude Code harness forbids nested sub-agent spawning \u2014 *"Subagents cannot spawn other subagents. If your workflow requires nested delegation, use Skills or chain subagents from the main conversation."* (see <https://code.claude.com/docs/en/sub-agents>). If the orchestrator itself were spawned as a depth-1 sub-agent (e.g. via `Agent(subagent_type: "orchestrator")` from another session), the `Agent` tool needed to reach the `issue-worker` at depth-2 would not be available and Phase G would silently abort.',
13760
+ "",
13761
+ 'Practical implication for scheduled-task wiring: the `worker-orchestrator` scheduled task\'s `SKILL.md` instructs the **scheduled-task session itself** to read `.claude/agents/orchestrator.md` and execute its phase pipeline in-session, then use the `Agent` tool to delegate the picked work item to `issue-worker` (depth-1). The scheduled task does **not** call `Agent(subagent_type: "orchestrator")` \u2014 that would put the orchestrator at depth-1 and break the chain.'
14092
13762
  ].join("\n");
14093
- function buildOrchestratorConventionsContent(tiers, scopeGate = resolveScopeGate(), runRatio = resolveRunRatio(), preflight = resolvePreflightPr(), scheduledTasks = resolveScheduledTasks(), unblockDependents = resolveUnblockDependents()) {
13763
+ function buildOrchestratorConventionsContent(tiers, scopeGate = resolveScopeGate(), runRatio = resolveRunRatio(), scheduledTasks = resolveScheduledTasks(), unblockDependents = resolveUnblockDependents()) {
14094
13764
  return [
14095
13765
  ORCHESTRATOR_CONVENTIONS_PREAMBLE,
14096
13766
  "",
@@ -14100,18 +13770,15 @@ function buildOrchestratorConventionsContent(tiers, scopeGate = resolveScopeGate
14100
13770
  "",
14101
13771
  renderRunRatioSection(runRatio),
14102
13772
  "",
14103
- renderPreflightPrSection(preflight),
14104
- "",
14105
13773
  renderScheduledTasksSection(scheduledTasks),
14106
13774
  "",
14107
13775
  renderUnblockDependentsSection(unblockDependents)
14108
13776
  ].join("\n");
14109
13777
  }
14110
- function resolveOrchestratorAssets(tierConfig, scopeGateConfig, runRatioConfig, preflightPrConfig, scheduledTasksConfig, unblockDependentsConfig) {
13778
+ function resolveOrchestratorAssets(tierConfig, scopeGateConfig, runRatioConfig, scheduledTasksConfig, unblockDependentsConfig) {
14111
13779
  const tiers = resolveAgentTiers(tierConfig);
14112
13780
  const scopeGate = resolveScopeGate(scopeGateConfig);
14113
13781
  const runRatio = resolveRunRatio(runRatioConfig);
14114
- const preflight = resolvePreflightPr(preflightPrConfig);
14115
13782
  const scheduledTasks = resolveScheduledTasks(scheduledTasksConfig);
14116
13783
  const unblockDependentsResolved = resolveUnblockDependents(
14117
13784
  unblockDependentsConfig
@@ -14120,23 +13787,16 @@ function resolveOrchestratorAssets(tierConfig, scopeGateConfig, runRatioConfig,
14120
13787
  tiers,
14121
13788
  scopeGate,
14122
13789
  runRatio,
14123
- preflight,
14124
13790
  scheduledTasks,
14125
13791
  unblockDependents: unblockDependentsResolved,
14126
13792
  conventionsContent: buildOrchestratorConventionsContent(
14127
13793
  tiers,
14128
13794
  scopeGate,
14129
13795
  runRatio,
14130
- preflight,
14131
13796
  scheduledTasks,
14132
13797
  unblockDependentsResolved
14133
13798
  ),
14134
- procedure: buildCheckBlockedProcedure(
14135
- tiers,
14136
- scopeGate,
14137
- runRatio,
14138
- preflight
14139
- ),
13799
+ procedure: buildCheckBlockedProcedure(tiers, scopeGate, runRatio),
14140
13800
  unblockDependentsProcedure: buildUnblockDependentsProcedure(
14141
13801
  unblockDependentsResolved
14142
13802
  )
@@ -14150,13 +13810,12 @@ var orchestratorBundle = {
14150
13810
  rules: [
14151
13811
  {
14152
13812
  name: "orchestrator-conventions",
14153
- description: "Guidelines for orchestrator agent behavior and pipeline management, including the funnel-tier dispatch sort, scope gate, pre-flight PR merge contract, and per-agent scheduled-task layout",
13813
+ description: "Guidelines for orchestrator agent behavior and pipeline management, including the funnel-tier dispatch sort, scope gate, and per-agent scheduled-task layout",
14154
13814
  scope: AGENT_RULE_SCOPE.ALWAYS,
14155
13815
  content: buildOrchestratorConventionsContent(
14156
13816
  DEFAULT_AGENT_TIERS,
14157
13817
  resolveScopeGate(),
14158
13818
  resolveRunRatio(),
14159
- resolvePreflightPr(),
14160
13819
  resolveScheduledTasks(),
14161
13820
  resolveUnblockDependents()
14162
13821
  ),
@@ -15893,6 +15552,162 @@ var prReviewerSubAgent = {
15893
15552
  "`feat(scope): description`). The body should bullet the changes and end",
15894
15553
  "with `Closes #<issue-number>`.",
15895
15554
  "",
15555
+ "##### Update the branch when `mergeStateStatus` is `BEHIND`",
15556
+ "",
15557
+ "After enabling auto-merge, re-read the PR's `mergeStateStatus` so a",
15558
+ "branch that fell behind the default branch lands on the next CI tick",
15559
+ "instead of sitting in the auto-merge queue indefinitely:",
15560
+ "",
15561
+ "```bash",
15562
+ "gh pr view <pr-number> --json mergeStateStatus --jq '.mergeStateStatus'",
15563
+ "```",
15564
+ "",
15565
+ "When the value is `BEHIND`, attempt to bring the head branch current with",
15566
+ "the default branch via `gh pr update-branch` (default merge strategy \u2014",
15567
+ "**never** `--rebase`, which would rewrite commits on a published branch):",
15568
+ "",
15569
+ "```bash",
15570
+ "gh pr update-branch <pr-number>",
15571
+ "```",
15572
+ "",
15573
+ "Branch on the outcome:",
15574
+ "",
15575
+ "- **Success** \u2014 record `Branch updated: yes` for the per-PR report and",
15576
+ " stop. Auto-merge will fire when required checks pass on the new head",
15577
+ " SHA. Do **not** poll for the merge here \u2014 Phase 5 owns polling.",
15578
+ "- **Failure for reasons other than a merge conflict** (permission",
15579
+ " denied, branch protection refusing the merge commit, transient",
15580
+ " network error) \u2014 record `Branch updated: failed (<reason>)`, post a",
15581
+ " short comment explaining the failure, and stop. Do not retry.",
15582
+ "- **Failure because the merge would conflict** \u2014 proceed to the",
15583
+ " conflict-resolution delegation flow below.",
15584
+ "",
15585
+ "When `mergeStateStatus` is **not** `BEHIND` (`CLEAN`, `BLOCKED`,",
15586
+ "`UNSTABLE`, `HAS_HOOKS`, `UNKNOWN`), record `Branch updated: not needed`",
15587
+ "and skip the rest of this sub-section. Only the `BEHIND` state triggers",
15588
+ "an `update-branch` attempt \u2014 every other state either has nothing to do",
15589
+ "or is already gated on a different signal that Phase 5 picks up.",
15590
+ "",
15591
+ "Never run `gh pr update-branch` on a PR whose review mode is",
15592
+ "`human-required`. Pushing main into a human-required PR expands the",
15593
+ "scope of the diff the human is reviewing without their consent. The",
15594
+ "`update-branch` step lives **only** under the `Mode auto-merge` branch",
15595
+ "of this phase \u2014 `human-required` skips straight to its hand-off block",
15596
+ "below.",
15597
+ "",
15598
+ "##### Conflict-resolution delegation (BEHIND + conflicts)",
15599
+ "",
15600
+ "When `gh pr update-branch <pr-number>` fails because the merge would",
15601
+ "produce conflicts, the reviewer **may** delegate conflict resolution to",
15602
+ "`issue-worker` via the existing feedback-mode delegation contract (the",
15603
+ "same path Phase 4's in-scope-fix delegation uses). The reviewer never",
15604
+ "hand-resolves conflicts itself \u2014 branch mutations always belong to",
15605
+ "`issue-worker`.",
15606
+ "",
15607
+ "Delegate **only when all** of the following hold. If any guard fails,",
15608
+ "fall through to the fallback at the end of this sub-section instead.",
15609
+ "",
15610
+ "1. **Review mode is `auto-merge`.** Never delegate conflict",
15611
+ " resolution on `human-required` PRs \u2014 pushing main resolutions into",
15612
+ " them expands the diff the human is reviewing. (This is the same",
15613
+ " reason the `update-branch` step itself is auto-merge-only.)",
15614
+ "2. **Delegation invocation guard permits the hand-off** \u2014 the PR",
15615
+ " carries the `origin:issue-worker` label, **or** the reviewer was",
15616
+ " invoked with `--allow-human-author`. The same guard used for the",
15617
+ " in-scope-fix delegation flow above applies here unchanged.",
15618
+ "3. **The `review:fixing` lease is currently free.** If",
15619
+ " `review:fixing` is already on the PR, another delegation is",
15620
+ " in-flight; skip conflict-resolution delegation, log the contention",
15621
+ " to the sticky summary, and fall through to the fallback.",
15622
+ "4. **No conflicting file is generated or projen-managed.** Run",
15623
+ " `gh pr view <pr-number> --json files --jq '.files[].path'` and",
15624
+ " inspect the conflicting paths reported by the failed",
15625
+ " `update-branch`. If **any** conflicting path matches one of the",
15626
+ " following globs, the conflict is unsafe to resolve mechanically",
15627
+ " and the reviewer must skip delegation:",
15628
+ " - `**/*.lock` and `pnpm-lock.yaml` / `yarn.lock` / `package-lock.json`",
15629
+ " - `**/.projen/**`",
15630
+ " - any file whose first 5 lines contain the marker",
15631
+ " `~~ Generated by projen` or `// Generated by`.",
15632
+ " The lockfile guard exists because lockfile conflicts often need a",
15633
+ " regen (`pnpm i`) rather than a textual merge; the projen / generated",
15634
+ " guard exists because those files are derived from `.projenrc.ts`",
15635
+ " and conflicts there should be resolved by re-running synth, not by",
15636
+ " merging the conflict markers.",
15637
+ "",
15638
+ "When every guard above passes, hand off to `issue-worker` with a",
15639
+ "**single synthetic fix-list item** that describes the rebase work:",
15640
+ "",
15641
+ "1. **Disable auto-merge** so a fast CI pass cannot land the PR",
15642
+ " mid-delegation (idempotent \u2014 safe no-op when auto-merge was never",
15643
+ " enabled). This mirrors step (b) of the in-scope-fix flow:",
15644
+ "",
15645
+ " ```bash",
15646
+ " gh pr merge <pr-number> --disable-auto",
15647
+ " ```",
15648
+ "",
15649
+ "2. **Acquire the `review:fixing` lease** by adding the label",
15650
+ " (mirrors step (c) of the in-scope-fix flow). On contention, abort",
15651
+ " the delegation and fall through to the fallback:",
15652
+ "",
15653
+ " ```bash",
15654
+ " gh pr edit <pr-number> --add-label 'review:fixing'",
15655
+ " ```",
15656
+ "",
15657
+ "3. **Post a fix-list comment** containing exactly one synthetic item",
15658
+ " describing the rebase. The `comment_id` is the literal string",
15659
+ " `synthetic:rebase-behind-main` so the worker recognises the",
15660
+ " special case and the next reviewer pass can identify the item:",
15661
+ "",
15662
+ " ```markdown",
15663
+ " ## Reviewer: fix list for @issue-worker",
15664
+ "",
15665
+ " - [ ] @reviewer \u2014 rebase onto origin/<default-branch> and resolve conflicts in: <space-separated list of conflicting files>",
15666
+ "",
15667
+ " ```json fix-list",
15668
+ " {",
15669
+ ' "pr": <pr-number>,',
15670
+ ' "branch": "<head-ref-name>",',
15671
+ ' "generated_at": "<ISO-8601 timestamp>",',
15672
+ ' "items": [',
15673
+ ' {"comment_id": "synthetic:rebase-behind-main", "author": "reviewer", "file": "<first-conflicting-file>", "instruction": "Branch is BEHIND default-branch with merge conflicts. Pull and rebase onto origin/<default-branch>, resolve conflicts in <conflicting-files>, push the resolved branch (no force-push), and report success."}',
15674
+ " ]",
15675
+ " }",
15676
+ " ```",
15677
+ " ```",
15678
+ "",
15679
+ "4. **Invoke `issue-worker` in feedback mode** with the same prompt",
15680
+ " shape used by the in-scope-fix flow: include the literal phrase",
15681
+ " `feedback mode: PR #<n>` plus the repository identifier",
15682
+ " (`{{repository.owner}}/{{repository.name}}`).",
15683
+ "",
15684
+ "5. **Process the worker's report** for the synthetic item using the",
15685
+ " same logic as step (f) of the in-scope-fix flow \u2014 `handled` reacts",
15686
+ " `rocket` on the fix-list comment; `failed` reacts `thinking_face`",
15687
+ " and posts a reply citing the worker's failure reason.",
15688
+ "",
15689
+ "6. **Release the `review:fixing` lease** with",
15690
+ " `gh pr edit <pr-number> --remove-label 'review:fixing'`. Always",
15691
+ " run this step.",
15692
+ "",
15693
+ "7. **Do not re-enable auto-merge in the same pass.** After delegation,",
15694
+ " exit and let a human re-invoke the reviewer. The next pass will",
15695
+ " re-evaluate `mergeStateStatus` against the rebased branch and",
15696
+ " re-enable auto-merge through the normal flow above.",
15697
+ "",
15698
+ "Record `Branch updated: delegated (PR #<n>)` for the per-PR report",
15699
+ "when delegation completes (regardless of the worker's outcome \u2014 the",
15700
+ "delegation itself is the action taken).",
15701
+ "",
15702
+ "**Fallback when delegation is not permitted or guards fail.** Post a",
15703
+ "short comment explaining why the branch could not be updated",
15704
+ "automatically and stop. Do not push commits, do not force, do not",
15705
+ "retry. Record `Branch updated: failed (conflicts; <short reason>)`.",
15706
+ "",
15707
+ "```bash",
15708
+ "gh pr comment <pr-number> --body 'Auto-merge queued; branch is BEHIND <default-branch> with conflicts. <short reason delegation was skipped \u2014 e.g. human-required mode, generated-file conflicts, or in-flight review:fixing lease>. A human (or the next reviewer pass after rebase) will need to resolve.'",
15709
+ "```",
15710
+ "",
15896
15711
  "#### Mode `human-required`",
15897
15712
  "",
15898
15713
  "Do **not** run `gh pr merge --auto`. Instead, hand the PR off to a",
@@ -16083,6 +15898,7 @@ var prReviewerSubAgent = {
16083
15898
  " - Nitpick: <items>",
16084
15899
  "",
16085
15900
  "Action taken: <enable-auto-merge | label-awaiting-human | commented-on-the-pr | none>",
15901
+ "Branch updated: <yes | not needed | failed (<reason>) | delegated (PR #<n>) | n/a>",
16086
15902
  "Branch state: <merged | open | closed>",
16087
15903
  "Issue state: <closed | open>",
16088
15904
  "```",
@@ -16148,7 +15964,23 @@ var prReviewerSubAgent = {
16148
15964
  " `review:awaiting-human` label is **not** present on the PR. Any",
16149
15965
  " AC-drift pushback, any failed-fix pushback, and any human-required",
16150
15966
  " hand-off all keep auto-merge disabled until the human resolves",
16151
- " the underlying state."
15967
+ " the underlying state.",
15968
+ "15. **Never run `gh pr update-branch` on a `human-required` PR.**",
15969
+ " Pushing main into a human-required PR expands the scope of the",
15970
+ " diff the human is reviewing without their consent. The",
15971
+ " `update-branch` step is gated to the `Mode auto-merge` branch of",
15972
+ " Phase 4 only. The same restriction applies to delegating",
15973
+ " conflict resolution to `issue-worker`: never delegate a rebase",
15974
+ " on a `human-required` PR.",
15975
+ "16. **Never delegate conflict resolution involving generated or",
15976
+ " projen-managed files.** When `gh pr update-branch` fails on a",
15977
+ " BEHIND PR with conflicts and any conflicting path is a lockfile,",
15978
+ " a `**/.projen/**` file, or a file marked",
15979
+ " `~~ Generated by projen` / `// Generated by`, the reviewer must",
15980
+ " skip the `issue-worker` delegation and fall back to the comment",
15981
+ " pathway. Mechanical merge of generated content is unsafe \u2014 those",
15982
+ " files are derived from `.projenrc.ts` and must be regenerated,",
15983
+ " not merged."
16152
15984
  ].join("\n")
16153
15985
  };
16154
15986
  var reviewPrSkill = {
@@ -27260,12 +27092,6 @@ var ClaudeRenderer = class _ClaudeRenderer {
27260
27092
  if (agent.platforms?.claude?.memory) {
27261
27093
  lines.push(`memory: ${agent.platforms.claude.memory}`);
27262
27094
  }
27263
- if (agent.canDelegateToAgents && agent.canDelegateToAgents.length > 0) {
27264
- lines.push(`canDelegateToAgents:`);
27265
- for (const delegateName of agent.canDelegateToAgents) {
27266
- lines.push(` - "${delegateName}"`);
27267
- }
27268
- }
27269
27095
  lines.push("---");
27270
27096
  lines.push("");
27271
27097
  lines.push(...agent.prompt.split("\n"));
@@ -27729,7 +27555,6 @@ var AgentConfig = class _AgentConfig extends Component8 {
27729
27555
  if (resolvedRunRatio.enabled) {
27730
27556
  this.project.gitignore.addPatterns(`/${resolvedRunRatio.stateFilePath}`);
27731
27557
  }
27732
- validatePreflightPrConfig(this.options.preflightPr);
27733
27558
  validateUnblockDependentsConfig(this.options.unblockDependents);
27734
27559
  const resolvedProgressFiles = validateProgressFilesConfig(
27735
27560
  this.options.progressFiles
@@ -27946,14 +27771,13 @@ ${section}`
27946
27771
  }
27947
27772
  }
27948
27773
  }
27949
- if (this.options.tiers || this.options.scopeGate || this.options.runRatio || this.options.preflightPr || this.options.scheduledTasks || this.options.unblockDependents) {
27774
+ if (this.options.tiers || this.options.scopeGate || this.options.runRatio || this.options.scheduledTasks || this.options.unblockDependents) {
27950
27775
  const orchestratorRule = ruleMap.get("orchestrator-conventions");
27951
27776
  if (orchestratorRule) {
27952
27777
  const { conventionsContent } = resolveOrchestratorAssets(
27953
27778
  this.options.tiers,
27954
27779
  this.options.scopeGate,
27955
27780
  this.options.runRatio,
27956
- this.options.preflightPr,
27957
27781
  this.options.scheduledTasks,
27958
27782
  this.options.unblockDependents
27959
27783
  );
@@ -28268,14 +28092,13 @@ ${hook}`
28268
28092
  procMap.set(proc.name, proc);
28269
28093
  }
28270
28094
  }
28271
- if (this.options.tiers || this.options.scopeGate || this.options.runRatio || this.options.preflightPr) {
28095
+ if (this.options.tiers || this.options.scopeGate || this.options.runRatio) {
28272
28096
  const existing = procMap.get("check-blocked.sh");
28273
28097
  if (existing) {
28274
28098
  const { procedure } = resolveOrchestratorAssets(
28275
28099
  this.options.tiers,
28276
28100
  this.options.scopeGate,
28277
- this.options.runRatio,
28278
- this.options.preflightPr
28101
+ this.options.runRatio
28279
28102
  );
28280
28103
  if (procedure.content !== existing.content) {
28281
28104
  procMap.set("check-blocked.sh", procedure);
@@ -28290,7 +28113,6 @@ ${hook}`
28290
28113
  void 0,
28291
28114
  void 0,
28292
28115
  void 0,
28293
- void 0,
28294
28116
  this.options.unblockDependents
28295
28117
  );
28296
28118
  if (unblockDependentsProcedure2.content !== existing.content) {
@@ -30727,7 +30549,7 @@ var DEFAULT_AUTO_APPROVE_LABEL = "auto-approve";
30727
30549
  var DEFAULT_HEAD_BRANCH = "github-actions/upgrade";
30728
30550
  var DEFAULT_APPROVAL_APP_ID_SECRET = "APPROVAL_APP_ID";
30729
30551
  var DEFAULT_APPROVAL_APP_PRIVATE_KEY_SECRET = "APPROVAL_APP_PRIVATE_KEY";
30730
- var DEFAULT_MERGE_METHOD2 = MERGE_METHODS.SQUASH;
30552
+ var DEFAULT_MERGE_METHOD = MERGE_METHODS.SQUASH;
30731
30553
  var PULL_REQUEST_TARGET_TYPES = [
30732
30554
  "labeled",
30733
30555
  "synchronize",
@@ -30741,7 +30563,7 @@ function addApproveMergeUpgradeWorkflow(project, options) {
30741
30563
  const allowedUsernames = options.allowedUsernames;
30742
30564
  const appIdSecret = options.approvalAppIdSecret ?? DEFAULT_APPROVAL_APP_ID_SECRET;
30743
30565
  const privateKeySecret = options.approvalAppPrivateKeySecret ?? DEFAULT_APPROVAL_APP_PRIVATE_KEY_SECRET;
30744
- const mergeMethod = options.mergeMethod ?? DEFAULT_MERGE_METHOD2;
30566
+ const mergeMethod = options.mergeMethod ?? DEFAULT_MERGE_METHOD;
30745
30567
  const workflow = project.github?.addWorkflow(workflowName);
30746
30568
  if (!workflow) return;
30747
30569
  workflow.on({
@@ -32617,7 +32439,6 @@ export {
32617
32439
  DEFAULT_API_EXTRACTOR_REPORT_FOLDER,
32618
32440
  DEFAULT_AUDIT_REPORT_DIR,
32619
32441
  DEFAULT_DECOMPOSITION_TEMPLATE,
32620
- DEFAULT_DELEGATE_TO_PR_REVIEWER,
32621
32442
  DEFAULT_DISPATCH_MODEL,
32622
32443
  DEFAULT_DISPATCH_TO_HOUSEKEEPING_RATIO,
32623
32444
  DEFAULT_HOUSEKEEPING_MODEL,
@@ -32627,7 +32448,6 @@ export {
32627
32448
  DEFAULT_ISSUE_TEMPLATES_ENABLED,
32628
32449
  DEFAULT_ISSUE_TEMPLATES_PATH,
32629
32450
  DEFAULT_ISSUE_TEMPLATES_REQUIRE_REFERENCE,
32630
- DEFAULT_MERGE_METHOD,
32631
32451
  DEFAULT_OFF_PEAK_CRON_EXAMPLE,
32632
32452
  DEFAULT_PARTIAL_UNBLOCK_COMMENT_TEMPLATE,
32633
32453
  DEFAULT_PRIORITY_LABELS,
@@ -32637,7 +32457,6 @@ export {
32637
32457
  DEFAULT_PROGRESS_FILES_FORMAT,
32638
32458
  DEFAULT_PROGRESS_FILES_STALE_AFTER_HOURS,
32639
32459
  DEFAULT_PROGRESS_FILES_STATE_DIR,
32640
- DEFAULT_REQUIRE_LINKED_ISSUE,
32641
32460
  DEFAULT_REQUIRE_PRODUCT_CONTEXT,
32642
32461
  DEFAULT_SAMPLE_COMPILER_OPTIONS,
32643
32462
  DEFAULT_SCHEDULED_TASKS_ROOT,
@@ -32669,7 +32488,6 @@ export {
32669
32488
  MINIMUM_RELEASE_AGE,
32670
32489
  MONOREPO_LAYOUT,
32671
32490
  MonorepoProject,
32672
- PREFLIGHT_MERGE_METHOD_VALUES,
32673
32491
  PROD_DEPLOY_NAME,
32674
32492
  PROGRESS_FILES_FORMAT_VALUES,
32675
32493
  PnpmWorkspace,
@@ -32773,8 +32591,6 @@ export {
32773
32591
  renderIssueTemplatesRuleContent,
32774
32592
  renderIssueTemplatesStarterPage,
32775
32593
  renderMeetingTypesSection,
32776
- renderPreflightPrSection,
32777
- renderPreflightPrShellHelpers,
32778
32594
  renderPriorityRulesSection,
32779
32595
  renderProgressFileName,
32780
32596
  renderProgressFilePath,
@@ -32807,7 +32623,6 @@ export {
32807
32623
  resolveModelAlias,
32808
32624
  resolveOrchestratorAssets,
32809
32625
  resolveOutdirFromPackageName,
32810
- resolvePreflightPr,
32811
32626
  resolveProgressFiles,
32812
32627
  resolveRunRatio,
32813
32628
  resolveScheduledTasks,
@@ -32828,7 +32643,6 @@ export {
32828
32643
  validateAgentTierConfig,
32829
32644
  validateIssueTemplatesConfig,
32830
32645
  validateMonorepoLayout,
32831
- validatePreflightPrConfig,
32832
32646
  validateProgressFilesConfig,
32833
32647
  validateRunRatioConfig,
32834
32648
  validateScheduledTasksConfig,