@fro.bot/systematic 3.21.7 → 3.21.8

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/index.js CHANGED
@@ -10322,6 +10322,7 @@ var REASON_CODES = new Set([
10322
10322
  "no-op-operation",
10323
10323
  "operation-not-required",
10324
10324
  "operation-target-mismatch",
10325
+ "readback-timeout",
10325
10326
  "receipt-mismatch",
10326
10327
  "rejected-operation",
10327
10328
  "resource-mismatch",
@@ -10359,14 +10360,55 @@ function isWorkflowGuardBlockedError(value) {
10359
10360
  return false;
10360
10361
  return typeof candidate.reasonCode === "string" && REASON_CODES.has(candidate.reasonCode);
10361
10362
  }
10363
+ function defaultTargetObserver(targetDirectory) {
10364
+ return createOpencodeOperationObserver({ targetDirectory });
10365
+ }
10366
+ function unconfirmedReadback(probe) {
10367
+ return { probe, reasonCode: "command-timeout" };
10368
+ }
10362
10369
  function initializationCause(kind) {
10363
10370
  return { site: "initialize-session", kind, timedOut: false };
10364
10371
  }
10365
- var OBSERVER_READBACK_FAILED_CAUSE = Object.freeze({
10366
- site: "refresh-readback",
10367
- kind: "observer-readback-failed",
10368
- timedOut: false
10369
- });
10372
+ function observerReadbackFailedCause(reasonCode, site = "refresh-readback") {
10373
+ return {
10374
+ site,
10375
+ kind: "observer-readback-failed",
10376
+ ...reasonCode !== undefined ? { reasonCode } : {},
10377
+ timedOut: reasonCode === "command-timeout"
10378
+ };
10379
+ }
10380
+ function remoteFailureReason(result) {
10381
+ if (result?.status === "missing-resource")
10382
+ return "missing-resource";
10383
+ if (result?.status === "unavailable")
10384
+ return result.reasonCode;
10385
+ return;
10386
+ }
10387
+ async function readSnapshot(observer, expectedTargetIdentity) {
10388
+ let result;
10389
+ try {
10390
+ result = await observer.snapshot();
10391
+ } catch {
10392
+ return { status: "fatal" };
10393
+ }
10394
+ if (isProbeTimeout(result))
10395
+ return { status: "timeout" };
10396
+ if (result.status === "unavailable") {
10397
+ return { status: "fatal", reasonCode: result.reasonCode };
10398
+ }
10399
+ if (expectedTargetIdentity !== undefined && result.snapshot.targetDigest !== expectedTargetIdentity) {
10400
+ return { status: "fatal" };
10401
+ }
10402
+ return { status: "ok", value: result.snapshot };
10403
+ }
10404
+ function isProbeTimeout(result) {
10405
+ if (result === undefined)
10406
+ return false;
10407
+ if (result.status !== "unavailable" && result.status !== "error") {
10408
+ return false;
10409
+ }
10410
+ return result.reasonCode === "command-timeout";
10411
+ }
10370
10412
  var startToolShape = {
10371
10413
  expected_operations: array(_enum(OPERATIONS)).optional(),
10372
10414
  resource_scopes: record(string(), string()).optional()
@@ -10851,7 +10893,7 @@ function isSuccessfulAfter(output) {
10851
10893
  function isSuccessfulSkillAfter(output) {
10852
10894
  return parseHostOutput(output, { maxOutputLength: Number.POSITIVE_INFINITY }) !== undefined;
10853
10895
  }
10854
- function statusForTool(status, unavailableCause, seedDeferrals = []) {
10896
+ function statusForTool(status, unavailableCause, seedDeferrals = [], unconfirmedReadbacks = []) {
10855
10897
  return JSON.stringify({
10856
10898
  state: status.state,
10857
10899
  reasonCode: status.reasonCode,
@@ -10859,7 +10901,8 @@ function statusForTool(status, unavailableCause, seedDeferrals = []) {
10859
10901
  satisfiedOperations: status.satisfiedOperations,
10860
10902
  missingOperations: status.missingOperations,
10861
10903
  ...unavailableCause && status.state === "unavailable" ? { firstUnavailableCause: unavailableCause } : {},
10862
- ...seedDeferrals.length > 0 ? { seedDeferrals } : {}
10904
+ ...seedDeferrals.length > 0 ? { seedDeferrals } : {},
10905
+ ...unconfirmedReadbacks.length > 0 ? { unconfirmedReadbacks } : {}
10863
10906
  });
10864
10907
  }
10865
10908
  function markerStatusRank(state) {
@@ -11107,34 +11150,48 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
11107
11150
  return;
11108
11151
  return parentObserverRegistration();
11109
11152
  }
11110
- function effectiveOperationObserver() {
11153
+ function resolveEffectiveObserver() {
11111
11154
  const parentObserver = options.observer;
11112
11155
  if (!parentObserver)
11113
- return;
11156
+ return { status: "fatal" };
11114
11157
  const pinnedTargetIdentity = guard.status().unit?.pinnedOperationTargetIdentity;
11115
11158
  if (pinnedTargetIdentity === undefined || pinnedTargetIdentity === options.workspaceIdentity) {
11116
11159
  return {
11117
- observer: parentObserver,
11118
- targetIdentity: options.workspaceIdentity,
11119
- pinned: false
11160
+ status: "ok",
11161
+ value: {
11162
+ observer: parentObserver,
11163
+ targetIdentity: options.workspaceIdentity,
11164
+ pinned: false
11165
+ }
11120
11166
  };
11121
11167
  }
11122
11168
  const registration = operationObserverRegistration(pinnedTargetIdentity);
11123
11169
  if (!registration)
11124
- return;
11170
+ return { status: "fatal" };
11171
+ return resolvePinnedObserver(parentObserver, registration, pinnedTargetIdentity);
11172
+ }
11173
+ function resolvePinnedObserver(parentObserver, registration, pinnedTargetIdentity) {
11125
11174
  let validation;
11126
11175
  try {
11127
11176
  validation = parentObserver.validateRegisteredWorktree(registration.targetRoot);
11128
11177
  } catch {
11129
- return;
11178
+ return { status: "fatal" };
11130
11179
  }
11131
- if (validation.status !== "ok" || validation.targetRoot !== registration.targetRoot || registeredWorktreeIdentity(validation) !== registration.registeredWorktreeIdentity || registration.observer.targetDigest !== pinnedTargetIdentity) {
11132
- return;
11180
+ if (isProbeTimeout(validation))
11181
+ return { status: "timeout" };
11182
+ if (validation.status !== "ok") {
11183
+ return { status: "fatal", reasonCode: validation.reasonCode };
11184
+ }
11185
+ if (validation.targetRoot !== registration.targetRoot || registeredWorktreeIdentity(validation) !== registration.registeredWorktreeIdentity || registration.observer.targetDigest !== pinnedTargetIdentity) {
11186
+ return { status: "fatal" };
11133
11187
  }
11134
11188
  return {
11135
- observer: registration.observer,
11136
- targetIdentity: pinnedTargetIdentity,
11137
- pinned: true
11189
+ status: "ok",
11190
+ value: {
11191
+ observer: registration.observer,
11192
+ targetIdentity: pinnedTargetIdentity,
11193
+ pinned: true
11194
+ }
11138
11195
  };
11139
11196
  }
11140
11197
  function questionResource(target) {
@@ -11818,51 +11875,76 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
11818
11875
  function observerReadbackApplies() {
11819
11876
  return options.observer !== undefined && guard.status().epoch !== null;
11820
11877
  }
11878
+ function skippedWithRemoteTail(head) {
11879
+ return [
11880
+ unconfirmedReadback(head),
11881
+ ...guard.status().satisfiedOperations.filter(remoteOperation).map((operation) => unconfirmedReadback(operation))
11882
+ ];
11883
+ }
11821
11884
  async function refreshReadback() {
11822
11885
  if (!observerReadbackApplies())
11823
- return;
11824
- const effective = effectiveOperationObserver();
11825
- if (!effective) {
11826
- markUnavailable(OBSERVER_READBACK_FAILED_CAUSE);
11827
- return;
11886
+ return [];
11887
+ const lookup = resolveEffectiveObserver();
11888
+ if (lookup.status === "timeout")
11889
+ return skippedWithRemoteTail("pinned");
11890
+ if (lookup.status === "fatal") {
11891
+ markUnavailable(observerReadbackFailedCause(lookup.reasonCode));
11892
+ return [];
11828
11893
  }
11829
- let result;
11830
- try {
11831
- result = await effective.observer.snapshot();
11832
- } catch {
11833
- markUnavailable(OBSERVER_READBACK_FAILED_CAUSE);
11834
- return;
11894
+ const effective = lookup.value;
11895
+ const read = await readSnapshot(effective.observer, effective.targetIdentity);
11896
+ if (read.status === "timeout") {
11897
+ return skippedWithRemoteTail(effective.pinned ? "pinned" : "local");
11835
11898
  }
11836
- if (result.status === "unavailable" || result.snapshot.targetDigest !== effective.targetIdentity) {
11837
- markUnavailable(OBSERVER_READBACK_FAILED_CAUSE);
11838
- return;
11899
+ if (read.status === "fatal") {
11900
+ markUnavailable(observerReadbackFailedCause(read.reasonCode));
11901
+ return [];
11839
11902
  }
11903
+ return applyReadbackAndProbeRemote(effective, read.value);
11904
+ }
11905
+ async function applyReadbackAndProbeRemote(effective, snapshot) {
11840
11906
  const observed = guard.observeReadback({
11841
11907
  workspaceIdentity: options.workspaceIdentity,
11842
- repositoryIdentity: result.snapshot.repositoryRevisionDigest,
11843
- worktreeIdentity: result.snapshot.worktreeRevisionDigest,
11908
+ repositoryIdentity: snapshot.repositoryRevisionDigest,
11909
+ worktreeIdentity: snapshot.worktreeRevisionDigest,
11844
11910
  ...effective.pinned ? { operationTargetIdentity: effective.targetIdentity } : {}
11845
11911
  });
11846
- if (observed.status === "rejected" && observed.reasonCode === "workspace-mismatch" || !await refreshRemoteReadbacks(effective.observer, result.snapshot)) {
11847
- markUnavailable(OBSERVER_READBACK_FAILED_CAUSE);
11912
+ if (observed.status === "rejected" && observed.reasonCode === "workspace-mismatch") {
11913
+ markUnavailable(observerReadbackFailedCause());
11914
+ return [];
11915
+ }
11916
+ const remote = await refreshRemoteReadbacks(effective.observer, snapshot);
11917
+ if (remote.kind === "fatal") {
11918
+ markUnavailable(observerReadbackFailedCause(remote.reasonCode));
11848
11919
  }
11920
+ return remote.unconfirmed;
11849
11921
  }
11850
11922
  async function refreshRemoteReadbacks(observer, local) {
11851
11923
  const remoteOperations = guard.status().satisfiedOperations.filter(remoteOperation);
11852
11924
  if (remoteOperations.length === 0)
11853
- return true;
11925
+ return { kind: "ok", unconfirmed: [] };
11854
11926
  const remoteSnapshot = observer.remoteSnapshot;
11855
11927
  if (!remoteSnapshot)
11856
- return false;
11928
+ return { kind: "fatal", unconfirmed: [] };
11929
+ const unconfirmed = [];
11857
11930
  for (const operation of remoteOperations) {
11858
11931
  const result = await readRemoteScope(remoteSnapshot, operation);
11859
- if (result?.status !== "available")
11860
- return false;
11932
+ if (isProbeTimeout(result)) {
11933
+ unconfirmed.push(unconfirmedReadback(operation));
11934
+ continue;
11935
+ }
11936
+ if (result?.status !== "available") {
11937
+ return {
11938
+ kind: "fatal",
11939
+ unconfirmed,
11940
+ reasonCode: remoteFailureReason(result)
11941
+ };
11942
+ }
11861
11943
  const observed = guard.observeReadback(remoteReadbackInput(operation, local, options.workspaceIdentity, result.snapshot));
11862
11944
  if (observed.status === "rejected")
11863
- return false;
11945
+ return { kind: "fatal", unconfirmed };
11864
11946
  }
11865
- return true;
11947
+ return { kind: "ok", unconfirmed };
11866
11948
  }
11867
11949
  function currentMarkerSource() {
11868
11950
  const status = guard.status();
@@ -12174,9 +12256,7 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
12174
12256
  markUnavailable();
12175
12257
  return;
12176
12258
  }
12177
- const operationObserver = target.targetRoot === canonicalParentTargetRoot ? options.observer : [...operationObservers.values()].find((registration) => registration.targetRoot === target.targetRoot)?.observer ?? createOpencodeOperationObserver({
12178
- targetDirectory: target.targetRoot
12179
- });
12259
+ const operationObserver = target.targetRoot === canonicalParentTargetRoot ? options.observer : [...operationObservers.values()].find((registration) => registration.targetRoot === target.targetRoot)?.observer ?? (options.createTargetObserver ?? defaultTargetObserver)(target.targetRoot);
12180
12260
  let result;
12181
12261
  try {
12182
12262
  result = await operationObserver.snapshot();
@@ -12686,99 +12766,89 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
12686
12766
  abandonedCompletes.set(callDigest, pending.target);
12687
12767
  }
12688
12768
  async function completionReadbacks() {
12689
- if (!options.observer)
12769
+ const observer = options.observer;
12770
+ if (!observer)
12690
12771
  return { status: "none" };
12691
- let parentResult;
12692
- try {
12693
- parentResult = await options.observer.snapshot();
12694
- } catch {
12695
- return { status: "unavailable" };
12696
- }
12697
- if (parentResult.status === "unavailable" || parentResult.snapshot.targetDigest !== options.workspaceIdentity) {
12698
- return { status: "unavailable" };
12699
- }
12700
- const effective = effectiveOperationObserver();
12701
- if (!effective)
12702
- return { status: "unavailable" };
12703
- let effectiveSnapshot = parentResult.snapshot;
12704
- if (effective.pinned) {
12705
- let pinnedResult;
12706
- try {
12707
- pinnedResult = await effective.observer.snapshot();
12708
- } catch {
12709
- return { status: "unavailable" };
12710
- }
12711
- if (pinnedResult.status === "unavailable" || pinnedResult.snapshot.targetDigest !== effective.targetIdentity) {
12712
- return { status: "unavailable" };
12713
- }
12714
- effectiveSnapshot = pinnedResult.snapshot;
12715
- }
12716
- const initialEffectiveSnapshot = effectiveSnapshot;
12717
- const remoteReadbacks = await completionRemoteReadbacks(effective.observer);
12718
- if (!remoteReadbacks)
12719
- return { status: "unavailable" };
12720
- let finalParentResult;
12721
- try {
12722
- finalParentResult = await options.observer.snapshot();
12723
- } catch {
12724
- return { status: "unavailable" };
12725
- }
12726
- if (finalParentResult.status === "unavailable" || finalParentResult.snapshot.targetDigest !== parentResult.snapshot.targetDigest || finalParentResult.snapshot.repositoryRevisionDigest !== parentResult.snapshot.repositoryRevisionDigest || finalParentResult.snapshot.worktreeRevisionDigest !== parentResult.snapshot.worktreeRevisionDigest) {
12727
- return { status: "unavailable" };
12728
- }
12729
- let finalEffective = effective;
12772
+ const parent = await readSnapshot(observer, options.workspaceIdentity);
12773
+ if (parent.status !== "ok")
12774
+ return parent;
12775
+ const lookup = resolveEffectiveObserver();
12776
+ if (lookup.status !== "ok")
12777
+ return lookup;
12778
+ const effective = lookup.value;
12779
+ let initialEffective = parent.value;
12730
12780
  if (effective.pinned) {
12731
- const revalidated = effectiveOperationObserver();
12732
- if (!revalidated)
12733
- return { status: "unavailable" };
12734
- finalEffective = revalidated;
12735
- if (finalEffective.observer !== effective.observer || finalEffective.targetIdentity !== effective.targetIdentity || !finalEffective.pinned) {
12736
- return { status: "unavailable" };
12737
- }
12738
- let pinnedResult;
12739
- try {
12740
- pinnedResult = await finalEffective.observer.snapshot();
12741
- } catch {
12742
- return { status: "unavailable" };
12743
- }
12744
- if (pinnedResult.status === "unavailable" || pinnedResult.snapshot.targetDigest !== finalEffective.targetIdentity) {
12745
- return { status: "unavailable" };
12746
- }
12747
- effectiveSnapshot = pinnedResult.snapshot;
12748
- if (effectiveSnapshot.repositoryRevisionDigest !== initialEffectiveSnapshot.repositoryRevisionDigest || effectiveSnapshot.worktreeRevisionDigest !== initialEffectiveSnapshot.worktreeRevisionDigest) {
12749
- return { status: "unavailable" };
12750
- }
12751
- } else {
12752
- effectiveSnapshot = finalParentResult.snapshot;
12753
- }
12781
+ const pinned = await readSnapshot(effective.observer, effective.targetIdentity);
12782
+ if (pinned.status !== "ok")
12783
+ return pinned;
12784
+ initialEffective = pinned.value;
12785
+ }
12786
+ const remote = await completionRemoteReadbacks(effective.observer);
12787
+ if (remote.status !== "ready")
12788
+ return remote;
12789
+ const finalParent = await readSnapshot(observer);
12790
+ if (finalParent.status !== "ok")
12791
+ return finalParent;
12792
+ if (completionParentDrifted(parent.value, finalParent.value)) {
12793
+ return { status: "fatal" };
12794
+ }
12795
+ const final = effective.pinned ? await revalidatePinnedCompletion(effective, initialEffective) : { status: "ready", effective, snapshot: finalParent.value };
12796
+ if (final.status !== "ready")
12797
+ return final;
12754
12798
  return {
12755
12799
  status: "ready",
12756
12800
  readbacks: [
12757
12801
  {
12758
12802
  workspaceIdentity: options.workspaceIdentity,
12759
- repositoryIdentity: effectiveSnapshot.repositoryRevisionDigest,
12760
- worktreeIdentity: effectiveSnapshot.worktreeRevisionDigest,
12761
- operationTargetIdentity: finalEffective.targetIdentity
12803
+ repositoryIdentity: final.snapshot.repositoryRevisionDigest,
12804
+ worktreeIdentity: final.snapshot.worktreeRevisionDigest,
12805
+ operationTargetIdentity: final.effective.targetIdentity
12762
12806
  },
12763
- ...remoteReadbacks.map(({ operation, snapshot }) => remoteReadbackInput(operation, effectiveSnapshot, options.workspaceIdentity, snapshot))
12807
+ ...remote.readbacks.map(({ operation, snapshot }) => remoteReadbackInput(operation, final.snapshot, options.workspaceIdentity, snapshot))
12764
12808
  ]
12765
12809
  };
12766
12810
  }
12811
+ function completionParentDrifted(initial, final) {
12812
+ return final.targetDigest !== initial.targetDigest || final.repositoryRevisionDigest !== initial.repositoryRevisionDigest || final.worktreeRevisionDigest !== initial.worktreeRevisionDigest;
12813
+ }
12814
+ async function revalidatePinnedCompletion(effective, initial) {
12815
+ const lookup = resolveEffectiveObserver();
12816
+ if (lookup.status !== "ok")
12817
+ return lookup;
12818
+ const revalidated = lookup.value;
12819
+ if (revalidated.observer !== effective.observer || revalidated.targetIdentity !== effective.targetIdentity || !revalidated.pinned) {
12820
+ return { status: "fatal" };
12821
+ }
12822
+ const pinned = await readSnapshot(revalidated.observer, revalidated.targetIdentity);
12823
+ if (pinned.status !== "ok")
12824
+ return pinned;
12825
+ if (pinned.value.repositoryRevisionDigest !== initial.repositoryRevisionDigest || pinned.value.worktreeRevisionDigest !== initial.worktreeRevisionDigest) {
12826
+ return { status: "fatal" };
12827
+ }
12828
+ return {
12829
+ status: "ready",
12830
+ effective: revalidated,
12831
+ snapshot: pinned.value
12832
+ };
12833
+ }
12767
12834
  async function completionRemoteReadbacks(observer) {
12768
12835
  const remoteOperations = guard.status().satisfiedOperations.filter(remoteOperation);
12769
12836
  if (remoteOperations.length === 0)
12770
- return [];
12837
+ return { status: "ready", readbacks: [] };
12771
12838
  const remoteSnapshot = observer.remoteSnapshot;
12772
12839
  if (!remoteSnapshot)
12773
- return;
12840
+ return { status: "fatal" };
12774
12841
  const readbacks = [];
12775
12842
  for (const operation of remoteOperations) {
12776
12843
  const result = await readRemoteScope(remoteSnapshot, operation);
12777
- if (result?.status !== "available")
12778
- return;
12844
+ if (isProbeTimeout(result))
12845
+ return { status: "timeout" };
12846
+ if (result?.status !== "available") {
12847
+ return { status: "fatal", reasonCode: remoteFailureReason(result) };
12848
+ }
12779
12849
  readbacks.push({ operation, snapshot: result.snapshot });
12780
12850
  }
12781
- return readbacks;
12851
+ return { status: "ready", readbacks };
12782
12852
  }
12783
12853
  function finishMismatchedTarget(callDigest, pending, output) {
12784
12854
  abandonComplete(callDigest, pending, true);
@@ -12794,11 +12864,34 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
12794
12864
  markUnavailable();
12795
12865
  writeAbandonedCompletionResult(output, finalTarget, "guard-unavailable");
12796
12866
  }
12797
- function finishUnavailableReadback(callDigest, pending, output) {
12867
+ function finishUnavailableReadback(callDigest, pending, output, reasonCode) {
12798
12868
  abandonComplete(callDigest, pending, true);
12799
- markUnavailable();
12869
+ terminalCompletes.set(callDigest, {
12870
+ target: pending.target,
12871
+ status: "unavailable",
12872
+ reasonCode: "finalization-failed"
12873
+ });
12874
+ markUnavailable(observerReadbackFailedCause(reasonCode, "complete-readback"));
12800
12875
  writeAbandonedCompletionResult(output, pending.target, "finalization-failed");
12801
12876
  }
12877
+ function finishReadbackTimeout(callDigest, pending, output) {
12878
+ if (guard.status().state === "unavailable") {
12879
+ finishUnavailableReadback(callDigest, pending, output, "command-timeout");
12880
+ } else {
12881
+ finishRetryableReadback(callDigest, pending, output);
12882
+ }
12883
+ }
12884
+ function finishRetryableReadback(callDigest, pending, output) {
12885
+ abandonComplete(callDigest, pending, true);
12886
+ const terminal = {
12887
+ target: pending.target,
12888
+ status: "rejected",
12889
+ reasonCode: "readback-timeout",
12890
+ title: "Workflow readback timed out"
12891
+ };
12892
+ terminalCompletes.set(callDigest, terminal);
12893
+ writeTerminalCompletionResult(output, terminal, pending.target, terminal.title);
12894
+ }
12802
12895
  async function finishComplete(host, output) {
12803
12896
  const callDigest = digestCall(ledger, host.callID);
12804
12897
  const pending = pendingCompletes.get(callDigest);
@@ -12813,13 +12906,13 @@ function createSessionRuntime(options, operationObservers, recoveredOperationCon
12813
12906
  finishUnreplayableComplete(finalTarget, output);
12814
12907
  return;
12815
12908
  }
12816
- if (!options.observer) {
12817
- finalizeComplete(callDigest, pending, output);
12909
+ const readbacks = await completionReadbacks();
12910
+ if (readbacks.status === "fatal") {
12911
+ finishUnavailableReadback(callDigest, pending, output, readbacks.reasonCode);
12818
12912
  return;
12819
12913
  }
12820
- const readbacks = await completionReadbacks();
12821
- if (readbacks.status === "unavailable") {
12822
- finishUnavailableReadback(callDigest, pending, output);
12914
+ if (readbacks.status === "timeout") {
12915
+ finishReadbackTimeout(callDigest, pending, output);
12823
12916
  return;
12824
12917
  }
12825
12918
  finalizeComplete(callDigest, pending, output, readbacks.status === "ready" ? readbacks.readbacks : undefined);
@@ -13296,10 +13389,10 @@ function createOpencodeWorkflowGuard(options) {
13296
13389
  output: unavailableToolResult()
13297
13390
  }),
13298
13391
  systematic_workflow_status: makeWorkflowTool("Read the bounded guarded workflow status.", statusToolShape, sessionRuntimeFor, async (runtime, input) => {
13299
- await runtime.refreshReadback();
13392
+ const unconfirmed = await runtime.refreshReadback();
13300
13393
  return {
13301
13394
  title: "Workflow guard status",
13302
- output: statusToolSchema.safeParse(input).success ? statusForTool(runtime.readStatus(), runtime.unavailableCause(), runtime.seedDeferrals()) : unavailableToolResult()
13395
+ output: statusToolSchema.safeParse(input).success ? statusForTool(runtime.readStatus(), runtime.unavailableCause(), runtime.seedDeferrals(), unconfirmed) : unavailableToolResult()
13303
13396
  };
13304
13397
  }),
13305
13398
  systematic_workflow_complete: makeWorkflowTool("Request completion of a guarded workflow unit or epoch.", completeToolShape, sessionRuntimeFor, (_runtime, input) => completeToolSchema.safeParse(input).success ? {
@@ -30,6 +30,12 @@ export interface OpencodeWorkflowGuardOptions {
30
30
  readonly sessionLocation?: string;
31
31
  /** Injectable clock (epoch milliseconds); defaults to `Date.now`. */
32
32
  readonly now?: () => number;
33
+ /**
34
+ * Injectable factory for the observer of a registered linked-worktree target;
35
+ * defaults to `createOpencodeOperationObserver`. A test seam: it lets tests
36
+ * control a pinned worktree observer's snapshots.
37
+ */
38
+ readonly createTargetObserver?: (targetDirectory: string) => OpencodeOperationObserver;
33
39
  }
34
40
  export interface OpencodeWorkflowChildSession {
35
41
  readonly sessionId: string;
@@ -6,7 +6,7 @@ export type WorkflowState = 'protected' | 'waiting' | 'rejected' | 'disabled' |
6
6
  export type RepairKind = 'fresh-readback' | 'rerun-operation' | 'question-attestation';
7
7
  export type TransitionTarget = 'unit' | 'epoch';
8
8
  export type EpochFamily = 'work' | 'shipping';
9
- export type WorkflowReasonCode = 'abandoned-transition' | 'call-context-conflict' | 'cancelled-operation' | 'consumed-receipt' | 'disabled' | 'epoch-completed' | 'epoch-mismatch' | 'failed-operation' | 'family-conflict' | 'finalization-failed' | 'foreign-registration' | 'forbidden-field' | 'guard-unavailable' | 'incompatible-receipt' | 'invalid-configuration' | 'invalid-control' | 'invalid-receipt' | 'invalid-transition' | 'missing-evidence' | 'no-supported-repair' | 'no-active-epoch' | 'no-active-unit' | 'no-op-operation' | 'operation-not-required' | 'operation-target-mismatch' | 'receipt-mismatch' | 'rejected-operation' | 'resource-mismatch' | 'running-operation' | 'stale-receipt' | 'transition-finalized' | 'transition-terminal' | 'transition-replayed' | 'unattributed-operation' | 'unit-active' | 'unit-completed' | 'unit-incomplete' | 'unit-mismatch' | 'unit-ready' | 'workspace-mismatch' | 'runtime-scope-conflict' | 'invalid-recovery' | 'recovery-conflict' | 'fork-copy-not-lineage';
9
+ export type WorkflowReasonCode = 'abandoned-transition' | 'call-context-conflict' | 'cancelled-operation' | 'consumed-receipt' | 'disabled' | 'epoch-completed' | 'epoch-mismatch' | 'failed-operation' | 'family-conflict' | 'finalization-failed' | 'foreign-registration' | 'forbidden-field' | 'guard-unavailable' | 'incompatible-receipt' | 'invalid-configuration' | 'invalid-control' | 'invalid-receipt' | 'invalid-transition' | 'missing-evidence' | 'no-supported-repair' | 'no-active-epoch' | 'no-active-unit' | 'no-op-operation' | 'operation-not-required' | 'operation-target-mismatch' | 'readback-timeout' | 'receipt-mismatch' | 'rejected-operation' | 'resource-mismatch' | 'running-operation' | 'stale-receipt' | 'transition-finalized' | 'transition-terminal' | 'transition-replayed' | 'unattributed-operation' | 'unit-active' | 'unit-completed' | 'unit-incomplete' | 'unit-mismatch' | 'unit-ready' | 'workspace-mismatch' | 'runtime-scope-conflict' | 'invalid-recovery' | 'recovery-conflict' | 'fork-copy-not-lineage';
10
10
  export interface WorkflowGuardOptions {
11
11
  ledger: ReceiptLedger;
12
12
  classifier?: ReceiptClassifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fro.bot/systematic",
3
- "version": "3.21.7",
3
+ "version": "3.21.8",
4
4
  "description": "Compound-engineering loops for OpenCode, Pi, and Claude Code",
5
5
  "type": "module",
6
6
  "homepage": "https://fro.bot/systematic",
@@ -18,19 +18,6 @@ var __export = (target, all) => {
18
18
  })
19
19
  }
20
20
 
21
- // node_modules/.bun/zod@4.6.5/node_modules/zod/v4/classic/iso.js
22
- var exports_iso = {}
23
- __export(exports_iso, {
24
- ZodISODate: () => ZodISODate,
25
- ZodISODateTime: () => ZodISODateTime,
26
- ZodISODuration: () => ZodISODuration,
27
- ZodISOTime: () => ZodISOTime,
28
- date: () => date2,
29
- datetime: () => datetime2,
30
- duration: () => duration2,
31
- time: () => time2,
32
- })
33
-
34
21
  // src/ce-review-validator.ts
35
22
  import fs3 from 'node:fs'
36
23
  import { fileURLToPath } from 'node:url'
@@ -6299,6 +6286,17 @@ function superRefine(fn, params) {
6299
6286
  return _superRefine(fn, params)
6300
6287
  }
6301
6288
  // node_modules/.bun/zod@4.6.5/node_modules/zod/v4/classic/iso.js
6289
+ var exports_iso = {}
6290
+ __export(exports_iso, {
6291
+ ZodISODate: () => ZodISODate,
6292
+ ZodISODateTime: () => ZodISODateTime,
6293
+ ZodISODuration: () => ZodISODuration,
6294
+ ZodISOTime: () => ZodISOTime,
6295
+ date: () => date2,
6296
+ datetime: () => datetime2,
6297
+ duration: () => duration2,
6298
+ time: () => time2,
6299
+ })
6302
6300
  function datetime2(params) {
6303
6301
  return _isoDateTime(ZodISODateTime, params)
6304
6302
  }
@@ -114,4 +114,4 @@ The bootstrap inlines the active harness profile naming the exact mechanisms for
114
114
 
115
115
  When a mechanism is unavailable, present numbered options in chat and wait for questions, maintain a visible list for task tracking, and dispatch delegation sequentially or do the work inline.
116
116
 
117
- Check the workflow guard availability once per execution unit. Guard state is per session; a child session starts `inactive`. `inactive` (reason `no-active-epoch`) means no guarded workflow has started in this session. It is not unavailable and not terminal: load a guarded skill to begin, and do not call `systematic_workflow_start` or `systematic_workflow_complete` before one is active. If the guard reports `unavailable` or `guard-unavailable`, treat it as terminal for that unit: do not retry `systematic_workflow_start` or `systematic_workflow_complete`. Use the documented unguarded fallback only when authorized, and report the unavailable state once.
117
+ Check the workflow guard availability once per execution unit. Guard state is per session; a child session starts `inactive`. `inactive` (reason `no-active-epoch`) means no guarded workflow has started in this session. It is not unavailable and not terminal: load a guarded skill to begin, and do not call `systematic_workflow_start` or `systematic_workflow_complete` before one is active. A completion rejected with `readback-timeout` is retryable: call `systematic_workflow_complete` again at most twice, then report it to the user. Probes listed in `unconfirmedReadbacks` on status output (`local`, `pinned`, or an operation name) are unverified until a later status call confirms them. If the guard reports `unavailable` or `guard-unavailable`, treat it as terminal for that unit: do not retry `systematic_workflow_start` or `systematic_workflow_complete`. Use the documented unguarded fallback only when authorized, and report the unavailable state once.