@ordewell/core 0.10.3 → 0.10.5

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 (46) hide show
  1. package/dist/{IFileSystem-DCd-rkeH.d.ts → IFileSystem-ClBdp59f.d.ts} +1 -1
  2. package/dist/{IFileSystem-B8Nkgg4e.d.mts → IFileSystem-Db34maxC.d.mts} +1 -1
  3. package/dist/{IRunner-CXdYyIZo.d.mts → IRunner-Crkt3tHD.d.ts} +64 -3
  4. package/dist/{IRunner-QBdYcatb.d.ts → IRunner-lMQIa5Wc.d.mts} +64 -3
  5. package/dist/{ModeResolver-geqjKkLY.d.mts → ModeResolver-B4hhABNf.d.mts} +1 -1
  6. package/dist/{ModeResolver-BOU90Nn-.d.ts → ModeResolver-CUR5jCSU.d.ts} +1 -1
  7. package/dist/{Task-CRVIqSfy.d.mts → Task-D4QHjdGv.d.mts} +93 -11
  8. package/dist/{Task-CRVIqSfy.d.ts → Task-D4QHjdGv.d.ts} +93 -11
  9. package/dist/{chunk-A57ITQE7.mjs → chunk-4QLFM73A.mjs} +34 -5
  10. package/dist/chunk-4QLFM73A.mjs.map +1 -0
  11. package/dist/{chunk-FH6M5QZG.mjs → chunk-6LEA6WAM.mjs} +88 -7
  12. package/dist/chunk-6LEA6WAM.mjs.map +1 -0
  13. package/dist/{chunk-645FALZX.mjs → chunk-F3KIX7WR.mjs} +3 -3
  14. package/dist/{chunk-OYUSADFM.mjs → chunk-NJGID6BG.mjs} +3 -1
  15. package/dist/chunk-NJGID6BG.mjs.map +1 -0
  16. package/dist/{chunk-SM6BV6XS.mjs → chunk-RT4NQ2BZ.mjs} +3 -1
  17. package/dist/chunk-RT4NQ2BZ.mjs.map +1 -0
  18. package/dist/index.d.mts +307 -66
  19. package/dist/index.d.ts +307 -66
  20. package/dist/index.js +1688 -402
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +1567 -388
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/parsing.d.mts +2 -2
  25. package/dist/parsing.d.ts +2 -2
  26. package/dist/parsing.js.map +1 -1
  27. package/dist/parsing.mjs +3 -3
  28. package/dist/{plan-utils-oC8bO4pN.d.ts → plan-utils-BVJCzNvm.d.ts} +204 -19
  29. package/dist/{plan-utils-KU1Rse82.d.mts → plan-utils-wI8MuDBC.d.mts} +204 -19
  30. package/dist/plan-utils.d.mts +4 -4
  31. package/dist/plan-utils.d.ts +4 -4
  32. package/dist/plan-utils.js +94 -5
  33. package/dist/plan-utils.js.map +1 -1
  34. package/dist/plan-utils.mjs +13 -3
  35. package/dist/testing.d.mts +6 -3
  36. package/dist/testing.d.ts +6 -3
  37. package/dist/testing.js +7 -0
  38. package/dist/testing.js.map +1 -1
  39. package/dist/testing.mjs +7 -2
  40. package/dist/testing.mjs.map +1 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-A57ITQE7.mjs.map +0 -1
  43. package/dist/chunk-FH6M5QZG.mjs.map +0 -1
  44. package/dist/chunk-OYUSADFM.mjs.map +0 -1
  45. package/dist/chunk-SM6BV6XS.mjs.map +0 -1
  46. /package/dist/{chunk-645FALZX.mjs.map → chunk-F3KIX7WR.mjs.map} +0 -0
@@ -155,8 +155,10 @@ interface IsolationRepo {
155
155
  root: string;
156
156
  /** The commit checked out at run start. Switching branches mid-run does not retarget it. */
157
157
  baseRef: string;
158
- /** Branch name checked out at run start; absent on a detached HEAD. */
158
+ /** Branch name checked out at run start; absent on a detached HEAD, and on a record saved before this was noted. */
159
159
  baseBranch?: string;
160
+ /** Set when the run started on a detached HEAD, so that is told from a record that never noted its branch. */
161
+ startedDetached?: true;
160
162
  integrationBranch: string;
161
163
  }
