@staix/agent-hub 0.35.0 → 0.37.0
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 +43 -0
- package/README.md +25 -4
- package/THIRD_PARTY_NOTICES.md +0 -18
- package/docs/agent-notes/README.md +71 -1
- package/docs/agent-notes/adapters.md +5 -2
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +7 -6
- package/docs/agent-notes/local-worker.md +1 -0
- package/docs/agent-notes/models.md +5 -3
- package/docs/agent-notes/tasks.md +9 -2
- package/docs/agent-notes/tests.md +1 -1
- package/docs/contracts/companion-cli-v1.json +70 -0
- package/docs/design/adapters.md +115 -2
- package/docs/design/agent-hub-architecture.md +10 -2
- package/docs/design/bus.md +8 -0
- package/docs/design/execution-reference.md +171 -11
- package/docs/design/guidance-experiments.md +438 -0
- package/docs/design/guidance-probes.md +802 -0
- package/docs/design/model-routes.md +1053 -0
- package/docs/design/supervision.md +121 -0
- package/docs/design/task-board.md +111 -0
- package/docs/dogfood.md +24 -15
- package/docs/events.md +20 -1
- package/docs/memory.md +3 -3
- package/docs/operations.md +366 -133
- package/docs/profiles.md +2 -2
- package/docs/quickstart.md +114 -3
- package/docs/research.md +5 -3
- package/docs/sdlc.md +113 -7
- package/docs/security.md +88 -6
- package/docs/specs/2026-09-19-agent-hub-design.md +14 -11
- package/docs/specs/2026-10-04-switchyard-source-port-design.md +3 -1
- package/docs/verification/2026-10-25-qwen-dual-output-t0.md +22 -0
- package/docs/verification/2026-11-08-qwen-0269-model-setter-1317.md +25 -11
- package/docs/verification/2026-11-09-qwen-0270-acp.md +181 -0
- package/docs/verification/2026-11-09-qwen-0270-model-setter-1317.md +61 -0
- package/docs/verification/2026-11-10-0.36.0.md +59 -0
- package/docs/verification/2026-11-10-claude-implementer-2.1.322.md +59 -0
- package/docs/verification/2026-11-10-qwen-0270-dual-output.md +367 -0
- package/docs/verification/2026-11-10-qwen-0271-dual-output.md +101 -0
- package/docs/verification/2026-11-11-0.37.0.md +40 -0
- package/docs/verification/2026-11-11-guidance-probe-t2-1226.md +153 -0
- package/docs/verification/2026-11-11-qwen-setter-suggestions-off.md +167 -0
- package/docs/verification/claude-shell-wrapper-native.py +1 -1
- package/docs/verified.json +27 -27
- package/package.json +3 -4
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +3570 -1800
- package/plugins/agent-hub/server.js +4112 -1913
- package/src/adapters/channel-peer.ts +7 -1
- package/src/adapters/claude-channel.ts +7 -4
- package/src/adapters/compat.ts +10 -10
- package/src/adapters/local-probe.ts +174 -0
- package/src/adapters/local-worker.ts +233 -22
- package/src/adapters/qwen-dual.ts +324 -44
- package/src/cli/console-state.ts +25 -6
- package/src/cli/console-versions.ts +99 -0
- package/src/cli/console.ts +13 -1
- package/src/cli/guidance.ts +67 -0
- package/src/cli/help.ts +12 -4
- package/src/cli/identity.ts +10 -3
- package/src/cli/init-prompt.ts +15 -2
- package/src/cli/init-required-checks.ts +122 -0
- package/src/cli/init-settings.ts +10 -4
- package/src/cli/init.ts +39 -3
- package/src/cli/install-paths.ts +7 -2
- package/src/cli/lineage.ts +78 -0
- package/src/cli/main.ts +171 -14
- package/src/cli/runtime-version-warning.ts +2 -2
- package/src/cli/sdlc-output.ts +9 -5
- package/src/cli/setup-research.ts +10 -0
- package/src/hub/autonomy-defaults.ts +20 -9
- package/src/hub/board.ts +346 -4
- package/src/hub/build-entry.ts +11 -0
- package/src/hub/bus.ts +12 -0
- package/src/hub/ci-watch.ts +4 -4
- package/src/hub/config-apply.ts +6 -3
- package/src/hub/config-trust.ts +7 -1
- package/src/hub/control-client.ts +5 -2
- package/src/hub/daemon.ts +508 -26
- package/src/hub/delivery-hints.ts +4 -2
- package/src/hub/delivery-journal.ts +50 -2
- package/src/hub/delivery-public.ts +51 -0
- package/src/hub/dogfood-profile.ts +8 -4
- package/src/hub/events.ts +3 -2
- package/src/hub/execution-lineage-owner.ts +272 -0
- package/src/hub/execution-lineage.ts +52 -8
- package/src/hub/execution-links.ts +85 -0
- package/src/hub/guidance-probe-store.ts +713 -0
- package/src/hub/guidance-probes.ts +358 -0
- package/src/hub/guidance-variants.ts +398 -0
- package/src/hub/handoff.ts +1 -0
- package/src/hub/hub-tools.ts +43 -2
- package/src/hub/inference.ts +18 -5
- package/src/hub/manager.ts +44 -2
- package/src/hub/memory-policy.ts +2 -2
- package/src/hub/operational-authority.ts +13 -1
- package/src/hub/peers.ts +6 -1
- package/src/hub/planning.ts +1 -1
- package/src/hub/ports.ts +1 -1
- package/src/hub/progress.ts +47 -23
- package/src/hub/report.ts +2 -0
- package/src/hub/research.ts +1 -0
- package/src/hub/restart.ts +20 -0
- package/src/hub/roles.ts +26 -0
- package/src/hub/routing.ts +4 -1
- package/src/hub/sdlc-merge.ts +39 -1
- package/src/hub/sdlc-release-authorization.ts +139 -17
- package/src/hub/sdlc-release-policy.ts +100 -0
- package/src/hub/sdlc-release.ts +60 -8
- package/src/hub/sdlc.ts +62 -11
- package/src/hub/settings.ts +2 -0
- package/src/hub/supervision-proposals.ts +405 -0
- package/src/hub/supervision-rules.ts +388 -0
- package/src/hub/supervision.ts +2 -0
- package/src/hub/task-approval.ts +2 -2
- package/src/hub/task-repository.ts +5 -0
- package/src/hub/tasks.ts +917 -53
- package/src/local/probe-errors.ts +28 -0
- package/src/local/probe-sandbox.ts +224 -0
- package/src/local/probe-types.ts +108 -0
- package/src/local/probe-workspace.ts +237 -0
- package/src/local/sandbox.ts +71 -2
- package/src/local/tools.ts +135 -9
- package/src/memory/capture.ts +2 -2
- package/src/models/relay.ts +9 -2
- package/src/models/route/advisor-trigger.ts +88 -0
- package/src/models/route/config.ts +39 -8
- package/src/models/route/conversation-view.ts +179 -0
- package/src/models/route/decision-evidence.ts +1 -1
- package/src/models/route/decision.ts +193 -26
- package/src/models/route/escalation-control.ts +30 -0
- package/src/models/route/hub-prompts.ts +97 -0
- package/src/models/route/judge-choice.ts +155 -0
- package/src/models/route/judge-replies.ts +102 -0
- package/src/models/route/labels.ts +14 -70
- package/src/models/route/observation-signals.ts +250 -0
- package/src/models/route/plan-execute-choice.ts +27 -0
- package/src/models/route/relay-selector.ts +10 -9
- package/src/models/route/runtime.ts +129 -60
- package/src/models/route/stage-diagnostics.ts +22 -0
- package/src/models/route/stage-evidence.ts +55 -0
- package/src/models/route/stage-fallback.ts +58 -0
- package/src/models/route/stage-input.ts +155 -0
- package/src/models/route/stage.ts +5 -147
- package/src/models/route/turn-state.ts +77 -0
- package/src/omniroute/client.ts +3 -0
- package/src/ui/guidance-panel.ts +156 -0
- package/src/ui/guidance-view.ts +43 -0
- package/src/ui/lineage-view.ts +34 -0
- package/src/ui/plugin.ts +141 -27
- package/src/version.ts +4 -0
- package/templates/adec/README.md +32 -0
- package/templates/adec/ahub.plan-execute.json +23 -0
- package/templates/adec/ahub.stage.json +23 -0
- package/LICENSES/Apache-2.0.txt +0 -204
- package/src/models/route/advisor.ts +0 -102
- package/src/models/route/escalation.ts +0 -82
- package/src/models/route/judge.ts +0 -23
- package/src/models/route/normalize.ts +0 -103
- package/src/models/route/plan-execute.ts +0 -52
- package/src/models/route/prompts.ts +0 -8
- package/src/models/route/signals.ts +0 -247
- package/src/models/route/state.ts +0 -54
- package/src/models/route/text.ts +0 -61
package/src/hub/memory-policy.ts
CHANGED
|
@@ -60,7 +60,7 @@ export function promotionScreen(
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
/** Host-only review capsules retain bodies for recipients, never observer sinks or capture. */
|
|
63
|
-
export function isTrustedReviewPackage(env: Envelope): boolean {
|
|
63
|
+
export function isTrustedReviewPackage(env: Pick<Envelope, "from" | "kind" | "refs">): boolean {
|
|
64
64
|
return env.from === HUB && env.kind === "review" && typeof env.refs?.reviewPackage === "string"
|
|
65
65
|
&& /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(env.refs.reviewPackage);
|
|
66
66
|
}
|
|
@@ -80,7 +80,7 @@ export function reviewCaptureExcluded(tool: string, args: string): boolean {
|
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
/** reviewResponse is stamped by Bus from delivered-parent provenance, never peer refs. */
|
|
83
|
-
export function isReviewObserverExcluded(env: Envelope): boolean {
|
|
83
|
+
export function isReviewObserverExcluded(env: Pick<Envelope, "from" | "kind" | "refs">): boolean {
|
|
84
84
|
return isTrustedReviewPackage(env) || env.from !== HUB && env.from !== "user" && (env.kind === "chat" || env.kind === "status")
|
|
85
85
|
&& typeof env.refs?.reviewResponse === "string" && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(env.refs.reviewResponse);
|
|
86
86
|
}
|
|
@@ -32,7 +32,7 @@ export type ConductorLocalAction = typeof CONDUCTOR_LOCAL_ACTIONS[number];
|
|
|
32
32
|
export const conductorLocalAction = (value:unknown): value is ConductorLocalAction => typeof value==="string" && (CONDUCTOR_LOCAL_ACTIONS as readonly string[]).includes(value);
|
|
33
33
|
/** Daemon-authorized labels. Recovery labels pass the initial role check, then require their separate per-operation proof. */
|
|
34
34
|
export const CONDUCTOR_DAEMON_OPERATIONS = ["roster add","roster remove","stop","queue show","queue resolve","queue discard","settings set","doctor orphans kill","logs","export",
|
|
35
|
-
"board import","intake approve","schedule run","schedule pause","schedule resume","goal link","task unassign","restart","upgrade","recovery resume","recovery abort"] as const;
|
|
35
|
+
"board import","intake approve","schedule run","schedule pause","schedule resume","goal link","task unassign","guidance probe register","guidance probe start","guidance probe show","guidance probe cancel","restart","upgrade","recovery resume","recovery abort"] as const;
|
|
36
36
|
/**
|
|
37
37
|
* #933: forms whose effect runs in the CLI process itself (local files). The daemon admits and audits them once at the handshake (`admit`),
|
|
38
38
|
* after the CLI has validated their arguments. Recovery-bearing restart/upgrade forms use the separate source-issued continuation proof.
|
|
@@ -91,6 +91,14 @@ export function conductorOperation(command:string,args:readonly string[]): Condu
|
|
|
91
91
|
if (command==="intake" && sub==="approve" && words.length===2) return "intake approve";
|
|
92
92
|
if (command==="schedule" && (sub==="run" || sub==="pause" || sub==="resume")) return `schedule ${sub}`;
|
|
93
93
|
if (command==="goal" && args.find(arg=>arg!=="--json")==="link") return "goal link";
|
|
94
|
+
if (command === "guidance" && args[0] === "probe") {
|
|
95
|
+
switch (args[1]) {
|
|
96
|
+
case "register": return "guidance probe register";
|
|
97
|
+
case "start": return "guidance probe start";
|
|
98
|
+
case "show": return "guidance probe show";
|
|
99
|
+
case "cancel": return "guidance probe cancel";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
94
102
|
return undefined;
|
|
95
103
|
}
|
|
96
104
|
|
|
@@ -119,6 +127,10 @@ export function operationalRequestLabel(value:unknown):string|undefined {
|
|
|
119
127
|
if(message.t==="peer_stop")return "stop";
|
|
120
128
|
if(message.t==="goal_link")return "goal link";
|
|
121
129
|
if(message.t==="task" && typeof message.op==="string" && Object.hasOwn(CONDUCTOR_TASK_OPS,message.op))return CONDUCTOR_TASK_OPS[message.op];
|
|
130
|
+
if (typeof message.t === "string" && message.t.startsWith("guidance_probe_")) {
|
|
131
|
+
const operation = message.t.slice("guidance_probe_".length);
|
|
132
|
+
return ["register", "start", "show", "cancel"].includes(operation) ? `guidance probe ${operation}` : undefined;
|
|
133
|
+
}
|
|
122
134
|
if(message.t==="queue" && typeof message.op==="string" && ["show","resolve","discard"].includes(message.op))return `queue ${message.op}`;
|
|
123
135
|
if(message.t==="settings_set"||message.t==="settings_preview")return "settings set";
|
|
124
136
|
return undefined;
|
package/src/hub/peers.ts
CHANGED
|
@@ -53,6 +53,11 @@ export interface PeerAdapter {
|
|
|
53
53
|
readonly standbySessions?: readonly PeerStandbySession[];
|
|
54
54
|
/** The current owner's attachment facts, for display only; absent unless a socket is attached and no newer claim is arriving (#1310). */
|
|
55
55
|
readonly ownerAttachment?: PeerOwnerAttachment;
|
|
56
|
+
/**
|
|
57
|
+
* #1385: the agent-hub client this peer runs in another process, for display only. Absent means the adapter runs inside the daemon, so it runs the daemon's own code; `attached` false
|
|
58
|
+
* means no client is attached now, and an attached client without `version` did not report one. Never admission, compatibility or authorization evidence.
|
|
59
|
+
*/
|
|
60
|
+
readonly hubClient?: { attached: boolean; version?: string };
|
|
56
61
|
/** Person-authorized takeover port. The host still performs its own admission and claim fences. */
|
|
57
62
|
takeover?(standbyId: string | undefined, eligible: (socket: object) => boolean): PeerTakeoverClaim | undefined;
|
|
58
63
|
/** Exact transport ownership check for guarding a selected standby through its asynchronous preface. */
|
|
@@ -101,7 +106,7 @@ export interface PeerAdapter {
|
|
|
101
106
|
/** Fixed-builtin native proof only; present undefined is unknown, not an absent proxy. */
|
|
102
107
|
readonly frontendProxy?: FrontendProxyPort;
|
|
103
108
|
/** Fixed operator notices from builtin native adapters, never provider text or native ids. */
|
|
104
|
-
readonly statusNotice?: { code: "unidentified-cancellation" | "qwen-detached" | "qwen-stalled" | "jcode-headless-after-recovery"; message: string };
|
|
109
|
+
readonly statusNotice?: { code: "unidentified-cancellation" | "qwen-detached" | "qwen-stalled" | "qwen-deny-quiescence" | "jcode-headless-after-recovery"; message: string };
|
|
105
110
|
/** Fixed builtins with session.nativeRevert only. Native conversation effects remain in the adapter. */
|
|
106
111
|
revertTurn?(nativeTurn: string): Promise<void>;
|
|
107
112
|
/** #445 C1: what this peer's native source lists right now (a probed version only), or an empty manifest. Never throws for an unprobed version; a transport failure rejects. */
|
package/src/hub/planning.ts
CHANGED
|
@@ -77,7 +77,7 @@ export function planningPatch(input: unknown = {}): PlanningPatch {
|
|
|
77
77
|
/** Structured lifecycle events only, including reviewerless approval via done. */
|
|
78
78
|
export function actualTaskDates(task: Pick<Task, "history" | "state" | "reviewer">) {
|
|
79
79
|
const first = (events: readonly string[]) => task.history.find(entry => events.includes(entry.event))?.at ?? null;
|
|
80
|
-
const approved = first(["approved"]), reviewed = task.reviewer !== null || task.history.some(entry => entry.event === "approved" || entry.event === "changes_requested");
|
|
80
|
+
const approved = first(["approved", "merged outside the hub"]), reviewed = task.reviewer !== null || task.history.some(entry => entry.event === "approved" || entry.event === "changes_requested");
|
|
81
81
|
const reviewerlessDone = task.state === "approved" && !task.reviewer ? [...task.history].reverse().find(entry => entry.event === "done")?.at ?? null : null;
|
|
82
82
|
return { startedAt: first(["accepted"]), reviewAt: reviewed ? first(["done"]) : null, doneAt: approved ?? reviewerlessDone };
|
|
83
83
|
}
|
package/src/hub/ports.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const CONTROL = 0;
|
|
|
10
10
|
export const CODEX_APP = 1;
|
|
11
11
|
export const CODEX_PROXY = 2;
|
|
12
12
|
/** Reserved after sidecar retirement (#553); never bind this offset or move later allocations. */
|
|
13
|
-
export const
|
|
13
|
+
export const RESERVED_SIDECAR = 3;
|
|
14
14
|
|
|
15
15
|
/** SQLite-backed project allocation; an explicit JSON path retains the legacy utility API under a lock. */
|
|
16
16
|
export function allocatePorts(projectDir: string, registry?: string): number {
|
package/src/hub/progress.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
1
|
+
import { EscalationControl } from "../models/route/escalation-control.ts";
|
|
2
|
+
import type { EscalationCategory, EscalationReply } from "../models/route/judge-replies.ts";
|
|
3
|
+
import { diagnoseStageResult } from "../models/route/stage-diagnostics.ts";
|
|
4
|
+
import { repeatedObservationFailure, failureFingerprint as fingerprint, type ToolObservation } from "../models/route/observation-signals.ts";
|
|
5
5
|
import type { HubEvent } from "./events.ts";
|
|
6
6
|
import type { Task } from "./board.ts";
|
|
7
7
|
|
|
@@ -10,7 +10,19 @@ const MAX_STATES = 256;
|
|
|
10
10
|
const MAX_OBSERVATIONS = 28;
|
|
11
11
|
const MAX_TEXT = 500;
|
|
12
12
|
|
|
13
|
-
type NativeToolObservation = ToolObservation & { turn?: string };
|
|
13
|
+
export type NativeToolObservation = ToolObservation & { turn?: string };
|
|
14
|
+
|
|
15
|
+
/** The host-owned progress factory's grouped record, not a provider normalizer schema. */
|
|
16
|
+
export interface ProgressConversation {
|
|
17
|
+
instructions: string[];
|
|
18
|
+
instructionRoles: "system"[];
|
|
19
|
+
messages: {
|
|
20
|
+
role: "user" | "assistant";
|
|
21
|
+
content: string;
|
|
22
|
+
toolCalls: { id: string; name: string; arguments: { command?: string } }[];
|
|
23
|
+
toolResults: { toolCallId: string; content: string; isError?: boolean }[];
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
14
26
|
|
|
15
27
|
/** Normalize only completed Codex work observations; event payloads and unrelated item text are ignored. */
|
|
16
28
|
export function normalizeCodexObservation(value: unknown): ToolObservation | undefined {
|
|
@@ -40,7 +52,7 @@ interface ProgressState {
|
|
|
40
52
|
task: number;
|
|
41
53
|
at: number;
|
|
42
54
|
observations: NativeToolObservation[];
|
|
43
|
-
escalation:
|
|
55
|
+
escalation: EscalationControl;
|
|
44
56
|
generation: number;
|
|
45
57
|
checking: boolean;
|
|
46
58
|
attemptedTurns: Set<string>;
|
|
@@ -54,16 +66,34 @@ export interface ProgressDimensions {
|
|
|
54
66
|
production: number;
|
|
55
67
|
}
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
/** Observer calibration is independent of stage risk and never reads commands/arguments. */
|
|
70
|
+
export function progressDimensions(observations: readonly NativeToolObservation[]): ProgressDimensions {
|
|
71
|
+
let severity = 0, reads = 0, mutations = 0, inspected = 0;
|
|
72
|
+
const turns = new Set<string>();
|
|
73
|
+
for (let index = Math.max(0, observations.length - MAX_OBSERVATIONS); index < observations.length; index++) {
|
|
74
|
+
const item = observations[index];
|
|
75
|
+
if (!item) continue;
|
|
76
|
+
inspected++;
|
|
77
|
+
const name = item.name.slice(0, 80).toLowerCase();
|
|
78
|
+
const read = /^(read|read_file|glob|grep|search|list|list_dir)$/.test(name);
|
|
79
|
+
const mutation = /^(filechange|write|write_file|edit|apply_patch|patch|delete|create|replace)$/.test(name);
|
|
80
|
+
if (read) reads++;
|
|
81
|
+
if (mutation) mutations++;
|
|
82
|
+
const diagnostic = diagnoseStageResult({ text: item.resultText?.slice(0, MAX_TEXT) ?? "", error: item.isError === true,
|
|
83
|
+
family: read ? "read" : mutation ? "mutation" : "other", associated: true });
|
|
84
|
+
if (diagnostic.fault !== "none") severity = 0.7;
|
|
85
|
+
const turn = validTurn(item.turn);
|
|
86
|
+
if (turn) turns.add(turn);
|
|
87
|
+
}
|
|
88
|
+
return { severity, spinning: turns.size >= 8 && mutations === 0 ? 1 : 0,
|
|
89
|
+
exploring: reads / Math.max(1, inspected), production: mutations / Math.max(1, inspected) };
|
|
60
90
|
}
|
|
61
91
|
|
|
62
92
|
export interface ProgressDeps {
|
|
63
93
|
tasks(): Task[];
|
|
64
94
|
/** The same project-wide gate used for turn-free facts: no observation while any PII task is open. */
|
|
65
95
|
isPrivate(): boolean;
|
|
66
|
-
inference: { escalate(conversation:
|
|
96
|
+
inference: { escalate(conversation: ProgressConversation, turn: number): Promise<EscalationReply | undefined> };
|
|
67
97
|
emit(event: HubEvent): void;
|
|
68
98
|
notify(line: string): void;
|
|
69
99
|
now?: () => number;
|
|
@@ -89,8 +119,7 @@ export class ProgressObserver {
|
|
|
89
119
|
state.observations.push(boundedObservation(observation));
|
|
90
120
|
if (state.observations.length > MAX_OBSERVATIONS) state.observations.splice(0, state.observations.length - MAX_OBSERVATIONS);
|
|
91
121
|
pruneAttemptedTurns(state);
|
|
92
|
-
|
|
93
|
-
this.safeEmit({ type: "progress", peer, task: taskId, ...progressDimensions(signals) });
|
|
122
|
+
this.safeEmit({ type: "progress", peer, task: taskId, ...progressDimensions(state.observations) });
|
|
94
123
|
if (this.judgeEligible(state)) void this.evaluateState(peer, taskId, state);
|
|
95
124
|
}
|
|
96
125
|
|
|
@@ -145,9 +174,8 @@ export class ProgressObserver {
|
|
|
145
174
|
|
|
146
175
|
private judgeEligible(state: ProgressState): boolean {
|
|
147
176
|
if (!latestNativeTurn(state.observations) || state.escalation.snapshot().latched) return false;
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
return repeatedAcrossTurns || progressDimensions(signals).spinning > 0;
|
|
177
|
+
const repeatedAcrossTurns = repeatedObservationFailure(state.observations) === true && repeatedFailureAcrossTurns(state.observations);
|
|
178
|
+
return repeatedAcrossTurns || progressDimensions(state.observations).spinning > 0;
|
|
151
179
|
}
|
|
152
180
|
|
|
153
181
|
private openTask(peer: string, id: number): Task | undefined {
|
|
@@ -171,7 +199,7 @@ export class ProgressObserver {
|
|
|
171
199
|
let state = this.states.get(id);
|
|
172
200
|
if (!state) {
|
|
173
201
|
if (this.states.size >= MAX_STATES) this.states.delete(this.states.keys().next().value!);
|
|
174
|
-
state = { peer, task, at: this.now(), observations: [], escalation: new
|
|
202
|
+
state = { peer, task, at: this.now(), observations: [], escalation: new EscalationControl(), generation: 0, checking: false, attemptedTurns: new Set(), turn: 0 };
|
|
175
203
|
this.states.set(id, state);
|
|
176
204
|
}
|
|
177
205
|
return state;
|
|
@@ -216,17 +244,13 @@ function repeatedFailureAcrossTurns(observations: readonly NativeToolObservation
|
|
|
216
244
|
return [...turnsByFingerprint.values()].some((turns) => turns.size >= 2);
|
|
217
245
|
}
|
|
218
246
|
|
|
219
|
-
function signalsFor(observations: readonly NativeToolObservation[]): ToolSignals {
|
|
220
|
-
return extractToolSignalsFromObservations(observations, knownTurns(observations).length);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
247
|
function pruneAttemptedTurns(state: ProgressState): void {
|
|
224
248
|
const active = new Set(knownTurns(state.observations));
|
|
225
249
|
for (const turn of state.attemptedTurns) if (!active.has(turn)) state.attemptedTurns.delete(turn);
|
|
226
250
|
}
|
|
227
251
|
|
|
228
|
-
function conversation(observations: readonly NativeToolObservation[], task: Task):
|
|
229
|
-
const frames = new Map<string, { role: "assistant"; content: string; toolCalls: { id: string; name: string; arguments:
|
|
252
|
+
function conversation(observations: readonly NativeToolObservation[], task: Task): ProgressConversation {
|
|
253
|
+
const frames = new Map<string, { role: "assistant"; content: string; toolCalls: { id: string; name: string; arguments: { command?: string } }[]; toolResults: { toolCallId: string; content: string; isError?: boolean }[] }>();
|
|
230
254
|
let nextCall = 0;
|
|
231
255
|
for (const item of observations) {
|
|
232
256
|
const nativeTurn = validTurn(item.turn);
|
|
@@ -247,5 +271,5 @@ function conversation(observations: readonly NativeToolObservation[], task: Task
|
|
|
247
271
|
};
|
|
248
272
|
}
|
|
249
273
|
|
|
250
|
-
export type ProgressVerdict =
|
|
274
|
+
export type ProgressVerdict = EscalationReply;
|
|
251
275
|
export type ProgressCategory = Exclude<EscalationCategory, "none">;
|
package/src/hub/report.ts
CHANGED
|
@@ -114,6 +114,7 @@ export function summarize(events: StampedEvent[]): Report {
|
|
|
114
114
|
const seenSupervision = new Set<string>();
|
|
115
115
|
const lastTier = new Map<string, string>();
|
|
116
116
|
for (const e of events) {
|
|
117
|
+
if (e.type === "route" && e.decisionTarget === "judge") continue;
|
|
117
118
|
r.from ??= e.at;
|
|
118
119
|
r.to = e.at;
|
|
119
120
|
switch (e.type) {
|
|
@@ -304,6 +305,7 @@ export function summarizeByTask(events: StampedEvent[]): TaskReport {
|
|
|
304
305
|
const seenUsage = new Set<string>();
|
|
305
306
|
// Resolve latest class/outcome before rolling usage up: usage may precede the task's history in a slice.
|
|
306
307
|
for (const e of events) {
|
|
308
|
+
if (e.type === "route" && e.decisionTarget === "judge") continue;
|
|
307
309
|
r.from ??= e.at; r.to = e.at;
|
|
308
310
|
if (startsAttribution(e) && reportingSince === null) reportingSince = Date.parse(e.at);
|
|
309
311
|
if (e.type !== "task") continue;
|
package/src/hub/research.ts
CHANGED
|
@@ -157,6 +157,7 @@ export function taskRecords(events: StampedEvent[], projectId: string, writer: T
|
|
|
157
157
|
else delete a.tooling[peer]; // a fingerprint of an earlier attachment does not describe this work: unknown until one comes
|
|
158
158
|
};
|
|
159
159
|
for (const e of events) {
|
|
160
|
+
if (e.type === "route" && e.decisionTarget === "judge") continue;
|
|
160
161
|
// A crash writes no offline: a new run is a new attachment, and no fingerprint from before it describes later work.
|
|
161
162
|
if (e.type === "hub_start") { online.clear(); tooling.clear(); if (startsAttribution(e)) personReportingSince ??= Date.parse(e.at); continue; }
|
|
162
163
|
if (e.type === "state") {
|
package/src/hub/restart.ts
CHANGED
|
@@ -47,6 +47,9 @@ export interface RestartSnapshot {
|
|
|
47
47
|
boardDigest: string;
|
|
48
48
|
budgetDigest: string;
|
|
49
49
|
modelOverrides?: { count: number; digest: string };
|
|
50
|
+
guidanceVariants?: { experiments: number; variants: number; digest: string };
|
|
51
|
+
guidanceProbes?: { experiments: number; sessions: number; digest: string };
|
|
52
|
+
executionReferences?: { count: number; digest: string };
|
|
50
53
|
/** Whole captured binding set; portable identities are covered alongside queue/board integrity. */
|
|
51
54
|
externalBindingsDigest?: string;
|
|
52
55
|
/** Research state remains part of controlled-recovery integrity when present. */
|
|
@@ -114,6 +117,23 @@ export function readRestartSnapshot(stateDir: string, expected: RestartReadExpec
|
|
|
114
117
|
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join(",") !== "count,digest"
|
|
115
118
|
|| !Number.isSafeInteger(value.count) || value.count < 0 || typeof value.digest !== "string" || !/^[a-f0-9]{64}$/.test(value.digest)) return undefined;
|
|
116
119
|
}
|
|
120
|
+
if (s.integrity && Object.hasOwn(s.integrity, "guidanceVariants")) {
|
|
121
|
+
const value = s.integrity.guidanceVariants;
|
|
122
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join(",") !== "digest,experiments,variants"
|
|
123
|
+
|| !Number.isSafeInteger(value.experiments) || value.experiments < 0 || !Number.isSafeInteger(value.variants) || value.variants < value.experiments
|
|
124
|
+
|| typeof value.digest !== "string" || value.digest.length !== 64 || !/^[a-f0-9]{64}$/.test(value.digest)) return undefined;
|
|
125
|
+
}
|
|
126
|
+
if (s.integrity && Object.hasOwn(s.integrity, "guidanceProbes")) {
|
|
127
|
+
const value = s.integrity.guidanceProbes;
|
|
128
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join(",") !== "digest,experiments,sessions"
|
|
129
|
+
|| !Number.isSafeInteger(value.experiments) || value.experiments < 0 || !Number.isSafeInteger(value.sessions) || value.sessions < value.experiments
|
|
130
|
+
|| typeof value.digest !== "string" || value.digest.length !== 64 || !/^[a-f0-9]{64}$/.test(value.digest)) return undefined;
|
|
131
|
+
}
|
|
132
|
+
if (s.integrity && Object.hasOwn(s.integrity, "executionReferences")) {
|
|
133
|
+
const value = s.integrity.executionReferences;
|
|
134
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join(",") !== "count,digest"
|
|
135
|
+
|| !Number.isSafeInteger(value.count) || value.count < 0 || typeof value.digest !== "string" || !/^[a-f0-9]{64}$/.test(value.digest)) return undefined;
|
|
136
|
+
}
|
|
117
137
|
if (s.integrity && Object.hasOwn(s.integrity, "research")) {
|
|
118
138
|
const research = s.integrity.research;
|
|
119
139
|
if (!research || typeof research !== "object" || Array.isArray(research)
|
package/src/hub/roles.ts
CHANGED
|
@@ -14,6 +14,16 @@ export interface CatalogRole {
|
|
|
14
14
|
body: string; review: string; layer: "shipped" | "project"; hash: string;
|
|
15
15
|
}
|
|
16
16
|
export interface RoleCatalog { roles: Map<string, CatalogRole>; errors: { id: string; reason: string }[] }
|
|
17
|
+
export interface RoleSectionSpan {
|
|
18
|
+
readonly name: typeof ROLE_SECTIONS[number];
|
|
19
|
+
readonly startUtf16: number; readonly endUtf16: number; readonly contentStartUtf16: number;
|
|
20
|
+
readonly headingRaw: string; readonly contentRaw: string; readonly raw: string;
|
|
21
|
+
}
|
|
22
|
+
export interface RoleDocument {
|
|
23
|
+
readonly role: Readonly<CatalogRole>;
|
|
24
|
+
readonly rawHeader: string; readonly bodyPrefix: string;
|
|
25
|
+
readonly sections: readonly RoleSectionSpan[];
|
|
26
|
+
}
|
|
17
27
|
/** Flat headers are data, never YAML execution or authority configuration. */
|
|
18
28
|
export function parseRole(text: string, stem: string, layer: CatalogRole["layer"]): CatalogRole {
|
|
19
29
|
if (Buffer.byteLength(text) > 8192 || text.includes("\r") || !ID.test(stem)) throw new Error("invalid role size, encoding or file id");
|
|
@@ -48,6 +58,22 @@ export function parseRole(text: string, stem: string, layer: CatalogRole["layer"
|
|
|
48
58
|
const review = body.slice(reviewStart, sections[5]!.index).trim();
|
|
49
59
|
return { id: stem, name: header.name!, group: header.group!, summary: header.summary!, source: header.source!, base: list("base", BASES), classes: list("classes", CLASSES), body, review, layer, hash: createHash("sha256").update(text).digest("hex") };
|
|
50
60
|
}
|
|
61
|
+
/** Validate with the existing parser, then retain exact source slices without trim or normalization. */
|
|
62
|
+
export function parseRoleDocument(text: string, stem: string, layer: CatalogRole["layer"]): RoleDocument {
|
|
63
|
+
const role = parseRole(text, stem, layer);
|
|
64
|
+
const rawHeader = /^---\n[\s\S]*?\n---\n/.exec(text)![0];
|
|
65
|
+
const body = text.slice(rawHeader.length), headings = [...body.matchAll(/^## (.+)$/gm)];
|
|
66
|
+
const sections = headings.map((heading, index): RoleSectionSpan => {
|
|
67
|
+
const startUtf16 = rawHeader.length + heading.index!;
|
|
68
|
+
const endUtf16 = rawHeader.length + (headings[index + 1]?.index ?? body.length);
|
|
69
|
+
let contentStartUtf16 = startUtf16 + heading[0].length;
|
|
70
|
+
if (text[contentStartUtf16] === "\n") contentStartUtf16++;
|
|
71
|
+
return Object.freeze({ name: ROLE_SECTIONS[index]!, startUtf16, endUtf16, contentStartUtf16,
|
|
72
|
+
headingRaw: text.slice(startUtf16, contentStartUtf16), contentRaw: text.slice(contentStartUtf16, endUtf16), raw: text.slice(startUtf16, endUtf16) });
|
|
73
|
+
});
|
|
74
|
+
Object.freeze(role.base); Object.freeze(role.classes); Object.freeze(role);
|
|
75
|
+
return Object.freeze({ role, rawHeader, bodyPrefix: body.slice(0, headings[0]!.index), sections: Object.freeze(sections) });
|
|
76
|
+
}
|
|
51
77
|
function projectRole(file: string): string {
|
|
52
78
|
const fd = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
53
79
|
try {
|
package/src/hub/routing.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface PeerCapabilities { tests: boolean; spec: boolean; testsReason?:
|
|
|
11
11
|
import type { PeerId, PeerState } from "./envelope.ts";
|
|
12
12
|
|
|
13
13
|
import { parseHubRoutes, type HubRoute } from "../models/route/config.ts";
|
|
14
|
-
import { DEFAULT_STAY_SWITCH, type StaySwitchMode } from "../models/route/stage.ts";
|
|
14
|
+
import { DEFAULT_STAY_SWITCH, type StaySwitchMode } from "../models/route/stage-fallback.ts";
|
|
15
15
|
|
|
16
16
|
export interface ClassPolicy {
|
|
17
17
|
/** preference order among attached, unpaused peers */
|
|
@@ -426,6 +426,8 @@ export function assign(
|
|
|
426
426
|
states: Record<PeerId, PeerState>,
|
|
427
427
|
routing: Routing,
|
|
428
428
|
opts: InstanceRoutingOptions & {
|
|
429
|
+
/** Precomputed snapshot guidance only; it never changes peer eligibility or performs a read. */
|
|
430
|
+
entryDiagnostic?: string;
|
|
429
431
|
capabilities?: Record<PeerId, PeerCapabilities>;
|
|
430
432
|
repository?: string;
|
|
431
433
|
exclude?: PeerId[];
|
|
@@ -469,6 +471,7 @@ export function assign(
|
|
|
469
471
|
const instanceMode = hasInstances(opts);
|
|
470
472
|
const policy = routing.classes[task.class];
|
|
471
473
|
const trace: string[] = [`class ${task.class}${policy ? "" : " (no [classes] entry: only an explicit owner can take it)"}`, `signals: ${task.signals.join(", ") || "none"}`];
|
|
474
|
+
if (opts.entryDiagnostic) trace.push(`build entry: ${opts.entryDiagnostic}`);
|
|
472
475
|
// Which file each of this class's values comes from (#269), only when the machine-local overlay sets one.
|
|
473
476
|
const local = Object.keys(routing.sources ?? {}).filter((key) => key.startsWith(`classes.${task.class}.`)).map((key) => key.slice(`classes.${task.class}.`.length));
|
|
474
477
|
if (local.length) trace.push(`policy source: ${local.join(", ")} from ${OVERLAY_FILE}; the rest from routing.toml`);
|
package/src/hub/sdlc-merge.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { findingsForHead, findingHead, findingTally } from "./review-findings.ts
|
|
|
2
2
|
import { readMergeQueue, type DeliveryTask, type MergeQueue } from "./sdlc-queue.ts";
|
|
3
3
|
import { evalGapBlockers, evalGateView, evalReportedGap, evalRequiredChecks, readEvalFor, type EvalResult } from "./eval-gate.ts";
|
|
4
4
|
import { mergeCostFrom } from "./cost-governance.ts";
|
|
5
|
-
import { readPrCostHistory, readSdlcPr, stageDefinition, type AutoMergeMode, type PrEvidence, type SdlcConfig, type SdlcGh, type MergeRecord } from "./sdlc.ts";
|
|
5
|
+
import { parsePrEvidence, readPrCostHistory, readSdlcPr, stageDefinition, type AutoMergeMode, type PrEvidence, type SdlcConfig, type SdlcGh, type MergeRecord, type SdlcReceipt } from "./sdlc.ts";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* #786 T1/T2: the one guarded merge. Given a task and the head its reviewer approved, it re-reads the PR (`readSdlcPr`) and the merge queue
|
|
@@ -91,6 +91,44 @@ function checkGates(evidence: PrEvidence, required: readonly string[], extra: re
|
|
|
91
91
|
return gates;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/** One bounded GitHub snapshot for adoption: no bodies, no merge or cleanup mutation, and complete head-bound review/check coverage. */
|
|
95
|
+
export async function readAdoptMergeEvidence(receipt: SdlcReceipt, run: SdlcGh): Promise<PrEvidence | undefined> {
|
|
96
|
+
if (!REPO.test(receipt.repo ?? "") || receipt.repo!.startsWith("-") || !Number.isSafeInteger(receipt.pr) || receipt.pr! <= 0) return undefined;
|
|
97
|
+
const [owner, name] = receipt.repo!.split("/");
|
|
98
|
+
const query = "query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){headRefOid state reviewDecision isDraft mergeCommit{oid} reviewRequests(first:100){nodes{requestedReviewer{__typename}} pageInfo{hasNextPage}} reviewThreads(first:100){nodes{isResolved} pageInfo{hasNextPage}} commits(last:1){nodes{commit{oid statusCheckRollup{contexts(first:100){nodes{... on CheckRun{name status conclusion} ... on StatusContext{context state}} pageInfo{hasNextPage}}}}}}}}}";
|
|
99
|
+
try {
|
|
100
|
+
const result = await run(["api", "graphql", "-f", `query=${query}`, "-f", `owner=${owner}`, "-f", `name=${name}`, "-F", `number=${receipt.pr}`]);
|
|
101
|
+
if (result.code !== 0) return undefined;
|
|
102
|
+
const response = JSON.parse(result.stdout), pr = response?.data?.repository?.pullRequest;
|
|
103
|
+
const commit = pr?.commits?.nodes?.length === 1 ? pr.commits.nodes[0]?.commit : undefined, checks = commit?.statusCheckRollup?.contexts;
|
|
104
|
+
if (response.errors !== undefined || !pr || commit?.oid !== pr.headRefOid || checks?.pageInfo?.hasNextPage !== false || !Array.isArray(checks.nodes)) return undefined;
|
|
105
|
+
const threads = pr.reviewThreads, requests = pr.reviewRequests;
|
|
106
|
+
const threadComplete = threads?.pageInfo?.hasNextPage === false && Array.isArray(threads.nodes) && threads.nodes.every((node: { isResolved?: unknown } | null) => typeof node?.isResolved === "boolean");
|
|
107
|
+
const requestComplete = requests?.pageInfo?.hasNextPage === false && Array.isArray(requests.nodes) && requests.nodes.every((node: { requestedReviewer?: { __typename?: unknown } } | null) => typeof node?.requestedReviewer?.__typename === "string");
|
|
108
|
+
const evidence = parsePrEvidence({ ...pr, statusCheckRollup: checks.nodes, files: [], ...(threadComplete ? { unresolvedThreads: threads.nodes.filter((node: { isResolved: boolean }) => !node.isResolved).length } : {}), reviewRequests: requestComplete ? requests.nodes : undefined });
|
|
109
|
+
evidence.checks = evidence.checks.map((check, index): PrEvidence["checks"][number] => {
|
|
110
|
+
const raw = checks.nodes[index];
|
|
111
|
+
const green = raw.name ? (raw.status === "COMPLETED" && raw.conclusion === "SUCCESS") : raw.state === "SUCCESS";
|
|
112
|
+
return check.state === "passed" && !green ? { ...check, state: "unknown" } : check;
|
|
113
|
+
});
|
|
114
|
+
// Files are outside adoption's decision. Keep their coverage explicitly unknown in the shared evidence shape.
|
|
115
|
+
return { ...evidence, pathsComplete: false, typesComplete: false };
|
|
116
|
+
} catch { return undefined; }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** #1328 T3: adoption observes a completed merge; it never dispatches a merge or invents a reviewer verdict. */
|
|
120
|
+
export function adoptMergeGates(evidence: PrEvidence | undefined, head: string, required: readonly string[]): string[] {
|
|
121
|
+
if (!evidence) return ["PR evidence unavailable; restore GitHub access and retry ahub sdlc adopt-merge"];
|
|
122
|
+
const gates: string[] = [];
|
|
123
|
+
if (evidence.state !== "MERGED") gates.push("PR is not merged; complete the normal review and guarded merge before adopting it");
|
|
124
|
+
if (evidence.head !== head) gates.push("PR head differs from the task's last recorded full head; record the correct task head before retrying ahub sdlc adopt-merge");
|
|
125
|
+
if (evidence.unresolved === null || evidence.unresolved > 0) gates.push("PR review threads are unresolved or unknown; resolve the threads and restore complete GitHub readback before retrying ahub sdlc adopt-merge");
|
|
126
|
+
if (evidence.pendingReviews === null || evidence.pendingReviews > 0) gates.push("PR review requests are pending or unknown; settle the requests and restore complete GitHub readback before retrying ahub sdlc adopt-merge");
|
|
127
|
+
if (evidence.review === "changes_requested") gates.push("PR has a pending change request; settle the review before retrying ahub sdlc adopt-merge");
|
|
128
|
+
gates.push(...checkGates(evidence, required).map(gate => `${gate}; configure required_checks in .agenthub/sdlc.toml and get every required check green at the recorded head before retrying ahub sdlc adopt-merge`));
|
|
129
|
+
return gates;
|
|
130
|
+
}
|
|
131
|
+
|
|
94
132
|
function queueGates(queue: MergeQueue | undefined, pr: number): string[] {
|
|
95
133
|
const row = queue?.rows.find(r => r.pr === pr);
|
|
96
134
|
if (!queue || !row) return ["merge queue unavailable: this PR is not in the open snapshot"];
|