@staix/agent-hub 0.50.0 → 0.52.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 +51 -0
- package/README.md +1 -1
- package/docs/adding-an-ai-tool.md +26 -4
- package/docs/agent-notes/README.md +1 -0
- package/docs/agent-notes/adapters.md +4 -3
- package/docs/agent-notes/budget.md +8 -2
- package/docs/agent-notes/daemon.md +13 -8
- package/docs/agent-notes/local-worker.md +3 -3
- package/docs/agent-notes/security-review.md +6 -5
- package/docs/agent-notes/tasks.md +10 -3
- package/docs/agent-notes/tests.md +4 -3
- package/docs/cooperbench.md +1 -1
- package/docs/design/adapters.md +21 -0
- package/docs/design/cli-output-inventory.md +165 -150
- package/docs/design/cli-output.md +4 -3
- package/docs/design/guidance-probes.md +1 -0
- package/docs/design/roadmap.md +3 -1
- package/docs/design/task-board.md +35 -0
- package/docs/dogfood.md +21 -3
- package/docs/events.md +4 -2
- package/docs/memory.md +5 -3
- package/docs/operations.md +259 -19
- package/docs/quickstart.md +29 -2
- package/docs/roadmap.json +20 -20
- package/docs/roadmap.md +2 -2
- package/docs/roles.md +1 -1
- package/docs/sdlc.md +29 -5
- package/docs/security.md +11 -5
- package/docs/specs/2026-09-19-agent-hub-design.md +44 -0
- package/docs/specs/2026-09-19-multi-project-design.md +4 -0
- package/docs/specs/2026-09-20-upgrade-recovery-design.md +17 -0
- package/docs/specs/mcp-endpoint.md +63 -0
- package/docs/verification/2026-11-29-agy-1.5.20.md +33 -0
- package/docs/verification/2026-11-29-claude-profile-hook.md +12 -0
- package/docs/verification/2026-11-29-idle-daemon-footprint.md +75 -0
- package/docs/verification/2026-11-29-kimi-281-reviewer-compat.md +38 -0
- package/docs/verification/2026-11-29-kimi-tui-281.md +12 -0
- package/docs/verification/2026-11-30-0.51.0.md +91 -0
- package/docs/verification/2026-11-30-account-switch-1806.md +445 -0
- package/docs/verification/2026-11-30-capability-listing-shape-1808.md +45 -0
- package/docs/verification/2026-11-30-upgrade-keep-1807.md +174 -0
- package/docs/verification/2026-12-01-1811-confirmation-receipt.md +19 -0
- package/docs/verification/2026-12-01-1811-orca-agent-list.md +20 -0
- package/docs/verification/2026-12-01-1811-orca-pane-key.md +21 -0
- package/docs/verification/2026-12-02-1819-claude-process-after-renewal.md +54 -0
- package/docs/verification/2026-12-02-agy-1.5.21.md +74 -0
- package/docs/verification/2026-12-02-claude-implementer-2.1.334.md +44 -0
- package/docs/verification/2026-12-02-cli-import-graph.md +33 -0
- package/docs/verification/2026-12-03-0.52.0.md +150 -0
- package/docs/verification/2026-12-03-codex-0173-reviewer-isolation.md +53 -0
- package/docs/verification/2026-12-03-codex-0173-reviewer-tool-call.md +34 -0
- package/docs/verification/2026-12-03-jcode-1.3.0.md +25 -0
- package/docs/verification/agy/README.md +17 -0
- package/docs/verification/agy/cli-surface.ts +68 -0
- package/docs/verification/agy/interactive-bridge.ts +92 -0
- package/docs/verification/agy/interactive-session.ts +131 -0
- package/docs/verification/agy/launcher-nonce.ts +215 -0
- package/docs/verification/agy/native-hooks.ts +210 -0
- package/docs/verification/agy/originals/agent-hub-681/cli-surface.ts +87 -0
- package/docs/verification/agy/originals/agent-hub-681/native-hooks-adapted.ts +91 -0
- package/docs/verification/agy/originals/agent-hub-681/tui-actual.ts +200 -0
- package/docs/verification/agy/originals/agent-hub-684/probe.ts +107 -0
- package/docs/verification/agy/originals.json +25 -0
- package/docs/verification/agy/permission-new-functions.ts +128 -0
- package/docs/verification/agy/run-probe.py +108 -0
- package/docs/verification/agy/runtime.ts +171 -0
- package/docs/verification/agy/tmux-helper-control.ts +6 -0
- package/docs/verification/agy/tmux-session.ts +235 -0
- package/docs/verified.json +87 -42
- package/package.json +3 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/compat.json +157 -0
- package/plugins/agent-hub/kimi-hook.js +1416 -24985
- package/plugins/agent-hub/server.js +17415 -32755
- package/scripts/check-docs.mjs +1 -1
- package/src/adapters/acp.ts +13 -13
- package/src/adapters/agy/definition.ts +9 -26
- package/src/adapters/agy/entry.ts +2 -0
- package/src/adapters/channel-peer.ts +3 -1
- package/src/adapters/claude-channel-evidence.ts +7 -3
- package/src/adapters/claude-channel.ts +38 -257
- package/src/adapters/claude-implementer.ts +3 -1
- package/src/adapters/codex-appserver.ts +77 -15
- package/src/adapters/compat.ts +78 -14
- package/src/adapters/configured-acp.ts +23 -163
- package/src/adapters/configured-adapter-policy.ts +160 -0
- package/src/adapters/configured-pull-entry.ts +53 -0
- package/src/adapters/configured-pull.ts +38 -0
- package/src/adapters/conformance/fakes/app-server.ts +9 -2
- package/src/adapters/declaration-catalog.ts +25 -0
- package/src/adapters/declaration-data.ts +342 -0
- package/src/adapters/declaration-resolution.ts +53 -0
- package/src/adapters/definitions/builtin-metadata.ts +62 -84
- package/src/adapters/definitions/jcode-launch.ts +13 -0
- package/src/adapters/definitions/native-adapter-policy.ts +390 -0
- package/src/adapters/definitions/native-cli-claude-launch.ts +6 -3
- package/src/adapters/definitions/native-cli-codex-launch.ts +2 -1
- package/src/adapters/definitions/native-cli-entry-claude.ts +17 -2
- package/src/adapters/definitions/native-cli-entry-codex.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-jcode.ts +6 -2
- package/src/adapters/definitions/native-cli-entry-kimi.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-pi.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-qwen.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-types.ts +12 -3
- package/src/adapters/definitions/native-cli-jcode-home-init.ts +1 -1
- package/src/adapters/definitions/native-cli-launch-common.ts +2 -2
- package/src/adapters/definitions/native-cli-preview-common.ts +1 -1
- package/src/adapters/definitions/native-cli-retained.ts +1 -1
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-configuration.ts +18 -0
- package/src/adapters/definitions/native-help.ts +24 -0
- package/src/adapters/definitions/native-launch-declarations.ts +34 -0
- package/src/adapters/definitions/native-launch-policy.ts +4 -0
- package/src/adapters/definitions/native-launch-settings.ts +72 -0
- package/src/adapters/definitions/native-light-cli.ts +18 -0
- package/src/adapters/definitions/native-light-preview.ts +10 -0
- package/src/adapters/definitions/native-wrapper-launch.ts +10 -0
- package/src/adapters/definitions/qwen.ts +6 -29
- package/src/adapters/definitions/reviewer-variants.ts +7 -8
- package/src/adapters/external-declarations.ts +31 -0
- package/src/adapters/external-modules.ts +4 -29
- package/src/adapters/jcode.ts +19 -12
- package/src/adapters/native-capabilities.ts +18 -8
- package/src/adapters/native-facts-hooks.ts +12 -0
- package/src/adapters/native-proof-ports.ts +1 -1
- package/src/adapters/presets.ts +136 -0
- package/src/adapters/qwen-dual.ts +2 -2
- package/src/adapters/registry-types.ts +3 -0
- package/src/adapters/registry.ts +20 -81
- package/src/adapters/reviewer-print.ts +26 -9
- package/src/adapters/role-eligibility.ts +2 -1
- package/src/cli/accounts-import.ts +72 -0
- package/src/cli/agents-latest-table.ts +88 -0
- package/src/cli/agents-latest.ts +22 -0
- package/src/cli/agents-output.ts +10 -0
- package/src/cli/agents-presets.ts +100 -0
- package/src/cli/agents.ts +1 -1
- package/src/cli/attention.ts +3 -2
- package/src/cli/autonomy-homes.ts +7 -2
- package/src/cli/autonomy-offline.ts +1 -1
- package/src/cli/bench.ts +1 -1
- package/src/cli/budget-renew-guidance.ts +129 -0
- package/src/cli/claude-homes.ts +9 -5
- package/src/cli/claude-profile-hook.ts +31 -11
- package/src/cli/command-context.ts +3 -0
- package/src/cli/command-table.ts +123 -0
- package/src/cli/commands/accounts.ts +8 -0
- package/src/cli/commands/agents.ts +18 -0
- package/src/cli/commands/answer.ts +28 -0
- package/src/cli/commands/ask.ts +17 -0
- package/src/cli/commands/autonomy.ts +83 -0
- package/src/cli/commands/backlog.ts +46 -0
- package/src/cli/commands/bench.ts +60 -0
- package/src/cli/commands/board.ts +48 -0
- package/src/cli/commands/broker.ts +9 -0
- package/src/cli/commands/budget.ts +96 -0
- package/src/cli/commands/capabilities.ts +12 -0
- package/src/cli/commands/check-path.ts +55 -0
- package/src/cli/commands/completion.ts +8 -0
- package/src/cli/commands/console.ts +12 -0
- package/src/cli/commands/daemon.ts +8 -0
- package/src/cli/commands/deliverables.ts +25 -0
- package/src/cli/commands/doctor.ts +249 -0
- package/src/cli/commands/down.ts +3 -0
- package/src/cli/commands/export.ts +15 -0
- package/src/cli/commands/facts.ts +15 -0
- package/src/cli/commands/goal.ts +22 -0
- package/src/cli/commands/guidance.ts +102 -0
- package/src/cli/commands/help.ts +17 -0
- package/src/cli/commands/host.ts +45 -0
- package/src/cli/commands/init.ts +121 -0
- package/src/cli/commands/instructed.ts +19 -0
- package/src/cli/commands/instruction-hook.ts +15 -0
- package/src/cli/commands/intake.ts +24 -0
- package/src/cli/commands/kill.ts +15 -0
- package/src/cli/commands/learn.ts +23 -0
- package/src/cli/commands/lineage.ts +30 -0
- package/src/cli/commands/logs.ts +21 -0
- package/src/cli/commands/manager.ts +15 -0
- package/src/cli/commands/memory.ts +21 -0
- package/src/cli/commands/model.ts +25 -0
- package/src/cli/commands/models.ts +40 -0
- package/src/cli/commands/native.ts +39 -0
- package/src/cli/commands/pause.ts +5 -0
- package/src/cli/commands/peer.ts +32 -0
- package/src/cli/commands/permission.ts +26 -0
- package/src/cli/commands/permit.ts +12 -0
- package/src/cli/commands/pet.ts +24 -0
- package/src/cli/commands/projects.ts +49 -0
- package/src/cli/commands/queue.ts +70 -0
- package/src/cli/commands/recovery-run.ts +13 -0
- package/src/cli/commands/recovery.ts +130 -0
- package/src/cli/commands/release.ts +23 -0
- package/src/cli/commands/releases.ts +91 -0
- package/src/cli/commands/remember.ts +6 -0
- package/src/cli/commands/report.ts +27 -0
- package/src/cli/commands/research.ts +53 -0
- package/src/cli/commands/reset.ts +89 -0
- package/src/cli/commands/restart.ts +5 -0
- package/src/cli/commands/results.ts +31 -0
- package/src/cli/commands/resume.ts +5 -0
- package/src/cli/commands/review.ts +24 -0
- package/src/cli/commands/roadmap.ts +21 -0
- package/src/cli/commands/role.ts +34 -0
- package/src/cli/commands/roles.ts +30 -0
- package/src/cli/commands/room.ts +14 -0
- package/src/cli/commands/roster.ts +48 -0
- package/src/cli/commands/route.ts +9 -0
- package/src/cli/commands/say.ts +21 -0
- package/src/cli/commands/schedule.ts +17 -0
- package/src/cli/commands/sdlc.ts +321 -0
- package/src/cli/commands/settings.ts +148 -0
- package/src/cli/commands/setup.ts +89 -0
- package/src/cli/commands/shared-refusals.ts +25 -0
- package/src/cli/commands/smoke.ts +44 -0
- package/src/cli/commands/source.ts +64 -0
- package/src/cli/commands/specs.ts +13 -0
- package/src/cli/commands/status.ts +28 -0
- package/src/cli/commands/stop.ts +17 -0
- package/src/cli/commands/structure.ts +60 -0
- package/src/cli/commands/study.ts +39 -0
- package/src/cli/commands/tail.ts +19 -0
- package/src/cli/commands/task.ts +114 -0
- package/src/cli/commands/title.ts +17 -0
- package/src/cli/commands/turns.ts +10 -0
- package/src/cli/commands/ui.ts +47 -0
- package/src/cli/commands/undo.ts +77 -0
- package/src/cli/commands/up.ts +39 -0
- package/src/cli/commands/upgrade.ts +5 -0
- package/src/cli/commands/usage.ts +33 -0
- package/src/cli/commands/version.ts +5 -0
- package/src/cli/commands/watch.ts +30 -0
- package/src/cli/commands/worktrees.ts +31 -0
- package/src/cli/conductor-recovery.ts +1 -1
- package/src/cli/console-state.ts +5 -138
- package/src/cli/console-versions.ts +1 -1
- package/src/cli/facts-hook.ts +11 -4
- package/src/cli/help.ts +44 -20
- package/src/cli/identity.ts +27 -4
- package/src/cli/init-prompt.ts +1 -1
- package/src/cli/init-settings.ts +4 -35
- package/src/cli/init.ts +1 -1
- package/src/cli/json-text-spans.ts +57 -0
- package/src/cli/launch-check.ts +156 -0
- package/src/cli/launch.ts +19 -70
- package/src/cli/light-dispatch.ts +29 -0
- package/src/cli/main.js +8 -1
- package/src/cli/main.ts +257 -2799
- package/src/cli/memory.ts +1 -1
- package/src/cli/orca-probe.ts +119 -0
- package/src/cli/output.ts +45 -3
- package/src/cli/preview.ts +11 -6
- package/src/cli/recovery-launch.ts +1 -1
- package/src/cli/recovery-version-preflight.ts +28 -9
- package/src/cli/replace-process.ts +22 -0
- package/src/cli/report-layout.ts +142 -0
- package/src/cli/roadmap-usage.ts +16 -0
- package/src/cli/roadmap.ts +3 -16
- package/src/cli/sdlc-doctor.ts +27 -0
- package/src/cli/sdlc-output.ts +55 -1
- package/src/cli/setup-homes.ts +2 -2
- package/src/cli/start-agents-run.ts +85 -7
- package/src/cli/start-check.ts +28 -0
- package/src/cli/statusline-tee.ts +25 -4
- package/src/cli/terminal-recovery.ts +53 -10
- package/src/cli/upgrade-interactive.ts +1 -0
- package/src/cli/upgrade-runtime.ts +12 -1
- package/src/cli/upgrade.ts +4 -15
- package/src/cli/warn-line.ts +1 -1
- package/src/hub/accounts.ts +148 -0
- package/src/hub/addons.ts +20 -0
- package/src/hub/agent-drift.ts +2 -1
- package/src/hub/budget-projection.ts +39 -7
- package/src/hub/budget.ts +231 -16
- package/src/hub/channel-project.ts +3 -3
- package/src/hub/ci-watch.ts +311 -79
- package/src/hub/conductor-peer.ts +24 -0
- package/src/hub/conductor.ts +2 -21
- package/src/hub/config-apply.ts +25 -14
- package/src/hub/config-edit.ts +1 -1
- package/src/hub/config-tier.ts +2 -0
- package/src/hub/config.ts +535 -0
- package/src/hub/control-client.ts +49 -1
- package/src/hub/daemon.ts +492 -569
- package/src/hub/delivery-public.ts +11 -0
- package/src/hub/events.ts +3 -0
- package/src/hub/home-tag.ts +12 -0
- package/src/hub/host.ts +217 -0
- package/src/hub/hub-check.ts +125 -0
- package/src/hub/hub-tools.ts +2 -1
- package/src/hub/instance-budget.ts +2 -2
- package/src/hub/instance-config.ts +15 -126
- package/src/hub/instances.ts +22 -6
- package/src/hub/instruction-receipt.ts +2 -2
- package/src/hub/kimi-usage.ts +38 -11
- package/src/hub/lifecycle.ts +86 -4
- package/src/hub/mcp-bridge-core.ts +98 -0
- package/src/hub/mcp-channel-push.ts +20 -0
- package/src/hub/mcp-endpoint-serve.ts +178 -0
- package/src/hub/mcp-endpoint.ts +226 -0
- package/src/hub/mcp-tool-call.ts +181 -0
- package/src/hub/operational-settings.ts +2 -0
- package/src/hub/orca-env.ts +6 -0
- package/src/hub/orca-state.ts +84 -0
- package/src/hub/path-policy.ts +1 -1
- package/src/hub/peers.ts +5 -1
- package/src/hub/permission-mode.ts +5 -41
- package/src/hub/permission-paths.ts +41 -0
- package/src/hub/project.ts +20 -0
- package/src/hub/protocol-window.ts +58 -0
- package/src/hub/quota-origin.ts +20 -0
- package/src/hub/recovery-policy.ts +1 -1
- package/src/hub/registry.ts +36 -2
- package/src/hub/releases-inventory.ts +198 -0
- package/src/hub/report.ts +1 -1
- package/src/hub/research.ts +1 -1
- package/src/hub/review-brief.ts +47 -2
- package/src/hub/roster.ts +6 -3
- package/src/hub/routing.ts +9 -2
- package/src/hub/runtime-capture-prune.ts +25 -3
- package/src/hub/runtime-prune-health.ts +8 -1
- package/src/hub/sdlc-check.ts +205 -0
- package/src/hub/sdlc-release-authorization.ts +42 -21
- package/src/hub/sdlc-release-diagnostics.ts +5 -0
- package/src/hub/sdlc-release-policy.ts +21 -7
- package/src/hub/sdlc-release.ts +80 -20
- package/src/hub/sdlc-sync.ts +146 -0
- package/src/hub/sdlc.ts +38 -5
- package/src/hub/settings.ts +7 -4
- package/src/hub/start-agents.ts +1 -1
- package/src/hub/start-mode.ts +11 -4
- package/src/hub/structure-budget.ts +131 -0
- package/src/hub/structure-scan.ts +149 -0
- package/src/hub/tasks-experiment.ts +455 -0
- package/src/hub/tasks-guidance.ts +606 -0
- package/src/hub/tasks-roadmap-plan.ts +419 -0
- package/src/hub/tasks-roadmap.ts +491 -0
- package/src/hub/tasks-study.ts +661 -0
- package/src/hub/tasks-survey.ts +192 -0
- package/src/hub/tasks.ts +457 -2584
- package/src/hub/terminal-open.ts +5 -3
- package/src/hub/tooling.ts +3 -19
- package/src/hub/usage-rollup.ts +9 -3
- package/src/local/tools.ts +5 -0
- package/src/ui/index.html +1 -1
- package/src/ui/needs.ts +17 -5
- package/src/ui/peer-palette.ts +2 -4
- package/src/ui/plugin.ts +1 -1
- package/templates/presets/agents.json +60 -0
- package/templates/presets/confirmation-matrix.json +8 -8
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// #1830 S4a: the advisor survey methods of `Tasks`, moved whole. `Tasks` builds one `SurveyDomain` with its deps and an explicit host (the callbacks the moved bodies reach), keeps a one-line
|
|
2
|
+
// delegating method for each member it or the other domain still uses, and stays the only board writer: every board write here runs inside a `Tasks` callback or a host
|
|
3
|
+
// method. No module-level state: the counters and flags live on the instance. Never imported by adapters, tools or the CLI.
|
|
4
|
+
import { SURVEY_FOCUS, SURVEY_LIMITS, parseSurveyFindings, parseSurveyVetDecisions, publicSurveyFinding, surveyBrief, surveyFindingKey, surveyObject, surveyInputAt, surveyInputProblem, type SurveyFinding, type SurveyFocus, type SurveyPass } from "./advisor-survey.ts";
|
|
5
|
+
import { type ConsideredEntry } from "./considered-findings.ts";
|
|
6
|
+
import type { StoredSurvey, SurveyPreparedCard } from "./board.ts";
|
|
7
|
+
import { type GitHubSource } from "./github-import.ts";
|
|
8
|
+
import { type ReviewFinding } from "./review-findings.ts";
|
|
9
|
+
import { HOST_ROADMAP_DRAFT, type Task, type TaskPlan, type TaskRefs } from "./board.ts";
|
|
10
|
+
import { USER, type PeerId } from "./envelope.ts";
|
|
11
|
+
import type { PiiVerdict } from "./inference.ts";
|
|
12
|
+
import { detectSignals } from "./routing.ts";
|
|
13
|
+
import { TaskRepositories } from "./task-repository.ts";
|
|
14
|
+
import { PreEffectToolRefusal } from "./tool-refusal.ts";
|
|
15
|
+
import type { TasksDeps } from "./tasks.ts";
|
|
16
|
+
|
|
17
|
+
/** What the moved methods call back into `Tasks` for: each member is the `Tasks` member of that name, unchanged. */
|
|
18
|
+
export interface SurveyHost {
|
|
19
|
+
configuredManualConductor(by: PeerId): boolean;
|
|
20
|
+
consideredBefore(task: Task, finding: Pick<ReviewFinding, "id" | "pass" | "path"> | SurveyFinding, ref?: string, readChanges?: (entryRef?: string) => string[] | undefined): { rejectedBefore: boolean; change: "none" | "unchanged" | "changed" | "unknown"; suppressed: boolean };
|
|
21
|
+
consideredBrief(repo: string, ref?: string, scope?: readonly string[]): string;
|
|
22
|
+
consideredChanges(repo: string, ref?: string): (entryRef?: string) => string[] | undefined;
|
|
23
|
+
consideredDetails(repo: string, id: string, pass: SurveyPass, ref?: string, readChanges?: (entryRef?: string) => string[] | undefined): { complete: boolean; change: "unchanged" | "changed" | "unknown"; items: { id: string; reason?: string; change: "unchanged" | "changed" | "unknown"; withheld?: true }[] };
|
|
24
|
+
readonly incomingBacklog: Set<number>;
|
|
25
|
+
isConfiguredPlanner(peer: PeerId): boolean;
|
|
26
|
+
readonly isPii: (task: Pick<Task, "signals">) => boolean;
|
|
27
|
+
need(id: unknown, open?: boolean, preEffect?: boolean, allowBacklog?: boolean): Task;
|
|
28
|
+
observerExcluded(by: PeerId): boolean;
|
|
29
|
+
propose(by: PeerId, input: { title?: string; detail?: string; class?: string; role?: unknown; reason?: unknown; refs?: TaskRefs; plan?: TaskPlan; owner?: PeerId; after?: unknown; urgent?: unknown; needs_network?: unknown; needs_worktree?: unknown; backlog?: unknown; draft?: unknown; goal?: unknown; [HOST_ROADMAP_DRAFT]?: unknown }, external?: GitHubSource, created?: () => void, fence?: () => string | undefined, hostCreatedHook?: (task: Task) => void): Promise<Task>;
|
|
30
|
+
readonly publicMetadataText: (text: string) => boolean;
|
|
31
|
+
releaseNotice(line: string, run?: () => unknown): void;
|
|
32
|
+
readonly repositories: TaskRepositories;
|
|
33
|
+
requestCheck(by: PeerId, fence?: () => string | undefined): () => void;
|
|
34
|
+
reviewObserverTurn(by: PeerId, task?: number): boolean;
|
|
35
|
+
screenCall(text: string): Promise<PiiVerdict>;
|
|
36
|
+
readonly screenOn: () => boolean;
|
|
37
|
+
signalsFor(task: Pick<Task, "title" | "detail" | "refs"> & { plan?: TaskPlan }, routing?: ReturnType<TasksDeps["routing"]>): ReturnType<typeof detectSignals>;
|
|
38
|
+
studyHold(): string | undefined;
|
|
39
|
+
studyNumber(value: unknown, field: string): number;
|
|
40
|
+
studyWrite<T>(write: () => Promise<T>): Promise<T>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class SurveyDomain {
|
|
44
|
+
constructor(private readonly d: TasksDeps, private readonly host: SurveyHost) {}
|
|
45
|
+
|
|
46
|
+
private surveyToolInput<T>(command: "start" | "report", field: string, rule: string, read: () => T): T {
|
|
47
|
+
try { return surveyInputAt(field, rule, read); } catch (error) {
|
|
48
|
+
const problem = surveyInputProblem(error) ?? { field, rule };
|
|
49
|
+
const next = command === "report" ? "fix that field and resend hub_survey_report; tool description lists shape"
|
|
50
|
+
: "fix that field and resend ahub sdlc survey start; ahub help sdlc survey lists shape";
|
|
51
|
+
throw new PreEffectToolRefusal(`${problem.field}: ${problem.rule}; ${next}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private surveyStarting = false;
|
|
56
|
+
|
|
57
|
+
private surveyAdmit(by: PeerId, check: () => void): void {
|
|
58
|
+
check();
|
|
59
|
+
if ((this.d.sdlc?.config().mode ?? "off") === "off") throw new PreEffectToolRefusal("advisor surveys require lifecycle advise or enforce");
|
|
60
|
+
if (this.d.privateTurn?.(by) || this.d.reviewOnly?.(by) || this.d.requestAuthority?.(by)) throw new PreEffectToolRefusal("advisor surveys are unavailable in private or child sessions");
|
|
61
|
+
const held = this.host.studyHold(); if (held) throw new PreEffectToolRefusal(held);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private surveyTask(by: PeerId, id: unknown, write = false): { task: Task; survey: StoredSurvey } {
|
|
65
|
+
const task = this.host.need(this.host.studyNumber(id, "survey task")), survey = this.d.board.surveyOfTask(task.id, task.created);
|
|
66
|
+
if (!survey || survey.repo !== this.host.repositories.scope({}).key || this.host.repositories.scope(task.refs).key !== survey.repo) throw new PreEffectToolRefusal("survey is unavailable in this project");
|
|
67
|
+
const owner = task.owner === by && this.d.bus.isRostered(by) && this.host.isConfiguredPlanner(by);
|
|
68
|
+
const reviewer = task.reviewer === by && this.d.bus.isRostered(by) && !!this.d.roles?.[by]?.includes("reviewer");
|
|
69
|
+
if (write ? !owner || task.state !== "in_progress" : by !== USER && !owner && !reviewer && !(this.host.configuredManualConductor(by) && this.d.bus.isRostered(by)))
|
|
70
|
+
throw new PreEffectToolRefusal("survey reporting requires its assigned in-progress planner; readback requires its owner, reviewer, person or current conductor");
|
|
71
|
+
return { task, survey };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
surveyPrivate(task: Task, by?: PeerId): boolean {
|
|
75
|
+
return this.host.isPii(task) || task.signals.includes("pii") || task.signals.includes("pii_path") || !!(by && this.d.privateTurn?.(by));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The existing task routing chooses one planner; no worker, scanner, issue or fix is launched. */
|
|
79
|
+
async surveyStart(by: PeerId, input: unknown = {}, fence?: () => string | undefined): Promise<{ task: number; survey: number; ref: string; focus?: SurveyFocus }> {
|
|
80
|
+
const fields = this.surveyToolInput("start", "start", "must be a closed object with optional focus", () => surveyObject(input, ["focus"])), focus = fields.focus;
|
|
81
|
+
if (focus !== undefined && (typeof focus !== "string" || !(SURVEY_FOCUS as readonly string[]).includes(focus))) this.surveyToolInput("start", "focus", "must be bugs, tests, debt, deps, dx or docs", () => { throw new Error("invalid bounded survey data"); });
|
|
82
|
+
const check = this.host.requestCheck(by, fence), authority = () => {
|
|
83
|
+
this.surveyAdmit(by, check);
|
|
84
|
+
if (by !== USER && !(this.host.configuredManualConductor(by) && this.d.bus.isRostered(by))) throw new PreEffectToolRefusal("only the person or current unique conductor may start a survey");
|
|
85
|
+
};
|
|
86
|
+
authority();
|
|
87
|
+
if (this.host.observerExcluded(by) || this.host.reviewObserverTurn(by)) throw new PreEffectToolRefusal("survey start is unavailable from observer material");
|
|
88
|
+
if (this.surveyStarting) throw new PreEffectToolRefusal("a survey is already starting");
|
|
89
|
+
const repo = this.host.repositories.scope({}).key, source = this.d.auditSource;
|
|
90
|
+
if (!source) throw new PreEffectToolRefusal("survey source unavailable; start the hub from the project checkout");
|
|
91
|
+
const ref = source.head();
|
|
92
|
+
if (!ref || !/^[a-f0-9]{40}$/.test(ref) || source.resolve(ref) !== ref) throw new PreEffectToolRefusal("survey commit unavailable; select a checkout with a readable commit");
|
|
93
|
+
if (this.d.board.surveyOpen(repo)) throw new PreEffectToolRefusal("a survey is already open; finish or cancel it first");
|
|
94
|
+
const brief = `${surveyBrief({ ...(focus === undefined ? {} : { focus: focus as SurveyFocus }) })}\nPinned source commit: ${ref}\nRead this exact commit, including during vetting. Findings are declarations, never host proof of independent source review.\nSubmit candidates with hub_survey_report {id: <this task>, findings: [...]}; explicit vet decisions use vet: [...].\n${this.host.consideredBrief(repo, ref)}`;
|
|
95
|
+
if (!this.host.publicMetadataText(brief)) throw new PreEffectToolRefusal("survey brief is not public");
|
|
96
|
+
this.surveyStarting = true;
|
|
97
|
+
try { return await this.host.studyWrite(async () => {
|
|
98
|
+
const guard = () => { authority(); if (this.d.auditSource !== source || this.host.repositories.scope({}).key !== repo || this.d.board.surveyOpen(repo)) throw new PreEffectToolRefusal("survey source or open-survey admission changed"); };
|
|
99
|
+
guard();
|
|
100
|
+
let surveyID: number | undefined;
|
|
101
|
+
const task = await this.host.propose(by, { title: `Advisor survey${focus ? ` (${focus})` : ""} at ${ref.slice(0, 12)}`, detail: brief, class: "plan" }, undefined, undefined,
|
|
102
|
+
() => { guard(); return undefined; }, created => {
|
|
103
|
+
if (this.surveyPrivate(created, by)) throw new PreEffectToolRefusal("survey brief privacy was not cleared");
|
|
104
|
+
surveyID = this.d.board.surveyCreate({ task: created.id, taskCreated: created.created, repo, ref, ...(focus === undefined ? {} : { focus: focus as SurveyFocus }), by, at: this.d.now?.() ?? Date.now() });
|
|
105
|
+
});
|
|
106
|
+
return { task: task.id, survey: surveyID!, ref, ...(focus === undefined ? {} : { focus: focus as SurveyFocus }) };
|
|
107
|
+
}); } finally { this.surveyStarting = false; }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
surveyShow(by: PeerId, id: unknown) {
|
|
111
|
+
const check = this.host.requestCheck(by); this.surveyAdmit(by, check);
|
|
112
|
+
const { task, survey } = this.surveyTask(by, id);
|
|
113
|
+
if (this.surveyPrivate(task, by)) return { task: task.id, status: "private" as const };
|
|
114
|
+
const revision = this.d.board.statusRevision(), policy = JSON.stringify([this.d.roles, this.d.routing(), this.d.piiPaths]);
|
|
115
|
+
const full = by === USER || this.d.bus.isRostered(by) && (task.owner === by && this.host.isConfiguredPlanner(by) || task.reviewer === by && !!this.d.roles?.[by]?.includes("reviewer"));
|
|
116
|
+
const stored = this.d.board.surveyFindings(survey.id), changes = this.host.consideredChanges(survey.repo, survey.ref);
|
|
117
|
+
if (stored.some(row => !this.host.publicMetadataText(JSON.stringify(row.finding)) || this.host.signalsFor({ title: row.finding.id, detail: JSON.stringify(row.finding), refs: { paths: row.finding.paths } }).some(signal => signal === "pii" || signal === "pii_path"))) return { task: task.id, status: "private" as const };
|
|
118
|
+
const items = stored.map(row => {
|
|
119
|
+
const finding = full ? row.finding : publicSurveyFinding(row.finding), before = this.host.consideredBefore(task, row.finding, survey.ref, changes);
|
|
120
|
+
const details = this.host.consideredDetails(survey.repo, row.finding.id, row.finding.pass, survey.ref, changes);
|
|
121
|
+
return { ...finding, ...(row.decision ? { verdict: row.decision.verdict } : {}), ...before, rejected: details.items, rejectedComplete: details.complete };
|
|
122
|
+
});
|
|
123
|
+
this.surveyAdmit(by, check);
|
|
124
|
+
const now = this.surveyTask(by, id);
|
|
125
|
+
if (this.surveyPrivate(now.task, by)) return { task: task.id, status: "private" as const };
|
|
126
|
+
if (this.d.board.statusRevision() !== revision || now.task.history.length !== task.history.length || JSON.stringify([this.d.roles, this.d.routing(), this.d.piiPaths]) !== policy) throw new PreEffectToolRefusal("survey changed during readback; reload before reading");
|
|
127
|
+
return { task: task.id, survey: survey.id, ref: survey.ref, ...(survey.focus ? { focus: survey.focus } : {}), status: "available" as const, items };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async surveyReport(by: PeerId, input: unknown, fence?: () => string | undefined) {
|
|
131
|
+
const fields = this.surveyToolInput("report", "report", "must be a closed object with id and findings, vet or show", () => surveyObject(input, ["id", "findings", "vet", "show"]));
|
|
132
|
+
this.surveyToolInput("report", "id", "must be a positive integer survey task id", () => { if (!Number.isSafeInteger(fields.id) || (fields.id as number) < 1) throw new Error("invalid bounded survey data"); });
|
|
133
|
+
this.surveyToolInput("report", "show", "must be true for read-only show and cannot include findings or vet decisions", () => {
|
|
134
|
+
if (fields.show !== undefined && fields.show !== true || fields.show && (fields.findings !== undefined || fields.vet !== undefined)) throw new Error("invalid bounded survey data");
|
|
135
|
+
});
|
|
136
|
+
if (fields.show) { this.host.requestCheck(by, fence)(); return this.surveyShow(by, fields.id); }
|
|
137
|
+
const findings = fields.findings === undefined ? [] : this.surveyToolInput("report", "findings", "must match the documented finding array", () => parseSurveyFindings(fields.findings));
|
|
138
|
+
const decisions = fields.vet === undefined ? [] : this.surveyToolInput("report", "vet", "must match the documented vet array", () => parseSurveyVetDecisions(fields.vet));
|
|
139
|
+
const check = this.host.requestCheck(by, fence), guard = () => { this.surveyAdmit(by, check); return this.surveyTask(by, fields.id, true); };
|
|
140
|
+
const initial = guard();
|
|
141
|
+
if (this.surveyPrivate(initial.task, by) || this.host.observerExcluded(by) || this.host.reviewObserverTurn(by)) throw new PreEffectToolRefusal("survey writes unavailable during private or observer work");
|
|
142
|
+
if (!findings.length && !decisions.length) throw new PreEffectToolRefusal("report: needs findings or explicit vet decisions; fix that field and resend hub_survey_report; tool description lists shape");
|
|
143
|
+
const observerExcluded = this.host.observerExcluded(by); // Capture before any awaited screen; never forward observer material.
|
|
144
|
+
if (observerExcluded) throw new PreEffectToolRefusal("survey observer input is unavailable");
|
|
145
|
+
return this.host.studyWrite(async () => {
|
|
146
|
+
const { task, survey } = guard(), boardRevision = this.d.board.statusRevision(), policy = JSON.stringify([this.d.sdlc?.config().mode, this.d.roles, this.d.routing(), this.d.piiPaths]);
|
|
147
|
+
const current = () => {
|
|
148
|
+
const now = guard();
|
|
149
|
+
if (now.task.created !== task.created || now.task.history.length !== task.history.length || now.task.owner !== task.owner || this.surveyPrivate(now.task, by)
|
|
150
|
+
|| this.d.board.statusRevision() !== boardRevision || JSON.stringify([this.d.sdlc?.config().mode, this.d.roles, this.d.routing(), this.d.piiPaths]) !== policy) throw new PreEffectToolRefusal("survey authority, privacy or policy changed; reload before reporting");
|
|
151
|
+
};
|
|
152
|
+
const existing = this.d.board.surveyFindings(survey.id), merged = new Map(existing.map(row => [row.finding.id, row.finding]));
|
|
153
|
+
for (const finding of findings) { const prior = merged.get(finding.id); if (prior && JSON.stringify(prior) !== JSON.stringify(finding)) throw new PreEffectToolRefusal("findings[].id: survey candidate id already records different content; fix that field and resend hub_survey_report; tool description lists shape"); merged.set(finding.id, finding); }
|
|
154
|
+
const text = JSON.stringify({ findings: this.surveyToolInput("report", "findings", "combined findings must remain within the documented bounds", () => parseSurveyFindings([...merged.values()])), decisions });
|
|
155
|
+
if (!this.host.publicMetadataText(text)) throw new PreEffectToolRefusal("survey metadata was not cleared as public");
|
|
156
|
+
if (this.host.screenOn() && (await this.host.screenCall(text)).label !== "clear") throw new PreEffectToolRefusal("survey metadata privacy screening was unavailable or refused");
|
|
157
|
+
current();
|
|
158
|
+
const changes = this.host.consideredChanges(survey.repo, survey.ref);
|
|
159
|
+
const cards: SurveyPreparedCard[] = [], rejections: ConsideredEntry[] = [], reconsiderations: ConsideredEntry[] = [];
|
|
160
|
+
const items: { id: string; rejectedBefore: boolean; change: "none" | "unchanged" | "changed" | "unknown"; suppressed: boolean }[] = [];
|
|
161
|
+
for (const decision of decisions) {
|
|
162
|
+
const finding = merged.get(decision.id); if (!finding) throw new PreEffectToolRefusal("vet[].id: vet decision names an unknown survey candidate; fix that field and resend hub_survey_report; tool description lists shape");
|
|
163
|
+
const before = this.host.consideredBefore(task, finding, survey.ref, changes); items.push({ id: finding.id, ...before });
|
|
164
|
+
const entry = (reason: string): ConsideredEntry => ({ repo: survey.repo, id: finding.id, pass: finding.pass, paths: finding.paths, reason, ref: survey.ref,
|
|
165
|
+
source: { task: task.id, created: task.created, kind: "survey" }, ...(finding.pass === "security" ? { withheld: true } : {}) });
|
|
166
|
+
if (decision.verdict === "rejected") { rejections.push(entry(decision.reason!)); continue; }
|
|
167
|
+
if (before.suppressed && !decision.reason) continue;
|
|
168
|
+
if (before.rejectedBefore && decision.reason) reconsiderations.push(entry(decision.reason));
|
|
169
|
+
const key = surveyFindingKey(survey.repo, finding.pass, finding.id), security = finding.pass === "security";
|
|
170
|
+
const history = this.d.board.surveyCardHistory(key), reopens = history.active ? undefined : history.closed;
|
|
171
|
+
current();
|
|
172
|
+
const reopenReason = security ? "explicit current vet; security details remain in the authorized survey"
|
|
173
|
+
: decision.reason ?? (before.change === "changed" ? "affected paths changed since the recorded rejection" : "explicit current vet; no applicable rejected finding remains");
|
|
174
|
+
const reopening = reopens === undefined ? {} : { reopens, reopenReason };
|
|
175
|
+
const draft = { title: security ? `Survey security finding ${finding.id}` : `Survey ${finding.confidence}: ${finding.id}`,
|
|
176
|
+
detail: `${key}\nSource survey task ${task.id} at ${survey.ref}.\n${finding.confidence === "low" ? "Read-only investigation. Do not edit files or execute a fix." : "Prepare a backlog plan. Do not execute a fix."}${security ? "\nSecurity details withheld; read the source survey with authorized task access." : `\nEvidence: ${finding.evidence}\nImpact: ${finding.impact}\nEffort: ${finding.effort}\nRisk: ${finding.risk}\nFix sketch: ${finding.fix_sketch}`}${reopens === undefined ? "" : `\nReopened from hub task ${reopens}: ${reopenReason}`}`,
|
|
177
|
+
refs: security ? {} : { paths: finding.paths } };
|
|
178
|
+
if (Buffer.byteLength(draft.detail) > SURVEY_LIMITS.cardBytes) throw new PreEffectToolRefusal("survey card exceeds its detail bound; shorten the finding or reconsideration reason");
|
|
179
|
+
const signals = this.host.signalsFor(draft);
|
|
180
|
+
if (this.host.isPii({ signals }) || signals.includes("pii") || signals.includes("pii_path") || !this.host.publicMetadataText(JSON.stringify(draft))) throw new PreEffectToolRefusal("survey candidate card is not public");
|
|
181
|
+
if (this.host.screenOn() && (await this.host.screenCall(JSON.stringify(draft))).label !== "clear") throw new PreEffectToolRefusal("survey card privacy screening was unavailable or refused");
|
|
182
|
+
current(); cards.push({ id: finding.id, key, ...draft, class: finding.confidence === "low" ? "triage" : "plan", signals, ...reopening });
|
|
183
|
+
}
|
|
184
|
+
current();
|
|
185
|
+
const result = this.d.board.surveyApply(survey.id, { findings, decisions, by, at: this.d.now?.() ?? Date.now(), cards, rejections, reconsiderations },
|
|
186
|
+
{ boardRevision, taskCreated: task.created, taskFlowRevision: task.history.length, owner: task.owner! });
|
|
187
|
+
for (const id of result.createdIDs) this.host.incomingBacklog.add(id);
|
|
188
|
+
this.host.releaseNotice(`survey task ${task.id}: ${result.createdIDs.length} backlog candidates created`);
|
|
189
|
+
return { task: task.id, survey: survey.id, status: "recorded" as const, ...result, items };
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|