MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / parseTimingModel

Function parseTimingModel

packages/core/src/repro/schema.ts:472–532  ·  view source on GitHub ↗
(
  value: unknown,
  path: string,
)

Source from the content-addressed store, hash-verified

470}
471
472function parseTimingModel(
473 value: unknown,
474 path: string,
475): ReproParseResult<ReproTimingModelMetadata> {
476 if (!isJsonObject(value)) {
477 return fail("ZR_REPRO_INVALID_BUNDLE", path, "timingModel must be an object");
478 }
479 const known = assertKnownFields(value, TIMING_MODEL_KEYS, path);
480 if (!known.ok) return known;
481
482 const kind = readString(value, "kind", `${path}.kind`);
483 if (!kind.ok) return kind;
484 if (kind.value !== REPRO_TIMING_MODEL_KIND_DETERMINISTIC) {
485 return fail(
486 "ZR_REPRO_INVALID_BUNDLE",
487 `${path}.kind`,
488 `timingModel.kind must be '${REPRO_TIMING_MODEL_KIND_DETERMINISTIC}'`,
489 );
490 }
491
492 const clock = readString(value, "clock", `${path}.clock`);
493 if (!clock.ok) return clock;
494 if (clock.value !== REPRO_TIMING_CLOCK_MONOTONIC_MS) {
495 return fail(
496 "ZR_REPRO_INVALID_BUNDLE",
497 `${path}.clock`,
498 `timingModel.clock must be '${REPRO_TIMING_CLOCK_MONOTONIC_MS}'`,
499 );
500 }
501
502 const replayStrategy = readString(value, "replayStrategy", `${path}.replayStrategy`);
503 if (!replayStrategy.ok) return replayStrategy;
504 if (replayStrategy.value !== REPRO_TIMING_REPLAY_STRATEGY_RECORDED_DELTA) {
505 return fail(
506 "ZR_REPRO_INVALID_BUNDLE",
507 `${path}.replayStrategy`,
508 `timingModel.replayStrategy must be '${REPRO_TIMING_REPLAY_STRATEGY_RECORDED_DELTA}'`,
509 );
510 }
511
512 const timeUnit = readString(value, "timeUnit", `${path}.timeUnit`);
513 if (!timeUnit.ok) return timeUnit;
514 if (timeUnit.value !== REPRO_TIMING_UNIT_MS) {
515 return fail(
516 "ZR_REPRO_INVALID_BUNDLE",
517 `${path}.timeUnit`,
518 `timingModel.timeUnit must be '${REPRO_TIMING_UNIT_MS}'`,
519 );
520 }
521
522 const baseTimeMs = readNonNegativeInteger(value, "baseTimeMs", `${path}.baseTimeMs`);
523 if (!baseTimeMs.ok) return baseTimeMs;
524
525 return ok({
526 kind: REPRO_TIMING_MODEL_KIND_DETERMINISTIC,
527 clock: REPRO_TIMING_CLOCK_MONOTONIC_MS,
528 replayStrategy: REPRO_TIMING_REPLAY_STRATEGY_RECORDED_DELTA,
529 timeUnit: REPRO_TIMING_UNIT_MS,

Callers 1

validateV1BundleFunction · 0.85

Calls 6

isJsonObjectFunction · 0.85
assertKnownFieldsFunction · 0.85
readNonNegativeIntegerFunction · 0.85
failFunction · 0.70
readStringFunction · 0.70
okFunction · 0.70

Tested by

no test coverage detected