@staix/agent-hub 0.35.0 → 0.36.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 +26 -0
- package/README.md +21 -4
- package/docs/agent-notes/README.md +60 -0
- package/docs/agent-notes/adapters.md +5 -2
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +5 -4
- package/docs/agent-notes/models.md +4 -3
- package/docs/agent-notes/tasks.md +8 -1
- package/docs/agent-notes/tests.md +1 -0
- package/docs/design/adapters.md +72 -0
- package/docs/design/agent-hub-architecture.md +1 -1
- 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/model-routes.md +628 -0
- package/docs/design/supervision.md +121 -0
- package/docs/design/task-board.md +111 -0
- package/docs/dogfood.md +15 -4
- package/docs/operations.md +291 -22
- package/docs/profiles.md +2 -2
- package/docs/quickstart.md +106 -1
- package/docs/research.md +4 -2
- package/docs/sdlc.md +108 -4
- package/docs/security.md +67 -5
- package/docs/specs/2026-09-19-agent-hub-design.md +5 -4
- package/docs/verification/2026-10-25-qwen-dual-output-t0.md +22 -0
- package/docs/verification/2026-11-09-qwen-0270-acp.md +181 -0
- package/docs/verification/2026-11-09-qwen-0270-model-setter-1317.md +46 -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/claude-shell-wrapper-native.py +1 -1
- package/docs/verified.json +27 -27
- package/package.json +1 -1
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +1201 -368
- package/plugins/agent-hub/server.js +1682 -431
- package/src/adapters/claude-channel.ts +7 -4
- package/src/adapters/compat.ts +10 -10
- package/src/adapters/local-worker.ts +1 -1
- package/src/adapters/qwen-dual.ts +324 -44
- package/src/cli/guidance.ts +67 -0
- package/src/cli/help.ts +10 -3
- 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/lineage.ts +78 -0
- package/src/cli/main.ts +111 -10
- 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 +2 -1
- package/src/hub/config-trust.ts +1 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +342 -20
- 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/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-variants.ts +398 -0
- package/src/hub/handoff.ts +1 -0
- package/src/hub/hub-tools.ts +43 -2
- package/src/hub/manager.ts +44 -2
- package/src/hub/memory-policy.ts +2 -2
- package/src/hub/peers.ts +1 -1
- package/src/hub/planning.ts +1 -1
- package/src/hub/progress.ts +24 -7
- package/src/hub/restart.ts +13 -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.ts +1 -1
- 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 +603 -50
- package/src/memory/capture.ts +2 -2
- package/src/models/relay.ts +9 -2
- package/src/models/route/config.ts +27 -0
- package/src/models/route/decision.ts +87 -15
- package/src/models/route/relay-selector.ts +8 -7
- package/src/models/route/runtime.ts +22 -16
- 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/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 +71 -7
package/src/hub/daemon.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { parseGuidanceCreateInput, parseGuidanceIdQuery } from "./guidance-variants.ts";
|
|
2
|
+
import { publicDeliveryBodies } from "./delivery-public.ts";
|
|
1
3
|
import { GeneratedNoteRegistry, type GeneratedNoteProof } from "../memory/record-provenance.ts";
|
|
2
4
|
import { RecordCapture, type RecordCapturePolicy } from "../memory/records.ts";
|
|
3
5
|
import { VisualStore, validateVisualInput, validateVisualPayload, VISUAL_ID_PATTERN, type VisualRecord, type VisualSummary } from "./visual.ts";
|
|
@@ -180,11 +182,13 @@ import { canonicalPath, realPath, hubHome } from "./project.ts";
|
|
|
180
182
|
import { HandoffRefusal, checkTarget, handoffAge, handoffCatchUpRow, handoffChunks, handoffConnectFailure, handoffLogGate, handoffOutcomeUnknown, handoffReach, parseHandoff, resolveTarget, handoffEventFor, type HandoffEvent } from "./handoff.ts";
|
|
181
183
|
import { mainCheckoutBranch, mainCheckoutWarning } from "./main-checkout.ts";
|
|
182
184
|
import type { BusEvent, PublishResult } from "./bus.ts";
|
|
183
|
-
import { CONDUCTOR_TOOLS, CONDUCTOR_TOOL_NAMES, DEFAULT_ROLES, IMPLEMENTER_HUB_TOOL_NAMES, roleContract, TASK_TOOL_NAMES, TASK_TOOLS, BOUNDED_TASK_TOOLS, CAPABILITY_TOOLS, profileTaskTools, sessionTitleTools } from "./hub-tools.ts";
|
|
185
|
+
import { CONDUCTOR_TOOLS, CONDUCTOR_TOOL_NAMES, DEFAULT_ROLES, IMPLEMENTER_HUB_TOOL_NAMES, roleContract, TASK_TOOL_NAMES, TASK_TOOLS, BOUNDED_TASK_TOOLS, LINEAGE_TOOL_NAMES, GUIDANCE_TOOL_NAMES, CAPABILITY_TOOLS, profileTaskTools, sessionTitleTools } from "./hub-tools.ts";
|
|
184
186
|
import { effectiveClass, listedCapabilities, PublishRefusal, readShare, shareView, validatePublished, type CapabilityManifest } from "./capabilities.ts";
|
|
185
187
|
import { invocationApproval, checkArgs, DEFAULT_TIMEOUT_S, InvocationLedger, invocationRefusal, refusedBy, renderInvocationResult, requestText, type InvocationOutcome, type InvocationRow } from "./invocations.ts";
|
|
186
188
|
import { Conductor, ConductorHolds, conductorPeer, requireConductor, conductorProgressSink, publicConductorTask, publicPeerBudget, taskShowAllowed, type ConductEvent } from "./conductor.ts";
|
|
187
189
|
import { SupervisionFeed } from "./supervision.ts";
|
|
190
|
+
import { MAX_REFS, taskRevision, type SupervisionFacts, type SupervisionHistoryFact } from "./supervision-rules.ts";
|
|
191
|
+
import { ProposalStore, SupervisionProposals, type SupervisionProposal } from "./supervision-proposals.ts";
|
|
188
192
|
import { drainCliAudits } from "../cli/identity-audit.ts";
|
|
189
193
|
import { launcherPreview } from "../cli/preview.ts";
|
|
190
194
|
import { AssignmentUndeliveredError, ESCALATE_AFTER, Tasks } from "./tasks.ts";
|
|
@@ -299,6 +303,8 @@ export interface HubConfig {
|
|
|
299
303
|
specs: SpecsConfig;
|
|
300
304
|
catalog_roles?: Record<string, string[]>;
|
|
301
305
|
conductor: { feed: "own" | "all" | "off"; approval_wait_s: number };
|
|
306
|
+
/** #1221 T2: what the supervision queue may do. `off` evaluates nothing, `shadow` stores bounded proposals with no inbox row or notice, `advisory` may also show a pending one in the console inbox. Machine-local and off by default. */
|
|
307
|
+
supervision: { mode: "off" | "shadow" | "advisory" };
|
|
302
308
|
budget: BudgetConfig;
|
|
303
309
|
context: ContextConfig;
|
|
304
310
|
inference: InferenceConfig;
|
|
@@ -379,6 +385,7 @@ export const DEFAULT_CONFIG: HubConfig = {
|
|
|
379
385
|
roster: {},
|
|
380
386
|
roles: DEFAULT_ROLES,
|
|
381
387
|
conductor: { feed: "own", approval_wait_s: 30 },
|
|
388
|
+
supervision: { mode: "off" },
|
|
382
389
|
budget: DEFAULT_BUDGET,
|
|
383
390
|
context: DEFAULT_CONTEXT,
|
|
384
391
|
model_relay: { cooldown_failures: MODEL_COOLDOWN_FAILURES_SETTING.defaultValue, cooldown_s: MODEL_COOLDOWN_SETTING.defaultValue, cooldown_cap_s: MODEL_COOLDOWN_CAP_SETTING.defaultValue, terminal_history_limit: MODEL_TERMINAL_HISTORY_SETTING.defaultValue },
|
|
@@ -417,7 +424,7 @@ export const DEFAULT_CONFIG: HubConfig = {
|
|
|
417
424
|
export { stateDirFor };
|
|
418
425
|
|
|
419
426
|
/** Ids an external process may not claim: the console user and the adapters the daemon runs itself. */
|
|
420
|
-
const READ_ONLY_HUB_TOOLS = new Set(["hub_visual_show", "hub_capabilities", "hub_inbox", "hub_send", "hub_delivery_done", "hub_review", "hub_task_show", "hub_task_list", "hub_study_show", "hub_experiment_show", "hub_memory_search", "hub_memory_show", "hub_memory_graph", "hub_source_read", "hub_status", "hub_specs"]);
|
|
427
|
+
const READ_ONLY_HUB_TOOLS = new Set(["hub_guidance_list", "hub_guidance_show", "hub_lineage_show", "hub_visual_show", "hub_capabilities", "hub_inbox", "hub_send", "hub_delivery_done", "hub_review", "hub_task_show", "hub_task_list", "hub_study_show", "hub_experiment_show", "hub_memory_search", "hub_memory_show", "hub_memory_graph", "hub_source_read", "hub_status", "hub_specs", "hub_supervision_list"]);
|
|
421
428
|
const BASE_RESERVED_IDS = new Set<string>([USER, ...SUPPORTED_PEERS.filter(peer => definitionOf(peer)?.attach?.externalHello !== true), HUB, DIGEST]);
|
|
422
429
|
const PEER_ID = /^[a-z][a-z0-9-]{0,31}$/;
|
|
423
430
|
|
|
@@ -1488,7 +1495,8 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
1488
1495
|
*/
|
|
1489
1496
|
const silence = (env: Envelope, to: PeerId): string | undefined => {
|
|
1490
1497
|
if (reviewOnlyPeer(to) && env.to?.includes(to) && !reviewOnlyItem(to, env)) return `${to} is a review-only instance: it receives review requests only (send a review through the task board)`;
|
|
1491
|
-
|
|
1498
|
+
// Deferred hub notices are released before Tasks exists; keep Tasks-independent exclusions first.
|
|
1499
|
+
if (env.from === USER || env.from === HUB || env.from === DIGEST || env.priority === "fyi" || env.kind !== "chat" || to === USER || !turnFree()) return undefined;
|
|
1492
1500
|
const cohort = tasks.silenced(env.from, to);
|
|
1493
1501
|
if (!cohort) return undefined;
|
|
1494
1502
|
const ids = [...cohort.members.keys()].sort((a, b) => a - b).map((id) => `#${id}`).join(", ");
|
|
@@ -1855,6 +1863,8 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
1855
1863
|
// normalized origin remote, the same on every machine; without one, its path). Fail-open: without it the hub works as before.
|
|
1856
1864
|
// Daemon start never depends on the memory home: an unresolvable home falls back to the raw key.
|
|
1857
1865
|
const memoryProjectRaw = memoryProjectKey(opts.cwd);
|
|
1866
|
+
const executionLineageProjectKey = `ahub-${createHash("sha256").update(memoryProjectRaw).digest("hex")}`;
|
|
1867
|
+
const executionLineageCursorKey = randomBytes(32).toString("hex");
|
|
1858
1868
|
const memoryProject = (() => { try { return memoryProjectFor(opts.cwd); } catch { return memoryProjectRaw; } })();
|
|
1859
1869
|
let memoryStore: MemoryStore | undefined;
|
|
1860
1870
|
let memoryBinding: MemoryProfileBinding | undefined;
|
|
@@ -2264,6 +2274,19 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
2264
2274
|
const inboxPolling = new InboxPolling();
|
|
2265
2275
|
startupTimings.mark("model_runtime");
|
|
2266
2276
|
const board = new Board(join(opts.stateDir, "hub.db"));
|
|
2277
|
+
try {
|
|
2278
|
+
const retainedExecutionReferences = board.executionReferencesIntegrity(), expected = restored?.integrity?.executionReferences;
|
|
2279
|
+
if (restored?.integrity && (expected ? expected.count !== retainedExecutionReferences.count || expected.digest !== retainedExecutionReferences.digest : retainedExecutionReferences.count !== 0)) throw new Error("changed recovery binding");
|
|
2280
|
+
} catch {
|
|
2281
|
+
board.close(); throw new Error("execution reference state or recovery binding is unavailable; restore trusted project state and choose a compatible recovery target before retrying");
|
|
2282
|
+
}
|
|
2283
|
+
try {
|
|
2284
|
+
const retainedGuidance = board.guidanceVariantsIntegrity(), expected = restored?.integrity?.guidanceVariants;
|
|
2285
|
+
if (restored?.integrity && (expected ? expected.experiments !== retainedGuidance.experiments || expected.variants !== retainedGuidance.variants
|
|
2286
|
+
|| expected.digest !== retainedGuidance.digest : retainedGuidance.experiments !== 0 || retainedGuidance.variants !== 0)) throw new Error("changed recovery binding");
|
|
2287
|
+
} catch {
|
|
2288
|
+
board.close(); throw new Error("guidance variant state or recovery binding is unavailable; restore trusted project state and choose a supporting target before retrying");
|
|
2289
|
+
}
|
|
2267
2290
|
const visuals = new VisualStore(join(opts.stateDir, "hub.db"));
|
|
2268
2291
|
startupCleanup.push(() => visuals.close());
|
|
2269
2292
|
// Held recovery must compare the source's exact rows before any retention mutation.
|
|
@@ -2345,6 +2368,10 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
2345
2368
|
}
|
|
2346
2369
|
};
|
|
2347
2370
|
const reviewObserverInput = (peer: PeerId): boolean => {
|
|
2371
|
+
// ponytail: read-only held views mint no input receipt; conservatively exclude
|
|
2372
|
+
// retained readable held review rows until explicit disposition, even if unread.
|
|
2373
|
+
// Upgrade with host-verified read provenance, never a transport ACK.
|
|
2374
|
+
if (bus.hasHeldReviewScope(peer)) return true;
|
|
2348
2375
|
resetReviewObserverSessionIfChanged(peer);
|
|
2349
2376
|
const pending = pendingReviewObserverInputs.get(peer);
|
|
2350
2377
|
return (pending ? pending.held || pending.previous?.held === true : currentReviewObserverInputs.get(peer)?.held === true) || reviewObserverDurableHeld(peer);
|
|
@@ -2942,6 +2969,7 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
2942
2969
|
...(config.memory.enabled ? { memory } : {}),
|
|
2943
2970
|
candidates, candidateScreen: screenMemory, privateTurn: peer => !!turns.get(peer)?.private || contextPii(peer),
|
|
2944
2971
|
memoryCheck: checkMemory,
|
|
2972
|
+
executionLineage: { projectKey: executionLineageProjectKey, cursorKey: executionLineageCursorKey, readDelivery: id => journal.get(id) },
|
|
2945
2973
|
briefs: new Briefs(config.memory.enabled ? memory : undefined, chain.at(-1)!, () => config.memory.brief_items,
|
|
2946
2974
|
memoryStore ? taskMemoryItems : undefined,
|
|
2947
2975
|
(peer, task, counts) => event({ type: "memory_brief", source: "amem", peer, task, ...counts }),
|
|
@@ -3046,6 +3074,115 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
3046
3074
|
failing: () => ({ ...bus.failingPeers(), ...Object.fromEntries(reviewerUnavailable) }),
|
|
3047
3075
|
held: () => Object.fromEntries(bus.knownPeers().flatMap((peer) => { const hold = queueHold(peer); return hold ? [[peer, hold]] : []; })),
|
|
3048
3076
|
});
|
|
3077
|
+
/**
|
|
3078
|
+
* #1221 T2: the bounded proposal queue. The store is built even while the mode is off (its tables are additive and a
|
|
3079
|
+
* person may turn the mode on at the next reload), and nothing in it runs until an explicit decision arrives: reading
|
|
3080
|
+
* the board is the only thing this side does on its own.
|
|
3081
|
+
*/
|
|
3082
|
+
const proposalStore = new ProposalStore(join(opts.stateDir, "hub.db"));
|
|
3083
|
+
startupCleanup.push(() => proposalStore.close());
|
|
3084
|
+
const supervisionProposals = new SupervisionProposals(proposalStore, {
|
|
3085
|
+
facts: (task) => proposalFacts(task),
|
|
3086
|
+
isPrivate: (task) => { const row = board.get(task); return !row || tasks.isPii(row); },
|
|
3087
|
+
// The native generation this reading was made under: the owner's session, or `hub` when no agent owns the task.
|
|
3088
|
+
generation: (task) => {
|
|
3089
|
+
const owner = board.get(task)?.owner;
|
|
3090
|
+
return !owner || owner === USER || owner === HUB ? "hub" : `${owner}@${bus.peers.get(owner)?.sessionGeneration ?? "unknown"}`;
|
|
3091
|
+
},
|
|
3092
|
+
// Present roles only, and no new one: the task's owner and reviewer, the configured planner, the conductor, the person.
|
|
3093
|
+
mayDecide: (actor, task) => {
|
|
3094
|
+
const row = board.get(task);
|
|
3095
|
+
if (!row) return false;
|
|
3096
|
+
if (actor === USER || actor === conductorPeer(config.roles) || plannerPeers().includes(actor)) return true;
|
|
3097
|
+
return row.owner === actor || row.reviewer === actor;
|
|
3098
|
+
},
|
|
3099
|
+
// The action's own authority, which a decision does not carry: `escalate` is the conductor's move and the person's,
|
|
3100
|
+
// while the hub's owner notice for a recheck or an integration request runs for whoever may decide.
|
|
3101
|
+
mayRun: (actor, proposal) =>
|
|
3102
|
+
proposal.action !== "escalate" || actor === USER || actor === conductorPeer(config.roles),
|
|
3103
|
+
// A needs_review delivery holds the owner's advice too; unavailable hold evidence is held, never a pass.
|
|
3104
|
+
held: (task) => {
|
|
3105
|
+
const owner = board.get(task)?.owner;
|
|
3106
|
+
if (!owner || owner === USER || owner === HUB) return false;
|
|
3107
|
+
const hints = bus.heldDeliveryHints(owner);
|
|
3108
|
+
return hints === undefined || hints.count > 0;
|
|
3109
|
+
},
|
|
3110
|
+
run: (proposal, actor) => runSupervisionProposal(proposal, actor),
|
|
3111
|
+
now: () => Date.now(),
|
|
3112
|
+
});
|
|
3113
|
+
/** The bounded fact set one proposal reads: the task, its declared overlap partners, and its own measurement. */
|
|
3114
|
+
async function proposalFacts(task: number): Promise<SupervisionFacts> {
|
|
3115
|
+
const row = board.get(task);
|
|
3116
|
+
if (!row) return { tasks: [] };
|
|
3117
|
+
const partners = tasks.overlapTasks(row).filter((id) => id !== row.id).slice(0, MAX_REFS);
|
|
3118
|
+
const read = [row, ...partners.map((id) => board.get(id)).filter((candidate): candidate is typeof row => !!candidate)];
|
|
3119
|
+
const facts: SupervisionFacts = {
|
|
3120
|
+
tasks: read.map((candidate) => ({ id: candidate.id, state: candidate.state, history: candidate.history as SupervisionHistoryFact[] })),
|
|
3121
|
+
overlaps: partners.map((other) => ({ task: row.id, other })),
|
|
3122
|
+
};
|
|
3123
|
+
const side = facts.tasks[0]!;
|
|
3124
|
+
const window = side.history.slice(taskRevision(side).from);
|
|
3125
|
+
// Hashing is only owed when this revision recorded a check pass over delivered ids; otherwise the rule says so itself.
|
|
3126
|
+
if (!tasks.isPii(row) && window.some((entry) => entry.event === "check passed") && window.some((entry) => (entry.deliverables?.length ?? 0) > 0)) {
|
|
3127
|
+
const status = await tasks.deliverableStatus(row);
|
|
3128
|
+
if (status) {
|
|
3129
|
+
facts.deliverables = [{
|
|
3130
|
+
task: row.id, checked: status.files.every((file) => file.state !== "unknown"),
|
|
3131
|
+
changed: status.files.filter((file) => file.state === "changed").map((file) => file.id),
|
|
3132
|
+
missing: status.files.filter((file) => file.state === "missing").map((file) => file.id),
|
|
3133
|
+
}];
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
return facts;
|
|
3137
|
+
}
|
|
3138
|
+
/**
|
|
3139
|
+
* The existing action a proposal names, through that action's own authority. `escalate` is the conductor's move (the
|
|
3140
|
+
* person may always escalate, exactly as the console does); the other two are the hub's own owner notice, whose own
|
|
3141
|
+
* authority is the delivery path: the check re-run and the integration stay the owner's actions, and their results
|
|
3142
|
+
* land on the board as their own records.
|
|
3143
|
+
*/
|
|
3144
|
+
async function runSupervisionProposal(proposal: SupervisionProposal, actor: string): Promise<{ outcome: "ran" | "refused" | "unknown"; detail?: string }> {
|
|
3145
|
+
if (proposal.action === "escalate") {
|
|
3146
|
+
try {
|
|
3147
|
+
if (actor === USER) await tasks.escalate(USER, proposal.task, "a supervision proposal the person accepted", "manual", true);
|
|
3148
|
+
else await conductor.execute(actor, "hub_task_escalate", { id: proposal.task });
|
|
3149
|
+
} catch (error) {
|
|
3150
|
+
// An action's own pre-effect refusal is a certain outcome: nothing ran. Anything else may have had an effect, and
|
|
3151
|
+
// the queue records it `unknown` instead of pretending either way.
|
|
3152
|
+
if (error instanceof PreEffectToolRefusal) return { outcome: "refused", detail: error.message.slice(0, 200) };
|
|
3153
|
+
throw error;
|
|
3154
|
+
}
|
|
3155
|
+
return { outcome: "ran", detail: "escalate" };
|
|
3156
|
+
}
|
|
3157
|
+
const partner = proposal.refs.find((ref) => ref.startsWith("task:"));
|
|
3158
|
+
const other = proposal.action === "request_integration" && partner ? Number(partner.slice("task:".length)) : undefined;
|
|
3159
|
+
const stale = proposal.refs.filter((ref) => ref.startsWith("deliverable:")).join(", ");
|
|
3160
|
+
const body = proposal.action === "recheck"
|
|
3161
|
+
? `Task #${proposal.task}: supervision recheck. The files delivered before the recorded check pass changed since then${stale ? ` (${stale})` : ""}. Run the check again and re-file hub_task_done with its result.`
|
|
3162
|
+
: `Task #${proposal.task}: supervision integration. #${proposal.task} and #${other ?? "?"} declared overlapping work, both owners accepted, and no integration is recorded since. Land the integration, or record why the overlap does not need one.`;
|
|
3163
|
+
const told = tasks.supervisionNotice(proposal.task, other, body);
|
|
3164
|
+
return told.sent.length ? { outcome: "ran", detail: `notice to ${told.sent.join(", ")}` } : { outcome: "refused", detail: told.refused ?? "no owner to tell" };
|
|
3165
|
+
}
|
|
3166
|
+
/** `off` evaluates nothing; `shadow` stores bounded proposals with no console row or notice; `advisory` may show one. */
|
|
3167
|
+
const supervisionMode = () => config.supervision?.mode ?? "off";
|
|
3168
|
+
/** What a tool result and the inbox show: codes and ids only, never a title, a note or a path. */
|
|
3169
|
+
const proposalView = (proposal: SupervisionProposal) => ({
|
|
3170
|
+
id: proposal.id, task: proposal.task, rule: proposal.rule, version: proposal.version, revision: proposal.revision, trigger: proposal.trigger,
|
|
3171
|
+
refs: proposal.refs, limits: { records: proposal.records, truncated: proposal.truncated }, action: proposal.action, reason: proposal.reason,
|
|
3172
|
+
state: proposal.state, created: proposal.createdAt, ...(proposal.actor ? { actor: proposal.actor } : {}),
|
|
3173
|
+
...(proposal.disposedAt === undefined ? {} : { decided: proposal.disposedAt }), ...(proposal.receipt ? { receipt: proposal.receipt } : {}),
|
|
3174
|
+
});
|
|
3175
|
+
const proposeObserved = (task: number): void => {
|
|
3176
|
+
if (supervisionMode() === "off" || stopping || recoveryActive()) return;
|
|
3177
|
+
const row = board.get(task);
|
|
3178
|
+
// A declared pair's reading is bound to its lower task id, so a change on the higher-id side is only read by
|
|
3179
|
+
// re-reading each partner: without that, a pair proposal would be created or invalidated from one side alone.
|
|
3180
|
+
for (const id of new Set([task, ...(row ? tasks.overlapTasks(row) : [])])) {
|
|
3181
|
+
const candidate = board.get(id);
|
|
3182
|
+
if (!candidate || candidate.state === "backlog" || tasks.isPii(candidate)) continue;
|
|
3183
|
+
void supervisionProposals.observe(id).catch((error: Error) => log(`supervision observe for #${id} failed: ${error.message}`));
|
|
3184
|
+
}
|
|
3185
|
+
};
|
|
3049
3186
|
relevantNotice = (peer, env) => {
|
|
3050
3187
|
if (env.from === HUB && env.refs?.boundedCheck) {
|
|
3051
3188
|
const run = env.refs.boundedCheck, binding = checkBindings.get(run);
|
|
@@ -3073,6 +3210,9 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
3073
3210
|
return true;
|
|
3074
3211
|
};
|
|
3075
3212
|
tasks.recoverIntegrations();
|
|
3213
|
+
// #1221 T2 AC6: a restart keeps the dedupe keys, the dispositions and an action outcome the hub never observed. A
|
|
3214
|
+
// pending proposal whose task moved or closed expires here, once, with nothing replayed.
|
|
3215
|
+
void supervisionProposals.recover().catch((error: Error) => log(`supervision reconcile failed: ${error.message}`));
|
|
3076
3216
|
/** Peers told, at their first attach, what the cohorts lost in the restart held for them (issue #107). */
|
|
3077
3217
|
const replayed = new Set<PeerId>();
|
|
3078
3218
|
// Turn-free facts (issue #108): what the others changed in an owner's files, at its tool calls. Scopes are read from
|
|
@@ -3124,6 +3264,8 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
3124
3264
|
const observeProgress = (peer: PeerId, observation: ToolObservation | undefined, taskId?: string): void => {
|
|
3125
3265
|
if (!observation) return;
|
|
3126
3266
|
if (reviewObserverHeld(peer) || bus.lastDeliveredTo(peer).some(isReviewObserverExcluded)) { progress.clearPeer(peer); return; }
|
|
3267
|
+
const toolName = observation.name.replace(/^mcp__[^ ]+__/, "");
|
|
3268
|
+
if (GUIDANCE_TOOL_NAMES.has(toolName)) return;
|
|
3127
3269
|
if (observation.name === "hub_set_title" || observation.name === "hub_ask") return; // #1053: a question and its answer are never progress evidence (they may reach an escalation model)
|
|
3128
3270
|
try {
|
|
3129
3271
|
const candidates = board.list().filter(task => task.owner === peer && ["in_progress", "changes_requested"].includes(task.state));
|
|
@@ -3299,7 +3441,7 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
3299
3441
|
if ((h.event === "proposed" || h.event === "backlog pulled" || h.event === "catalog role changed") && (t.role ? catalog.roles.has(t.role) : h.event === "catalog role changed")) event({ type: "role", task: t.id, actor: h.by, stage: "assigned", roles: t.role ? [roleIdentity(catalog.roles.get(t.role)!)] : [] });
|
|
3300
3442
|
event({ type: "task", id: t.id, event: h.event, by: h.by, state: t.state, owner: t.owner, reviewer: t.reviewer, class: t.class, ...(t.profile ? { profile: t.profile, profileClass: t.profileClass } : {}), ...(t.role ? { role: t.role, ...(catalog.roles.has(t.role) ? { roleIdentity: roleIdentity(catalog.roles.get(t.role)!) } : {}) } : {}), pii: tasks.isPii(t), ...(t.planningRevision ? { release: t.release ?? null, priority: t.priority ?? null, plannedStart: t.plannedStart ?? null, due: t.due ?? null } : {}), ...(h.reason ? { reason: h.reason } : {}) });
|
|
3301
3443
|
// #1277 AC6: a cancelled task is a terminal task too, and the guarded merge writes its receipt after the approval, so its result completes the record's merge block.
|
|
3302
|
-
if (config.research.enabled && ((t.state === "approved" && (h.event === "approved" || h.event === "done" || h.event === "merge result")) || (t.state === "cancelled" && h.event === "cancelled"))) recordResearch(t.id);
|
|
3444
|
+
if (config.research.enabled && ((t.state === "approved" && (h.event === "approved" || h.event === "done" || h.event === "merged outside the hub" || h.event === "merge result")) || (t.state === "cancelled" && h.event === "cancelled"))) recordResearch(t.id);
|
|
3303
3445
|
if (memoryStore && (t.state === "in_progress" || h.event === "done") && !tasks.isPii(t)) renewLeases(t);
|
|
3304
3446
|
if ((h.event === "proposed" || h.event === "backlog pulled") && projections.enabled && turnLog) {
|
|
3305
3447
|
const created = taskProposalAt(t);
|
|
@@ -3309,6 +3451,8 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
3309
3451
|
}
|
|
3310
3452
|
}
|
|
3311
3453
|
supervision.taskChanged(t, h);
|
|
3454
|
+
// #1221 T2: the rules read only after the board has the record; a mode that is off costs one string comparison.
|
|
3455
|
+
proposeObserved(t.id);
|
|
3312
3456
|
// Models can self-claim after their turn begins; preserve that ownership even if they finish before settlement.
|
|
3313
3457
|
const turn = t.owner ? turns.get(t.owner) : undefined;
|
|
3314
3458
|
if (turn) turnTasks.set(turn.id, [...new Set([...(turnTasks.get(turn.id) ?? []), t.id])]);
|
|
@@ -4888,13 +5032,13 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
4888
5032
|
const id = Number.isSafeInteger(proposed) && proposed! > 0 ? proposed : admittedId;
|
|
4889
5033
|
auditConduct({ kind: "conduct", actor: by, action: op.slice(4), ...(id === undefined ? {} : { task: id }) });
|
|
4890
5034
|
}
|
|
4891
|
-
const hint = args[3] && op !== "hub_source_read" && op !== "hub_set_title" && op !== "hub_evidence_record" && op !== "hub_visual" && op !== "hub_visual_show" ? ownHeldHint(by) : "";
|
|
5035
|
+
const hint = args[3] && !GUIDANCE_TOOL_NAMES.has(op) && op !== "hub_lineage_show" && op !== "hub_lineage_link" && op !== "hub_source_read" && op !== "hub_set_title" && op !== "hub_evidence_record" && op !== "hub_visual" && op !== "hub_visual_show" ? ownHeldHint(by) : "";
|
|
4892
5036
|
return hint ? `${text}\n\n${hint}` : text;
|
|
4893
5037
|
} catch (error) {
|
|
4894
5038
|
if (reviewTool && traceId !== undefined) reviewerToolObservers.get(by)?.(traceId, reviewTool, error instanceof Error ? error.message : "review tool refused");
|
|
4895
5039
|
if (nativeTurn && effectful && !(error instanceof PreEffectToolRefusal) && turns.get(by) === nativeTurn) nativeTurn.taskEffect = true;
|
|
4896
5040
|
// Keep proven pre-effect refusal identity/code for native receipts; only add body-free metadata.
|
|
4897
|
-
const hint = args[3] && op !== "hub_source_read" && op !== "hub_set_title" && op !== "hub_evidence_record" && op !== "hub_visual" && op !== "hub_visual_show" ? ownHeldHint(by) : "";
|
|
5041
|
+
const hint = args[3] && !GUIDANCE_TOOL_NAMES.has(op) && op !== "hub_lineage_show" && op !== "hub_lineage_link" && op !== "hub_source_read" && op !== "hub_set_title" && op !== "hub_evidence_record" && op !== "hub_visual" && op !== "hub_visual_show" ? ownHeldHint(by) : "";
|
|
4898
5042
|
if (hint && error instanceof Error) error.message += `\n\n${hint}`;
|
|
4899
5043
|
throw error;
|
|
4900
5044
|
} finally {
|
|
@@ -5249,10 +5393,38 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
5249
5393
|
} catch { throw new Error(`visual ${id} was stored but its stub delivery failed; inspect the visual before posting again`); }
|
|
5250
5394
|
return `visual ${id}`;
|
|
5251
5395
|
}
|
|
5396
|
+
function executionLineageRead(by: PeerId, input: unknown, piiTurn = false): Record<string, unknown> {
|
|
5397
|
+
const excluded = piiTurn || !!turns.get(by)?.private || contextPii(by) || reviewObserverHeld(by) || reviewObserverInput(by) || bus.lastDeliveredTo(by).some(isReviewObserverExcluded);
|
|
5398
|
+
return { ok: true, lineage: excluded || stopping || recoveryActive() || bus.isRecoveryHeld ? { state: "unavailable" } : tasks.executionLineage(by, input) };
|
|
5399
|
+
}
|
|
5400
|
+
function guidanceRead(by: PeerId, op: "list" | "show", input: unknown, piiTurn = false): Record<string, unknown> {
|
|
5401
|
+
const excluded = piiTurn || !!turns.get(by)?.private || contextPii(by) || reviewObserverHeld(by) || reviewObserverInput(by) || bus.lastDeliveredTo(by).some(isReviewObserverExcluded);
|
|
5402
|
+
return { ok: true, guidance: excluded || stopping || recoveryActive() || bus.isRecoveryHeld ? { state: "unavailable" }
|
|
5403
|
+
: op === "list" ? tasks.guidanceVariantList(by, input) : tasks.guidanceVariantDiff(by, input) };
|
|
5404
|
+
}
|
|
5252
5405
|
async function taskOpBody(by: PeerId, op: string, a: Record<string, any>, inProcess = false, piiTurn = false): Promise<string> {
|
|
5253
5406
|
if (op === "hub_visual" || op === "hub_visual_show") return visualTool(by, op, a, piiTurn);
|
|
5254
5407
|
const reviewTurn = reviewObserverHeld(by) || bus.lastDeliveredTo(by).some(isReviewObserverExcluded);
|
|
5255
5408
|
if (reviewTurn || op === "hub_review" && reviewCaptureExcluded(op, JSON.stringify(a))) progress.clearPeer(by);
|
|
5409
|
+
if (GUIDANCE_TOOL_NAMES.has(op)) {
|
|
5410
|
+
if (op === "hub_guidance_list" || op === "hub_guidance_show") return JSON.stringify(guidanceRead(by, op === "hub_guidance_list" ? "list" : "show", a, piiTurn));
|
|
5411
|
+
const excluded = piiTurn || !!turns.get(by)?.private || contextPii(by) || reviewTurn || reviewObserverInput(by);
|
|
5412
|
+
if (excluded) throw new PreEffectToolRefusal("guidance writes are unavailable in private or review input; retry in a public current-owner context");
|
|
5413
|
+
if (stopping || recoveryActive() || bus.isRecoveryHeld) throw new PreEffectToolRefusal("recovery or shutdown is holding guidance writes; wait for release and inspect the task before retrying");
|
|
5414
|
+
if (op === "hub_guidance_create") {
|
|
5415
|
+
let variant; try { variant = parseGuidanceCreateInput(a); } catch { throw new PreEffectToolRefusal("guidance create accepts only a complete bounded V1 variant; remove unknown wrapper fields before retrying"); }
|
|
5416
|
+
return JSON.stringify({ ok: true, receipt: await tasks.guidanceVariantCreate(by, variant) });
|
|
5417
|
+
}
|
|
5418
|
+
let selector; try { selector = parseGuidanceIdQuery(a, true); } catch { throw new PreEffectToolRefusal("guidance withdrawal needs task epoch, current flow and variant id only; refresh the selected task before retrying"); }
|
|
5419
|
+
return JSON.stringify({ ok: true, receipt: await tasks.guidanceVariantWithdraw(by, selector) });
|
|
5420
|
+
}
|
|
5421
|
+
if (LINEAGE_TOOL_NAMES.has(op)) {
|
|
5422
|
+
const excluded = piiTurn || !!turns.get(by)?.private || contextPii(by) || reviewTurn || reviewObserverInput(by);
|
|
5423
|
+
if (op === "hub_lineage_show") return JSON.stringify(executionLineageRead(by, a, piiTurn));
|
|
5424
|
+
if (excluded) throw new PreEffectToolRefusal("execution reference linking is unavailable in a private or review-observer context; retry only in a public task context");
|
|
5425
|
+
if (stopping || recoveryActive() || bus.isRecoveryHeld) throw new PreEffectToolRefusal("recovery or shutdown is holding execution reference links; wait for release and retry");
|
|
5426
|
+
return JSON.stringify({ ok: true, link: await tasks.linkExecutionReference(by, a) });
|
|
5427
|
+
}
|
|
5256
5428
|
if (op === "hub_ask") {
|
|
5257
5429
|
// #1053: a structured question for the person. Refused before any row for a read-only instance, a PII turn's own words are marked private by the desk's `isPrivate`.
|
|
5258
5430
|
if (by === USER) throw new PreEffectToolRefusal("hub_ask is for the agents of this project; the person answers with the console (ahub status shows open questions)");
|
|
@@ -5265,6 +5437,24 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
5265
5437
|
if (!a || typeof a !== "object" || Array.isArray(a) || Object.keys(a).some(key => key !== "title")) return JSON.stringify({ ok: false, reason: "invalid", error: "hub_set_title accepts only title; provide a public name of 1-80 normalized characters" });
|
|
5266
5438
|
return JSON.stringify(await setSessionTitle(by, a.title, true, piiTurn));
|
|
5267
5439
|
}
|
|
5440
|
+
if (op === "hub_supervision_list" || op === "hub_supervision_accept" || op === "hub_supervision_dismiss") {
|
|
5441
|
+
// #1221 T2: the queue carries public board facts only, so a private turn neither reads nor decides one.
|
|
5442
|
+
if (piiTurn || turns.get(by)?.private || contextPii(by)) throw new PreEffectToolRefusal("supervision proposals are unavailable during a private or PII turn");
|
|
5443
|
+
if (op === "hub_supervision_list") {
|
|
5444
|
+
if (a && (typeof a !== "object" || Array.isArray(a) || Object.keys(a).some(key => key !== "task") || a.task !== undefined && (!Number.isSafeInteger(a.task) || a.task < 1)))
|
|
5445
|
+
throw new PreEffectToolRefusal("hub_supervision_list takes only an optional task id");
|
|
5446
|
+
const rows = await supervisionProposals.read(by, a?.task);
|
|
5447
|
+
// `refused` is the queue's own count of readings a bound refused instead of storing: a full queue is visible here.
|
|
5448
|
+
return JSON.stringify({ mode: supervisionMode(), proposals: rows.map(proposalView), refused: supervisionProposals.refusedReadings(),
|
|
5449
|
+
...(rows.length ? {} : { note: supervisionMode() === "off" ? "supervision is off; a person turns it on with `ahub settings set supervision.mode advisory`" : "no supervision proposal is pending on your tasks" }) });
|
|
5450
|
+
}
|
|
5451
|
+
if (!a || typeof a !== "object" || Array.isArray(a) || Object.keys(a).some(key => key !== "id") || typeof a.id !== "string")
|
|
5452
|
+
throw new PreEffectToolRefusal(`${op} takes only a proposal id`);
|
|
5453
|
+
if (stopping || recoveryActive()) throw new PreEffectToolRefusal("recovery or shutdown is holding supervision decisions");
|
|
5454
|
+
const decision = await supervisionProposals.decide(by, a.id, op === "hub_supervision_accept" ? "accept" : "dismiss");
|
|
5455
|
+
if (!decision.ok) throw new PreEffectToolRefusal(decision.error);
|
|
5456
|
+
return JSON.stringify({ ok: true, proposal: proposalView(decision.proposal), ...(decision.receipt ? { receipt: decision.receipt } : {}) });
|
|
5457
|
+
}
|
|
5268
5458
|
if (inProcess && (op === "hub_task_propose" || op === "hub_review") && a && typeof a === "object" && Object.hasOwn(a, "request_id")) throw new PreEffectToolRefusal("request_id replay keys require the control-protocol task transport");
|
|
5269
5459
|
if (BOUNDED_TASK_TOOLS.has(op)) {
|
|
5270
5460
|
const keys = op === "hub_task_spec" ? ["id"] : op === "hub_check_start" ? ["id", "check", "files"] : ["run"];
|
|
@@ -5608,7 +5798,6 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
5608
5798
|
return [result, specReport, extra].filter(Boolean).join("\n");
|
|
5609
5799
|
}
|
|
5610
5800
|
case "hub_sdlc_record":
|
|
5611
|
-
await tasks.specStageGate(by, a.id, a.receipt); // #481 S1: a live spec edit-time check before a build stage
|
|
5612
5801
|
return line(await tasks.recordSdlc(by, a.id, a.receipt));
|
|
5613
5802
|
case "hub_review": {
|
|
5614
5803
|
const reviewed = await tasks.review(by, a.id, a.verdict, a.note, a.unmet, a.head, a.coverage, a.findings);
|
|
@@ -6681,12 +6870,14 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
6681
6870
|
const researchComparisons = board.researchComparisonIntegrity();
|
|
6682
6871
|
const researchRunners = board.runnerReceiptIntegrity();
|
|
6683
6872
|
const researchEvidence = board.researchEvidenceIntegrity();
|
|
6873
|
+
const guidanceVariants = board.guidanceVariantsIntegrity();
|
|
6874
|
+
const executionReferences = board.executionReferencesIntegrity();
|
|
6684
6875
|
const reviewComments = board.reviewCommentsIntegrity();
|
|
6685
6876
|
const modelState = modelOverrides.integrity();
|
|
6686
6877
|
const visualIntegrity = visuals.integrity();
|
|
6687
6878
|
if (!Number.isSafeInteger(visualIntegrity.count) || visualIntegrity.count < 0 || !/^[a-f0-9]{64}$/.test(visualIntegrity.digest))
|
|
6688
6879
|
throw new Error("visual recovery integrity unavailable; inspect the retained store before recovery");
|
|
6689
|
-
return { queues, manualPaused: [...manualPaused].sort(), boardDigest: digest(boardState), budgetDigest: digest(budgetState), ...(modelState.count ? { modelOverrides: modelState } : {}), ...(research.campaigns || research.units ? { research } : {}), ...(researchDispatch.activations || researchDispatch.handoffs ? { researchDispatch } : {}), ...(researchExperiments.protocols || researchExperiments.attempts || researchExperiments.events || researchExperiments.observations ? { researchExperiments } : {}), ...(researchComparisons.plans || researchComparisons.approvals || researchComparisons.contexts ? { researchComparisons } : {}), ...(researchRunners.count ? { researchRunners } : {}), ...(researchEvidence.links || researchEvidence.revisions ? { researchEvidence } : {}), ...(reviewComments.comments || reviewComments.packages ? { reviewComments } : {}), ...(visualIntegrity.count ? { visuals: visualIntegrity } : {}), ...(allExternalInstanceIds().length ? { externalBindingsDigest: digest(allExternalInstanceIds().sort().map(id => [id, (externalRefusedRows.has(id) ? externalBindings.get(id) : retainedExternalBinding(id)) ?? null])) } : {}) };
|
|
6880
|
+
return { queues, manualPaused: [...manualPaused].sort(), boardDigest: digest(boardState), budgetDigest: digest(budgetState), ...(modelState.count ? { modelOverrides: modelState } : {}), ...(research.campaigns || research.units ? { research } : {}), ...(researchDispatch.activations || researchDispatch.handoffs ? { researchDispatch } : {}), ...(researchExperiments.protocols || researchExperiments.attempts || researchExperiments.events || researchExperiments.observations ? { researchExperiments } : {}), ...(researchComparisons.plans || researchComparisons.approvals || researchComparisons.contexts ? { researchComparisons } : {}), ...(researchRunners.count ? { researchRunners } : {}), ...(researchEvidence.links || researchEvidence.revisions ? { researchEvidence } : {}), ...(guidanceVariants.experiments || guidanceVariants.variants ? { guidanceVariants } : {}), ...(executionReferences.count ? { executionReferences } : {}), ...(reviewComments.comments || reviewComments.packages ? { reviewComments } : {}), ...(visualIntegrity.count ? { visuals: visualIntegrity } : {}), ...(allExternalInstanceIds().length ? { externalBindingsDigest: digest(allExternalInstanceIds().sort().map(id => [id, (externalRefusedRows.has(id) ? externalBindings.get(id) : retainedExternalBinding(id)) ?? null])) } : {}) };
|
|
6690
6881
|
};
|
|
6691
6882
|
/** The integrity in the shape `expected` was recorded in: the current one unless only an older shape matches. */
|
|
6692
6883
|
const integrityAs = (expected: unknown) => {
|
|
@@ -8809,7 +9000,7 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
8809
9000
|
function queueView(row: ReturnType<Bus["queueShow"]>, detail = false, publicOnly = false) {
|
|
8810
9001
|
if (!row) return undefined;
|
|
8811
9002
|
const originals = row.originals;
|
|
8812
|
-
|
|
9003
|
+
|
|
8813
9004
|
return {
|
|
8814
9005
|
id: row.id, peer: row.peer, state: row.state, revision: row.revision,
|
|
8815
9006
|
...(row.failureCause ? { failureCause: row.failureCause } : {}),
|
|
@@ -8819,12 +9010,40 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
8819
9010
|
createdAt: row.createdAt, updatedAt: row.updatedAt,
|
|
8820
9011
|
envelopeIds: originals.map((env) => env.id),
|
|
8821
9012
|
important: originals.some((env) => env.priority === "important"),
|
|
8822
|
-
...(detail ? { messages: originals
|
|
8823
|
-
body: privateDelivery ? "[private: inspect the associated task with ahub task show]" : publicOnly && !tasks.publicMetadataText(env.body) ? "[withheld]" : sanitize(env.body),
|
|
8824
|
-
})) } : {}),
|
|
9013
|
+
...(detail ? { messages: publicDeliveryBodies(originals, { publicOnly, taskPrivate: id => { const task = board.get(Number(id)); return !task || tasks.isPii(task); }, publicMetadataText: text => tasks.publicMetadataText(text) }) } : {}),
|
|
8825
9014
|
};
|
|
8826
9015
|
}
|
|
8827
9016
|
|
|
9017
|
+
/** Separate from pull: failure here must never discard an already committed normal handout. */
|
|
9018
|
+
function inboxHeldRead(c: Client, current: () => boolean) {
|
|
9019
|
+
try {
|
|
9020
|
+
const peer = c.peer;
|
|
9021
|
+
if (!peer || !current() || contextPii(peer)) throw new Error("held inbox authority unavailable");
|
|
9022
|
+
const policy = config, configVersion = configRevision, boardVersion = board.statusRevision();
|
|
9023
|
+
const held = bus.heldInbox(peer);
|
|
9024
|
+
const launch = c.toolsOwner ? currentImplementerTools(c) : undefined;
|
|
9025
|
+
const rows = held.rows.map(row => {
|
|
9026
|
+
if (!current() || reviewOnlyPeer(peer) && row.originals.some(env => !reviewOnlyItem(peer, env))) throw new Error("held inbox scope unavailable");
|
|
9027
|
+
if (c.toolsOwner && (!launch || row.originals.some(env => (env.refs?.task === undefined ? implementerChatTask(peer) : Number(env.refs.task)) !== launch.task))) throw new Error("held inbox belongs to another task session");
|
|
9028
|
+
return { id: row.id, revision: row.revision, state: row.state, messages: publicDeliveryBodies(row.originals, {
|
|
9029
|
+
publicOnly: true, taskPrivate: id => { const task = board.get(Number(id)); return !task || tasks.isPii(task); },
|
|
9030
|
+
publicMetadataText: text => tasks.publicMetadataText(text),
|
|
9031
|
+
}) };
|
|
9032
|
+
});
|
|
9033
|
+
// Screening may consult host ports. Revalidate the exact caller and current privacy before exposure.
|
|
9034
|
+
if (!current() || contextPii(peer) || config !== policy || configRevision !== configVersion || board.statusRevision() !== boardVersion) throw new Error("held inbox changed during projection");
|
|
9035
|
+
for (const row of held.rows) {
|
|
9036
|
+
if (reviewInputHeld(peer, row.originals)) {
|
|
9037
|
+
const owner = bus.peers.get(peer), active = ownedObserverInputs.get(peer);
|
|
9038
|
+
if (active && active.owner === owner) active.supersededByReviewInput = true;
|
|
9039
|
+
noteSteeredReviewInput(peer, row.originals); // RAM observation only: no ACK or durable handoff.
|
|
9040
|
+
}
|
|
9041
|
+
}
|
|
9042
|
+
if (!current() || contextPii(peer)) throw new Error("held inbox authority changed");
|
|
9043
|
+
return { count: held.count, rows, truncated: held.truncated, ...(held.unavailable ? { unavailable: true } : {}) };
|
|
9044
|
+
} catch { return { unavailable: true, next: "Held bodies were not read; inspect ahub queue list for this peer, then retry hub_inbox after authority or storage recovers." }; }
|
|
9045
|
+
}
|
|
9046
|
+
|
|
8828
9047
|
let operationalViewCache: { board: number; config: number; routing: ReturnType<typeof activeRouting>; privacy: string; view: ReturnType<typeof operationalView> } | undefined;
|
|
8829
9048
|
function publicOperationalView() {
|
|
8830
9049
|
const revision=board.statusRevision(),routing=activeRouting(),privacy=JSON.stringify([config.pii?.paths??[],config.local.deny]);
|
|
@@ -8853,6 +9072,14 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
8853
9072
|
if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).slice(0, 128).filter(([key]) => /^[A-Za-z][A-Za-z0-9_]*$/.test(key)).map(([key, item]) => [key, publicReadValue(item, depth + 1)]));
|
|
8854
9073
|
return null;
|
|
8855
9074
|
}
|
|
9075
|
+
function sdlcSettingsView() {
|
|
9076
|
+
let file: ReturnType<typeof loadSdlc> | undefined;
|
|
9077
|
+
try { file = loadSdlc(opts.cwd, VERSION); } catch { /* unreadable file stays unknown */ }
|
|
9078
|
+
return {
|
|
9079
|
+
"sdlc.mode": { value: lifecycleConfig.mode, fileValue: file?.mode ?? null, ...(!file ? { problem: "file unavailable" } : {}) },
|
|
9080
|
+
"sdlc.required_checks": { value: lifecycleConfig.requiredChecks, fileValue: file?.requiredChecks ?? null, ...(!file ? { problem: "file unavailable" } : {}) },
|
|
9081
|
+
};
|
|
9082
|
+
}
|
|
8856
9083
|
function publicSettingsView() {
|
|
8857
9084
|
const view = settingsView();
|
|
8858
9085
|
const rows = view.rows.flatMap(row => {
|
|
@@ -8877,7 +9104,7 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
8877
9104
|
...(row.min !== undefined ? { min: row.min } : {}), ...(row.max !== undefined ? { max: row.max } : {}),
|
|
8878
9105
|
...(row.locked ? { locked: "read-only" } : {}), ...(opaque ? { withheld: true } : {}) }];
|
|
8879
9106
|
});
|
|
8880
|
-
return { rows, roster: rosterView().map(row => ({ peer: row.peer, on: row.on, startMode: row.startMode, state: row.state, queued: row.queued, tasks: row.tasks })), public: true, withheld: ["file", "source", "notes", "undo", "configEdit"] };
|
|
9107
|
+
return { rows, sdlc: Object.fromEntries(Object.entries(sdlcSettingsView()).map(([key, value]) => [key, publicReadValue(value)])), roster: rosterView().map(row => ({ peer: row.peer, on: row.on, startMode: row.startMode, state: row.state, queued: row.queued, tasks: row.tasks })), public: true, withheld: ["file", "source", "notes", "undo", "configEdit"] };
|
|
8881
9108
|
}
|
|
8882
9109
|
function publicReleaseShow(input: Record<string, any>) {
|
|
8883
9110
|
const release = input.id !== undefined ? Number.isSafeInteger(input.id) && input.id > 0 ? board.release(input.id) : undefined
|
|
@@ -9173,6 +9400,10 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
9173
9400
|
...(attentionStatus.taskWip[id] ? { wip: attentionStatus.taskWip[id]!.wip, wipLimit: attentionStatus.taskWip[id]!.wipLimit, wipBreakdown: { active: attentionStatus.taskWip[id]!.active, reviewWait: attentionStatus.taskWip[id]!.reviewWait, reserved: attentionStatus.taskWip[id]!.reserved } } : { wip: tasks.wip(id), wipLimit: tasks.wipLimit(id) }),
|
|
9174
9401
|
activeTasks: boardTasks.filter(task => task.owner === id && ["in_progress", "changes_requested"].includes(task.state)).map(task => task.id),
|
|
9175
9402
|
})),
|
|
9403
|
+
// #1221 T2 AC5: the advisory row set for the console's existing inbox. Codes and ids only, never a title or a note;
|
|
9404
|
+
// a private task's proposal is not in the list at all, and `off` or `shadow` adds no field, so an older page and a
|
|
9405
|
+
// console that never opted in see exactly what they saw before.
|
|
9406
|
+
...(supervisionMode() === "advisory" ? { supervision: { mode: "advisory" as const, proposals: supervisionProposals.awaiting(USER).map(proposalView) } } : {}),
|
|
9176
9407
|
tasks: boardTasks.map((task) => {
|
|
9177
9408
|
const view = tasks.publicView(task);
|
|
9178
9409
|
// Refs and history can themselves quote private text. The dashboard needs neither.
|
|
@@ -9982,6 +10213,16 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
9982
10213
|
if (!option || (definitionOf(req.peer)?.trust.hubSandboxed === true && option.kind !== "reject_once")) return bad;
|
|
9983
10214
|
return pending.done(option.optionId, "dashboard") ? { ok: true } : { ok: false, error: "permission expired or already answered" };
|
|
9984
10215
|
}
|
|
10216
|
+
case "supervision": {
|
|
10217
|
+
// #1221 T2 AC5: an advisory inbox row decides one proposal as the person, through the same fence the hub tool
|
|
10218
|
+
// uses (`decide`); the console supplies the verb and the id, never an actor, a task or an action.
|
|
10219
|
+
if (typeof a.id !== "string" || (a.verb !== "accept" && a.verb !== "dismiss")) return bad;
|
|
10220
|
+
if (stopping || recoveryActive()) return { ok: false, error: "recovery or shutdown is holding supervision decisions" };
|
|
10221
|
+
const decision = await supervisionProposals.decide(USER, a.id, a.verb);
|
|
10222
|
+
return decision.ok
|
|
10223
|
+
? { ok: true, proposal: proposalView(decision.proposal), ...(decision.receipt ? { receipt: decision.receipt } : {}) }
|
|
10224
|
+
: { ok: false, error: decision.error };
|
|
10225
|
+
}
|
|
9985
10226
|
case "send": {
|
|
9986
10227
|
if (!text("body", 8000)) return bad;
|
|
9987
10228
|
if (a.to !== undefined && (!Array.isArray(a.to) || a.to.length > 32 || a.to.some((id) => typeof id !== "string" || !PEER_ID.test(id) || !bus.knownPeers().includes(id) && membershipAllowed(id)))) return bad;
|
|
@@ -10127,6 +10368,14 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
10127
10368
|
? `target lacks task_cancel; cancelled tasks: ${ids.map(id => `#${id}`).join(", ")}` : undefined;
|
|
10128
10369
|
};
|
|
10129
10370
|
const incompatibleRecoveryTarget = () => {
|
|
10371
|
+
if (!Array.isArray(msg.targetFeatures) || !msg.targetFeatures.includes("guidance_variants")) {
|
|
10372
|
+
try { if (board.hasGuidanceVariants()) return "target lacks guidance_variants; retained immutable variants require a supporting daemon; choose a target advertising guidance_variants"; }
|
|
10373
|
+
catch { return "guidance variant compatibility is unknown; inspect retained storage or choose a supporting target"; }
|
|
10374
|
+
}
|
|
10375
|
+
if (!Array.isArray(msg.targetFeatures) || !msg.targetFeatures.includes("execution_lineage")) {
|
|
10376
|
+
try { if (board.hasExecutionReferences()) return "target lacks execution_lineage; retained declared references require a supporting daemon; choose a target advertising execution_lineage"; }
|
|
10377
|
+
catch { return "execution reference compatibility is unknown; inspect the retained store or choose a supporting target"; }
|
|
10378
|
+
}
|
|
10130
10379
|
if ((!Array.isArray(msg.targetFeatures) || !msg.targetFeatures.includes("model_overrides")) && modelOverrides.hasRecords()) return "target lacks model_overrides; retained runtime model choices require a supporting daemon; clear them with ahub model clear or choose a supporting target";
|
|
10131
10380
|
if (!Array.isArray(msg.targetFeatures) || !msg.targetFeatures.includes("visuals")) {
|
|
10132
10381
|
try {
|
|
@@ -10946,19 +11195,21 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
10946
11195
|
return void reply({ ok: true });
|
|
10947
11196
|
}
|
|
10948
11197
|
case "inbox": {
|
|
11198
|
+
if (msg.peer !== undefined && msg.peer !== c.peer) return void reply({ ok: false, error: "hub_inbox reads only your authenticated peer; omit peer and ask the person to inspect another peer's queue" });
|
|
10949
11199
|
if (stopping || recoveryActive()) return void reply({ ok: false, error: "the hub is not serving inbox reads now (recovery or shutdown); run ahub status, then call hub_inbox again after it recovers" });
|
|
10950
11200
|
if (c.toolsOwner) {
|
|
10951
11201
|
const peer = c.peer!, current = captureImplementerTools(c), launch = currentImplementerTools(c);
|
|
11202
|
+
const heldRead = () => inboxHeldRead(c, current);
|
|
10952
11203
|
try {
|
|
10953
11204
|
// Inspect the still-pending batch before pull commits/removes it: private work never reaches this native child.
|
|
10954
11205
|
const pending = bus.pendingEnvelopes(peer);
|
|
10955
11206
|
if (!current() || pending.some(env => { const task = env.refs?.task === undefined ? undefined : board.get(Number(env.refs.task)); return env.private || contextPii(peer) || !!task && tasks.isPii(task); })) return void reply({ ok: false, error: "private inbox delivery refused" });
|
|
10956
11207
|
if (!launch || pending.some(env => (env.refs?.task === undefined ? implementerChatTask(peer) : Number(env.refs.task)) !== launch.task)) return void reply({ ok: false, error: "inbox delivery belongs to another task session" });
|
|
10957
11208
|
const envs = bus.pull(peer, { allowNeedsReviewHold: true });
|
|
10958
|
-
if (!envs) return void reply({ ok: false, error: queueHold(peer) ?? "delivery held", held: inboxHeldMetadata(peer, true), waiting: bus.queued(peer), waitingImportant: bus.queuedImportant(peer) });
|
|
10959
|
-
return void reply({ ok: true, envs, held: inboxHeldMetadata(peer, true), waiting: bus.queued(peer), waitingImportant: bus.queuedImportant(peer) });
|
|
11209
|
+
if (!envs) return void reply({ ok: false, error: queueHold(peer) ?? "delivery held", held: inboxHeldMetadata(peer, true), heldRead: heldRead(), waiting: bus.queued(peer), waitingImportant: bus.queuedImportant(peer) });
|
|
11210
|
+
return void reply({ ok: true, envs, held: inboxHeldMetadata(peer, true), heldRead: heldRead(), waiting: bus.queued(peer), waitingImportant: bus.queuedImportant(peer) });
|
|
10960
11211
|
} catch (error) {
|
|
10961
|
-
if (error instanceof ReviewInputHandoffError) return void reply({ ok: false, error: error.message, held: inboxHeldMetadata(peer, true), waiting: bus.queued(peer), waitingImportant: bus.queuedImportant(peer) });
|
|
11212
|
+
if (error instanceof ReviewInputHandoffError) return void reply({ ok: false, error: error.message, held: inboxHeldMetadata(peer, true), heldRead: heldRead(), waiting: bus.queued(peer), waitingImportant: bus.queuedImportant(peer) });
|
|
10962
11213
|
return void reply({ ok: false, error: "delivery journal unavailable" });
|
|
10963
11214
|
}
|
|
10964
11215
|
}
|
|
@@ -10966,6 +11217,8 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
10966
11217
|
// Pull and push share holds and journal settlement; work read here is completed, never pushed again.
|
|
10967
11218
|
const peer = c.peer ? bus.peers.get(c.peer) : undefined;
|
|
10968
11219
|
if (c.role !== "peer" || !isWsPeer(peer) || !peer.owns(sock)) return void reply({ ok: false, error: "not attached to the hub yet; retry hub_inbox in a moment" });
|
|
11220
|
+
const current = () => sock.data === c && sock.readyState === WebSocket.OPEN && c.role === "peer" && c.peer === peer.id && membershipAllowed(peer.id) && bus.peers.get(peer.id) === peer && peer.owns(sock) && !stopping && !recoveryActive();
|
|
11221
|
+
const heldRead = () => inboxHeldRead(c, current);
|
|
10969
11222
|
try {
|
|
10970
11223
|
const envs = bus.pull(peer.id, { allowNeedsReviewHold: true });
|
|
10971
11224
|
if (!envs) {
|
|
@@ -10977,7 +11230,7 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
10977
11230
|
?? (bus.isRecoveryHeld ? "recovery is holding deliveries" : undefined)
|
|
10978
11231
|
?? (bus.stateOf(peer.id) === "paused" ? pauseReason(peer.id) : undefined);
|
|
10979
11232
|
const error = blockingCause ?? (accepted ? "an accepted delivery is awaiting your explicit confirmation" : "delivery held");
|
|
10980
|
-
return void reply({ ok: false, error, held, waiting: bus.queued(peer.id), waitingImportant: bus.queuedImportant(peer.id) });
|
|
11233
|
+
return void reply({ ok: false, error, held, heldRead: heldRead(), waiting: bus.queued(peer.id), waitingImportant: bus.queuedImportant(peer.id) });
|
|
10981
11234
|
}
|
|
10982
11235
|
peer.lastInboxAt = Date.now();
|
|
10983
11236
|
let polling: ReturnType<InboxPolling["read"]>;
|
|
@@ -10988,9 +11241,9 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
10988
11241
|
} catch { polling = undefined; } // The pull already completed: advice must never discard its envelopes.
|
|
10989
11242
|
writeStatus();
|
|
10990
11243
|
if (envs.length) log(`${peer.id} read ${envs.length} queued message(s) through hub_inbox`);
|
|
10991
|
-
return void reply({ ok: true, envs, held: inboxHeldMetadata(peer.id, true), waiting: bus.queued(peer.id), waitingImportant: bus.queuedImportant(peer.id), ...(polling ? { pollingAdvice: { count: polling.count, minutes: polling.minutes } } : {}) });
|
|
11244
|
+
return void reply({ ok: true, envs, held: inboxHeldMetadata(peer.id, true), heldRead: heldRead(), waiting: bus.queued(peer.id), waitingImportant: bus.queuedImportant(peer.id), ...(polling ? { pollingAdvice: { count: polling.count, minutes: polling.minutes } } : {}) });
|
|
10992
11245
|
} catch (error) {
|
|
10993
|
-
if (error instanceof ReviewInputHandoffError) return void reply({ ok: false, error: error.message, held: inboxHeldMetadata(peer.id, true), waiting: bus.queued(peer.id), waitingImportant: bus.queuedImportant(peer.id) });
|
|
11246
|
+
if (error instanceof ReviewInputHandoffError) return void reply({ ok: false, error: error.message, held: inboxHeldMetadata(peer.id, true), heldRead: heldRead(), waiting: bus.queued(peer.id), waitingImportant: bus.queuedImportant(peer.id) });
|
|
10994
11247
|
return void reply({ ok: false, error: "delivery journal unavailable" });
|
|
10995
11248
|
}
|
|
10996
11249
|
}
|
|
@@ -11614,6 +11867,35 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
11614
11867
|
}
|
|
11615
11868
|
return;
|
|
11616
11869
|
}
|
|
11870
|
+
if (msg.op === "adopt-merge") {
|
|
11871
|
+
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer ? c.peer : undefined;
|
|
11872
|
+
if (!asker) return void reply({ ok: false, error: "only the person or the current configured conductor may adopt a merge; ask the person to run ahub sdlc adopt-merge" });
|
|
11873
|
+
let actorCurrent: () => void;
|
|
11874
|
+
const externalOwner = c.externalOwner;
|
|
11875
|
+
try {
|
|
11876
|
+
const sessionCurrent = c.role === "console" ? () => {
|
|
11877
|
+
if (sock.data !== c || sock.readyState !== WebSocket.OPEN || c.role !== "console") throw new Error("person session changed");
|
|
11878
|
+
} : operationalCurrent(sock);
|
|
11879
|
+
actorCurrent = () => {
|
|
11880
|
+
sessionCurrent();
|
|
11881
|
+
if (externalOwner && !currentExternalTools(c, true)) throw new Error("actor execution root changed");
|
|
11882
|
+
sessionCurrent(); // A fresh execution-root probe can service callbacks before it returns.
|
|
11883
|
+
if (c.peer !== (asker === USER ? undefined : asker) || c.externalOwner !== externalOwner) throw new Error("actor session changed");
|
|
11884
|
+
};
|
|
11885
|
+
actorCurrent();
|
|
11886
|
+
}
|
|
11887
|
+
catch { return void reply({ ok: false, error: "current person or configured conductor session unavailable; reconnect the conductor or ask the person to run ahub sdlc adopt-merge" }); }
|
|
11888
|
+
const fence = () => {
|
|
11889
|
+
try { actorCurrent(); } catch { return "person or conductor session changed; reconnect and retry ahub sdlc adopt-merge"; }
|
|
11890
|
+
return recoveryActive() || stopping || c.peer && turns.get(c.peer)?.private ? "recovery, shutdown or a private turn holds adoption; retry ahub sdlc adopt-merge after it ends" : undefined;
|
|
11891
|
+
};
|
|
11892
|
+
taskOpsInFlight++;
|
|
11893
|
+
void tasks.adoptMerge(asker, msg.id, msg.pr, fence).then(
|
|
11894
|
+
result => reply({ ok: true, ...result }),
|
|
11895
|
+
(error: Error) => reply({ ok: false, error: sanitize(error.message) }),
|
|
11896
|
+
).finally(() => { taskOpsInFlight--; });
|
|
11897
|
+
return;
|
|
11898
|
+
}
|
|
11617
11899
|
if (msg.op === "merge") {
|
|
11618
11900
|
// #786 T1: the person or the one configured conductor asks for a guarded merge. Every request gets a reply, a refusal included.
|
|
11619
11901
|
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer && conductorPeer(config.roles) === c.peer && !c.toolsOwner && !turns.get(c.peer)?.private && !contextPii(c.peer) ? c.peer : undefined;
|
|
@@ -11890,6 +12172,46 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
11890
12172
|
if (c.role !== "console") return void reply({ ok: false, error: "autonomy is a person-only command; run ahub autonomy in a person's terminal" });
|
|
11891
12173
|
void autonomyCommand(msg.action, msg.environment, msg.confirmed, msg.confirmation).then(reply, () => reply({ ok: false, error: "project autonomy could not be changed" }));
|
|
11892
12174
|
return;
|
|
12175
|
+
case "guidance_list":
|
|
12176
|
+
case "guidance_show":
|
|
12177
|
+
case "guidance_create":
|
|
12178
|
+
case "guidance_withdraw": {
|
|
12179
|
+
const role = c.role, actor = role === "console" ? USER : role === "tools" && typeof c.peer === "string" && PEER_ID.test(c.peer) ? c.peer : undefined;
|
|
12180
|
+
if (!actor) return void reply({ ok: false, error: "guidance is unavailable for this caller; use an authorized current project session" });
|
|
12181
|
+
const { t: _t, rid: _rid, ...input } = msg;
|
|
12182
|
+
const ownedCurrent = c.toolsOwner ? captureImplementerTools(c) : undefined;
|
|
12183
|
+
const current = () => {
|
|
12184
|
+
if (sock.data !== c || c.closed || sock.readyState !== WebSocket.OPEN || c.role !== role || role === "tools" && c.peer !== actor || stopping)
|
|
12185
|
+
throw new PreEffectToolRefusal("guidance caller changed; reconnect in the current project session");
|
|
12186
|
+
if (c.externalOwner && !currentExternalTools(c, true) || ownedCurrent && !ownedCurrent()) throw new PreEffectToolRefusal("guidance runtime owner changed; reconnect before retrying");
|
|
12187
|
+
};
|
|
12188
|
+
try { current(); } catch (error) { return void reply({ ok: false, error: (error as Error).message }); }
|
|
12189
|
+
if (msg.t === "guidance_list" || msg.t === "guidance_show") return void reply(guidanceRead(actor, msg.t === "guidance_list" ? "list" : "show", input));
|
|
12190
|
+
const op = msg.t === "guidance_create" ? "hub_guidance_create" : "hub_guidance_withdraw";
|
|
12191
|
+
void childToolAuthority.run({ by: actor, current: () => { try { current(); return true; } catch { return false; } } }, () => taskOp(actor, op, input)).then(
|
|
12192
|
+
text => { try { current(); reply(JSON.parse(text)); } catch { reply({ ok: false, error: "guidance write is unconfirmed; inspect the task guidance before explicitly retrying" }); } },
|
|
12193
|
+
error => reply({ ok: false, error: error instanceof Error ? error.message : "guidance write is unconfirmed; inspect the task guidance before explicitly retrying" }));
|
|
12194
|
+
return;
|
|
12195
|
+
}
|
|
12196
|
+
case "lineage_show":
|
|
12197
|
+
case "lineage_link": {
|
|
12198
|
+
const role = c.role, actor = role === "console" ? USER : role === "tools" && typeof c.peer === "string" && PEER_ID.test(c.peer) ? c.peer : undefined;
|
|
12199
|
+
if (!actor) return void reply({ ok: false, error: "execution lineage is unavailable for this caller; use an authorized project session" });
|
|
12200
|
+
const { t: _t, rid: _rid, ...input } = msg;
|
|
12201
|
+
const ownedCurrent = c.toolsOwner ? captureImplementerTools(c) : undefined;
|
|
12202
|
+
const current = () => {
|
|
12203
|
+
if (sock.data !== c || c.closed || sock.readyState !== WebSocket.OPEN || c.role !== role || (role === "tools" && c.peer !== actor) || stopping) throw new PreEffectToolRefusal("execution lineage caller changed; reconnect and retry");
|
|
12204
|
+
if (c.externalOwner && !currentExternalTools(c, true) || ownedCurrent && !ownedCurrent()) throw new PreEffectToolRefusal("execution lineage owner changed; reconnect in the current project session");
|
|
12205
|
+
};
|
|
12206
|
+
const op = msg.t === "lineage_show" ? "hub_lineage_show" : "hub_lineage_link";
|
|
12207
|
+
try { current(); } catch (error) { return void reply({ ok: false, error: (error as Error).message }); }
|
|
12208
|
+
// A pure read is checked and serialized in this stack, without a new policy-change await.
|
|
12209
|
+
if (op === "hub_lineage_show") return void reply(executionLineageRead(actor, input));
|
|
12210
|
+
void childToolAuthority.run({ by: actor, current: () => { try { current(); return true; } catch { return false; } } }, () => taskOp(actor, op, input)).then(
|
|
12211
|
+
text => { try { current(); reply(JSON.parse(text)); } catch { reply({ ok: false, error: "execution lineage caller changed; reconnect and retry" }); } },
|
|
12212
|
+
error => reply({ ok: false, error: error instanceof Error ? error.message : "execution lineage unavailable; inspect the project task and retry" }));
|
|
12213
|
+
return;
|
|
12214
|
+
}
|
|
11893
12215
|
case "model":
|
|
11894
12216
|
if (c.role !== "console") return void reply(modelFailure("model overrides are person-only; run ahub model in a person's terminal"));
|
|
11895
12217
|
return void reply(modelCommandSafe(msg, { source: "cli", scope: c, current: () => c.authed === true && !c.closed && c.role === "console" && sock.readyState === WebSocket.OPEN }));
|
|
@@ -11898,7 +12220,7 @@ export async function startDaemon(opts: DaemonOptions) {
|
|
|
11898
12220
|
try { const current = publicReadCurrent(sock); current(); const view = publicSettingsView(); current(); return void reply({ ok: true, ...view }); }
|
|
11899
12221
|
catch { return void reply({ ok: false, error: "public settings read unavailable for this caller" }); }
|
|
11900
12222
|
}
|
|
11901
|
-
return void reply({ ok: true, ...settingsView(), roster: rosterView(), configEdit: (() => { const view = configEditor!.view(); return { revisions: view.revisions, known: view.known }; })() });
|
|
12223
|
+
return void reply({ ok: true, ...settingsView(), sdlc: sdlcSettingsView(), roster: rosterView(), configEdit: (() => { const view = configEditor!.view(); return { revisions: view.revisions, known: view.known }; })() });
|
|
11902
12224
|
case "settings_reload":
|
|
11903
12225
|
if (c.role !== "console") return void reply({ ok: false, error: "settings are a person command" });
|
|
11904
12226
|
return void reloadConfig("terminal", undefined, msg.confirm).then(reply, () => reply({ ok: false, error: "configuration reload could not be confirmed; inspect hub.log" }));
|