@webpieces/pr-gate 0.4.984 → 0.4.986

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.
Files changed (57) hide show
  1. package/package.json +8 -8
  2. package/src/scripts/commands/build-push-dev-command.d.ts +79 -0
  3. package/src/scripts/commands/build-push-dev-command.js +184 -0
  4. package/src/scripts/commands/build-push-dev-command.js.map +1 -0
  5. package/src/scripts/commands/finish-push-dev-command.d.ts +73 -17
  6. package/src/scripts/commands/finish-push-dev-command.js +187 -31
  7. package/src/scripts/commands/finish-push-dev-command.js.map +1 -1
  8. package/src/scripts/commands/start-push-dev-command.d.ts +43 -0
  9. package/src/scripts/commands/start-push-dev-command.js +111 -0
  10. package/src/scripts/commands/start-push-dev-command.js.map +1 -0
  11. package/src/scripts/pr-gate-app.d.ts +18 -18
  12. package/src/scripts/pr-gate-app.js +27 -26
  13. package/src/scripts/pr-gate-app.js.map +1 -1
  14. package/src/scripts/pr-gate-cli-app.d.ts +2 -2
  15. package/src/scripts/pr-gate-cli-app.js +20 -29
  16. package/src/scripts/pr-gate-cli-app.js.map +1 -1
  17. package/src/scripts/workflow/build-gate-log.d.ts +1 -0
  18. package/src/scripts/workflow/build-gate-log.js +7 -3
  19. package/src/scripts/workflow/build-gate-log.js.map +1 -1
  20. package/src/scripts/workflow/dev-build.d.ts +8 -5
  21. package/src/scripts/workflow/dev-build.js +13 -9
  22. package/src/scripts/workflow/dev-build.js.map +1 -1
  23. package/src/scripts/workflow/dev-copy-on-main.d.ts +6 -4
  24. package/src/scripts/workflow/dev-copy-on-main.js +8 -6
  25. package/src/scripts/workflow/dev-copy-on-main.js.map +1 -1
  26. package/src/scripts/workflow/dev-deploy-refs.d.ts +4 -17
  27. package/src/scripts/workflow/dev-deploy-refs.js +5 -21
  28. package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
  29. package/src/scripts/workflow/dev-resolve-runner.d.ts +56 -71
  30. package/src/scripts/workflow/dev-resolve-runner.js +156 -182
  31. package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
  32. package/src/scripts/workflow/landed-copy-resolver.d.ts +56 -0
  33. package/src/scripts/workflow/landed-copy-resolver.js +141 -0
  34. package/src/scripts/workflow/landed-copy-resolver.js.map +1 -0
  35. package/src/scripts/workflow/main-freshness.d.ts +16 -0
  36. package/src/scripts/workflow/main-freshness.js +33 -0
  37. package/src/scripts/workflow/main-freshness.js.map +1 -0
  38. package/src/scripts/workflow/push-dev-state.d.ts +12 -35
  39. package/src/scripts/workflow/push-dev-state.js +31 -62
  40. package/src/scripts/workflow/push-dev-state.js.map +1 -1
  41. package/src/scripts/workflow/verified-dev-copy.d.ts +46 -0
  42. package/src/scripts/workflow/verified-dev-copy.js +89 -0
  43. package/src/scripts/workflow/verified-dev-copy.js.map +1 -0
  44. package/src/scripts/{wp-build-dev.js → wp-build-push-dev.js} +2 -2
  45. package/src/scripts/wp-build-push-dev.js.map +1 -0
  46. package/src/scripts/{wp-push-dev.js → wp-start-push-dev.js} +2 -2
  47. package/src/scripts/wp-start-push-dev.js.map +1 -0
  48. package/src/scripts/commands/build-dev-command.d.ts +0 -27
  49. package/src/scripts/commands/build-dev-command.js +0 -99
  50. package/src/scripts/commands/build-dev-command.js.map +0 -1
  51. package/src/scripts/commands/push-dev-command.d.ts +0 -140
  52. package/src/scripts/commands/push-dev-command.js +0 -356
  53. package/src/scripts/commands/push-dev-command.js.map +0 -1
  54. package/src/scripts/wp-build-dev.js.map +0 -1
  55. package/src/scripts/wp-push-dev.js.map +0 -1
  56. /package/src/scripts/{wp-build-dev.d.ts → wp-build-push-dev.d.ts} +0 -0
  57. /package/src/scripts/{wp-push-dev.d.ts → wp-start-push-dev.d.ts} +0 -0
@@ -1,16 +1,19 @@
1
1
  import { BuildAffected } from './build-affected';
2
2
  import { DevDeployRefs } from './dev-deploy-refs';
3
3
  /** The example printed when the key is missing. An example, never a fallback: nothing ever RUNS it. */
4
- export declare const EXAMPLE_DEV_BUILD_COMMAND = "pnpm nx affected --target=ci --base=origin/dev --head=HEAD";
4
+ export declare const EXAMPLE_DEV_BUILD_COMMAND = "pnpm nx affected -t build test --base=origin/dev --head=HEAD";
5
5
  /**
6
6
  * The dev-scoped build (#1397): `commands.push-dev.buildCommand`, run through the SAME build gate as
7
7
  * `wp-build` and the PR gate (`BuildAffected.runBuildGateWith`) — one log-file capture, one heartbeat, one
8
8
  * ledger row pair, one failure rendering. Only the command and the log name (`build-dev.log`) differ.
9
9
  *
10
- * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: the PR gate builds what this branch
11
- * changes against `main`. Before a dev publish the question is different — does this copy build once it is
12
- * merged with what is ALREADY on `dev` — and the cheap way to answer it builds only what differs from
13
- * `origin/dev`. The two are different builds, so they are two keys.
10
+ * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: `wp-build-push-dev` runs BOTH (#1405). The
11
+ * PR gate's build runs first, on the feature branch alone, with the code rules judging it against main. This
12
+ * one runs on the merge with `dev` and answers a different question — does everyone's code still compile and
13
+ * pass tests together — so it should compile and test ONLY, affected vs `origin/dev`. It must not run the
14
+ * code rules (`architecture:validate-code`, i.e. an nx `ci` target): that tree holds every other developer's
15
+ * copy, and diffed against main their code is judged as the publisher's change. The two are different
16
+ * builds, so they are two keys.
14
17
  *
15
18
  * NO DEFAULT, deliberately (`.claude/rules/no-rule-defaults.md`): which build vouches for a dev publish is
16
19
  * the consumer's decision. Missing ⇒ the command refuses before it touches anything, naming the key and
@@ -9,16 +9,19 @@ const build_gate_log_1 = require("./build-gate-log");
9
9
  const dev_deploy_refs_1 = require("./dev-deploy-refs");
10
10
  const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
11
11
  /** The example printed when the key is missing. An example, never a fallback: nothing ever RUNS it. */
