@linxin666/dsh-client-ui-task-board 0.4.8 → 0.4.10
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/README.i18n.yaml +2 -2
- package/README.md +28 -22
- package/README.zh.md +28 -22
- package/lib/client.js +1435 -682
- package/lib/client.js.map +1 -1
- package/lib/index.js +356 -366
- package/lib/types/client/PluginSettingsCard.d.ts +21 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +7 -0
- package/lib/types/client/board/ExecutionLog.d.ts +16 -0
- package/lib/types/client/board/TaskForm.d.ts +4 -0
- package/lib/types/client/board/VerificationReport.d.ts +2 -15
- package/lib/types/client/body-mutations.d.ts +45 -0
- package/lib/types/client/locales.d.ts +42 -6
- package/lib/types/client/suppress-schedule-row.d.ts +86 -0
- package/lib/types/core/controller.d.ts +1 -1
- package/lib/types/core/subtask.d.ts +59 -49
- package/lib/types/core/tasks.d.ts +5 -8
- package/lib/types/core/use-cases/task-update.d.ts +1 -1
- package/lib/types/core/workspace-target.d.ts +23 -3
- package/lib/types/host/launch-admission.d.ts +8 -9
- package/lib/types/host-ledger.d.ts +72 -48
- package/lib/types/host-routes.d.ts +49 -0
- package/lib/types/host-runner.d.ts +20 -10
- package/lib/types/host-service.d.ts +7 -50
- package/lib/types/index.d.ts +61 -63
- package/lib/types/loopback.d.ts +21 -0
- package/lib/types/protocol.d.ts +0 -5
- package/lib/types/tool-surface.d.ts +1 -0
- package/package.json +25 -25
- package/src/client/CardDefaultPresetField.tsx +1 -1
- package/src/client/PluginSettingsCard.tsx +78 -18
- package/src/client/TaskBoardSettingsCard.tsx +68 -25
- package/src/client/board/ExecutionLog.tsx +140 -0
- package/src/client/board/LinkSubtaskModal.tsx +1 -9
- package/src/client/board/NewTaskModal.tsx +2 -11
- package/src/client/board/TaskCard.tsx +45 -23
- package/src/client/board/TaskDetail.tsx +407 -261
- package/src/client/board/TaskForm.tsx +19 -4
- package/src/client/board/VerificationReport.tsx +143 -104
- package/src/client/board/task-markdown.module.css +11 -8
- package/src/client/board-settings.module.css +35 -7
- package/src/client/board.module.css +855 -115
- package/src/client/body-mutations.ts +133 -0
- package/src/client/index.ts +10 -0
- package/src/client/locales.ts +97 -24
- package/src/client/settings-card.module.css +71 -10
- package/src/client/suppress-schedule-row.ts +198 -0
- package/src/core/controller.ts +1 -3
- package/src/core/subtask.ts +81 -76
- package/src/core/tasks.ts +5 -9
- package/src/core/use-cases/task-update.ts +1 -3
- package/src/core/workspace-target.ts +27 -3
- package/src/host/agent-tools.ts +14 -15
- package/src/host/launch-admission.ts +8 -9
- package/src/host-ledger.ts +158 -125
- package/src/host-routes.ts +65 -2
- package/src/host-runner.ts +53 -28
- package/src/host-service.ts +42 -127
- package/src/index.ts +84 -106
- package/src/loopback.ts +32 -0
- package/src/protocol.ts +2 -9
- package/src/tool-surface.ts +1 -0
- package/lib/types/client/board/team-run-promotion.d.ts +0 -26
- package/src/client/board/team-run-promotion.ts +0 -39
package/src/host/agent-tools.ts
CHANGED
|
@@ -132,9 +132,12 @@ function executionView(execution: ExecutionRecord): Record<string, unknown> {
|
|
|
132
132
|
...(execution.initiatedBy === undefined ? {} : { initiatedBy: execution.initiatedBy }),
|
|
133
133
|
// Set only by record-external-outcome: the Host observed no session for it.
|
|
134
134
|
...(execution.external === true ? { external: true } : {}),
|
|
135
|
+
// Every Host run joins a run group (single-member for a new run, and
|
|
136
|
+
// multi-member for a group the ledger stored before it stopped spreading one
|
|
137
|
+
// run across a subtree); the field keeps its historical name.
|
|
135
138
|
...(execution.runGroupId === undefined ? {} : { cascade: true }),
|
|
136
|
-
// A
|
|
137
|
-
// its
|
|
139
|
+
// A parent of a stored group has settled its own turn but still waits for
|
|
140
|
+
// its members; that is not a stuck card and the model must not retry it.
|
|
138
141
|
...(execution.ownResult === undefined
|
|
139
142
|
? {}
|
|
140
143
|
: { ownResult: execution.ownResult, awaitingSubtasks: execution.endedAt === undefined }),
|
|
@@ -277,7 +280,7 @@ function buildSetParentTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
277
280
|
description: [
|
|
278
281
|
'Attach an existing task under a parent (making it a subtask) or detach it back to the root board by setting its parentId.',
|
|
279
282
|
'Pass an empty parentId to detach.',
|
|
280
|
-
'The Host refuses the link when the parent is unknown or archived, when the moved task is one of its own descendants, when the resulting depth exceeds the deployment subtask limit (default one level, maximum three), or while the task has an unsettled execution (its link may still be a
|
|
283
|
+
'The Host refuses the link when the parent is unknown or archived, when the moved task is one of its own descendants, when the resulting depth exceeds the deployment subtask limit (default one level, maximum three), or while the task has an unsettled execution (its link may still be a stored run group parent pointer).',
|
|
281
284
|
'Running a task opens one run group over its subtree concurrently and leaves a subtask that already sits in the done column alone; a parent card settles only after its own turn and every direct subtask it opened have settled.',
|
|
282
285
|
].join(' '),
|
|
283
286
|
parameters: {
|
|
@@ -307,14 +310,13 @@ function buildRunTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
307
310
|
name: 'task_board_run',
|
|
308
311
|
description: [
|
|
309
312
|
'Run a task on the board now, or re-run a settled one.',
|
|
310
|
-
'Running a
|
|
311
|
-
'
|
|
313
|
+
'Running a card opens ONE session for that card: no session is opened for its subtasks, and the card agent dispatches them itself with subagent. A card whose subtasks are still unfinished runs under the liangshen agent preset and is told which cards to pick up.',
|
|
314
|
+
'Clicking a subtask runs that subtask as its own root, again without opening anything for its descendants.',
|
|
312
315
|
'A card whose effective permission is above the deployment session default is refused with confirmation-required until a HUMAN confirms the binding in the board UI; this tool cannot confirm it.',
|
|
313
|
-
'A card whose task carries teamRun instead starts ONE Team Lead session and the Host spawns a teammate per subtask inside it, so those cards run as an Agent Team rather than as independent sessions; that mode needs the deployment Agent Teams service and is refused when it is missing.',
|
|
314
316
|
'Executions consume real API quota. Sessions are created asynchronously, so read their ids and outcomes back with task_board_get.',
|
|
315
317
|
].join(' '),
|
|
316
318
|
parameters: {
|
|
317
|
-
taskId: { type: 'string', required: true, description: 'The task to run;
|
|
319
|
+
taskId: { type: 'string', required: true, description: 'The task to run; only this card gets a session, its unfinished subtasks are dispatched by that session own agent.' },
|
|
318
320
|
rerun: { type: 'boolean', description: 'Re-run a settled task: reset its column to todo before starting (default false).' },
|
|
319
321
|
},
|
|
320
322
|
output: { schema: { type: 'json' }, render: renderJson },
|
|
@@ -341,7 +343,7 @@ function buildRunTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
341
343
|
ok: true,
|
|
342
344
|
started,
|
|
343
345
|
...(root === undefined ? {} : { task: taskSummary(root, snapshot.tasks, snapshot.sessionDefaultPermission) }),
|
|
344
|
-
note: 'Executions run asynchronously; call task_board_get to read session ids and the settled outcome.
|
|
346
|
+
note: 'Executions run asynchronously; call task_board_get to read session ids and the settled outcome.',
|
|
345
347
|
})
|
|
346
348
|
} catch (error) {
|
|
347
349
|
const message = messageOf(error)
|
|
@@ -358,7 +360,7 @@ function buildManageTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
358
360
|
'Move, archive, restore, delete, or settle one task board card.',
|
|
359
361
|
'move-backlog, move-todo, move-running, move-done and move-failed are the manual column moves and cover every column; a card the runner is executing (one with an open execution) cannot be moved.',
|
|
360
362
|
'A manual move writes the card column only and never fabricates an execution record, so the card reports a declaration rather than evidence of a run: done/failed declare work finished (or failed) outside a Host-run execution — human work, an external system, a decision made elsewhere — and running says the work is under way without a tracked session. Use task_board_run when the work should actually run in a session here.',
|
|
361
|
-
'record-external-outcome is the record-backed version of move-done and move-failed: use it when YOU, or another agent outside this Host, actually finished or failed the card with your own model, so the terminal column and the run history both derive from one execution record. It takes result (succeeded or failed) and initiatedBy (who completed it, for example your own agent name) plus an optional summary, and it is refused while the card still has an open execution: the Host stays the only authority over a run it is executing. It cannot record running or cancelled — those remain Host-only.',
|
|
363
|
+
'record-external-outcome is the record-backed version of move-done and move-failed: use it when YOU, or another agent outside this Host, actually finished or failed the card with your own model, so the terminal column and the run history both derive from one execution record. It takes result (succeeded or failed) and initiatedBy (who completed it, for example your own agent name) plus an optional summary, and it is refused while the card still has an open execution: the Host stays the only authority over a run it is executing. It cannot record running or cancelled — those remain Host-only. A parent card that dispatched its subtasks uses it once, at the end, to backfill every subtask card with the conclusion it reached; the Host records an inherited verdict on a subtask the parent never wrote back, so the write-back is what keeps each subtask conclusion its own.',
|
|
362
364
|
'settle force-closes the open execution of a card the board can no longer observe (a stuck running card) and records it cancelled with the caller as the reason, so the card returns to the todo column and can be run again.',
|
|
363
365
|
'reset-verification clears the acceptance anomalies (timeouts, authentication failures, an unresolvable judge route, or an attempt the time budget ended) recorded on a card open execution, so the next update_goal(action: complete) runs a fresh acceptance. It is refused unless that execution really carries such anomalies, it never clears a quality verdict, and a spent anomaly budget otherwise HOLDS the card open instead of failing it: tell the user the acceptance environment is unusable and that this action is how they clear it once they have fixed it.',
|
|
364
366
|
'archive takes the whole subtask tree off the board and is refused while any member has an unsettled execution; restore brings the task, its ancestors and its subtree back; delete removes one card and is refused while it still has subtasks (detach or delete them first) or while it runs.',
|
|
@@ -459,7 +461,7 @@ function buildScheduleTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
459
461
|
'Arm, change, or disarm a task scheduled runs. Two kinds of plan exist: a recurring 5-field cron rule (day-of-month and day-of-week follow Vixie semantics: both restricted means OR, otherwise AND), and a one-shot that runs once at a future instant.',
|
|
460
462
|
'For a one-shot pass mode "once" with at (the planned instant, ms since epoch UTC). For a recurring rule pass mode "cron" (or omit mode) with a cron expression, optionally capped by maxRuns (a positive whole number of scheduled executions; omit for unlimited, pass 0 to clear a cap).',
|
|
461
463
|
'The wall clock is read in the rule stored IANA time zone; omit timeZone to use the Host zone reported by task_board_list/task_board_get. DST gaps are skipped and an ambiguous fall-back time fires once, at the earlier instant.',
|
|
462
|
-
'A due scheduled task runs
|
|
464
|
+
'A due scheduled task runs exactly what a manual run of that card does: one session for the card, never one per subtask.',
|
|
463
465
|
'The scheduler counts executions it actually starts; once a rule reaches its run budget it stops itself in the ledger, and a manual run never consumes the budget. A schedule whose tree contains an unconfirmed above-default permission is refused and does not consume the budget; the reason is reported in the list board summary as schedulerError.',
|
|
464
466
|
'Missed occurrences during Host downtime are skipped, never queued (a one-shot whose instant passed while the Host was down is stopped as missed); a task that is already running skips its occurrence without consuming the budget.',
|
|
465
467
|
].join(' '),
|
|
@@ -566,7 +568,8 @@ function buildGetTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
566
568
|
name: 'task_board_get',
|
|
567
569
|
description: [
|
|
568
570
|
'Read one task board card in full: prompt, description, labels, column, parent link, direct subtasks, execution targets, schedule, permission gate state, and the last ten execution attempts with their session ids and outcomes.',
|
|
569
|
-
'Use it before running or editing a card,
|
|
571
|
+
'Use it before running or editing a card, after a run to read the settled outcome, and to read each subtask card before dispatching it with subagent.',
|
|
572
|
+
'A card written before team runs were retired may still report teamRun: true; the field is history and never changes how the Host runs the card.',
|
|
570
573
|
].join(' '),
|
|
571
574
|
parameters: {
|
|
572
575
|
taskId: { type: 'string', required: true, description: 'Task id, as reported by task_board_list or task_board_create.' },
|
|
@@ -602,7 +605,6 @@ function buildCreateTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
602
605
|
model: { type: 'string', description: 'Pinned model as provider/model (or a model id); omit to adopt the board new-card default, and the host default when none is configured.' },
|
|
603
606
|
reasoningEffort: { type: 'string', description: 'Reasoning effort id for that model (an adapter-owned level such as "high"); omit to adopt the board new-card default for that model, and the model own default when none applies. Only an effort the target model declares is sent; an empty string clears it back to the default.' },
|
|
604
607
|
reuseSession: { type: 'boolean', description: 'Continue later runs in the previous execution session instead of a fresh conversation.' },
|
|
605
|
-
teamRun: { type: 'boolean', description: 'Run this task as an Agent Team: running it starts one Team Lead session and the Host spawns a teammate per subtask inside it. Omit or false for one independent session per member. Refused when the deployment serves no Agent Teams service.' },
|
|
606
608
|
goalRun: { type: 'boolean', description: 'Start each run with dsh built-in /goal so the session keeps working continuation rounds until the goal completes. Off by default: omit (or pass false) for a single plain turn, and pass true to opt this card in. It only takes effect while the deployment global native /goal switch is on.' },
|
|
607
609
|
skipVerification: { type: 'boolean', description: 'Run this task without the board acceptance gate: update_goal may mark the goal complete without a passing acceptance, and the execution record is marked skipped. Default false (omit to inherit the board-wide acceptance switch). Only affects executions started afterwards.' },
|
|
608
610
|
tags: {
|
|
@@ -654,7 +656,6 @@ function buildCreateTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
654
656
|
// targets the caller omitted are filled.
|
|
655
657
|
applyCardDefaults: true,
|
|
656
658
|
...(args.reuseSession === true ? { reuseSession: true } : {}),
|
|
657
|
-
...(args.teamRun === true ? { teamRun: true } : {}),
|
|
658
659
|
...(args.goalRun === true ? { goalRun: true } : {}),
|
|
659
660
|
...(args.skipVerification === true ? { skipVerification: true } : {}),
|
|
660
661
|
...(tags.length === 0 ? {} : { tags }),
|
|
@@ -714,7 +715,6 @@ function buildUpdateTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
714
715
|
model: { type: 'string', description: 'New pinned model; an empty string clears it.' },
|
|
715
716
|
reasoningEffort: { type: 'string', description: 'New reasoning effort id for the pinned model; an empty string clears it back to the model own default. Only an effort the target model declares is sent at run time.' },
|
|
716
717
|
reuseSession: { type: 'boolean', description: 'Continue later runs in the previous execution session.' },
|
|
717
|
-
teamRun: { type: 'boolean', description: 'Switches this task between a plain cascade (one session per member) and an Agent Team run (Lead session plus a teammate per subtask).' },
|
|
718
718
|
goalRun: { type: 'boolean', description: 'Whether each run starts with dsh built-in /goal (default false, one plain turn). Pass true to opt this card in, or false to return it to the default.' },
|
|
719
719
|
skipVerification: { type: 'boolean', description: 'Whether this task runs without the board acceptance gate (default false, inherit the board-wide switch). Pass true to opt out; pass false to opt back in. Only affects executions started afterwards.' },
|
|
720
720
|
tags: {
|
|
@@ -748,7 +748,6 @@ function buildUpdateTool(host: TaskBoardToolHost): ToolDefinition {
|
|
|
748
748
|
patch.permission = args.permission === '' ? undefined : args.permission
|
|
749
749
|
}
|
|
750
750
|
if (has(args, 'reuseSession')) patch.reuseSession = args.reuseSession === true
|
|
751
|
-
if (has(args, 'teamRun')) patch.teamRun = args.teamRun === true
|
|
752
751
|
if (has(args, 'goalRun')) patch.goalRun = args.goalRun === true ? true : false
|
|
753
752
|
if (has(args, 'skipVerification')) patch.skipVerification = args.skipVerification === true ? true : false
|
|
754
753
|
if (has(args, 'tags')) {
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Admission control for the session-creating half of a run.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* measured guidance caps at three
|
|
8
|
-
* (docs/multi-agent-resources.md), with no
|
|
4
|
+
* A run opens one session, so the burst this bounds is several runs starting at
|
|
5
|
+
* once — several cards run from different tabs, or a due schedule firing while
|
|
6
|
+
* a manual run is still launching. Unbounded, the Host asks DSH for N sessions
|
|
7
|
+
* in the same tick: the burst the repository's measured guidance caps at three
|
|
8
|
+
* heavy implementation subagents (docs/multi-agent-resources.md), with no
|
|
9
|
+
* mechanism enforcing it.
|
|
9
10
|
*
|
|
10
11
|
* The queue is SERVICE-wide, not per run group: the pressure it bounds is the
|
|
11
12
|
* machine's (the Host process's memory and the swap it drives), and two run
|
|
12
13
|
* groups opened from two tabs share one Host. Admission is round-robin across
|
|
13
|
-
* run groups — FIFO inside a group
|
|
14
|
-
*
|
|
15
|
-
* members — so a large subtree cannot starve a run opened after it, and no
|
|
16
|
-
* entry can be starved.
|
|
14
|
+
* run groups — FIFO inside a group — so one run cannot starve another opened
|
|
15
|
+
* after it, and no entry can be starved.
|
|
17
16
|
*
|
|
18
17
|
* The width is read through a live callback, so a settings edit takes effect on
|
|
19
18
|
* the next admission without remounting anything.
|
package/src/host-ledger.ts
CHANGED
|
@@ -10,13 +10,17 @@ import { usedTokensToday } from './host-spend.ts'
|
|
|
10
10
|
import { canMoveManually, hasOpenExecution, retainRecentExecutions, scheduleExhausted, scheduleRunBudget, settleExecution, settledStatus, startExecution, withSchedule, withStatus, type ExecutionOutcome, type ExecutionRecord, type ExecutionSummary, type ScheduleMode, type ScheduleStopReason, type TaskRecord } from './core/tasks.ts'
|
|
11
11
|
import {
|
|
12
12
|
DEFAULT_SUBTASK_DEPTH,
|
|
13
|
+
ancestorChain,
|
|
13
14
|
cascadeTargets,
|
|
14
15
|
combineCascadeOutcome,
|
|
15
|
-
|
|
16
|
+
hasOutstandingDescendants,
|
|
17
|
+
isOutstanding,
|
|
16
18
|
normalizeSubtaskDepth,
|
|
17
19
|
openGroupExecution,
|
|
20
|
+
outstandingDescendants as lineageOutstandingDescendants,
|
|
18
21
|
pendingCascadeChildren,
|
|
19
22
|
resolveExecutionTargets,
|
|
23
|
+
subtreeTasks,
|
|
20
24
|
} from './core/subtask.ts'
|
|
21
25
|
import { applyArchiveTask, applyRestoreTask } from './core/use-cases/task-archive.ts'
|
|
22
26
|
import { applyCreateTask } from './core/use-cases/task-create.ts'
|
|
@@ -28,7 +32,7 @@ import { applyDeleteTag, applyRenameTag } from './core/use-cases/task-tag.ts'
|
|
|
28
32
|
import { applyUpdateTask, canEditTaskContent, hasContentPatch } from './core/use-cases/task-update.ts'
|
|
29
33
|
import { TASK_BOARD_MIGRATABLE_SCHEMA_VERSIONS, TASK_BOARD_SCHEMA_VERSION, TASK_BOARD_ZONE_STAMP_SCHEMA_VERSION, type TaskBoardAction, type TaskBoardSchedulerSnapshot } from './protocol.ts'
|
|
30
34
|
import { withoutAcceptanceAnomalies, type ExecutionVerification } from './core/verification.ts'
|
|
31
|
-
import { DEFAULT_SESSION_PERMISSION,
|
|
35
|
+
import { DEFAULT_SESSION_PERMISSION, requiresPermissionConfirmation, type TaskPermission } from './core/handover.ts'
|
|
32
36
|
|
|
33
37
|
interface PersistedScheduler extends TaskBoardSchedulerSnapshot {
|
|
34
38
|
importedSources?: string[]
|
|
@@ -58,13 +62,10 @@ export interface LedgerState {
|
|
|
58
62
|
|
|
59
63
|
/** Human-facing text for a refused binding, per surface. */
|
|
60
64
|
function bindingRefusalMessage(
|
|
61
|
-
refusal: { kind: 'root' | 'inherited'
|
|
65
|
+
refusal: { kind: 'root' | 'inherited'; title: string },
|
|
62
66
|
sessionDefault: TaskPermission,
|
|
63
67
|
surface: 'run' | 'schedule',
|
|
64
68
|
): string {
|
|
65
|
-
if (refusal.kind === 'subtask-pin') {
|
|
66
|
-
return `team run cannot honor the permission binding of subtask "${refusal.title}": a teammate runs inside the Lead session and inherits its permission, which that pin exceeds; clear the card's permission or run the tree without Agent Team`
|
|
67
|
-
}
|
|
68
69
|
if (surface === 'schedule') return `task "${refusal.title}" has an unconfirmed above-default permission`
|
|
69
70
|
if (refusal.kind === 'root') {
|
|
70
71
|
return `confirmation-required: the effective permission is above the session default (${sessionDefault}); confirm the card's permission binding first`
|
|
@@ -75,15 +76,15 @@ function bindingRefusalMessage(
|
|
|
75
76
|
export interface OpenedRun {
|
|
76
77
|
task: TaskRecord
|
|
77
78
|
execution: ExecutionRecord
|
|
78
|
-
/**
|
|
79
|
-
* How the Host obtains this run's session. Absent or `session` launches a
|
|
80
|
-
* fresh (or reused) execution session; `teammate` means the run belongs to a
|
|
81
|
-
* team-mode cascade, where the Host asks the root's Lead session to spawn a
|
|
82
|
-
* teammate instead of launching a session of its own.
|
|
83
|
-
*/
|
|
84
|
-
dispatch?: 'session' | 'teammate'
|
|
85
79
|
}
|
|
86
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Prefix of the `initiatedBy` an inherited descendant verdict carries. The Host
|
|
83
|
+
* recorded it on the run card's behalf (see `inheritVerdictForDescendants`), not
|
|
84
|
+
* an outside agent that reported its own work.
|
|
85
|
+
*/
|
|
86
|
+
export const PARENT_RUN_INITIATOR_PREFIX = 'parent-run:'
|
|
87
|
+
|
|
87
88
|
/** Minimal value copy used by the Host session monitor. */
|
|
88
89
|
export interface OpenExecutionReference {
|
|
89
90
|
readonly taskId: string
|
|
@@ -119,7 +120,7 @@ export interface LedgerRuntimeView {
|
|
|
119
120
|
* Session ids of every open execution, including the ones
|
|
120
121
|
* {@link openExecutions} skips because their own outcome is already
|
|
121
122
|
* recorded. A caller that asks whether the board still observes any session
|
|
122
|
-
* must use this list: a
|
|
123
|
+
* must use this list: a stored run-group parent is settled by its members,
|
|
123
124
|
* but it is still an open execution.
|
|
124
125
|
*/
|
|
125
126
|
readonly openSessionIds: readonly string[]
|
|
@@ -400,7 +401,7 @@ function mergeTask(a: TaskRecord, b: TaskRecord): TaskRecord {
|
|
|
400
401
|
* missing, cyclic, or names an archived parent while the child is on board is
|
|
401
402
|
* dropped (the task becomes a root) instead of dropping the task. A chain
|
|
402
403
|
* deeper than the current `maxSubtaskDepth` is deliberately KEPT: the limit
|
|
403
|
-
* gates new links, it never deletes a stored one, and every
|
|
404
|
+
* gates new links, it never deletes a stored one, and every lineage walk is
|
|
404
405
|
* bounded by the limit anyway. The Host is the only writer of these links, so
|
|
405
406
|
* this is a last-resort guard against a hand-edited or imported document.
|
|
406
407
|
*/
|
|
@@ -413,7 +414,7 @@ export function repairParentLinks(tasks: readonly TaskRecord[]): TaskRecord[] {
|
|
|
413
414
|
let depth = 0
|
|
414
415
|
while (current !== undefined) {
|
|
415
416
|
// The first hop is the parent itself: an archived parent holding an
|
|
416
|
-
// on-board child is outside the archive
|
|
417
|
+
// on-board child is outside the archive subtree invariant, and only an
|
|
417
418
|
// import can produce it.
|
|
418
419
|
if (seen.has(current.id) || (depth === 0 && current.archivedAt !== undefined && task.archivedAt === undefined)) {
|
|
419
420
|
return { ...task, parentId: undefined }
|
|
@@ -593,8 +594,9 @@ export class HostTaskLedger {
|
|
|
593
594
|
runtimeView(): LedgerRuntimeView {
|
|
594
595
|
let armedSchedules = 0
|
|
595
596
|
let runningCards = 0
|
|
596
|
-
//
|
|
597
|
-
//
|
|
597
|
+
// Stored run groups a team-mode card opened before team runs were retired:
|
|
598
|
+
// every other member of those groups ran as a teammate inside that card's
|
|
599
|
+
// Lead session, which is why its turn is read even while its session runs.
|
|
598
600
|
const teamGroups = new Set<string>()
|
|
599
601
|
for (const task of this.document.tasks) {
|
|
600
602
|
if (task.teamRun !== true) continue
|
|
@@ -610,8 +612,8 @@ export class HostTaskLedger {
|
|
|
610
612
|
for (const execution of task.executions) {
|
|
611
613
|
if (execution.endedAt !== undefined) continue
|
|
612
614
|
if (execution.sessionId !== undefined) openSessionIds.push(execution.sessionId)
|
|
613
|
-
// A
|
|
614
|
-
// has nothing left to inspect, and its
|
|
615
|
+
// A stored run-group parent already knows its own outcome; the monitor
|
|
616
|
+
// has nothing left to inspect, and its members' settles finalize it.
|
|
615
617
|
if (execution.ownResult !== undefined) continue
|
|
616
618
|
openExecutions.push({
|
|
617
619
|
taskId: task.id,
|
|
@@ -724,10 +726,10 @@ export class HostTaskLedger {
|
|
|
724
726
|
}
|
|
725
727
|
|
|
726
728
|
/**
|
|
727
|
-
* Open the
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
729
|
+
* Open the one run a due schedule triggers: an empty array means nothing ran
|
|
730
|
+
* (already running, a card whose elevated permission is still unconfirmed, a
|
|
731
|
+
* one-shot whose instant was missed, or an exhausted budget), and the rule's
|
|
732
|
+
* own state says which.
|
|
731
733
|
*
|
|
732
734
|
* The run budget is enforced HERE, inside the single ledger writer: a rule
|
|
733
735
|
* whose counter already reached its cap is stopped instead of opened, so no
|
|
@@ -781,7 +783,7 @@ export class HostTaskLedger {
|
|
|
781
783
|
if (schedule.mode === 'once') {
|
|
782
784
|
// The single planned instant is due: open its one run and stop the rule
|
|
783
785
|
// in the same commit, so the budget can never produce a second one.
|
|
784
|
-
return this.
|
|
786
|
+
return this.startRun(task, triggeredAt, undefined, false, {
|
|
785
787
|
consumed: 1,
|
|
786
788
|
lastTriggeredAt: triggeredAt,
|
|
787
789
|
endedReason: 'fired',
|
|
@@ -796,7 +798,7 @@ export class HostTaskLedger {
|
|
|
796
798
|
const consumed = schedule.runCount + 1
|
|
797
799
|
const budget = scheduleRunBudget(schedule)
|
|
798
800
|
const spent = budget !== undefined && consumed >= budget
|
|
799
|
-
return this.
|
|
801
|
+
return this.startRun(task, triggeredAt, undefined, false, {
|
|
800
802
|
consumed: 1,
|
|
801
803
|
nextRunAt: spent ? undefined : next,
|
|
802
804
|
lastTriggeredAt: triggeredAt,
|
|
@@ -848,8 +850,8 @@ export class HostTaskLedger {
|
|
|
848
850
|
* failed without creating a session (see
|
|
849
851
|
* {@link applyScheduleRefund}). Called by the service on the failed-launch
|
|
850
852
|
* path only; a manual run and a launch that did reach a session are never
|
|
851
|
-
* refunded. A no-op for a task with no rule, so a failed
|
|
852
|
-
*
|
|
853
|
+
* refunded. A no-op for a task with no rule, so a failed run does not touch
|
|
854
|
+
* anything.
|
|
853
855
|
* @param taskId - the task whose occurrence is being refunded.
|
|
854
856
|
* @param now - clock instant (ms epoch).
|
|
855
857
|
*/
|
|
@@ -913,10 +915,12 @@ export class HostTaskLedger {
|
|
|
913
915
|
}
|
|
914
916
|
|
|
915
917
|
/**
|
|
916
|
-
* Settle one execution. A
|
|
917
|
-
*
|
|
918
|
-
*
|
|
919
|
-
*
|
|
918
|
+
* Settle one execution. A NEW run is a single-member group, so it settles on
|
|
919
|
+
* its own turn. A run group the Host opened before it stopped spreading one
|
|
920
|
+
* run across a subtree is folded here instead: a stored participant records
|
|
921
|
+
* its OWN outcome and only finalizes once every child execution in its group
|
|
922
|
+
* has settled, so a parent card leaves 'running' with the whole group's
|
|
923
|
+
* verdict rather than its own turn alone.
|
|
920
924
|
*
|
|
921
925
|
* `summary` is what the run left behind (see `ExecutionSummary`), passed in
|
|
922
926
|
* by whichever reader observed the session. It is informational: a caller
|
|
@@ -937,9 +941,9 @@ export class HostTaskLedger {
|
|
|
937
941
|
}
|
|
938
942
|
let changed = false
|
|
939
943
|
if (execution.ownResult === undefined) {
|
|
940
|
-
// A
|
|
941
|
-
// outcome; the fold that finalizes the card carries no session of its
|
|
942
|
-
// and leaves what is already here in place.
|
|
944
|
+
// A stored run-group parent records its own turn's closing text with its
|
|
945
|
+
// own outcome; the fold that finalizes the card carries no session of its
|
|
946
|
+
// own and leaves what is already here in place.
|
|
943
947
|
this.document.tasks = this.document.tasks.map(item => item.id !== taskId ? item : {
|
|
944
948
|
...item,
|
|
945
949
|
updatedAt: now,
|
|
@@ -955,9 +959,82 @@ export class HostTaskLedger {
|
|
|
955
959
|
if (task.teamRun === true
|
|
956
960
|
&& this.closeTeamMembers(taskId, groupId, execution.ownResult ?? outcome, execution.ownError ?? error, now)) changed = true
|
|
957
961
|
if (this.settleCascade(taskId, groupId, now)) changed = true
|
|
962
|
+
// The run's own card may now be terminal: hand its verdict down to the
|
|
963
|
+
// subtasks it was expected to dispatch.
|
|
964
|
+
if (this.inheritVerdictForDescendants(taskId, executionId, groupId, now)) changed = true
|
|
958
965
|
if (changed) this.commit()
|
|
959
966
|
}
|
|
960
967
|
|
|
968
|
+
/**
|
|
969
|
+
* Record the run's verdict on the outstanding descendants its root was asked
|
|
970
|
+
* to dispatch.
|
|
971
|
+
*
|
|
972
|
+
* A card with unfinished subtasks runs as an autonomous dispatcher: its
|
|
973
|
+
* session reads the subtasks, dispatches them with subagents, and is asked to
|
|
974
|
+
* write their conclusions back with
|
|
975
|
+
* `task_board_manage({action:'record-external-outcome'})` before it finishes.
|
|
976
|
+
* A run that never wrote one back would leave those cards parked with no
|
|
977
|
+
* record of what the parent decided about them, so once the RUN CARD's
|
|
978
|
+
* execution reached a decisive terminal record, every outstanding descendant
|
|
979
|
+
* this run opened no execution for inherits that verdict as an external
|
|
980
|
+
* record.
|
|
981
|
+
*
|
|
982
|
+
* Idempotent by construction: a card that already carries an execution in
|
|
983
|
+
* this run group (the fold owns it), an open execution (it is running on its
|
|
984
|
+
* own), or a terminal record stamped after this run started (the dispatching
|
|
985
|
+
* agent's own backfill, or an earlier pass of this one) is left alone. Only a
|
|
986
|
+
* decisive verdict is inherited: a cancelled run judged nothing about the
|
|
987
|
+
* subtasks, and a subtask already in the done column has nothing left to
|
|
988
|
+
* inherit.
|
|
989
|
+
* @param taskId - the card whose execution just settled.
|
|
990
|
+
* @param executionId - that execution.
|
|
991
|
+
* @param groupId - its run group.
|
|
992
|
+
* @param now - clock instant (ms epoch).
|
|
993
|
+
* @returns whether the document changed.
|
|
994
|
+
*/
|
|
995
|
+
private inheritVerdictForDescendants(taskId: string, executionId: string, groupId: string, now: number): boolean {
|
|
996
|
+
const root = this.document.tasks.find(item => item.id === taskId)
|
|
997
|
+
if (root === undefined) return false
|
|
998
|
+
const execution = root.executions.find(entry => entry.id === executionId)
|
|
999
|
+
if (execution?.endedAt === undefined || execution.result === undefined) return false
|
|
1000
|
+
if (execution.result !== 'succeeded' && execution.result !== 'failed') return false
|
|
1001
|
+
const verdict: ExecutionOutcome = execution.result
|
|
1002
|
+
// Only the card this run opened settles a tree it did not run itself: a
|
|
1003
|
+
// member of a historical multi-member group must not hand its own verdict
|
|
1004
|
+
// down to its siblings.
|
|
1005
|
+
if (ancestorChain(this.document.tasks, root).some(ancestor =>
|
|
1006
|
+
ancestor.executions.some(entry => entry.runGroupId === groupId))) return false
|
|
1007
|
+
const descendants = new Set(lineageOutstandingDescendants(this.document.tasks, root.id, this.maxSubtaskDepth).map(task => task.id))
|
|
1008
|
+
if (descendants.size === 0) return false
|
|
1009
|
+
const note = `本次执行由父卡「${root.title}」统一判定,本卡未单独开会话执行;结论继承自父卡运行`
|
|
1010
|
+
let changed = false
|
|
1011
|
+
this.document.tasks = this.document.tasks.map(task => {
|
|
1012
|
+
if (!descendants.has(task.id)) return task
|
|
1013
|
+
if (task.executions.some(entry => entry.runGroupId === groupId)) return task
|
|
1014
|
+
if (task.executions.some(entry => entry.endedAt === undefined)) return task
|
|
1015
|
+
if (task.executions.some(entry => entry.endedAt !== undefined && entry.startedAt >= execution.startedAt)) return task
|
|
1016
|
+
changed = true
|
|
1017
|
+
const inherited: ExecutionRecord = {
|
|
1018
|
+
id: crypto.randomUUID(),
|
|
1019
|
+
sessionId: undefined,
|
|
1020
|
+
startedAt: now,
|
|
1021
|
+
endedAt: now,
|
|
1022
|
+
result: verdict,
|
|
1023
|
+
error: note,
|
|
1024
|
+
initiatedBy: PARENT_RUN_INITIATOR_PREFIX + root.id,
|
|
1025
|
+
external: true,
|
|
1026
|
+
runGroupId: groupId,
|
|
1027
|
+
}
|
|
1028
|
+
return {
|
|
1029
|
+
...task,
|
|
1030
|
+
status: settledStatus(task, verdict),
|
|
1031
|
+
updatedAt: now,
|
|
1032
|
+
executions: retainRecentExecutions([...task.executions, inherited]),
|
|
1033
|
+
}
|
|
1034
|
+
})
|
|
1035
|
+
return changed
|
|
1036
|
+
}
|
|
1037
|
+
|
|
961
1038
|
attachSession(taskId: string, executionId: string, sessionId: string): void {
|
|
962
1039
|
const now = this.now()
|
|
963
1040
|
const task = this.document.tasks.find(item => item.id === taskId)
|
|
@@ -1137,7 +1214,7 @@ export class HostTaskLedger {
|
|
|
1137
1214
|
const reason = 'execution closed manually by '
|
|
1138
1215
|
+ (initiator === undefined || initiator === '' ? 'the operator' : initiator)
|
|
1139
1216
|
+ ': no verdict was recorded'
|
|
1140
|
-
for (const member of
|
|
1217
|
+
for (const member of subtreeTasks(this.document.tasks, action.taskId, this.maxSubtaskDepth)) {
|
|
1141
1218
|
for (const execution of member.executions) {
|
|
1142
1219
|
if (execution.endedAt !== undefined) continue
|
|
1143
1220
|
this.document.tasks = this.document.tasks.map(item => item.id !== member.id
|
|
@@ -1222,7 +1299,7 @@ export class HostTaskLedger {
|
|
|
1222
1299
|
// unconfirmed as the parent would be without its own stamp.
|
|
1223
1300
|
const refusal = this.bindingRefusal(task)
|
|
1224
1301
|
if (refusal !== undefined) throw new Error(bindingRefusalMessage(refusal, this.sessionDefaultPermission, 'run'))
|
|
1225
|
-
runs = this.
|
|
1302
|
+
runs = this.startRun(task, now, initiator, action.kind === 'rerun')
|
|
1226
1303
|
break
|
|
1227
1304
|
}
|
|
1228
1305
|
default: {
|
|
@@ -1235,8 +1312,8 @@ export class HostTaskLedger {
|
|
|
1235
1312
|
throw new Error(`unknown task board action kind: ${String((action as { kind?: unknown }).kind)}`)
|
|
1236
1313
|
}
|
|
1237
1314
|
}
|
|
1238
|
-
//
|
|
1239
|
-
//
|
|
1315
|
+
// startRun committed the opened execution itself; committing again here
|
|
1316
|
+
// would bump the revision twice for one action.
|
|
1240
1317
|
if (runs === undefined || runs.length === 0) this.commit()
|
|
1241
1318
|
return { state: this.state(), ...(runs === undefined ? {} : { runs }) }
|
|
1242
1319
|
}
|
|
@@ -1269,115 +1346,70 @@ export class HostTaskLedger {
|
|
|
1269
1346
|
/**
|
|
1270
1347
|
* The binding that makes a run illegal, if any.
|
|
1271
1348
|
*
|
|
1272
|
-
*
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1275
|
-
* teammate inherits that session's permission, so a subtask's OWN pin is
|
|
1276
|
-
* refused exactly when the Lead session does not already carry it — the
|
|
1277
|
-
* teammate could never be given that authority, and dropping the pin
|
|
1278
|
-
* silently would misreport the work (an inherited binding is the Lead's own
|
|
1279
|
-
* and stays allowed once the Lead is confirmed).
|
|
1349
|
+
* Only the card being run gets a session, so only ITS resolved binding gates
|
|
1350
|
+
* the run: a subtask's own elevated permission is that subtask's gate when the
|
|
1351
|
+
* subtask is run, and no longer blocks its parent from running.
|
|
1280
1352
|
* @param root - the task being run.
|
|
1281
1353
|
* @returns the first refusal, or undefined when the run may start.
|
|
1282
1354
|
*/
|
|
1283
|
-
private bindingRefusal(root: TaskRecord): { kind: 'root' | 'inherited'
|
|
1284
|
-
const
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1287
|
-
if (lead !== undefined && requiresPermissionConfirmation(lead, this.sessionDefaultPermission)) {
|
|
1288
|
-
return { kind: 'root', title: lead.title }
|
|
1289
|
-
}
|
|
1290
|
-
// The Lead session runs at the Lead's own binding, or at the deployment
|
|
1291
|
-
// default when it pins none; a teammate inherits that permission and
|
|
1292
|
-
// cannot be narrowed below it, so it carries a subtask pin when it is
|
|
1293
|
-
// already at least as wide. The raw record carries the subtask's OWN
|
|
1294
|
-
// binding: the resolved participant above already folded an inherited one
|
|
1295
|
-
// into its permission.
|
|
1296
|
-
const leadPermission = effectivePermission(lead ?? root) ?? this.sessionDefaultPermission
|
|
1297
|
-
const pinned = participants.find(participant => {
|
|
1298
|
-
if (participant.id === root.id) return false
|
|
1299
|
-
const raw = this.document.tasks.find(task => task.id === participant.id)
|
|
1300
|
-
return raw !== undefined && !permissionCarriedBy(leadPermission, effectivePermission(raw))
|
|
1301
|
-
})
|
|
1302
|
-
return pinned === undefined ? undefined : { kind: 'subtask-pin', title: pinned.title }
|
|
1303
|
-
}
|
|
1304
|
-
const unconfirmed = participants.find(participant => requiresPermissionConfirmation(participant, this.sessionDefaultPermission))
|
|
1305
|
-
if (unconfirmed === undefined) return undefined
|
|
1306
|
-
return { kind: unconfirmed.id === root.id ? 'root' : 'inherited', title: unconfirmed.title }
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
/**
|
|
1310
|
-
* The tasks a cascade from `rootId` would actually open executions for, with
|
|
1311
|
-
* their effective execution targets resolved. Archived members never run, and
|
|
1312
|
-
* a member that already has an open execution is skipped (a task cannot run
|
|
1313
|
-
* twice), so the result is the participant set the launch will use.
|
|
1314
|
-
*/
|
|
1315
|
-
private cascadeParticipants(rootId: string): TaskRecord[] {
|
|
1316
|
-
return cascadeTargets(this.document.tasks, rootId, this.maxSubtaskDepth)
|
|
1317
|
-
.map(participant => resolveExecutionTargets(participant, this.document.tasks, this.maxSubtaskDepth))
|
|
1318
|
-
.filter(participant => participant.archivedAt === undefined
|
|
1319
|
-
&& !hasOpenExecution(participant))
|
|
1355
|
+
private bindingRefusal(root: TaskRecord): { kind: 'root' | 'inherited'; title: string } | undefined {
|
|
1356
|
+
const resolved = resolveExecutionTargets(root, this.document.tasks, this.maxSubtaskDepth)
|
|
1357
|
+
if (!requiresPermissionConfirmation(resolved, this.sessionDefaultPermission)) return undefined
|
|
1358
|
+
return { kind: root.parentId === undefined ? 'root' : 'inherited', title: root.title }
|
|
1320
1359
|
}
|
|
1321
1360
|
|
|
1322
1361
|
/** Whether a task or any of its subtasks still has an open execution. */
|
|
1323
1362
|
private subtreeHasOpenExecution(id: string): boolean {
|
|
1324
|
-
return
|
|
1363
|
+
return subtreeTasks(this.document.tasks, id, this.maxSubtaskDepth)
|
|
1325
1364
|
.some(task => hasOpenExecution(task))
|
|
1326
1365
|
}
|
|
1327
1366
|
|
|
1367
|
+
/** The descendants of a card that still hold work, as the launch prompt names them. */
|
|
1368
|
+
outstandingDescendants(taskId: string): TaskRecord[] {
|
|
1369
|
+
return lineageOutstandingDescendants(this.document.tasks, taskId, this.maxSubtaskDepth)
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/** Whether a card still has a subtask outside the done column. */
|
|
1373
|
+
hasOutstandingDescendants(taskId: string): boolean {
|
|
1374
|
+
return hasOutstandingDescendants(this.document.tasks, taskId, this.maxSubtaskDepth)
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1328
1377
|
/**
|
|
1329
|
-
* Open
|
|
1330
|
-
*
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1378
|
+
* Open ONE execution for the requested card, under a fresh run group, and
|
|
1379
|
+
* commit the ledger once. The group stays single-member on purpose: a run
|
|
1380
|
+
* never opens a session for a subtask (that card's own agent dispatches
|
|
1381
|
+
* subagents inside this session), and the group id is what later lets the
|
|
1382
|
+
* settlement fold a HISTORICAL multi-member group it opened before this
|
|
1383
|
+
* behavior changed.
|
|
1334
1384
|
* @param root - the task the user ran.
|
|
1335
1385
|
* @param now - clock instant (ms epoch).
|
|
1336
1386
|
* @param initiator - the DSH session that asked for the run (audit only).
|
|
1337
1387
|
* @param rerun - true to reset the root to 'todo' before starting it.
|
|
1338
1388
|
* @param progress - when set, this run was a due occurrence and the root's
|
|
1339
1389
|
* rule is advanced (counter, next target, stop/skip record) in the same
|
|
1340
|
-
* atomic commit that opened the
|
|
1390
|
+
* atomic commit that opened the execution.
|
|
1341
1391
|
*/
|
|
1342
|
-
private
|
|
1392
|
+
private startRun(root: TaskRecord, now: number, initiator?: string, rerun = false, progress?: ScheduleProgress): OpenedRun[] {
|
|
1343
1393
|
const before = this.document.tasks
|
|
1394
|
+
const [participant] = cascadeTargets(before, root.id)
|
|
1395
|
+
if (participant === undefined || participant.archivedAt !== undefined) return []
|
|
1396
|
+
if (hasOpenExecution(participant)) return []
|
|
1344
1397
|
const groupId = crypto.randomUUID()
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
const team = root.teamRun === true
|
|
1349
|
-
const started = new Map<string, TaskRecord>()
|
|
1350
|
-
const runs: OpenedRun[] = []
|
|
1351
|
-
for (const task of cascadeTargets(before, root.id, this.maxSubtaskDepth)) {
|
|
1352
|
-
if (task.archivedAt !== undefined) continue
|
|
1353
|
-
// A subtask that already sits in 'done' is left alone: running the parent
|
|
1354
|
-
// repeats the parent, never the work a subtask has already finished. The
|
|
1355
|
-
// rule is the card's column, so it holds for a manual run, a re-run and a
|
|
1356
|
-
// due occurrence alike.
|
|
1357
|
-
if (!joinsCascadeRun(task, root.id)) continue
|
|
1358
|
-
if (hasOpenExecution(task)) continue
|
|
1359
|
-
const base = rerun && task.id === root.id ? withStatus(task, 'todo', now) : task
|
|
1360
|
-
const opened = startExecution(base, now, crypto.randomUUID(), initiator, groupId)
|
|
1361
|
-
started.set(task.id, opened.task)
|
|
1362
|
-
runs.push({
|
|
1363
|
-
task: resolveExecutionTargets(opened.task, before, this.maxSubtaskDepth),
|
|
1364
|
-
execution: opened.execution,
|
|
1365
|
-
...(team && task.id !== root.id ? { dispatch: 'teammate' as const } : {}),
|
|
1366
|
-
})
|
|
1367
|
-
}
|
|
1368
|
-
if (runs.length === 0) return []
|
|
1369
|
-
let tasks: readonly TaskRecord[] = before.map(task => started.get(task.id) ?? task)
|
|
1398
|
+
const base = rerun ? withStatus(participant, 'todo', now) : participant
|
|
1399
|
+
const opened = startExecution(base, now, crypto.randomUUID(), initiator, groupId)
|
|
1400
|
+
let tasks: readonly TaskRecord[] = before.map(task => task.id === participant.id ? opened.task : task)
|
|
1370
1401
|
if (progress !== undefined) tasks = applyScheduleProgress(tasks, root.id, progress, now)
|
|
1371
1402
|
this.document.tasks = [...tasks]
|
|
1372
1403
|
this.commit()
|
|
1373
|
-
return
|
|
1404
|
+
return [{ task: resolveExecutionTargets(opened.task, before, this.maxSubtaskDepth), execution: opened.execution }]
|
|
1374
1405
|
}
|
|
1375
1406
|
|
|
1376
1407
|
/**
|
|
1377
|
-
* Finalize every
|
|
1378
|
-
* lineage: a member settles once its own outcome is recorded and none
|
|
1379
|
-
* group children is still open, and its verdict folds those children in
|
|
1380
|
-
* (failure dominates, then cancellation).
|
|
1408
|
+
* Finalize every stored run-group parent that is ready, walking from `taskId`
|
|
1409
|
+
* up the lineage: a member settles once its own outcome is recorded and none
|
|
1410
|
+
* of its group children is still open, and its verdict folds those children in
|
|
1411
|
+
* (failure dominates, then cancellation). A single-member group — every run
|
|
1412
|
+
* this Host opens now — settles on its own turn exactly as any plain run does.
|
|
1381
1413
|
*/
|
|
1382
1414
|
private settleCascade(taskId: string, groupId: string, now: number): boolean {
|
|
1383
1415
|
let changed = false
|
|
@@ -1414,11 +1446,12 @@ export class HostTaskLedger {
|
|
|
1414
1446
|
* members are all settled. The Host poll calls this on every tick, so a run
|
|
1415
1447
|
* can no longer be left in the running column by a settle nobody observed:
|
|
1416
1448
|
*
|
|
1417
|
-
* - A team run is governed by its Lead. Once the Lead's own outcome is
|
|
1449
|
+
* - A stored team run is governed by its Lead. Once the Lead's own outcome is
|
|
1418
1450
|
* recorded, its still-open members are settled with that verdict. A
|
|
1419
1451
|
* teammate is a durable member of the Team and may never report a turn of
|
|
1420
|
-
* its own, and without this the whole lineage waits on it forever.
|
|
1421
|
-
*
|
|
1452
|
+
* its own, and without this the whole lineage waits on it forever. New runs
|
|
1453
|
+
* never start a team, so this only closes a group the ledger already holds.
|
|
1454
|
+
* - A stored group parent whose members are all settled is finalized here even
|
|
1422
1455
|
* when the settle that completed the tree happened in another process, or
|
|
1423
1456
|
* was interrupted between its child write and its parent write.
|
|
1424
1457
|
*
|