@staix/agent-hub 0.52.0 → 0.54.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 +37 -0
- package/README.md +4 -3
- package/docs/addons/open-code-review.md +3 -6
- package/docs/agent-notes/README.md +1 -1
- package/docs/agent-notes/adapters.md +5 -4
- package/docs/agent-notes/budget.md +2 -2
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +6 -5
- package/docs/agent-notes/models.md +1 -1
- package/docs/agent-notes/tasks.md +3 -3
- package/docs/agent-notes/tests.md +4 -4
- package/docs/contracts/companion-cli-v2.json +90 -0
- package/docs/contracts/companion-cli-v3.json +348 -0
- package/docs/design/adapters.md +1 -1
- package/docs/design/agent-hub-architecture.md +8 -5
- package/docs/design/bus.md +1 -1
- package/docs/design/cli-output-inventory.md +4 -2
- package/docs/design/execution-reference.md +1 -1
- package/docs/design/guidance-experiments.md +1 -0
- package/docs/design/guidance-probes.md +1 -0
- package/docs/design/model-routes.md +20 -5
- package/docs/design/roadmap.md +6 -4
- package/docs/design/task-board.md +21 -2
- package/docs/dogfood.md +13 -6
- package/docs/events.md +1 -1
- package/docs/memory.md +2 -2
- package/docs/operations.md +158 -50
- package/docs/quickstart.md +14 -2
- package/docs/security.md +17 -9
- package/docs/specs/2026-09-19-agent-hub-design.md +5 -3
- package/docs/specs/2026-09-19-multi-project-design.md +1 -1
- package/docs/specs/2026-09-20-upgrade-recovery-design.md +24 -0
- package/docs/specs/2026-12-04-arev-adoption-design.md +84 -0
- package/docs/specs/mcp-endpoint.md +15 -4
- package/docs/specs/relay-contract.md +38 -0
- package/docs/verification/2026-12-04-host-shared-receipts.md +43 -0
- package/docs/verification/2026-12-05-0.53.0.md +101 -0
- package/docs/verification/2026-12-05-agy-1.5.24.md +55 -0
- package/docs/verification/2026-12-05-claude-implementer-2.1.337.md +43 -0
- package/docs/verification/2026-12-06-0.54.0.md +76 -0
- package/docs/verification/2026-12-06-codex-0174-reviewer-isolation.md +43 -0
- package/docs/verification/2026-12-06-codex-0174-reviewer-tool-call.md +34 -0
- package/docs/verification/2026-12-06-compat-codex-capabilities-0.174.0.md +25 -0
- package/docs/verification/2026-12-06-compat-pi-1.8.0.md +23 -0
- package/docs/verified.json +38 -29
- package/package.json +9 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/.mcp.json +1 -1
- package/plugins/agent-hub/compat.json +9 -5
- package/plugins/agent-hub/kimi-hook.js +892 -874
- package/plugins/agent-hub/relay-launcher.js +24 -0
- package/plugins/agent-hub/server.js +27271 -25146
- package/src/adapters/acp-session-model.ts +1 -1
- package/src/adapters/acp.ts +5 -4
- package/src/adapters/agy/definition.ts +1 -1
- package/src/adapters/agy/hooks.ts +1 -1
- package/src/adapters/channel-peer.ts +3 -1
- package/src/adapters/claude-channel-evidence.ts +26 -1
- package/src/adapters/claude-channel.ts +27 -30
- package/src/adapters/claude-connection-policy.ts +62 -0
- package/src/adapters/claude-relay.ts +255 -0
- package/src/adapters/codex-review-isolation.ts +1 -2
- package/src/adapters/compat.ts +28 -18
- package/src/adapters/definitions/native-cli-preview-pi.ts +2 -1
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-context.ts +1 -2
- package/src/adapters/definitions/native-factories.ts +4 -1
- package/src/adapters/definitions/native-quota.ts +1 -1
- package/src/adapters/definitions/native-recovery.ts +3 -1
- package/src/adapters/external-modules.ts +2 -2
- package/src/adapters/kimi-review.ts +1 -1
- package/src/adapters/kimi-tui-facts.ts +1 -1
- package/src/adapters/local-worker.ts +3 -3
- package/src/adapters/native-capabilities.ts +1 -1
- package/src/adapters/pi.ts +26 -7
- package/src/adapters/registry-types.ts +2 -0
- package/src/adapters/relay-launcher.ts +27 -0
- package/src/adapters/reviewer-mcp.ts +1 -1
- package/src/cli/agents.ts +20 -8
- package/src/cli/agy-mcp.ts +1 -1
- package/src/cli/claude-profile-hook.ts +1 -1
- package/src/cli/command-table.ts +1 -0
- package/src/cli/commands/agents.ts +18 -1
- package/src/cli/commands/doctor.ts +18 -4
- package/src/cli/commands/launch-line.ts +32 -0
- package/src/cli/commands/status.ts +14 -3
- package/src/cli/help.ts +7 -4
- package/src/cli/identity.ts +1 -1
- package/src/cli/init-roles.ts +1 -1
- package/src/cli/init-settings.ts +1 -1
- package/src/cli/launch-line-plan.ts +82 -0
- package/src/cli/launch-line-project.ts +13 -0
- package/src/cli/main.ts +10 -9
- package/src/cli/pi-steps-warning.ts +14 -0
- package/src/cli/recovery-package.ts +60 -6
- package/src/cli/reset.ts +1 -1
- package/src/cli/shell-quote.ts +1 -3
- package/src/cli/upgrade-interactive.ts +7 -2
- package/src/cli/upgrade-keep-plan.ts +47 -0
- package/src/cli/upgrade-restore-state.ts +1 -1
- package/src/cli/upgrade-runtime.ts +119 -18
- package/src/cli/upgrade.ts +17 -2
- package/src/hub/accounts.ts +8 -4
- package/src/hub/action-class.ts +1 -3
- package/src/hub/adec-triage.ts +105 -0
- package/src/hub/autonomy.ts +1 -1
- package/src/hub/board.ts +3 -27
- package/src/hub/bus.ts +39 -6
- package/src/hub/capabilities.ts +1 -1
- package/src/hub/channel-project-base.ts +46 -0
- package/src/hub/channel-project.ts +21 -46
- package/src/hub/config-apply.ts +1 -1
- package/src/hub/config-edit.ts +1 -1
- package/src/hub/config-tier.ts +1 -1
- package/src/hub/config.ts +2 -2
- package/src/hub/confirmation-matrix.ts +1 -1
- package/src/hub/control/board-messages.ts +415 -0
- package/src/hub/control/dashboard-messages.ts +221 -0
- package/src/hub/control/delivery-messages.ts +356 -0
- package/src/hub/control/dispatch.ts +114 -0
- package/src/hub/control/hub-tool-helpers.ts +243 -0
- package/src/hub/control/hub-tools.ts +147 -0
- package/src/hub/control/native-messages.ts +665 -0
- package/src/hub/control/operations-messages.ts +269 -0
- package/src/hub/control/peer-messages.ts +126 -0
- package/src/hub/control/recovery-messages.ts +391 -0
- package/src/hub/control/recovery-operation.ts +480 -0
- package/src/hub/control/scope.ts +460 -0
- package/src/hub/control/sdlc-messages.ts +373 -0
- package/src/hub/control/task-ops-more.ts +245 -0
- package/src/hub/control/task-ops.ts +553 -0
- package/src/hub/control/ui-actions.ts +241 -0
- package/src/hub/control-write-trace.ts +1 -4
- package/src/hub/daemon.ts +485 -4324
- package/src/hub/delivery-hints.ts +2 -0
- package/src/hub/delivery-journal.ts +17 -6
- package/src/hub/events.ts +2 -1
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/host.ts +41 -9
- package/src/hub/hub-tools.ts +3 -4
- package/src/hub/invocations.ts +1 -1
- package/src/hub/lifecycle.ts +4 -3
- package/src/hub/mcp-endpoint-serve.ts +4 -3
- package/src/hub/mcp-endpoint.ts +15 -6
- package/src/hub/memory-profile-check.ts +1 -1
- package/src/hub/no-writes.ts +1 -1
- package/src/hub/peers.ts +2 -0
- package/src/hub/pi-exit-policy.ts +27 -0
- package/src/hub/progress.ts +1 -1
- package/src/hub/project-runtime-state.ts +17 -4
- package/src/hub/project-runtime.ts +3 -1
- package/src/hub/protocol-window.ts +1 -1
- package/src/hub/recovery-continuity.ts +3 -3
- package/src/hub/recovery-kept-roster.ts +50 -0
- package/src/hub/review-anchor.ts +13 -181
- package/src/hub/review-brief.ts +78 -28
- package/src/hub/review-findings.ts +15 -193
- package/src/hub/review-ledger.ts +162 -0
- package/src/hub/review-material.ts +3 -3
- package/src/hub/reviewer-pool.ts +4 -2
- package/src/hub/roadmap-issue-states.ts +65 -14
- package/src/hub/roadmap-sync.ts +39 -14
- package/src/hub/routing.ts +9 -0
- package/src/hub/runtime-capture-prune.ts +8 -2
- package/src/hub/runtime-package-assets.ts +3 -0
- package/src/hub/sdlc-release-policy.ts +1 -2
- package/src/hub/settings.ts +1 -1
- package/src/hub/spec-ack-tool.ts +4 -0
- package/src/hub/spec-report-history.ts +36 -0
- package/src/hub/specs.ts +1 -4
- package/src/hub/supervision.ts +33 -6
- package/src/hub/tasks-audit.ts +390 -0
- package/src/hub/tasks-backlog.ts +522 -0
- package/src/hub/tasks-handoff.ts +208 -0
- package/src/hub/tasks-release.ts +257 -0
- package/src/hub/tasks-roadmap.ts +17 -3
- package/src/hub/tasks-specs.ts +672 -0
- package/src/hub/tasks-types.ts +334 -0
- package/src/hub/tasks.ts +286 -1961
- package/src/hub/upgrade-session-contract.ts +11 -0
- package/src/local/probe-sandbox.ts +1 -2
- package/src/local/probe-workspace.ts +1 -1
- package/src/models/route/config.ts +4 -4
- package/src/models/route/decision.ts +18 -10
- package/src/models/route/observation-signals.ts +1 -2
- package/src/models/route/runtime.ts +8 -5
- package/src/npm-artifact.ts +76 -0
- package/src/omniroute/client.ts +6 -0
- package/src/pi/extension.ts +5 -2
- package/src/pi/install.ts +77 -0
- package/src/pi/pin.ts +49 -0
- package/src/primitives.ts +14 -0
- package/src/version.ts +2 -0
- package/templates/adec/README.md +10 -6
- package/templates/config.json +1 -1
- package/templates/specs.block.md +1 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
// #1830 S2c: the `sdlc` control message moved out of onMessage, with the public-read helpers only it uses.
|
|
2
|
+
import { discoverInitChecks } from "../../cli/init-required-checks.ts";
|
|
3
|
+
import { parseReleaseGuardArgv, parseReleasePushUpdates } from "../../cli/sdlc-release-guard.ts";
|
|
4
|
+
import { VERSION } from "../../version.ts";
|
|
5
|
+
import type { Task } from "../board.ts";
|
|
6
|
+
import { conductorPeer } from "../conductor.ts";
|
|
7
|
+
import { USER, sanitize } from "../envelope.ts";
|
|
8
|
+
import { hubGitSync } from "../git.ts";
|
|
9
|
+
import { runSdlcCheck } from "../sdlc-check.ts";
|
|
10
|
+
import { requiredChecksFor } from "../sdlc-merge.ts";
|
|
11
|
+
import { releaseAuthorizationError } from "../sdlc-release-authorization.ts";
|
|
12
|
+
import { planSdlcSync } from "../sdlc-sync.ts";
|
|
13
|
+
import { loadSdlc, readSpecEdit, sdlcGh } from "../sdlc.ts";
|
|
14
|
+
import type { SdlcGh } from "../sdlc.ts";
|
|
15
|
+
import { readbackAcceptField } from "../spec-readback.ts";
|
|
16
|
+
import { githubOriginRepository } from "../task-repository.ts";
|
|
17
|
+
import { existsSync } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import type { ControlMessage, DaemonScope } from "./scope.ts";
|
|
20
|
+
|
|
21
|
+
function publicDeliveryQueue(scope: DaemonScope, report: Awaited<ReturnType<typeof scope.tasks.deliveryQueue>>) {
|
|
22
|
+
const privateTasks = scope.board.list().filter(task => scope.tasks.isPii(task));
|
|
23
|
+
const privateIds = new Set(privateTasks.map(task => task.id));
|
|
24
|
+
const privatePrs = new Set([...report.rows.filter(row => row.private).map(row => row.pr), ...privateTasks.filter(task => task.sdlc?.repo?.toLowerCase() === report.repo.toLowerCase()).flatMap(task => task.sdlc?.pr ? [task.sdlc.pr] : [])]);
|
|
25
|
+
const mixed = privatePrs.size > 0;
|
|
26
|
+
// ponytail: mixed private repositories expose no dependency/readiness evidence. A typed per-dependency privacy projection can restore independent evidence later.
|
|
27
|
+
return scope.publicReadValue({ repo: report.repo, complete: report.complete && !mixed, truncated: report.truncated,
|
|
28
|
+
rows: report.rows.map(row => row.private || privatePrs.has(row.pr) ? { private: true, ready: false, tasks: [], after: [], blockers: ["private lifecycle evidence unavailable"] }
|
|
29
|
+
: mixed ? { pr: row.pr, tasks: row.tasks.filter(id => !privateIds.has(id)), ready: false, after: [], blockers: ["private dependency evidence unavailable"] }
|
|
30
|
+
: { pr: row.pr, tasks: row.tasks, head: row.head, ready: row.ready, blockers: row.blockers, after: row.after,
|
|
31
|
+
...(row.findings ? { findings: row.findings } : {}), ...(row.planConformance ? { planConformance: row.planConformance } : {}), ...(row.testIntegrity ? { testIntegrity: row.testIntegrity } : {}), ...(row.evalGate ? { evalGate: row.evalGate } : {}), ...(row.securityPass ? { securityPass: row.securityPass } : {}) }),
|
|
32
|
+
order: mixed ? [] : report.order, ...(report.unordered ? { unordered: mixed ? [] : report.unordered } : {}), conflicts: mixed ? [] : report.conflicts });
|
|
33
|
+
}
|
|
34
|
+
/** A public read may use host GitHub authentication only for this project's current public scope. */
|
|
35
|
+
function publicDeliveryRepository(scope: DaemonScope, repo: unknown): repo is string {
|
|
36
|
+
if (typeof repo !== "string" || !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo) || repo.startsWith("-") || !scope.tasks.publicMetadataText(repo)) return false;
|
|
37
|
+
const identity = repo.toLowerCase();
|
|
38
|
+
return Object.keys(scope.lifecycleConfig.repos ?? {}).some(key => key.toLowerCase() === identity)
|
|
39
|
+
|| scope.board.list().some(task => !scope.tasks.isPii(task) && task.external?.repo.toLowerCase() === identity)
|
|
40
|
+
|| githubOriginRepository(scope.opts.cwd) === identity;
|
|
41
|
+
}
|
|
42
|
+
function publicReadPrivacy(scope: DaemonScope) { return JSON.stringify(scope.board.list().map(task => [task.id, scope.tasks.isPii(task), task.history.length])); }
|
|
43
|
+
// sdlc
|
|
44
|
+
export function sdlcMessage(scope: DaemonScope, m: ControlMessage): void {
|
|
45
|
+
const { sock, c, msg, reply } = m;
|
|
46
|
+
{
|
|
47
|
+
if (msg.op === "release-guard" || msg.op === "release-guard-hook") {
|
|
48
|
+
if (c.role !== "console" && c.role !== "tools" && c.role !== "peer" || c.peer && (!!scope.turns.get(c.peer)?.private || scope.contextPii(c.peer))) return void reply({ ok: false, error: "release guard unavailable for this caller" });
|
|
49
|
+
if (msg.op === "release-guard") {
|
|
50
|
+
const parsed = parseReleaseGuardArgv(msg.argv);
|
|
51
|
+
if (!parsed.ok) return void reply({ ok: false, error: parsed.reason });
|
|
52
|
+
void scope.releaseAuthorizations.guardRequest(parsed.request).then(reply, () => reply({ ok: false, error: "release guard evidence unavailable" }));
|
|
53
|
+
} else {
|
|
54
|
+
const parsed = parseReleasePushUpdates(msg.remoteName, msg.remoteUrl, msg.stdin);
|
|
55
|
+
if (!parsed.ok) return void reply({ ok: false, error: parsed.reason });
|
|
56
|
+
reply(scope.releaseAuthorizations.guardPush(parsed.remoteName, parsed.remoteUrl, parsed.updates));
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (msg.op === "adopt-merge") {
|
|
61
|
+
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer ? c.peer : undefined;
|
|
62
|
+
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" });
|
|
63
|
+
let actorCurrent: () => void;
|
|
64
|
+
const externalOwner = c.externalOwner;
|
|
65
|
+
try {
|
|
66
|
+
const sessionCurrent = c.role === "console" ? () => {
|
|
67
|
+
if (sock.data !== c || sock.readyState !== WebSocket.OPEN || c.role !== "console") throw new Error("person session changed");
|
|
68
|
+
} : scope.operationalCurrent(sock);
|
|
69
|
+
actorCurrent = () => {
|
|
70
|
+
sessionCurrent();
|
|
71
|
+
if (externalOwner && !scope.currentExternalTools(c, true)) throw new Error("actor execution root changed");
|
|
72
|
+
sessionCurrent(); // A fresh execution-root probe can service callbacks before it returns.
|
|
73
|
+
if (c.peer !== (asker === USER ? undefined : asker) || c.externalOwner !== externalOwner) throw new Error("actor session changed");
|
|
74
|
+
};
|
|
75
|
+
actorCurrent();
|
|
76
|
+
}
|
|
77
|
+
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" }); }
|
|
78
|
+
const fence = () => {
|
|
79
|
+
try { actorCurrent(); } catch { return "person or conductor session changed; reconnect and retry ahub sdlc adopt-merge"; }
|
|
80
|
+
return scope.recoveryActive() || scope.stopping || c.peer && scope.turns.get(c.peer)?.private ? "recovery, shutdown or a private turn holds adoption; retry ahub sdlc adopt-merge after it ends" : undefined;
|
|
81
|
+
};
|
|
82
|
+
scope.taskOpsInFlight++;
|
|
83
|
+
void scope.tasks.adoptMerge(asker, msg.id, msg.pr, fence).then(
|
|
84
|
+
result => reply({ ok: true, ...result }),
|
|
85
|
+
(error: Error) => reply({ ok: false, error: sanitize(error.message) }),
|
|
86
|
+
).finally(() => { scope.taskOpsInFlight--; });
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (msg.op === "survey-start" || msg.op === "survey-show") {
|
|
90
|
+
if (Object.keys(msg).some(key => !["t", "rid", "op", "focus", "id"].includes(key))) return void reply({ ok: false, error: "survey accepts only its task id or focus; remove unknown fields" });
|
|
91
|
+
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer && conductorPeer(scope.config.roles) === c.peer && !c.toolsOwner && !scope.turns.get(c.peer)?.private && !scope.contextPii(c.peer) ? c.peer : undefined;
|
|
92
|
+
if (!asker) return void reply({ ok: false, error: "only the person or current configured conductor may start or show advisor surveys" });
|
|
93
|
+
const externalOwner = c.externalOwner;
|
|
94
|
+
const sessionCurrent = c.role === "console" ? () => { if (sock.data !== c || sock.readyState !== WebSocket.OPEN || c.role !== "console") throw new Error("person session changed"); } : scope.operationalCurrent(sock);
|
|
95
|
+
const fence = () => {
|
|
96
|
+
try {
|
|
97
|
+
sessionCurrent();
|
|
98
|
+
if (externalOwner && !scope.currentExternalTools(c, true)) return "survey execution root changed; reconnect and retry";
|
|
99
|
+
sessionCurrent();
|
|
100
|
+
if (c.peer !== (asker === USER ? undefined : asker) || c.externalOwner !== externalOwner || c.toolsOwner) return "survey actor changed; reconnect and retry";
|
|
101
|
+
if (c.peer && (scope.turns.get(c.peer)?.private || scope.contextPii(c.peer))) return "survey unavailable during private input";
|
|
102
|
+
return scope.recoveryActive() || scope.stopping ? "recovery or shutdown holds survey writes; retry after release" : undefined;
|
|
103
|
+
} catch { return "survey person or conductor session changed; reconnect and retry"; }
|
|
104
|
+
};
|
|
105
|
+
const refusal = fence(); if (refusal) return void reply({ ok: false, error: refusal });
|
|
106
|
+
if (msg.op === "survey-show") {
|
|
107
|
+
try { return void reply({ ok: true, survey: scope.tasks.surveyShow(asker, msg.id) }); }
|
|
108
|
+
catch (error) { return void reply({ ok: false, error: sanitize(error instanceof Error ? error.message : "survey read unavailable").slice(0, 300) }); }
|
|
109
|
+
}
|
|
110
|
+
scope.taskOpsInFlight++;
|
|
111
|
+
void scope.tasks.surveyStart(asker, { focus: msg.focus }, fence).then(result => reply({ ok: true, ...result }),
|
|
112
|
+
(error: Error) => reply({ ok: false, error: sanitize(error.message).slice(0, 300) })).finally(() => { scope.taskOpsInFlight--; });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (msg.op === "readback-start" || msg.op === "readback-show") {
|
|
116
|
+
// #1658: the person or the current conductor starts and reads a spec read-back; every request gets a reply.
|
|
117
|
+
if (Object.keys(msg).some(key => !["t", "rid", "op", "id"].includes(key))) return void reply({ ok: false, error: "a read-back accepts only its task id; remove unknown fields" });
|
|
118
|
+
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer && conductorPeer(scope.config.roles) === c.peer && !c.toolsOwner && !scope.turns.get(c.peer)?.private && !scope.contextPii(c.peer) ? c.peer : undefined;
|
|
119
|
+
if (!asker) return void reply({ ok: false, error: "only the person or the current configured conductor may use spec read-backs; ask the person to run ahub sdlc readback start" });
|
|
120
|
+
const externalOwner = c.externalOwner;
|
|
121
|
+
const sessionCurrent = c.role === "console" ? () => { if (sock.data !== c || sock.readyState !== WebSocket.OPEN || c.role !== "console") throw new Error("person session changed"); } : scope.operationalCurrent(sock);
|
|
122
|
+
const fence = () => {
|
|
123
|
+
try {
|
|
124
|
+
sessionCurrent();
|
|
125
|
+
if (externalOwner && !scope.currentExternalTools(c, true)) return "read-back execution root changed; reconnect and retry";
|
|
126
|
+
sessionCurrent();
|
|
127
|
+
if (c.peer !== (asker === USER ? undefined : asker) || c.externalOwner !== externalOwner || c.toolsOwner) return "read-back actor changed; reconnect and retry";
|
|
128
|
+
if (c.peer && (scope.turns.get(c.peer)?.private || scope.contextPii(c.peer))) return "read-back unavailable during private input";
|
|
129
|
+
return scope.recoveryActive() || scope.stopping ? "recovery or shutdown holds read-back writes; retry after release" : undefined;
|
|
130
|
+
} catch { return "read-back person or conductor session changed; reconnect and retry"; }
|
|
131
|
+
};
|
|
132
|
+
const refusal = fence(); if (refusal) return void reply({ ok: false, error: refusal });
|
|
133
|
+
if (msg.op === "readback-show") {
|
|
134
|
+
try { return void reply({ ok: true, readback: scope.tasks.specReadbackShow(asker, msg.id) }); }
|
|
135
|
+
catch (error) { return void reply({ ok: false, error: sanitize(error instanceof Error ? error.message : "read-back read unavailable").slice(0, 300) }); }
|
|
136
|
+
}
|
|
137
|
+
scope.taskOpsInFlight++;
|
|
138
|
+
void scope.tasks.specReadbackStart(asker, msg.id, fence).then(result => reply({ ok: true, ...result }),
|
|
139
|
+
(error: Error) => reply({ ok: false, error: sanitize(error.message).slice(0, 300) })).finally(() => { scope.taskOpsInFlight--; });
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (msg.op === "audit-start" || msg.op === "audit-show") {
|
|
143
|
+
// #1403 A4: the person or the one configured conductor starts and reads a security audit. Every request gets a reply, a refusal included.
|
|
144
|
+
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer && conductorPeer(scope.config.roles) === c.peer && !c.toolsOwner && !scope.turns.get(c.peer)?.private && !scope.contextPii(c.peer) ? c.peer : undefined;
|
|
145
|
+
if (!asker) return void reply({ ok: false, error: "only the console user or the configured conductor may use security audits; ask the person to run ahub sdlc audit" });
|
|
146
|
+
if (msg.op === "audit-show") {
|
|
147
|
+
try { return void reply({ ok: true, audit: scope.tasks.auditShow(asker, msg.id) ?? null }); }
|
|
148
|
+
catch (error) { return void reply({ ok: false, error: sanitize(error instanceof Error ? error.message : "audit readback unavailable").slice(0, 300) }); }
|
|
149
|
+
}
|
|
150
|
+
if (scope.recoveryActive() || scope.stopping) return void reply({ ok: false, error: "recovery or shutdown is holding task writes; retry ahub sdlc audit start after it ends" });
|
|
151
|
+
scope.taskOpsInFlight++;
|
|
152
|
+
void scope.tasks.auditStart(asker, { profile: msg.profile, since: msg.since }, () => scope.recoveryActive() || scope.stopping ? "recovery or shutdown is holding task writes; retry ahub sdlc audit start after it ends" : undefined).then(
|
|
153
|
+
result => reply({ ok: true, ...result }),
|
|
154
|
+
(error: Error) => reply({ ok: false, error: sanitize(error.message).slice(0, 300) }),
|
|
155
|
+
).finally(() => { scope.taskOpsInFlight--; });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (msg.op === "merge") {
|
|
159
|
+
// #786 T1: the person or the one configured conductor asks for a guarded merge. Every request gets a reply, a refusal included.
|
|
160
|
+
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer && conductorPeer(scope.config.roles) === c.peer && !c.toolsOwner && !scope.turns.get(c.peer)?.private && !scope.contextPii(c.peer) ? c.peer : undefined;
|
|
161
|
+
if (!asker) return void reply({ ok: false, error: "only the console user or the configured conductor may merge" });
|
|
162
|
+
if (scope.recoveryActive()) return void reply({ ok: false, error: "recovery is holding mutations" });
|
|
163
|
+
if (!Number.isSafeInteger(msg.id) || msg.id <= 0 || (msg.dryRun !== undefined && typeof msg.dryRun !== "boolean")) return void reply({ ok: false, error: "usage: ahub sdlc merge <task> [--dry-run]" });
|
|
164
|
+
scope.tasks.guardedMerge(asker, msg.id, { dryRun: msg.dryRun === true, trigger: "command" }).then(
|
|
165
|
+
result => reply({ ok: true, ...result }),
|
|
166
|
+
(error: Error) => reply({ ok: false, error: sanitize(error.message).slice(0, 200) }),
|
|
167
|
+
);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (msg.op === "configure") {
|
|
171
|
+
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer && conductorPeer(scope.config.roles) === c.peer && !c.toolsOwner && !scope.turns.get(c.peer)?.private && !scope.contextPii(c.peer) ? c.peer : undefined;
|
|
172
|
+
if (!asker) return void reply({ ok: false, error: "only the console user or current configured conductor may configure SDLC" });
|
|
173
|
+
if (Object.keys(msg).some(key => !["t", "rid", "op", "mode", "required_checks", "instructionClaim"].includes(key)))
|
|
174
|
+
return void reply({ ok: false, error: "sdlc configure accepts only mode and required_checks; protected settings remain person-only" });
|
|
175
|
+
const externalOwner = c.externalOwner;
|
|
176
|
+
const session = c.role === "console" ? () => { if (sock.data !== c || sock.readyState !== WebSocket.OPEN || c.role !== "console") throw new Error("person session changed; reconnect before configuring SDLC"); } : scope.operationalCurrent(sock);
|
|
177
|
+
const current = () => {
|
|
178
|
+
session();
|
|
179
|
+
if (c.toolsOwner || c.externalOwner !== externalOwner || externalOwner && !scope.currentExternalTools(c, true)) throw new Error("SDLC caller or execution root changed; reconnect before configuring");
|
|
180
|
+
session();
|
|
181
|
+
if (asker !== USER && (c.peer !== asker || conductorPeer(scope.config.roles) !== asker || scope.turns.get(asker)?.private || scope.contextPii(asker) || scope.reviewObserverHeld(asker) || scope.reviewObserverInput(asker)))
|
|
182
|
+
throw new Error("SDLC configuration unavailable for private, observer or changed conductor input");
|
|
183
|
+
if (scope.stopping || scope.recoveryActive() || scope.bus.isRecoveryHeld) throw new Error("recovery or shutdown holds SDLC configuration; retry after release");
|
|
184
|
+
};
|
|
185
|
+
try { current(); } catch { return void reply({ ok: false, error: "SDLC configuration authority unavailable; reconnect in a public current conductor session" }); }
|
|
186
|
+
scope.taskOpsInFlight++;
|
|
187
|
+
void scope.configEditor!.configureSdlc(asker, { ...(Object.hasOwn(msg, "mode") ? { mode: msg.mode } : {}), ...(Object.hasOwn(msg, "required_checks") ? { required_checks: msg.required_checks } : {}), instructionClaim: msg.instructionClaim }, current)
|
|
188
|
+
.then(reply, () => reply({ ok: false, error: "SDLC configuration could not be completed; inspect the file and event log before retrying" })).finally(() => { scope.taskOpsInFlight--; });
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (msg.op === "authorize-release") {
|
|
192
|
+
const asker = c.role === "console" ? USER : c.role === "tools" && c.peer && conductorPeer(scope.config.roles) === c.peer && !c.toolsOwner && !scope.turns.get(c.peer)?.private && !scope.contextPii(c.peer) ? c.peer : undefined;
|
|
193
|
+
if (!asker) return void reply({ ok: false, error: "only the console user or the configured conductor may authorize a release" });
|
|
194
|
+
void scope.releaseAuthorizations.authorize(asker, msg.version, msg.commit).then(
|
|
195
|
+
authorization => reply({ ok: true, authorization }),
|
|
196
|
+
error => reply({ ok: false, error: releaseAuthorizationError(error) }),
|
|
197
|
+
);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (c.role !== "console" && ["status", "explain", "queue", "release"].includes(msg.op)) {
|
|
201
|
+
let current: () => void;
|
|
202
|
+
try { current = scope.publicReadCurrent(sock); current(); } catch { return void reply({ ok: false, error: "public lifecycle read unavailable for this caller" }); }
|
|
203
|
+
if (msg.op === "queue" || msg.op === "release") {
|
|
204
|
+
if (!publicDeliveryRepository(scope, msg.repo)) return void reply({ ok: false, error: "public repository unavailable for this project" });
|
|
205
|
+
current(); // An isolated Git probe can service pending callbacks before it returns.
|
|
206
|
+
if (!Array.isArray(msg.liveIssues ?? []) || (msg.liveIssues ?? []).length > 32) return void reply({ ok: false, error: "invalid delivery readback arguments" });
|
|
207
|
+
const before = publicReadPrivacy(scope);
|
|
208
|
+
const read = msg.op === "queue" ? scope.tasks.deliveryQueue(msg.repo) : scope.tasks.releaseReadiness(msg.repo, msg.liveIssues ?? []);
|
|
209
|
+
void read.then(report => {
|
|
210
|
+
current();
|
|
211
|
+
if (!publicDeliveryRepository(scope, msg.repo)) return void reply({ ok: false, error: "public repository unavailable for this project" });
|
|
212
|
+
current();
|
|
213
|
+
if (before !== publicReadPrivacy(scope)) throw new Error("privacy changed");
|
|
214
|
+
reply({ ok: true, public: true, report: msg.op === "queue" ? publicDeliveryQueue(scope, report as Awaited<ReturnType<typeof scope.tasks.deliveryQueue>>) : scope.publicReadValue(report) });
|
|
215
|
+
}).catch(() => reply({ ok: false, error: "public delivery readback unavailable" }));
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const selected = msg.id === undefined ? scope.board.list().filter(task => (task.sdlc || scope.lifecycleConfig.mode !== "off" || scope.lifecycleConfig.workflow === "gsd-lite") && task.state !== "backlog") : [scope.board.get(Number(msg.id))].filter((task): task is Task => !!task);
|
|
219
|
+
if (msg.id !== undefined && (!Number.isSafeInteger(msg.id) || msg.id <= 0 || !selected.length || selected.some(task => task.state === "backlog"))) return void reply({ ok: false, error: "invalid public lifecycle task id" });
|
|
220
|
+
void (async () => {
|
|
221
|
+
const statuses = new Map<number, Awaited<ReturnType<typeof scope.tasks.lifecycleStatus>>>();
|
|
222
|
+
for (const task of selected.slice(0, 100)) {
|
|
223
|
+
current(); const now = scope.board.get(task.id); if (!now || now.state === "backlog") throw new Error("task changed");
|
|
224
|
+
if (!scope.tasks.isPii(now)) statuses.set(task.id, await scope.tasks.lifecycleStatus(task.id, msg.id !== undefined));
|
|
225
|
+
current();
|
|
226
|
+
}
|
|
227
|
+
const rows = selected.slice(0, 100).map(task => {
|
|
228
|
+
const now = scope.board.get(task.id); if (!now || now.state === "backlog") throw new Error("task changed");
|
|
229
|
+
if (scope.tasks.isPii(now)) return { id: now.id, title: scope.tasks.publicTitle(now), private: true };
|
|
230
|
+
if (task.history.length !== now.history.length || !statuses.has(task.id)) throw new Error("task changed");
|
|
231
|
+
const status = statuses.get(task.id)!;
|
|
232
|
+
const safeStatus = Object.fromEntries(["mode", "stage", "blockers", "ready", "actor", "next", "spec", "playbook", "criteria", "definition", "entry", "exit", "planConformance", "testIntegrity", "evalGate", "securityPass", "findings"].filter(key => key in status).map(key => [key, scope.publicReadValue(status[key as keyof typeof status])]));
|
|
233
|
+
return { id: now.id, title: scope.tasks.publicTitle(now), receipt: scope.publicReadValue(scope.tasks.publicView(now).sdlc), ...safeStatus };
|
|
234
|
+
});
|
|
235
|
+
current(); reply({ ok: true, public: true, mode: scope.lifecycleConfig.mode, rows, truncated: selected.length > 100 });
|
|
236
|
+
})().catch(() => reply({ ok: false, error: "public lifecycle readback unavailable" }));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (msg.op === "sync") {
|
|
240
|
+
// #1856 T3: a preview writes nothing; apply re-plans and refuses before any write unless the fingerprint still matches.
|
|
241
|
+
if (c.role !== "console" && c.role !== "tools") return void reply({ ok: false, error: "ahub sdlc sync is for the person or a tools session; run it from a terminal" });
|
|
242
|
+
if (c.peer && (!!scope.turns.get(c.peer)?.private || scope.contextPii(c.peer))) return void reply({ ok: false, error: "ahub sdlc sync is unavailable in a private turn; finish it and retry" });
|
|
243
|
+
const apply = msg.apply === true, asker = c.role === "console" ? USER : c.peer;
|
|
244
|
+
if (apply && (!asker || typeof msg.confirm !== "string" || !/^[a-f0-9]{64}$/.test(msg.confirm))) return void reply({ ok: false, error: "apply needs the fingerprint of a preview; run ahub sdlc sync, then ahub sdlc sync --apply --confirm <fingerprint>" });
|
|
245
|
+
const repository = githubOriginRepository(scope.opts.cwd);
|
|
246
|
+
const writeRoadmap = msg.writeRoadmap === true, closeSettled = msg.closeSettled === true;
|
|
247
|
+
if (closeSettled) { try { scope.tasks.closeSettledGate(asker ?? USER); } catch (error) { return void reply({ ok: false, error: sanitize(error instanceof Error ? error.message : "closing settled issues is not permitted") }); } }
|
|
248
|
+
const planNow = () => planSdlcSync({
|
|
249
|
+
...(writeRoadmap ? { roadmap: { tracked: msg.roadmapTracked === true, render: () => scope.tasks.roadmapExport(asker ?? USER) } } : {}),
|
|
250
|
+
...(closeSettled ? { closeSettled: { cards: scope.board.list().map(task => ({ id: task.id, state: task.state, pii: scope.tasks.isPii(task), ...(task.sdlc?.repo ? { repo: task.sdlc.repo } : {}), ...(task.sdlc?.issue ? { issue: task.sdlc.issue } : {}), ...(task.sdlc?.pr ? { pr: task.sdlc.pr } : {}) })) } } : {}),
|
|
251
|
+
repository, authority: asker === USER ? "person" : `conductor:${asker ?? "none"}:${scope.lifecycleConfig.mode}`,
|
|
252
|
+
gh: (args, timeout, _cwd, bound) => sdlcGh(args, timeout, scope.opts.cwd, bound),
|
|
253
|
+
tasks: scope.board.list().filter(task => ["proposed", "in_progress", "in_review", "changes_requested"].includes(task.state)).map(task => {
|
|
254
|
+
const pii = scope.tasks.isPii(task);
|
|
255
|
+
return { id: task.id, state: task.state, // not tasks.publicTitle: it prefixes `#<id> `, which the title parser would read as an issue.
|
|
256
|
+
title: pii ? "" : task.title, pii, ...(task.refs.repo && !pii ? { refsRepo: task.refs.repo } : {}),
|
|
257
|
+
branches: !pii && task.refs.branch ? [task.refs.branch] : [], historyLength: task.history.length,
|
|
258
|
+
...(task.sdlc && !pii ? { sdlc: { ...(task.sdlc.repo ? { repo: task.sdlc.repo } : {}), ...(task.sdlc.issue ? { issue: task.sdlc.issue } : {}), ...(task.sdlc.pr ? { pr: task.sdlc.pr } : {}), ...(task.sdlc.localHead ? { localHead: task.sdlc.localHead } : {}), ...(task.sdlc.reviewedHead ? { reviewedHead: task.sdlc.reviewedHead } : {}) } } : {}) };
|
|
259
|
+
}),
|
|
260
|
+
});
|
|
261
|
+
if (!apply) {
|
|
262
|
+
void planNow().then(plan => reply({ ok: true, apply: false, options: { writeRoadmap, closeSettled }, ...plan }), error => reply({ ok: false, error: `sync plan unavailable (${error instanceof Error ? error.name : "unknown error"}); run ahub sdlc check and retry` }));
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
scope.taskOpsInFlight++;
|
|
266
|
+
void (async () => {
|
|
267
|
+
const plan = await planNow();
|
|
268
|
+
if (plan.fingerprint !== msg.confirm) return reply({ ok: false, error: `the board, origin or authority changed since the preview; review ahub sdlc sync and confirm the new fingerprint ${plan.fingerprint}`, fingerprint: plan.fingerprint });
|
|
269
|
+
const results: { task: number; kind: string; ok: boolean; error?: string }[] = [];
|
|
270
|
+
for (const op of plan.operations) {
|
|
271
|
+
try {
|
|
272
|
+
if (op.kind === "link") scope.tasks.recordSyncRepair(asker!, op.task, { repo: op.repo, issue: op.issue });
|
|
273
|
+
else if (op.kind === "bind") scope.tasks.recordSyncRepair(asker!, op.task, { repo: op.repo, pr: op.pr, localHead: op.localHead });
|
|
274
|
+
else await scope.tasks.adoptMerge(asker!, op.task, op.pr);
|
|
275
|
+
results.push({ task: op.task, kind: op.kind, ok: true });
|
|
276
|
+
} catch (error) { results.push({ task: op.task, kind: op.kind, ok: false, error: sanitize(error instanceof Error ? error.message : "refused") }); }
|
|
277
|
+
}
|
|
278
|
+
for (const close of plan.closes) {
|
|
279
|
+
try { await scope.tasks.closeSettledIssue(asker!, close.repo, close.issue); results.push({ task: 0, kind: `close #${close.issue}`, ok: true }); }
|
|
280
|
+
catch (error) { results.push({ task: 0, kind: `close #${close.issue}`, ok: false, error: sanitize(error instanceof Error ? error.message : "refused") }); }
|
|
281
|
+
}
|
|
282
|
+
let roadmapFiles: { json: string; markdown: string } | undefined;
|
|
283
|
+
if (plan.roadmap) {
|
|
284
|
+
try { const files = await scope.tasks.roadmapExport(asker!); roadmapFiles = { json: files.json, markdown: files.markdown }; } catch { results.push({ task: 0, kind: "roadmap refresh", ok: false, error: "the roadmap could not be rendered; run ahub roadmap export" }); }
|
|
285
|
+
}
|
|
286
|
+
reply({ ok: true, apply: true, fingerprint: plan.fingerprint, results, ambiguous: plan.ambiguous, headMoved: plan.headMoved, withheld: plan.withheld, ...(roadmapFiles ? { roadmapFiles } : {}) });
|
|
287
|
+
})().catch((error: Error) => reply({ ok: false, error: sanitize(error.message) })).finally(() => { scope.taskOpsInFlight--; });
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (c.role !== "console") return void reply({ ok: false, error: "SDLC readback is console only; task owners record ids through hub_sdlc_record" });
|
|
291
|
+
if (msg.op === "queue" || msg.op === "release") {
|
|
292
|
+
if (typeof msg.repo !== "string" || !Array.isArray(msg.liveIssues ?? []) || (msg.liveIssues ?? []).length > 32) return void reply({ ok: false, error: "invalid delivery readback arguments" });
|
|
293
|
+
const read = msg.op === "queue" ? scope.tasks.deliveryQueue(msg.repo) : scope.tasks.releaseReadiness(msg.repo, msg.liveIssues ?? []);
|
|
294
|
+
void read.then(report => reply({ ok: true, report: msg.op === "release" ? scope.releaseAuthorizations.report(report as Awaited<ReturnType<typeof scope.tasks.releaseReadiness>>) : report }), () => reply({ ok: false, error: "delivery readback unavailable" }));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (msg.op === "export") {
|
|
298
|
+
try { return void reply({ ok: true, export: scope.tasks.workflowExport(msg.id) }); } catch { return void reply({ ok: false, error: "workflow export unavailable" }); }
|
|
299
|
+
}
|
|
300
|
+
if (msg.op === "accept-departure") {
|
|
301
|
+
void scope.tasks.acceptPlanDeparture(USER, msg.id, msg.head, msg.reason).then(
|
|
302
|
+
() => reply({ ok: true }),
|
|
303
|
+
() => reply({ ok: false, error: "plan departure not accepted: task changed, current complete file evidence unavailable, or arguments invalid" }),
|
|
304
|
+
);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (msg.op === "accept") {
|
|
308
|
+
// #481 S1: the person's spec acceptance, bound to the issue's body edit time; no body is read.
|
|
309
|
+
if (!Number.isSafeInteger(msg.id) || msg.id <= 0 || !Number.isSafeInteger(msg.issue) || msg.issue <= 0 || (msg.repo !== undefined && typeof msg.repo !== "string")) return void reply({ ok: false, error: "usage: ahub sdlc accept <task> --issue <n> [--repo owner/repository]" });
|
|
310
|
+
const task = scope.board.get(msg.id);
|
|
311
|
+
const repo = msg.repo ?? task?.sdlc?.repo;
|
|
312
|
+
if (!task || typeof repo !== "string") return void reply({ ok: false, error: task ? "spec acceptance needs --repo owner/repository (the task's receipt names none)" : "invalid lifecycle task id" });
|
|
313
|
+
const linked = `${task.sdlc?.repo ?? ""}#${task.sdlc?.issue ?? ""}`;
|
|
314
|
+
void readSpecEdit(repo, msg.issue, scope.opts.boundedTools?.specEdit ?? ((args, timeout, _cwd, bound) => sdlcGh(args, timeout, scope.opts.cwd, bound))).then(edit => {
|
|
315
|
+
if (!edit) return reply({ ok: false, error: "issue edit time unavailable; nothing was recorded" });
|
|
316
|
+
// The readback is for the receipt read before it; a relink meanwhile makes it someone else's evidence.
|
|
317
|
+
const now = scope.board.get(msg.id)?.sdlc;
|
|
318
|
+
if (`${now?.repo ?? ""}#${now?.issue ?? ""}` !== linked) return reply({ ok: false, error: "the task's spec link changed during the readback; nothing was recorded, run ahub sdlc accept again" });
|
|
319
|
+
try {
|
|
320
|
+
// #1658 AC6: the read-back line prints before the acceptance is recorded, and the acceptance proceeds in every state.
|
|
321
|
+
const accepted = scope.board.get(msg.id)!;
|
|
322
|
+
// A read-back row whose bytes fail their hash is a storage defect, not a reason to refuse the person's
|
|
323
|
+
// acceptance: the line then says the state is unknown, and the acceptance is recorded as in any other state.
|
|
324
|
+
let readback: string | undefined;
|
|
325
|
+
try { readback = readbackAcceptField(scope.tasks.readbackView({ ...accepted, sdlc: { ...(accepted.sdlc ?? { stage: "spec" as const }), repo, issue: msg.issue } }, edit), msg.id).readback; }
|
|
326
|
+
catch { readback = "spec read-back: storage unreadable (the acceptance is recorded and no state is known; restore a trusted hub.db backup to read it)"; }
|
|
327
|
+
const next = scope.tasks.acceptSpec(USER, msg.id, { repo, issue: msg.issue, edit });
|
|
328
|
+
reply({ ok: true, acceptance: next.sdlc?.acceptance, ...(readback ? { readback } : {}) });
|
|
329
|
+
} catch (error) { reply({ ok: false, error: (error as Error).message }); }
|
|
330
|
+
}, () => reply({ ok: false, error: "issue edit time unavailable; nothing was recorded" }));
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
// #1856 T2: the read-only audit. Open to the person and to agents; it writes nothing, shows public titles only and counts private tasks.
|
|
334
|
+
if (msg.op === "check") {
|
|
335
|
+
const offline = msg.offline === true, repository = githubOriginRepository(scope.opts.cwd);
|
|
336
|
+
const checkGh: SdlcGh = (args, timeout, _cwd, bound) => sdlcGh(args, timeout, scope.opts.cwd, bound);
|
|
337
|
+
const roleHolders = (role: string) => Object.keys(scope.config.roles).filter(peer => scope.config.roles[peer]!.includes(role) && scope.projectRosterAllows(scope.config.roster, peer, scope.config.pi.enabled)).sort();
|
|
338
|
+
const unsettled = scope.board.list().filter(task => ["proposed", "in_progress", "in_review", "changes_requested"].includes(task.state));
|
|
339
|
+
const tracked = hubGitSync(["ls-files", "--error-unmatch", "docs/roadmap.json"], { cwd: scope.opts.cwd, encoding: "utf8", timeout: 5000 }).status === 0;
|
|
340
|
+
void runSdlcCheck({
|
|
341
|
+
offline, repository, gh: checkGh,
|
|
342
|
+
running: { mode: scope.lifecycleConfig.mode, requiredChecks: scope.lifecycleConfig.requiredChecks, effectiveChecks: requiredChecksFor(scope.lifecycleConfig, repository) },
|
|
343
|
+
file: () => { const exists = existsSync(join(scope.opts.cwd, ".agenthub", "sdlc.toml")); return { present: exists, config: loadSdlc(scope.opts.cwd, VERSION) }; },
|
|
344
|
+
holders: { planner: roleHolders("planner"), reviewer: roleHolders("reviewer"), conductor: roleHolders("conductor") },
|
|
345
|
+
discover: run => discoverInitChecks(scope.opts.cwd, run),
|
|
346
|
+
securityScan: () => ({ configured: !!scope.lifecycleConfig.securityScan, counts: scope.tasks.securityScanCounts() }),
|
|
347
|
+
tasks: unsettled.map(task => { const pii = scope.tasks.isPii(task); return { id: task.id, state: task.state, title: pii ? "" : scope.tasks.publicTitle(task), pii, ...(task.refs.branch && !pii ? { branch: task.refs.branch } : {}), ...(task.sdlc && !pii ? { sdlc: { ...(task.sdlc.repo ? { repo: task.sdlc.repo } : {}), ...(task.sdlc.issue ? { issue: task.sdlc.issue } : {}), ...(task.sdlc.pr ? { pr: task.sdlc.pr } : {}), ...(task.sdlc.localHead ? { localHead: task.sdlc.localHead } : {}) } } : {}) }; }),
|
|
348
|
+
...(scope.board.milestones().length || tracked ? { roadmap: {
|
|
349
|
+
drift: () => scope.tasks.roadmapCheck(USER),
|
|
350
|
+
unplaced: () => scope.tasks.roadmapUnplaced(USER, {}, checkGh),
|
|
351
|
+
} } : {}),
|
|
352
|
+
}).then(report => reply({ ok: true, ...report }), error => reply({ ok: false, error: `lifecycle audit unavailable (${error instanceof Error ? error.name : "unknown error"}); run ahub sdlc status and retry` }));
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (msg.op !== "status" && msg.op !== "explain") return void reply({ ok: false, error: "unknown SDLC operation" });
|
|
356
|
+
const listed = msg.id === undefined ? scope.board.list().filter(task => task.state !== "backlog" && (task.sdlc || scope.lifecycleConfig.mode !== "off" || scope.lifecycleConfig.workflow === "gsd-lite")) : [scope.board.get(Number(msg.id))].filter((task): task is Task => !!task);
|
|
357
|
+
if (msg.id !== undefined && (!Number.isSafeInteger(msg.id) || msg.id <= 0 || !listed.length)) return void reply({ ok: false, error: "invalid lifecycle task id" });
|
|
358
|
+
// #1856 T1: a bare status lists the unsettled tasks and those of a release train not yet shipped; `all` keeps the historical first-100 slice, a task id is unchanged.
|
|
359
|
+
const unsettledOnly = msg.op === "status" && msg.id === undefined && msg.all !== true;
|
|
360
|
+
const openTrains = unsettledOnly ? new Set(scope.board.releases().filter(release => release.state !== "shipped" && release.state !== "dropped").map(release => release.id)) : undefined;
|
|
361
|
+
const selected = unsettledOnly ? listed.filter(task => ["proposed", "in_progress", "in_review", "changes_requested"].includes(task.state) || (task.release != null && openTrains!.has(task.release))) : listed;
|
|
362
|
+
void (async () => {
|
|
363
|
+
const rows = [];
|
|
364
|
+
for (const task of selected.slice(0, 100)) {
|
|
365
|
+
const status = await scope.tasks.lifecycleStatus(task.id, msg.id !== undefined);
|
|
366
|
+
const current = scope.board.get(task.id) ?? task;
|
|
367
|
+
rows.push({ id: task.id, title: scope.tasks.publicTitle(current), ...(scope.tasks.isPii(current) ? {} : { receipt: scope.tasks.publicView(current).sdlc }), ...status });
|
|
368
|
+
}
|
|
369
|
+
reply({ ok: true, mode: scope.lifecycleConfig.mode, rows, ...(scope.tasks.securityScanCounts() ? { securityScan: scope.tasks.securityScanCounts() } : {}), truncated: selected.length > 100, ...(unsettledOnly ? { unsettledOnly: true, hiddenSettled: listed.length - selected.length } : {}) });
|
|
370
|
+
})().catch(() => reply({ ok: false, error: "lifecycle readback unavailable" }));
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
}
|