12
- exports.EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected --target=ci --base=origin/dev --head=HEAD';
12
+ exports.EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected -t build test --base=origin/dev --head=HEAD';
13
13
  /**
14
14
  * The dev-scoped build (#1397): `commands.push-dev.buildCommand`, run through the SAME build gate as
15
15
  * `wp-build` and the PR gate (`BuildAffected.runBuildGateWith`) — one log-file capture, one heartbeat, one
16
16
  * ledger row pair, one failure rendering. Only the command and the log name (`build-dev.log`) differ.
17
17
  *
18
- * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: the PR gate builds what this branch
19
- * changes against `main`. Before a dev publish the question is different — does this copy build once it is
20
- * merged with what is ALREADY on `dev` — and the cheap way to answer it builds only what differs from
21
- * `origin/dev`. The two are different builds, so they are two keys.
18
+ * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: `wp-build-push-dev` runs BOTH (#1405). The
19
+ * PR gate's build runs first, on the feature branch alone, with the code rules judging it against main. This
20
+ * one runs on the merge with `dev` and answers a different question — does everyone's code still compile and
21
+ * pass tests together — so it should compile and test ONLY, affected vs `origin/dev`. It must not run the
22
+ * code rules (`architecture:validate-code`, i.e. an nx `ci` target): that tree holds every other developer's
23
+ * copy, and diffed against main their code is judged as the publisher's change. The two are different
24
+ * builds, so they are two keys.
22
25
  *
23
26
  * NO DEFAULT, deliberately (`.claude/rules/no-rule-defaults.md`): which build vouches for a dev publish is
24
27
  * the consumer's decision. Missing ⇒ the command refuses before it touches anything, naming the key and
@@ -37,11 +40,12 @@ let DevBuild = class DevBuild {
37
40
  if (configured !== undefined && configured.trim() !== '')
38
41
  return configured;
39
42
  throw new rules_config_1.CliExitError(2, '\n' + SEP + '⛔ `commands.push-dev.buildCommand` is not configured\n' + SEP + '\n'
40
- + `${rules_config_1.WP_PUSH_DEV} builds your copy merged with origin/dev before it publishes, and ${rules_config_1.WP_BUILD_DEV}\n`
41
- + 'runs that build on its own. WHICH build is this repo\'s decision, so there is no default.\n'
43
+ + `${rules_config_1.WP_BUILD_PUSH_DEV} builds your copy merged with origin/dev before wp-finish-push-dev publishes it.\n`
44
+ + 'WHICH build is this repo\'s decision, so there is no default.\n'
42
45
  + 'Nothing was merged, built or published.\n\n'
43
- + 'Add this to webpieces.config.json, inside "commands", choosing a command that builds only what\n'
44
- + 'differs from origin/dev in this repo:\n\n'
46
+ + 'Add this to webpieces.config.json, inside "commands", choosing a command that compiles and tests\n'
47
+ + 'only what differs from origin/dev — and runs NO code rules (no `ci` target): the rules already judged\n'
48
+ + 'your branch against main, and on this tree they would judge every other developer\'s copy as yours:\n\n'
45
49
  + ` "push-dev": { "buildCommand": "${exports.EXAMPLE_DEV_BUILD_COMMAND}" }\n`);
46
50
  }
47
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"dev-build.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-build.ts"],"names":[],"mappings":";;;;AAAA,0DAAkF;AAClF,yCAA2D;AAE3D,qDAAmE;AACnE,qDAAmD;AACnD,uDAAkD;AAElD,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,uGAAuG;AAC1F,QAAA,yBAAyB,GAAG,4DAA4D,CAAC;AAEtG;;;;;;;;;;;;;GAaG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEI;IACA;IAFrB,YACqB,aAA4B,EAC5B,IAAmB;QADnB,kBAAa,GAAb,aAAa,CAAe;QAC5B,SAAI,GAAJ,IAAI,CAAe;IACrC,CAAC;IAEJ,4GAA4G;IAC5G,OAAO,CAAC,QAAgB;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,UAAU,CAAC;QAC5E,MAAM,IAAI,2BAAY,CAAC,CAAC,EACpB,IAAI,GAAG,GAAG,GAAG,wDAAwD,GAAG,GAAG,GAAG,IAAI;cAChF,GAAG,0BAAW,qEAAqE,2BAAY,IAAI;cACnG,6FAA6F;cAC7F,6CAA6C;cAC7C,kGAAkG;cAClG,2CAA2C;cAC3C,oCAAoC,iCAAyB,OAAO,CAAC,CAAC;IAChF,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,QAAgB,EAAE,YAAoB;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,iCAAgB,CAC9E,iDAAiD,EACjD,YAAY,EACZ,2CAA2C,EAC3C,gCAAe,CAClB,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAlCY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGD,8BAAa;QACtB,+BAAa;GAH/B,QAAQ,CAkCpB","sourcesContent":["import { CliExitError, WP_BUILD_DEV, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { BuildAffected, BuildGateOptions } from './build-affected';\nimport { DEV_BUILD_STAGE } from './build-gate-log';\nimport { DevDeployRefs } from './dev-deploy-refs';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The example printed when the key is missing. An example, never a fallback: nothing ever RUNS it. */\nexport const EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected --target=ci --base=origin/dev --head=HEAD';\n\n/**\n * The dev-scoped build (#1397): `commands.push-dev.buildCommand`, run through the SAME build gate as\n * `wp-build` and the PR gate (`BuildAffected.runBuildGateWith`) — one log-file capture, one heartbeat, one\n * ledger row pair, one failure rendering. Only the command and the log name (`build-dev.log`) differ.\n *\n * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: the PR gate builds what this branch\n * changes against `main`. Before a dev publish the question is different — does this copy build once it is\n * merged with what is ALREADY on `dev` — and the cheap way to answer it builds only what differs from\n * `origin/dev`. The two are different builds, so they are two keys.\n *\n * NO DEFAULT, deliberately (`.claude/rules/no-rule-defaults.md`): which build vouches for a dev publish is\n * the consumer's decision. Missing ⇒ the command refuses before it touches anything, naming the key and\n * printing the entry to paste.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevBuild {\n constructor(\n private readonly buildAffected: BuildAffected,\n private readonly refs: DevDeployRefs,\n ) {}\n\n /** The configured command, or the refusal naming the key. Called BEFORE any git write, so it fails fast. */\n command(repoRoot: string): string {\n const configured = this.refs.devBuildCommand(repoRoot);\n if (configured !== undefined && configured.trim() !== '') return configured;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ `commands.push-dev.buildCommand` is not configured\\n' + SEP + '\\n'\n + `${WP_PUSH_DEV} builds your copy merged with origin/dev before it publishes, and ${WP_BUILD_DEV}\\n`\n + 'runs that build on its own. WHICH build is this repo\\'s decision, so there is no default.\\n'\n + 'Nothing was merged, built or published.\\n\\n'\n + 'Add this to webpieces.config.json, inside \"commands\", choosing a command that builds only what\\n'\n + 'differs from origin/dev in this repo:\\n\\n'\n + ` \"push-dev\": { \"buildCommand\": \"${EXAMPLE_DEV_BUILD_COMMAND}\" }\\n`);\n }\n\n /**\n * Run the dev build on the CURRENT checkout. Throws CliExitError on a red build, with the `FullLog :`\n * pointer, exactly like `wp-build`. `rerunCommand` is what the failure text tells the reader to run\n * after fixing it.\n */\n run(repoRoot: string, rerunCommand: string): Promise<void> {\n const command = this.command(repoRoot);\n return this.buildAffected.runBuildGateWith(repoRoot, command, new BuildGateOptions(\n '🛠️ dev build (commands.push-dev.buildCommand)',\n rerunCommand,\n 'Dev build failed — nothing was published.',\n DEV_BUILD_STAGE,\n ));\n }\n}\n"]}
1
+ {"version":3,"file":"dev-build.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-build.ts"],"names":[],"mappings":";;;;AAAA,0DAA0E;AAC1E,yCAA2D;AAE3D,qDAAmE;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cesContent":["import { CliExitError, WP_BUILD_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { BuildAffected, BuildGateOptions } from './build-affected';\nimport { DEV_BUILD_STAGE } from './build-gate-log';\nimport { DevDeployRefs } from './dev-deploy-refs';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The example printed when the key is missing. An example, never a fallback: nothing ever RUNS it. */\nexport const EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected -t build test --base=origin/dev --head=HEAD';\n\n/**\n * The dev-scoped build (#1397): `commands.push-dev.buildCommand`, run through the SAME build gate as\n * `wp-build` and the PR gate (`BuildAffected.runBuildGateWith`) — one log-file capture, one heartbeat, one\n * ledger row pair, one failure rendering. Only the command and the log name (`build-dev.log`) differ.\n *\n * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: `wp-build-push-dev` runs BOTH (#1405). The\n * PR gate's build runs first, on the feature branch alone, with the code rules judging it against main. This\n * one runs on the merge with `dev` and answers a different question — does everyone's code still compile and\n * pass tests together — so it should compile and test ONLY, affected vs `origin/dev`. It must not run the\n * code rules (`architecture:validate-code`, i.e. an nx `ci` target): that tree holds every other developer's\n * copy, and diffed against main their code is judged as the publisher's change. The two are different\n * builds, so they are two keys.\n *\n * NO DEFAULT, deliberately (`.claude/rules/no-rule-defaults.md`): which build vouches for a dev publish is\n * the consumer's decision. Missing ⇒ the command refuses before it touches anything, naming the key and\n * printing the entry to paste.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevBuild {\n constructor(\n private readonly buildAffected: BuildAffected,\n private readonly refs: DevDeployRefs,\n ) {}\n\n /** The configured command, or the refusal naming the key. Called BEFORE any git write, so it fails fast. */\n command(repoRoot: string): string {\n const configured = this.refs.devBuildCommand(repoRoot);\n if (configured !== undefined && configured.trim() !== '') return configured;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ `commands.push-dev.buildCommand` is not configured\\n' + SEP + '\\n'\n + `${WP_BUILD_PUSH_DEV} builds your copy merged with origin/dev before wp-finish-push-dev publishes it.\\n`\n + 'WHICH build is this repo\\'s decision, so there is no default.\\n'\n + 'Nothing was merged, built or published.\\n\\n'\n + 'Add this to webpieces.config.json, inside \"commands\", choosing a command that compiles and tests\\n'\n + 'only what differs from origin/dev — and runs NO code rules (no `ci` target): the rules already judged\\n'\n + 'your branch against main, and on this tree they would judge every other developer\\'s copy as yours:\\n\\n'\n + ` \"push-dev\": { \"buildCommand\": \"${EXAMPLE_DEV_BUILD_COMMAND}\" }\\n`);\n }\n\n /**\n * Run the dev build on the CURRENT checkout. Throws CliExitError on a red build, with the `FullLog :`\n * pointer, exactly like `wp-build`. `rerunCommand` is what the failure text tells the reader to run\n * after fixing it.\n */\n run(repoRoot: string, rerunCommand: string): Promise<void> {\n const command = this.command(repoRoot);\n return this.buildAffected.runBuildGateWith(repoRoot, command, new BuildGateOptions(\n '🛠️ dev build (commands.push-dev.buildCommand)',\n rerunCommand,\n 'Dev build failed — nothing was published.',\n DEV_BUILD_STAGE,\n ));\n }\n}\n"]}
@@ -22,7 +22,8 @@ export declare class MergedPr {
22
22
  constructor(num: string, mergedAt: string);
23
23
  }
