@codedrifters/configulator 0.0.288 → 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
  {
@@ -12520,9 +12230,6 @@ function renderUnblockDependentsSection(ud) {
12520
12230
  "",
12521
12231
  "- The `pr-reviewer` sub-agent, Phase 5 (branch cleanup), after it",
12522
12232
  " applies `status:done` to the linked issue on a successful merge.",
12523
- "- The `orchestrator` sub-agent, Phase B0 (pre-flight PR merge)",
12524
- " post-merge verification, after it force-closes an issue whose",
12525
- " merge commit dropped its closing keyword.",
12526
12233
  "",
12527
12234
  "Any other agent that manually applies `status:done` should call",
12528
12235
  "`unblock-dependents.sh <closed-issue>` as its last step. The",
@@ -12828,12 +12535,11 @@ function shellSingleQuote(value) {
12828
12535
  }
12829
12536
 
12830
12537
  // src/agent/bundles/orchestrator.ts
12831
- function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
12538
+ function buildCheckBlockedScript(tiers, scopeGate, runRatio) {
12832
12539
  const tierCase = renderAgentTierCaseStatement(tiers);
12833
12540
  const scopeHelper = renderScopeGateShellHelpers(scopeGate);
12834
12541
  const scopeHelperIndented = scopeHelper.split("\n").map((line) => line.length > 0 ? line : "").join("\n");
12835
12542
  const runRatioHelper = renderRunRatioShellHelpers(runRatio);
12836
- const preflightHelper = renderPreflightPrShellHelpers(preflight);
12837
12543
  return [
12838
12544
  "#!/usr/bin/env bash",
12839
12545
  "# check-blocked.sh \u2014 Token-efficient issue triage for agent loops.",
@@ -12848,7 +12554,6 @@ function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
12848
12554
  "# .claude/procedures/check-blocked.sh prs",
12849
12555
  "# .claude/procedures/check-blocked.sh scope <issue-number>",
12850
12556
  "# .claude/procedures/check-blocked.sh tick",
12851
- "# .claude/procedures/check-blocked.sh preflight",
12852
12557
  "",
12853
12558
  "set -uo pipefail",
12854
12559
  "",
@@ -12863,10 +12568,6 @@ function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
12863
12568
  `RUN_RATIO_ENABLED=${runRatio.enabled ? "1" : "0"}`,
12864
12569
  `RUN_RATIO_DISPATCH_PER_HOUSEKEEPING=${runRatio.ratio}`,
12865
12570
  `ORCHESTRATOR_STATE_FILE="${runRatio.stateFilePath}"`,
12866
- `PREFLIGHT_ENABLED=${preflight.enabled ? "1" : "0"}`,
12867
- `PREFLIGHT_REQUIRE_LINKED_ISSUE=${preflight.requireLinkedIssue ? "1" : "0"}`,
12868
- `PREFLIGHT_MERGE_METHOD="${preflight.mergeMethod}"`,
12869
- `PREFLIGHT_DELEGATE_TO_PR_REVIEWER=${preflight.delegateToPrReviewer ? "1" : "0"}`,
12870
12571
  "",
12871
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",
12872
12573
  "",
@@ -12899,8 +12600,6 @@ function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
12899
12600
  "",
12900
12601
  runRatioHelper,
12901
12602
  "",
12902
- preflightHelper,
12903
- "",
12904
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",
12905
12604
  "",
12906
12605
  "cmd_unblock() {",
@@ -13265,26 +12964,24 @@ function buildCheckBlockedScript(tiers, scopeGate, runRatio, preflight) {
13265
12964
  ' prs) shift; cmd_prs "$@" ;;',
13266
12965
  ' scope) shift; cmd_scope "$@" ;;',
13267
12966
  ' tick) shift; cmd_tick "$@" ;;',
13268
- ' preflight) shift; cmd_preflight "$@" ;;',
13269
12967
  " help|*)",
13270
- ' 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>"',
13271
12969
  " exit 1",
13272
12970
  " ;;",
13273
12971
  "esac"
13274
12972
  ].join("\n");
13275
12973
  }
13276
- function buildCheckBlockedProcedure(tiers, scopeGate = resolveScopeGate(), runRatio = resolveRunRatio(), preflight = resolvePreflightPr()) {
12974
+ function buildCheckBlockedProcedure(tiers, scopeGate = resolveScopeGate(), runRatio = resolveRunRatio()) {
13277
12975
  return {
13278
12976
  name: "check-blocked.sh",
13279
- 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).",
13280
- 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)
13281
12979
  };
13282
12980
  }
13283
12981
  var checkBlockedProcedure = buildCheckBlockedProcedure(
13284
12982
  DEFAULT_AGENT_TIERS,
13285
12983
  resolveScopeGate(),
13286
- resolveRunRatio(),
13287
- resolvePreflightPr()
12984
+ resolveRunRatio()
13288
12985
  );
13289
12986
  function buildUnblockDependentsProcedure(unblockDependents = resolveUnblockDependents()) {
13290
12987
  return {
@@ -13298,7 +12995,7 @@ var unblockDependentsProcedure = buildUnblockDependentsProcedure(
13298
12995
  );
13299
12996
  var orchestratorSubAgent = {
13300
12997
  name: "orchestrator",
13301
- 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",
13302
12999
  model: AGENT_MODEL.POWERFUL,
13303
13000
  maxTurns: 100,
13304
13001
  platforms: { cursor: { exclude: true } },
@@ -13306,12 +13003,13 @@ var orchestratorSubAgent = {
13306
13003
  "# Orchestrator Agent",
13307
13004
  "",
13308
13005
  "You are the pipeline orchestrator for the **{{repository.owner}}/{{repository.name}}** repository.",
13309
- "Each invocation runs **one full end-to-end cycle**. The cycle merges",
13310
- "approved PRs, triages blocked issues, runs maintenance scans, picks the",
13311
- "next ready issue, and **delegates implementation to the `issue-worker`**",
13312
- "sub-agent in scheduled mode. The orchestrator itself never implements",
13313
- "code, creates branches, or pushes commits \u2014 it routes work to other",
13314
- "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.",
13315
13013
  "",
13316
13014
  "Run the phases below in order on every invocation. There is no",
13317
13015
  "dispatch/housekeeping fork \u2014 every phase runs every time.",
@@ -13319,20 +13017,23 @@ var orchestratorSubAgent = {
13319
13017
  "Phase ordering (each runs exactly once per invocation):",
13320
13018
  "",
13321
13019
  "1. **Phase A \u2014 Startup.** Pull the default branch.",
13322
- "2. **Phase B0 \u2014 Pre-flight PR Merge.** Land every eligible approved /",
13323
- " CI-green PR before triage reads dependency state.",
13324
- "3. **Phase C \u2014 Triage / Unblock.** Flip dependents that have all",
13020
+ "2. **Phase C \u2014 Triage / Unblock.** Flip dependents that have all",
13325
13021
  " their dependencies closed back to `status:ready`.",
13326
- "4. **Phase D \u2014 Maintenance.** Stale-issue and orphaned-resource scan",
13022
+ "3. **Phase D \u2014 Maintenance.** Stale-issue and orphaned-resource scan",
13327
13023
  " plus a needs-attention summary.",
13328
- "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",
13329
13025
  " and run the scope gate. If the result is `large`, flag and stop.",
13330
- "6. **Phase G \u2014 Delegate Implementation.** Hand the picked issue off",
13026
+ "5. **Phase G \u2014 Delegate Implementation.** Hand the picked issue off",
13331
13027
  " to the `issue-worker` sub-agent in scheduled mode. The worker",
13332
13028
  " handles claim \u2192 branch \u2192 implement \u2192 commit \u2192 PR autonomously.",
13333
- "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",
13334
13030
  " run summary.",
13335
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
+ "",
13336
13037
  "---",
13337
13038
  "",
13338
13039
  ...PROJECT_CONTEXT_READER_SECTION,
@@ -13344,100 +13045,6 @@ var orchestratorSubAgent = {
13344
13045
  "git checkout main && git pull origin main",
13345
13046
  "```",
13346
13047
  "",
13347
- "## Phase B0: Pre-flight PR Merge",
13348
- "",
13349
- "Before any other phase reads dependency state, land every",
13350
- "eligible PR. The sweep is idempotent \u2014 `gh pr merge` on an",
13351
- "already-merged PR is a no-op \u2014 so re-running on back-to-back",
13352
- "invocations is safe.",
13353
- "",
13354
- "List eligibility:",
13355
- "",
13356
- "```bash",
13357
- ".claude/procedures/check-blocked.sh preflight",
13358
- "```",
13359
- "",
13360
- "Expect one line per open PR:",
13361
- "",
13362
- "```",
13363
- 'PREFLIGHT_MERGE PR #<n> issue:#<m> branch:<b> \u2014 "<title>"',
13364
- 'PREFLIGHT_SKIP PR #<n> \u2014 <reason> \u2014 "<title>"',
13365
- "NO_PREFLIGHT_PRS",
13366
- "```",
13367
- "",
13368
- "If the output is `NO_PREFLIGHT_PRS`, continue to Phase B / C.",
13369
- "",
13370
- "For each `PREFLIGHT_MERGE` line, either **delegate** to the",
13371
- "`pr-reviewer` sub-agent (default) or **merge inline** depending",
13372
- "on the rendered pre-flight config. See the **Pre-flight PR",
13373
- "merge** section in `CLAUDE.md` for the project's mode.",
13374
- "",
13375
- "**Delegate mode (default).** Invoke the `pr-reviewer` sub-agent",
13376
- "with a single-pass brief covering every `PREFLIGHT_MERGE` line:",
13377
- "",
13378
- "> Run your merge pipeline once across these PRs: <list of",
13379
- "> `#<n>` numbers>. Merge every eligible PR (linked issue still",
13380
- "> open, AC satisfied, CI green, approval present) and comment on",
13381
- "> any PR you skip. Return a one-line summary as the final line of",
13382
- "> your response, e.g. `Merged 2 (#123, #124), skipped 1 (#125 \u2014",
13383
- "> AC not met), 0 eligible left.` or `No eligible PRs.`",
13384
- "",
13385
- "If the sub-agent's final line is missing, malformed, or indicates",
13386
- "an error, **do not retry** \u2014 proceed to the next phase anyway.",
13387
- "The next orchestrator session will re-run pre-flight and pick up",
13388
- "anything left behind.",
13389
- "",
13390
- "**Inline mode.** For each `PREFLIGHT_MERGE PR #<n> issue:#<m>`",
13391
- "line, merge the PR with the configured method (default",
13392
- "`--squash`) and `--delete-branch`:",
13393
- "",
13394
- "```bash",
13395
- 'gh pr merge <n> --squash --delete-branch --subject "<conventional-commit-title>" --body "<extended-description>"',
13396
- "```",
13397
- "",
13398
- "After every successful merge \u2014 whether delegated or inline \u2014 run",
13399
- "the post-merge verification step to close the stale-dependency",
13400
- "loop:",
13401
- "",
13402
- "```bash",
13403
- "gh issue view <m> --json state --jq '.state'",
13404
- "```",
13405
- "",
13406
- "If the linked issue's state is still `OPEN`, close it explicitly",
13407
- "and flip its status label to `status:done`:",
13408
- "",
13409
- "```bash",
13410
- "gh issue close <m>",
13411
- 'gh issue edit <m> --remove-label "status:ready-for-review" --add-label "status:done"',
13412
- "```",
13413
- "",
13414
- "After applying `status:done` \u2014 whether the auto-close fired or",
13415
- "you force-closed above \u2014 run the targeted unblock sweep so any",
13416
- "dependents that were only waiting on issue `<m>` flip to",
13417
- "`status:ready` immediately:",
13418
- "",
13419
- "```bash",
13420
- ".claude/procedures/unblock-dependents.sh <m>",
13421
- "```",
13422
- "",
13423
- "The script emits one line per processed dependent",
13424
- "(`UNBLOCKED #<n>` / `STILL_BLOCKED #<n>` / `NO_DEPENDENTS #<m>`)",
13425
- "so the run summary records what transitioned. See the",
13426
- "**Agent-driven unblocking** section in `CLAUDE.md` for the full",
13427
- "contract.",
13428
- "",
13429
- "This step is the reason pre-flight exists: it prevents the",
13430
- "orchestrator from reading a merged-but-not-auto-closed issue as",
13431
- "still blocking on the next unblock sweep.",
13432
- "",
13433
- "Log the pre-flight outcome (number merged, PRs skipped with",
13434
- "reasons, and any issues force-closed) so the run summary records",
13435
- "what landed.",
13436
- "",
13437
- "Skip lines starting with `PREFLIGHT_SKIP` \u2014 those PRs failed one",
13438
- "or more eligibility checks. The `pr-reviewer` or a human",
13439
- "operator picks them up on the normal review path.",
13440
- "",
13441
13048
  "## Phase C: Triage \u2014 Unblock",
13442
13049
  "",
13443
13050
  "Check for blocked issues whose dependencies have resolved:",
@@ -13633,40 +13240,31 @@ var orchestratorSubAgent = {
13633
13240
  "git fetch --prune origin",
13634
13241
  "```",
13635
13242
  "",
13636
- "Log completion: phases executed, PRs merged in pre-flight, issues",
13637
- "unblocked, stale issues flagged, the next work item picked, and",
13638
- "the outcome of Phase G's delegation (worker success / failure /",
13639
- "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).",
13640
13247
  "",
13641
13248
  "---",
13642
13249
  "",
13643
13250
  "## Rules",
13644
13251
  "",
13645
- "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.",
13646
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.",
13647
- "3. **Always use check-blocked.sh.** All triage queries go through the shell script for token efficiency.",
13648
- "4. **Follow CLAUDE.md conventions** for all git and gh operations.",
13649
- "5. **Priority order:** critical > high > medium > low > trivial, then **funnel tier asc** (lower tier wins ties), then FIFO by issue number.",
13650
- "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",
13651
13259
  " on the top `PICK` line before reporting `NEXT_WORK_ITEM`. A",
13652
13260
  " `large` issue must be flagged with `status:needs-attention` and",
13653
13261
  " handed a decomposition proposal \u2014 never claimed, never branched,",
13654
13262
  " never delegated to the `issue-worker`.",
13655
- "7. **Always run pre-flight before reading dependency state.**",
13656
- " Phase B0 (Pre-flight PR Merge) runs on every invocation,",
13657
- " immediately after Phase A. Never skip Phase B0: without it, an",
13658
- " issue whose only remaining blocker is an approved-but-not-yet-",
13659
- " merged PR reads as blocked on every cycle and the pipeline",
13660
- " thrashes. See the **Pre-flight PR merge** section in",
13661
- " `CLAUDE.md` for eligibility rules and the delegate-vs-inline",
13662
- " modes.",
13663
13263
  "8. **Sweep dependents whenever you apply `status:done`.** Every",
13664
13264
  " `status:done` transition must be immediately followed by",
13665
13265
  " `.claude/procedures/unblock-dependents.sh <n>` so downstream",
13666
13266
  " `Depends on: #<n>` issues flip to `status:ready` without",
13667
- " waiting for the next cycle. Phase B0's post-merge",
13668
- " verification (and any inline-mode merge) already calls the",
13669
- " sweep; don't skip it. See the **Agent-driven unblocking**",
13267
+ " waiting for the next cycle. See the **Agent-driven unblocking**",
13670
13268
  " section in `CLAUDE.md` for the contract.",
13671
13269
  "9. **Always invoke `issue-worker` in scheduled mode.** Phase G's",
13672
13270
  " delegation prompt must contain the literal phrase",
@@ -13680,7 +13278,7 @@ var issueWorkerSubAgent = {
13680
13278
  name: "issue-worker",
13681
13279
  description: "Selects the next ready issue from the queue, claims it, and implements the change end-to-end following repository conventions",
13682
13280
  model: AGENT_MODEL.POWERFUL,
13683
- maxTurns: 100,
13281
+ maxTurns: 150,
13684
13282
  platforms: { cursor: { exclude: true } },
13685
13283
  prompt: [
13686
13284
  "# Issue Worker",
@@ -13909,6 +13507,35 @@ var issueWorkerSubAgent = {
13909
13507
  " `file` (and optional `line`). Track `comment_id` per item so you can",
13910
13508
  " report which items were handled and which (if any) failed.",
13911
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
+ "",
13912
13539
  "4. When complete, prepare a short structured report (PR number, commit",
13913
13540
  " SHAs you will push, items handled by `comment_id`, items that failed",
13914
13541
  " to apply) \u2014 you will return this after Phase 6.",
@@ -13970,6 +13597,22 @@ var issueWorkerSubAgent = {
13970
13597
  "git push origin <branch-name>",
13971
13598
  "```",
13972
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
+ "",
13973
13616
  "**Normal mode:** Use conventional commit messages and push with `-u`",
13974
13617
  "to set up branch tracking:",
13975
13618
  "",
@@ -14103,8 +13746,8 @@ var ORCHESTRATOR_CONVENTIONS_PREAMBLE = [
14103
13746
  "",
14104
13747
  "When running the orchestrator agent (`.claude/agents/orchestrator.md`):",
14105
13748
  "",
14106
- "- 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",
14107
- "- 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`).",
14108
13751
  "- All triage queries use `.claude/procedures/check-blocked.sh` for token efficiency",
14109
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.",
14110
13753
  "- Priority order: critical > high > medium > low > trivial, then **funnel tier asc** (lower tier wins ties), then FIFO by issue number",
@@ -14117,7 +13760,7 @@ var ORCHESTRATOR_CONVENTIONS_PREAMBLE = [
14117
13760
  "",
14118
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.'
14119
13762
  ].join("\n");
14120
- 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()) {
14121
13764
  return [
14122
13765
  ORCHESTRATOR_CONVENTIONS_PREAMBLE,
14123
13766
  "",
@@ -14127,18 +13770,15 @@ function buildOrchestratorConventionsContent(tiers, scopeGate = resolveScopeGate
14127
13770
  "",
14128
13771
  renderRunRatioSection(runRatio),
14129
13772
  "",
14130
- renderPreflightPrSection(preflight),
14131
- "",
14132
13773
  renderScheduledTasksSection(scheduledTasks),
14133
13774
  "",
14134
13775
  renderUnblockDependentsSection(unblockDependents)
14135
13776
  ].join("\n");
14136
13777
  }
14137
- function resolveOrchestratorAssets(tierConfig, scopeGateConfig, runRatioConfig, preflightPrConfig, scheduledTasksConfig, unblockDependentsConfig) {
13778
+ function resolveOrchestratorAssets(tierConfig, scopeGateConfig, runRatioConfig, scheduledTasksConfig, unblockDependentsConfig) {
14138
13779
  const tiers = resolveAgentTiers(tierConfig);
14139
13780
  const scopeGate = resolveScopeGate(scopeGateConfig);
14140
13781
  const runRatio = resolveRunRatio(runRatioConfig);
14141
- const preflight = resolvePreflightPr(preflightPrConfig);
14142
13782
  const scheduledTasks = resolveScheduledTasks(scheduledTasksConfig);
14143
13783
  const unblockDependentsResolved = resolveUnblockDependents(
14144
13784
  unblockDependentsConfig
@@ -14147,23 +13787,16 @@ function resolveOrchestratorAssets(tierConfig, scopeGateConfig, runRatioConfig,
14147
13787
  tiers,
14148
13788
  scopeGate,
14149
13789
  runRatio,
14150
- preflight,
14151
13790
  scheduledTasks,
14152
13791
  unblockDependents: unblockDependentsResolved,
14153
13792
  conventionsContent: buildOrchestratorConventionsContent(
14154
13793
  tiers,
14155
13794
  scopeGate,
14156
13795
  runRatio,
14157
- preflight,
14158
13796
  scheduledTasks,
14159
13797
  unblockDependentsResolved
14160
13798
  ),
14161
- procedure: buildCheckBlockedProcedure(
14162
- tiers,
14163
- scopeGate,
14164
- runRatio,
14165
- preflight
14166
- ),
13799
+ procedure: buildCheckBlockedProcedure(tiers, scopeGate, runRatio),
14167
13800
  unblockDependentsProcedure: buildUnblockDependentsProcedure(
14168
13801
  unblockDependentsResolved
14169
13802
  )
@@ -14177,13 +13810,12 @@ var orchestratorBundle = {
14177
13810
  rules: [
14178
13811
  {
14179
13812
  name: "orchestrator-conventions",
14180
- 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",
14181
13814
  scope: AGENT_RULE_SCOPE.ALWAYS,
14182
13815
  content: buildOrchestratorConventionsContent(
14183
13816
  DEFAULT_AGENT_TIERS,
14184
13817
  resolveScopeGate(),
14185
13818
  resolveRunRatio(),
14186
- resolvePreflightPr(),
14187
13819
  resolveScheduledTasks(),
14188
13820
  resolveUnblockDependents()
14189
13821
  ),
@@ -15920,6 +15552,162 @@ var prReviewerSubAgent = {
15920
15552
  "`feat(scope): description`). The body should bullet the changes and end",
15921
15553
  "with `Closes #<issue-number>`.",
15922
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
+ "",
15923
15711
  "#### Mode `human-required`",
15924
15712
  "",
15925
15713
  "Do **not** run `gh pr merge --auto`. Instead, hand the PR off to a",
@@ -16110,6 +15898,7 @@ var prReviewerSubAgent = {
16110
15898
  " - Nitpick: <items>",
16111
15899
  "",
16112
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>",
16113
15902
  "Branch state: <merged | open | closed>",
16114
15903
  "Issue state: <closed | open>",
16115
15904
  "```",
@@ -16175,7 +15964,23 @@ var prReviewerSubAgent = {
16175
15964
  " `review:awaiting-human` label is **not** present on the PR. Any",
16176
15965
  " AC-drift pushback, any failed-fix pushback, and any human-required",
16177
15966
  " hand-off all keep auto-merge disabled until the human resolves",
16178
- " 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."
16179
15984
  ].join("\n")
16180
15985
  };
16181
15986
  var reviewPrSkill = {
@@ -27750,7 +27555,6 @@ var AgentConfig = class _AgentConfig extends Component8 {
27750
27555
  if (resolvedRunRatio.enabled) {
27751
27556
  this.project.gitignore.addPatterns(`/${resolvedRunRatio.stateFilePath}`);
27752
27557
  }
27753
- validatePreflightPrConfig(this.options.preflightPr);
27754
27558
  validateUnblockDependentsConfig(this.options.unblockDependents);
27755
27559
  const resolvedProgressFiles = validateProgressFilesConfig(
27756
27560
  this.options.progressFiles
@@ -27967,14 +27771,13 @@ ${section}`
27967
27771
  }
27968
27772
  }
27969
27773
  }
27970
- 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) {
27971
27775
  const orchestratorRule = ruleMap.get("orchestrator-conventions");
27972
27776
  if (orchestratorRule) {
27973
27777
  const { conventionsContent } = resolveOrchestratorAssets(
27974
27778
  this.options.tiers,
27975
27779
  this.options.scopeGate,
27976
27780
  this.options.runRatio,
27977
- this.options.preflightPr,
27978
27781
  this.options.scheduledTasks,
27979
27782
  this.options.unblockDependents
27980
27783
  );
@@ -28289,14 +28092,13 @@ ${hook}`
28289
28092
  procMap.set(proc.name, proc);
28290
28093
  }
28291
28094
  }
28292
- if (this.options.tiers || this.options.scopeGate || this.options.runRatio || this.options.preflightPr) {
28095
+ if (this.options.tiers || this.options.scopeGate || this.options.runRatio) {
28293
28096
  const existing = procMap.get("check-blocked.sh");
28294
28097
  if (existing) {
28295
28098
  const { procedure } = resolveOrchestratorAssets(
28296
28099
  this.options.tiers,
28297
28100
  this.options.scopeGate,
28298
- this.options.runRatio,
28299
- this.options.preflightPr
28101
+ this.options.runRatio
28300
28102
  );
28301
28103
  if (procedure.content !== existing.content) {
28302
28104
  procMap.set("check-blocked.sh", procedure);
@@ -28311,7 +28113,6 @@ ${hook}`
28311
28113
  void 0,
28312
28114
  void 0,
28313
28115
  void 0,
28314
- void 0,
28315
28116
  this.options.unblockDependents
28316
28117
  );
28317
28118
  if (unblockDependentsProcedure2.content !== existing.content) {
@@ -30748,7 +30549,7 @@ var DEFAULT_AUTO_APPROVE_LABEL = "auto-approve";
30748
30549
  var DEFAULT_HEAD_BRANCH = "github-actions/upgrade";
30749
30550
  var DEFAULT_APPROVAL_APP_ID_SECRET = "APPROVAL_APP_ID";
30750
30551
  var DEFAULT_APPROVAL_APP_PRIVATE_KEY_SECRET = "APPROVAL_APP_PRIVATE_KEY";
30751
- var DEFAULT_MERGE_METHOD2 = MERGE_METHODS.SQUASH;
30552
+ var DEFAULT_MERGE_METHOD = MERGE_METHODS.SQUASH;
30752
30553
  var PULL_REQUEST_TARGET_TYPES = [
30753
30554
  "labeled",
30754
30555
  "synchronize",
@@ -30762,7 +30563,7 @@ function addApproveMergeUpgradeWorkflow(project, options) {
30762
30563
  const allowedUsernames = options.allowedUsernames;
30763
30564
  const appIdSecret = options.approvalAppIdSecret ?? DEFAULT_APPROVAL_APP_ID_SECRET;
30764
30565
  const privateKeySecret = options.approvalAppPrivateKeySecret ?? DEFAULT_APPROVAL_APP_PRIVATE_KEY_SECRET;
30765
- const mergeMethod = options.mergeMethod ?? DEFAULT_MERGE_METHOD2;
30566
+ const mergeMethod = options.mergeMethod ?? DEFAULT_MERGE_METHOD;
30766
30567
  const workflow = project.github?.addWorkflow(workflowName);
30767
30568
  if (!workflow) return;
30768
30569
  workflow.on({
@@ -32638,7 +32439,6 @@ export {
32638
32439
  DEFAULT_API_EXTRACTOR_REPORT_FOLDER,
32639
32440
  DEFAULT_AUDIT_REPORT_DIR,
32640
32441
  DEFAULT_DECOMPOSITION_TEMPLATE,
32641
- DEFAULT_DELEGATE_TO_PR_REVIEWER,
32642
32442
  DEFAULT_DISPATCH_MODEL,
32643
32443
  DEFAULT_DISPATCH_TO_HOUSEKEEPING_RATIO,
32644
32444
  DEFAULT_HOUSEKEEPING_MODEL,
@@ -32648,7 +32448,6 @@ export {
32648
32448
  DEFAULT_ISSUE_TEMPLATES_ENABLED,
32649
32449
  DEFAULT_ISSUE_TEMPLATES_PATH,
32650
32450
  DEFAULT_ISSUE_TEMPLATES_REQUIRE_REFERENCE,
32651
- DEFAULT_MERGE_METHOD,
32652
32451
  DEFAULT_OFF_PEAK_CRON_EXAMPLE,
32653
32452
  DEFAULT_PARTIAL_UNBLOCK_COMMENT_TEMPLATE,
32654
32453
  DEFAULT_PRIORITY_LABELS,
@@ -32658,7 +32457,6 @@ export {
32658
32457
  DEFAULT_PROGRESS_FILES_FORMAT,
32659
32458
  DEFAULT_PROGRESS_FILES_STALE_AFTER_HOURS,
32660
32459
  DEFAULT_PROGRESS_FILES_STATE_DIR,
32661
- DEFAULT_REQUIRE_LINKED_ISSUE,
32662
32460
  DEFAULT_REQUIRE_PRODUCT_CONTEXT,
32663
32461
  DEFAULT_SAMPLE_COMPILER_OPTIONS,
32664
32462
  DEFAULT_SCHEDULED_TASKS_ROOT,
@@ -32690,7 +32488,6 @@ export {
32690
32488
  MINIMUM_RELEASE_AGE,
32691
32489
  MONOREPO_LAYOUT,
32692
32490
  MonorepoProject,
32693
- PREFLIGHT_MERGE_METHOD_VALUES,
32694
32491
  PROD_DEPLOY_NAME,
32695
32492
  PROGRESS_FILES_FORMAT_VALUES,
32696
32493
  PnpmWorkspace,
@@ -32794,8 +32591,6 @@ export {
32794
32591
  renderIssueTemplatesRuleContent,
32795
32592
  renderIssueTemplatesStarterPage,
32796
32593
  renderMeetingTypesSection,
32797
- renderPreflightPrSection,
32798
- renderPreflightPrShellHelpers,
32799
32594
  renderPriorityRulesSection,
32800
32595
  renderProgressFileName,
32801
32596
  renderProgressFilePath,
@@ -32828,7 +32623,6 @@ export {
32828
32623
  resolveModelAlias,
32829
32624
  resolveOrchestratorAssets,
32830
32625
  resolveOutdirFromPackageName,
32831
- resolvePreflightPr,
32832
32626
  resolveProgressFiles,
32833
32627
  resolveRunRatio,
32834
32628
  resolveScheduledTasks,
@@ -32849,7 +32643,6 @@ export {
32849
32643
  validateAgentTierConfig,
32850
32644
  validateIssueTemplatesConfig,
32851
32645
  validateMonorepoLayout,
32852
- validatePreflightPrConfig,
32853
32646
  validateProgressFilesConfig,
32854
32647
  validateRunRatioConfig,
32855
32648
  validateScheduledTasksConfig,