@staix/agent-hub 0.47.0 → 0.48.1
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/CHANGELOG.md +10 -0
- package/README.md +5 -3
- package/docs/agent-notes/daemon.md +1 -1
- package/docs/agent-notes/tasks.md +1 -0
- package/docs/design/guidance-probes.md +12 -0
- package/docs/design/roadmap.md +1 -1
- package/docs/dogfood.md +1 -1
- package/docs/operations.md +32 -1
- package/docs/quickstart.md +13 -1
- package/docs/security.md +13 -5
- package/docs/verification/2026-11-26-0.48.0.md +45 -0
- package/docs/verification/2026-11-27-0.48.1.md +37 -0
- package/docs/verified.json +20 -20
- package/package.json +1 -1
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +20 -6
- package/plugins/agent-hub/server.js +20 -6
- package/src/adapters/local-probe.ts +59 -14
- package/src/adapters/local-worker.ts +18 -6
- package/src/cli/help.ts +1 -1
- package/src/cli/main.ts +2 -2
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +20 -2
- package/src/hub/guidance-probe-store.ts +51 -10
- package/src/hub/guidance-probes.ts +25 -7
- package/src/hub/supervision.ts +19 -6
- package/src/hub/tasks.ts +45 -16
- package/src/local/probe-types.ts +1 -0
- package/src/local/probe-workspace.ts +49 -0
- package/src/omniroute/client.ts +19 -3
- package/src/ui/guidance-panel.ts +2 -2
- package/src/ui/guidance-view.ts +4 -2
|
@@ -67,7 +67,20 @@ export interface ProbePreparedFrame { slotId: string; sha256: string; bytes: num
|
|
|
67
67
|
export interface ProbePreparedWorkerFrame { inputFrame: string; nonGuidanceInputSha256: string }
|
|
68
68
|
export type ProbeWorkerFramePreparer = (state: ProbeStoredState, slot: ProbeSlot, guidance: string) => ProbePreparedWorkerFrame | Promise<ProbePreparedWorkerFrame>;
|
|
69
69
|
export interface ProbeResourceCharges { inputBytes?: number; scratchBytes?: number; outputBytes?: number }
|
|
70
|
+
export const GUIDANCE_PROBE_LIVE_LIMITS = { modelCalls: 8, tokens: 8_000, elapsedMs: 60_000, maxOutputTokens: 512 } as const;
|
|
71
|
+
export function isLiveGuidanceProbeManifest(manifest: GuidanceProbeManifestV1): boolean {
|
|
72
|
+
const { slots, limits } = manifest;
|
|
73
|
+
const [baseline, candidate] = slots;
|
|
74
|
+
return slots.length === 2 && baseline?.stage === "baseline" && baseline.arm === "baseline"
|
|
75
|
+
&& candidate?.stage === "candidate1" && candidate.arm === "candidate1"
|
|
76
|
+
&& slots.every(slot => slot.role === "worker" && slot.retryOf === undefined)
|
|
77
|
+
&& manifest.improverContextHash === undefined && manifest.improverContextBytes === undefined
|
|
78
|
+
&& limits.modelCalls <= slots.length * GUIDANCE_PROBE_LIVE_LIMITS.modelCalls
|
|
79
|
+
&& limits.tokens !== undefined && limits.tokens <= slots.length * GUIDANCE_PROBE_LIVE_LIMITS.tokens
|
|
80
|
+
&& limits.elapsedMs <= slots.length * GUIDANCE_PROBE_LIVE_LIMITS.elapsedMs;
|
|
81
|
+
}
|
|
70
82
|
export interface ProbeSessionAdmission {
|
|
83
|
+
mode?: "live";
|
|
71
84
|
key: ProbeKey; expectedRevision: number; host: ProbeHostBinding; child?: ProbeChildBinding; preparedFrame?: ProbePreparedFrame; now: number;
|
|
72
85
|
}
|
|
73
86
|
export interface ProbeReservation { key: ProbeKey; slotId: string; generation: number; revision: number }
|
|
@@ -97,6 +110,7 @@ export interface ProbeCounters {
|
|
|
97
110
|
/** Why a session settled, recorded once when it settled so a receipt is derived from the session's own facts and never from experiment state that moves later. */
|
|
98
111
|
export type ProbeCloseCause = "none" | "cancel" | "elapsed" | "hold" | "crash";
|
|
99
112
|
export interface ProbeSession {
|
|
113
|
+
live?: { reservedAt: number; tokensReserved: number };
|
|
100
114
|
slotId: string; generation: number; revision: number; state: ProbeSessionState; candidateArtifactSha256: string | null;
|
|
101
115
|
closeCause?: ProbeCloseCause;
|
|
102
116
|
child?: ProbeChildBinding;
|
|
@@ -137,7 +151,7 @@ export interface GuidanceProbeFakePorts {
|
|
|
137
151
|
*/
|
|
138
152
|
discardRetained?(retained: ProbeRetainedRecord): void;
|
|
139
153
|
}
|
|
140
|
-
export interface ProbePublicReceipt extends ProbeReceipt { experimentId: string; taskId: number; evidence: "declaration" | "fixture" | "unknown" }
|
|
154
|
+
export interface ProbePublicReceipt extends ProbeReceipt { experimentId: string; taskId: number; evidence: "declaration" | "fixture" | "live" | "unknown" }
|
|
141
155
|
export interface ProbePublicStatus extends ProbePublicReceipt { counters: ProbeCounters; cancelRequested: boolean; notNeeded: number; comparable: boolean; authoring: "admitted_fixture" | "uncontrolled" | "unknown" }
|
|
142
156
|
export type GuidanceProbeCommand = { op: "register"; file: string; json: boolean }
|
|
143
157
|
| { op: "start"; id: string; revision: number; variantId?: string; json: boolean }
|
|
@@ -342,7 +356,7 @@ export function parseGuidanceProbeSubcommand(args: readonly string[]): GuidanceP
|
|
|
342
356
|
}
|
|
343
357
|
|
|
344
358
|
const probeStates: readonly ProbeState[] = ["declared", "active", "closing", "closed_fixture", "failed_fixture", "unknown_held"];
|
|
345
|
-
const publicEvidence = (value: unknown): value is ProbePublicReceipt["evidence"] => ["declaration", "fixture", "unknown"].includes(value as string);
|
|
359
|
+
const publicEvidence = (value: unknown): value is ProbePublicReceipt["evidence"] => ["declaration", "fixture", "live", "unknown"].includes(value as string);
|
|
346
360
|
function publicReceipt(value: unknown, status: boolean): ProbePublicReceipt | ProbePublicStatus | undefined {
|
|
347
361
|
try {
|
|
348
362
|
const extra = status ? ["counters", "cancelRequested", "notNeeded", "comparable", "authoring"] : [];
|
|
@@ -403,6 +417,7 @@ export interface ProbeOutputManifestV1 { v: 1; entries: readonly ProbeOutputEntr
|
|
|
403
417
|
export interface ProbeReceiptUsage { modelCalls: number; modelUsageKnown: number; toolCalls: number; toolUsageKnown: number; tokensObserved: number | null }
|
|
404
418
|
/** The host's immutable record of one finished session. Every field is host-computed; none is a provider claim. */
|
|
405
419
|
export interface ProbeReceiptV1 {
|
|
420
|
+
mode?: "live";
|
|
406
421
|
v: 1;
|
|
407
422
|
experimentId: string;
|
|
408
423
|
slotId: string;
|
|
@@ -449,7 +464,8 @@ export function parseProbeReceipt(value: unknown): ProbeReceiptV1 | undefined {
|
|
|
449
464
|
try {
|
|
450
465
|
const f = object(inert(value, PROBE_OUTPUT_LIMITS.receiptBytes), ["v", "experimentId", "slotId", "generation", "revision", "requestedModel", "servedModel", "inputFrameSha256",
|
|
451
466
|
"workerEffectiveInputSha256", "nonGuidanceInputSha256", "guidanceSha256", "runtimeSha256", "toolsetSha256", "modelConfigSha256", "startedAt", "endedAt", "elapsedMs", "state",
|
|
452
|
-
"usage", "limits", "output", "expiresAt", "digest"]);
|
|
467
|
+
"usage", "limits", "output", "expiresAt", "digest"], ["mode"]);
|
|
468
|
+
required(f.mode === undefined || f.mode === "live");
|
|
453
469
|
required(f.v === 1 && identity(f.experimentId) && identity(f.slotId) && probeInteger(f.generation) && probeInteger(f.revision));
|
|
454
470
|
required(f.requestedModel === GUIDANCE_PROBE_MODEL && (f.servedModel === null || typeof f.servedModel === "string" && Buffer.byteLength(f.servedModel) <= 256));
|
|
455
471
|
required(nullableSha(f.inputFrameSha256) && nullableSha(f.workerEffectiveInputSha256) && nullableSha(f.nonGuidanceInputSha256) && nullableSha(f.guidanceSha256));
|
|
@@ -634,7 +650,7 @@ export interface ProbeExportSlot {
|
|
|
634
650
|
}
|
|
635
651
|
/**
|
|
636
652
|
* What a producer or a receipt consumer reads about one experiment. Everything in it is host-observed or host-computed from sealed receipts; a fixture
|
|
637
|
-
* run is `evidence: "fixture"
|
|
653
|
+
* run is `evidence: "fixture"`; a live run carries a host-sealed mode. Neither attests sampling control, provider behaviour or model quality. Unknown stays unknown: a
|
|
638
654
|
* usage gap is `usage_unknown`, an unobserved served model is `served_model_unobserved`, and a slot with no receipt is `unknown` in the denominator.
|
|
639
655
|
*/
|
|
640
656
|
export interface ProbeReceiptExport {
|
|
@@ -670,7 +686,7 @@ export function parseGuidanceProbeReceiptExport(value: unknown): ProbeReceiptExp
|
|
|
670
686
|
const counts = object(f.counts, COUNT_KEYS);
|
|
671
687
|
required(COUNT_KEYS.every(key => probeInteger(counts[key])));
|
|
672
688
|
const slots = f.slots; required(Array.isArray(slots) && slots.length <= GUIDANCE_PROBE_LIMITS.slots);
|
|
673
|
-
const seen = new Set<string>(); let withReceipt = 0;
|
|
689
|
+
const seen = new Set<string>(); let withReceipt = 0, liveReceipts = 0;
|
|
674
690
|
for (const item of slots as unknown[]) {
|
|
675
691
|
const s = object(item, ["slotId", "stage", "role", "arm", "state", "receipt", "receiptDigest", "withheld", "retention"]);
|
|
676
692
|
required(identity(s.slotId) && !seen.has(s.slotId as string) && STAGES.includes(s.stage as ProbeStage) && SLOT_ROLES.includes(s.role as ProbeSlot["role"])
|
|
@@ -681,12 +697,14 @@ export function parseGuidanceProbeReceiptExport(value: unknown): ProbeReceiptExp
|
|
|
681
697
|
// A withheld receipt still names its digest; a slot with no receipt has neither, and is never marked withheld.
|
|
682
698
|
required(s.withheld ? probeSha256(s.receiptDigest) : s.receiptDigest === null);
|
|
683
699
|
} else {
|
|
684
|
-
const receipt = parseProbeReceipt(s.receipt); required(receipt && !s.withheld && receipt.slotId === s.slotId && s.receiptDigest === receipt.digest
|
|
700
|
+
const receipt = parseProbeReceipt(s.receipt); required(receipt && !s.withheld && receipt.slotId === s.slotId && s.receiptDigest === receipt.digest
|
|
701
|
+
&& (status!.evidence !== "live" || receipt.mode === "live") && (status!.evidence !== "fixture" || receipt.mode === undefined));
|
|
685
702
|
withReceipt++;
|
|
703
|
+
if (receipt!.mode === "live") { required(s.role === "worker"); liveReceipts++; }
|
|
686
704
|
}
|
|
687
705
|
}
|
|
688
706
|
const total = COUNT_KEYS.reduce((sum, key) => sum + (counts[key] as number), 0);
|
|
689
|
-
required(total === (slots as unknown[]).length && withReceipt <= total);
|
|
707
|
+
required(total === (slots as unknown[]).length && withReceipt <= total && (liveReceipts === 0 || liveReceipts === withReceipt));
|
|
690
708
|
return f as unknown as ProbeReceiptExport;
|
|
691
709
|
} catch { return undefined; }
|
|
692
710
|
}
|
package/src/hub/supervision.ts
CHANGED
|
@@ -37,6 +37,10 @@ export interface SupervisionDeps {
|
|
|
37
37
|
/** Durable round state belongs to the daemon's store, not the controller. */
|
|
38
38
|
readRound?: (peer: string) => string | undefined;
|
|
39
39
|
writeRound?: (peer: string, signature: string) => void;
|
|
40
|
+
/** #1738: the board status revision, moved by every task write. With it, an unchanged round check skips the full board read. */
|
|
41
|
+
revision?: () => number;
|
|
42
|
+
/** #1738: one task by id, so a per-task notice does not read the whole board. */
|
|
43
|
+
task?: (id: number) => Task | undefined;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
/** Deterministic milestone producer. The Bus alone owns batching, retry and native turns. */
|
|
@@ -44,8 +48,14 @@ export class SupervisionFeed {
|
|
|
44
48
|
private readonly approvals = new Set<string>();
|
|
45
49
|
private readonly holds = new Set<string>();
|
|
46
50
|
private readonly rounds = new Map<string, string>();
|
|
51
|
+
/** #1738: the key of the last round check that sent nothing; never set after a refused send, which must stay retryable. */
|
|
52
|
+
private quietRound: string | undefined;
|
|
47
53
|
constructor(private readonly d: SupervisionDeps) {}
|
|
48
54
|
|
|
55
|
+
private taskById(id: number): Task | undefined {
|
|
56
|
+
return this.d.task ? this.d.task(id) : this.d.tasks().find((t) => t.id === id);
|
|
57
|
+
}
|
|
58
|
+
|
|
49
59
|
/** Pending notices may have been withdrawn on role/off change; live requests can notify again on regrant. */
|
|
50
60
|
resetPending(peer: string): void {
|
|
51
61
|
for (const key of this.approvals) if (key.startsWith(`${peer}:`)) this.approvals.delete(key);
|
|
@@ -71,7 +81,7 @@ export class SupervisionFeed {
|
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
milestone(id: number, milestone: SupervisionMilestone, fields: SupervisionFields = {}): boolean {
|
|
74
|
-
const task = this.
|
|
84
|
+
const task = this.taskById(id);
|
|
75
85
|
if (!task || !this.includes(task)) return false;
|
|
76
86
|
if (this.d.isPrivate(task)) return this.send(`task:${id}:${milestone}`, `#${id} [pii]: ${milestone}; ahub task show ${id}`, "status", id);
|
|
77
87
|
const bits = [this.d.publicTitle(task), milestone];
|
|
@@ -86,7 +96,7 @@ export class SupervisionFeed {
|
|
|
86
96
|
|
|
87
97
|
/** R4: only ids and the fixed rule number enter the conductor's feed. */
|
|
88
98
|
roadmapFinding(taskId: number, milestone: number | null, rule: number, marker: string): boolean {
|
|
89
|
-
const task = this.
|
|
99
|
+
const task = this.taskById(taskId);
|
|
90
100
|
if (!task || !this.includes(task) || this.d.isPrivate(task) || milestone !== null && (!Number.isSafeInteger(milestone) || milestone < 1) || !Number.isSafeInteger(rule) || rule < 1 || rule > 8 || !/^[a-f0-9]{64}$/.test(marker)) return false;
|
|
91
101
|
return this.send(`roadmap:${marker}`, `roadmap${milestone === null ? "" : ` milestone ${milestone}`}, task ${taskId}: drift rule ${rule}; inspect ahub roadmap check`, "status", taskId);
|
|
92
102
|
}
|
|
@@ -114,7 +124,7 @@ export class SupervisionFeed {
|
|
|
114
124
|
|
|
115
125
|
/** Tasks owns durable cause/replan deduplication; the feed keeps its configured recipient and scope. */
|
|
116
126
|
taskStalled(stall: TaskStall): boolean {
|
|
117
|
-
const task = this.
|
|
127
|
+
const task = this.taskById(stall.task);
|
|
118
128
|
if (!task || isClosedTaskState(task.state) || !this.includes(task)) return false;
|
|
119
129
|
const cause = stall.cause;
|
|
120
130
|
const bits = [`#${stall.task}: stalled`, `cause ${cause.kind}`, `reason ${cause.code}`];
|
|
@@ -159,13 +169,16 @@ export class SupervisionFeed {
|
|
|
159
169
|
checkRound(): boolean {
|
|
160
170
|
const peer = this.recipient();
|
|
161
171
|
if (!peer) return false;
|
|
172
|
+
const previous = this.d.readRound?.(peer) ?? this.rounds.get(peer);
|
|
173
|
+
// #1738: the result depends only on the recipient, the scope, the tasks and the stored round. While none moved since a check that sent nothing, it sends nothing again.
|
|
174
|
+
const key = this.d.revision ? JSON.stringify([peer, this.d.scope(), this.d.revision(), previous ?? null]) : undefined;
|
|
175
|
+
if (key !== undefined && key === this.quietRound) return false;
|
|
162
176
|
const tasks = this.d.tasks().filter((t) => this.includes(t));
|
|
163
|
-
if (!tasks.length || tasks.some((t) => !isClosedTaskState(t.state))) return false;
|
|
177
|
+
if (!tasks.length || tasks.some((t) => !isClosedTaskState(t.state))) { this.quietRound = key; return false; }
|
|
164
178
|
const signature = tasks.map((t) => t.id).sort((a, b) => a - b).join(",");
|
|
165
|
-
const previous = this.d.readRound?.(peer) ?? this.rounds.get(peer);
|
|
166
179
|
const completed = new Set(previous?.split(",") ?? []);
|
|
167
180
|
const newlyJoined = tasks.filter((t) => !completed.has(String(t.id)));
|
|
168
|
-
if (!newlyJoined.length) return false;
|
|
181
|
+
if (!newlyJoined.length) { this.quietRound = key; return false; }
|
|
169
182
|
const count = `${newlyJoined.length} task${newlyJoined.length === 1 ? "" : "s"}`;
|
|
170
183
|
const cancelled = newlyJoined.filter(t => t.state === "cancelled").length;
|
|
171
184
|
const outcome = cancelled ? `${count} closed (${newlyJoined.length - cancelled} approved, ${cancelled} cancelled)` : `${count} approved`;
|
package/src/hub/tasks.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { buildDecomposePrompt, parseDecomposition, planPartPublish, DECOMPOSE_IT
|
|
|
13
13
|
import { pathCandidates } from "@staix/agent-mem";
|
|
14
14
|
import { renderGuidanceVariantV1 } from "./guidance-variants.ts";
|
|
15
15
|
import { GuidanceProbeFixtureHost, type GuidanceProbeStore } from "./guidance-probe-store.ts";
|
|
16
|
-
import { GuidanceProbeError, GUIDANCE_PROBE_STOP_TIMEOUT_MS, GUIDANCE_PROBE_FENCE_INTERVAL_MS, guidanceProbeCanonical, guidanceProbeManifestKey,
|
|
16
|
+
import { GuidanceProbeError, GUIDANCE_PROBE_STOP_TIMEOUT_MS, GUIDANCE_PROBE_FENCE_INTERVAL_MS, GUIDANCE_PROBE_LIVE_LIMITS, isLiveGuidanceProbeManifest, guidanceProbeCanonical, guidanceProbeManifestKey,
|
|
17
17
|
parseGuidanceProbeRegistration, parseGuidanceProbeReceiptExport, probeHash, probeSha256, probeInteger, probeSessionGeneration,
|
|
18
18
|
type ProbeChildBinding, type ProbeStoredState, type ProbePublicReceipt, type ProbePublicStatus, type ProbeHostBinding,
|
|
19
19
|
type ProbeReceiptExport, type ProbeExportSlot, type ProbeReceiptV1, type ProbeRetentionState,
|
|
@@ -179,15 +179,19 @@ export interface AuditView extends AuditSummary {
|
|
|
179
179
|
/** Findings in this report that were already verified or rejected, so the hub left them as decided. */
|
|
180
180
|
notUpdated?: string[];
|
|
181
181
|
}
|
|
182
|
+
/** #1738: how long one working-tree spec check serves the roadmap snapshot. */
|
|
183
|
+
const ROADMAP_SPECS_REUSE_MS = 60_000;
|
|
184
|
+
|
|
182
185
|
export interface TasksDeps {
|
|
183
186
|
/** #1647 AC4: the hub's own token increments per task (a task id to its count, null when unknown), for the metrics grouped by reason. Read-only; absent means no reading. */
|
|
184
187
|
taskTokens?: () => Readonly<Record<number, number | null>>;
|
|
185
188
|
/** Timing-only owner question evidence for the idle-owner ladder. */
|
|
186
189
|
ownerQuestionWait?: (task: number, peer: PeerId) => { open: boolean; settled?: number } | undefined;
|
|
187
|
-
/** Private
|
|
190
|
+
/** Private probe ledger and host-selected runner. Wire input selects only an already registered content ID. */
|
|
188
191
|
guidanceProbes?: {
|
|
189
192
|
store: GuidanceProbeStore;
|
|
190
193
|
fakePorts?: GuidanceProbeFakePorts;
|
|
194
|
+
live?: { id: string; adapter: Pick<import("../local/probe-types.ts").ProbeLocalAdapter, "ports" | "prepareWorkerFrame"> };
|
|
191
195
|
prepareWorkerFrame?: ProbeWorkerFramePreparer;
|
|
192
196
|
prepareEditorFrame?: (state: ProbeStoredState, slot: ProbeSlot) => string | Promise<string>;
|
|
193
197
|
session?: (by: PeerId) => { generation: string | number; nativeSession: string | null; requestConnectionId: string; current: () => void } | undefined;
|
|
@@ -642,6 +646,7 @@ function hasReviewAnchorInput(raw: unknown): boolean {
|
|
|
642
646
|
interface GuidanceProbeRuntime {
|
|
643
647
|
id: string; by: PeerId; controller: AbortController; current: () => ProbeAdmissionRecheck;
|
|
644
648
|
requestedRevision: number; variantId?: string;
|
|
649
|
+
ports: GuidanceProbeFakePorts;
|
|
645
650
|
reservation?: ProbeReservation; promise?: Promise<ProbePublicReceipt>; stopPromise?: Promise<void>;
|
|
646
651
|
launched: boolean; launchSettled: boolean; stopSettled: boolean; stopKnown: boolean; stopRequested: boolean;
|
|
647
652
|
watch?: { handle: unknown }; failure?: Error;
|
|
@@ -3777,9 +3782,22 @@ export class Tasks {
|
|
|
3777
3782
|
return this.roadmapResult(by, id);
|
|
3778
3783
|
}
|
|
3779
3784
|
|
|
3785
|
+
/** #1738: the hub's own roadmap pass (the five-minute sweep and each task change's notice) runs milestoneList several times (the sweep, roadmapNotify, roadmapCheck and each
|
|
3786
|
+
* finding's recheck), and a working-tree spec check runs one synchronous git per spec path, so hub reads reuse one check for ROADMAP_SPECS_REUSE_MS. A thrown check is not
|
|
3787
|
+
* kept. Reads by the person and peers, and explicit `specs check`, stay uncached.
|
|
3788
|
+
* ponytail: a time window, not a repository key; key it on HEAD and index state, or run the check off the event loop, if a minute of stale freshness ever matters. */
|
|
3789
|
+
private roadmapSpecs: { at: number; report: SpecsCheckReport | SpecsCoverReport | undefined } | undefined;
|
|
3790
|
+
private roadmapSpecsCheck(): SpecsCheckReport | SpecsCoverReport | undefined {
|
|
3791
|
+
const now = this.d.now?.() ?? Date.now(), kept = this.roadmapSpecs;
|
|
3792
|
+
if (kept && now >= kept.at && now - kept.at < ROADMAP_SPECS_REUSE_MS) return kept.report;
|
|
3793
|
+
const report = this.d.specsRead?.("check", []);
|
|
3794
|
+
this.roadmapSpecs = { at: now, report };
|
|
3795
|
+
return report;
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3780
3798
|
private roadmapSnapshot(by: PeerId): RoadmapSnapshot {
|
|
3781
3799
|
let freshness: SpecsCheckReport["freshness"] | undefined;
|
|
3782
|
-
try { const report = this.d.specsRead?.("check", []); if (report && "freshness" in report && !report.truncated && report.errors === 0)
|
|
3800
|
+
try { const report = by === HUB ? this.roadmapSpecsCheck() : this.d.specsRead?.("check", []); if (report && "freshness" in report && !report.truncated && report.errors === 0)
|
|
3783
3801
|
freshness = report.freshness.filter(row => this.publicMetadataText(row.path) && (row.id === undefined || this.publicMetadataText(row.id))); } catch { /* unavailable evidence stays unknown */ }
|
|
3784
3802
|
return { milestones: this.d.board.milestones(), links: this.d.board.milestoneLinks(), tasks: this.d.board.list(), releases: this.d.board.releases(), freshness,
|
|
3785
3803
|
issueOf: task => { try { const source = this.planIssueIdentity(task); return source ? `${source.repo.toLowerCase()}#${source.issue}` : undefined; } catch { return undefined; } },
|
|
@@ -6515,7 +6533,7 @@ export class Tasks {
|
|
|
6515
6533
|
entry.controller.abort();
|
|
6516
6534
|
if (!entry.launched || !entry.reservation) { this.guidanceProbeRetire(entry); return; }
|
|
6517
6535
|
if (entry.stopRequested && (!entry.stopSettled || entry.stopKnown || !explicitStop)) return;
|
|
6518
|
-
const reservation = entry.reservation, ports =
|
|
6536
|
+
const reservation = entry.reservation, ports = entry.ports;
|
|
6519
6537
|
entry.stopRequested = true; entry.stopSettled = false; entry.stopKnown = false;
|
|
6520
6538
|
entry.stopPromise = (async () => {
|
|
6521
6539
|
try {
|
|
@@ -6534,7 +6552,9 @@ export class Tasks {
|
|
|
6534
6552
|
if (!state || !entry.reservation || state.firstReservedAt === null) throw new Error("owned probe clock is unavailable");
|
|
6535
6553
|
const now = this.d.now?.() ?? Date.now(), elapsed = now - state.firstReservedAt;
|
|
6536
6554
|
if (!probeInteger(elapsed) || elapsed < state.counters.elapsedHighWaterMs || state.admissionHold !== "none") { this.guidanceProbeAbort(entry, "elapsed"); return; }
|
|
6537
|
-
const
|
|
6555
|
+
const live = state.sessions.find(session => session.slotId === entry.reservation!.slotId)?.live;
|
|
6556
|
+
const remaining = Math.min(state.registration.manifest.limits.elapsedMs - elapsed,
|
|
6557
|
+
live === undefined ? Infinity : GUIDANCE_PROBE_LIVE_LIMITS.elapsedMs - (now - live.reservedAt));
|
|
6538
6558
|
if (remaining <= 0) { this.guidanceProbeAbort(entry, "elapsed"); return; }
|
|
6539
6559
|
entry.watch = { handle: this.guidanceProbeTimer().set(() => {
|
|
6540
6560
|
if (this.guidanceProbeActive.get(entry.id) !== entry || entry.controller.signal.aborted) return;
|
|
@@ -6551,7 +6571,7 @@ export class Tasks {
|
|
|
6551
6571
|
&& state.sessions.filter(item => item.state === "closed_fixture").every(item => item.coverage.coverageVerified)
|
|
6552
6572
|
&& state.sessions.every(item => item.state !== "failed_known" || item.coverage.preLaunchFailure || item.coverage.coverageVerified);
|
|
6553
6573
|
const evidence: ProbePublicReceipt["evidence"] = state.counters.workerAttempts + state.counters.editorAttempts === 0 ? "declaration"
|
|
6554
|
-
: holds || !verifiedCoverage || state.sessions.some(item => ["reserved", "running", "unknown_held"].includes(item.state)) ? "unknown" : "fixture";
|
|
6574
|
+
: holds || !verifiedCoverage || state.sessions.some(item => ["reserved", "running", "unknown_held"].includes(item.state)) ? "unknown" : launchedSessions.every(item => item.live !== undefined) ? "live" : "fixture";
|
|
6555
6575
|
return { ...state.receipt, already, taskId: state.registration.manifest.task.id,
|
|
6556
6576
|
experimentId: this.guidancePublicField(state.registration.manifest.experimentId), evidence,
|
|
6557
6577
|
counters: { ...state.counters }, cancelRequested: state.cancelRequested, notNeeded: state.notNeeded, authoring,
|
|
@@ -6670,8 +6690,17 @@ export class Tasks {
|
|
|
6670
6690
|
if (!probeInteger(revision) || variantId !== undefined && !probeSha256(variantId))
|
|
6671
6691
|
throw new PreEffectToolRefusal("guidance probe start selector is invalid; use its current CAS revision and exact G1 id");
|
|
6672
6692
|
const dependency = this.d.guidanceProbes!;
|
|
6673
|
-
//
|
|
6674
|
-
|
|
6693
|
+
// Match a host-configured content ID, never a mode requested by the caller or carried by imported evidence.
|
|
6694
|
+
const live = dependency.live?.id === id ? dependency.live.adapter : undefined;
|
|
6695
|
+
if (live && (by === USER || request.nativeSession === null))
|
|
6696
|
+
// refusal:by-design human-authority: live starts require an authenticated conductor session
|
|
6697
|
+
throw new PreEffectToolRefusal("live guidance probes require the current authenticated conductor native session");
|
|
6698
|
+
if (live && !isLiveGuidanceProbeManifest(state.registration.manifest))
|
|
6699
|
+
// refusal:by-design operator-knowledge: the operator must supply the preregistered bounded declaration
|
|
6700
|
+
throw new PreEffectToolRefusal("live guidance probe requires a bounded baseline and candidate declaration");
|
|
6701
|
+
const selectedPorts = live?.ports ?? dependency.fakePorts;
|
|
6702
|
+
// refusal:by-design human-authority: only the host operator can select a live registration
|
|
6703
|
+
if (!selectedPorts) throw new PreEffectToolRefusal("guidance probe runner is unavailable in production T1 for this registration");
|
|
6675
6704
|
const key = { projectKey: host.projectKey, id }, original = dependency.store.startSelector(key, revision);
|
|
6676
6705
|
if (original && (original.actor !== by || original.sessionGeneration !== host.sessionGeneration || original.nativeSession !== host.nativeSession
|
|
6677
6706
|
|| original.requestConnectionId !== host.requestConnectionId)) throw new PreEffectToolRefusal("guidance probe original start belongs to another request session; inspect its retained id without replaying it");
|
|
@@ -6697,11 +6726,11 @@ export class Tasks {
|
|
|
6697
6726
|
throw new PreEffectToolRefusal("guidance probe active start belongs to another request session; inspect its retained id without replaying it");
|
|
6698
6727
|
// Frame preparation has not granted a reservation. A duplicate is only a read of truthful current metadata.
|
|
6699
6728
|
if (!active.reservation) return this.guidanceProbeReceipt(this.guidanceProbeState(by, id, request.check), true);
|
|
6700
|
-
const replay = dependency.store.reserveSession({ key, expectedRevision: revision, ...prepared, now: this.d.now?.() ?? Date.now() }, current);
|
|
6729
|
+
const replay = dependency.store.reserveSession({ key, expectedRevision: revision, ...prepared, ...(live ? { mode: "live" as const } : {}), now: this.d.now?.() ?? Date.now() }, current);
|
|
6701
6730
|
if (replay.kind !== "existing") throw new Error("guidance probe start is unconfirmed; inspect retained state before any further work");
|
|
6702
6731
|
return this.guidanceProbeReceipt(this.guidanceProbeState(by, id, request.check), true);
|
|
6703
6732
|
}
|
|
6704
|
-
const entry: GuidanceProbeRuntime = { id, by, requestedRevision: revision, ...(variantId === undefined ? {} : { variantId }), controller: new AbortController(), current, launched: false, launchSettled: false,
|
|
6733
|
+
const entry: GuidanceProbeRuntime = { id, by, requestedRevision: revision, ...(variantId === undefined ? {} : { variantId }), controller: new AbortController(), current, ports: selectedPorts, launched: false, launchSettled: false,
|
|
6705
6734
|
stopRequested: false, stopSettled: false, stopKnown: false };
|
|
6706
6735
|
this.guidanceProbeActive.set(id, entry);
|
|
6707
6736
|
const ports: GuidanceProbeFakePorts = {
|
|
@@ -6710,17 +6739,17 @@ export class Tasks {
|
|
|
6710
6739
|
this.guidanceProbeWatch(entry);
|
|
6711
6740
|
if (signal.aborted) throw new Error("owned probe was aborted before launch");
|
|
6712
6741
|
entry.launched = true;
|
|
6713
|
-
return
|
|
6742
|
+
return selectedPorts.launch(input, effects, signal);
|
|
6714
6743
|
},
|
|
6715
|
-
stop: (input, signal) =>
|
|
6716
|
-
...(
|
|
6744
|
+
stop: (input, signal) => selectedPorts.stop(input, signal),
|
|
6745
|
+
...(selectedPorts.discardRetained ? { discardRetained: record => selectedPorts.discardRetained!(record) } : {}),
|
|
6717
6746
|
};
|
|
6718
6747
|
let reserved = false, returned = false;
|
|
6719
|
-
const runner = new GuidanceProbeFixtureHost(dependency.store, { ports, revalidate: current, now: () => this.d.now?.() ?? Date.now(),
|
|
6720
|
-
prepareWorkerFrame: dependency.prepareWorkerFrame, prepareEditorFrame: dependency.prepareEditorFrame, onReserved: () => { reserved = true; } });
|
|
6748
|
+
const runner = new GuidanceProbeFixtureHost(dependency.store, { ports, ...(live ? { mode: "live" as const } : {}), revalidate: current, now: () => this.d.now?.() ?? Date.now(),
|
|
6749
|
+
prepareWorkerFrame: live?.prepareWorkerFrame ?? dependency.prepareWorkerFrame, prepareEditorFrame: dependency.prepareEditorFrame, onReserved: () => { reserved = true; } });
|
|
6721
6750
|
entry.promise = (async () => {
|
|
6722
6751
|
try {
|
|
6723
|
-
const saved = await runner.start({ key, expectedRevision: revision, ...prepared, now: this.d.now?.() ?? Date.now() }, entry.controller.signal);
|
|
6752
|
+
const saved = await runner.start({ key, expectedRevision: revision, ...prepared, ...(live ? { mode: "live" as const } : {}), now: this.d.now?.() ?? Date.now() }, entry.controller.signal);
|
|
6724
6753
|
returned = true;
|
|
6725
6754
|
if (saved.state === "unknown_held" && entry.launched) {
|
|
6726
6755
|
this.guidanceProbeAbort(entry, "observation", true);
|
package/src/local/probe-types.ts
CHANGED
|
@@ -50,6 +50,7 @@ export interface ProbeLocalSession {
|
|
|
50
50
|
config: Readonly<ProbeLocalModelConfig>;
|
|
51
51
|
accounting: ProbeLocalEffectScope;
|
|
52
52
|
reserve(charges: ProbeResourceCharges, descriptor: string): Promise<void>;
|
|
53
|
+
pinnedChat?: Awaited<ReturnType<OmniRoute["pinCampusChat"]>>;
|
|
53
54
|
}
|
|
54
55
|
export interface ProbeLocalResult {
|
|
55
56
|
answer: string;
|
|
@@ -224,6 +224,55 @@ export function probeWorkspaceCurrent(workspace: ProbeWorkspace): void {
|
|
|
224
224
|
}
|
|
225
225
|
export function probeWorkspacePrivateRoot(workspace: ProbeWorkspace): string { probeWorkspaceCurrent(workspace); return workspaces.get(workspace)!.parent; }
|
|
226
226
|
export function probeWorkspaceTemporaryRoot(workspace: ProbeWorkspace): string { probeWorkspaceCurrent(workspace); return workspaces.get(workspace)!.temporaryRoot; }
|
|
227
|
+
|
|
228
|
+
/** Release an empty-source live workspace after its owner joined the stop and collected output. */
|
|
229
|
+
export function releaseEmptyProbeWorkspace(workspace: ProbeWorkspace): void {
|
|
230
|
+
probeWorkspacePhysical(workspace);
|
|
231
|
+
const state = workspaces.get(workspace)!;
|
|
232
|
+
if (state.identities.length || workspace.files.length) refused();
|
|
233
|
+
const directories = new Map(state.directories.map(entry => [entry.file, entry])), allowedDirectories = new Set(directories.keys());
|
|
234
|
+
const writable = new Set(workspace.allowedWrites);
|
|
235
|
+
for (const file of writable) {
|
|
236
|
+
for (let directory = dirname(file); !allowedDirectories.has(directory); directory = dirname(directory)) {
|
|
237
|
+
if (directory === dirname(directory)) refused();
|
|
238
|
+
allowedDirectories.add(directory);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const files: { file: string; dev: number; ino: number }[] = [];
|
|
242
|
+
const find = (directory: string): void => {
|
|
243
|
+
const handle = opendirSync(directory);
|
|
244
|
+
try {
|
|
245
|
+
for (let entry = handle.readSync(); entry; entry = handle.readSync()) {
|
|
246
|
+
const file = join(directory, entry.name);
|
|
247
|
+
if (allowedDirectories.has(file)) {
|
|
248
|
+
const existing = directories.get(file);
|
|
249
|
+
if (existing) requireDirectory(existing);
|
|
250
|
+
else directories.set(file, directoryIdentity(file));
|
|
251
|
+
find(file);
|
|
252
|
+
} else if (writable.has(file)) {
|
|
253
|
+
const stat = lstatSync(file);
|
|
254
|
+
if (!stat.isFile() || stat.nlink !== 1) refused();
|
|
255
|
+
files.push({ file, dev: stat.dev, ino: stat.ino });
|
|
256
|
+
} else refused();
|
|
257
|
+
}
|
|
258
|
+
} finally { handle.closeSync(); }
|
|
259
|
+
};
|
|
260
|
+
find(state.parent);
|
|
261
|
+
const requireParents = (file: string): void => {
|
|
262
|
+
for (let directory = dirname(file); directories.has(directory); directory = dirname(directory))
|
|
263
|
+
requireDirectory(directories.get(directory)!);
|
|
264
|
+
};
|
|
265
|
+
for (const entry of files) {
|
|
266
|
+
requireParents(entry.file);
|
|
267
|
+
const stat = lstatSync(entry.file);
|
|
268
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.dev !== entry.dev || stat.ino !== entry.ino) refused();
|
|
269
|
+
unlinkSync(entry.file);
|
|
270
|
+
}
|
|
271
|
+
for (const entry of [...directories.values()].sort((a, b) => b.file.length - a.file.length)) {
|
|
272
|
+
requireParents(entry.file); requireDirectory(entry); rmdirSync(entry.file);
|
|
273
|
+
}
|
|
274
|
+
workspaces.delete(workspace);
|
|
275
|
+
}
|
|
227
276
|
/** Local conservative ceiling, called before the owner ledger's compound admission; never performs a second ledger effect. */
|
|
228
277
|
export function reserveProbeWorkspaceBytes(workspace: ProbeWorkspace, bytes: number): void {
|
|
229
278
|
probeWorkspaceCurrent(workspace); const state = workspaces.get(workspace)!;
|
package/src/omniroute/client.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface ChatOptions {
|
|
|
45
45
|
onCampusOnly?: boolean;
|
|
46
46
|
signal?: AbortSignal;
|
|
47
47
|
}
|
|
48
|
+
type ChatRequest = { model: string; messages: ChatMessage[]; tools?: unknown[]; max_tokens?: number; temperature?: number; reasoning_effort?: string };
|
|
48
49
|
|
|
49
50
|
const readSecret = (file?: string) => {
|
|
50
51
|
try {
|
|
@@ -155,10 +156,24 @@ export class OmniRoute {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
async chat(body:
|
|
159
|
+
async chat(body: ChatRequest, opts: ChatOptions = {}): Promise<ChatResult> {
|
|
159
160
|
const base = await this.base();
|
|
160
161
|
if (!base) throw new Error("no model gateway is configured or reachable (omniroute.urls in .agenthub/config.json; see ahub doctor)");
|
|
161
162
|
if (opts.onCampusOnly && this.isAccessHost(base)) throw new Error("PII model calls require the confirmed campus gateway");
|
|
163
|
+
return this.chatAt(base, body, opts);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** A single endpoint and model for a confined experiment, with no route selection after admission. */
|
|
167
|
+
async pinCampusChat(model: string): Promise<(body: Omit<ChatRequest, "model">, signal: AbortSignal) => Promise<ChatResult>> {
|
|
168
|
+
const onCampus = await this.onCampus();
|
|
169
|
+
const base = this.live;
|
|
170
|
+
if (!base) throw new Error("campus gateway unavailable (no healthy endpoint); run ahub doctor");
|
|
171
|
+
if (this.isAccessHost(base)) throw new Error("campus gateway unavailable (Access endpoint selected); run ahub doctor on campus");
|
|
172
|
+
if (!onCampus) throw new Error("campus gateway unavailable (campus connection unconfirmed); run ahub doctor");
|
|
173
|
+
return (body, signal) => this.chatAt(base, { ...body, model }, { signal }, true);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private async chatAt(base: string, body: ChatRequest, opts: ChatOptions, pinned = false): Promise<ChatResult> {
|
|
162
177
|
const headers: Record<string, string> = { "content-type": "application/json" };
|
|
163
178
|
const key = this.apiKey();
|
|
164
179
|
if (!key) throw new Error("no OmniRoute API key (set OMNIROUTE_API_KEY or omniroute.api_key_file)");
|
|
@@ -167,15 +182,16 @@ export class OmniRoute {
|
|
|
167
182
|
try {
|
|
168
183
|
res = await fetch(`${base}/chat/completions`, {
|
|
169
184
|
method: "POST",
|
|
185
|
+
...(pinned ? { redirect: "error" as const } : {}),
|
|
170
186
|
headers,
|
|
171
187
|
body: JSON.stringify({ ...body, messages: body.messages.map(({ is_error: _internalError, ...message }) => message), stream: false }),
|
|
172
188
|
...(opts.signal ? { signal: opts.signal } : {}),
|
|
173
189
|
});
|
|
174
190
|
} catch (e) {
|
|
175
|
-
this.live = undefined; // probe again next time: the VPN may have dropped
|
|
191
|
+
if (!pinned) this.live = undefined; // probe again next time: the VPN may have dropped
|
|
176
192
|
throw e;
|
|
177
193
|
}
|
|
178
|
-
if (!res.ok) throw new Error(`model call failed: HTTP ${res.status} ${(await res.text()).slice(0, 300)}`);
|
|
194
|
+
if (!res.ok) throw new Error(`model call failed: HTTP ${res.status}${pinned ? "" : ` ${(await res.text()).slice(0, 300)}`}`);
|
|
179
195
|
const json = (await res.json()) as { choices?: { message?: ChatMessage }[]; usage?: unknown; model?: unknown };
|
|
180
196
|
const message = json.choices?.[0]?.message;
|
|
181
197
|
if (!message) throw new Error("model call returned no message");
|
package/src/ui/guidance-panel.ts
CHANGED
|
@@ -20,7 +20,7 @@ export default (host) => {
|
|
|
20
20
|
const probeLabel = node('label'); probeLabel.append(node('span', 'Probe ID (64 hex)'), probeId);
|
|
21
21
|
const probeButton = node('button', 'Read probe status'); probeButton.type = 'submit';
|
|
22
22
|
probeForm.append(probeLabel, probeButton);
|
|
23
|
-
const probeNote = node('p', 'Probe status
|
|
23
|
+
const probeNote = node('p', 'Probe status reads sealed receipts and the outcome denominator. A run with fixture evidence only claims no live model or worker trial.');
|
|
24
24
|
const probeOutput = node('pre', undefined, 'ahub-guidance-output');
|
|
25
25
|
probeOutput.tabIndex = 0; probeOutput.setAttribute('aria-label', 'Guidance probe status');
|
|
26
26
|
const scopeForm = node('form', undefined, 'ahub-guidance-scope');
|
|
@@ -145,7 +145,7 @@ export default (host) => {
|
|
|
145
145
|
state(typeof result?.error === 'string' && result.ok === false ? result.error : 'Probe status unavailable. Refresh the probe id or check access and guidance_probe_receipts support.'); return;
|
|
146
146
|
}
|
|
147
147
|
probeOutput.textContent = result.lines.join('\n');
|
|
148
|
-
state('Probe status read. Fixture evidence only; every unknown stays unknown.');
|
|
148
|
+
state(result.probe.slots?.some(slot => slot.receipt?.mode === 'live') ? 'Probe status read. Live attempt evidence.' : 'Probe status read. Fixture evidence only; every unknown stays unknown.');
|
|
149
149
|
} catch { if (active(token)) state('Probe status unavailable. Refresh the probe id or check access and guidance_probe_receipts support.'); }
|
|
150
150
|
finally { if (active(token)) { busy = false; update(); } }
|
|
151
151
|
}
|
package/src/ui/guidance-view.ts
CHANGED
|
@@ -49,7 +49,7 @@ const known = (value: number | null): string => value === null ? "unknown" : Str
|
|
|
49
49
|
/**
|
|
50
50
|
* T4 (#1226): the producer's probe status, one text for the plugin panel and the CLI. It states what the host observed and nothing more: a fixture run says
|
|
51
51
|
* `fixture`, a missing measurement says `unknown` and never zero, and every state that is not a success stays visible, so a failed, cancelled or unavailable
|
|
52
|
-
* arm cannot disappear from the denominator.
|
|
52
|
+
* arm cannot disappear from the denominator. Only a host-sealed live record is rendered as a live attempt.
|
|
53
53
|
*/
|
|
54
54
|
export function guidanceProbeStatusLines(exported: ProbeReceiptExport): string[] {
|
|
55
55
|
const status = exported.status, counts = exported.counts;
|
|
@@ -60,7 +60,9 @@ export function guidanceProbeStatusLines(exported: ProbeReceiptExport): string[]
|
|
|
60
60
|
`Attempts: ${status.counters.workerAttempts} worker, ${status.counters.editorAttempts} editor; model calls ${status.counters.modelCalls}; tool calls ${status.counters.toolCalls}.`,
|
|
61
61
|
`Token usage: ${status.counters.usageUnknown || status.counters.modelCalls === 0 ? "unknown" : status.counters.tokensObservedKnown}.`,
|
|
62
62
|
`Cancel requested: ${status.cancelRequested ? "yes" : "no"}.`,
|
|
63
|
-
|
|
63
|
+
exported.slots.some(slot => slot.receipt?.mode === "live")
|
|
64
|
+
? "Live attempt evidence. Upstream fallback policy and sampling control remain unknown."
|
|
65
|
+
: "Fixture evidence only: no live model or worker trial, sampling control, provider behaviour or model quality is claimed."];
|
|
64
66
|
for (const slot of exported.slots) {
|
|
65
67
|
const receipt = slot.receipt;
|
|
66
68
|
lines.push(`Slot ${plain(slot.slotId)}: ${slot.stage}/${slot.role}/${slot.arm}; session ${slot.state}; retained output ${slot.retention}.`);
|