24
24
  /**
25
- * Answers "is this dev copy already on `origin/main`?" for `wp-push-dev --remove` (#1401).
25
+ * Answers "is this dev copy already on `origin/main`?" for `wp-finish-push-dev --remove` (#1401), and for
26
+ * `wp-build-push-dev`'s automatic resolution of conflicts caused only by landed copies (#1405).
26
27
  *
27
28
  * WHY: developers ran `--remove` after their PR landed, as a "done, clean up" habit. On a repo that composes
28
29
  * `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and
@@ -40,9 +41,10 @@ export declare class DevCopyOnMain {
40
41
  constructor(gitExec: GitExec, processes: NativeProcessApi);
41
42
  landing(repoRoot: string, copyRef: string): Promise<DevCopyLanding>;
42
43
  /**
43
- * The merged PR whose head was `branch`, or null. It only decorates the refusal message, so a `gh` that
44
- * is missing, unauthenticated or offline yields null rather than an error: the content check above has
45
- * already decided.
44
+ * The merged PR whose head was `branch`, or null. A `gh` that is missing, unauthenticated or offline
45
+ * yields null rather than an error, and null is always the SAFE answer: for `--remove` it only drops a
46
+ * decoration from the refusal (the content check above has already decided), and for the landed-copy
47
+ * resolution (#1405) it means "not proven landed", so the conflict is left for the developer.
46
48
  */
47
49
  mergedPr(repoRoot: string, branch: string): Promise<MergedPr | null>;
48
50
  private names;
@@ -42,7 +42,8 @@ exports.MergedPr = MergedPr;
42
42
  // `<number> <mergedAt>` as the --jq below prints it; an empty list prints `null null`, which does not match.
43
43
  const PR_LINE = /^(\d+) (\S+)$/;
44
44
  /**
45
- * Answers "is this dev copy already on `origin/main`?" for `wp-push-dev --remove` (#1401).
45
+ * Answers "is this dev copy already on `origin/main`?" for `wp-finish-push-dev --remove` (#1401), and for
46
+ * `wp-build-push-dev`'s automatic resolution of conflicts caused only by landed copies (#1405).
46
47
  *
47
48
  * WHY: developers ran `--remove` after their PR landed, as a "done, clean up" habit. On a repo that composes
48
49
  * `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and
@@ -63,15 +64,16 @@ let DevCopyOnMain = class DevCopyOnMain {
63
64
  }
64
65
  async landing(repoRoot, copyRef) {
65
66
  const copy = `refs/remotes/origin/${copyRef}`;
66
- const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`], `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy}). Nothing was removed.`);
67
- const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy], `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy}). Nothing was removed.`));
67
+ const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`], `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy}).`);
68
+ const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy], `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy}).`));
68
69
  const landed = changed.filter((f) => !stillDiffer.has(f));
69
70
  return new DevCopyLanding(changed, landed);
70
71
  }
71
72
  /**
72
- * The merged PR whose head was `branch`, or null. It only decorates the refusal message, so a `gh` that
73
- * is missing, unauthenticated or offline yields null rather than an error: the content check above has
74
- * already decided.
73
+ * The merged PR whose head was `branch`, or null. A `gh` that is missing, unauthenticated or offline
74
+ * yields null rather than an error, and null is always the SAFE answer: for `--remove` it only drops a
75
+ * decoration from the refusal (the content check above has already decided), and for the landed-copy
76
+ * resolution (#1405) it means "not proven landed", so the conflict is left for the developer.
75
77
  */
