@orkestrel/capture 0.0.5 → 0.0.7

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.
@@ -481,7 +481,8 @@ export declare interface CaptureReport {
481
481
  * Carries a runner request through Vitest's provided-context protocol.
482
482
  *
483
483
  * @remarks Journey selections use the selected stage; frame captures use narrow and rest stages.
484
- * Registry refreshes retain their registry-prefixed stages. Records are keyed by id, stage, and variant.
484
+ * A registry refresh runs every selected variant in one registry stage. Records are keyed by id,
485
+ * stage, and variant.
485
486
  * `mode` carries the selected Vitest mode when the command line names one.
486
487
  *
487
488
  * @example
@@ -481,7 +481,8 @@ export declare interface CaptureReport {
481
481
  * Carries a runner request through Vitest's provided-context protocol.
482
482
  *
483
483
  * @remarks Journey selections use the selected stage; frame captures use narrow and rest stages.
484
- * Registry refreshes retain their registry-prefixed stages. Records are keyed by id, stage, and variant.
484
+ * A registry refresh runs every selected variant in one registry stage. Records are keyed by id,
485
+ * stage, and variant.
485
486
  * `mode` carries the selected Vitest mode when the command line names one.
486
487
  *
487
488
  * @example
@@ -317,11 +317,11 @@ var CAPTURE_SHEET_FILES = Object.freeze({
317
317
  notes: "index.md"
318
318
  });
319
319
  /**
320
- * Names the stage each producing variant's complete journey runs in, ahead of the variant's name.
320
+ * Names the one stage a registry refresh runs every selected producing variant's complete journey in.
321
321
  *
322
322
  * @example
323
323
  * ```ts
324
- * `${CAPTURE_REGISTRY_STAGE}-light-390` // 'registry-light-390'
324
+ * `runs/${id}/${CAPTURE_REGISTRY_STAGE}/light-390.json` // 'runs/<id>/registry/light-390.json'
325
325
  * ```
326
326
  */
327
327
  var CAPTURE_REGISTRY_STAGE = "registry";
@@ -4072,15 +4072,16 @@ var CapturePreflight = class {
4072
4072
  };
4073
4073
  // src/server/CaptureRegistrar.ts
4074
4074
  /**
4075
- * Refreshes the accepted registry from one complete capture-free journey per producing variant.
4075
+ * Refreshes the accepted registry from one complete capture-free journey stage over the selected variants.
4076
4076
  *
4077
4077
  * @remarks
4078
4078
  * The refresh is the one route that bootstraps or replaces the registry the stage transaction
4079
4079
  * requires, so it cannot stamp through the integrity engine. It reads the wrapper through the same
4080
4080
  * discovery the runner uses, takes the same invocation entity, request file, and Vitest child, and runs
4081
- * each producing variant as a stage of its own with the `all` selector and no capture variable. It
4082
- * reads each stage's reporter and final record, takes the project's input population before and
4083
- * after, and builds the receipts through `buildCaptureRegistry`. The registry is written to a
4081
+ * every selected producing variant in one stage, one child that receives each variant's project, with
4082
+ * the `all` selector and no capture variable. It reads the stage's reporter once and each variant's
4083
+ * final record, takes each project's input population before and after, and builds one receipt per
4084
+ * variant, all naming the one reporter, through `buildCaptureRegistry`. The registry is written to a
4084
4085
  * candidate beside its target, read back through the integrity engine, and only then renamed into
4085
4086
  * place, so a registry the engine would refuse never replaces a good one. With `--variant`, the
4086
4087
  * existing registry's receipts for the other declared variants are kept. It never widens a scoped
@@ -4154,9 +4155,13 @@ var CaptureRegistrar = class {
4154
4155
  context: { variant }
4155
4156
  });
4156
4157
  const variants = declared.filter((variant) => parsed.variants.length === 0 || parsed.variants.includes(variant));
4157
- for (const variant of variants) if (!projects.some((project) => project.variant === variant)) throw new _src_core.CaptureError(`The wrapper declares no journey project for ${variant}`, {
4158
- code: "HOST",
4159
- context: { variant }
4158
+ const selected = variants.map((variant) => {
4159
+ const project = projects.find((candidate) => candidate.variant === variant);
4160
+ if (project === void 0) throw new _src_core.CaptureError(`The wrapper declares no journey project for ${variant}`, {
4161
+ code: "HOST",
4162
+ context: { variant }
4163
+ });
4164
+ return project;
4160
4165
  });
4161
4166
  const target = `${resolveCaptureRelative(root, primary.directory)}/${_src_core.CAPTURE_REGISTRY_FILE}`;
4162
4167
  const candidate = `${target}.${invocation.id}.candidate`;
@@ -4173,11 +4178,8 @@ var CaptureRegistrar = class {
4173
4178
  });
4174
4179
  const retained = parsed.variants.length === 0 ? [] : this.#retain(target, variants, declared);
4175
4180
  if (retained.length > 0) buildCaptureRegistry(retained);
4176
- const imports = [];
4177
- for (const variant of variants) {
4178
- if (invocation.interrupted) return CAPTURE_EXIT.failed;
4179
- imports.push(await this.#stage(invocation, parsed, projects, primary, variant));
4180
- }
4181
+ if (invocation.interrupted) return CAPTURE_EXIT.failed;
4182
+ const imports = await this.#stage(invocation, parsed, projects, primary, selected);
4181
4183
  if (invocation.interrupted) return CAPTURE_EXIT.failed;
4182
4184
  const registry = buildCaptureRegistry([...retained, ...imports]);
4183
4185
  const path = (0, node_path.resolve)(root, candidate);
@@ -4217,23 +4219,19 @@ var CaptureRegistrar = class {
4217
4219
  }
4218
4220
  }
4219
4221
  }
4220
- async #stage(invocation, parsed, projects, primary, variant) {
4222
+ async #stage(invocation, parsed, projects, primary, selected) {
4221
4223
  const { root } = this.#options;
4222
- const project = projects.find((candidate) => candidate.variant === variant);
4223
- if (project === void 0) throw new _src_core.CaptureError(`The wrapper declares no journey project for ${variant}`, {
4224
- code: "HOST",
4225
- context: { variant }
4226
- });
4227
4224
  const selectors = [...new Set(projects.flatMap((candidate) => candidate.tags))].filter((tag) => tag.startsWith(CAPTURE_OWNER_PREFIX)).map((tag) => tag.slice(CAPTURE_OWNER_PREFIX.length));
4228
- const stage = `${CAPTURE_REGISTRY_STAGE}-${variant}`;
4225
+ const stage = CAPTURE_REGISTRY_STAGE;
4226
+ const variants = selected.map((project) => project.variant);
4229
4227
  const reportFile = (0, node_path.resolve)(invocation.directory, `${stage}.json`);
4230
4228
  const log = (0, node_path.resolve)(invocation.directory, `${stage}.log`);
4231
- const record = `${resolveCaptureRelative(root, primary.directory)}/${CAPTURE_RUNS_DIRECTORY}/${invocation.id}/${stage}/${variant}.json`;
4229
+ const records = `${resolveCaptureRelative(root, primary.directory)}/${CAPTURE_RUNS_DIRECTORY}/${invocation.id}/${stage}`;
4232
4230
  const args = buildCaptureArguments({
4233
4231
  entry: (0, node_path.resolve)(root, CAPTURE_VITEST_ENTRY),
4234
4232
  config: parsed.config,
4235
4233
  report: reportFile,
4236
- projects: [project.name],
4234
+ projects: selected.map((project) => project.name),
4237
4235
  filter: buildCaptureFilter("journey", "all", selectors),
4238
4236
  final: primary.final,
4239
4237
  ...parsed.mode === void 0 ? {} : { mode: parsed.mode }
@@ -4247,67 +4245,84 @@ var CaptureRegistrar = class {
4247
4245
  command: "journey",
4248
4246
  ...parsed.mode === void 0 ? {} : { mode: parsed.mode },
4249
4247
  selector: "all",
4250
- variants: [variant],
4248
+ variants,
4251
4249
  args
4252
4250
  };
4253
- const before = readCaptureInputs(root, project.inputs);
4251
+ const snapshots = selected.map((project) => ({
4252
+ project,
4253
+ before: readCaptureInputs(root, project.inputs)
4254
+ }));
4254
4255
  const started = Date.now();
4255
4256
  (0, node_fs.rmSync)(reportFile, { force: true });
4256
- this.#stdout(`registry ${stage}: ${variant}; all; report=${reportFile}; record=${record}\n`);
4257
+ this.#stdout(`registry ${stage}: ${variants.join(", ")}; all; report=${reportFile}; records=${records}/<variant>.json\n`);
4257
4258
  const outcome = await this.#run(invocation, request, log);
4258
4259
  if (invocation.interrupted) throw new _src_core.CaptureError("Runner interrupted", {
4259
4260
  code: "STAGE",
4260
- context: { variant }
4261
+ context: {
4262
+ stage,
4263
+ variants
4264
+ }
4261
4265
  });
4262
- if (outcome.code !== 0 || outcome.signal !== null) throw new _src_core.CaptureError(`The registry journey for ${variant} did not exit successfully (${String(outcome.code ?? outcome.signal)})`, {
4266
+ const subject = `The registry journey for ${variants.join(", ")} in stage ${stage}`;
4267
+ if (outcome.code !== 0 || outcome.signal !== null) throw new _src_core.CaptureError(`${subject} did not exit successfully (${String(outcome.code ?? outcome.signal)})`, {
4263
4268
  code: "STAGE",
4264
4269
  context: {
4265
- variant,
4270
+ stage,
4271
+ variants,
4266
4272
  code: outcome.code,
4267
4273
  signal: outcome.signal
4268
4274
  }
4269
4275
  });
4270
- if (!(0, node_fs.existsSync)(reportFile)) throw new _src_core.CaptureError(`The registry journey for ${variant} wrote no reporter at ${reportFile}`, {
4276
+ if (!(0, node_fs.existsSync)(reportFile)) throw new _src_core.CaptureError(`${subject} wrote no reporter at ${reportFile}`, {
4271
4277
  code: "EVIDENCE",
4272
- context: { variant }
4278
+ context: {
4279
+ stage,
4280
+ variants
4281
+ }
4273
4282
  });
4274
4283
  const text = (0, node_fs.readFileSync)(reportFile, "utf8");
4275
4284
  const report = (0, _src_core.readCaptureReport)((0, _orkestrel_contract.parseJSON)(text));
4276
4285
  if (report.start < started || report.end > Date.now()) throw new _src_core.CaptureError("Reporter does not belong to this refresh", { code: "EVIDENCE" });
4277
- if (!(0, node_fs.existsSync)((0, node_path.resolve)(root, record))) throw new _src_core.CaptureError(`The registry journey for ${variant} wrote no final record at ${record}`, {
4278
- code: "EVIDENCE",
4279
- context: { variant }
4280
- });
4281
- const run = (0, _orkestrel_contract.parseJSON)((0, node_fs.readFileSync)((0, node_path.resolve)(root, record), "utf8"));
4282
- if (!(0, _src_core.isCaptureRun)(run) || run.request === void 0 || run.variant !== variant || (0, _src_core.describeCaptureRequest)(run.request) !== (0, _src_core.describeCaptureRequest)(request)) throw new _src_core.CaptureError(`Invalid or mismatched final record: ${record}`, { code: "EVIDENCE" });
4283
- if (Date.parse(run.time) < started || Date.parse(run.time) > report.end) throw new _src_core.CaptureError("Final record time does not belong to this refresh", { code: "EVIDENCE" });
4284
- (0, _src_core.validateCaptureRun)(run, report, project.name);
4285
- if (!run.complete) throw new _src_core.CaptureError(`The registry journey for ${variant} was not a complete run; a refresh imports complete runs only`, {
4286
- code: "EVIDENCE",
4287
- context: { variant }
4288
- });
4289
- if (JSON.stringify(readCaptureInputs(root, project.inputs)) !== JSON.stringify(before)) throw new _src_core.CaptureError("Bounded host inputs or membership changed during the refresh", {
4290
- code: "STAGE",
4291
- context: { variant }
4292
- });
4293
- return {
4294
- receipt: {
4295
- version: _src_core.CAPTURE_VERSION,
4296
- variant,
4297
- time: run.time,
4298
- report: {
4299
- file: resolveCaptureRelative(root, reportFile),
4300
- digest: computeCaptureHash(text)
4286
+ const file = resolveCaptureRelative(root, reportFile);
4287
+ const digest = computeCaptureHash(text);
4288
+ return snapshots.map(({ project, before }) => {
4289
+ const variant = project.variant;
4290
+ const record = `${records}/${variant}.json`;
4291
+ if (!(0, node_fs.existsSync)((0, node_path.resolve)(root, record))) throw new _src_core.CaptureError(`The registry journey for ${variant} wrote no final record at ${record}`, {
4292
+ code: "EVIDENCE",
4293
+ context: { variant }
4294
+ });
4295
+ const run = (0, _orkestrel_contract.parseJSON)((0, node_fs.readFileSync)((0, node_path.resolve)(root, record), "utf8"));
4296
+ if (!(0, _src_core.isCaptureRun)(run) || run.request === void 0 || run.variant !== variant || (0, _src_core.describeCaptureRequest)(run.request) !== (0, _src_core.describeCaptureRequest)(request)) throw new _src_core.CaptureError(`Invalid or mismatched final record: ${record}`, { code: "EVIDENCE" });
4297
+ if (Date.parse(run.time) < started || Date.parse(run.time) > report.end) throw new _src_core.CaptureError("Final record time does not belong to this refresh", { code: "EVIDENCE" });
4298
+ (0, _src_core.validateCaptureRun)(run, report, project.name);
4299
+ if (!run.complete) throw new _src_core.CaptureError(`The registry journey for ${variant} was not a complete run; a refresh imports complete runs only`, {
4300
+ code: "EVIDENCE",
4301
+ context: { variant }
4302
+ });
4303
+ if (JSON.stringify(readCaptureInputs(root, project.inputs)) !== JSON.stringify(before)) throw new _src_core.CaptureError("Bounded host inputs or membership changed during the refresh", {
4304
+ code: "STAGE",
4305
+ context: { variant }
4306
+ });
4307
+ return {
4308
+ receipt: {
4309
+ version: _src_core.CAPTURE_VERSION,
4310
+ variant,
4311
+ time: run.time,
4312
+ report: {
4313
+ file,
4314
+ digest
4315
+ },
4316
+ inputs: before,
4317
+ declarations: run.declarations,
4318
+ registry: run.registry,
4319
+ complete: run.complete
4301
4320
  },
4302
- inputs: before,
4303
- declarations: run.declarations,
4304
- registry: run.registry,
4305
- complete: run.complete
4306
- },
4307
- report: text,
4308
- outcome,
4309
- capped: false
4310
- };
4321
+ report: text,
4322
+ outcome,
4323
+ capped: false
4324
+ };
4325
+ });
4311
4326
  }
4312
4327
  async #run(invocation, request, log) {
4313
4328
  try {