@orkestrel/capture 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/core/index.d.cts +2 -1
- package/dist/src/core/index.d.ts +2 -1
- package/dist/src/server/index.cjs +79 -64
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +8 -7
- package/dist/src/server/index.d.ts +8 -7
- package/dist/src/server/index.js +79 -64
- package/dist/src/server/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -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
|
-
*
|
|
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
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
4082
|
-
*
|
|
4083
|
-
*
|
|
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
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
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
|
-
|
|
4177
|
-
|
|
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,
|
|
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 =
|
|
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
|
|
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:
|
|
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
|
|
4248
|
+
variants,
|
|
4251
4249
|
args
|
|
4252
4250
|
};
|
|
4253
|
-
const
|
|
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}: ${
|
|
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: {
|
|
4261
|
+
context: {
|
|
4262
|
+
stage,
|
|
4263
|
+
variants
|
|
4264
|
+
}
|
|
4261
4265
|
});
|
|
4262
|
-
|
|
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
|
-
|
|
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(
|
|
4276
|
+
if (!(0, node_fs.existsSync)(reportFile)) throw new _src_core.CaptureError(`${subject} wrote no reporter at ${reportFile}`, {
|
|
4271
4277
|
code: "EVIDENCE",
|
|
4272
|
-
context: {
|
|
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
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
variant
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
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
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
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 {
|