76
78
  async mergedPr(repoRoot, branch) {
77
79
  const result = await this.processes.run('gh', [
@@ -1 +1 @@
1
- {"version":3,"file":"dev-copy-on-main.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-copy-on-main.ts"],"names":[],"mappings":";;;;AAAA,8DAA6D;AAC7D,yCAA2D;AAE3D,yCAAqC;AAErC,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C;;;;;GAKG;AACH,MAAa,cAAc;IAEV;IACA;IAFb,YACa,OAAiB,EACjB,MAAgB;QADhB,YAAO,GAAP,OAAO,CAAU;QACjB,WAAM,GAAN,MAAM,CAAU;IAC1B,CAAC;IAEJ,8GAA8G;IAC9G,WAAW;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACtD,CAAC;IAED,kEAAkE;IAClE,YAAY;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACzD,CAAC;CACJ;AAfD,wCAeC;AAED,wFAAwF;AACxF,MAAa,QAAQ;IAEJ;IACA;IAFb,YACa,GAAW,EACX,QAAgB;QADhB,QAAG,GAAH,GAAG,CAAQ;QACX,aAAQ,GAAR,QAAQ,CAAQ;I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E,oCAAoC;SAC5E,EAAE,QAAQ,CAAC,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACjD,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAEO,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,IAAc,EAAE,OAAe;QACjE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7H,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACzG,CAAC;CACJ,CAAA;AApCY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGP,kBAAO;QACL,iCAAgB;GAHvC,aAAa,CAoCzB","sourcesContent":["import { NativeProcessApi } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from './git-exec';\n\nconst MAIN_REF = 'refs/remotes/origin/main';\n\n/**\n * How much of one dev copy is already on `origin/main`. Data-only per CLAUDE.md.\n *\n * `changed` is every file the copy changes relative to its merge-base with `origin/main`; `landed` is the\n * subset whose content on `origin/main` is now identical to the copy's.\n */\nexport class DevCopyLanding {\n constructor(\n readonly changed: string[],\n readonly landed: string[],\n ) {}\n\n /** Every file the copy changes already has the copy's content on main — removing it takes nothing off dev. */\n fullyOnMain(): boolean {\n return this.landed.length === this.changed.length;\n }\n\n /** Some, but not all, of the copy's files are already on main. */\n partlyOnMain(): boolean {\n return this.landed.length > 0 && !this.fullyOnMain();\n }\n}\n\n/** The merged PR a copy's branch landed through, for the refusal message. Data-only. */\nexport class MergedPr {\n constructor(\n readonly num: string,\n readonly mergedAt: string,\n ) {}\n}\n\n// `<number> <mergedAt>` as the --jq below prints it; an empty list prints `null null`, which does not match.\nconst PR_LINE = /^(\\d+) (\\S+)$/;\n\n/**\n * Answers \"is this dev copy already on `origin/main`?\" for `wp-push-dev --remove` (#1401).\n *\n * WHY: developers ran `--remove` after their PR landed, as a \"done, clean up\" habit. On a repo that composes\n * `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and\n * still triggers a full recompose that can redeploy every service. Only rolling back a copy that broke dev is\n * a real reason to remove.\n *\n * HOW: a pure content check, no GitHub dependency. The files the copy changes since its merge-base with\n * `origin/main` (`git diff A...B`), minus the files where `origin/main` and the copy still differ\n * (`git diff A B`), are the files already landed. Both refs must already be fetched. `--no-renames` so a\n * rename counts both its old and new path rather than hiding the deletion.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevCopyOnMain {\n constructor(\n private readonly gitExec: GitExec,\n private readonly processes: NativeProcessApi,\n ) {}\n\n async landing(repoRoot: string, copyRef: string): Promise<DevCopyLanding> {\n const copy = `refs/remotes/origin/${copyRef}`;\n const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`],\n `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy}). Nothing was removed.`);\n const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy],\n `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy}). Nothing was removed.`));\n const landed = changed.filter((f: string): boolean => !stillDiffer.has(f));\n return new DevCopyLanding(changed, landed);\n }\n\n /**\n * The merged PR whose head was `branch`, or null. It only decorates the refusal message, so a `gh` that\n * is missing, unauthenticated or offline yields null rather than an error: the content check above has\n * already decided.\n */\n async mergedPr(repoRoot: string, branch: string): Promise<MergedPr | null> {\n const result = await this.processes.run('gh', [\n 'pr', 'list', '--head', branch, '--state', 'merged', '--limit', '1',\n '--json', 'number,mergedAt', '--jq', '.[0] | \"\\\\(.number) \\\\(.mergedAt)\"',\n ], repoRoot);\n if (!result.ok) return null;\n const match = PR_LINE.exec(result.stdout.trim());\n if (match === null) return null;\n return new MergedPr(match[1], match[2]);\n }\n\n private async names(repoRoot: string, revs: string[], failMsg: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['-C', repoRoot, 'diff', '--name-only', '--no-renames', ...revs], repoRoot, failMsg);\n return out.split('\\n').map((l: string): string => l.trim()).filter((l: string): boolean => l !== '');\n }\n}\n"]}
1
+ {"version":3,"file":"dev-copy-on-main.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-copy-on-main.ts"],"names":[],"mappings":";;;;AAAA,8DAA6D;AAC7D,yCAA2D;AAE3D,yCAAqC;AAErC,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C;;;;;GAKG;AACH,MAAa,cAAc;IAEV;IACA;IAFb,YACa,OAAiB,EACjB,MAAgB;QADhB,YAAO,GAAP,OAAO,CAAU;QACjB,WAAM,GAAN,MAAM,CAAU;IAC1B,CAAC;IAEJ,8GAA8G;IAC9G,WAAW;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACtD,CAAC;IAED,kEAAkE;IAClE,YAAY;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACzD,CAAC;CACJ;AAfD,wCAeC;AAED,wFAAwF;AACxF,MAAa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AAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG;YACnE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,oCAAoC;SAC5E,EAAE,QAAQ,CAAC,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACjD,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAEO,KAAK,CAAC,KAAK,CAAC,QAAgB,EAAE,IAAc,EAAE,OAAe;QACjE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7H,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACzG,CAAC;CACJ,CAAA;AArCY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGP,kBAAO;QACL,iCAAgB;GAHvC,aAAa,CAqCzB","sourcesContent":["import { NativeProcessApi } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from './git-exec';\n\nconst MAIN_REF = 'refs/remotes/origin/main';\n\n/**\n * How much of one dev copy is already on `origin/main`. Data-only per CLAUDE.md.\n *\n * `changed` is every file the copy changes relative to its merge-base with `origin/main`; `landed` is the\n * subset whose content on `origin/main` is now identical to the copy's.\n */\nexport class DevCopyLanding {\n constructor(\n readonly changed: string[],\n readonly landed: string[],\n ) {}\n\n /** Every file the copy changes already has the copy's content on main — removing it takes nothing off dev. */\n fullyOnMain(): boolean {\n return this.landed.length === this.changed.length;\n }\n\n /** Some, but not all, of the copy's files are already on main. */\n partlyOnMain(): boolean {\n return this.landed.length > 0 && !this.fullyOnMain();\n }\n}\n\n/** The merged PR a copy's branch landed through, for the refusal message. Data-only. */\nexport class MergedPr {\n constructor(\n readonly num: string,\n readonly mergedAt: string,\n ) {}\n}\n\n// `<number> <mergedAt>` as the --jq below prints it; an empty list prints `null null`, which does not match.\nconst PR_LINE = /^(\\d+) (\\S+)$/;\n\n/**\n * Answers \"is this dev copy already on `origin/main`?\" for `wp-finish-push-dev --remove` (#1401), and for\n * `wp-build-push-dev`'s automatic resolution of conflicts caused only by landed copies (#1405).\n *\n * WHY: developers ran `--remove` after their PR landed, as a \"done, clean up\" habit. On a repo that composes\n * `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and\n * still triggers a full recompose that can redeploy every service. Only rolling back a copy that broke dev is\n * a real reason to remove.\n *\n * HOW: a pure content check, no GitHub dependency. The files the copy changes since its merge-base with\n * `origin/main` (`git diff A...B`), minus the files where `origin/main` and the copy still differ\n * (`git diff A B`), are the files already landed. Both refs must already be fetched. `--no-renames` so a\n * rename counts both its old and new path rather than hiding the deletion.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevCopyOnMain {\n constructor(\n private readonly gitExec: GitExec,\n private readonly processes: NativeProcessApi,\n ) {}\n\n async landing(repoRoot: string, copyRef: string): Promise<DevCopyLanding> {\n const copy = `refs/remotes/origin/${copyRef}`;\n const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`],\n `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy}).`);\n const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy],\n `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy}).`));\n const landed = changed.filter((f: string): boolean => !stillDiffer.has(f));\n return new DevCopyLanding(changed, landed);\n }\n\n /**\n * The merged PR whose head was `branch`, or null. A `gh` that is missing, unauthenticated or offline\n * yields null rather than an error, and null is always the SAFE answer: for `--remove` it only drops a\n * decoration from the refusal (the content check above has already decided), and for the landed-copy\n * resolution (#1405) it means \"not proven landed\", so the conflict is left for the developer.\n */\n async mergedPr(repoRoot: string, branch: string): Promise<MergedPr | null> {\n const result = await this.processes.run('gh', [\n 'pr', 'list', '--head', branch, '--state', 'merged', '--limit', '1',\n '--json', 'number,mergedAt', '--jq', '.[0] | \"\\\\(.number) \\\\(.mergedAt)\"',\n ], repoRoot);\n if (!result.ok) return null;\n const match = PR_LINE.exec(result.stdout.trim());\n if (match === null) return null;\n return new MergedPr(match[1], match[2]);\n }\n\n private async names(repoRoot: string, revs: string[], failMsg: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['-C', repoRoot, 'diff', '--name-only', '--no-renames', ...revs], repoRoot, failMsg);\n return out.split('\\n').map((l: string): string => l.trim()).filter((l: string): boolean => l !== '');\n }\n}\n"]}
@@ -2,8 +2,7 @@ import { DevDeployConfig } from '@webpieces/rules-config';
2
2
  import { GitExec } from './git-exec';
3
3
  /**
4
4
  * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —
5
- * `--list` prints it and the clobber guard compares against `sha`, and neither should be re-parsing
6
- * `ls-remote` output.
5
+ * `--list` prints it, and should not be re-parsing `ls-remote` output.
7
6
  */
8
7
  export declare class DevCopy {
9
8
  /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */
@@ -14,8 +13,8 @@ export declare class DevCopy {
14
13
  constructor(ref: string, sha: string, sourceBranch: string);
15
14
  }
16
15
  /**
17
- * Ref derivation and preconditions for the dev-deploy flow — the half of `wp-push-dev` that decides WHICH
18
- * refs are in play, kept out of the commands so both `wp-push-dev` and `wp-finish-push-dev` answer those
16
+ * Ref derivation and preconditions for the dev-deploy flow — the half that decides WHICH refs are in play,
17
+ * kept out of the commands so `wp-start-push-dev`, `wp-build-push-dev` and `wp-finish-push-dev` answer those
19
18
  * questions identically.
20
19
  *
21
20
  * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire
@@ -50,12 +49,7 @@ export declare class DevDeployRefs {
50
49
  */
51
50
  assertPushable(cfg: DevDeployConfig, branch: string): void;
52
51
  /**
53
- * Every live copy in the namespace, sorted by ref name.
54
- *
55
- * The sort is not cosmetic: `--resolve` with no argument queues these in exactly this order, and the
56
- * consumer's CI composes `dev` in the same order, so what a developer resolves locally is the
57
- * composition CI will actually build. A different order can produce a different (still valid) merge
58
- * result, which would make the local resolution a guess about CI rather than a rehearsal of it.
52
+ * Every live copy in the namespace, sorted by ref name — what `wp-finish-push-dev --list` prints.
59
53
  */
60
54
  liveCopies(repoRoot: string, cfg: DevDeployConfig): Promise<DevCopy[]>;
61
55
  /**
@@ -83,12 +77,5 @@ export declare class DevDeployRefs {
83
77
  * stale refs rehearses a composition CI will not build.
84
78
  */
85
79
  fetchCopies(repoRoot: string, refs: string[]): Promise<void>;
86
- /**
87
- * The subject of every commit `origin/<ref>` has that `HEAD` does not — the clobber signal. Empty =
88
- * safe to publish. Subjects rather than a count, because a commit this flow wrote itself (a recorded
89
- * conflict resolution, see DevResolveRunner) is re-derived by the next publish's check against dev and
90
- * is therefore safe to replace, while anything else on the copy is somebody's work.
91
- */
92
- subjectsOnlyOnRemote(repoRoot: string, ref: string): Promise<string[]>;
93
80
  private refusal;
94
81
  }
@@ -11,8 +11,7 @@ const MAIN = 'main';
11
11
  const DETACHED = 'HEAD';
12
12
  /**
13
13
  * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —
14
- * `--list` prints it and the clobber guard compares against `sha`, and neither should be re-parsing
15
- * `ls-remote` output.
14
+ * `--list` prints it, and should not be re-parsing `ls-remote` output.
16
15
  */
17
16
  class DevCopy {
18
17
  /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */
@@ -28,8 +27,8 @@ class DevCopy {
28
27
  }
29
28
  exports.DevCopy = DevCopy;
30
29
  /**
31
- * Ref derivation and preconditions for the dev-deploy flow — the half of `wp-push-dev` that decides WHICH
32
- * refs are in play, kept out of the commands so both `wp-push-dev` and `wp-finish-push-dev` answer those
30
+ * Ref derivation and preconditions for the dev-deploy flow — the half that decides WHICH refs are in play,
31
+ * kept out of the commands so `wp-start-push-dev`, `wp-build-push-dev` and `wp-finish-push-dev` answer those
33
32
  * questions identically.
34
33
  *
35
34
  * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire
@@ -92,12 +91,7 @@ let DevDeployRefs = class DevDeployRefs {
92
91
  }
93
92
  }
94
93
  /**
95
- * Every live copy in the namespace, sorted by ref name.
96
- *
97
- * The sort is not cosmetic: `--resolve` with no argument queues these in exactly this order, and the
98
- * consumer's CI composes `dev` in the same order, so what a developer resolves locally is the
99
- * composition CI will actually build. A different order can produce a different (still valid) merge
100
- * result, which would make the local resolution a guess about CI rather than a rehearsal of it.
94
+ * Every live copy in the namespace, sorted by ref name — what `wp-finish-push-dev --list` prints.
101
95
  */
102
96
  async liveCopies(repoRoot, cfg) {
103
97
  const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', cfg.copyRefGlob()], repoRoot, `Failed to list the dev copies (git ls-remote --heads origin '${cfg.copyRefGlob()}').`);
@@ -156,18 +150,8 @@ let DevDeployRefs = class DevDeployRefs {
156
150
  const specs = refs.map((r) => `+refs/heads/${r}:refs/remotes/origin/${r}`);
157
151
  await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', ...specs], 'Failed to fetch the dev copy refs from origin');
158
152
  }
159
- /**
160
- * The subject of every commit `origin/<ref>` has that `HEAD` does not — the clobber signal. Empty =
161
- * safe to publish. Subjects rather than a count, because a commit this flow wrote itself (a recorded
162
- * conflict resolution, see DevResolveRunner) is re-derived by the next publish's check against dev and
163
- * is therefore safe to replace, while anything else on the copy is somebody's work.
164
- */
165
- async subjectsOnlyOnRemote(repoRoot, ref) {
166
- const out = await this.gitExec.gitQuery(['log', '--format=%s', `HEAD..refs/remotes/origin/${ref}`], repoRoot, `Failed to compare HEAD against origin/${ref} (git log HEAD..origin/${ref}).`);
167
- return out.split('\n').filter((l) => l.trim() !== '');
168
- }
169
153
  refusal(headline, body) {
170
- return '\n' + SEP + `⛔ ${headline}\n` + SEP + '\n' + body + `\nRun \`${rules_config_1.WP_PUSH_DEV} --help\` for the full command.\n`;
154
+ return '\n' + SEP + `⛔ ${headline}\n` + SEP + '\n' + body + '\nRun `pnpm wp-finish-push-dev --help` for the full command.\n';
171
155
  }
172
156
  };
173
157
  exports.DevDeployRefs = DevDeployRefs;
@@ -1 +1 @@
1
- {"version":3,"file":"dev-deploy-refs.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-deploy-refs.ts"],"names":[],"mappings":";;;;AAAA,0DAAsG;AACtG,yCAA2D;AAC3D,8DAAwD;AAExD,yCAAqC;AAErC,MAAM,GAAG,GAAG,0DAA0D,CAAC;AACvE,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAa,OAAO;IAChB,iFAAiF;IACjF,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,uFAAuF;IACvF,YAAY,CAAS;IAErB,YAAY,GAAW,EAAE,GAAW,EAAE,YAAoB;QACtD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AAZD,0BAYC;AAED;;;;;;;;;;G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G,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,WAAW,0BAAW,mCAAmC,CAAC;IAC1H,CAAC;CACJ,CAAA;AArJY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEC,kBAAO;GADpC,aAAa,CAqJzB","sourcesContent":["import { CliExitError, DevDeployConfig, loadAndValidate, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { gitCheckout } from '@webpieces/tooling-common';\n\nimport { GitExec } from './git-exec';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\nconst MAIN = 'main';\nconst DETACHED = 'HEAD';\n\n/**\n * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —\n * `--list` prints it and the clobber guard compares against `sha`, and neither should be re-parsing\n * `ls-remote` output.\n */\nexport class DevCopy {\n /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */\n ref: string;\n sha: string;\n /** The feature branch this is a copy OF — `ref` with the namespace prefix stripped. */\n sourceBranch: string;\n\n constructor(ref: string, sha: string, sourceBranch: string) {\n this.ref = ref;\n this.sha = sha;\n this.sourceBranch = sourceBranch;\n }\n}\n\n/**\n * Ref derivation and preconditions for the dev-deploy flow — the half of `wp-push-dev` that decides WHICH\n * refs are in play, kept out of the commands so both `wp-push-dev` and `wp-finish-push-dev` answer those\n * questions identically.\n *\n * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire\n * another developer's commits — landing that PR would ship their unreviewed work to production. Every\n * write this flow performs therefore targets either the `<namespace>/<feature>` copy or a local throwaway\n * branch, and NOTHING here ever moves `<feature>` itself. That is why a conflict resolution needs the copy\n * to live in: it is the only place the resolution can be recorded without contaminating the PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevDeployRefs {\n constructor(private readonly gitExec: GitExec) {}\n\n /** The `pr-gate.devDeploy` block — `dev-include` / `dev` / `dev-remove` unless the consumer overrode it. */\n config(repoRoot: string): DevDeployConfig {\n return loadAndValidate(repoRoot).prGate.devDeploy;\n }\n\n /**\n * `commands.push-dev.buildCommand`, or `undefined` when the consumer has not configured it. There is\n * no default (#1397, `.claude/rules/no-rule-defaults.md`); DevBuild turns `undefined` into the refusal\n * that names the key.\n */\n devBuildCommand(repoRoot: string): string | undefined {\n return loadAndValidate(repoRoot).commands.pushDev.buildCommand;\n }\n\n /** The checked-out branch name, or `'HEAD'` on a detached HEAD (which {@link assertPushable} refuses). */\n currentBranch(repoRoot: string): string {\n return gitCheckout.requireBranch(repoRoot);\n }\n\n /**\n * Refuse every branch that must never be the SOURCE of a dev copy, before anything is fetched or\n * pushed.\n *\n * `main` and the composed dev branch are refused for the same reason from opposite ends: `main` is the\n * trunk (whatever is on it already deploys, so copying it is meaningless), and the dev branch is a\n * BUILD ARTIFACT that CI recomputes from `origin/main` on every run — copying it would publish a\n * composition of everyone's work under one developer's name, and it would be wiped on the next CI run\n * anyway. A branch already inside the namespace is refused because publishing a copy of a copy nests\n * the prefix (`dev-include/dev-include/…`) and nothing would ever clean it up.\n */\n assertPushable(cfg: DevDeployConfig, branch: string): void {\n if (branch === DETACHED || branch === '') {\n throw new CliExitError(2, this.refusal(\n 'Detached HEAD',\n 'There is no branch name to derive the dev copy from. Check out your feature branch first:\\n'\n + ' git checkout <your-feature-branch>\\n'));\n }\n if (branch === MAIN) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${MAIN}\\``,\n `\\`${MAIN}\\` is the trunk — whatever is on it already deploys, so a dev copy of it means nothing.\\n`\n + 'Check out the feature branch you actually want on the dev server and re-run.\\n'));\n }\n if (branch === cfg.devBranch) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${cfg.devBranch}\\``,\n `\\`${cfg.devBranch}\\` is a BUILD ARTIFACT, not a source branch: your CI resets it to origin/${MAIN},\\n`\n + `merges every \\`${cfg.copyRefGlob()}\\` ref into it, and force-pushes — every run. Copying it would\\n`\n + \"publish a composition of everybody's work under your branch's name, and the next CI run would\\n\"\n + 'wipe it. Check out your own feature branch and re-run.\\n'));\n }\n if (branch === cfg.branchNamespace || branch.startsWith(`${cfg.branchNamespace}/`)) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of a dev copy (\\`${branch}\\`)`,\n `\\`${cfg.branchNamespace}/\\` holds the disposable copies this command WRITES; you are standing on one.\\n`\n + `Publishing from here would nest the prefix (\\`${cfg.branchNamespace}/${branch}\\`) and nothing ever\\n`\n + 'cleans that up. Check out the real feature branch and re-run.\\n'));\n }\n }\n\n /**\n * Every live copy in the namespace, sorted by ref name.\n *\n * The sort is not cosmetic: `--resolve` with no argument queues these in exactly this order, and the\n * consumer's CI composes `dev` in the same order, so what a developer resolves locally is the\n * composition CI will actually build. A different order can produce a different (still valid) merge\n * result, which would make the local resolution a guess about CI rather than a rehearsal of it.\n */\n async liveCopies(repoRoot: string, cfg: DevDeployConfig): Promise<DevCopy[]> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', cfg.copyRefGlob()], repoRoot,\n `Failed to list the dev copies (git ls-remote --heads origin '${cfg.copyRefGlob()}').`);\n const copies: DevCopy[] = [];\n for (const line of out.split('\\n')) {\n if (line.trim() === '') continue;\n const fields = line.split(/\\s+/);\n const sha = fields[0];\n const ref = fields[1];\n if (sha === undefined || ref === undefined || !ref.startsWith('refs/heads/')) continue;\n const shortRef = ref.slice('refs/heads/'.length);\n copies.push(new DevCopy(shortRef, sha, shortRef.slice(cfg.branchNamespace.length + 1)));\n }\n return copies.sort((a: DevCopy, b: DevCopy): number => (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0));\n }\n\n /**\n * The sha of a local ref (default HEAD).\n *\n * Read AFTER a push so the watch hints quote the sha that is provably published. Quoting the copy\n * REF instead would be a moving target — it advances the next time anybody publishes — and the whole\n * value of the \"did my code land in dev\" check is that it is a claim about one specific commit.\n */\n headSha(repoRoot: string, ref = 'HEAD'): Promise<string> {\n return this.gitExec.gitQuery(['-C', repoRoot, 'rev-parse', ref], repoRoot,\n `Failed to read the sha of ${ref} (git rev-parse).`);\n }\n\n /**\n * Fetch `origin/main` and return its sha — what the `--remove` marker points at (#1395).\n *\n * The marker carries no content, so any sha the remote already has would do; `main`'s tip is chosen\n * because it is guaranteed to exist on origin (the push sends no objects) and it is what the\n * consumer's workflow composes from anyway. Fetched rather than read from the local tracking ref, so a\n * clone that has not fetched in weeks does not point the marker at an arbitrarily old commit.\n */\n async freshMainTip(repoRoot: string): Promise<string> {\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', `+refs/heads/${MAIN}:refs/remotes/origin/${MAIN}`],\n `Failed to fetch origin/${MAIN}, which the --remove marker points at. Nothing was removed`);\n return this.headSha(repoRoot, `refs/remotes/origin/${MAIN}`);\n }\n\n /** The remote sha of one copy, or '' when that copy does not exist yet. */\n async remoteSha(repoRoot: string, ref: string): Promise<string> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', ref], repoRoot,\n `Failed to look up origin/${ref} (git ls-remote).`);\n const line = out.split('\\n').find((l: string): boolean => l.trim() !== '');\n if (line === undefined) return '';\n return line.split(/\\s+/)[0] ?? '';\n }\n\n /**\n * Fetch the named copy refs into `refs/remotes/origin/<ref>` so the local merges below run against\n * fresh state. A no-op for an empty list, and a hard failure otherwise: a resolve queued against\n * stale refs rehearses a composition CI will not build.\n */\n async fetchCopies(repoRoot: string, refs: string[]): Promise<void> {\n if (refs.length === 0) return;\n const specs = refs.map((r: string): string => `+refs/heads/${r}:refs/remotes/origin/${r}`);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', ...specs],\n 'Failed to fetch the dev copy refs from origin');\n }\n\n /**\n * The subject of every commit `origin/<ref>` has that `HEAD` does not — the clobber signal. Empty =\n * safe to publish. Subjects rather than a count, because a commit this flow wrote itself (a recorded\n * conflict resolution, see DevResolveRunner) is re-derived by the next publish's check against dev and\n * is therefore safe to replace, while anything else on the copy is somebody's work.\n */\n async subjectsOnlyOnRemote(repoRoot: string, ref: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['log', '--format=%s', `HEAD..refs/remotes/origin/${ref}`], repoRoot,\n `Failed to compare HEAD against origin/${ref} (git log HEAD..origin/${ref}).`);\n return out.split('\\n').filter((l: string): boolean => l.trim() !== '');\n }\n\n private refusal(headline: string, body: string): string {\n return '\\n' + SEP + `⛔ ${headline}\\n` + SEP + '\\n' + body + `\\nRun \\`${WP_PUSH_DEV} --help\\` for the full command.\\n`;\n }\n}\n"]}
1
+ {"version":3,"file":"dev-deploy-refs.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-deploy-refs.ts"],"names":[],"mappings":";;;;AAAA,0DAAyF;AACzF,yCAA2D;AAC3D,8DAAwD;AAExD,yCAAqC;AAErC,MAAM,GAAG,GAAG,0DAA0D,CAAC;AACvE,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAa,OAAO;IAChB,iFAAiF;IACjF,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,uFAAuF;IACvF,YAAY,CAAS;IAErB,YAAY,GAAW,EAAE,GAAW,EAAE,YAAoB;QACtD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AAZD,0BAYC;AAED;;;;;;;;;;GAUG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAa;IACO;IAA7B,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAEjD,4GAA4G;IAC5G,MAAM,CAAC,QAAgB;Q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AI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3E,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,QAAgB,EAAE,IAAc;QAC9C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,eAAe,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;QAC3F,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,EAC1E,+CAA+C,CAAC,CAAC;IACzD,CAAC;IAEO,OAAO,CAAC,QAAgB,EAAE,IAAY;QAC1C,OAAO,IAAI,GAAG,GAAG,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,gEAAgE,CAAC;IACjI,CAAC;CACJ,CAAA;AApIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEC,kBAAO;GADpC,aAAa,CAoIzB","sourcesContent":["import { CliExitError, DevDeployConfig, loadAndValidate } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { gitCheckout } from '@webpieces/tooling-common';\n\nimport { GitExec } from './git-exec';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\nconst MAIN = 'main';\nconst DETACHED = 'HEAD';\n\n/**\n * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —\n * `--list` prints it, and should not be re-parsing `ls-remote` output.\n */\nexport class DevCopy {\n /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */\n ref: string;\n sha: string;\n /** The feature branch this is a copy OF — `ref` with the namespace prefix stripped. */\n sourceBranch: string;\n\n constructor(ref: string, sha: string, sourceBranch: string) {\n this.ref = ref;\n this.sha = sha;\n this.sourceBranch = sourceBranch;\n }\n}\n\n/**\n * Ref derivation and preconditions for the dev-deploy flow — the half that decides WHICH refs are in play,\n * kept out of the commands so `wp-start-push-dev`, `wp-build-push-dev` and `wp-finish-push-dev` answer those\n * questions identically.\n *\n * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire\n * another developer's commits — landing that PR would ship their unreviewed work to production. Every\n * write this flow performs therefore targets either the `<namespace>/<feature>` copy or a local throwaway\n * branch, and NOTHING here ever moves `<feature>` itself. That is why a conflict resolution needs the copy\n * to live in: it is the only place the resolution can be recorded without contaminating the PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevDeployRefs {\n constructor(private readonly gitExec: GitExec) {}\n\n /** The `pr-gate.devDeploy` block — `dev-include` / `dev` / `dev-remove` unless the consumer overrode it. */\n config(repoRoot: string): DevDeployConfig {\n return loadAndValidate(repoRoot).prGate.devDeploy;\n }\n\n /**\n * `commands.push-dev.buildCommand`, or `undefined` when the consumer has not configured it. There is\n * no default (#1397, `.claude/rules/no-rule-defaults.md`); DevBuild turns `undefined` into the refusal\n * that names the key.\n */\n devBuildCommand(repoRoot: string): string | undefined {\n return loadAndValidate(repoRoot).commands.pushDev.buildCommand;\n }\n\n /** The checked-out branch name, or `'HEAD'` on a detached HEAD (which {@link assertPushable} refuses). */\n currentBranch(repoRoot: string): string {\n return gitCheckout.requireBranch(repoRoot);\n }\n\n /**\n * Refuse every branch that must never be the SOURCE of a dev copy, before anything is fetched or\n * pushed.\n *\n * `main` and the composed dev branch are refused for the same reason from opposite ends: `main` is the\n * trunk (whatever is on it already deploys, so copying it is meaningless), and the dev branch is a\n * BUILD ARTIFACT that CI recomputes from `origin/main` on every run — copying it would publish a\n * composition of everyone's work under one developer's name, and it would be wiped on the next CI run\n * anyway. A branch already inside the namespace is refused because publishing a copy of a copy nests\n * the prefix (`dev-include/dev-include/…`) and nothing would ever clean it up.\n */\n assertPushable(cfg: DevDeployConfig, branch: string): void {\n if (branch === DETACHED || branch === '') {\n throw new CliExitError(2, this.refusal(\n 'Detached HEAD',\n 'There is no branch name to derive the dev copy from. Check out your feature branch first:\\n'\n + ' git checkout <your-feature-branch>\\n'));\n }\n if (branch === MAIN) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${MAIN}\\``,\n `\\`${MAIN}\\` is the trunk — whatever is on it already deploys, so a dev copy of it means nothing.\\n`\n + 'Check out the feature branch you actually want on the dev server and re-run.\\n'));\n }\n if (branch === cfg.devBranch) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${cfg.devBranch}\\``,\n `\\`${cfg.devBranch}\\` is a BUILD ARTIFACT, not a source branch: your CI resets it to origin/${MAIN},\\n`\n + `merges every \\`${cfg.copyRefGlob()}\\` ref into it, and force-pushes — every run. Copying it would\\n`\n + \"publish a composition of everybody's work under your branch's name, and the next CI run would\\n\"\n + 'wipe it. Check out your own feature branch and re-run.\\n'));\n }\n if (branch === cfg.branchNamespace || branch.startsWith(`${cfg.branchNamespace}/`)) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of a dev copy (\\`${branch}\\`)`,\n `\\`${cfg.branchNamespace}/\\` holds the disposable copies this command WRITES; you are standing on one.\\n`\n + `Publishing from here would nest the prefix (\\`${cfg.branchNamespace}/${branch}\\`) and nothing ever\\n`\n + 'cleans that up. Check out the real feature branch and re-run.\\n'));\n }\n }\n\n /**\n * Every live copy in the namespace, sorted by ref name — what `wp-finish-push-dev --list` prints.\n */\n async liveCopies(repoRoot: string, cfg: DevDeployConfig): Promise<DevCopy[]> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', cfg.copyRefGlob()], repoRoot,\n `Failed to list the dev copies (git ls-remote --heads origin '${cfg.copyRefGlob()}').`);\n const copies: DevCopy[] = [];\n for (const line of out.split('\\n')) {\n if (line.trim() === '') continue;\n const fields = line.split(/\\s+/);\n const sha = fields[0];\n const ref = fields[1];\n if (sha === undefined || ref === undefined || !ref.startsWith('refs/heads/')) continue;\n const shortRef = ref.slice('refs/heads/'.length);\n copies.push(new DevCopy(shortRef, sha, shortRef.slice(cfg.branchNamespace.length + 1)));\n }\n return copies.sort((a: DevCopy, b: DevCopy): number => (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0));\n }\n\n /**\n * The sha of a local ref (default HEAD).\n *\n * Read AFTER a push so the watch hints quote the sha that is provably published. Quoting the copy\n * REF instead would be a moving target — it advances the next time anybody publishes — and the whole\n * value of the \"did my code land in dev\" check is that it is a claim about one specific commit.\n */\n headSha(repoRoot: string, ref = 'HEAD'): Promise<string> {\n return this.gitExec.gitQuery(['-C', repoRoot, 'rev-parse', ref], repoRoot,\n `Failed to read the sha of ${ref} (git rev-parse).`);\n }\n\n /**\n * Fetch `origin/main` and return its sha — what the `--remove` marker points at (#1395).\n *\n * The marker carries no content, so any sha the remote already has would do; `main`'s tip is chosen\n * because it is guaranteed to exist on origin (the push sends no objects) and it is what the\n * consumer's workflow composes from anyway. Fetched rather than read from the local tracking ref, so a\n * clone that has not fetched in weeks does not point the marker at an arbitrarily old commit.\n */\n async freshMainTip(repoRoot: string): Promise<string> {\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', `+refs/heads/${MAIN}:refs/remotes/origin/${MAIN}`],\n `Failed to fetch origin/${MAIN}, which the --remove marker points at. Nothing was removed`);\n return this.headSha(repoRoot, `refs/remotes/origin/${MAIN}`);\n }\n\n /** The remote sha of one copy, or '' when that copy does not exist yet. */\n async remoteSha(repoRoot: string, ref: string): Promise<string> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', ref], repoRoot,\n `Failed to look up origin/${ref} (git ls-remote).`);\n const line = out.split('\\n').find((l: string): boolean => l.trim() !== '');\n if (line === undefined) return '';\n return line.split(/\\s+/)[0] ?? '';\n }\n\n /**\n * Fetch the named copy refs into `refs/remotes/origin/<ref>` so the local merges below run against\n * fresh state. A no-op for an empty list, and a hard failure otherwise: a resolve queued against\n * stale refs rehearses a composition CI will not build.\n */\n async fetchCopies(repoRoot: string, refs: string[]): Promise<void> {\n if (refs.length === 0) return;\n const specs = refs.map((r: string): string => `+refs/heads/${r}:refs/remotes/origin/${r}`);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', ...specs],\n 'Failed to fetch the dev copy refs from origin');\n }\n\n private refusal(headline: string, body: string): string {\n return '\\n' + SEP + `⛔ ${headline}\\n` + SEP + '\\n' + body + '\\nRun `pnpm wp-finish-push-dev --help` for the full command.\\n';\n }\n}\n"]}
@@ -1,121 +1,106 @@
1
1
  import { DevDeployConfig } from '@webpieces/rules-config';
