@staix/agent-hub 0.46.1 → 0.47.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 +79 -0
- package/README.md +8 -4
- package/docs/adding-an-ai-tool.md +20 -4
- package/docs/agent-notes/adapters.md +3 -3
- package/docs/agent-notes/benchmarks.md +7 -1
- package/docs/agent-notes/daemon.md +5 -4
- package/docs/agent-notes/tasks.md +4 -2
- package/docs/agent-notes/tests.md +3 -0
- package/docs/contracts/companion-cli-v1.json +3 -0
- package/docs/data-policy.md +9 -0
- package/docs/design/adapters.md +14 -0
- package/docs/design/cli-output-inventory.md +362 -0
- package/docs/design/cli-output.md +42 -1
- package/docs/design/execution-reference.md +5 -2
- package/docs/design/guidance-probes.md +2 -2
- package/docs/design/refusal-inventory.md +26 -0
- package/docs/design/roadmap.md +4 -0
- package/docs/design/task-board.md +17 -1
- package/docs/dogfood.md +26 -10
- package/docs/events.md +9 -0
- package/docs/friction.md +46 -0
- package/docs/memory.md +35 -3
- package/docs/operations.md +63 -15
- package/docs/profiles.md +1 -0
- package/docs/quickstart.md +8 -2
- package/docs/roles.md +6 -0
- package/docs/sdlc.md +44 -1
- package/docs/security.md +16 -7
- package/docs/specs/2026-09-19-agent-hub-design.md +17 -0
- package/docs/specs/2026-09-19-multi-project-design.md +7 -1
- package/docs/verification/2026-11-25-agy-1.5.16.md +31 -0
- package/docs/verification/2026-11-25-claude-implementer-2.1.332.md +47 -0
- package/docs/verification/2026-11-25-codex-0172-reviewer-isolation.md +47 -0
- package/docs/verification/2026-11-25-kimi-272-reviewer-compat.md +38 -0
- package/docs/verification/2026-11-25-kimi-tui-272.md +14 -0
- package/docs/verification/2026-11-25-pi-160-compat.md +40 -0
- package/docs/verification/2026-11-26-0.47.0.md +43 -0
- package/docs/verification/2026-11-26-codex-0172-reviewer-tool-call.md +29 -0
- package/docs/verification/dogfood/2026-11-24.md +2829 -0
- package/docs/verification/pi-160-model-free.ts +57 -0
- package/docs/verification/pi-160-native.mjs +21 -0
- package/docs/verified.json +43 -31
- package/package.json +2 -2
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +579 -126
- package/plugins/agent-hub/server.js +668 -138
- package/src/adapters/acp.ts +5 -0
- package/src/adapters/channel-peer.ts +7 -0
- package/src/adapters/claude-print-child.ts +27 -5
- package/src/adapters/codex-appserver.ts +9 -0
- package/src/adapters/compat.ts +12 -11
- package/src/adapters/configured-acp.ts +45 -2
- package/src/adapters/configured-print.ts +163 -0
- package/src/adapters/conformance/index.ts +1 -0
- package/src/adapters/conformance/print.ts +57 -0
- package/src/adapters/definitions/native-activity.ts +57 -0
- package/src/adapters/definitions/native-factories.ts +4 -2
- package/src/adapters/jcode.ts +10 -2
- package/src/adapters/local-worker.ts +2 -0
- package/src/adapters/registry-types.ts +5 -3
- package/src/adapters/role-eligibility.ts +5 -0
- package/src/cli/bench.ts +2 -1
- package/src/cli/broker.ts +2 -1
- package/src/cli/capabilities-output.ts +10 -14
- package/src/cli/configured-acp-entry.ts +10 -2
- package/src/cli/console-state.ts +25 -5
- package/src/cli/error-format.ts +2 -0
- package/src/cli/guidance.ts +1 -1
- package/src/cli/handoff-output.ts +20 -17
- package/src/cli/help.ts +78 -40
- package/src/cli/init-settings.ts +15 -0
- package/src/cli/intake-output.ts +13 -13
- package/src/cli/launch.ts +3 -2
- package/src/cli/learn-output.ts +40 -21
- package/src/cli/main.ts +148 -77
- package/src/cli/memory.ts +47 -2
- package/src/cli/output.ts +54 -31
- package/src/cli/roadmap.ts +2 -2
- package/src/cli/room-output.ts +71 -0
- package/src/cli/room.ts +19 -33
- package/src/cli/schedule-output.ts +20 -19
- package/src/cli/sdlc-output.ts +188 -170
- package/src/cli/source-output.ts +17 -14
- package/src/cli/specs.ts +13 -13
- package/src/cli/study-output.ts +66 -69
- package/src/cli/task-output.ts +106 -158
- package/src/cli/terminal-recovery.ts +2 -1
- package/src/cli/upgrade-runtime.ts +2 -1
- package/src/cli/warn-line.ts +18 -0
- package/src/cli/worktrees-output.ts +25 -23
- package/src/hub/audit-source.ts +45 -0
- package/src/hub/board.ts +141 -5
- package/src/hub/bus.ts +13 -2
- package/src/hub/config-apply.ts +14 -1
- package/src/hub/config-trust.ts +1 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +371 -45
- package/src/hub/handoff.ts +5 -1
- package/src/hub/hub-tools.ts +23 -5
- package/src/hub/instance-config.ts +3 -3
- package/src/hub/learn-followup.ts +103 -0
- package/src/hub/learning.ts +63 -1
- package/src/hub/manager.ts +15 -1
- package/src/hub/memory-policy.ts +2 -1
- package/src/hub/memory-review.ts +217 -0
- package/src/hub/peer-activity.ts +37 -0
- package/src/hub/peers.ts +3 -0
- package/src/hub/project-move.ts +258 -0
- package/src/hub/registry.ts +16 -5
- package/src/hub/restart.ts +7 -0
- package/src/hub/review-brief.ts +8 -4
- package/src/hub/review-checkout.ts +26 -0
- package/src/hub/review-findings.ts +6 -3
- package/src/hub/risk-tier.ts +129 -0
- package/src/hub/roadmap-check.ts +1 -0
- package/src/hub/routing.ts +3 -1
- package/src/hub/sdlc-merge.ts +9 -0
- package/src/hub/sdlc-metrics.ts +24 -1
- package/src/hub/sdlc-queue.ts +1 -1
- package/src/hub/sdlc.ts +15 -6
- package/src/hub/settings.ts +2 -0
- package/src/hub/spec-readback.ts +136 -0
- package/src/hub/specs.ts +1 -1
- package/src/hub/task-list-page.ts +1 -1
- package/src/hub/tasks.ts +558 -65
- package/src/hub/ui.ts +4 -2
- package/src/ui/index.html +26 -2
- package/src/ui/overview-model.ts +138 -0
- package/src/ui/plugin.ts +30 -4
- package/templates/roles/ops/project-manager.md +1 -1
package/src/hub/board.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { MILESTONE_HISTORY_LIMIT, parseMilestoneInput, parseMilestonePatch, mile
|
|
|
25
25
|
import { HUB, USER, type PeerId } from "./envelope.ts";
|
|
26
26
|
import type { AuditFinding, AuditProfile, AuditUnit } from "./security-audit.ts";
|
|
27
27
|
import type { ReviewFinding } from "./review-findings.ts";
|
|
28
|
+
import type { ReviewCheckoutEvidence } from "./review-checkout.ts";
|
|
28
29
|
import type { SweepRecord } from "./task-sweep.ts";
|
|
29
30
|
import type { SpecAcceptance, SdlcReceipt } from "./sdlc.ts";
|
|
30
31
|
import { parseReviewFindings, type ReviewFindingSet } from "./review-findings.ts";
|
|
@@ -36,6 +37,7 @@ export type { SpecAck, SpecRef, SpecTaskReport } from "./specs-task.ts";
|
|
|
36
37
|
import { campaignHash, parseResearchCampaign, parseResearchHandoff, type ResearchCampaignContract, type ResearchCampaignStatus, type ResearchUnit, type ResearchHandoffV1, type ResearchHandoffRecord } from "./research-campaign.ts";
|
|
37
38
|
import { parseSurveyFindings, parseSurveyVetDecisions, surveyArray, surveyObject, surveyPath, surveyText, surveyFindingId, surveyPass, type SurveyFinding, type SurveyVetDecision, SURVEY_FOCUS, SURVEY_LIMITS, type SurveyFocus } from "./advisor-survey.ts";
|
|
38
39
|
import { parseConsideredEntry, type ConsideredEntry } from "./considered-findings.ts";
|
|
40
|
+
import { parseSpecReadbackReport, READBACK_STORE_BYTES, type SpecReadbackReport } from "./spec-readback.ts";
|
|
39
41
|
|
|
40
42
|
export interface StoredSurvey { id: number; task: number; taskCreated: number; repo: string; ref: string; focus?: SurveyFocus; by: string; at: number; withheld?: true }
|
|
41
43
|
export interface StoredSurveyFinding { finding: SurveyFinding; foundBy: string; foundAt: number; decision?: SurveyVetDecision; decisionBy?: string; decisionAt?: number }
|
|
@@ -43,8 +45,14 @@ export interface SurveyPreparedCard { id: string; key: string; title: string; de
|
|
|
43
45
|
export interface SurveyApplyInput { findings: SurveyFinding[]; decisions: SurveyVetDecision[]; by: string; at: number; cards?: SurveyPreparedCard[]; rejections?: ConsideredEntry[]; reconsiderations?: ConsideredEntry[]; withheld?: true }
|
|
44
46
|
export interface SurveyWriteFence { boardRevision: number; taskCreated: number; taskFlowRevision: number; owner: string }
|
|
45
47
|
export interface StoredRejectedFinding { id: number; entry: ConsideredEntry; reconsideredBy: number[] }
|
|
48
|
+
/**
|
|
49
|
+
* #1658: one read-back request per task incarnation, issue and body edit time. The request is stored on it like a survey
|
|
50
|
+
* report; `reader` is the peer the hub asked and `report` is what it sent back, only through `readbackReport`.
|
|
51
|
+
*/
|
|
52
|
+
export interface StoredReadback { id: number; task: number; taskCreated: number; repo: string; issue: number; lastEditedAt: string | null; updatedAt: string; reader: string; by: string; at: number; report?: SpecReadbackReport; missingRefs?: string[] }
|
|
46
53
|
const SURVEY_STORE_LIMIT = 1000, SURVEY_STORE_BYTES = 64 * 1024;
|
|
47
54
|
const surveyStorageFailure = (): never => { throw new Error("survey storage invalid; stop the hub and restore a trusted hub.db backup before retrying"); };
|
|
55
|
+
const readbackStorageFailure = (): never => { throw new Error("spec read-back storage invalid; stop the hub and restore a trusted hub.db backup before retrying"); };
|
|
48
56
|
const surveyInputFailure = (): never => { throw new Error("invalid survey storage input or changed binding"); };
|
|
49
57
|
const surveyInteger = (value: unknown, min = 1): number => typeof value === "number" && Number.isSafeInteger(value) && value >= min ? value : surveyInputFailure();
|
|
50
58
|
const surveyHash = (body: string) => createHash("sha256").update(body).digest("hex");
|
|
@@ -54,6 +62,23 @@ function surveyCreateInput(input: unknown): Omit<StoredSurvey, "id"> {
|
|
|
54
62
|
return { task: surveyInteger(row.task), taskCreated: surveyInteger(row.taskCreated, 0), repo: surveyText(row.repo, 1024), ref: row.ref,
|
|
55
63
|
...(row.focus === undefined ? {} : { focus: (typeof row.focus === "string" && (SURVEY_FOCUS as readonly string[]).includes(row.focus) ? row.focus as SurveyFocus : surveyInputFailure()) }), by: surveyText(row.by, 128), at: surveyInteger(row.at, 0), ...(row.withheld === true ? { withheld: true } : {}) };
|
|
56
64
|
}
|
|
65
|
+
const readbackStamp = (value: unknown): value is string => typeof value === "string" && value.length > 0 && value.length <= 40 && !Number.isNaN(Date.parse(value));
|
|
66
|
+
/** #1658: a read-back row is the request plus, once sent, the reader's bounded report, inside the bound the parser accepts; never a verdict or a score. */
|
|
67
|
+
function readbackInput(input: unknown): Omit<StoredReadback, "id"> {
|
|
68
|
+
const row = surveyObject(input, ["task", "taskCreated", "repo", "issue", "lastEditedAt", "updatedAt", "reader", "by", "at", "report", "missingRefs"]);
|
|
69
|
+
if (!readbackStamp(row.updatedAt) || row.lastEditedAt !== null && !readbackStamp(row.lastEditedAt)
|
|
70
|
+
|| !Number.isSafeInteger(row.issue) || (row.issue as number) < 1
|
|
71
|
+
|| row.report !== undefined && row.missingRefs === undefined) return surveyInputFailure();
|
|
72
|
+
const refs = row.missingRefs === undefined ? undefined : surveyArray(row.missingRefs, 64).map(surveyPath);
|
|
73
|
+
if (refs && new Set(refs).size !== refs.length) return surveyInputFailure();
|
|
74
|
+
const report = row.report === undefined ? undefined : parseSpecReadbackReport(row.report);
|
|
75
|
+
const body = { task: surveyInteger(row.task), taskCreated: surveyInteger(row.taskCreated, 0), repo: surveyText(row.repo, 1024), issue: row.issue as number,
|
|
76
|
+
lastEditedAt: (row.lastEditedAt ?? null) as string | null, updatedAt: row.updatedAt, reader: surveyText(row.reader, 128), by: surveyText(row.by, 128), at: surveyInteger(row.at, 0) };
|
|
77
|
+
if (report && report.task !== body.task) return surveyInputFailure();
|
|
78
|
+
const value = { ...body, ...(report === undefined ? {} : { report, missingRefs: refs! }) };
|
|
79
|
+
if (Buffer.byteLength(JSON.stringify(value)) > READBACK_STORE_BYTES) return surveyInputFailure();
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
57
82
|
function surveyStoredFinding(input: unknown): StoredSurveyFinding {
|
|
58
83
|
const row = surveyObject(input, ["finding", "foundBy", "foundAt", "decision", "decisionBy", "decisionAt"]), finding = parseSurveyFindings([row.finding])[0]!;
|
|
59
84
|
const decision = row.decision === undefined ? undefined : parseSurveyVetDecisions([row.decision])[0]!;
|
|
@@ -199,6 +224,9 @@ const experimentPage = (after: number, limit: number): void => {
|
|
|
199
224
|
|
|
200
225
|
export const CLASSES = ["plan", "implement", "bulk_edit", "test", "review", "summarize", "triage"] as const;
|
|
201
226
|
export type TaskClass = (typeof CLASSES)[number];
|
|
227
|
+
/** #1647: why a planner split or handed off this task. A closed set, so the board can group cost and rework by it; absent on every task proposed before it existed. */
|
|
228
|
+
export const TASK_REASONS = ["explore", "parallel", "context", "verify", "capability", "person"] as const;
|
|
229
|
+
export type TaskReason = (typeof TASK_REASONS)[number];
|
|
202
230
|
/** #1403 A4: one security audit as stored. `units` is the ledger; it changes only through `Board.auditReport`. */
|
|
203
231
|
export interface StoredAudit { id: number; task: number; taskCreated: number; ref: string; since?: string; profile: AuditProfile; scoped: boolean; at: number; by: string; units: AuditUnit[] }
|
|
204
232
|
const EVIDENCE_HISTORY_WINDOW = 1024;
|
|
@@ -323,6 +351,12 @@ export interface HistoryEntry {
|
|
|
323
351
|
reviewFindings?: ReviewFindingSet;
|
|
324
352
|
/** Immutable artifact head of this verdict, including when lifecycle gates are off. */
|
|
325
353
|
reviewedHead?: string;
|
|
354
|
+
/**
|
|
355
|
+
* #1646: what the checkout the reviewer read held at this verdict, read by the hub for the reviewed paths of the brief, with
|
|
356
|
+
* `source` naming that checkout (the reviewing session's own, or the project's). It stays out of `sdlc`, whose JSON the
|
|
357
|
+
* approval's coverage receipt hashes.
|
|
358
|
+
*/
|
|
359
|
+
checkout?: ReviewCheckoutEvidence;
|
|
326
360
|
/**
|
|
327
361
|
* #509a: the files a `done`, a lifecycle record or an approval bound, with the content hashes the hub computed. An approval carries the hashes
|
|
328
362
|
* it was given at review time, so a later edit reads as "deliverable changed since review". Full paths live here; every view goes through
|
|
@@ -466,6 +500,8 @@ export interface Task extends PlanningFields {
|
|
|
466
500
|
profileClass?: string;
|
|
467
501
|
/** Catalog guidance id only, never an authority role (#295). */
|
|
468
502
|
role?: string;
|
|
503
|
+
/** #1647: the named reason this task was split off. Absent means none was given. */
|
|
504
|
+
reason?: TaskReason;
|
|
469
505
|
owner: PeerId | null;
|
|
470
506
|
/** Null for legacy rows; only Tasks chooses or changes a planner. */
|
|
471
507
|
planner?: PeerId | null;
|
|
@@ -622,6 +658,7 @@ export class Board {
|
|
|
622
658
|
this.db.run("CREATE TABLE IF NOT EXISTS task_code_symbols (task INTEGER PRIMARY KEY, payload TEXT NOT NULL)");
|
|
623
659
|
this.db.run("DELETE FROM task_code_symbols WHERE task NOT IN (SELECT id FROM tasks) OR task IN (SELECT id FROM tasks WHERE json_valid(signals) AND EXISTS (SELECT 1 FROM json_each(signals) WHERE value IN ('pii','pii_path')))");
|
|
624
660
|
if (!have.has("task_role")) this.db.run("ALTER TABLE tasks ADD COLUMN task_role TEXT");
|
|
661
|
+
if (!have.has("task_reason")) this.db.run("ALTER TABLE tasks ADD COLUMN task_reason TEXT");
|
|
625
662
|
if (!have.has("project_profile")) this.db.run("ALTER TABLE tasks ADD COLUMN project_profile TEXT");
|
|
626
663
|
for (const col of ["rank", "priority", "release", "planned_start", "due"]) {
|
|
627
664
|
if (!have.has(col)) this.db.run(`ALTER TABLE tasks ADD COLUMN "${col}" INTEGER`);
|
|
@@ -729,6 +766,10 @@ export class Board {
|
|
|
729
766
|
withheld INTEGER NOT NULL DEFAULT 0, UNIQUE(task_id,task_created))`);
|
|
730
767
|
this.db.run(`CREATE TABLE IF NOT EXISTS advisor_survey_findings (
|
|
731
768
|
survey INTEGER NOT NULL, finding_id TEXT NOT NULL, body TEXT NOT NULL, body_sha256 TEXT NOT NULL, PRIMARY KEY(survey,finding_id))`);
|
|
769
|
+
// #1658: one spec read-back request per task incarnation, issue and body edit time. Private like a survey; the edit time is the key column, so a later body starts a second row.
|
|
770
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS spec_readbacks (
|
|
771
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, task_id INTEGER NOT NULL, task_created INTEGER NOT NULL, issue INTEGER NOT NULL, edit TEXT NOT NULL,
|
|
772
|
+
body TEXT NOT NULL, body_sha256 TEXT NOT NULL, UNIQUE(task_id,task_created,issue,edit))`);
|
|
732
773
|
this.db.run(`CREATE TABLE IF NOT EXISTS considered_findings (
|
|
733
774
|
id INTEGER PRIMARY KEY AUTOINCREMENT, repo TEXT NOT NULL, finding_id TEXT NOT NULL, pass TEXT NOT NULL, kind TEXT NOT NULL,
|
|
734
775
|
body TEXT NOT NULL, body_sha256 TEXT NOT NULL, replay_key TEXT NOT NULL UNIQUE, prior_ids TEXT NOT NULL, withheld INTEGER NOT NULL DEFAULT 0)`);
|
|
@@ -1429,6 +1470,69 @@ export class Board {
|
|
|
1429
1470
|
});
|
|
1430
1471
|
} catch { return surveyStorageFailure(); }
|
|
1431
1472
|
}
|
|
1473
|
+
/** No report exists yet for a request whose reader was never chosen; `unavailable` is a receipt fact, not a row. */
|
|
1474
|
+
readbackCreate(input: { task: number; taskCreated: number; repo: string; issue: number; lastEditedAt: string | null; updatedAt: string; reader: string; by: string; at: number }): number {
|
|
1475
|
+
const row = readbackInput(input);
|
|
1476
|
+
const write = () => {
|
|
1477
|
+
const task = this.get(row.task);
|
|
1478
|
+
if (!task || task.created !== row.taskCreated || task.signals.includes("pii") || task.signals.includes("pii_path")) return surveyInputFailure();
|
|
1479
|
+
const known = this.readbackOfTask(row.task, row.taskCreated, row.issue, row.lastEditedAt);
|
|
1480
|
+
if (known) {
|
|
1481
|
+
const identity = (value: Omit<StoredReadback, "id">) => JSON.stringify([value.task, value.taskCreated, value.repo, value.issue, value.lastEditedAt, value.updatedAt, value.reader, value.by]);
|
|
1482
|
+
// A start that raced another start, or an issue comment that moved `updatedAt` under the same `lastEditedAt`, finds
|
|
1483
|
+
// the earlier row here. It is never overwritten: the row stands and the caller reads it.
|
|
1484
|
+
if (identity(known) !== identity(row)) throw new Error(`read-back ${known.id} already holds this task, issue and body for a different read; run ahub sdlc readback show ${row.task} for the request that stands`);
|
|
1485
|
+
return known.id;
|
|
1486
|
+
}
|
|
1487
|
+
const body = JSON.stringify(row);
|
|
1488
|
+
const saved = this.taskWrite(() => this.db.query("INSERT INTO spec_readbacks(task_id,task_created,issue,edit,body,body_sha256) VALUES(?,?,?,?,?,?)")
|
|
1489
|
+
.run(row.task, row.taskCreated, row.issue, row.lastEditedAt ?? "", body, surveyHash(body)));
|
|
1490
|
+
return Number(saved.lastInsertRowid);
|
|
1491
|
+
};
|
|
1492
|
+
return this.pendingChanges ? write() : this.atomic(write);
|
|
1493
|
+
}
|
|
1494
|
+
readbackOfTask(taskId: number, created: number, issue: number, edit: string | null): StoredReadback | undefined {
|
|
1495
|
+
surveyInteger(taskId); surveyInteger(created, 0); surveyInteger(issue);
|
|
1496
|
+
if (edit !== null && (typeof edit !== "string" || edit.length > 40)) return surveyInputFailure();
|
|
1497
|
+
const row = this.db.query("SELECT id FROM spec_readbacks WHERE task_id=? AND task_created=? AND issue=? AND edit=?").get(taskId, created, issue, edit ?? "") as { id: number } | null;
|
|
1498
|
+
return row ? this.readback(row.id) : undefined;
|
|
1499
|
+
}
|
|
1500
|
+
/** The newest request for this task incarnation: the one `status` and `show` report on. */
|
|
1501
|
+
readbackLatest(taskId: number, created: number): StoredReadback | undefined {
|
|
1502
|
+
surveyInteger(taskId); surveyInteger(created, 0);
|
|
1503
|
+
const row = this.db.query("SELECT id FROM spec_readbacks WHERE task_id=? AND task_created=? ORDER BY id DESC LIMIT 1").get(taskId, created) as { id: number } | null;
|
|
1504
|
+
return row ? this.readback(row.id) : undefined;
|
|
1505
|
+
}
|
|
1506
|
+
readback(id: number): StoredReadback | undefined {
|
|
1507
|
+
surveyInteger(id);
|
|
1508
|
+
const row = this.db.query(`SELECT id,task_id,task_created,issue,CASE WHEN length(CAST(edit AS BLOB))<=40 THEN edit END AS edit,
|
|
1509
|
+
CASE WHEN length(CAST(body AS BLOB))<=${READBACK_STORE_BYTES} THEN body END AS body,CASE WHEN length(CAST(body_sha256 AS BLOB))=64 THEN body_sha256 END AS body_sha256
|
|
1510
|
+
FROM spec_readbacks WHERE id=?`).get(id) as { id: number; task_id: number; task_created: number; issue: number; edit: string | null; body: string | null; body_sha256: string } | null;
|
|
1511
|
+
if (!row) return;
|
|
1512
|
+
try {
|
|
1513
|
+
if (!row.body || surveyHash(row.body) !== row.body_sha256) return surveyStorageFailure();
|
|
1514
|
+
const value = readbackInput(JSON.parse(row.body));
|
|
1515
|
+
if (value.task !== row.task_id || value.taskCreated !== row.task_created || value.issue !== row.issue || (value.lastEditedAt ?? "") !== row.edit) return surveyStorageFailure();
|
|
1516
|
+
return { id: row.id, ...value };
|
|
1517
|
+
} catch { return surveyStorageFailure(); }
|
|
1518
|
+
}
|
|
1519
|
+
/** One report per request: an identical replay returns the stored row, anything else is refused rather than replaced. */
|
|
1520
|
+
readbackReport(id: number, report: unknown, missingRefs: unknown): StoredReadback {
|
|
1521
|
+
surveyInteger(id);
|
|
1522
|
+
const parsed = parseSpecReadbackReport(report), refs = surveyArray(missingRefs, 64).map(surveyPath);
|
|
1523
|
+
if (new Set(refs).size !== refs.length) return surveyInputFailure();
|
|
1524
|
+
return this.atomic(() => {
|
|
1525
|
+
const current = this.readback(id) ?? surveyInputFailure();
|
|
1526
|
+
if (parsed.task !== current.task) return surveyInputFailure();
|
|
1527
|
+
if (current.report) {
|
|
1528
|
+
if (JSON.stringify(current.report) !== JSON.stringify(parsed) || JSON.stringify(current.missingRefs) !== JSON.stringify(refs)) return surveyInputFailure();
|
|
1529
|
+
return current;
|
|
1530
|
+
}
|
|
1531
|
+
const { id: _id, ...next } = { ...current, report: parsed, missingRefs: refs }, body = JSON.stringify(next);
|
|
1532
|
+
this.taskWrite(() => this.db.query("UPDATE spec_readbacks SET body=?,body_sha256=? WHERE id=?").run(body, surveyHash(body), id));
|
|
1533
|
+
return { id, ...next };
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1432
1536
|
private consideredWrite(input: unknown, kind: "rejected" | "reconsidered", priorIDs: readonly number[] = []): number {
|
|
1433
1537
|
const entry = parseConsideredEntry(input), task = this.get(entry.source.task);
|
|
1434
1538
|
if (!task || task.created !== entry.source.created) return surveyInputFailure();
|
|
@@ -1575,6 +1679,22 @@ export class Board {
|
|
|
1575
1679
|
hasSurveyState(): boolean {
|
|
1576
1680
|
return !!(this.db.query("SELECT EXISTS(SELECT 1 FROM advisor_surveys UNION ALL SELECT 1 FROM advisor_survey_findings UNION ALL SELECT 1 FROM considered_findings) AS present").get() as { present: number }).present;
|
|
1577
1681
|
}
|
|
1682
|
+
hasSpecReadbacksState(): boolean {
|
|
1683
|
+
return !!(this.db.query("SELECT EXISTS(SELECT 1 FROM spec_readbacks) AS present").get() as { present: number }).present;
|
|
1684
|
+
}
|
|
1685
|
+
/** Stream validated read-back rows into recovery proof; output never carries issue text or a report body. */
|
|
1686
|
+
specReadbackIntegrity(): { readbacks: number; digest: string } {
|
|
1687
|
+
try { return this.db.transaction(() => {
|
|
1688
|
+
const digest = createHash("sha256"); let readbacks = 0;
|
|
1689
|
+
for (const key of this.db.query("SELECT id FROM spec_readbacks ORDER BY id").iterate() as Iterable<{ id: number }>) {
|
|
1690
|
+
const row = this.readback(key.id); if (!row) return readbackStorageFailure();
|
|
1691
|
+
digest.update(JSON.stringify({ readback: row })); readbacks++;
|
|
1692
|
+
}
|
|
1693
|
+
const count = this.db.query("SELECT COUNT(*) AS count FROM spec_readbacks").get() as { count: number };
|
|
1694
|
+
if (count.count !== readbacks) return readbackStorageFailure();
|
|
1695
|
+
return { readbacks, digest: digest.digest("hex") };
|
|
1696
|
+
})(); } catch { return readbackStorageFailure(); }
|
|
1697
|
+
}
|
|
1578
1698
|
/** Stream bounded validated private rows into recovery proof; output never includes finding or ledger text. */
|
|
1579
1699
|
surveyIntegrity(): { surveys: number; findings: number; considered: number; digest: string } {
|
|
1580
1700
|
try { return this.db.transaction(() => {
|
|
@@ -2456,7 +2576,7 @@ export class Board {
|
|
|
2456
2576
|
})();
|
|
2457
2577
|
}
|
|
2458
2578
|
|
|
2459
|
-
propose(by: PeerId, t: { title: string; detail?: string; class: TaskClass; planner?: PeerId | null; plannerReason?: PlannerReason; profile?: import("./profiles.ts").ProfileName; profileClass?: string; customProfile?: true; role?: string; refs?: TaskRefs; plan?: TaskPlan; deps?: number[]; reserved?: PeerId; signals?: string[]; backlog?: boolean; draft?: boolean; external?: GitHubSource }, createdHook?: (task: Task) => void): Task {
|
|
2579
|
+
propose(by: PeerId, t: { title: string; detail?: string; class: TaskClass; planner?: PeerId | null; plannerReason?: PlannerReason; profile?: import("./profiles.ts").ProfileName; profileClass?: string; customProfile?: true; role?: string; reason?: TaskReason; refs?: TaskRefs; plan?: TaskPlan; deps?: number[]; reserved?: PeerId; signals?: string[]; backlog?: boolean; draft?: boolean; external?: GitHubSource }, createdHook?: (task: Task) => void): Task {
|
|
2460
2580
|
// Host-only synchronous DB bookkeeping. Never sourced from task input or called with I/O/screens.
|
|
2461
2581
|
if (createdHook !== undefined) {
|
|
2462
2582
|
if (typeof createdHook !== "function") throw new Error("invalid host proposal hook");
|
|
@@ -2467,8 +2587,8 @@ export class Board {
|
|
|
2467
2587
|
const history: HistoryEntry[] = [{ at: now, by, ...instructedHistory(by), ...chosen, event: t.backlog ? "backlogged" : "proposed", ...(this.trackPlanRevisions?.() && t.plan && Object.keys(t.plan).length ? { planRevision: { revision: 1, fingerprint: planFingerprint(t.plan) } } : {}) }];
|
|
2468
2588
|
const { lastInsertRowid } = this.taskWrite(() => {
|
|
2469
2589
|
const inserted = this.db
|
|
2470
|
-
.query("INSERT INTO tasks (title, detail, class, state, refs, plan, deps, reserved, signals, history, created, updated, project_profile, task_role, external_repo, external_issue, planner, draft) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
|
2471
|
-
.run(t.title, t.detail ?? "", t.class, t.backlog ? "backlog" : "proposed", JSON.stringify(t.refs ?? {}), JSON.stringify(t.plan ?? {}), JSON.stringify(t.deps ?? []), t.reserved ?? null, JSON.stringify(t.signals ?? []), JSON.stringify(history), now, now, t.profile && (t.profile !== "dev" || t.customProfile || t.profileClass !== undefined && t.profileClass !== t.class) ? JSON.stringify({ profile: t.profile, profileClass: t.profileClass ?? t.class }) : null, t.role ?? null, t.external?.repo.toLowerCase() ?? null, t.external?.issue ?? null, planner, t.draft && t.backlog ? 1 : 0);
|
|
2590
|
+
.query("INSERT INTO tasks (title, detail, class, state, refs, plan, deps, reserved, signals, history, created, updated, project_profile, task_role, external_repo, external_issue, planner, draft, task_reason) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
|
2591
|
+
.run(t.title, t.detail ?? "", t.class, t.backlog ? "backlog" : "proposed", JSON.stringify(t.refs ?? {}), JSON.stringify(t.plan ?? {}), JSON.stringify(t.deps ?? []), t.reserved ?? null, JSON.stringify(t.signals ?? []), JSON.stringify(history), now, now, t.profile && (t.profile !== "dev" || t.customProfile || t.profileClass !== undefined && t.profileClass !== t.class) ? JSON.stringify({ profile: t.profile, profileClass: t.profileClass ?? t.class }) : null, t.role ?? null, t.external?.repo.toLowerCase() ?? null, t.external?.issue ?? null, planner, t.draft && t.backlog ? 1 : 0, t.reason ?? null);
|
|
2472
2592
|
if (this.proposalPlanner && !Object.hasOwn(t, "planner") && t.plannerReason === undefined) {
|
|
2473
2593
|
const selected = this.proposalPlanner(this.get(Number(inserted.lastInsertRowid))!);
|
|
2474
2594
|
const binding = plannerMetadata(selected.planner, selected.plannerReason);
|
|
@@ -2735,7 +2855,7 @@ export class Board {
|
|
|
2735
2855
|
|
|
2736
2856
|
/** The only way a task changes. Validates the move, records who did what, returns the new row. */
|
|
2737
2857
|
/** A `plan` in the patch replaces the old one whole: a new plan is the owner's current intent, not an addition. */
|
|
2738
|
-
update(id: number, by: PeerId, event: string, patch: Partial<Pick<Task, "state" | "owner" | "planner" | "reviewer" | "reserved" | "refs" | "plan" | "rejections" | "signals" | "sdlc" | "role" | "cancelled" | "codeSymbols">>, note?: string, extra: Pick<HistoryEntry, "invocation" | "plannerReason" | "planAuthor" | "selfReview" | "profile" | "sweep" | "wait" | "reason" | "from" | "capacity" | "conductorManual" | "withheld" | "noWrites" | "reviewCost" | "requestHead" | "reviewContext" | "reviewScope" | "evidenceOnly" | "reviewedHead" | "reviewFindings" | "unmetCriteria" | "deliverables" | "checkKey" | "missingKeys" | "claim" | "planObservation" | "planDeparture" | "planDepartureInvalidated" | "specReport" | "specRefBinding" | "resolvedReviewComments" | "securityPass" | keyof ReviewerHistory> = {}, expectedFlowRevision?: number, codeSymbolsAuthority?: typeof HOST_CODE_SYMBOLS, adoptionAuthority?: typeof HOST_MERGE_ADOPTION): Task {
|
|
2858
|
+
update(id: number, by: PeerId, event: string, patch: Partial<Pick<Task, "state" | "owner" | "planner" | "reviewer" | "reserved" | "refs" | "plan" | "rejections" | "signals" | "sdlc" | "role" | "cancelled" | "codeSymbols">>, note?: string, extra: Pick<HistoryEntry, "invocation" | "plannerReason" | "planAuthor" | "selfReview" | "profile" | "sweep" | "wait" | "reason" | "from" | "capacity" | "conductorManual" | "withheld" | "noWrites" | "reviewCost" | "requestHead" | "reviewContext" | "reviewScope" | "evidenceOnly" | "reviewedHead" | "reviewFindings" | "checkout" | "unmetCriteria" | "deliverables" | "checkKey" | "missingKeys" | "claim" | "planObservation" | "planDeparture" | "planDepartureInvalidated" | "specReport" | "specRefBinding" | "resolvedReviewComments" | "securityPass" | keyof ReviewerHistory> = {}, expectedFlowRevision?: number, codeSymbolsAuthority?: typeof HOST_CODE_SYMBOLS, adoptionAuthority?: typeof HOST_MERGE_ADOPTION): Task {
|
|
2739
2859
|
const instruction = instructedExecution.getStore();
|
|
2740
2860
|
if (instruction?.active && instruction.taskId === id) instruction.current();
|
|
2741
2861
|
if (extra.resolvedReviewComments?.length && !this.db.inTransaction) return this.atomic(() => this.update(id, by, event, patch, note, extra, expectedFlowRevision, codeSymbolsAuthority, adoptionAuthority));
|
|
@@ -2820,6 +2940,20 @@ export class Board {
|
|
|
2820
2940
|
if (!["approved", "changes_requested"].includes(event) || patch.state !== event) throw new Error("unmet criteria require a saved review verdict");
|
|
2821
2941
|
unmetCriteria = criterionIdList(extra.unmetCriteria);
|
|
2822
2942
|
}
|
|
2943
|
+
// #1646: what the checkout the reviewer read held, bounded like the brief it was read for. A malformed record is refused, never
|
|
2944
|
+
// quietly dropped: evidence that reads as absent would be indistinguishable from a checkout nobody read.
|
|
2945
|
+
let checkout: ReviewCheckoutEvidence | undefined;
|
|
2946
|
+
if (extra.checkout !== undefined) {
|
|
2947
|
+
if (!["approved", "changes_requested"].includes(event) || patch.state !== event) throw new Error("checkout evidence requires a saved review verdict");
|
|
2948
|
+
const { source, head, differing, untracked } = extra.checkout as Partial<Record<keyof ReviewCheckoutEvidence, unknown>>;
|
|
2949
|
+
const paths = (value: unknown): string[] | undefined => Array.isArray(value) && value.length <= 500
|
|
2950
|
+
&& value.every(path => typeof path === "string" && path.length > 0 && path.length <= 1024 && !/[\p{Cc}]/u.test(path)) ? value : undefined;
|
|
2951
|
+
const differingPaths = paths(differing), untrackedPaths = paths(untracked);
|
|
2952
|
+
if (source !== "peer-cwd" && source !== "project-root") throw new Error("invalid checkout evidence source");
|
|
2953
|
+
if (differingPaths === undefined || untrackedPaths === undefined) throw new Error("invalid checkout evidence paths");
|
|
2954
|
+
if (head !== null && !(typeof head === "string" && /^[a-f0-9]{40}$/.test(head))) throw new Error("invalid checkout head");
|
|
2955
|
+
checkout = { source, head, differing: differingPaths, untracked: untrackedPaths };
|
|
2956
|
+
}
|
|
2823
2957
|
if (extra.planDeparture && (by !== "user" || event !== "plan departure accepted")) throw new Error("plan departure acceptance is person-only");
|
|
2824
2958
|
const trackPlan = this.trackPlanRevisions?.() === true, hasDeparture = task.history.some(h => h.planDeparture);
|
|
2825
2959
|
const fingerprint = patch.plan && (trackPlan || hasDeparture) ? planFingerprint(next.plan ?? {}) : undefined;
|
|
@@ -2835,7 +2969,7 @@ export class Board {
|
|
|
2835
2969
|
&& priorHead !== undefined && /^[a-f0-9]{40}$/.test(priorHead);
|
|
2836
2970
|
const previousHistory = backfill ? task.history.map((entry, index) => index === priorApproval && !entry.reviewedHead
|
|
2837
2971
|
? { ...entry, reviewedHead: entry.reviewFindings?.head ?? priorHead } : entry) : task.history;
|
|
2838
|
-
const history = [...previousHistory, { at: Date.now(), by, event, ...instructedHistory(by), ...(resolvedReviewComments?.length ? { resolvedReviewComments } : {}), ...(returnPlanning ? { planning: returnPlanning } : {}), ...(extra.invocation ? { invocation: extra.invocation } : {}), ...plannerHistory, ...authorHistory, ...(extra.selfReview === true ? { selfReview: true as const } : {}), ...(planRevision ? { planRevision } : {}), ...(extra.planObservation ? { planObservation: extra.planObservation } : {}), ...(extra.planDeparture ? { planDeparture: extra.planDeparture } : {}), ...(departureInvalidated ? { planDepartureInvalidated: true as const } : {}), ...reviewMetadata, ...specMetadata, ...(note ? { note } : {}), ...(patch.cancelled?.supersededBy ? { supersededBy: patch.cancelled.supersededBy } : {}), ...("owner" in patch ? { owner: next.owner } : {}), ...(extra.profile ? { profile: extra.profile } : {}), ...(extra.sweep ? { sweep: extra.sweep } : {}), ...(event === "wait recorded" && extra.wait && Number.isSafeInteger(extra.wait.until) && extra.wait.until > 0 ? { wait: { until: extra.wait.until, owner: extra.wait.owner } } : {}), ...(extra.reason && TASK_MOVE_REASONS.includes(extra.reason) ? { reason: extra.reason } : {}), ...(extra.from ? { from: extra.from } : {}), ...(extra.capacity === true ? { capacity: true as const } : {}), ...(extra.conductorManual === true ? { conductorManual: true as const } : {}), ...(extra.withheld && (note || reviewFindings) ? { withheld: true as const } : {}), ...(reviewFindings ? { reviewFindings } : {}), ...(extra.reviewedHead ? { reviewedHead: extra.reviewedHead } : {}), ...(unmetCriteria?.length ? { unmetCriteria } : {}), ...(securityPass ? { securityPass } : {}), ...(deliverables ? { deliverables } : {}), ...(extra.reviewContext === "fresh" || extra.reviewContext === "continuing" ? { reviewContext: extra.reviewContext } : {}), ...(extra.reviewScope === "code" ? { reviewScope: "code" as const } : {}), ...(extra.evidenceOnly === true && event === "changes_requested" ? { evidenceOnly: true as const } : {}), ...(extra.reviewCost ? { reviewCost: extra.reviewCost } : {}), ...(["done", "check run passed", "check run failed"].includes(event) && extra.requestHead && /^[a-f0-9]{40}$/.test(extra.requestHead) ? { requestHead: extra.requestHead } : {}), ...(event === "done" && extra.noWrites === true ? { noWrites: true as const } : {}), ...(["check passed", "check failed", "check run passed", "check run failed"].includes(event) && typeof extra.checkKey === "string" && /^[a-z][a-z0-9_]{0,47}$/.test(extra.checkKey) ? { checkKey: extra.checkKey } : {}), ...(["check passed", "check failed"].includes(event) && Number.isSafeInteger(extra.missingKeys) && extra.missingKeys! >= 0 && extra.missingKeys! <= 100_000 ? { missingKeys: extra.missingKeys } : {}), ...(event === "claim verdict" && extra.claim ? { claim: extra.claim } : {}) }];
|
|
2972
|
+
const history = [...previousHistory, { at: Date.now(), by, event, ...instructedHistory(by), ...(resolvedReviewComments?.length ? { resolvedReviewComments } : {}), ...(returnPlanning ? { planning: returnPlanning } : {}), ...(extra.invocation ? { invocation: extra.invocation } : {}), ...plannerHistory, ...authorHistory, ...(extra.selfReview === true ? { selfReview: true as const } : {}), ...(planRevision ? { planRevision } : {}), ...(extra.planObservation ? { planObservation: extra.planObservation } : {}), ...(extra.planDeparture ? { planDeparture: extra.planDeparture } : {}), ...(departureInvalidated ? { planDepartureInvalidated: true as const } : {}), ...reviewMetadata, ...specMetadata, ...(note ? { note } : {}), ...(patch.cancelled?.supersededBy ? { supersededBy: patch.cancelled.supersededBy } : {}), ...("owner" in patch ? { owner: next.owner } : {}), ...(extra.profile ? { profile: extra.profile } : {}), ...(extra.sweep ? { sweep: extra.sweep } : {}), ...(event === "wait recorded" && extra.wait && Number.isSafeInteger(extra.wait.until) && extra.wait.until > 0 ? { wait: { until: extra.wait.until, owner: extra.wait.owner } } : {}), ...(extra.reason && TASK_MOVE_REASONS.includes(extra.reason) ? { reason: extra.reason } : {}), ...(extra.from ? { from: extra.from } : {}), ...(extra.capacity === true ? { capacity: true as const } : {}), ...(extra.conductorManual === true ? { conductorManual: true as const } : {}), ...(extra.withheld && (note || reviewFindings) ? { withheld: true as const } : {}), ...(reviewFindings ? { reviewFindings } : {}), ...(extra.reviewedHead ? { reviewedHead: extra.reviewedHead } : {}), ...(checkout ? { checkout } : {}), ...(unmetCriteria?.length ? { unmetCriteria } : {}), ...(securityPass ? { securityPass } : {}), ...(deliverables ? { deliverables } : {}), ...(extra.reviewContext === "fresh" || extra.reviewContext === "continuing" ? { reviewContext: extra.reviewContext } : {}), ...(extra.reviewScope === "code" ? { reviewScope: "code" as const } : {}), ...(extra.evidenceOnly === true && event === "changes_requested" ? { evidenceOnly: true as const } : {}), ...(extra.reviewCost ? { reviewCost: extra.reviewCost } : {}), ...(["done", "check run passed", "check run failed"].includes(event) && extra.requestHead && /^[a-f0-9]{40}$/.test(extra.requestHead) ? { requestHead: extra.requestHead } : {}), ...(event === "done" && extra.noWrites === true ? { noWrites: true as const } : {}), ...(["check passed", "check failed", "check run passed", "check run failed"].includes(event) && typeof extra.checkKey === "string" && /^[a-z][a-z0-9_]{0,47}$/.test(extra.checkKey) ? { checkKey: extra.checkKey } : {}), ...(["check passed", "check failed"].includes(event) && Number.isSafeInteger(extra.missingKeys) && extra.missingKeys! >= 0 && extra.missingKeys! <= 100_000 ? { missingKeys: extra.missingKeys } : {}), ...(event === "claim verdict" && extra.claim ? { claim: extra.claim } : {}) }];
|
|
2839
2973
|
this.taskWrite(() => {
|
|
2840
2974
|
if (resolvedReviewComments?.length) for (const record of this.reviewComments(task.id, task.created)) {
|
|
2841
2975
|
if (!resolvedReviewComments.includes(record.thread.id) || record.lifecycle !== "sent") continue;
|
|
@@ -3349,6 +3483,8 @@ function parse(row: Record<string, unknown>): Task {
|
|
|
3349
3483
|
delete out.external_repo; delete out.external_issue;
|
|
3350
3484
|
if (out.task_role != null) out.role = out.task_role;
|
|
3351
3485
|
delete out.task_role;
|
|
3486
|
+
if (typeof out.task_reason === "string" && (TASK_REASONS as readonly string[]).includes(out.task_reason)) out.reason = out.task_reason;
|
|
3487
|
+
delete out.task_reason;
|
|
3352
3488
|
if (out.planned_start != null) out.plannedStart = out.planned_start;
|
|
3353
3489
|
delete out.planned_start;
|
|
3354
3490
|
if (out.planning_revision) out.planningRevision = out.planning_revision;
|
package/src/hub/bus.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ActivityKind } from "./peer-activity.ts";
|
|
1
2
|
import { isDeliveryFailureCause, type DeliveryFailureCause } from "./delivery-failure.ts";
|
|
2
3
|
import { isReviewObserverExcluded } from "./memory-policy.ts";
|
|
3
4
|
import { remoteEnvelope, appendNote, DIGEST, frame, HUB, USER, isInvocationKind, keepNotes, MAX_HOP, mergePrefaces, newEnvelope, noteLine, parseMarker, quoteNotes, replyAudience, uniqueMemoryLines, type Envelope, type EnvelopeOpts, type PeerId, type PeerState, type Priority } from "./envelope.ts";
|
|
@@ -93,6 +94,7 @@ export interface BusOptions {
|
|
|
93
94
|
onImportantQueued?: (peer: PeerId, counts: { queued: number; important: number }) => void;
|
|
94
95
|
/** Optional (#878): an attached adapter observed its session title or current plan item. Never published, journaled or tapped. */
|
|
95
96
|
doing?: (peer: PeerId, kind: DoingKind, text?: unknown) => void;
|
|
97
|
+
activity?: (peer: PeerId, kind: ActivityKind | undefined) => void;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
/** Serializable delivery state used by the controlled restart coordinator. Bodies stay in the private daemon file. */
|
|
@@ -321,7 +323,15 @@ export class Bus {
|
|
|
321
323
|
this.peers.set(peer.id, peer);
|
|
322
324
|
if (!this.queues.has(peer.id)) this.queues.set(peer.id, []);
|
|
323
325
|
peer.onDelivery = (receipt) => { if (this.peers.get(peer.id) === peer) this.deliveryReceipt(peer.id, receipt); };
|
|
324
|
-
peer.
|
|
326
|
+
peer.onActivity = kind => {
|
|
327
|
+
if (!this.closed && this.peers.get(peer.id) === peer && (kind === undefined || peer.state === "busy"))
|
|
328
|
+
this.opts.activity?.(peer.id, kind);
|
|
329
|
+
};
|
|
330
|
+
peer.onDoing = (kind, text) => {
|
|
331
|
+
if (kind === "reset") { this.clearReviewProvenance(peer.id); peer.onActivity?.(undefined); }
|
|
332
|
+
if (!this.closed && this.peers.get(peer.id) === peer) this.opts.doing?.(peer.id, kind, text);
|
|
333
|
+
};
|
|
334
|
+
this.opts.activity?.(peer.id, undefined);
|
|
325
335
|
this.opts.doing?.(peer.id, "reset"); // a new adapter never shows what the one it replaces was doing
|
|
326
336
|
// A final still traverses the current onMessage observer exactly once. This one-shot
|
|
327
337
|
// marker is host-local, never a caller-supplied envelope or wire field.
|
|
@@ -458,6 +468,7 @@ export class Bus {
|
|
|
458
468
|
if (peer.state === "offline" && this.journal) {
|
|
459
469
|
for (const [id, owner] of [...this.activeDeliveries]) if (owner === peer.id) this.uncertain(peer.id, id, "peer disconnected before delivery settlement", "peer offline");
|
|
460
470
|
}
|
|
471
|
+
if (peer.state !== "busy") this.opts.activity?.(peer.id, undefined);
|
|
461
472
|
this.emit({ t: "state", peer: peer.id, state: this.stateOf(peer.id) });
|
|
462
473
|
void this.drain(peer.id);
|
|
463
474
|
};
|
|
@@ -1681,7 +1692,7 @@ export class Bus {
|
|
|
1681
1692
|
}
|
|
1682
1693
|
|
|
1683
1694
|
/** A confirmed new native session invalidates only this session's current-input cache; durable named-parent rows remain. */
|
|
1684
|
-
resetLastDelivery(peer: PeerId): void { this.lastDelivery.delete(peer); this.lastPulled.delete(peer); }
|
|
1695
|
+
resetLastDelivery(peer: PeerId): void { this.lastDelivery.delete(peer); this.lastPulled.delete(peer); this.opts.activity?.(peer, undefined); }
|
|
1685
1696
|
|
|
1686
1697
|
/**
|
|
1687
1698
|
* Take back an envelope that has not been delivered yet (a request that has expired). True when it was removed from a
|
package/src/hub/config-apply.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { checkStartAgents } from "./start-agents.ts";
|
|
|
19
19
|
import { catalogAssignments } from "./roles.ts";
|
|
20
20
|
import { resolveProfile } from "./profiles.ts";
|
|
21
21
|
import { foldersConfig, schedulesConfig } from "./schedules.ts";
|
|
22
|
+
import { MEMORY_REVIEW_CAP_MAX, MEMORY_REVIEW_MAX_NOTES, memoryReviewConfig } from "./memory-review.ts";
|
|
22
23
|
import { corpusConfig } from "./corpus-config.ts";
|
|
23
24
|
import { taskSweepConfig } from "./task-sweep.ts";
|
|
24
25
|
import { projectionConfig } from "./text-projection.ts";
|
|
@@ -183,6 +184,14 @@ export const validatePetConfig: Check = (v, k) => {
|
|
|
183
184
|
block(petFields)(stripLegacyPetWindow(v), k);
|
|
184
185
|
};
|
|
185
186
|
shapes.set(validatePetConfig, { fields: petFields });
|
|
187
|
+
// #1329: memory.review is a block inside the memory block, so the key walk needs its own shape, and its whole-block rule
|
|
188
|
+
// (an enable without both caps is refused) runs after the leaf types.
|
|
189
|
+
const memoryReviewFields: Record<string, Check> = {
|
|
190
|
+
enabled: bool, every: text, projects: strings, peer: text, max_notes: number(1, MEMORY_REVIEW_MAX_NOTES, true),
|
|
191
|
+
max_tokens_run: number(1, MEMORY_REVIEW_CAP_MAX, true), max_tokens_week: number(1, MEMORY_REVIEW_CAP_MAX, true),
|
|
192
|
+
};
|
|
193
|
+
const memoryReviewCheck: Check = (v, k) => { if (v === undefined) return; block(memoryReviewFields)(v, k); memoryReviewConfig(v); };
|
|
194
|
+
shapes.set(memoryReviewCheck, { fields: memoryReviewFields });
|
|
186
195
|
const nativeValidators = { bool, text, strings, argv, number, words, block };
|
|
187
196
|
const researchRunners: Check = value => { parseResearchRunners(value); };
|
|
188
197
|
shapes.set(researchRunners, { item: block({ publicKey: text, projects: strings, revoked: bool }) });
|
|
@@ -197,7 +206,8 @@ const schema: Record<string, Check> = {
|
|
|
197
206
|
adapters: v => { createProjectAdapterCatalog(v); }, instances: v => { validateInstances(v, createProjectAdapterCatalog()); }, pet: validatePetConfig,
|
|
198
207
|
batch_max: number(1, 100_000, true), batch_ms: number(0, 2_147_483_647), queue_cap: number(1, 1_000_000, true),
|
|
199
208
|
memory: block({ enabled: bool, worker_url: text, inject_tokens: number(0, 1_000_000, true), brief_items: number(0, 10_000, true), native: bool,
|
|
200
|
-
short_ttl_days: number(1, 3650, true), sync_interval_min: number(0, 1440, true), suggest_edges: bool, preface_unused_after: number(0, 100_000, true)
|
|
209
|
+
short_ttl_days: number(1, 3650, true), sync_interval_min: number(0, 1440, true), suggest_edges: bool, preface_unused_after: number(0, 100_000, true),
|
|
210
|
+
review: memoryReviewCheck }),
|
|
201
211
|
roster: peerMap(bool), roles: map(strings), planner: words(PLANNER_PEERS), profile: words(["dev", "research", "writing", "general"]),
|
|
202
212
|
profile_overrides: (v, k) => { map(() => {})(v, k); const fields = object(v, k); for (const name of ["classes", "role_text", "catalog_roles"]) if (fields[name] !== undefined) map(() => {})(fields[name], `${k}.${name}`); resolveProfile("dev", v); },
|
|
203
213
|
catalog_roles: (v, k) => { map(() => {})(v, k); catalogAssignments(v); },
|
|
@@ -312,6 +322,9 @@ export function configApply(key: string, scopes: readonly ConfigIdentityScope[]
|
|
|
312
322
|
const operational = operationalNumber(key);
|
|
313
323
|
if (operational) return { applies: operational.applies, ...(operational.restartReason ? { reason: operational.restartReason } : {}) };
|
|
314
324
|
if (key === "memory.sync_interval_min") return { applies: "live" };
|
|
325
|
+
// #1329: the rest of `memory` quiesces consumers and a profile, but the review block has none: it only decides whether a
|
|
326
|
+
// schedule entry exists, and the daemon reads it at every schedule path, so the switch takes effect on the reload itself.
|
|
327
|
+
if (key === "memory.review" || key.startsWith("memory.review.")) return { applies: "live" };
|
|
315
328
|
if (nextMemory.has(key)) return { applies: "next use" };
|
|
316
329
|
for (const [path, reason] of Object.entries(restart)) if (key === path || key.startsWith(`${path}.`)) return { applies: "restart", reason };
|
|
317
330
|
if ([...live].some(path => key === path || key.startsWith(`${path}.`))) return { applies: "live" };
|
package/src/hub/config-trust.ts
CHANGED
|
@@ -33,6 +33,7 @@ export const MACHINE_LOCAL = [
|
|
|
33
33
|
"supervision.mode", // #1221 T2: lets the hub propose existing actions to a person's console and agents; an opt-in only the person's own machine sets
|
|
34
34
|
"folder_triggers", // #512c: entries make the hub read a folder and propose a task per new file; a committed config may not point the hub at a folder on someone else's machine
|
|
35
35
|
"schedules", // #512: entries make the hub propose tasks on a timer; a committed config may not create work on someone else's machine
|
|
36
|
+
"memory.review", // #1329: the switch that schedules a memory review and the caps it spends; a committed config may not start work on someone else's machine
|
|
36
37
|
"corpus.paths", // #510: folders the hub reads as evidence; a committed config may not point the hub at a folder on someone else's machine
|
|
37
38
|
"invocation", // #445 C1: what another agent may be offered from this machine's agents (a digest-pinned allowlist); a committed config may not share a person's agents' commands with someone else's peers
|
|
38
39
|
] as const;
|
|
@@ -23,7 +23,7 @@ export const PROTOCOL = 17;
|
|
|
23
23
|
/** The descriptor's legacy protocol field remains this floor for previous published clients. */
|
|
24
24
|
export const PROTOCOL_MIN = 16;
|
|
25
25
|
// Literal metadata is read without executing a recovery target; consistency is pinned in tests.
|
|
26
|
-
export const DAEMON_FEATURES = ["instructed_intent", "instructed_exact", "roadmap", "roadmap_instructed", "guidance_views", "guidance_variants", "guidance_probes", "guidance_probe_receipts", "execution_lineage", "model_overrides", "visuals", "project_autonomy", "conductor_recovery", "encrypted_rooms", "external_adapter_instances", "external_adapter_modules", "configured_acp", "native_hook_launch", "task_cancel", "invocation", "recovery_deferred_hub", "peer_instances", "role_stages", "task_planners", "release_trains", "reviewer_pool", "reviewer_quota", "native_tui_launch", "terminal_owner", "cli_audit_delegated", "action_policy_floor", "calendar_schedules", "research_records", "research_dispatch", "research_dropped_offers", "research_experiments", "research_comparisons", "research_runners", "task_handoff", "session_identity", "schema_guard", "design_specs", "queue_discard_states", "tool_write_idempotency", "research_evidence", "research_synthesis", "research_evidence_withdrawal", "advisor_surveys", "review_comments", "questions", "accepted_delivery_settlement", "completions", "review_observer_input_state", "task_handoff_key", "task_handoff_seq", "peer_takeover"] as const;
|
|
26
|
+
export const DAEMON_FEATURES = ["instructed_intent", "instructed_exact", "roadmap", "roadmap_instructed", "guidance_views", "guidance_variants", "guidance_probes", "guidance_probe_receipts", "execution_lineage", "model_overrides", "visuals", "project_autonomy", "conductor_recovery", "encrypted_rooms", "external_adapter_instances", "external_adapter_modules", "configured_acp", "configured_print", "native_hook_launch", "task_cancel", "invocation", "recovery_deferred_hub", "peer_instances", "role_stages", "task_planners", "release_trains", "reviewer_pool", "reviewer_quota", "native_tui_launch", "terminal_owner", "cli_audit_delegated", "action_policy_floor", "calendar_schedules", "research_records", "research_dispatch", "research_dropped_offers", "research_experiments", "research_comparisons", "research_runners", "task_handoff", "session_identity", "schema_guard", "design_specs", "queue_discard_states", "tool_write_idempotency", "research_evidence", "research_synthesis", "research_evidence_withdrawal", "advisor_surveys", "review_comments", "questions", "accepted_delivery_settlement", "completions", "review_observer_input_state", "task_handoff_key", "task_handoff_seq", "peer_takeover", "spec_readbacks"] as const;
|
|
27
27
|
/** Protocols a current coordinator may authenticate while upgrading a running source. */
|
|
28
28
|
export const RECOVERY_SOURCE_PROTOCOLS = [9, 10, 11, 12, 13, 14, 15, 16, PROTOCOL] as const;
|
|
29
29
|
|