@hominis/fireforge 0.50.0 → 0.52.0

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 (212) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/build-info.json +4 -4
  3. package/dist/src/commands/check-report.d.ts +17 -4
  4. package/dist/src/commands/check-report.js +19 -6
  5. package/dist/src/commands/check-run.d.ts +5 -0
  6. package/dist/src/commands/check-run.js +9 -1
  7. package/dist/src/commands/check-steps.d.ts +8 -0
  8. package/dist/src/commands/check-steps.js +31 -6
  9. package/dist/src/commands/check.js +1 -1
  10. package/dist/src/commands/declarations-report.d.ts +43 -0
  11. package/dist/src/commands/declarations-report.js +76 -0
  12. package/dist/src/commands/export-placement-gate.js +8 -0
  13. package/dist/src/commands/furnace/rename-registrations.js +7 -2
  14. package/dist/src/commands/furnace/validate.js +26 -1
  15. package/dist/src/commands/lint-per-patch.js +6 -2
  16. package/dist/src/commands/lint-per-run-checkjs.js +2 -2
  17. package/dist/src/commands/lint-report.js +7 -2
  18. package/dist/src/commands/manifest.js +2 -0
  19. package/dist/src/commands/park.d.ts +22 -0
  20. package/dist/src/commands/park.js +232 -0
  21. package/dist/src/commands/patch/delete.js +11 -6
  22. package/dist/src/commands/patch/index.d.ts +3 -3
  23. package/dist/src/commands/patch/index.js +8 -4
  24. package/dist/src/commands/patch/lint-ignore-from.d.ts +44 -0
  25. package/dist/src/commands/patch/lint-ignore-from.js +142 -0
  26. package/dist/src/commands/patch/lint-ignore.js +39 -29
  27. package/dist/src/commands/patch/move-files-create.js +11 -4
  28. package/dist/src/commands/patch/move-files-into.js +10 -4
  29. package/dist/src/commands/patch/move-files.js +3 -1
  30. package/dist/src/commands/patch/removal-created-files.d.ts +48 -0
  31. package/dist/src/commands/patch/removal-created-files.js +83 -0
  32. package/dist/src/commands/patch/rename.js +15 -3
  33. package/dist/src/commands/patch/reserve.d.ts +33 -0
  34. package/dist/src/commands/patch/reserve.js +152 -0
  35. package/dist/src/commands/patch/retire.js +11 -6
  36. package/dist/src/commands/patch/split-plan.d.ts +10 -1
  37. package/dist/src/commands/patch/split-plan.js +16 -1
  38. package/dist/src/commands/patch/split.js +14 -5
  39. package/dist/src/commands/patch/stage.d.ts +34 -0
  40. package/dist/src/commands/patch/stage.js +153 -0
  41. package/dist/src/commands/patch/staged-dependency-remove.d.ts +31 -0
  42. package/dist/src/commands/patch/staged-dependency-remove.js +80 -0
  43. package/dist/src/commands/patch/staged-dependency.js +40 -98
  44. package/dist/src/commands/re-export-adjacent.d.ts +5 -0
  45. package/dist/src/commands/re-export-adjacent.js +4 -3
  46. package/dist/src/commands/re-export-bulk-scan.d.ts +2 -1
  47. package/dist/src/commands/re-export-bulk-scan.js +22 -7
  48. package/dist/src/commands/re-export-hunks.d.ts +35 -0
  49. package/dist/src/commands/re-export-hunks.js +220 -0
  50. package/dist/src/commands/re-export-options.js +29 -2
  51. package/dist/src/commands/re-export-purity-scope.d.ts +18 -0
  52. package/dist/src/commands/re-export-purity-scope.js +131 -0
  53. package/dist/src/commands/re-export-register.js +15 -1
  54. package/dist/src/commands/re-export-removed.d.ts +1 -1
  55. package/dist/src/commands/re-export-removed.js +17 -2
  56. package/dist/src/commands/re-export-scan.d.ts +2 -0
  57. package/dist/src/commands/re-export-scan.js +4 -1
  58. package/dist/src/commands/re-export-single.js +102 -42
  59. package/dist/src/commands/re-export-stale-registrations.d.ts +18 -0
  60. package/dist/src/commands/re-export-stale-registrations.js +62 -0
  61. package/dist/src/commands/re-export.js +35 -34
  62. package/dist/src/commands/status-output.js +5 -1
  63. package/dist/src/commands/test-build-furnace.d.ts +3 -2
  64. package/dist/src/commands/test-build-furnace.js +8 -2
  65. package/dist/src/commands/test-build-phase.d.ts +2 -0
  66. package/dist/src/commands/test-build-phase.js +34 -17
  67. package/dist/src/commands/test-checkjs.js +3 -2
  68. package/dist/src/commands/test-dispatch.d.ts +39 -0
  69. package/dist/src/commands/test-dispatch.js +220 -0
  70. package/dist/src/commands/test-furnace-reach.d.ts +37 -0
  71. package/dist/src/commands/test-furnace-reach.js +132 -0
  72. package/dist/src/commands/test-orchestrate.d.ts +14 -0
  73. package/dist/src/commands/test-orchestrate.js +25 -4
  74. package/dist/src/commands/test-perf-scope.d.ts +21 -0
  75. package/dist/src/commands/test-perf-scope.js +55 -0
  76. package/dist/src/commands/test-prelock.js +100 -4
  77. package/dist/src/commands/test-register.js +18 -3
  78. package/dist/src/commands/test-results.d.ts +62 -0
  79. package/dist/src/commands/test-results.js +62 -0
  80. package/dist/src/commands/test-run.d.ts +13 -55
  81. package/dist/src/commands/test-run.js +73 -101
  82. package/dist/src/commands/test-shards.d.ts +110 -0
  83. package/dist/src/commands/test-shards.js +255 -0
  84. package/dist/src/commands/test-stale-gate.d.ts +5 -1
  85. package/dist/src/commands/test-stale-gate.js +11 -2
  86. package/dist/src/commands/test-verdict.d.ts +2 -1
  87. package/dist/src/commands/test.d.ts +1 -1
  88. package/dist/src/commands/test.js +68 -75
  89. package/dist/src/commands/token-lint.js +48 -8
  90. package/dist/src/commands/verify.js +9 -2
  91. package/dist/src/core/build-baseline-types.d.ts +13 -0
  92. package/dist/src/core/build-baseline-validate.js +9 -0
  93. package/dist/src/core/build-baseline.js +7 -0
  94. package/dist/src/core/build-prepare.d.ts +6 -0
  95. package/dist/src/core/build-prepare.js +29 -3
  96. package/dist/src/core/config-paths.d.ts +1 -1
  97. package/dist/src/core/config-paths.js +2 -0
  98. package/dist/src/core/config-validate-check.js +83 -7
  99. package/dist/src/core/config-validate-test-toolchains.js +14 -0
  100. package/dist/src/core/config-validate-token-scales.d.ts +3 -0
  101. package/dist/src/core/config-validate-token-scales.js +47 -5
  102. package/dist/src/core/config-validate.js +6 -0
  103. package/dist/src/core/coverage-extend.js +2 -2
  104. package/dist/src/core/coverage-records.d.ts +11 -0
  105. package/dist/src/core/coverage-records.js +34 -0
  106. package/dist/src/core/engine-session-lock.d.ts +6 -0
  107. package/dist/src/core/engine-session-lock.js +10 -2
  108. package/dist/src/core/file-lock-shared.d.ts +57 -0
  109. package/dist/src/core/file-lock-shared.js +117 -0
  110. package/dist/src/core/file-lock.d.ts +9 -0
  111. package/dist/src/core/file-lock.js +58 -2
  112. package/dist/src/core/furnace-apply.js +10 -10
  113. package/dist/src/core/furnace-config-validate-exceptions.d.ts +11 -3
  114. package/dist/src/core/furnace-config-validate-exceptions.js +59 -8
  115. package/dist/src/core/furnace-config-validate.js +7 -1
  116. package/dist/src/core/furnace-registration-jar-inplace.d.ts +12 -0
  117. package/dist/src/core/furnace-registration-jar-inplace.js +80 -0
  118. package/dist/src/core/furnace-validate-accessibility.d.ts +5 -3
  119. package/dist/src/core/furnace-validate-accessibility.js +75 -30
  120. package/dist/src/core/furnace-validate-exceptions.d.ts +13 -4
  121. package/dist/src/core/furnace-validate-exceptions.js +59 -4
  122. package/dist/src/core/furnace-validate-icon-button.js +30 -1
  123. package/dist/src/core/history-log-file.js +8 -1
  124. package/dist/src/core/line-prefixer.d.ts +18 -0
  125. package/dist/src/core/line-prefixer.js +34 -0
  126. package/dist/src/core/mach.d.ts +7 -0
  127. package/dist/src/core/mach.js +24 -9
  128. package/dist/src/core/module-resolution-preflight.d.ts +19 -3
  129. package/dist/src/core/module-resolution-preflight.js +24 -6
  130. package/dist/src/core/negative-control-compiled.d.ts +36 -0
  131. package/dist/src/core/negative-control-compiled.js +87 -0
  132. package/dist/src/core/negative-control-diff.d.ts +14 -2
  133. package/dist/src/core/negative-control-diff.js +49 -6
  134. package/dist/src/core/negative-control.d.ts +12 -0
  135. package/dist/src/core/negative-control.js +48 -5
  136. package/dist/src/core/park-store.d.ts +63 -0
  137. package/dist/src/core/park-store.js +216 -0
  138. package/dist/src/core/patch-export-update.d.ts +4 -0
  139. package/dist/src/core/patch-export-update.js +12 -3
  140. package/dist/src/core/patch-export.d.ts +3 -2
  141. package/dist/src/core/patch-export.js +21 -14
  142. package/dist/src/core/patch-files.js +26 -8
  143. package/dist/src/core/patch-lint-checkjs-any-import.d.ts +6 -4
  144. package/dist/src/core/patch-lint-checkjs-any-import.js +9 -7
  145. package/dist/src/core/patch-lint-checkjs-diagnostics.d.ts +17 -0
  146. package/dist/src/core/patch-lint-checkjs-diagnostics.js +32 -0
  147. package/dist/src/core/patch-lint-checkjs.d.ts +10 -1
  148. package/dist/src/core/patch-lint-checkjs.js +13 -3
  149. package/dist/src/core/patch-lint-cross.d.ts +3 -1
  150. package/dist/src/core/patch-lint-cross.js +5 -0
  151. package/dist/src/core/patch-lint-css.js +14 -10
  152. package/dist/src/core/patch-lint-forward-registration-extended.d.ts +5 -0
  153. package/dist/src/core/patch-lint-forward-registration-extended.js +1 -1
  154. package/dist/src/core/patch-lint-ignore.d.ts +56 -12
  155. package/dist/src/core/patch-lint-ignore.js +173 -43
  156. package/dist/src/core/patch-lint-ownership.d.ts +10 -0
  157. package/dist/src/core/patch-lint-ownership.js +26 -0
  158. package/dist/src/core/patch-lint-size.js +9 -1
  159. package/dist/src/core/patch-lint-token-scale.d.ts +26 -8
  160. package/dist/src/core/patch-lint-token-scale.js +206 -29
  161. package/dist/src/core/patch-lint.js +2 -2
  162. package/dist/src/core/patch-manifest-io.js +8 -1
  163. package/dist/src/core/patch-manifest-key-order.d.ts +24 -0
  164. package/dist/src/core/patch-manifest-key-order.js +61 -0
  165. package/dist/src/core/patch-manifest-stage.d.ts +46 -0
  166. package/dist/src/core/patch-manifest-stage.js +96 -0
  167. package/dist/src/core/patch-manifest-validate.js +27 -1
  168. package/dist/src/core/patch-order-legal.d.ts +2 -1
  169. package/dist/src/core/patch-order-legal.js +7 -2
  170. package/dist/src/core/patch-policy.d.ts +6 -2
  171. package/dist/src/core/patch-policy.js +14 -7
  172. package/dist/src/core/patch-retired.d.ts +26 -4
  173. package/dist/src/core/patch-retired.js +40 -2
  174. package/dist/src/core/run-log.d.ts +6 -0
  175. package/dist/src/core/run-log.js +17 -1
  176. package/dist/src/core/test-harness-crash.d.ts +2 -1
  177. package/dist/src/core/test-harness-crash.js +5 -8
  178. package/dist/src/core/test-harness-signature.d.ts +16 -0
  179. package/dist/src/core/test-harness-signature.js +19 -1
  180. package/dist/src/core/test-raw-log.d.ts +66 -0
  181. package/dist/src/core/test-raw-log.js +122 -0
  182. package/dist/src/core/test-run-completeness.d.ts +47 -7
  183. package/dist/src/core/test-run-completeness.js +70 -23
  184. package/dist/src/core/test-stale-check.d.ts +10 -1
  185. package/dist/src/core/test-stale-check.js +15 -1
  186. package/dist/src/core/test-xpcshell-retry.d.ts +2 -0
  187. package/dist/src/core/test-xpcshell-retry.js +2 -1
  188. package/dist/src/core/token-lint.d.ts +5 -2
  189. package/dist/src/core/token-lint.js +8 -3
  190. package/dist/src/core/token-sibling-sheets.d.ts +46 -0
  191. package/dist/src/core/token-sibling-sheets.js +119 -0
  192. package/dist/src/core/tree-guard.js +2 -0
  193. package/dist/src/core/typecheck-shim.d.ts +6 -1
  194. package/dist/src/core/typecheck-shim.js +139 -2
  195. package/dist/src/core/typecheck.js +3 -1
  196. package/dist/src/index.d.ts +9 -3
  197. package/dist/src/index.js +4 -1
  198. package/dist/src/types/commands/index.d.ts +2 -2
  199. package/dist/src/types/commands/options.d.ts +68 -7
  200. package/dist/src/types/commands/patches.d.ts +43 -0
  201. package/dist/src/types/config.d.ts +74 -2
  202. package/dist/src/types/furnace.d.ts +29 -0
  203. package/dist/src/types/index.d.ts +1 -1
  204. package/dist/src/utils/options.d.ts +3 -2
  205. package/dist/src/utils/options.js +9 -4
  206. package/docs/configuration.md +110 -9
  207. package/docs/furnace.md +61 -1
  208. package/docs/lifecycle-invariants.md +13 -11
  209. package/docs/machine-output.md +68 -18
  210. package/docs/patch-workflow.md +174 -13
  211. package/docs/testing.md +89 -5
  212. package/package.json +3 -3