2
+ import { NativeProcessApi } from '@webpieces/tooling-common';
2
3
  import { GitExec } from './git-exec';
3
4
  import { DevDeployRefs } from './dev-deploy-refs';
4
5
  import { PushDevState, PushDevStateStore } from './push-dev-state';
5
- import { DevDeployWatchHints } from './dev-deploy-watch-hints';
6
6
  import { DevBuild } from './dev-build';
7
+ import { VerifiedDevCopyStore } from './verified-dev-copy';
8
+ import { LandedCopyResolver } from './landed-copy-resolver';
7
9
  /**
8
10
  * The subject prefix of the ONE commit this flow writes onto a copy: the recorded conflict resolution.
9
- * The clobber guard reads it — a remote-only commit with this subject is re-derived by the next publish's
10
- * check against dev, so replacing it destroys nothing; any other remote-only commit is somebody's work.
11
11
  */
12
12
  export declare const RESOLUTION_SUBJECT = "Dev-deploy: conflict resolution for";
13
13
  /**
14
- * The queue-draining engine behind `wp-push-dev` (its pre-publish check against dev, #1397),
15
- * `wp-push-dev --resolve`, `--rebase-resolution`, and `wp-finish-push-dev`.
14
+ * The engine behind `wp-build-push-dev`'s check against dev (#1403): merge `origin/<devBranch>` into a
15
+ * THROWAWAY branch, take the publisher's side on conflicts caused only by copies already on main (#1405),
16
+ * stop on any other conflict, `pnpm install`, run the dev build (compile + tests, no code rules), and record
17
+ * the copy `wp-finish-push-dev` publishes.
16
18
  *
17
- * ONE class owns every git WRITE in the resolve flow, and that is a hard requirement rather than tidiness:
19
+ * ONE class owns every git WRITE of the check, and that is a hard requirement rather than tidiness:
18
20
  * `redirect-how-to-merge-main` blocks `git merge` in every form INCLUDING `--continue`, and
19
- * `pr-creation-or-push-guard` blocks every `git push`. So an AI cannot be told "now run `git commit`" or
21
+ * `merge-in-progress-guard` blocks `git commit`. So an AI cannot be told "now run `git commit`" or
20
22
  * "`git merge --continue`" — those instructions are unrunnable by the only party reading them. The command
21
- * owns the merges, the commit and the push (as child processes the hooks never see); the AI's entire job is
22
- * editing the conflicted files and `git add`-ing them, neither of which is blocked.
23
+ * owns the merge and the commits (as child processes the hooks never see); the AI's entire job is editing
24
+ * the conflicted files and `git add`-ing them, neither of which is blocked.
25
+ *
26
+ * It NEVER writes to the feature branch: every merge lands on a throwaway that is deleted at the end, so no
27
+ * other developer's commits can reach the PR head even if the check is abandoned halfway.
23
28
  */
