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