@linxin666/dsh-client-ui-task-board 0.4.16 → 0.4.18
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 +107 -1354
- package/lib/client.js.map +1 -1
- package/lib/index.js +138 -2537
- 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/client/settings-entry-form.d.ts +1 -1
- 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 -201
- package/src/client/board/ExecutionLog.tsx +2 -5
- package/src/client/board/NewTaskModal.tsx +1 -42
- package/src/client/board/TaskBoard.tsx +2 -2
- 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 +2 -2
- package/src/client/locales.ts +6 -224
- package/src/client/settings-entry-form.ts +1 -1
- package/src/core/attachment.ts +1 -0
- package/src/core/controller.ts +1 -3
- package/src/core/extension.ts +4 -5
- package/src/core/freeze-snapshot.ts +3 -3
- 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/extension-registry.ts +2 -2
- package/src/host/llm-dispatch.ts +8 -10
- package/src/host-ledger.ts +3 -89
- package/src/host-routes.ts +4 -4
- package/src/host-runner.ts +13 -139
- package/src/host-service.ts +51 -266
- package/src/index.ts +9 -163
- package/src/protocol.ts +9 -44
- 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
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Goal acceptance gate: the board's evaluator-backed certification of a goal
|
|
3
|
-
* completion claim.
|
|
4
|
-
*
|
|
5
|
-
* The gate sits on the official tool pre-execute lifecycle and intercepts the
|
|
6
|
-
* one call that ends a goal run — `update_goal` with `action: 'complete'`
|
|
7
|
-
* — BEFORE it takes effect. This is why the board does not ask the agent to
|
|
8
|
-
* verify itself: the tool call that finishes the goal is refused until a
|
|
9
|
-
* matching acceptance pass record exists, so no prompt wording and no
|
|
10
|
-
* self-report can route around it.
|
|
11
|
-
*
|
|
12
|
-
* Semantics owned here:
|
|
13
|
-
* - one acceptance cycle per EXECUTION, spent at most twice: the first failure
|
|
14
|
-
* returns its findings to the fixing agent, the second ends the cycle;
|
|
15
|
-
* - a repeated completion call during a repair, a new automatic goal round, a
|
|
16
|
-
* plugin reload and a Host restart all reuse the same cycle rather than
|
|
17
|
-
* resetting it (the budget is persisted on the execution record);
|
|
18
|
-
* - an anomaly (timeout, authentication, unparseable answer, an unusable judge
|
|
19
|
-
* route) is recorded separately from a quality verdict and is never treated
|
|
20
|
-
* as one;
|
|
21
|
-
* - exhausting the anomaly budget does NOT judge the card: an environment that
|
|
22
|
-
* cannot answer is not the work failing, so the cycle is held open with no
|
|
23
|
-
* judge call until a user clears the recorded anomalies (issue #1828);
|
|
24
|
-
* - an attempt the time budget ends before any verdict is recorded as its own
|
|
25
|
-
* stage and charged to no budget at all (issue #1828);
|
|
26
|
-
* - an INVALID acceptance (a veto whose required evidence is missing,
|
|
27
|
-
* unlocatable, or aimed at the empty-work baseline) is recorded in its own
|
|
28
|
-
* stage, spends its OWN bounded budget, and never consumes a quality attempt
|
|
29
|
-
* or fails the card; when that budget is spent the cycle is held for a human
|
|
30
|
-
* exactly like a spent anomaly budget;
|
|
31
|
-
* - concurrent completion calls for one execution share one acceptance.
|
|
32
|
-
|
|
33
|
-
* The validity check itself is program-level (`assessAcceptanceValidity` in
|
|
34
|
-
* `core/verification.ts`), applied after the judge answers and BEFORE any
|
|
35
|
-
* quality verdict is written: a stronger prompt alone could not enforce it.
|
|
36
|
-
*/
|
|
37
|
-
import type { PreToolDecision } from '@deepseek-ai/dsh-tools';
|
|
38
|
-
import type { LlmRuntime } from '@deepseek-ai/dsh-llm';
|
|
39
|
-
import { type WorkspaceChangeSource } from './workspace-evidence.ts';
|
|
40
|
-
import type { HostTaskLedger } from '../host-ledger.ts';
|
|
41
|
-
/** The subset of the official goal service this gate drives. */
|
|
42
|
-
export interface GoalFace {
|
|
43
|
-
get(agent: unknown): {
|
|
44
|
-
id: string;
|
|
45
|
-
revision: number;
|
|
46
|
-
objective: string;
|
|
47
|
-
} | undefined;
|
|
48
|
-
block(agent: unknown, ref: {
|
|
49
|
-
id: string;
|
|
50
|
-
revision: number;
|
|
51
|
-
}, reason: {
|
|
52
|
-
code: string;
|
|
53
|
-
message: string;
|
|
54
|
-
}): unknown;
|
|
55
|
-
}
|
|
56
|
-
/** Everything the gate needs from its owner. */
|
|
57
|
-
export interface GoalVerificationGateDeps {
|
|
58
|
-
ledger: HostTaskLedger;
|
|
59
|
-
/** Resolve the optional model runtime lazily (it may activate later). */
|
|
60
|
-
llm?: () => LlmRuntime | undefined;
|
|
61
|
-
/** Resolve the optional goal service lazily. */
|
|
62
|
-
goals?: () => GoalFace | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Resolve the optional host change service lazily. Absent (or a deployment
|
|
65
|
-
* that serves none) simply means the judge sees the trajectory alone.
|
|
66
|
-
*/
|
|
67
|
-
workspaceChanges?: () => WorkspaceChangeSource | undefined;
|
|
68
|
-
/**
|
|
69
|
-
* Ceiling of one judge request, read per acceptance (a row setting). Absent
|
|
70
|
-
* keeps the default, so a programmatic mount still judges.
|
|
71
|
-
*/
|
|
72
|
-
callTimeoutMs?: () => number;
|
|
73
|
-
/**
|
|
74
|
-
* Total ceiling of one acceptance attempt, read per acceptance (a row
|
|
75
|
-
* setting). Absent keeps the default.
|
|
76
|
-
*/
|
|
77
|
-
budgetMs?: () => number;
|
|
78
|
-
logger: {
|
|
79
|
-
warn(message: string, ...rest: unknown[]): void;
|
|
80
|
-
};
|
|
81
|
-
now?: () => number;
|
|
82
|
-
}
|
|
83
|
-
/** The shape of one tool pre-execution the gate inspects. */
|
|
84
|
-
export interface GateExecution {
|
|
85
|
-
name: string;
|
|
86
|
-
arguments: unknown;
|
|
87
|
-
agent?: unknown;
|
|
88
|
-
signal: AbortSignal;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Create the goal acceptance gate.
|
|
92
|
-
* @param deps - the ledger, the model runtime, the goal service and the settings.
|
|
93
|
-
* @returns the `tools/pre-execute` listener body (without the waterfall next()).
|
|
94
|
-
*/
|
|
95
|
-
export declare function createGoalVerificationGate(deps: GoalVerificationGateDeps): (exec: GateExecution) => Promise<PreToolDecision | undefined>;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Goal acceptance runner: evidence assembly and the judge calls of one
|
|
3
|
-
* acceptance attempt.
|
|
4
|
-
*
|
|
5
|
-
* Lives in the host half because it needs the live session event log and the
|
|
6
|
-
* official `llm` service; every rule it applies (criteria, scale, tags,
|
|
7
|
-
* thresholds, budgets, caps) comes from `../core/verification.ts`, which mirrors
|
|
8
|
-
* the installed dsh-llm-verifier 0.8.4 default final acceptance.
|
|
9
|
-
*/
|
|
10
|
-
import { type LlmRuntime } from '@deepseek-ai/dsh-llm';
|
|
11
|
-
import { type VerificationAttempt, type VerificationRoute, type VerificationUsage } from '../core/verification.ts';
|
|
12
|
-
/** Largest trace handed to the judge, mirroring the verifier's default cap. */
|
|
13
|
-
export declare const VERIFICATION_MAX_TRACE_CHARS = 80000;
|
|
14
|
-
/** Largest single trace entry; one huge tool result must not eat the budget. */
|
|
15
|
-
export declare const VERIFICATION_MAX_ENTRY_CHARS = 4000;
|
|
16
|
-
/** Largest per-finding text kept from one judge answer. */
|
|
17
|
-
export declare const VERIFICATION_MAX_FINDING_CHARS = 400;
|
|
18
|
-
/** Largest verbatim citation kept from one finding. */
|
|
19
|
-
export declare const VERIFICATION_MAX_QUOTE_CHARS = 600;
|
|
20
|
-
/** Largest requirement/observation/gap statement kept from one finding. */
|
|
21
|
-
export declare const VERIFICATION_MAX_PROBLEM_CHARS = 400;
|
|
22
|
-
/** Structured findings kept per judge answer and per acceptance. */
|
|
23
|
-
export declare const VERIFICATION_MAX_FINDINGS_PER_CALL = 3;
|
|
24
|
-
export declare const VERIFICATION_MAX_FINDINGS = 12;
|
|
25
|
-
/**
|
|
26
|
-
* Default ceiling of ONE judge request. The effective ceiling is a row setting
|
|
27
|
-
* (`goalVerificationCallTimeoutSeconds`), read live by the gate, because 120s was
|
|
28
|
-
* tight for a reasoning model reading an 80,000 character trace with a 16,384
|
|
29
|
-
* token output cap: every timeout it produced was charged as an acceptance
|
|
30
|
-
* anomaly against a budget that then failed the card.
|
|
31
|
-
*/
|
|
32
|
-
export declare const VERIFICATION_CALL_TIMEOUT_MS = 150000;
|
|
33
|
-
export declare const VERIFICATION_MAX_TOKENS = 16384;
|
|
34
|
-
export declare const VERIFICATION_TEMPERATURE = 0.2;
|
|
35
|
-
export declare const VERIFICATION_REQUEST_ATTEMPTS = 3;
|
|
36
|
-
/** Redaction patterns, mirrored from the verifier's defaults. */
|
|
37
|
-
export declare const VERIFICATION_REDACT_PATTERNS: readonly string[];
|
|
38
|
-
/** Why one acceptance could not produce a verdict. */
|
|
39
|
-
export type VerificationErrorKind = 'route-unavailable' | 'timeout' | 'auth' | 'parse' | 'request' | 'aborted' | 'budget';
|
|
40
|
-
/**
|
|
41
|
-
* The time one acceptance attempt may still spend.
|
|
42
|
-
*
|
|
43
|
-
* `deadline` is the instant the whole attempt runs out; `callTimeoutMs` is the
|
|
44
|
-
* ceiling of a single judge call. The pair is what ties the retry budget to the
|
|
45
|
-
* acceptance budget: a call is not started unless its own ceiling still fits
|
|
46
|
-
* inside what is left, because starting one the outer budget will abort anyway
|
|
47
|
-
* only burns wall time and turns a slow machine into an anomaly.
|
|
48
|
-
*/
|
|
49
|
-
export interface AcceptanceBudget {
|
|
50
|
-
/** Absolute instant (ms epoch) the acceptance attempt runs out at. */
|
|
51
|
-
deadline: number;
|
|
52
|
-
/** Ceiling of one judge call in milliseconds. */
|
|
53
|
-
callTimeoutMs: number;
|
|
54
|
-
/** Clock the caller runs on, injected so tests drive it deterministically. */
|
|
55
|
-
now: () => number;
|
|
56
|
-
}
|
|
57
|
-
/** An acceptance anomaly: never a quality verdict, always recorded as one. */
|
|
58
|
-
export declare class VerificationError extends Error {
|
|
59
|
-
readonly kind: VerificationErrorKind;
|
|
60
|
-
readonly usage: VerificationUsage;
|
|
61
|
-
constructor(kind: VerificationErrorKind, message: string, usage?: VerificationUsage, options?: {
|
|
62
|
-
cause?: unknown;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/** Fresh zeroed usage counters. */
|
|
66
|
-
export declare function emptyUsage(): VerificationUsage;
|
|
67
|
-
/** Structural view of one session event, as the host log carries it. */
|
|
68
|
-
interface RawEvent {
|
|
69
|
-
type?: unknown;
|
|
70
|
-
seq?: unknown;
|
|
71
|
-
time?: unknown;
|
|
72
|
-
data?: unknown;
|
|
73
|
-
}
|
|
74
|
-
/** Read one session's events across the shapes the SDK cohort exposes. */
|
|
75
|
-
export declare function sessionEvents(session: unknown): readonly RawEvent[];
|
|
76
|
-
/** Evidence assembled for one acceptance attempt. */
|
|
77
|
-
export interface AcceptanceEvidence {
|
|
78
|
-
problem: string;
|
|
79
|
-
trace: string;
|
|
80
|
-
entries: number;
|
|
81
|
-
fromSeq?: number;
|
|
82
|
-
toSeq?: number;
|
|
83
|
-
omittedCharacters: number;
|
|
84
|
-
hash: string;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Assemble the evidence one acceptance judges.
|
|
88
|
-
*
|
|
89
|
-
* The window starts at the execution's own `startedAt`, never at the session's
|
|
90
|
-
* first event: a reused session carries the history of earlier executions, and
|
|
91
|
-
* those runs must not be judged as this one's work. Only observed output is
|
|
92
|
-
* rendered — tool calls with their arguments and their results, assistant
|
|
93
|
-
* prose, goal round markers and team messages — and the result is redacted and
|
|
94
|
-
* capped before it ever reaches a judge.
|
|
95
|
-
* @param session - the live session of the execution.
|
|
96
|
-
* @param problem - the execution's composed prompt, shown as the task statement.
|
|
97
|
-
* @param startedAt - the instant the execution opened (ms epoch).
|
|
98
|
-
* @returns the bounded, redacted evidence.
|
|
99
|
-
*/
|
|
100
|
-
/**
|
|
101
|
-
* The session events inside one execution's own window.
|
|
102
|
-
*
|
|
103
|
-
* A reused session carries the history of earlier executions; only the events
|
|
104
|
-
* at or after this execution's start belong to the work being judged.
|
|
105
|
-
* @param session - the live session.
|
|
106
|
-
* @param startedAt - the execution's start instant (ms epoch).
|
|
107
|
-
* @returns the events of this execution, oldest first.
|
|
108
|
-
*/
|
|
109
|
-
export declare function evidenceEvents(session: unknown, startedAt: number): readonly RawEvent[];
|
|
110
|
-
export declare function collectEvidence(session: unknown, problem: string, startedAt: number): AcceptanceEvidence;
|
|
111
|
-
/** The verdict of one acceptance attempt. */
|
|
112
|
-
export interface AcceptanceResult {
|
|
113
|
-
attempt: VerificationAttempt;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Run one acceptance: every criterion is judged twice, the odd round with the
|
|
117
|
-
* A/B slots swapped, and the per-round scores are mapped back and averaged per
|
|
118
|
-
* criterion.
|
|
119
|
-
* @param input - the judge route, evidence, threshold, time budget and cancellation.
|
|
120
|
-
* @returns the recorded attempt (quality verdict, anomaly, or budget stop).
|
|
121
|
-
*/
|
|
122
|
-
export declare function runAcceptance(input: {
|
|
123
|
-
llm: LlmRuntime;
|
|
124
|
-
route: VerificationRoute;
|
|
125
|
-
evidence: AcceptanceEvidence;
|
|
126
|
-
threshold: number;
|
|
127
|
-
index: number;
|
|
128
|
-
signal: AbortSignal;
|
|
129
|
-
/** Instant (ms epoch) the attempt runs out at; defaults to now plus the default budget. */
|
|
130
|
-
deadline?: number;
|
|
131
|
-
/** Ceiling of one judge call; defaults to {@link VERIFICATION_CALL_TIMEOUT_MS}. */
|
|
132
|
-
callTimeoutMs?: number;
|
|
133
|
-
/** Host-observed workspace changes, rendered as the prompt's reference context. */
|
|
134
|
-
context?: string;
|
|
135
|
-
/** How many changed files that context shows. */
|
|
136
|
-
workspaceFiles?: number;
|
|
137
|
-
now?: () => number;
|
|
138
|
-
}): Promise<AcceptanceResult>;
|
|
139
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/** The subset of the host change service this module drives. */
|
|
2
|
-
export interface WorkspaceChangeSource {
|
|
3
|
-
summary(sessionId: string, seq: number): unknown;
|
|
4
|
-
diff(sessionId: string, seq: number, index: number, signal: AbortSignal): Promise<unknown>;
|
|
5
|
-
}
|
|
6
|
-
/** One session event, as the host log carries it. */
|
|
7
|
-
interface RawEvent {
|
|
8
|
-
type?: unknown;
|
|
9
|
-
seq?: unknown;
|
|
10
|
-
}
|
|
11
|
-
/** How many changed files one evidence block renders. */
|
|
12
|
-
export declare const MAX_WORKSPACE_FILES = 8;
|
|
13
|
-
/** Character ceiling for the whole rendered block. */
|
|
14
|
-
export declare const WORKSPACE_EVIDENCE_MAX_CHARS = 24000;
|
|
15
|
-
/** Character ceiling for one file's rendered comparison. */
|
|
16
|
-
export declare const WORKSPACE_EVIDENCE_MAX_FILE_CHARS = 6000;
|
|
17
|
-
/**
|
|
18
|
-
* Resolve the optional host change service from a context-like object.
|
|
19
|
-
* @param ctx - anything exposing @@get(name)@@.
|
|
20
|
-
* @returns the service, or undefined when this deployment serves none.
|
|
21
|
-
*/
|
|
22
|
-
export declare function probeWorkspaceChanges(ctx: {
|
|
23
|
-
get(name: string): unknown;
|
|
24
|
-
}): WorkspaceChangeSource | undefined;
|
|
25
|
-
/** The sequence of the newest change event inside the reviewed window. */
|
|
26
|
-
export declare function latestChangeEvent(events: readonly RawEvent[]): {
|
|
27
|
-
seq: number;
|
|
28
|
-
turn?: number;
|
|
29
|
-
} | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Render the host's own record of what the reviewed window changed.
|
|
32
|
-
*
|
|
33
|
-
* Bounded twice — at most {@link MAX_WORKSPACE_FILES} files, and a shared
|
|
34
|
-
* character budget split across them — so one enormous generated file cannot
|
|
35
|
-
* crowd out every other change. Every failure degrades to less evidence (or an
|
|
36
|
-
* empty block) instead of an error, because the acceptance being prepared must
|
|
37
|
-
* still reach a verdict.
|
|
38
|
-
* @param events - session events already bounded to the execution's window.
|
|
39
|
-
* @param sessionId - the session whose changes these are.
|
|
40
|
-
* @param source - the probed host service.
|
|
41
|
-
* @param options - budget, cancellation and the diagnostic sink.
|
|
42
|
-
* @returns the rendered block plus how many files it shows.
|
|
43
|
-
*/
|
|
44
|
-
export declare function renderWorkspaceEvidence(events: readonly RawEvent[], sessionId: string, source: WorkspaceChangeSource, options: {
|
|
45
|
-
signal: AbortSignal;
|
|
46
|
-
warn?: (message: string) => void;
|
|
47
|
-
maxChars?: number;
|
|
48
|
-
}): Promise<{
|
|
49
|
-
text: string;
|
|
50
|
-
files: number;
|
|
51
|
-
hash: string;
|
|
52
|
-
}>;
|
|
53
|
-
export {};
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One execution's goal-acceptance report.
|
|
3
|
-
*
|
|
4
|
-
* Rendered inside the execution-history row, so a rerun or a scheduled run
|
|
5
|
-
* keeps its OWN report and a later cycle never overwrites an earlier verdict.
|
|
6
|
-
* The row itself only carries the verdict: the judge route, the acceptance
|
|
7
|
-
* count, the per-criterion scores and their threshold, the findings, the
|
|
8
|
-
* evidence scope and the token usage sit behind one disclosure, because the
|
|
9
|
-
* same machine explanation repeated on all thirty-four rows of a card was what
|
|
10
|
-
* buried the row a reader needed. Expanding it shows every field the board
|
|
11
|
-
* decided on — nothing is dropped, only folded.
|
|
12
|
-
*
|
|
13
|
-
* Deliberately adds no new `data-dsh-part` value: the part enum is owned by the
|
|
14
|
-
* cross-repository semantic-attribute contract, and this report reuses the
|
|
15
|
-
* execution row's existing markup instead of extending that enum.
|
|
16
|
-
*/
|
|
17
|
-
import { useId, useState } from 'react'
|
|
18
|
-
import {
|
|
19
|
-
MAX_INVALID_ATTEMPTS,
|
|
20
|
-
MAX_QUALITY_ATTEMPTS,
|
|
21
|
-
exceptionAttempts,
|
|
22
|
-
invalidAttempts,
|
|
23
|
-
qualityAttempts,
|
|
24
|
-
verificationPhase,
|
|
25
|
-
verificationTotals,
|
|
26
|
-
type AcceptanceAuditRecord,
|
|
27
|
-
type AcceptanceCleanupRecord,
|
|
28
|
-
type ExecutionVerification,
|
|
29
|
-
type VerificationAttempt,
|
|
30
|
-
type VerificationCriterionFinding,
|
|
31
|
-
} from '../../core/verification.ts'
|
|
32
|
-
import { t } from '../locales.ts'
|
|
33
|
-
import type { TaskBoardKey } from '../locales.ts'
|
|
34
|
-
import css from '../board.module.css'
|
|
35
|
-
import { usePresence } from './overlay.tsx'
|
|
36
|
-
|
|
37
|
-
/** Render one 0..1 score as a percentage. */
|
|
38
|
-
function percent(value: number): string {
|
|
39
|
-
return (value * 100).toFixed(1) + '%'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** The judge route of one attempt, with its effective reasoning level. */
|
|
43
|
-
function routeLabel(attempt: VerificationAttempt): string {
|
|
44
|
-
const model = attempt.route.provider === '' ? attempt.route.model : attempt.route.provider + '/' + attempt.route.model
|
|
45
|
-
const effort = attempt.route.reasoningEffort
|
|
46
|
-
const key: TaskBoardKey = effort === undefined || effort === '' ? 'verify.judgeNoEffort' : 'verify.judge'
|
|
47
|
-
return t(key, effort === undefined || effort === '' ? { model } : { model, effort })
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** Board phase → report badge key. */
|
|
51
|
-
const PHASE_STATUS_KEY: Record<ReturnType<typeof verificationPhase>, TaskBoardKey> = {
|
|
52
|
-
off: 'verify.status.off',
|
|
53
|
-
executing: 'verify.status.pending',
|
|
54
|
-
verifying: 'verify.status.verifying',
|
|
55
|
-
repairing: 'verify.status.failed',
|
|
56
|
-
passed: 'verify.status.passed',
|
|
57
|
-
failed: 'verify.status.failed',
|
|
58
|
-
invalid: 'verify.status.invalidHeld',
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Board phase → the badge's colour slot. One slot per meaning instead of one
|
|
63
|
-
* per phase: a phase that is still running reads as a warning, a refused
|
|
64
|
-
* acceptance reads as a failure, and an acceptance that never applied reads as
|
|
65
|
-
* neutral — never as a pass.
|
|
66
|
-
*/
|
|
67
|
-
const PHASE_TONE: Record<ReturnType<typeof verificationPhase>, 'success' | 'error' | 'warn' | 'neutral'> = {
|
|
68
|
-
off: 'neutral',
|
|
69
|
-
executing: 'warn',
|
|
70
|
-
verifying: 'warn',
|
|
71
|
-
repairing: 'error',
|
|
72
|
-
passed: 'success',
|
|
73
|
-
failed: 'error',
|
|
74
|
-
invalid: 'error',
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Evidence location → locale key, for one structured finding's citation. */
|
|
78
|
-
const LOCATION_KEY: Record<VerificationCriterionFinding['location'], TaskBoardKey> = {
|
|
79
|
-
task: 'verify.location.task',
|
|
80
|
-
trajectory: 'verify.location.trajectory',
|
|
81
|
-
workspace: 'verify.location.workspace',
|
|
82
|
-
baseline: 'verify.location.baseline',
|
|
83
|
-
unknown: 'verify.location.unknown',
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Invalid reason → locale key. */
|
|
87
|
-
function invalidReasonKey(attempt: VerificationAttempt): TaskBoardKey {
|
|
88
|
-
switch (attempt.invalidReason) {
|
|
89
|
-
case 'missing-finding': return 'verify.invalidReason.missing-finding'
|
|
90
|
-
case 'unlocatable-quote': return 'verify.invalidReason.unlocatable-quote'
|
|
91
|
-
case 'baseline-finding': return 'verify.invalidReason.baseline-finding'
|
|
92
|
-
case 'vacuous-finding': return 'verify.invalidReason.vacuous-finding'
|
|
93
|
-
case 'insufficient-evidence': return 'verify.invalidReason.insufficient-evidence'
|
|
94
|
-
default: return 'verify.invalidReason.unknown'
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** Audit stage → locale key (the lightweight credential after cleanup). */
|
|
99
|
-
const AUDIT_STAGE_KEY: Record<AcceptanceAuditRecord['stage'], TaskBoardKey> = {
|
|
100
|
-
quality: 'verify.cleanup.stage.quality',
|
|
101
|
-
invalid: 'verify.cleanup.stage.invalid',
|
|
102
|
-
exception: 'verify.cleanup.stage.exception',
|
|
103
|
-
budget: 'verify.cleanup.stage.budget',
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** Stable key for one finding row. */
|
|
107
|
-
function findingKey(attempt: VerificationAttempt, index: number): string {
|
|
108
|
-
return attempt.at.toString(36) + '-' + String(index)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** One recorded attempt: a quality verdict, an invalid veto, an anomaly, or a budget stop. */
|
|
112
|
-
function AttemptRow({ attempt, detailRemoved }: { attempt: VerificationAttempt, detailRemoved: boolean }) {
|
|
113
|
-
// Everything that is not a quality verdict renders as an anomaly row: a
|
|
114
|
-
// budget stop carries no score either, and an invalid acceptance carries a
|
|
115
|
-
// score the board REFUSED to book, so showing either as a scored failure
|
|
116
|
-
// would read as a judgement the board never made. The invalid row gets its
|
|
117
|
-
// own badge and reason line, because it is a distinct outcome.
|
|
118
|
-
const invalid = attempt.stage === 'invalid'
|
|
119
|
-
const exception = attempt.stage !== 'quality' && !invalid
|
|
120
|
-
const result = exception ? 'failed' : attempt.passed ? 'succeeded' : 'failed'
|
|
121
|
-
return (
|
|
122
|
-
<li className={css.attemptRow} data-result={result}>
|
|
123
|
-
<div className={css.attemptHead}>
|
|
124
|
-
<span className={css.executionBadge} data-result={result}>
|
|
125
|
-
{invalid ? t('verify.status.invalid') : exception ? t('verify.status.exception') : attempt.passed ? t('verify.status.passed') : t('verify.status.failed')}
|
|
126
|
-
</span>
|
|
127
|
-
<span className={css.executionTimes}>
|
|
128
|
-
{invalid
|
|
129
|
-
? t('verify.attemptInvalid', { index: String(attempt.index) })
|
|
130
|
-
: exception
|
|
131
|
-
? t('verify.attemptException', { index: String(attempt.index) })
|
|
132
|
-
: t('verify.attempt', { index: String(attempt.index) })}
|
|
133
|
-
{' · '}{routeLabel(attempt)}
|
|
134
|
-
{!exception && !invalid && ' · ' + t('verify.rounds', { rounds: String(attempt.rounds) })}
|
|
135
|
-
</span>
|
|
136
|
-
</div>
|
|
137
|
-
{invalid && (
|
|
138
|
-
<span className={css.executionTimes}>
|
|
139
|
-
{t('verify.invalidDetail', { reason: t(invalidReasonKey(attempt)) })}
|
|
140
|
-
</span>
|
|
141
|
-
)}
|
|
142
|
-
{attempt.error !== undefined && <span className={css.executionTimes}>{attempt.error}</span>}
|
|
143
|
-
{!exception && (
|
|
144
|
-
<>
|
|
145
|
-
<span className={css.executionTimes}>
|
|
146
|
-
{t('verify.summary', {
|
|
147
|
-
score: percent(attempt.score),
|
|
148
|
-
threshold: percent(attempt.criteria[0]?.threshold ?? 0),
|
|
149
|
-
baseline: percent(attempt.baseline),
|
|
150
|
-
})}
|
|
151
|
-
</span>
|
|
152
|
-
<span className={css.executionTimes}>{t('verify.criteria')}</span>
|
|
153
|
-
<ul className={css.executionList}>
|
|
154
|
-
{attempt.criteria.map(criterion => (
|
|
155
|
-
<li key={criterion.id} className={css.executionTimes}>
|
|
156
|
-
{t('verify.criterion', {
|
|
157
|
-
name: criterion.name,
|
|
158
|
-
score: percent(criterion.score),
|
|
159
|
-
threshold: percent(criterion.threshold),
|
|
160
|
-
})}
|
|
161
|
-
</li>
|
|
162
|
-
))}
|
|
163
|
-
</ul>
|
|
164
|
-
</>
|
|
165
|
-
)}
|
|
166
|
-
{(attempt.criterionFindings ?? []).length > 0 && (
|
|
167
|
-
<>
|
|
168
|
-
<span className={css.executionTimes}>{t('verify.criterionFindings')}</span>
|
|
169
|
-
<ul className={css.executionList}>
|
|
170
|
-
{(attempt.criterionFindings ?? []).map((finding, index) => (
|
|
171
|
-
<li key={findingKey(attempt, index)} className={css.executionTimes}>
|
|
172
|
-
{t('verify.criterionFindingFull', {
|
|
173
|
-
criterion: finding.criterionId,
|
|
174
|
-
location: t(LOCATION_KEY[finding.location]),
|
|
175
|
-
quote: finding.quote,
|
|
176
|
-
requirement: finding.requirement,
|
|
177
|
-
observation: finding.observation,
|
|
178
|
-
gap: finding.gap,
|
|
179
|
-
})}
|
|
180
|
-
</li>
|
|
181
|
-
))}
|
|
182
|
-
</ul>
|
|
183
|
-
</>
|
|
184
|
-
)}
|
|
185
|
-
{attempt.findings.length > 0 && (
|
|
186
|
-
<>
|
|
187
|
-
<span className={css.executionTimes}>{t('verify.findings')}</span>
|
|
188
|
-
<ul className={css.executionList}>
|
|
189
|
-
{attempt.findings.map((finding, index) => (
|
|
190
|
-
<li key={findingKey(attempt, index)} className={css.executionTimes}>{finding}</li>
|
|
191
|
-
))}
|
|
192
|
-
</ul>
|
|
193
|
-
</>
|
|
194
|
-
)}
|
|
195
|
-
{!exception && !invalid && attempt.findings.length === 0 && (
|
|
196
|
-
// A cleaned attempt has no findings because the acceptance removed them,
|
|
197
|
-
// not because the judge gave none: saying "the judge reported no
|
|
198
|
-
// finding" here would invite exactly the misreading the cleanup rule
|
|
199
|
-
// exists to avoid.
|
|
200
|
-
<span className={css.executionTimes}>{t(detailRemoved ? 'verify.detailRemoved' : 'verify.noFindings')}</span>
|
|
201
|
-
)}
|
|
202
|
-
<span className={css.executionTimes}>
|
|
203
|
-
{t('verify.evidence', {
|
|
204
|
-
chars: String(attempt.evidence.chars),
|
|
205
|
-
entries: String(attempt.evidence.entries),
|
|
206
|
-
omitted: String(attempt.evidence.omittedCharacters),
|
|
207
|
-
})}
|
|
208
|
-
{attempt.evidence.workspaceFiles !== undefined && attempt.evidence.workspaceFiles > 0
|
|
209
|
-
? ' · ' + t('verify.workspaceEvidence', { files: String(attempt.evidence.workspaceFiles) })
|
|
210
|
-
: ''}
|
|
211
|
-
</span>
|
|
212
|
-
<span className={css.executionTimes}>
|
|
213
|
-
{t('verify.usage', {
|
|
214
|
-
calls: String(attempt.usage.calls),
|
|
215
|
-
input: String(attempt.usage.inputTokens),
|
|
216
|
-
output: String(attempt.usage.outputTokens),
|
|
217
|
-
reasoning: String(attempt.usage.reasoningTokens),
|
|
218
|
-
})}
|
|
219
|
-
{attempt.usage.usageIncomplete === true ? t('verify.usageIncomplete') : ''}
|
|
220
|
-
</span>
|
|
221
|
-
</li>
|
|
222
|
-
)
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Retention notice of one execution's acceptance detail.
|
|
227
|
-
*
|
|
228
|
-
* It exists so a reader never mistakes a cleaned-up report for a judge that
|
|
229
|
-
* produced no evidence: the notice says the detail WAS produced and was removed
|
|
230
|
-
* by the automatic cleanup, and lists the lightweight credential that survives.
|
|
231
|
-
* A pending or failed cleanup is reported the same way — never as a missing
|
|
232
|
-
* verdict and never as a revoked pass.
|
|
233
|
-
*/
|
|
234
|
-
function CleanupNotice({ cleanup }: { cleanup: AcceptanceCleanupRecord }) {
|
|
235
|
-
const key: TaskBoardKey = cleanup.state === 'cleaned'
|
|
236
|
-
? 'verify.cleanup.cleaned'
|
|
237
|
-
: cleanup.state === 'failed' ? 'verify.cleanup.failed' : 'verify.cleanup.pending'
|
|
238
|
-
return (
|
|
239
|
-
<>
|
|
240
|
-
<span className={css.executionTimes}>
|
|
241
|
-
{cleanup.state === 'failed'
|
|
242
|
-
? t(key, { attempts: String(cleanup.attempts), error: cleanup.lastError ?? '' })
|
|
243
|
-
: t(key)}
|
|
244
|
-
</span>
|
|
245
|
-
{cleanup.audit.length > 0 && (
|
|
246
|
-
<ul className={css.executionList}>
|
|
247
|
-
{cleanup.audit.map((record, index) => (
|
|
248
|
-
<li key={record.at.toString(36) + '-' + record.stage + '-' + String(index)} className={css.executionTimes}>
|
|
249
|
-
{t('verify.cleanup.audit', {
|
|
250
|
-
index: String(index + 1),
|
|
251
|
-
stage: t(AUDIT_STAGE_KEY[record.stage]),
|
|
252
|
-
score: percent(record.score),
|
|
253
|
-
hash: record.evidenceHash.slice(0, 12),
|
|
254
|
-
})}
|
|
255
|
-
{record.findingSummary === undefined ? '' : ' · ' + record.findingSummary}
|
|
256
|
-
</li>
|
|
257
|
-
))}
|
|
258
|
-
</ul>
|
|
259
|
-
)}
|
|
260
|
-
</>
|
|
261
|
-
)
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Render one execution's acceptance report.
|
|
266
|
-
* @param props - the execution's persisted acceptance block.
|
|
267
|
-
* @returns the verdict badge with its fold-out detail, or nothing when
|
|
268
|
-
* acceptance never applied.
|
|
269
|
-
*/
|
|
270
|
-
export function VerificationReport({ verification }: { verification: ExecutionVerification }) {
|
|
271
|
-
const [expanded, setExpanded] = useState(false)
|
|
272
|
-
const presence = usePresence(expanded)
|
|
273
|
-
const panelId = useId()
|
|
274
|
-
const phase = verificationPhase(verification)
|
|
275
|
-
if (phase === 'off' && verification.contract.enabled === false && verification.applicability !== 'skipped') return null
|
|
276
|
-
const totals = verificationTotals(verification)
|
|
277
|
-
const route = verification.contract.route
|
|
278
|
-
const applicabilityKey: TaskBoardKey | undefined = verification.applicability === 'disabled'
|
|
279
|
-
? 'verify.applicability.disabled'
|
|
280
|
-
: verification.applicability === 'skipped'
|
|
281
|
-
? 'verify.applicability.skipped'
|
|
282
|
-
: verification.applicability === 'goal-unavailable'
|
|
283
|
-
? 'verify.applicability.goalUnavailable'
|
|
284
|
-
: verification.applicability === 'goal-disabled'
|
|
285
|
-
? 'verify.applicability.goalDisabled'
|
|
286
|
-
: verification.applicability === 'team-member' ? 'verify.applicability.teamMember' : undefined
|
|
287
|
-
return (
|
|
288
|
-
<div className={css.verifyReport}>
|
|
289
|
-
<button
|
|
290
|
-
type="button"
|
|
291
|
-
className={css.verifyBadge}
|
|
292
|
-
data-tone={PHASE_TONE[phase]}
|
|
293
|
-
aria-expanded={expanded}
|
|
294
|
-
aria-controls={panelId}
|
|
295
|
-
onClick={() => { setExpanded(!expanded) }}
|
|
296
|
-
>
|
|
297
|
-
{t('verify.title')}
|
|
298
|
-
<span className={css.verifyVerdict}>{t(PHASE_STATUS_KEY[phase])}</span>
|
|
299
|
-
<span className={css.disclosureChevron} data-open={expanded} aria-hidden="true" />
|
|
300
|
-
</button>
|
|
301
|
-
{presence.mounted && (
|
|
302
|
-
<div className={css.verifyPanel} id={panelId} data-state={presence.phase}>
|
|
303
|
-
<span className={css.executionTimes}>
|
|
304
|
-
{t('verify.invalidCounts', {
|
|
305
|
-
quality: String(qualityAttempts(verification).length),
|
|
306
|
-
max: String(MAX_QUALITY_ATTEMPTS),
|
|
307
|
-
invalid: String(invalidAttempts(verification).length),
|
|
308
|
-
maxInvalid: String(MAX_INVALID_ATTEMPTS),
|
|
309
|
-
exceptions: String(exceptionAttempts(verification).length),
|
|
310
|
-
})}
|
|
311
|
-
</span>
|
|
312
|
-
{route !== undefined && (
|
|
313
|
-
<span className={css.executionTimes}>
|
|
314
|
-
{verification.contract.modelSource === 'inherit'
|
|
315
|
-
? t('verify.judgeInherited', { model: route.provider + '/' + route.model })
|
|
316
|
-
: t(route.reasoningEffort === undefined || route.reasoningEffort === '' ? 'verify.judgeNoEffort' : 'verify.judge', {
|
|
317
|
-
model: route.provider + '/' + route.model,
|
|
318
|
-
...(route.reasoningEffort === undefined ? {} : { effort: route.reasoningEffort }),
|
|
319
|
-
})}
|
|
320
|
-
</span>
|
|
321
|
-
)}
|
|
322
|
-
{verification.contract.effortFallback !== undefined && (
|
|
323
|
-
<span className={css.executionTimes}>
|
|
324
|
-
{t('verify.effortFallback', {
|
|
325
|
-
requested: verification.contract.effortFallback.requested,
|
|
326
|
-
resolved: verification.contract.effortFallback.resolved ?? t('settings.goalVerificationResolvedNoEffort'),
|
|
327
|
-
})}
|
|
328
|
-
</span>
|
|
329
|
-
)}
|
|
330
|
-
{applicabilityKey !== undefined && <span className={css.executionTimes}>{t(applicabilityKey)}</span>}
|
|
331
|
-
{verification.failedReason !== undefined && (
|
|
332
|
-
<span className={css.executionTimes}>{t('verify.finalFailure', { reason: verification.failedReason })}</span>
|
|
333
|
-
)}
|
|
334
|
-
{totals.calls > 0 && (
|
|
335
|
-
<span className={css.executionTimes}>
|
|
336
|
-
{t('verify.usage', {
|
|
337
|
-
calls: String(totals.calls),
|
|
338
|
-
input: String(totals.inputTokens),
|
|
339
|
-
output: String(totals.outputTokens),
|
|
340
|
-
reasoning: String(totals.reasoningTokens),
|
|
341
|
-
})}
|
|
342
|
-
{totals.usageIncomplete ? t('verify.usageIncomplete') : ''}
|
|
343
|
-
</span>
|
|
344
|
-
)}
|
|
345
|
-
{verification.attempts.length > 0 && (
|
|
346
|
-
<ul className={css.executionList}>
|
|
347
|
-
{[...verification.attempts].reverse().map(attempt => (
|
|
348
|
-
<AttemptRow
|
|
349
|
-
key={attempt.at.toString(36) + '-' + attempt.stage + '-' + String(attempt.index)}
|
|
350
|
-
attempt={attempt}
|
|
351
|
-
detailRemoved={verification.cleanup?.state === 'cleaned'}
|
|
352
|
-
/>
|
|
353
|
-
))}
|
|
354
|
-
</ul>
|
|
355
|
-
)}
|
|
356
|
-
{verification.cleanup !== undefined && <CleanupNotice cleanup={verification.cleanup} />}
|
|
357
|
-
</div>
|
|
358
|
-
)}
|
|
359
|
-
</div>
|
|
360
|
-
)
|
|
361
|
-
}
|