@smithers-orchestrator/time-travel 0.20.3 → 0.21.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 (2) hide show
  1. package/package.json +6 -8
  2. package/src/jumpToFrame.js +19 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithers-orchestrator/time-travel",
3
- "version": "0.20.3",
3
+ "version": "0.21.0",
4
4
  "description": "Smithers snapshots, diffs, forks, replay, timelines, and VCS-tagged run history",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -50,13 +50,11 @@
50
50
  "drizzle-orm": "^0.45.2",
51
51
  "effect": "^3.21.1",
52
52
  "picocolors": "^1.1.1",
53
- "@smithers-orchestrator/db": "0.20.3",
54
- "@smithers-orchestrator/driver": "0.20.3",
55
- "@smithers-orchestrator/errors": "0.20.3",
56
- "@smithers-orchestrator/graph": "0.20.3",
57
- "@smithers-orchestrator/scheduler": "0.20.3",
58
- "@smithers-orchestrator/observability": "0.20.3",
59
- "@smithers-orchestrator/vcs": "0.20.3"
53
+ "@smithers-orchestrator/db": "0.21.0",
54
+ "@smithers-orchestrator/errors": "0.21.0",
55
+ "@smithers-orchestrator/observability": "0.21.0",
56
+ "@smithers-orchestrator/scheduler": "0.21.0",
57
+ "@smithers-orchestrator/vcs": "0.21.0"
60
58
  },
61
59
  "devDependencies": {
62
60
  "@types/bun": "latest",
@@ -491,6 +491,7 @@ export async function jumpToFrame(input) {
491
491
  let lock = null;
492
492
  /** @type {number | null} */
493
493
  let auditRowId = null;
494
+ let canWriteAudit = false;
494
495
 
495
496
  try {
496
497
  return await withSpan(
@@ -513,6 +514,12 @@ export async function jumpToFrame(input) {
513
514
  );
514
515
  }
515
516
 
517
+ const run = await input.adapter.getRun(runId);
518
+ if (!run) {
519
+ throw new JumpToFrameError("RunNotFound", `Run not found: ${runId}`);
520
+ }
521
+ canWriteAudit = true;
522
+
516
523
  lock = await withSpan(
517
524
  "timetravel.lock.acquire",
518
525
  { runId },
@@ -562,11 +569,6 @@ export async function jumpToFrame(input) {
562
569
  }),
563
570
  );
564
571
 
565
- const run = await input.adapter.getRun(runId);
566
- if (!run) {
567
- throw new JumpToFrameError("RunNotFound", `Run not found: ${runId}`);
568
- }
569
-
570
572
  const latestFrame = await readLatestFrame(input.adapter, runId);
571
573
  if (!latestFrame) {
572
574
  throw new JumpToFrameError("FrameOutOfRange", `Run ${runId} has no frames.`);
@@ -971,9 +973,9 @@ export async function jumpToFrame(input) {
971
973
  durationMs,
972
974
  fromFrameNo: fromFrameNoForAudit,
973
975
  });
974
- } else {
975
- // We threw before reaching the in_progress write (usually validation /
976
- // lock-busy / rate-limit). Still record the attempt for auditability.
976
+ } else if (canWriteAudit) {
977
+ // The run exists but we threw before reaching the in_progress write.
978
+ // Still record the attempt for auditability.
977
979
  await writeRewindAuditRow(input.adapter, {
978
980
  runId: runIdForAudit,
979
981
  fromFrameNo: fromFrameNoForAudit,
@@ -984,13 +986,15 @@ export async function jumpToFrame(input) {
984
986
  durationMs,
985
987
  });
986
988
  }
987
- await emitLog(input.onLog, "info", "jumpToFrame audit row written", {
988
- runId: runIdForAudit,
989
- fromFrameNo: fromFrameNoForAudit,
990
- toFrameNo: toFrameNoForAudit,
991
- caller,
992
- result: auditResult,
993
- });
989
+ if (auditRowId !== null || canWriteAudit) {
990
+ await emitLog(input.onLog, "info", "jumpToFrame audit row written", {
991
+ runId: runIdForAudit,
992
+ fromFrameNo: fromFrameNoForAudit,
993
+ toFrameNo: toFrameNoForAudit,
994
+ caller,
995
+ result: auditResult,
996
+ });
997
+ }
994
998
  } catch (auditError) {
995
999
  await emitLog(input.onLog, "error", "jumpToFrame audit write failed", {
996
1000
  runId: runIdForAudit,