@linxin666/dsh-client-ui-task-board 0.4.16 → 0.4.17
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 +16 -36
- package/README.zh.md +16 -36
- package/lib/client.js +101 -1348
- package/lib/client.js.map +1 -1
- package/lib/index.js +129 -2528
- package/lib/types/client/TaskBoardSettingsCard.d.ts +0 -20
- package/lib/types/client/board/status-key.d.ts +0 -15
- package/lib/types/client/locales.d.ts +1 -110
- package/lib/types/core/controller.d.ts +1 -1
- package/lib/types/core/extension.d.ts +4 -5
- package/lib/types/core/model-catalog.d.ts +58 -0
- package/lib/types/core/reasoning-effort.d.ts +1 -1
- package/lib/types/core/tasks.d.ts +0 -45
- package/lib/types/core/use-cases/task-update.d.ts +1 -1
- package/lib/types/host/llm-dispatch.d.ts +8 -10
- package/lib/types/host-ledger.d.ts +0 -28
- package/lib/types/host-runner.d.ts +6 -71
- package/lib/types/host-service.d.ts +17 -89
- package/lib/types/index.d.ts +0 -78
- package/lib/types/protocol.d.ts +6 -23
- package/package.json +26 -26
- package/src/client/TaskBoardSettingsCard.tsx +13 -200
- package/src/client/board/ExecutionLog.tsx +2 -5
- package/src/client/board/NewTaskModal.tsx +1 -42
- package/src/client/board/TaskCard.tsx +2 -7
- package/src/client/board/TaskDetail.tsx +2 -37
- package/src/client/board/status-key.ts +0 -30
- package/src/client/board-settings.module.css +3 -22
- package/src/client/board.module.css +1 -104
- package/src/client/index.ts +1 -1
- package/src/client/locales.ts +6 -224
- package/src/core/controller.ts +1 -3
- package/src/core/extension.ts +4 -5
- package/src/core/model-catalog.ts +114 -0
- package/src/core/reasoning-effort.ts +1 -1
- package/src/core/store.ts +22 -17
- package/src/core/tasks.ts +0 -53
- package/src/core/use-cases/task-update.ts +1 -8
- package/src/host/agent-tools.ts +1 -15
- package/src/host/llm-dispatch.ts +8 -10
- package/src/host-ledger.ts +1 -86
- package/src/host-routes.ts +4 -4
- package/src/host-runner.ts +12 -138
- package/src/host-service.ts +51 -266
- package/src/index.ts +9 -163
- package/src/protocol.ts +8 -43
- package/lib/types/client/board/VerificationReport.d.ts +0 -10
- package/lib/types/core/verification-budget.d.ts +0 -52
- package/lib/types/core/verification.d.ts +0 -753
- package/lib/types/host/verification-gate.d.ts +0 -95
- package/lib/types/host/verification-runner.d.ts +0 -139
- package/lib/types/host/workspace-evidence.d.ts +0 -53
- package/src/client/board/VerificationReport.tsx +0 -361
- package/src/core/verification-budget.ts +0 -115
- package/src/core/verification.ts +0 -1594
- package/src/host/verification-gate.ts +0 -487
- package/src/host/verification-runner.ts +0 -702
- package/src/host/workspace-evidence.ts +0 -176
package/src/host-service.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { CardDefaults } from './core/card-defaults.ts'
|
|
|
16
16
|
import { TaskBoardExtensionRegistry } from './host/extension-registry.ts'
|
|
17
17
|
import type { TaskBoardExtension } from './core/extension.ts'
|
|
18
18
|
import { isTaskPermission, normalizeTargetId, type ExecutionOutcome, type ExecutionSummary, type ScheduleMode, type TaskRecord, type TaskStatus } from './core/tasks.ts'
|
|
19
|
-
import
|
|
19
|
+
import type { ModelCatalogView } from './core/model-catalog.ts'
|
|
20
20
|
import type { TaskPermission } from './core/handover.ts'
|
|
21
21
|
import type { TaskAttachment } from './core/attachment.ts'
|
|
22
22
|
import {
|
|
@@ -65,50 +65,22 @@ const ABANDONED_LAUNCH_REASON = 'host stopped before this execution started'
|
|
|
65
65
|
const REWORK_SESSION_REASON = 'rework: the card\'s previous execution session is not present and idle in the host session roster, so there is no conversation to send the rework instructions into'
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* The
|
|
68
|
+
* The host model catalog one run group freezes, read once for the whole group.
|
|
69
69
|
*
|
|
70
|
-
* The
|
|
71
|
-
* prompted. Admission delays the launch, so
|
|
72
|
-
* let a
|
|
73
|
-
* run and not others. Reading
|
|
74
|
-
* admission, which is its root's — keeps the whole
|
|
75
|
-
* still freezes it before any member
|
|
70
|
+
* The catalog decides whether a card's pinned reasoning level may be sent, and
|
|
71
|
+
* it is read BEFORE the session is prompted. Admission delays the launch, so
|
|
72
|
+
* reading it per execution would let a catalog change made while later members
|
|
73
|
+
* wait reach some members of one run and not others. Reading it once per run
|
|
74
|
+
* group — at the group's first admission, which is its root's — keeps the whole
|
|
75
|
+
* group on one catalog and still freezes it before any member is prompted.
|
|
76
76
|
*/
|
|
77
|
-
interface
|
|
78
|
-
|
|
79
|
-
/** The GLOBAL native-/goal switch, resolved exactly once for the run group. */
|
|
80
|
-
globalGoalEnabled: boolean
|
|
81
|
-
/** The host model catalog the group's contracts resolve their route from. */
|
|
77
|
+
interface FrozenRunCatalog {
|
|
78
|
+
/** The host model catalog the group's routes and reasoning levels resolve against. */
|
|
82
79
|
catalog: ModelCatalogView | undefined
|
|
83
80
|
}
|
|
84
81
|
|
|
85
|
-
/** Reads (or returns the already-read)
|
|
86
|
-
type
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Why an enforced goal execution settled failed while its acceptance DID run:
|
|
90
|
-
* attempts were recorded and none of them passed. The judge answered about the
|
|
91
|
-
* work and the work did not pass.
|
|
92
|
-
*/
|
|
93
|
-
export const NO_MATCHING_PASS_VERIFICATION_REASON = 'goal 验收:本次执行没有匹配的验收通过记录(验收未运行、未通过或报告来自其他执行),按未验收判失败。'
|
|
94
|
-
/**
|
|
95
|
-
* Why an enforced goal execution settled failed with ZERO acceptance records:
|
|
96
|
-
* the gate was never opened, so the judge never ran and nothing was ever judged
|
|
97
|
-
* (issue #1837). The root cause is a session that declared completion in prose
|
|
98
|
-
* instead of calling `update_goal(action: complete)` — a tool-adherence problem,
|
|
99
|
-
* NOT a quality verdict on the delivery — so this reason says so and keeps the
|
|
100
|
-
* two investigation directions apart.
|
|
101
|
-
*/
|
|
102
|
-
export const NEVER_INVOKED_VERIFICATION_REASON = 'goal 验收未触发:本次执行没有任何验收记录,验收门从未打开——执行会话没有调用 update_goal(action: complete) 来完成目标(常见于只在回复里宣告完成)。这不是质量判负:交付从未被裁判评估。'
|
|
103
|
-
/**
|
|
104
|
-
* Why an enforced goal execution settled failed while its ONLY acceptance
|
|
105
|
-
* records are INVALID: the judge answered but could not locate its own
|
|
106
|
-
* rejection, so the board stopped calling it. This is NOT an evidence-backed
|
|
107
|
-
* quality veto — the requirement is explicit that such a run must not be
|
|
108
|
-
* described as one — but the execution still has no matching pass, so it ends
|
|
109
|
-
* for lack of one, and the reason names that precisely.
|
|
110
|
-
*/
|
|
111
|
-
export const INVALID_ONLY_VERIFICATION_REASON = 'goal 验收无效:本次执行只记录了无效验收(裁判未能给出与任务要求对应、且可定位到本次证据的否决依据),看板已停止调用裁判。这**不是**有证据的质量判负:验收本身不可用,本次运行因没有匹配的通过记录而结束。请检查验收环境与证据可见性,或用 task_board_manage(action=reset-verification) 清除记录的无效验收后重新完成目标。'
|
|
82
|
+
/** Reads (or returns the already-read) catalog of one run group. */
|
|
83
|
+
type RunCatalogFreezer = () => Promise<FrozenRunCatalog>
|
|
112
84
|
|
|
113
85
|
/**
|
|
114
86
|
* Provenance of one cron-triggered run: when the rule fired and the zone
|
|
@@ -134,7 +106,7 @@ export interface ScheduledRunContext {
|
|
|
134
106
|
* an enabled rule (the new-task dialog and the one-time browser import),
|
|
135
107
|
* `set-schedule` edits one, and `delete`/`archive` drop one. `update` is
|
|
136
108
|
* deliberately absent — the update patch cannot carry a schedule — and neither
|
|
137
|
-
* can the run, move, lineage, permission
|
|
109
|
+
* can the run, move, lineage, permission or label actions.
|
|
138
110
|
*/
|
|
139
111
|
const SCHEDULE_WRITE_ACTIONS: ReadonlySet<TaskBoardAction['kind']> = new Set(['create', 'import', 'set-schedule', 'delete', 'archive'])
|
|
140
112
|
|
|
@@ -205,7 +177,6 @@ const ACTION_KINDS: Readonly<Record<TaskBoardAction['kind'], true>> = {
|
|
|
205
177
|
archive: true,
|
|
206
178
|
restore: true,
|
|
207
179
|
settle: true,
|
|
208
|
-
'reset-verification': true,
|
|
209
180
|
'record-external-outcome': true,
|
|
210
181
|
'set-schedule': true,
|
|
211
182
|
run: true,
|
|
@@ -265,11 +236,9 @@ export class TaskBoardHostService {
|
|
|
265
236
|
*/
|
|
266
237
|
private readonly unreadablePolls = new Map<string, number>()
|
|
267
238
|
private preventIdleSleep = false
|
|
268
|
-
|
|
269
|
-
private readonly
|
|
239
|
+
/** Live reader of the host model catalog; frozen per run group. */
|
|
240
|
+
private readonly modelCatalog: () => Promise<ModelCatalogView | undefined>
|
|
270
241
|
private readonly timers: HostTimerFace
|
|
271
|
-
/** Live reader of the global native-/goal switch; frozen per execution. */
|
|
272
|
-
private readonly goalRunEnabled: () => boolean
|
|
273
242
|
/** Live reader of the deployment's new-card defaults (published and applied per create). */
|
|
274
243
|
private readonly cardDefaults: () => CardDefaults
|
|
275
244
|
/**
|
|
@@ -324,21 +293,12 @@ export class TaskBoardHostService {
|
|
|
324
293
|
cardDefaults?: () => CardDefaults
|
|
325
294
|
timers?: HostTimerFace
|
|
326
295
|
/**
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
* default for every deployment that never configured it.
|
|
332
|
-
*/
|
|
333
|
-
goalRunEnabled?: () => boolean
|
|
334
|
-
/**
|
|
335
|
-
* Live acceptance settings (volatile config reads). Absent keeps goal
|
|
336
|
-
* acceptance OFF for every execution this service opens, which is what a
|
|
337
|
-
* programmatic mount without the settings domain gets.
|
|
296
|
+
* The host model catalog the card routes and reasoning levels resolve
|
|
297
|
+
* against, read live so a deployment that mounts the model service after the
|
|
298
|
+
* board still gains it. Absent means "no capability evidence": a pinned
|
|
299
|
+
* effort is then not sent at all.
|
|
338
300
|
*/
|
|
339
|
-
|
|
340
|
-
/** The host model catalog the acceptance contract resolves its route from. */
|
|
341
|
-
verificationCatalog?: () => Promise<ModelCatalogView | undefined>
|
|
301
|
+
modelCatalog?: () => Promise<ModelCatalogView | undefined>
|
|
342
302
|
/**
|
|
343
303
|
* Live admission width for run launches: the number of launches (one
|
|
344
304
|
* session creation and its prompt each) that may be in flight at once. Read
|
|
@@ -396,14 +356,12 @@ export class TaskBoardHostService {
|
|
|
396
356
|
this.timers = options.timers ?? PROCESS_TIMERS
|
|
397
357
|
this.power = options.power ?? new PowerInhibitor()
|
|
398
358
|
this.now = options.now ?? Date.now
|
|
399
|
-
this.goalRunEnabled = options.goalRunEnabled ?? (() => false)
|
|
400
359
|
this.cardDefaults = options.cardDefaults ?? (() => ({}))
|
|
401
360
|
this.runLaunchWidth = options.runLaunchWidth ?? (() => DEFAULT_RUN_LAUNCH_WIDTH)
|
|
402
361
|
this.spendBudgetTokens = options.spendBudgetTokens ?? (() => DEFAULT_SPEND_BUDGET_TOKENS)
|
|
403
362
|
this.spendUsedToday = options.spendUsedToday ?? (now => usedTokensToday(now))
|
|
404
363
|
this.launches = new LaunchAdmissionQueue(() => normalizeRunLaunchWidth(this.runLaunchWidth()))
|
|
405
|
-
this.
|
|
406
|
-
this.verificationCatalog = options.verificationCatalog ?? (async () => undefined)
|
|
364
|
+
this.modelCatalog = options.modelCatalog ?? (async () => undefined)
|
|
407
365
|
this.extensions = new TaskBoardExtensionRegistry({
|
|
408
366
|
ledger: this.ledger,
|
|
409
367
|
// Capability writes go through the board's own action path, so every
|
|
@@ -441,9 +399,6 @@ export class TaskBoardHostService {
|
|
|
441
399
|
this.syncPowerReasons()
|
|
442
400
|
this.pollTimer = this.timers.interval(() => { this.schedulePoll() }, sessionPollMs(this.sessionPollSeconds))
|
|
443
401
|
this.schedulePoll()
|
|
444
|
-
// Boot is also the cleanup catch-up point: an execution that passed before
|
|
445
|
-
// the Host stopped may still hold its detail (a crash, a failed write).
|
|
446
|
-
this.cleanupPendingAcceptanceDetail()
|
|
447
402
|
// Boot is a recovery point: an occurrence armed while the Host was down is
|
|
448
403
|
// not replayed, and each schedule rolls to its next future target. A
|
|
449
404
|
// schedule the Board should have served while running is then armed
|
|
@@ -519,13 +474,9 @@ export class TaskBoardHostService {
|
|
|
519
474
|
power: this.power.snapshot(),
|
|
520
475
|
sessionDefaultPermission: this.ledger.sessionDefaultPermission,
|
|
521
476
|
maxSubtaskDepth: this.ledger.maxSubtaskDepth,
|
|
522
|
-
// The
|
|
523
|
-
//
|
|
524
|
-
//
|
|
525
|
-
goalRunEnabled: this.goalRunEnabled(),
|
|
526
|
-
// The new-card defaults are published live for the same reason the switch
|
|
527
|
-
// is: the create dialog prefills from them, and each creating session
|
|
528
|
-
// re-reads them for the create it submits.
|
|
477
|
+
// The new-card defaults are published live: the create dialog prefills
|
|
478
|
+
// from them, and each creating session re-reads them for the create it
|
|
479
|
+
// submits.
|
|
529
480
|
...(cardDefaults === undefined ? {} : { cardDefaults }),
|
|
530
481
|
// The attachment limits travel with the snapshot so the browser can
|
|
531
482
|
// refuse an oversized selection before it uploads anything.
|
|
@@ -543,26 +494,13 @@ export class TaskBoardHostService {
|
|
|
543
494
|
}
|
|
544
495
|
|
|
545
496
|
/**
|
|
546
|
-
* The
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
* The card shows the RESOLVED route, not the raw configuration, so "inherit
|
|
550
|
-
* host" reads as the concrete model and reasoning level the next execution
|
|
551
|
-
* will actually freeze, including any recorded effort fallback.
|
|
552
|
-
* @returns the resolved acceptance options.
|
|
497
|
+
* The host model catalog the settings card's model and reasoning-level
|
|
498
|
+
* choices come from.
|
|
499
|
+
* @returns the catalog, or an empty one when this deployment serves none.
|
|
553
500
|
*/
|
|
554
|
-
async
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
catalog: ModelCatalogView
|
|
558
|
-
}> {
|
|
559
|
-
const settings = this.verificationSettings()
|
|
560
|
-
const catalog = await this.verificationCatalog()
|
|
561
|
-
return {
|
|
562
|
-
settings,
|
|
563
|
-
contract: resolveContract(settings, catalog),
|
|
564
|
-
catalog: catalog ?? { groups: [] },
|
|
565
|
-
}
|
|
501
|
+
async modelCatalogOptions(): Promise<{ catalog: ModelCatalogView }> {
|
|
502
|
+
const catalog = await this.modelCatalog()
|
|
503
|
+
return { catalog: catalog ?? { groups: [] } }
|
|
566
504
|
}
|
|
567
505
|
|
|
568
506
|
/** SSE frame payload; deliberately skips the tasks deep-clone of {@link snapshot}. */
|
|
@@ -770,7 +708,7 @@ export class TaskBoardHostService {
|
|
|
770
708
|
this.listeners.clear()
|
|
771
709
|
}
|
|
772
710
|
|
|
773
|
-
private async launch(opened: OpenedRun, schedule?: ScheduledRunContext,
|
|
711
|
+
private async launch(opened: OpenedRun, schedule?: ScheduledRunContext, freezeCatalog?: RunCatalogFreezer): Promise<void> {
|
|
774
712
|
/** The session this launch attached to the execution, once it exists. */
|
|
775
713
|
let attached: string | undefined
|
|
776
714
|
try {
|
|
@@ -810,65 +748,27 @@ export class TaskBoardHostService {
|
|
|
810
748
|
...(rework === undefined ? {} : { rework }),
|
|
811
749
|
}
|
|
812
750
|
const promptContext = Object.keys(contextParts).length === 0 ? undefined : contextParts
|
|
813
|
-
// Freeze this
|
|
814
|
-
//
|
|
815
|
-
//
|
|
816
|
-
// same contract from an OFF switch: the board-wide switch decides the
|
|
817
|
-
// default, the card decides this execution, and both are read here.
|
|
751
|
+
// Freeze this run group's model catalog BEFORE the session is prompted: a
|
|
752
|
+
// catalog change made while the run is in flight must not change which
|
|
753
|
+
// reasoning level this execution is allowed to send.
|
|
818
754
|
//
|
|
819
755
|
// The read is the run GROUP's when the queue handed one down: admission
|
|
820
|
-
// delays a member's launch, so a per-execution read would let a
|
|
821
|
-
//
|
|
822
|
-
// others. One group, one
|
|
756
|
+
// delays a member's launch, so a per-execution read would let a change
|
|
757
|
+
// made while later members wait reach some members of one run and not
|
|
758
|
+
// others. One group, one catalog — and still frozen before the group's
|
|
823
759
|
// first session is prompted.
|
|
824
|
-
const {
|
|
825
|
-
// The GLOBAL native-/goal switch is read ONCE per run group and carried by
|
|
826
|
-
// value for the whole execution: a settings edit after this point can only
|
|
827
|
-
// affect executions that start later.
|
|
828
|
-
// The card must ASK for the goal run: the option is off by default, so an
|
|
829
|
-
// absent value is a plain turn exactly like an explicit false.
|
|
830
|
-
const goalEnabled = globalGoalEnabled && opened.task.goalRun === true
|
|
831
|
-
// The card's opt-out is a DISTINCT reason, not the board switch: the
|
|
832
|
-
// report must be able to say which of the two turned the gate off.
|
|
833
|
-
const skippedBy: ExecutionVerification['applicability'] = opened.task.skipVerification === true ? 'skipped' : 'disabled'
|
|
834
|
-
const contract = resolveContract(
|
|
835
|
-
{ ...settings, enabled: settings.enabled && opened.task.skipVerification !== true },
|
|
836
|
-
catalog,
|
|
837
|
-
)
|
|
838
|
-
// An execution that will not become a goal run can never fire the
|
|
839
|
-
// completion gate, so it is marked with the reason that actually applied:
|
|
840
|
-
// the global switch being off is its OWN reason, distinct from this run
|
|
841
|
-
// simply not becoming a goal run (the card never opted in, or a refused or
|
|
842
|
-
// unavailable /goal command), and it must never read as an accepted run.
|
|
843
|
-
// The reason names which switch withheld the goal: the GLOBAL master
|
|
844
|
-
// switch (this board never arms /goal) is a different fact from the card's
|
|
845
|
-
// own goal option staying off — which is the default, so it is what an
|
|
846
|
-
// untouched card gets.
|
|
847
|
-
const notArmed: ExecutionVerification['applicability'] = globalGoalEnabled ? 'goal-unavailable' : 'goal-disabled'
|
|
848
|
-
const initial: ExecutionVerification = {
|
|
849
|
-
contract,
|
|
850
|
-
attempts: [],
|
|
851
|
-
applicability: !contract.enabled ? skippedBy : notArmed,
|
|
852
|
-
}
|
|
853
|
-
this.ledger.setVerification(opened.task.id, opened.execution.id, initial)
|
|
760
|
+
const { catalog } = await (freezeCatalog ?? (() => this.readRunCatalog()))()
|
|
854
761
|
const sessionId = await this.runner.launch(opened.task, {
|
|
855
762
|
...(reuseSessionId === undefined ? {} : { reuseSessionId }),
|
|
856
763
|
...(forcedPreset === undefined ? {} : { agentPreset: forcedPreset }),
|
|
857
764
|
...(promptContext === undefined ? {} : { promptContext }),
|
|
858
|
-
// The
|
|
859
|
-
// arming decision is exactly the one made above.
|
|
860
|
-
goalEnabled,
|
|
861
|
-
// The same catalog snapshot the acceptance contract was frozen from.
|
|
765
|
+
// The same catalog snapshot the reasoning decision is resolved from.
|
|
862
766
|
catalog,
|
|
863
|
-
// Bind the session to the execution before the prompt is queued
|
|
864
|
-
// completion gate can never observe the agent without its binding.
|
|
767
|
+
// Bind the session to the execution before the prompt is queued.
|
|
865
768
|
onSession: (id) => {
|
|
866
769
|
attached = id
|
|
867
770
|
this.ledger.attachSession(opened.task.id, opened.execution.id, id)
|
|
868
771
|
},
|
|
869
|
-
onGoalArmed: (armed) => {
|
|
870
|
-
this.setApplicability(opened.task.id, opened.execution.id, !contract.enabled ? skippedBy : armed ? 'enforced' : notArmed)
|
|
871
|
-
},
|
|
872
772
|
})
|
|
873
773
|
if (attached === undefined) this.ledger.attachSession(opened.task.id, opened.execution.id, sessionId)
|
|
874
774
|
} catch (error) {
|
|
@@ -888,27 +788,22 @@ export class TaskBoardHostService {
|
|
|
888
788
|
}
|
|
889
789
|
|
|
890
790
|
/**
|
|
891
|
-
* Read the
|
|
892
|
-
*
|
|
893
|
-
* switch, then the model catalog that both resolves the contract's route and
|
|
894
|
-
* decides the reasoning effort the session may be given.
|
|
791
|
+
* Read the model catalog one run group freezes. The catalog is what decides
|
|
792
|
+
* whether a card's pinned reasoning level may be sent to the session.
|
|
895
793
|
*/
|
|
896
|
-
private async
|
|
897
|
-
|
|
898
|
-
const globalGoalEnabled = this.goalRunEnabled() === true
|
|
899
|
-
const catalog = await this.verificationCatalog()
|
|
900
|
-
return { settings, globalGoalEnabled, catalog }
|
|
794
|
+
private async readRunCatalog(): Promise<FrozenRunCatalog> {
|
|
795
|
+
return { catalog: await this.modelCatalog() }
|
|
901
796
|
}
|
|
902
797
|
|
|
903
798
|
/**
|
|
904
|
-
* A {@link
|
|
799
|
+
* A {@link RunCatalogFreezer} that reads once and hands the SAME value to
|
|
905
800
|
* every later caller of one run group. A read that fails is not cached: the
|
|
906
801
|
* next member reads again, exactly as a per-execution read would have.
|
|
907
802
|
*/
|
|
908
|
-
private
|
|
909
|
-
let pending: Promise<
|
|
803
|
+
private catalogFreezerForRunGroup(): RunCatalogFreezer {
|
|
804
|
+
let pending: Promise<FrozenRunCatalog> | undefined
|
|
910
805
|
return () => {
|
|
911
|
-
pending ??= this.
|
|
806
|
+
pending ??= this.readRunCatalog().catch((error: unknown) => {
|
|
912
807
|
pending = undefined
|
|
913
808
|
throw error
|
|
914
809
|
})
|
|
@@ -1047,16 +942,6 @@ export class TaskBoardHostService {
|
|
|
1047
942
|
): Promise<void> {
|
|
1048
943
|
for (const execution of executions) {
|
|
1049
944
|
if (execution.sessionId === undefined) continue
|
|
1050
|
-
const record = this.ledger.getTask(execution.taskId)?.executions.find(entry => entry.id === execution.executionId)
|
|
1051
|
-
const verification = record?.verification
|
|
1052
|
-
// A cycle the gate already closed is decided here, without another
|
|
1053
|
-
// inspection: the goal may still be active (or un-blockable) exactly
|
|
1054
|
-
// because the acceptance failed, and the card must not stay in the
|
|
1055
|
-
// running column waiting for a verdict that is already recorded.
|
|
1056
|
-
if (verification?.failedReason !== undefined) {
|
|
1057
|
-
this.settleAndNotify(execution.taskId, execution.executionId, 'failed', verification.failedReason)
|
|
1058
|
-
continue
|
|
1059
|
-
}
|
|
1060
945
|
try {
|
|
1061
946
|
// A team member's turn is read even while the roster calls its session
|
|
1062
947
|
// running: a durable teammate never goes idle for good.
|
|
@@ -1069,29 +954,6 @@ export class TaskBoardHostService {
|
|
|
1069
954
|
continue
|
|
1070
955
|
}
|
|
1071
956
|
this.unreadablePolls.delete(execution.executionId)
|
|
1072
|
-
// Forced acceptance: the old fallback paths — a completed turn, a
|
|
1073
|
-
// paused goal, an unreadable projection, a manual settle — must never
|
|
1074
|
-
// be mistaken for a verified success. Only a matching pass record
|
|
1075
|
-
// settles this execution as succeeded.
|
|
1076
|
-
if (result.outcome === 'succeeded' && verificationRequired(verification) && passedAttempt(verification) === undefined) {
|
|
1077
|
-
// Two different failures share this branch, and they send the reader
|
|
1078
|
-
// in opposite directions: attempts on record mean the judge ran and
|
|
1079
|
-
// the work did not pass, while zero attempts mean the gate never
|
|
1080
|
-
// opened at all (issue #1837) — the session narrated completion
|
|
1081
|
-
// instead of calling `update_goal(action: complete)`.
|
|
1082
|
-
this.settleAndNotify(
|
|
1083
|
-
execution.taskId,
|
|
1084
|
-
execution.executionId,
|
|
1085
|
-
'failed',
|
|
1086
|
-
verificationNeverInvoked(verification)
|
|
1087
|
-
? NEVER_INVOKED_VERIFICATION_REASON
|
|
1088
|
-
: verificationOnlyInvalid(verification)
|
|
1089
|
-
? INVALID_ONLY_VERIFICATION_REASON
|
|
1090
|
-
: NO_MATCHING_PASS_VERIFICATION_REASON,
|
|
1091
|
-
result.summary,
|
|
1092
|
-
)
|
|
1093
|
-
continue
|
|
1094
|
-
}
|
|
1095
957
|
// The run's closing text rides whichever verdict it earned: a failed
|
|
1096
958
|
// execution still leaves what it managed to say.
|
|
1097
959
|
this.settleAndNotify(execution.taskId, execution.executionId, result.outcome, 'error' in result ? result.error : undefined, result.summary)
|
|
@@ -1134,73 +996,6 @@ export class TaskBoardHostService {
|
|
|
1134
996
|
outcome,
|
|
1135
997
|
...(error === undefined ? {} : { error }),
|
|
1136
998
|
})
|
|
1137
|
-
// The pass record and the settlement are DURABLE by this point (both are in
|
|
1138
|
-
// the ledger above), so the acceptance-only detail may now be cleaned. A
|
|
1139
|
-
// cleanup failure is recorded against the execution and retried on the next
|
|
1140
|
-
// Host start; it never revokes the pass this settlement just wrote.
|
|
1141
|
-
if (outcome === 'succeeded') this.cleanupAcceptanceDetail(taskId, executionId)
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
/**
|
|
1145
|
-
* Remove one execution's acceptance-only detail after it PASSED and settled.
|
|
1146
|
-
*
|
|
1147
|
-
* Deliberately narrow: only the acceptance mechanism's own per-attempt
|
|
1148
|
-
* material (findings, invalid diagnostics, the bulky judge side) is removed,
|
|
1149
|
-
* and only for THIS execution, keyed by its own id in the ledger it belongs
|
|
1150
|
-
* to. No user file, task artifact, raw session history or other execution's
|
|
1151
|
-
* record is read or written. Idempotent by the record's own state, and it
|
|
1152
|
-
* clearly never touches a run that did not pass (the caller's guard) — a
|
|
1153
|
-
* failed or invalid execution keeps everything a repair or a review needs.
|
|
1154
|
-
* @param taskId - the task whose execution settled.
|
|
1155
|
-
* @param executionId - the settled execution.
|
|
1156
|
-
*/
|
|
1157
|
-
private cleanupAcceptanceDetail(taskId: string, executionId: string): void {
|
|
1158
|
-
const execution = this.ledger.getTask(taskId)?.executions.find(entry => entry.id === executionId)
|
|
1159
|
-
const verification = execution?.verification
|
|
1160
|
-
// Only an execution with a REAL pass record is cleaned. An execution whose
|
|
1161
|
-
// acceptance never ran (no block) or was disabled/skipped has nothing this
|
|
1162
|
-
// mechanism created, and a failed one must keep its evidence.
|
|
1163
|
-
if (verification === undefined || passedAttempt(verification) === undefined) return
|
|
1164
|
-
if (verification.cleanup?.state === 'cleaned') return
|
|
1165
|
-
try {
|
|
1166
|
-
const cleaned = withAcceptanceDetailCleared(verification, this.now())
|
|
1167
|
-
if (cleaned === undefined) return
|
|
1168
|
-
this.ledger.setVerification(taskId, executionId, cleaned)
|
|
1169
|
-
} catch (error) {
|
|
1170
|
-
// Record the failure so the UI can say the cleanup is pending and the
|
|
1171
|
-
// Host retries it at start; the pass itself is untouched.
|
|
1172
|
-
const attempts = (verification.cleanup?.attempts ?? 0) + 1
|
|
1173
|
-
this.ledger.setVerification(taskId, executionId, {
|
|
1174
|
-
...verification,
|
|
1175
|
-
cleanup: {
|
|
1176
|
-
state: 'failed',
|
|
1177
|
-
attempts,
|
|
1178
|
-
startedAt: verification.cleanup?.startedAt ?? this.now(),
|
|
1179
|
-
lastError: error instanceof Error ? error.message : String(error),
|
|
1180
|
-
audit: verification.cleanup?.audit ?? [],
|
|
1181
|
-
},
|
|
1182
|
-
})
|
|
1183
|
-
safeConsoleError('[dsh-task-board] acceptance-detail cleanup failed; it is retried on the next Host start', error)
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* Catch-up pass: clean the acceptance detail of every execution that PASSED
|
|
1189
|
-
* and settled but whose cleanup did not finish (a crash, a failed write, a
|
|
1190
|
-
* Host killed mid-cleanup).
|
|
1191
|
-
*
|
|
1192
|
-
* The same bounds as any other cleanup apply — only a real pass record on a
|
|
1193
|
-
* settled execution is touched — so this can never delete material belonging
|
|
1194
|
-
* to an execution that did not pass, and never a user file.
|
|
1195
|
-
*/
|
|
1196
|
-
private cleanupPendingAcceptanceDetail(): void {
|
|
1197
|
-
for (const task of this.ledger.allTasks()) {
|
|
1198
|
-
for (const execution of task.executions) {
|
|
1199
|
-
if (execution.endedAt === undefined) continue
|
|
1200
|
-
if (execution.result !== 'succeeded') continue
|
|
1201
|
-
this.cleanupAcceptanceDetail(task.id, execution.id)
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
999
|
}
|
|
1205
1000
|
|
|
1206
1001
|
private noteUnreadableInspection(execution: OpenExecutionReference, reason: string | undefined): void {
|
|
@@ -1316,21 +1111,11 @@ export class TaskBoardHostService {
|
|
|
1316
1111
|
private dispatchRuns(runs: readonly OpenedRun[], schedule?: ScheduledRunContext): void {
|
|
1317
1112
|
const root = runs[0]
|
|
1318
1113
|
if (root === undefined) return
|
|
1319
|
-
this.scheduleLaunch(root, schedule, this.
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* Move one execution's applicability without touching its frozen contract or
|
|
1324
|
-
* its recorded attempts (used when the run's goal form becomes known).
|
|
1325
|
-
*/
|
|
1326
|
-
private setApplicability(taskId: string, executionId: string, applicability: ExecutionVerification['applicability']): void {
|
|
1327
|
-
const verification = this.ledger.getTask(taskId)?.executions.find(entry => entry.id === executionId)?.verification
|
|
1328
|
-
if (verification === undefined || verification.applicability === applicability) return
|
|
1329
|
-
this.ledger.setVerification(taskId, executionId, { ...verification, applicability })
|
|
1114
|
+
this.scheduleLaunch(root, schedule, this.catalogFreezerForRunGroup())
|
|
1330
1115
|
}
|
|
1331
1116
|
|
|
1332
|
-
private scheduleLaunch(opened: OpenedRun, schedule?: ScheduledRunContext,
|
|
1333
|
-
this.enqueueLaunch(opened, () => this.launch(opened, schedule,
|
|
1117
|
+
private scheduleLaunch(opened: OpenedRun, schedule?: ScheduledRunContext, freezeCatalog?: RunCatalogFreezer): void {
|
|
1118
|
+
this.enqueueLaunch(opened, () => this.launch(opened, schedule, freezeCatalog).catch(error => {
|
|
1334
1119
|
safeConsoleError('[dsh-task-board] execution launch settlement failed', error)
|
|
1335
1120
|
}), schedule)
|
|
1336
1121
|
}
|