24
29
  export declare class DevResolveRunner {
25
30
  private readonly gitExec;
26
31
  private readonly refs;
27
32
  private readonly store;
28
- private readonly watchHints;
33
+ private readonly verified;
29
34
  private readonly devBuild;
30
- constructor(gitExec: GitExec, refs: DevDeployRefs, store: PushDevStateStore, watchHints: DevDeployWatchHints, devBuild: DevBuild);
35
+ private readonly processes;
36
+ private readonly landedCopies;
37
+ constructor(gitExec: GitExec, refs: DevDeployRefs, store: PushDevStateStore, verified: VerifiedDevCopyStore, devBuild: DevBuild, processes: NativeProcessApi, landedCopies: LandedCopyResolver);
31
38
  /**
32
- * Start a resolve: park on a throwaway branch at the current copy, then drain the queue.
33
- *
34
- * The checkout is `-B <tmp> <base>` and NEVER the feature branch, which is the cardinal constraint made
35
- * mechanical — every merge below lands on a branch that is deleted at the end, so no other developer's
36
- * commits can reach the PR head even if the resolve is abandoned halfway.
37
- *
38
- * `base` differs between the callers and the difference IS the semantics. A plain publish starts at the
39
- * LOCAL HEAD and merges `origin/<devBranch>` in (does this copy merge and build against what is already
40
- * on dev?). `--resolve` starts at the published copy and merges the other copies in (compose what CI
41
- * will build). `--rebase-resolution` starts at the LOCAL HEAD and merges the published copy in (replay
42
- * an existing resolution on top of the new commits, instead of force-pushing over it). What is finally
43
- * PUBLISHED is the state's DevResolveMode's decision — see finalize.
44
- *
45
- * `fetchRefs` is passed separately from the queue because `--rebase-resolution` merges a ref that is
46
- * also its push destination, so "everything to fetch" and "everything to merge" are not the same list.
39
+ * Start the check: park on a throwaway branch at the feature head, merge `origin/<devBranch>` into it,
40
+ * and either halt on a conflict or go straight on to install, build and record.
47
41
  */
48
- start(repoRoot: string, state: PushDevState, base: string, fetchRefs: string[]): Promise<void>;
42
+ start(repoRoot: string, cfg: DevDeployConfig, state: PushDevState): Promise<void>;
49
43
  /**
50
- * Resume after the human/AI has resolved the halted merge: commit it, then keep draining.
51
- *
52
- * REFETCHES the remaining queue first. A resolution session can run long, and queuing against refs
53
- * fetched an hour ago rehearses a composition CI will not build — the one freshness gap the sibling
54
- * update flow is still known to have (only its stage ① ever fetches).
44
+ * The merge conflicted. First take the publisher's side on every file whose dev side comes ONLY from
45
+ * copies already on main (#1405, LandedCopyResolver); when that was every conflicted file, commit the
46
+ * merge and carry on. Otherwise halt on what is left — the developer's job, as before.
55
47
  */
56
- resume(repoRoot: string, state: PushDevState): Promise<void>;
48
+ private resolveLandedOrHalt;
57
49
  /**
58
- * Throw the whole resolve away: undo any halted merge, go back to the original branch, delete the
59
- * throwaway branch and the state file. Nothing published, nothing on the feature branch.
50
+ * The merge failed WITHOUT leaving a conflicted file (an untracked file in the way, a broken ref, …).
51
+ * There is nothing to resolve, so the checkout goes back to the feature branch and git's own words say why.
60
52
  */
61
- abort(repoRoot: string, state: PushDevState): Promise<void>;
53
+ private mergeFailed;
54
+ /** Resume after the conflicted files were resolved and `git add`-ed: commit the merge, then finish. */
55
+ resume(repoRoot: string, state: PushDevState): Promise<void>;
62
56
  /**
63
- * Merge queued refs until one conflicts (HALT, hand the tree over) or the queue empties (PUBLISH).
64
- *
65
- * A LATER ref can conflict too, which is why this is a loop resumed from a state file rather than a
66
- * single pass: `wp-finish-push-dev` can legitimately stop again on the next ref in the queue.
57
+ * Throw the whole check away: undo any halted merge, go back to the original branch, delete the
58
+ * throwaway branch and the state file. Nothing verified, nothing on the feature branch.
67
59
  */
68
- private drain;
60
+ abort(repoRoot: string, state: PushDevState): Promise<void>;
69
61
  /** Stop with the conflicted files listed and the ONE command that continues. Exit 2 = "your turn". */
70
62
  private halt;
71
63
  /**
72
- * Queue empty. What happens next is the mode's (see DevResolveMode):
64
+ * The merge is complete. Install and build the MERGED tree, then turn the throwaway into the copy and
65
+ * record it for `wp-finish-push-dev`.
73
66
  *
74
- * - PREBUILD runs the dev build on the MERGED tree first, so a red build stops before anything is
75
- * published.
76
- * - PREBUILD and COMPOSE then publish the BASE plus the recorded resolution — never the merge. REPLAY
77
- * publishes the merge, as it always has.
67
+ * `pnpm install` runs AFTER the merge, never before: other copies already on dev can add workspace
68
+ * packages main does not have yet, so the feature branch's `node_modules` does not link the merged
69
+ * tree (#1403 — a 30-commits-behind branch failed six minutes into its build on exactly that).
78
70
  */
79
- private finalize;
71
+ private finish;
72
+ private install;
80
73
  /**
81
- * Run the dev build on the merged throwaway. On a red build, put the checkout back first — the fix
82
- * belongs on the feature branch, and a developer left parked on a throwaway would make the next
83
- * `wp-*` command act on the wrong branch — then let the build's own failure (with its `FullLog :`
84
- * pointer) reach the top-level handler unchanged.
74
+ * Run one step on the throwaway. On a failure, put the checkout back first — the fix belongs on the
75
+ * feature branch, and a developer left parked on a throwaway would make the next `wp-*` command act on
76
+ * the wrong branch — then let the step's own failure (a build's carries its `FullLog :` pointer) reach
77
+ * the top-level handler unchanged.
85
78
  */
86
- private buildOrRestore;
79
+ private onThrowaway;
87
80
  /**
88
- * Turn the throwaway into what gets PUBLISHED: the base sha plus, when anything conflicted, ONE commit
89
- * that sets each resolved file to its resolved content.
81
+ * Turn the throwaway into the copy: the base sha plus, when anything conflicted, ONE commit that sets
82
+ * each resolved file to its resolved content.
90
83
  *
91
- * This is issue #1397's option (a): the merge is used for the conflict check and the build only, and
92
- * is never published. Publishing it would make every other copy an ancestor of this one, so a later
93
- * `--remove` of that copy would leave its commits on dev through ours. The resolution commit has
94
- * exactly one parent, the base, so the only thing it can carry of anybody else's work is the text of
95
- * the hunks that were resolved — content, never history.
84
+ * The merge is used for the conflict check and the build only, and is never published. Publishing it
85
+ * would make every other copy an ancestor of this one, so a later `--remove` of that copy would leave
86
+ * its commits on dev through ours. The resolution commit has exactly one parent, the base, so the only
87
+ * thing it can carry of anybody else's work is the text of the hunks that were resolved — content,
88
+ * never history.
96
89
  */
97
90
  private recordResolution;
98
- /** Back to the original branch; the throwaway and the state file are gone. */
91
+ /** Back to the original branch; any halted merge, the throwaway and the state file are gone. */
99
92
  private restore;
100
- /**
101
- * PREBUILD leases against the sha the clobber guard inspected (plain `--force` only when asked); the
102
- * other two modes overwrite the copy they themselves started from, as they always have.
103
- */
104
- private pushSafety;
105
- private buildStep;
106
- private publishedBanner;
93
+ private verifiedBanner;
107
94
  /** Conflicted (unmerged-in-index) paths. Empty once every one has been resolved and `git add`ed. */
108
95
  private unmergedPaths;
109
96
  private assertNoUnmergedPaths;
110
97
  /**
111
- * The name of the throwaway branch for a resolve of `branch`.
98
+ * The name of the throwaway branch for a check of `branch`.
112
99
  *
113
100
  * Suffixed rather than prefixed, matching the existing `<feature>Squash` / `<feature>PreMerge<n>`
114
101
  * convention — and deliberately NOT inside the dev namespace, which holds REMOTE copies only.
115
102
  */
116
103
  tmpBranchFor(branch: string): string;
117
- /** The banner `--resolve` prints before the first merge, so the queue is visible before it halts. */
104
+ /** The banner `wp-build-push-dev` prints before its check against dev. */
118
105
  announce(cfg: DevDeployConfig, state: PushDevState): string;
119
- /** The banner plain `wp-push-dev` prints before its check against dev (#1397). */
120
- announcePrebuild(cfg: DevDeployConfig, state: PushDevState): string;
121
106
  }