162
164
  /**
@@ -237,6 +239,10 @@ interface IsolationHandoffRepo {
237
239
  path: string;
238
240
  integrationBranch: string;
239
241
  baseRef: string;
242
+ /** The branch the run started on in this repo; absent when it started on a detached HEAD or the record never noted one. */
243
+ baseBranch?: string;
244
+ /** Set when the run started on a detached HEAD. */
245
+ startedDetached?: true;
240
246
  /** Tasks whose work landed in this repo, in plan order. */
241
247
  landed: IsolationLandedTask[];
242
248
  }
@@ -259,27 +265,36 @@ interface IsolationView {
259
265
  /**
260
266
  * Why "Merge all" would not touch a repo. `partial-landing`: a task's landing
261
267
  * was interrupted and could not be rolled back there, so its integration
262
- * branch holds part of a task.
268
+ * branch holds part of a task. `wrong-branch`: the repo is not on the branch
269
+ * the run started on, and the merge would land on some other one.
263
270
  */
264
- type IsolationMergeBlockReason = 'merge-in-progress' | 'conflict' | 'uncommitted-changes' | 'partial-landing' | 'git-error';
271
+ type IsolationMergeBlockReason = 'merge-in-progress' | 'conflict' | 'uncommitted-changes' | 'partial-landing' | 'wrong-branch' | 'git-error';
265
272
  interface IsolationMergeBlock {
266
273
  repo: string;
267
274
  reason: IsolationMergeBlockReason;
268
275
  /** The files that would conflict, or the user's uncommitted ones the merge also changes; empty for the other reasons. */
269
276
  files: string[];
277
+ /** `wrong-branch` only: the branch the run started on. */
278
+ expected?: string;
279
+ /** `wrong-branch` only: the branch checked out now; absent on a detached HEAD. */
280
+ actual?: string;
281
+ /** `wrong-branch` only: the repo is in the middle of a rebase, which is what detached its HEAD. */
282
+ rebasing?: true;
270
283
  }
271
284
  /**
272
285
  * How "Merge all" went.
273
286
  * - `merged`: every repo with work on its integration branch took it.
274
- * - `blocked`: the preflight found repos that could not, so nothing was
287
+ * - `blocked`: a repo was on another branch than the run started on, or the
288
+ * preflight found repos that could not take their merge, so nothing was
275
289
  * touched anywhere; `blocked` says which and why.
276
290
  * - `conflict` / `failed`: a merge stopped in `repo` — on git older than 2.38,
277
291
  * which cannot preflight, or for a reason no preflight could foresee. That
278
292
  * merge was aborted, leaving `repo` as it was; `landed` names the repos
279
293
  * merged before it, which stay merged, and is absent when there are none.
280
294
  *
281
- * A group of one is blocked only by a partial landing; otherwise its one merge
282
- * lands or is aborted whole, so it reports as it always has.
295
+ * A group of one is blocked only by a partial landing or by being on the wrong
296
+ * branch; otherwise its one merge lands or is aborted whole, so it reports as
297
+ * it always has.
283
298
  */
284
299
  type IsolationMergeResult = {
285
300
  outcome: 'merged';
@@ -463,7 +478,7 @@ interface IWorktreeIsolation {
463
478
  * so a crash-recovery prune does not sweep it away; a repair it ends leaves
464
479
  * the task `conflict`, as it was before the repair. Takes the run rather than
465
480
  * a bare task id: ids are only unique within one plan, and one daemon serves
466
- * many (ADR-0007).
481
+ * many (ADR-0025 D2).
467
482
  */
468
483
  release(run: IsolationRun, taskId: string, opts: {
469
484
  keep: boolean;
@@ -561,7 +576,11 @@ interface UsageRecord {
561
576
  amount: number;
562
577
  currency: string;
563
578
  };
564
- /** The model's context window, when the runner itself reports it. */
579
+ /**
580
+ * The model's context window: as the runner or provider reported it, or,
581
+ * when it reported none, from that runner's or provider's own model listing
582
+ * (`ContextWindowFill`). Never from a table kept in Ordewell.
583
+ */
565
584
  contextWindow?: number;
566
585
  /** Set when a subagent made the call; its usage still counts toward the total. */
567
586
  subagentId?: string;
@@ -638,16 +657,41 @@ interface ModelUsage {
638
657
  totals: UsageTotals;
639
658
  }
640
659
  declare function addModelUsage(models: readonly ModelUsage[], record: UsageRecord): ModelUsage[];
660
+ /**
661
+ * What Ordewell has counted of a runner's own session that reports its cost
662
+ * as a running total: that total and each model's share, in USD, as of its
663
+ * last report. A resume of that session counts its first report's growth
664
+ * over this; with no count kept for it, that report only sets the baseline.
665
+ */
666
+ interface RunnerSessionCost {
667
+ sessionId: string;
668
+ usd: number;
669
+ modelUsd: Record<string, number>;
670
+ }
641
671
  interface AttemptUsage extends PlannerUsage {
642
672
  attempt: number;
643
673
  runner: string;
674
+ /** The runner session this attempt ran in, as its runner reported it: what a later Continue of it resumes. */
675
+ sessionId?: string;
644
676
  startedAt: string;
645
677
  endedAt?: string;
646
678
  wallTimeMs: number;
679
+ /** What was counted of its runner session's running cost as it ended: a continue of that session counts on from it. */
680
+ runnerSessionCost?: RunnerSessionCost;
647
681
  }
648
682
  declare function startAttemptUsage(attempt: number, runner: string, startedAt: string): AttemptUsage;
649
683
  declare function addAttemptUsage(usage: AttemptUsage, record: UsageRecord, now: string): AttemptUsage;
650
- declare function endAttemptUsage(usage: AttemptUsage, now: string): AttemptUsage;
684
+ declare function endAttemptUsage(usage: AttemptUsage, now: string, runnerSessionCost?: RunnerSessionCost, sessionId?: string): AttemptUsage;
685
+ /** The count a continue of `sessionId` starts from: the one its latest attempt in that session ended with. */
686
+ declare function countedSessionCost(attempts: readonly AttemptUsage[] | undefined, sessionId: string): RunnerSessionCost | undefined;
687
+ /**
688
+ * The model a continue's session last ran on and the window it was measured
689
+ * against: the latest earlier attempt of that same runner session that
690
+ * reported one. An attempt that measured nothing is skipped — a continuation
691
+ * does not undo what its session was last measured against — and a window is
692
+ * never borrowed from another session: a fresh attempt starts one.
693
+ */
694
+ declare function resumedSessionWindow(attempts: readonly AttemptUsage[] | undefined, runner: string, attempt: number, sessionId: string): Pick<PlannerUsage, 'source' | 'model' | 'contextWindow'> | undefined;
651
695
  interface PlanUsage {
652
696
  totals: UsageTotals;
653
697
  byModel: ModelUsage[];
@@ -660,6 +704,21 @@ interface UsageTask {
660
704
  subtasks?: readonly UsageTask[];
661
705
  }
662
706
  declare function planUsage(tasks: readonly UsageTask[]): PlanUsage;
707
+ /**
708
+ * What one task spent across every attempt and every model it ran on, so a
709
+ * stop, a model change and a continue never makes the earlier spend vanish. The
710
+ * context meter is the exception: it reads the latest attempt, because only the
711
+ * current model's window says how full the next prompt is.
712
+ */
713
+ interface TaskUsageSummary {
714
+ totals: UsageTotals;
715
+ attempts: number;
716
+ contextFill?: {
717
+ usedTokens: number;
718
+ windowTokens: number;
719
+ };
720
+ }
721
+ declare function taskUsageSummary(task: Pick<UsageTask, 'attemptUsage'>): TaskUsageSummary;
663
722
 
664
723
  /**
665
724
  * How far a plan's supervisor may act in its wake-up turns (ADR-0029): a plan
@@ -993,6 +1052,13 @@ interface Task {
993
1052
  userStoriesCovered?: string[];
994
1053
  /** The runner's saved session for a later continue; cleared when a fresh attempt starts. */
995
1054
  runnerSessionId?: string;
1055
+ /**
1056
+ * The runner that session belongs to: a session cannot cross runners, so
1057
+ * Continue is offered only while the task is still assigned to it. Absent
1058
+ * on a plan saved before it was recorded; the last attempt's runner stands
1059
+ * in (see `sessionOwner`).
1060
+ */
1061
+ runnerSessionOwner?: RunnerId;
996
1062
  /** Set only while `status` is `awaiting_user`, and not always then — a pause saved by an older build has none. */
997
1063
  awaitingReason?: AwaitingReason;
998
1064
  /**
@@ -1177,10 +1243,13 @@ interface ConversationMessage {
1177
1243
  * (ADR-0029), its record in `execution`. 'wake_up' is the digest a wake-up
1178
1244
  * gave the supervisor (role 'user': the model was told it), and
1179
1245
  * 'supervisor' what the supervisor said in a wake-up turn (ADR-0029).
1246
+ * 'error' is a planner turn that ended on the planner's usage limit, drawn
1247
+ * as a failure and never replayed to the planner: it is not the planner's
1248
+ * answer, and its inputs are sent again (see {@link PlannerResendState}).
1180
1249
  * Absent for ordinary chat turns, so sessions saved before markers existed
1181
1250
  * degrade gracefully.
1182
1251
  */
1183
- kind?: 'plan_generated' | 'system' | 'compaction' | 'skill_load' | 'execution' | 'wake_up' | 'supervisor';
1252
+ kind?: 'plan_generated' | 'system' | 'compaction' | 'skill_load' | 'execution' | 'wake_up' | 'supervisor' | 'error';
1184
1253
  actor?: 'Ordewell setting';
1185
1254
  /** Present exactly when `kind` is 'skill_load'. */
1186
1255
  skill?: SkillLoad;
@@ -1268,6 +1337,17 @@ interface SupervisionSnapshot {
1268
1337
  /** The events inside their debounce window and the wake-up rate's timestamps. */
1269
1338
  wake?: SupervisorSnapshot;
1270
1339
  }
1340
+ /**
1341
+ * What waits on the planner's usage limit. With `at`, the inputs no turn
1342
+ * answered are sent again then, on their own; without it — the reset could
1343
+ * not be read, the resend hit the limit again, or it was cancelled — they go
1344
+ * with the next input: the user's message, or a wake-up.
1345
+ */
1346
+ interface PlannerResendState {
1347
+ /** The runner whose account hit the limit; a planner on another one is not held by it. */
1348
+ runner?: RunnerId;
1349
+ at?: string;
1350
+ }
1271
1351
  interface LegacyPlanState {
1272
1352
  runSettings?: RunSettings;
1273
1353
  /** What supervision remembers across a daemon restart (ADR-0029); absent on plans saved before it existed. */
@@ -1295,6 +1375,8 @@ interface LegacyPlanState {
1295
1375
  isolation?: PlanIsolation;
1296
1376
  /** Kept so a reopened session shows the same token line (#49). */
1297
1377
  plannerUsage?: PlannerUsage;
1378
+ /** The planner hit its usage limit and the inputs its turn took wait to be sent again; absent otherwise. */
1379
+ plannerResend?: PlannerResendState;
1298
1380
  /**
1299
1381
  * The tasks the user approved to run: every task when they executed the
1300
1382
  * plan, and each one they started or retried themselves since. A command
@@ -1385,4 +1467,4 @@ type ApprovalRecord = Pick<LegacyPlanState, 'approved' | 'approvedTasks'>;
1385
1467
  */
1386
1468
  declare function waitsForApproval(task: Pick<Task, 'id' | 'type' | 'status'>, record: ApprovalRecord): boolean;
1387
1469
 
1388
- export { type ResearchStepOutcome as $, type ApprovalRecord as A, BUILTIN_SKILL_NAMES as B, type ConversationMessage as C, DEFAULT_RUNNERS as D, type ExecutionActor as E, type IsolationTaskStatus as F, type GuardTarget as G, type IsolationView as H, type IWorktreeIsolation as I, type PlanIsolation as J, type PlanState as K, type LegacyPlanState as L, type ModelUsage as M, type PlanStatus as N, type PlanUsage as O, type PendingPlanTurn as P, type PlannerUsage as Q, type PrepareIntent as R, type PreparedTask as S, type PreservedWork as T, type PreviousWork as U, type RefusedRemoval as V, type RepairEvidence as W, type RepoGroupLayout as X, type ResearchLogEntry as Y, type ResearchProgress as Z, type ResearchStep as _, type AttemptUsage as a, type ResearchToolType as a0, type RunSettings as a1, type RunnerId as a2, type SetupFailure as a3, type ShadowedSkill as a4, type SkillAppliesTo as a5, type SkillCatalog as a6, type SkillInfo as a7, type SkillLoad as a8, type SkillLoadNotice as a9, createEmptyPlan as aA, createSkillsService as aB, createTask as aC, endAttemptUsage as aD, flattenTasks as aE, flattenTasksWithParents as aF, isAwaitingReason as aG, isMeasured as aH, isSupervisorLevel as aI, isUserMessage as aJ, migratePlanState as aK, partedPromptUsage as aL, pausedOnLimit as aM, planUsage as aN, plannerContextFill as aO, rejoinPlanTree as aP, startAttemptUsage as aQ, usageLine as aR, waitsForApproval as aS, type SkillMetadata as aa, type SkillSource as ab, SkillsService as ac, type SubagentOutcome as ad, type SupervisorLevel as ae, type Task as af, type TaskDiffRead as ag, type TaskDiffResult as ah, type TaskIsolation as ai, type TaskIsolationState as aj, type TaskModelAssignment as ak, type TaskSkillNotice as al, type TaskSkillSnapshot as am, type TaskSnapshot as an, type TaskStatus as ao, type TreeSnapshot as ap, type UsageLine as aq, type UsageRecord as ar, type UsageTotals as as, type Verdict as at, type VerificationCheck as au, addAttemptUsage as av, addModelUsage as aw, addPlannerUsage as ax, addUsage as ay, addUsageTotals as az, type AwaitingReason as b, DEFAULT_SUPERVISOR_RETRY_LIMIT as c, type DiscoveredModel as d, type ExecutionCommandName as e, type ExecutionRecord as f, type GuardTrip as g, type IntegrationDisposal as h, type InvalidSkill as i, type IsolationAvailability as j, type IsolationHandoff as k, type IsolationHandoffRepo as l, type IsolationInactiveReason as m, type IsolationLandedTask as n, type IsolationLanding as o, type IsolationMergeBlock as p, type IsolationMergeBlockReason as q, type IsolationMergeResult as r, type IsolationOutcome as s, type IsolationPruneResult as t, type IsolationRemoval as u, type IsolationRepo as v, type IsolationRun as w, type IsolationTaskRecord as x, type IsolationTaskRef as y, type IsolationTaskRepo as z };
1470
+ export { type ResearchStep as $, type ApprovalRecord as A, BUILTIN_SKILL_NAMES as B, type ConversationMessage as C, DEFAULT_RUNNERS as D, type ExecutionActor as E, type IsolationTaskStatus as F, type GuardTarget as G, type IsolationView as H, type IWorktreeIsolation as I, type PlanIsolation as J, type PlanState as K, type LegacyPlanState as L, type ModelUsage as M, type PlanStatus as N, type PlanUsage as O, type PendingPlanTurn as P, type PlannerResendState as Q, type PlannerUsage as R, type PrepareIntent as S, type PreparedTask as T, type PreservedWork as U, type PreviousWork as V, type RefusedRemoval as W, type RepairEvidence as X, type RepoGroupLayout as Y, type ResearchLogEntry as Z, type ResearchProgress as _, type AttemptUsage as a, type ResearchStepOutcome as a0, type ResearchToolType as a1, type RunSettings as a2, type RunnerId as a3, type RunnerSessionCost as a4, type SetupFailure as a5, type ShadowedSkill as a6, type SkillAppliesTo as a7, type SkillCatalog as a8, type SkillInfo as a9, addPlannerUsage as aA, addUsage as aB, addUsageTotals as aC, countedSessionCost as aD, createEmptyPlan as aE, createSkillsService as aF, createTask as aG, endAttemptUsage as aH, flattenTasks as aI, flattenTasksWithParents as aJ, isAwaitingReason as aK, isMeasured as aL, isSupervisorLevel as aM, isUserMessage as aN, migratePlanState as aO, partedPromptUsage as aP, pausedOnLimit as aQ, planUsage as aR, plannerContextFill as aS, rejoinPlanTree as aT, resumedSessionWindow as aU, startAttemptUsage as aV, taskUsageSummary as aW, usageLine as aX, waitsForApproval as aY, type SkillLoad as aa, type SkillLoadNotice as ab, type SkillMetadata as ac, type SkillSource as ad, SkillsService as ae, type SubagentOutcome as af, type SupervisorLevel as ag, type Task as ah, type TaskDiffRead as ai, type TaskDiffResult as aj, type TaskIsolation as ak, type TaskIsolationState as al, type TaskModelAssignment as am, type TaskSkillNotice as an, type TaskSkillSnapshot as ao, type TaskSnapshot as ap, type TaskStatus as aq, type TaskUsageSummary as ar, type TreeSnapshot as as, type UsageLine as at, type UsageRecord as au, type UsageTotals as av, type Verdict as aw, type VerificationCheck as ax, addAttemptUsage as ay, addModelUsage as az, type AwaitingReason as b, DEFAULT_SUPERVISOR_RETRY_LIMIT as c, type DiscoveredModel as d, type ExecutionCommandName as e, type ExecutionRecord as f, type GuardTrip as g, type IntegrationDisposal as h, type InvalidSkill as i, type IsolationAvailability as j, type IsolationHandoff as k, type IsolationHandoffRepo as l, type IsolationInactiveReason as m, type IsolationLandedTask as n, type IsolationLanding as o, type IsolationMergeBlock as p, type IsolationMergeBlockReason as q, type IsolationMergeResult as r, type IsolationOutcome as s, type IsolationPruneResult as t, type IsolationRemoval as u, type IsolationRepo as v, type IsolationRun as w, type IsolationTaskRecord as x, type IsolationTaskRef as y, type IsolationTaskRepo as z };
@@ -12,7 +12,7 @@ import {
12
12
  resolveTaskRef,
13
13
  skillNames,
14
14
  updateTaskInPlan
15
- } from "./chunk-SM6BV6XS.mjs";
15
+ } from "./chunk-RT4NQ2BZ.mjs";
16
16
 
17
17
  // src/services/JsonExtractor.ts
18
18
  var PLAN_ENVELOPE_KEY = "tasks";
@@ -301,7 +301,7 @@ function blockedByLabel(refs) {
301
301
  function skippedLabel(reason) {
302
302
  return reason ? `Skipped: ${reason}` : "Skipped";
303
303
  }
304
- var WAITS_FOR_APPROVAL_LABEL = "Waiting for your approval to start";
304
+ var WAITS_FOR_APPROVAL_LABEL = "Waits for your approval";
305
305
  function approvalLabel(count) {
306
306
  if (!count) return null;
307
307
  return count > 1 ? `Waiting for approval (${count})` : "Waiting for approval";
@@ -369,7 +369,14 @@ function clampThinkingEffort(effort, variants) {
369
369
  }
370
370
  return void 0;
371
371
  }
372
- function coerceAssignments(tasks, perRunnerAllowlist, modelsByRunner) {
372
+ function coerceAssignments(tasks, perRunnerAllowlist, modelsByRunner, planned = []) {
373
+ const prior = new Map(flattenTasks(planned).map((t) => [t.id, t]));
374
+ const unwritten = (task) => {
375
+ const was = prior.get(task.id);
376
+ if (!was?.assignedModel || !task.assignedModel || was.assignedRunner !== task.assignedRunner) return void 0;
377
+ if (was.assignedModel.modelId !== task.assignedModel.modelId || was.assignedModel.thinkingEffort !== task.assignedModel.thinkingEffort) return void 0;
378
+ return was;
379
+ };
373
380
  const clampVariant = (task) => {
374
381
  if (!task.assignedModel || !modelsByRunner) return task;
375
382
  const model = modelsByRunner[task.assignedRunner]?.find(
@@ -398,6 +405,11 @@ function coerceAssignments(tasks, perRunnerAllowlist, modelsByRunner) {
398
405
  };
399
406
  const coerceOne = (task) => {
400
407
  if (task.type === "user") return task;
408
+ const kept = unwritten(task);
409
+ if (kept) {
410
+ const left = { ...task, assignedModel: kept.assignedModel };
411
+ return kept.status === "in_progress" || kept.status === "awaiting_user" ? left : clampVariant(left);
412
+ }
401
413
  const allowlist = allowedFor(task.assignedRunner);
402
414
  if (!task.assignedModel) {
403
415
  if (allowlist && allowlist.length > 0) {
@@ -594,6 +606,15 @@ function lockedTaskRefusal(task, action = "changed") {
594
606
  if (task.status === "completed") return `"${task.title}" is completed and cannot be ${action}: rearm it to run it again, or add a new task for further work`;
595
607
  return null;
596
608
  }
609
+ function liveModelRefusal(task) {
610
+ return `"${task.title}" has a live runner, so its model and effort cannot change now: stop the task first, or use the runner's own /model`;
611
+ }
612
+ function liveRunnerRefusal(task) {
613
+ return `"${task.title}" has a live runner, so its runner cannot change now: stop the task first`;
614
+ }
615
+ function sameAssignment(a, b) {
616
+ return a?.modelId === b?.modelId && a?.thinkingEffort === b?.thinkingEffort;
617
+ }
597
618
  var AI_ONLY_FIELDS = ["assignedModel", "taskMode", "autonomy", "ops"];
598
619
  function checkModelAndModeValidity(runner, assignedModel, taskMode, catalog) {
599
620
  if (!catalog) return { ok: true };
@@ -653,11 +674,18 @@ function validateTaskEdit(actor, tasks, taskId, changes, catalog) {
653
674
  const { task: target, parent } = found;
654
675
  const locked = actor === "planner" ? lockedTaskRefusal(target, "modified") : null;
655
676
  if (locked) return { ok: false, error: locked };
677
+ const coherence = typeCoherenceCheck(target, changes);
678
+ const landing = coherence?.clear?.includes("assignedModel") ? { ...changes, assignedModel: void 0 } : changes;
679
+ if ("assignedModel" in landing && !sameAssignment(landing.assignedModel, target.assignedModel) && catalog?.liveRunner?.(taskId)) {
680
+ return { ok: false, error: liveModelRefusal(target) };
681
+ }
682
+ if ("assignedRunner" in changes && changes.assignedRunner !== target.assignedRunner && catalog?.liveRunner?.(taskId)) {
683
+ return { ok: false, error: liveRunnerRefusal(target) };
684
+ }
656
685
  if (changes.dependencies) {
657
686
  const depCheck = canSetDependencies(parent?.subtasks ?? tasks, taskId, changes.dependencies);
658
687
  if (!depCheck.ok) return depCheck;
659
688
  }
660
- const coherence = typeCoherenceCheck(target, changes);
661
689
  if (coherence && !coherence.ok) return coherence;
662
690
  const ops = opsCheck(target, parent !== null, changes);
663
691
  if (ops) return ops;
@@ -1363,6 +1391,7 @@ export {
1363
1391
  requestedSkills,
1364
1392
  plannedTask,
1365
1393
  checkPlanInvariants,
1394
+ liveRunnerRefusal,
1366
1395
  validateTaskEdit,
1367
1396
  UPDATABLE_FIELDS,
1368
1397
  taskOpsProtocol,
@@ -1375,4 +1404,4 @@ export {
1375
1404
  canSplitTask,
1376
1405
  applyTaskOps
1377
1406
  };
1378
- //# sourceMappingURL=chunk-A57ITQE7.mjs.map
1407
+ //# sourceMappingURL=chunk-4QLFM73A.mjs.map