@kynver-app/runtime 0.1.76 → 0.1.77

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/cli.js CHANGED
@@ -1813,7 +1813,9 @@ function computeWorkerStatus(worker, options = {}) {
1813
1813
  finalResult,
1814
1814
  error,
1815
1815
  changedFiles,
1816
- gitAncestry
1816
+ gitAncestry,
1817
+ instructionPolicyFingerprint: worker.instructionPolicyFingerprint ?? null,
1818
+ instructionPolicyEvidence: worker.instructionPolicyEvidence ?? null
1817
1819
  };
1818
1820
  }
1819
1821
  function isFinishedWorkerStatus(status) {
@@ -3600,6 +3602,21 @@ function persistCompletionAck(worker, runId, fields) {
3600
3602
  saveWorker(runId, worker);
3601
3603
  }
3602
3604
 
3605
+ // src/completion-replay.ts
3606
+ function trimBlocker(value) {
3607
+ if (typeof value !== "string") return null;
3608
+ const trimmed = value.trim();
3609
+ return trimmed.length ? trimmed : null;
3610
+ }
3611
+ function shouldReplayHarnessCompletion(worker) {
3612
+ if (trimBlocker(worker.completionBlocker)) return true;
3613
+ if (worker.completionOutcome === "rejected") return true;
3614
+ return false;
3615
+ }
3616
+ function hasTerminalCompletionAck(worker) {
3617
+ return hasCompletionAck(worker) && !shouldReplayHarnessCompletion(worker);
3618
+ }
3619
+
3603
3620
  // src/worker-ops.ts
3604
3621
  import path17 from "node:path";
3605
3622
 
@@ -4418,7 +4435,7 @@ async function tryCompleteWorker(args) {
4418
4435
  return { ok: true, skipped: true, reason: "worker-not-finished" };
4419
4436
  }
4420
4437
  const forceReplay = args.force === true || args.force === "true";
4421
- if (!forceReplay && hasCompletionAck(worker)) {
4438
+ if (!forceReplay && hasTerminalCompletionAck(worker)) {
4422
4439
  return {
4423
4440
  ok: true,
4424
4441
  skipped: true,
@@ -4810,7 +4827,7 @@ async function autoCompleteWorker(raw) {
4810
4827
  reason: "worker has no agentOsId/taskId \u2014 nothing to attribute completion to"
4811
4828
  };
4812
4829
  }
4813
- if (hasCompletionAck(worker)) {
4830
+ if (hasTerminalCompletionAck(worker)) {
4814
4831
  return {
4815
4832
  worker: worker.name,
4816
4833
  runId: worker.runId,
@@ -4823,7 +4840,7 @@ async function autoCompleteWorker(raw) {
4823
4840
  const startMs = Date.now();
4824
4841
  while (true) {
4825
4842
  worker = loadWorker(args.run, args.name);
4826
- if (hasCompletionAck(worker)) {
4843
+ if (hasTerminalCompletionAck(worker)) {
4827
4844
  return {
4828
4845
  worker: worker.name,
4829
4846
  runId: worker.runId,
@@ -6122,7 +6139,23 @@ async function dispatchRun(args) {
6122
6139
  for (const decision of result.started) {
6123
6140
  shouldContinueDispatch = await spawnClaimed(decision) && shouldContinueDispatch;
6124
6141
  }
6125
- skipped.push(...result.skipped ?? []);
6142
+ skipped.push(
6143
+ ...result.skipped ?? []
6144
+ );
6145
+ if (exactTargetMode) {
6146
+ for (const skipDecision of skipped) {
6147
+ const taskId = String(skipDecision.task.id);
6148
+ if (!exactTargetIds.has(taskId)) continue;
6149
+ outcomes.push({
6150
+ taskId,
6151
+ started: false,
6152
+ error: `exact_target_not_started:${skipDecision.skipReason}`,
6153
+ skipReason: skipDecision.skipReason,
6154
+ detail: skipDecision.reason ?? null,
6155
+ requestedTargetTaskIds: [...exactTargetIds]
6156
+ });
6157
+ }
6158
+ }
6126
6159
  if (exactTargetMode) shouldContinueDispatch = false;
6127
6160
  while (shouldContinueDispatch && outcomes.length < cappedStarts) {
6128
6161
  if (exactTargetMode) break;
@@ -7074,6 +7107,24 @@ async function runPipelineDispatch(args, slots) {
7074
7107
  };
7075
7108
  }
7076
7109
 
7110
+ // src/pipeline-exact-targets.ts
7111
+ function operatorExactTargetTaskIds(operatorTick) {
7112
+ if (!operatorTick || typeof operatorTick !== "object") return [];
7113
+ const body = operatorTick;
7114
+ const raw = body.response?.dispatch?.exactTargetTaskIds;
7115
+ if (!Array.isArray(raw)) return [];
7116
+ const seen = /* @__PURE__ */ new Set();
7117
+ const out = [];
7118
+ for (const value of raw) {
7119
+ if (typeof value !== "string") continue;
7120
+ const id = value.trim();
7121
+ if (!id || seen.has(id)) continue;
7122
+ seen.add(id);
7123
+ out.push(id);
7124
+ }
7125
+ return out;
7126
+ }
7127
+
7077
7128
  // src/pipeline-max-starts.ts
7078
7129
  function operatorDispatchFromTick(operatorTick) {
7079
7130
  const body = operatorTick;
@@ -8560,7 +8611,7 @@ async function completeFinishedWorkers(runId, args) {
8560
8611
  void 0
8561
8612
  );
8562
8613
  if (!worker?.taskId || worker.localOnly) continue;
8563
- if (hasCompletionAck(worker)) {
8614
+ if (hasTerminalCompletionAck(worker)) {
8564
8615
  outcomes.push({ worker: name, ok: true, taskId: worker.taskId ?? null, skipped: true });
8565
8616
  continue;
8566
8617
  }
@@ -8629,24 +8680,50 @@ async function runPipelineTick(args) {
8629
8680
  let maxStarts = maxStartsAdvice.maxStarts;
8630
8681
  const sweep = await sweepRun({ run: runId, agentOsId, pipeline: true, ...args });
8631
8682
  let dispatch = null;
8632
- if (execute && maxStarts > 0) {
8633
- dispatch = await runPipelineDispatch(
8683
+ let startedCount = 0;
8684
+ const exactTargetTaskIds = operatorExactTargetTaskIds(operatorTick);
8685
+ let remainingStarts = maxStarts;
8686
+ if (execute && remainingStarts > 0 && exactTargetTaskIds.length > 0) {
8687
+ const exactBudget = Math.min(remainingStarts, exactTargetTaskIds.length);
8688
+ const exact = await runPipelineDispatch(
8689
+ {
8690
+ ...args,
8691
+ run: runId,
8692
+ agentOsId,
8693
+ targetTaskIds: exactTargetTaskIds.join(",")
8694
+ },
8695
+ exactBudget
8696
+ );
8697
+ const exactStarted = countDispatchStarts(exact);
8698
+ startedCount += exactStarted;
8699
+ remainingStarts = Math.max(0, remainingStarts - exactStarted);
8700
+ dispatch = { exactTargetTaskIds, exact, startedCount };
8701
+ }
8702
+ if (execute && remainingStarts > 0) {
8703
+ const broad = await runPipelineDispatch(
8634
8704
  {
8635
8705
  ...args,
8636
8706
  run: runId,
8637
8707
  agentOsId
8638
8708
  },
8639
- maxStarts
8709
+ remainingStarts
8640
8710
  );
8641
- } else {
8642
- dispatch = {
8643
- ok: true,
8644
- skipped: true,
8645
- reason: execute ? dispatchResourceGate.reason ?? "no slots or queued work" : "execute disabled",
8646
- maxStarts: 0
8647
- };
8711
+ const broadStarted = countDispatchStarts(broad);
8712
+ startedCount += broadStarted;
8713
+ dispatch = dispatch && typeof dispatch === "object" ? { ...dispatch, broad, startedCount } : broad;
8714
+ } else if (!execute || maxStarts <= 0) {
8715
+ if (!dispatch) {
8716
+ dispatch = {
8717
+ ok: true,
8718
+ skipped: true,
8719
+ reason: execute ? dispatchResourceGate.reason ?? "no slots or queued work" : "execute disabled",
8720
+ maxStarts: 0,
8721
+ ...exactTargetTaskIds.length ? { exactTargetTaskIds, exactOnly: true } : {}
8722
+ };
8723
+ }
8724
+ } else if (dispatch && typeof dispatch === "object") {
8725
+ dispatch = { ...dispatch, broadSkipped: true, startedCount };
8648
8726
  }
8649
- const startedCount = dispatch?.startedCount ?? 0;
8650
8727
  const idle = !maxStartsAdvice.underutilized && maxStarts === 0 && completedWorkers.length === 0 && startedCount === 0;
8651
8728
  return {
8652
8729
  runId,