@@ -19,7 +19,7 @@ import { applyReExportFilesPositionalFolding, validateReExportOptionCombinations
19
19
  import { validateExpectedRemovals } from './re-export-removed.js';
20
20
  import { normalizeEngineRelativeInput, normalizeScanFiles } from './re-export-scan.js';
21
21
  import { assignScanFileOwners, scanOptionsForPatch } from './re-export-scan-owner.js';
22
- import { reExportSinglePatchWithIndexLockRetry } from './re-export-single.js';
22
+ import { reExportSinglePatchWithIndexLockRetry, } from './re-export-single.js';
23
23
  import { formatReExportRunSummary } from './re-export-summary.js';
24
24
  async function resolveSelectedPatches(patches, options, manifest) {
25
25
  if (options.all) {
@@ -59,6 +59,27 @@ async function resolveSelectedPatches(patches, options, manifest) {
59
59
  const selectedFilenames = selected;
60
60
  return manifest.patches.filter((p) => selectedFilenames.includes(p.filename));
61
61
  }
62
+ /** Refreshes each selected patch in turn, collecting which wrote and which failed. */
63
+ async function reExportEach(args) {
64
+ const { selectedPatches, options, scanAssignments, progress, startedAt, shared } = args;
65
+ const written = [];
66
+ const failed = [];
67
+ for (const [index, patch] of selectedPatches.entries()) {
68
+ const patchOptions = scanOptionsForPatch(options, patch.filename, scanAssignments);
69
+ progress.message(`Re-exporting ${index + 1}/${selectedPatches.length}: ${patch.filename} (${patch.filesAffected.length} file(s), ${elapsedSince(startedAt)} elapsed)...`);
70
+ try {
71
+ if (await reExportSinglePatchWithIndexLockRetry({ ...shared, patch, options: patchOptions })) {
72
+ written.push(patch.filename);
73
+ }
74
+ }
75
+ catch (error) {
76
+ failed.push(patch.filename);
77
+ warn(`Failed to re-export ${patch.filename}`);
78
+ warn(toError(error).message);
79
+ }
80
+ }
81
+ return { written, failed };
82
+ }
62
83
  /**
63
84
  * Runs the re-export command to regenerate existing patches from current engine state.
64
85
  * @param projectRoot - Root directory of the project
@@ -105,7 +126,7 @@ export async function reExportCommand(projectRoot, patches, options) {
105
126
  outro('Nothing to re-export');
106
127
  return;
107
128
  }
108
- const expectedRemovals = await validateExpectedRemovals(paths, selectedPatches, options);
129
+ const expectedRemovals = await validateExpectedRemovals(paths, selectedPatches, options, manifest.patches);
109
130
  if (expectedRemovals.length > 0)
110
131
  options = { ...options, expectRemoved: expectedRemovals };
111
132
  if (scanFilesByPatch !== undefined) {
@@ -125,7 +146,7 @@ export async function reExportCommand(projectRoot, patches, options) {
125
146
  // we write anything.
126
147
  if (options.files !== undefined) {
127
148
  const filesConfig = await loadConfig(projectRoot);
128
- await withDryRunReExportLock(paths.fireforgeDir, isDryRun, () => withDryRunPurityGuard(paths.engine, paths.patches, isDryRun, () => reExportFilesInPlace(paths, selectedPatches, options, filesConfig)));
149
+ await withDryRunReExportLock(paths.fireforgeDir, isDryRun, () => withDryRunPurityGuard(paths.engine, paths.patches, isDryRun, () => reExportFilesInPlace(paths, selectedPatches, options, filesConfig), { patches: selectedPatches }));
129
150
  return;
130
151
  }
131
152
  const config = await loadConfig(projectRoot);
@@ -139,38 +160,18 @@ export async function reExportCommand(projectRoot, patches, options) {
139
160
  // reports includes it.
140
161
  const startedAt = Date.now();
141
162
  const lintCtx = await buildReExportLintContext(projectRoot, paths, config, options.noCache === true, new Set(selectedPatches.map((patch) => patch.filename)));
142
- let reExported = 0;
143
- const reExportedFilenames = [];
144
- const failedFilenames = [];
145
163
  const progress = spinner('Preparing re-export...');
146
- await withDryRunReExportLock(paths.fireforgeDir, isDryRun, async () => withDryRunPurityGuard(paths.engine, paths.patches, isDryRun, async () => {
147
- for (const [index, patch] of selectedPatches.entries()) {
148
- const patchOptions = scanOptionsForPatch(options, patch.filename, scanAssignments);
149
- progress.message(`Re-exporting ${index + 1}/${selectedPatches.length}: ${patch.filename} (${patch.filesAffected.length} file(s), ${elapsedSince(startedAt)} elapsed)...`);
150
- try {
151
- const exported = await reExportSinglePatchWithIndexLockRetry({
152
- patch,
153
- paths,
154
- manifest,
155
- options: patchOptions,
156
- isDryRun,
157
- config,
158
- adjacentCtx,
159
- driftCtx,
160
- lintCtx,
161
- });
162
- if (exported) {
163
- reExported++;
164
- reExportedFilenames.push(patch.filename);
165
- }
166
- }
167
- catch (error) {
168
- failedFilenames.push(patch.filename);
169
- warn(`Failed to re-export ${patch.filename}`);
170
- warn(toError(error).message);
171
- }
172
- }
173
- }));
164
+ const outcome = await withDryRunReExportLock(paths.fireforgeDir, isDryRun, () => withDryRunPurityGuard(paths.engine, paths.patches, isDryRun, () => reExportEach({
165
+ selectedPatches,
166
+ options,
167
+ scanAssignments,
168
+ progress,
169
+ startedAt,
170
+ shared: { paths, manifest, isDryRun, config, adjacentCtx, driftCtx, lintCtx },
171
+ }), { patches: selectedPatches }));
172
+ const reExportedFilenames = outcome.written;
173
+ const failedFilenames = outcome.failed;
174
+ const reExported = reExportedFilenames.length;
174
175
  await finishReExportLint(lintCtx);
175
176
  warnUnseenExpectedDrift(driftCtx);
176
177
  warnUnseenApprovedUnmanaged(adjacentCtx);
@@ -206,7 +206,11 @@ export function renderTestCoverageStatus(baseline) {
206
206
  }
207
207
  info(`Last build: ${baseline.builtAt} (binary: ${baseline.binaryName}, ` +
208
208
  `engine HEAD: ${baseline.engineHeadSha || '(unborn)'})`);
209
- info(`Recorded by: ${baseline.recordedBy ?? 'unknown'}`);
209
+ const recorder = baseline.recorder;
210
+ info(`Recorded by: ${baseline.recordedBy ?? 'unknown'}` +
211
+ (recorder === undefined
212
+ ? ''
213
+ : ` (pid ${recorder.pid}${recorder.sessionId !== undefined ? `, session ${recorder.sessionId}` : ''})`));
210
214
  const coverage = baseline.testPackagingCoverage;
211
215
  if (coverage === undefined) {
212
216
  info('Test packaging coverage: full (implicit — baseline predates coverage recording)');
@@ -16,6 +16,7 @@ import type { BuildPreparation } from '../core/build-prepare.js';
16
16
  *
17
17
  * @param projectRoot - Root directory of the project
18
18
  * @param preparation - Result of `prepareBuildEnvironment`
19
- * @param skipped - True under `--no-furnace-apply`
19
+ * @param skipped - True under `--no-furnace-apply` / `--furnace-apply none`
20
+ * @param unreached - Components `--furnace-apply reached` left out
20
21
  */
21
- export declare function reportPreTestFurnace(projectRoot: string, preparation: BuildPreparation, skipped: boolean): Promise<void>;
22
+ export declare function reportPreTestFurnace(projectRoot: string, preparation: BuildPreparation, skipped: boolean, unreached?: readonly string[]): Promise<void>;
@@ -20,9 +20,10 @@ import { setVerdictRunAttribute } from './test-verdict.js';
20
20
  *
21
21
  * @param projectRoot - Root directory of the project
22
22
  * @param preparation - Result of `prepareBuildEnvironment`
23
- * @param skipped - True under `--no-furnace-apply`
23
+ * @param skipped - True under `--no-furnace-apply` / `--furnace-apply none`
24
+ * @param unreached - Components `--furnace-apply reached` left out
24
25
  */
25
- export async function reportPreTestFurnace(projectRoot, preparation, skipped) {
26
+ export async function reportPreTestFurnace(projectRoot, preparation, skipped, unreached) {
26
27
  if (skipped) {
27
28
  setVerdictRunAttribute('furnace-apply', 'skipped');
28
29
  let pending = [];
@@ -37,6 +38,11 @@ export async function reportPreTestFurnace(projectRoot, preparation, skipped) {
37
38
  : 'Furnace apply skipped (--no-furnace-apply): engine/ is packaged as it stands.');
38
39
  return;
39
40
  }
41
+ if (unreached !== undefined && unreached.length > 0) {
42
+ setVerdictRunAttribute('furnace-skipped', unreached.join(','));
43
+ notice(`--furnace-apply reached: ${unreached.length} component(s) with undeployed components/ ` +
44
+ `edits that no requested test reaches are NOT in this build: ${unreached.join(', ')}.`);
45
+ }
40
46
  const applied = preparation.furnaceAppliedNames ?? [];
41
47
  if (applied.length === 0)
42
48
  return;
@@ -16,4 +16,6 @@ import type { HarnessClassification } from './test-modes.js';
16
16
  export declare function runTestBuildPhase(projectRoot: string, paths: ProjectPaths, projectConfig: FireForgeConfig, harnessRetries: number, options: TestOptions, request: {
17
17
  classification: HarnessClassification;
18
18
  normalizedPaths: string[];
19
+ /** Forces a full pre-test build (a compiled negative control). */
20
+ fullBuildReason?: string;
19
21
  }): Promise<boolean>;
@@ -16,6 +16,7 @@ import { BuildError } from '../errors/build.js';
16
16
  import { toError } from '../utils/errors.js';
17
17
  import { info, notice, spinner, verbose } from '../utils/logger.js';
18
18
  import { reportPreTestFurnace } from './test-build-furnace.js';
19
+ import { partitionReachedComponents, resolveFurnaceApplyMode } from './test-furnace-reach.js';
19
20
  import { reportBuildOnlyCompletion } from './test-modes.js';
20
21
  import { enforceStaleBuildGate, enforceStaticComponentsGate } from './test-stale-gate.js';
21
22
  import { emitPassVerdict } from './test-verdict.js';
@@ -26,7 +27,7 @@ import { emitPassVerdict } from './test-verdict.js';
26
27
  * @param options - See {@link RunPreTestBuildOptions}
27
28
  */
28
29
  async function runPreTestBuild(options) {
29
- const { projectRoot, paths, projectConfig, harnessRetries, testPackagingCoverage, refuseUnexportedDrift, extend, skipFurnaceApply, } = options;
30
+ const { projectRoot, paths, projectConfig, harnessRetries, testPackagingCoverage, refuseUnexportedDrift, extend, furnace, fullBuildReason, } = options;
30
31
  await withBuildLock(projectRoot, async () => {
31
32
  // Pass the previous baseline exactly like `fireforge build` does, so
32
33
  // auto-configure runs under the same conditions on both paths. The
@@ -46,9 +47,10 @@ async function runPreTestBuild(options) {
46
47
  const preparation = await prepareBuildEnvironment(projectRoot, paths, projectConfig, {
47
48
  previousBaseline,
48
49
  refuseUnexportedDrift,
49
- skipFurnaceApply,
50
+ skipFurnaceApply: furnace.skip,
51
+ furnaceComponents: furnace.only,
50
52
  });
51
- await reportPreTestFurnace(projectRoot, preparation, skipFurnaceApply);
53
+ await reportPreTestFurnace(projectRoot, preparation, furnace.skip, furnace.unreached);
52
54
  // Which earlier claims this scoped build keeps, per staged path. The
53
55
  // mozconfig half can only be checked once prepareBuildEnvironment has
54
56
  // regenerated engine/mozconfig (the file this build will configure
@@ -64,17 +66,16 @@ async function runPreTestBuild(options) {
64
66
  if (retentionNotice !== undefined)
65
67
  notice(retentionNotice);
66
68
  }
67
- const buildKind = preparation.fullBuildRequired ? 'full' : 'faster';
68
- if (preparation.fullBuildRequired) {
69
+ const fullBuild = preparation.fullBuildRequired || fullBuildReason !== undefined;
70
+ const buildKind = fullBuild ? 'full' : 'faster';
71
+ if (fullBuild) {
69
72
  // Warning severity rather than info: agent-facing output filters
70
73
  // keep warnings and errors only, and this is the line that explains an
71
74
  // otherwise unexplained multi-minute build.
72
- notice(preparation.fullBuildReason ??
75
+ notice((preparation.fullBuildRequired ? preparation.fullBuildReason : fullBuildReason) ??
73
76
  'A jar.mn registration changed since the last successful build; escalating this pre-test build to a full mach build so new install-manifest destinations are created.');
74
77
  }
75
- const s = spinner(preparation.fullBuildRequired
76
- ? 'Running required full build...'
77
- : 'Running incremental build...');
78
+ const s = spinner(fullBuild ? 'Running required full build...' : 'Running incremental build...');
78
79
  // The pre-test build routes through the same protected mach dispatch as
79
80
  // `fireforge build` / `build --ui`: in-venv resource-monitor guard plus
80
81
  // the uniform recognized-crash retry budget, with a fresh mach process
@@ -114,7 +115,7 @@ async function runPreTestBuild(options) {
114
115
  ...recorded,
115
116
  previousBaseline,
116
117
  recordedBy: describeBuildInvocation(extend !== undefined, testPackagingCoverage),
117
- staticComponentsHandling: preparation.fullBuildRequired
118
+ staticComponentsHandling: fullBuild
118
119
  ? 'refresh'
119
120
  : plan !== undefined && (plan.keepFull || Object.keys(plan.retained).length > 0)
120
121
  ? 'carry-forward'
@@ -129,8 +130,8 @@ async function runPreTestBuild(options) {
129
130
  }
130
131
  s.error('Pre-test build failed');
131
132
  throw new BuildError(result.crashSignature
132
- ? buildHarnessCrashMessage(result.crashSignature, result.attempts, 'mach build faster')
133
- : 'Pre-test build failed', preparation.fullBuildRequired ? 'mach build' : 'mach build faster');
133
+ ? buildHarnessCrashMessage(result.crashSignature, result.attempts, fullBuild ? 'mach build' : 'mach build faster')
134
+ : 'Pre-test build failed', fullBuild ? 'mach build' : 'mach build faster');
134
135
  });
135
136
  }
136
137
  /**
@@ -161,13 +162,28 @@ function assertRefuseUnexportedDriftUsage(options) {
161
162
  return;
162
163
  throw new InvalidArgumentError('--refuse-unexported-drift requires --build or --build-only: it guards the pre-test build, and this run dispatches none.', '--refuse-unexported-drift');
163
164
  }
164
- /** Refuses `--no-furnace-apply` on a run that dispatches no build, for the same reason. */
165
+ /** Refuses `--no-furnace-apply`/`--furnace-apply` on a run that dispatches no build, for the same reason. */
165
166
  function assertNoFurnaceApplyUsage(options) {
166
- if (options.furnaceApply !== false)
167
+ if (options.furnaceApply === undefined || options.furnaceApply === true)
167
168
  return;
168
169
  if (options.build === true || options.buildOnly === true)
169
170
  return;
170
- throw new InvalidArgumentError("--no-furnace-apply requires --build or --build-only: it skips the pre-test build's Furnace apply, and this run dispatches no build.", '--no-furnace-apply');
171
+ const flag = options.furnaceApply === false ? '--no-furnace-apply' : '--furnace-apply';
172
+ throw new InvalidArgumentError(`${flag} requires --build or --build-only: it shapes the pre-test build's Furnace apply, and this run dispatches no build.`, flag);
173
+ }
174
+ /**
175
+ * The Furnace part of a pre-test build: skip the apply, apply everything,
176
+ * or apply only the components the request reaches (and name the rest).
177
+ */
178
+ async function planPreTestFurnace(projectRoot, paths, projectConfig, options, normalizedPaths) {
179
+ const mode = resolveFurnaceApplyMode(options, projectConfig);
180
+ if (mode === 'none')
181
+ return { skip: true };
182
+ // A path-less build packages the whole suite, which reaches everything.
183
+ if (mode === 'all' || normalizedPaths.length === 0)
184
+ return { skip: false };
185
+ const { reached, skipped } = await partitionReachedComponents(projectRoot, paths.engine, normalizedPaths);
186
+ return { skip: false, only: reached, unreached: skipped };
171
187
  }
172
188
  /** Renders the `recordedBy` invocation string surfaced by `status --test-coverage`. */
173
189
  function describeBuildInvocation(extending, coverage) {
@@ -184,7 +200,7 @@ function describeBuildInvocation(extending, coverage) {
184
200
  * next steps, and emits the run's single `PASS` verdict.
185
201
  */
186
202
  export async function runTestBuildPhase(projectRoot, paths, projectConfig, harnessRetries, options, request) {
187
- const { classification, normalizedPaths } = request;
203
+ const { classification, normalizedPaths, fullBuildReason } = request;
188
204
  const extending = options.extendCoverage === true;
189
205
  if (extending) {
190
206
  assertExtendCoverageUsage(options, normalizedPaths);
@@ -218,7 +234,8 @@ export async function runTestBuildPhase(projectRoot, paths, projectConfig, harne
218
234
  testPackagingCoverage: coverage,
219
235
  refuseUnexportedDrift: options.refuseUnexportedDrift === true,
220
236
  extend: extending ? { requestedPaths: normalizedPaths } : undefined,
221
- skipFurnaceApply: options.furnaceApply === false,
237
+ fullBuildReason,
238
+ furnace: await planPreTestFurnace(projectRoot, paths, projectConfig, options, normalizedPaths),
222
239
  });
223
240
  info('');
224
241
  if (options.buildOnly) {
@@ -1,7 +1,8 @@
1
1
  // SPDX-License-Identifier: EUPL-1.2
2
2
  import { findUnownedSupportHeads, formatUnownedSupportHeadNotice, } from '../core/checkjs-support-heads.js';
3
+ import { buildPatchQueueContext } from '../core/patch-lint.js';
3
4
  import { runCheckJsTestFilesGrouped } from '../core/patch-lint-checkjs.js';
4
- import { isTestScriptFile } from '../core/patch-lint-ownership.js';
5
+ import { isTestScriptFile, resolvableModulesForTests } from '../core/patch-lint-ownership.js';
5
6
  import { loadPatchesManifest } from '../core/patch-manifest.js';
6
7
  import { analyzeTestPathScopes } from '../core/test-path-scope.js';
7
8
  import { GeneralError } from '../errors/base.js';
@@ -24,7 +25,7 @@ export async function checkRequestedTestTypes(paths, config, requested) {
24
25
  owned.add(head.file);
25
26
  notice(`Pre-build checkJs: ${formatUnownedSupportHeadNotice(head)}`);
26
27
  }
27
- const result = await runCheckJsTestFilesGrouped(paths.engine, owned, config.patchLint, paths.root, selected);
28
+ const result = await runCheckJsTestFilesGrouped(paths.engine, owned, config.patchLint, paths.root, selected, resolvableModulesForTests(await buildPatchQueueContext(paths.patches)));
28
29
  const issues = [...result.global, ...[...result.byFile.values()].flat()];
29
30
  for (const issue of issues)
30
31
  notice(`Pre-build checkJs: ${issue.file}: ${issue.message}`);
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The dispatch half of one `fireforge test` run, split out of `test.ts`:
3
+ * the engine-generation guard around the harness, and the choice between
4
+ * one combined invocation, per-argument shards, `--shard-size` chunks and
5
+ * `--jobs` parallel harness instances.
6
+ */
7
+ import type { PostRebuildFailureContext } from '../core/test-harness-output.js';
8
+ import type { TestOptions } from '../types/commands/index.js';
9
+ import type { FireForgeConfig } from '../types/config.js';
10
+ import { type TestRunContext } from './test-run.js';
11
+ import { type ShardGroup } from './test-shards.js';
12
+ /** Everything the dispatch half needs from the run body. */
13
+ export interface TestDispatchInputs {
14
+ engineDir: string;
15
+ runCtx: TestRunContext;
16
+ dispatchGroups: ShardGroup[];
17
+ options: TestOptions;
18
+ projectConfig: FireForgeConfig;
19
+ canaryPath: string | undefined;
20
+ shuffleSeed: number | undefined;
21
+ normalizedPaths: string[];
22
+ xpcshellOnly: boolean;
23
+ postRebuildContext: PostRebuildFailureContext | undefined;
24
+ }
25
+ /**
26
+ * Refuses `--jobs`/`--shard-size` shapes that cannot work, before any lock
27
+ * or build: both need explicit paths and a real dispatch, and parallel
28
+ * instances cannot share one operator-pinned Marionette port.
29
+ *
30
+ * @param testPaths - Requested paths
31
+ * @param options - Parsed options
32
+ */
33
+ export declare function assertParallelTestUsage(testPaths: readonly string[], options: TestOptions): void;
34
+ /**
35
+ * Runs the planned dispatch and finalizes its verdict.
36
+ *
37
+ * @param inputs - See {@link TestDispatchInputs}
38
+ */
39
+ export declare function dispatchTests(inputs: TestDispatchInputs): Promise<void>;
@@ -0,0 +1,220 @@
1
+ // SPDX-License-Identifier: EUPL-1.2
2
+ /**
3
+ * The dispatch half of one `fireforge test` run, split out of `test.ts`:
4
+ * the engine-generation guard around the harness, and the choice between
5
+ * one combined invocation, per-argument shards, `--shard-size` chunks and
6
+ * `--jobs` parallel harness instances.
7
+ */
8
+ import { createServer } from 'node:net';
9
+ import { assertEngineGenerationUnchanged, snapshotEngineGeneration, } from '../core/engine-session-lock.js';
10
+ import { autoPortsRequested } from '../core/harness-port-fallback.js';
11
+ import { extractForwardedMarionettePort } from '../core/marionette-port.js';
12
+ import { GeneralError, InvalidArgumentError } from '../errors/base.js';
13
+ import { BuildError } from '../errors/build.js';
14
+ import { notice } from '../utils/logger.js';
15
+ import { diagnoseShardOutcome, finalizeSingleRunOutcome } from './test-diagnose.js';
16
+ import { shuffleTestGroups } from './test-harness-env.js';
17
+ import { reportCanaryOutcome } from './test-modes.js';
18
+ import { perfGenerationTolerance, runGenerationTolerance } from './test-perf-scope.js';
19
+ import { runTestsWithRetries } from './test-run.js';
20
+ import { chunkShardGroups, finalizeShardedOutcome, runShardedTests, splitContiguous, } from './test-shards.js';
21
+ import { emitFailVerdict, setVerdictRunAttribute } from './test-verdict.js';
22
+ /**
23
+ * Refuses `--jobs`/`--shard-size` shapes that cannot work, before any lock
24
+ * or build: both need explicit paths and a real dispatch, and parallel
25
+ * instances cannot share one operator-pinned Marionette port.
26
+ *
27
+ * @param testPaths - Requested paths
28
+ * @param options - Parsed options
29
+ */
30
+ export function assertParallelTestUsage(testPaths, options) {
31
+ const parallel = (options.jobs ?? 1) > 1;
32
+ const flags = [
33
+ ...(parallel ? ['--jobs'] : []),
34
+ ...(options.shardSize !== undefined ? ['--shard-size'] : []),
35
+ ];
36
+ if (flags.length === 0)
37
+ return;
38
+ const flag = flags.join('/');
39
+ if (testPaths.length === 0 || options.canary !== undefined || options.auto === true) {
40
+ throw new InvalidArgumentError(`${flag} splits explicit test paths, so it needs paths and cannot be combined with --canary or --auto.`, flags[0]);
41
+ }
42
+ if (options.buildOnly === true) {
43
+ throw new InvalidArgumentError(`${flag} shapes a dispatch; --build-only runs none.`, flags[0]);
44
+ }
45
+ if (parallel &&
46
+ (options.marionettePort !== undefined ||
47
+ extractForwardedMarionettePort(options.machArg ?? []) !== undefined)) {
48
+ throw new InvalidArgumentError('--jobs gives every harness instance its own Marionette port, so it cannot be combined with a pinned --marionette-port (or a forwarded one).', '--jobs');
49
+ }
50
+ }
51
+ /**
52
+ * Verifies `engine/` did not change under the run in a way the run could
53
+ * see before any PASS verdict may print. On failure the run's verdict is
54
+ * `FAIL reason=inconclusive`, because the harness result exists but cannot
55
+ * be trusted (`preflight` would misdescribe a run whose harness already
56
+ * executed). It is emitted here so the guard's throw can never leave a
57
+ * stale or missing verdict line behind.
58
+ */
59
+ async function verifyEngineGenerationOrEmitInconclusive(engineDir, before, inputs) {
60
+ try {
61
+ await assertEngineGenerationUnchanged(engineDir, before, inputs.perfSamples === undefined
62
+ ? runGenerationTolerance(engineDir, inputs.requested, (count) => {
63
+ setVerdictRunAttribute('drift-tolerated', String(count));
64
+ })
65
+ : perfGenerationTolerance(engineDir));
66
+ if (inputs.powerChanged === true)
67
+ throw new GeneralError('Perf power source changed during the run; repeat this sitting on a stable power source.');
68
+ }
69
+ catch (error) {
70
+ emitFailVerdict('inconclusive');
71
+ throw error;
72
+ }
73
+ }
74
+ /** A free TCP port on the loopback interface, for one harness instance. */
75
+ async function allocateLoopbackPort() {
76
+ return new Promise((resolve, reject) => {
77
+ const server = createServer();
78
+ server.once('error', reject);
79
+ server.listen(0, '127.0.0.1', () => {
80
+ const address = server.address();
81
+ const port = typeof address === 'object' && address !== null ? address.port : 0;
82
+ server.close(() => {
83
+ resolve(port);
84
+ });
85
+ });
86
+ });
87
+ }
88
+ /**
89
+ * The mochitest harness writes the dispatched test list to
90
+ * `_tests/testing/mochitest/tests.json` and the browser fetches it from
91
+ * there, so instances sharing the default name read each other's list (and
92
+ * one instance's cleanup removes it under the other). Each instance names
93
+ * its own file.
94
+ */
95
+ function testRunManifestArg(index) {
96
+ return `--testrun-manifest-file=fireforge-tests-${process.pid}-job${index + 1}.json`;
97
+ }
98
+ /**
99
+ * The context for `--jobs` instance `index` (0-based): its own output
100
+ * prefix and test-list manifest, and from the second instance on its own
101
+ * Marionette port, so browsers started at the same moment never race for
102
+ * 2828. The mochitest server ports are left to the engine harness's
103
+ * busy-port fallback, which `--jobs` requires (auto ports).
104
+ */
105
+ async function instanceContext(base, index, xpcshellOnly) {
106
+ const ctx = { ...base, outputPrefix: `[job ${index + 1}] ` };
107
+ if (xpcshellOnly)
108
+ return ctx;
109
+ const own = [...base.baseExtraArgs, testRunManifestArg(index)];
110
+ if (index === 0)
111
+ return { ...ctx, baseExtraArgs: own };
112
+ const port = await allocateLoopbackPort();
113
+ return {
114
+ ...ctx,
115
+ baseExtraArgs: [...own, `--setpref=marionette.port=${port}`, `--marionette=127.0.0.1:${port}`],
116
+ };
117
+ }
118
+ /** The shards to run, or undefined for one combined invocation. */
119
+ function planShards(inputs) {
120
+ const { dispatchGroups, options, canaryPath, shuffleSeed } = inputs;
121
+ if (canaryPath !== undefined)
122
+ return undefined;
123
+ const ordered = shuffleSeed === undefined ? dispatchGroups : shuffleTestGroups(dispatchGroups, shuffleSeed);
124
+ if (options.shardSize !== undefined)
125
+ return chunkShardGroups(ordered, options.shardSize);
126
+ const jobs = options.jobs ?? 1;
127
+ if (jobs > 1 && (options.shard === false || ordered.length === 1)) {
128
+ return splitContiguous(ordered.flatMap((group) => group.paths), jobs);
129
+ }
130
+ if (ordered.length > 1 && options.shard !== false)
131
+ return ordered;
132
+ return undefined;
133
+ }
134
+ /**
135
+ * Runs the planned dispatch and finalizes its verdict.
136
+ *
137
+ * @param inputs - See {@link TestDispatchInputs}
138
+ */
139
+ export async function dispatchTests(inputs) {
140
+ const { engineDir, runCtx, options, projectConfig, normalizedPaths } = inputs;
141
+ const jobs = options.jobs ?? 1;
142
+ if (jobs > 1 && !inputs.xpcshellOnly && !autoPortsRequested(options, projectConfig)) {
143
+ throw new InvalidArgumentError('--jobs runs several browsers at once, which needs auto ports (--auto-ports or ' +
144
+ 'test.mochitestPorts: "auto") so the harness can move each instance to free server ports.', '--jobs');
145
+ }
146
+ const guard = {
147
+ perfSamples: options.perfSamples,
148
+ requested: normalizedPaths,
149
+ };
150
+ const shards = planShards(inputs);
151
+ if (shards !== undefined) {
152
+ notice(describeSharding(shards.length, options, jobs));
153
+ const base = jobs > 1 ? await instanceContext(runCtx, 0, inputs.xpcshellOnly) : runCtx;
154
+ if (jobs > 1)
155
+ setVerdictRunAttribute('jobs', String(jobs));
156
+ const generationBefore = await snapshotEngineGeneration(engineDir);
157
+ let summary;
158
+ try {
159
+ summary = await runShardedTests(base, shards, (outcome, label) => diagnoseShardOutcome(outcome, label, projectConfig.binaryName, inputs.postRebuildContext), {
160
+ jobs,
161
+ contextFor: (index) => instanceContext(runCtx, index, inputs.xpcshellOnly),
162
+ perFile: options.shardSize !== undefined,
163
+ });
164
+ }
165
+ finally {
166
+ // Runs before the aggregate verdict below: a mutated engine/ emits
167
+ // `FAIL reason=inconclusive` and throws, so an invalidated run can
168
+ // never print `PASS shards=N/N` first. (A throw here masks an
169
+ // in-flight shard error, as the plain assert always did.)
170
+ await verifyEngineGenerationOrEmitInconclusive(engineDir, generationBefore, {
171
+ ...guard,
172
+ ...(base.powerChanged === true || runCtx.powerChanged === true
173
+ ? { powerChanged: true }
174
+ : {}),
175
+ });
176
+ }
177
+ finalizeShardedOutcome(summary);
178
+ return;
179
+ }
180
+ const combinedDispatchPaths = inputs.dispatchGroups.flatMap((group) => group.paths);
181
+ let outcome;
182
+ const generationBefore = await snapshotEngineGeneration(engineDir);
183
+ try {
184
+ outcome = await runTestsWithRetries(runCtx, combinedDispatchPaths);
185
+ }
186
+ catch (error) {
187
+ throw new BuildError('Test process failed to start', 'mach test', error instanceof Error ? error : undefined);
188
+ }
189
+ finally {
190
+ await verifyEngineGenerationOrEmitInconclusive(engineDir, generationBefore, {
191
+ ...guard,
192
+ ...(runCtx.powerChanged === true ? { powerChanged: true } : {}),
193
+ });
194
+ }
195
+ if (inputs.canaryPath !== undefined) {
196
+ reportCanaryOutcome(outcome);
197
+ return;
198
+ }
199
+ finalizeSingleRunOutcome(outcome, normalizedPaths, projectConfig.binaryName, inputs.postRebuildContext, options.headless === true);
200
+ }
201
+ /**
202
+ * The sharding notice. The default must not be silent: a cross-file
203
+ * pollution repro otherwise "passes" because the comparison run was
204
+ * sharded without saying so, misattributing a suite-context bug upstream.
205
+ */
206
+ function describeSharding(count, options, jobs) {
207
+ const instances = jobs > 1 ? ` on ${jobs} harness instances at once (each with its own ports and profile)` : '';
208
+ if (options.shardSize !== undefined) {
209
+ return (`Sharding: running ${count} chunk(s) of up to ${options.shardSize} file(s)${instances}, ` +
210
+ 'each chunk one mach invocation with a browser restart between files; results are judged ' +
211
+ 'per file from the structured log.');
212
+ }
213
+ if (jobs > 1 && options.shard === false) {
214
+ return (`Sharding: --jobs splits the combined request into ${count} contiguous chunk(s) in order` +
215
+ `${instances}. Cross-chunk state is NOT exercised.`);
216
+ }
217
+ return (`Sharding: running ${count} test path arguments in isolated browser instances${instances} ` +
218
+ '(one mach invocation per argument; a directory argument keeps its files in one instance). ' +
219
+ 'Cross-argument state is NOT exercised — pass --no-shard for a combined single-instance run.');
220
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * `fireforge test --build --furnace-apply reached`: deploy only the Furnace
3
+ * components a requested test reaches.
4
+ *
5
+ * The pre-test build's Furnace apply runs over the whole `components/`
6
+ * tree, so on a shared engine a peer's `test --build` deployed every
7
+ * session's undeployed component edits into the shared objdir, including
8
+ * edits another session was holding back for a before-capture. `reached`
9
+ * keeps the apply to the components the run can observe and names the rest.
10
+ *
11
+ * "Reaches" is textual, and errs towards applying: a component is reached
12
+ * when a requested test file, a `head*.js` beside it, or any test file
13
+ * under a requested directory names the component's tag, or when the test
14
+ * path itself names it. A component no test names cannot change what the
15
+ * run observes through its own code, so leaving its undeployed edit out
16
+ * keeps the run honest about what it packaged.
17
+ */
18
+ import type { TestOptions } from '../types/commands/index.js';
19
+ import type { FireForgeConfig } from '../types/config.js';
20
+ /** The effective Furnace apply mode for a pre-test build. */
21
+ export type FurnaceApplyMode = 'all' | 'reached' | 'none';
22
+ /**
23
+ * Resolves the mode from the flag and `test.furnaceApply`. `false`
24
+ * (`--no-furnace-apply`) is `none`.
25
+ */
26
+ export declare function resolveFurnaceApplyMode(options: TestOptions, config: FireForgeConfig): FurnaceApplyMode;
27
+ /**
28
+ * The stale components a request reaches, and the stale ones it does not.
29
+ *
30
+ * @param projectRoot - Project root
31
+ * @param engineDir - Absolute engine directory
32
+ * @param testPaths - Engine-relative requested paths
33
+ */
34
+ export declare function partitionReachedComponents(projectRoot: string, engineDir: string, testPaths: readonly string[]): Promise<{
35
+ reached: string[];
36
+ skipped: string[];
37
+ }>;