gentle-pi 2.2.0 → 2.4.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/README.md +76 -79
- package/assets/agents/review-readability.md +0 -2
- package/assets/agents/review-reliability.md +0 -2
- package/assets/agents/review-resilience.md +0 -2
- package/assets/agents/review-risk.md +0 -2
- package/assets/agents/sdd-apply.md +5 -3
- package/assets/agents/sdd-explore.md +1 -0
- package/assets/agents/sdd-proposal.md +2 -0
- package/assets/agents/sdd-research.md +54 -0
- package/assets/agents/sdd-status.md +4 -4
- package/assets/agents/sdd-tasks.md +2 -3
- package/assets/agents/sdd-verify.md +21 -1
- package/assets/chains/sdd-full.chain.md +1 -1
- package/assets/chains/sdd-verify.chain.md +1 -1
- package/assets/orchestrator-delegation.md +56 -249
- package/assets/orchestrator-memory.md +2 -0
- package/assets/orchestrator.md +20 -40
- package/assets/sdd-orchestrator-workflow.md +30 -37
- package/assets/support/sdd-status-contract.md +7 -7
- package/contracts/review-integration/v1/schemas/transition-execution.schema.json +42 -0
- package/contracts/review-integration/v2/schemas/last-event-closure.schema.json +66 -0
- package/contracts/review-integration/v2/schemas/opencode-provider-role.schema.json +14 -0
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -7
- package/contracts/review-provider-contract-mirror/{v1.1.0 → v1.2.0}/bundle/README.md +10 -0
- package/contracts/review-provider-contract-mirror/v1.2.0/bundle/manifest.json +74 -0
- package/contracts/review-provider-contract-mirror/v1.2.0/bundle/orchestration/pi.md +53 -0
- package/contracts/review-provider-contract-mirror/v1.2.0/bundle/schemas/targeted-validator.schema.json +1 -0
- package/contracts/review-provider-contract-mirror/{v1.1.0 → v1.2.0}/generated/provider-capabilities.baseline.json +9 -2
- package/contracts/review-provider-contract-mirror/{v1.1.0 → v1.2.0}/generated/provider-roles.baseline.json +2 -2
- package/docs/native-authority-architecture.md +9 -11
- package/docs/review-integration.md +27 -373
- package/extensions/ask-user-choice.ts +151 -0
- package/extensions/gentle-ai.ts +2349 -3785
- package/extensions/quiet-tools.ts +515 -32
- package/extensions/sdd-init.ts +4 -8
- package/lib/agent-home.ts +8 -0
- package/lib/gentle-ai-renderer.ts +70 -0
- package/lib/model-routing-authority.ts +133 -0
- package/lib/native-review-cli.ts +387 -940
- package/lib/opaque-pi-reviewer-adapter.ts +284 -0
- package/lib/provider-contract-bundle.ts +88 -6
- package/lib/review-candidate-view.ts +341 -132
- package/lib/review-host-relay.ts +324 -96
- package/lib/review-integration-v2.ts +868 -307
- package/lib/review-last-event-controller.ts +35 -0
- package/lib/sdd-preflight.ts +179 -68
- package/lib/sdd-status.ts +66 -111
- package/lib/terminal-theme.ts +1 -1
- package/package.json +83 -82
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/native-review-cli.mjs +337 -890
- package/runtime/review-integration-v2.mjs +816 -255
- package/runtime/review-relay-contract.mjs +1 -1
- package/scripts/{build-git-commit-transaction-runner.mjs → build-runtime-modules.mjs} +4 -5
- package/scripts/gentle-ai-installer.mjs +75 -22
- package/scripts/maintainer/provider-relay-matrix.mjs +195 -11
- package/scripts/test-packed-runner.mjs +4 -7
- package/scripts/verify-package-files.mjs +23 -23
- package/skills/_shared/review-ledger-contract.md +14 -14
- package/skills/chained-pr/SKILL.md +3 -0
- package/skills/cognitive-doc-design/SKILL.md +1 -1
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/gentle-ai/SKILL.md +7 -74
- package/skills/issue-creation/SKILL.md +53 -93
- package/skills/judgment-day/SKILL.md +5 -7
- package/skills/rdd-defect-workflow/SKILL.md +3 -3
- package/skills/release/SKILL.md +3 -3
- package/skills/skill-registry/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +3 -1
- package/tests/artifact-language.test.ts +24 -11
- package/tests/ask-user-choice.test.ts +264 -0
- package/tests/codegraph-tools.test.ts +3 -3
- package/tests/crosslane/cross-lane.mjs +15 -1168
- package/tests/delegated-key-learnings-contract.test.ts +8 -6
- package/tests/devbinary/native-review-parity.devtest.ts +167 -250
- package/tests/devbinary/pi-host-relay.devtest.ts +867 -0
- package/tests/fixtures/devbinary/last-event-capture-correction-plan.captured.json +10 -0
- package/tests/fixtures/devbinary/last-event-capture-refuter-approved.captured.json +20 -0
- package/tests/fixtures/devbinary/last-event-capture-refuter-correction-required.captured.json +26 -0
- package/tests/fixtures/devbinary/last-event-capture-result-approved.captured.json +8 -0
- package/tests/fixtures/devbinary/last-event-capture-result-correction-required.captured.json +26 -0
- package/tests/fixtures/devbinary/last-event-capture-validation-approved.captured.json +8 -0
- package/tests/fixtures/devbinary/last-event-closure.provenance.md +13 -0
- package/tests/fixtures/devbinary/review-acknowledged-v1.captured.json +9 -0
- package/tests/fixtures/devbinary/review-acknowledged.provenance.md +31 -0
- package/tests/fixtures/devbinary/start-v3-zero-lens-closed.captured.json +21 -0
- package/tests/fixtures/native-review-cli/v2.5.0-rc.1/PROVENANCE.txt +15 -0
- package/tests/fixtures/provider-contract-bundle/v1.2.0/README.md +22 -0
- package/{contracts/review-provider-contract-mirror/v1.1.0/bundle → tests/fixtures/provider-contract-bundle/v1.2.0}/manifest.json +11 -2
- package/tests/fixtures/provider-contract-bundle/v1.2.0/orchestration/pi.md +97 -0
- package/tests/fixtures/provider-contract-bundle/v1.2.0/schemas/lens.schema.json +16 -0
- package/tests/fixtures/provider-contract-bundle/v1.2.0/schemas/refuter.schema.json +1 -0
- package/tests/fixtures/provider-contract-bundle/v1.2.0/vectors/lens.json +1 -0
- package/tests/fixtures/provider-contract-bundle/v1.2.0/vectors/refuter.json +1 -0
- package/tests/fixtures/provider-contract-bundle/v1.2.0/vectors/targeted-validator.json +1 -0
- package/tests/gentle-ai-binary.test.ts +83 -13
- package/tests/gentle-ai-dev-binary.test.ts +51 -228
- package/tests/gentle-ai-installer.test.ts +137 -47
- package/tests/gentle-ai.test.ts +821 -131
- package/tests/gentle-theme.test.ts +133 -0
- package/tests/issue-creation-skill.test.ts +103 -0
- package/tests/maintainer/provider-relay.maintest.ts +340 -4
- package/tests/model-routing-authority.test.ts +257 -0
- package/tests/native-review-capability-contract.test.ts +45 -1
- package/tests/native-review-cli.test.ts +586 -962
- package/tests/native-review-consent.test.ts +150 -66
- package/tests/native-review-parity-runtime.test.ts +80 -359
- package/tests/native-review-parity.test.ts +674 -925
- package/tests/opaque-pi-reviewer-adapter.test.ts +266 -0
- package/tests/orchestrator-budget.test.ts +132 -88
- package/tests/orchestrator-rdd-ownership.test.ts +103 -0
- package/tests/package-manifest.test.ts +152 -36
- package/tests/provider-contract-bundle.test.ts +76 -0
- package/tests/provider-contract-mirror.test.ts +19 -0
- package/tests/provider-defect-handoff.test.ts +15 -118
- package/tests/quiet-tool-rendering.test.ts +1055 -28
- package/tests/review-agent-end-preflight.test.ts +408 -0
- package/tests/review-authority-recovery-docs.test.ts +1 -2
- package/tests/review-candidate-view.test.ts +409 -3
- package/tests/review-compact-contract.test.ts +4 -30
- package/tests/review-contract-prompt.test.ts +139 -0
- package/tests/review-controller-lock-status.test.ts +2 -2
- package/tests/review-controller-native-recovery.test.ts +363 -1450
- package/tests/review-controller-native-routing.test.ts +1251 -5642
- package/tests/review-controller-retired-ops.test.ts +1 -1
- package/tests/review-controller-workspace-root.test.ts +222 -71
- package/tests/review-controller.test.ts +26 -816
- package/tests/review-corrected-finalize-binding.test.ts +112 -153
- package/tests/review-dispatch-hydration-gap.test.ts +1 -53
- package/tests/review-gate.test.ts +0 -45
- package/tests/review-host-relay-restart-parity.test.ts +360 -0
- package/tests/review-host-relay-routing.test.ts +328 -91
- package/tests/review-host-relay.test.ts +436 -14
- package/tests/review-integration-v2-forward.test.ts +623 -553
- package/tests/review-integration-v2.test.ts +239 -165
- package/tests/review-last-event-closure.test.ts +408 -0
- package/tests/review-ledger-contract.test.ts +97 -35
- package/tests/review-recovered-lineage-routing.test.ts +0 -47
- package/tests/review-relay-transport-agent.test.ts +119 -46
- package/tests/review-snapshot.test.ts +3 -2
- package/tests/runtime-harness.mjs +362 -196
- package/tests/sdd-agent-tools.test.ts +36 -0
- package/tests/sdd-preflight.test.ts +81 -15
- package/tests/sdd-status.test.ts +109 -110
- package/tests/skill-collision-prefixes.test.ts +5 -8
- package/tests/writer-edit-surface-scope.test.ts +366 -0
- package/themes/Gentleman-Cute.json +94 -0
- package/themes/Gentleman-Sexy.json +92 -0
- package/lib/git-commit-transaction.ts +0 -861
- package/runtime/git-commit-transaction.mjs +0 -862
- package/scripts/run-git-commit-transaction.mjs +0 -35
- package/tests/fixtures/native-review-cli/v2.1.3/sdd-status-engram.json +0 -139
- package/tests/fixtures/native-review-cli/v2.1.3/sdd-status.json +0 -200
- package/tests/git-commit-transaction.test.ts +0 -530
- /package/contracts/review-provider-contract-mirror/{v1.1.0 → v1.2.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.1.0 → v1.2.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.1.0 → v1.2.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.1.0 → v1.2.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.1.0 → v1.2.0}/bundle/vectors/targeted-validator.json +0 -0
- /package/{contracts/review-provider-contract-mirror/v1.1.0/bundle → tests/fixtures/provider-contract-bundle/v1.2.0}/schemas/targeted-validator.schema.json +0 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
8
|
+
import type { NativeReviewCli } from "../lib/native-review-cli.ts";
|
|
9
|
+
import type { ReviewStatusV3 } from "../lib/review-integration-v2.ts";
|
|
10
|
+
|
|
11
|
+
// gentle-pi#556 / gentle-ai#4051: with RDD enabled, the agent finished an
|
|
12
|
+
// implementation and reported completion without ever entering the review
|
|
13
|
+
// preflight. These tests cover the read-only, idempotent `agent_end` nudge
|
|
14
|
+
// that reminds the agent to call gentle_review before reporting completion,
|
|
15
|
+
// without ever starting a review or answering consent itself.
|
|
16
|
+
//
|
|
17
|
+
// gentle-pi#568: `session_start` records the target identity STATUS reports
|
|
18
|
+
// at session start as a baseline, so `agent_end` skips a candidate that
|
|
19
|
+
// already existed before this session touched the worktree (the user's own
|
|
20
|
+
// pre-session work, not this session's output). These tests point
|
|
21
|
+
// `GENTLE_PI_AGENT_HOME` and the session `cwd` at fresh temp directories so
|
|
22
|
+
// `session_start`'s real SDD asset install and model config sweep never
|
|
23
|
+
// touch this machine's actual home directory.
|
|
24
|
+
|
|
25
|
+
type AnyHandler = (event: unknown, ctx: ExtensionContext) => unknown;
|
|
26
|
+
type SentMessage = { message: Record<string, unknown>; options: Record<string, unknown> };
|
|
27
|
+
|
|
28
|
+
function harness(nativeReviewCli: NativeReviewCli | null): {
|
|
29
|
+
handlers: Map<string, AnyHandler>;
|
|
30
|
+
sent: SentMessage[];
|
|
31
|
+
} {
|
|
32
|
+
const handlers = new Map<string, AnyHandler>();
|
|
33
|
+
const sent: SentMessage[] = [];
|
|
34
|
+
const pi = {
|
|
35
|
+
on(name: string, handler: AnyHandler) {
|
|
36
|
+
handlers.set(name, handler);
|
|
37
|
+
},
|
|
38
|
+
events: { emit() {} },
|
|
39
|
+
registerCommand() {},
|
|
40
|
+
registerTool() {},
|
|
41
|
+
sendMessage(message: Record<string, unknown>, options: Record<string, unknown> = {}) {
|
|
42
|
+
sent.push({ message, options });
|
|
43
|
+
},
|
|
44
|
+
} as unknown as ExtensionAPI;
|
|
45
|
+
createGentleAiExtension({ nativeReviewCli })(pi);
|
|
46
|
+
return { handlers, sent };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function ctx(sessionId: string, hasUI = true, cwd = process.cwd()): ExtensionContext {
|
|
50
|
+
return {
|
|
51
|
+
cwd,
|
|
52
|
+
hasUI,
|
|
53
|
+
ui: { notify() {} },
|
|
54
|
+
sessionManager: { getSessionId: () => sessionId },
|
|
55
|
+
} as unknown as ExtensionContext;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function withSessionStartEnv<T>(callback: (cwd: string) => Promise<T>): Promise<T> {
|
|
59
|
+
const previousAgentHome = process.env.GENTLE_PI_AGENT_HOME;
|
|
60
|
+
const previousConfigHome = process.env.GENTLE_PI_CONFIG_HOME;
|
|
61
|
+
process.env.GENTLE_PI_AGENT_HOME = await mkdtemp(join(tmpdir(), "gentle-pi-session-baseline-agent-home-"));
|
|
62
|
+
// Isolates both the model-config sweep and the dev-binary registration
|
|
63
|
+
// lookup from this machine's real ~/.pi/gentle-ai, so `session_start`'s
|
|
64
|
+
// unrelated notifications never leak into these assertions.
|
|
65
|
+
process.env.GENTLE_PI_CONFIG_HOME = await mkdtemp(join(tmpdir(), "gentle-pi-session-baseline-config-home-"));
|
|
66
|
+
try {
|
|
67
|
+
const cwd = await mkdtemp(join(tmpdir(), "gentle-pi-session-baseline-cwd-"));
|
|
68
|
+
return await callback(cwd);
|
|
69
|
+
} finally {
|
|
70
|
+
if (previousAgentHome === undefined) delete process.env.GENTLE_PI_AGENT_HOME;
|
|
71
|
+
else process.env.GENTLE_PI_AGENT_HOME = previousAgentHome;
|
|
72
|
+
if (previousConfigHome === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
73
|
+
else process.env.GENTLE_PI_CONFIG_HOME = previousConfigHome;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function onMode(effective: "on" | "off"): NativeReviewCli["reviewMode"] {
|
|
78
|
+
return async () => ({
|
|
79
|
+
operation: "status",
|
|
80
|
+
scope: "clone",
|
|
81
|
+
status: { global: "", cloneLocal: effective === "on" ? "on" : "", effective, source: "clone_local" },
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function executeStartStatus(targetIdentity: string): ReviewStatusV3 {
|
|
86
|
+
return {
|
|
87
|
+
applicability: "unrelated",
|
|
88
|
+
action: "start",
|
|
89
|
+
targetIdentity,
|
|
90
|
+
nextTransition: { kind: "execute", execute: { operation: "review.start", arguments: [] } },
|
|
91
|
+
} as unknown as ReviewStatusV3;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function collectStatus(targetIdentity: string): ReviewStatusV3 {
|
|
95
|
+
return {
|
|
96
|
+
applicability: "unrelated",
|
|
97
|
+
action: "start",
|
|
98
|
+
targetIdentity,
|
|
99
|
+
nextTransition: { kind: "collect", collect: { inputs: [] } },
|
|
100
|
+
} as unknown as ReviewStatusV3;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function stopStatus(targetIdentity: string): ReviewStatusV3 {
|
|
104
|
+
return {
|
|
105
|
+
applicability: "unrelated",
|
|
106
|
+
action: "start",
|
|
107
|
+
targetIdentity,
|
|
108
|
+
nextTransition: { kind: "stop" },
|
|
109
|
+
} as unknown as ReviewStatusV3;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const agentEndEvent = { type: "agent_end", messages: [] };
|
|
113
|
+
|
|
114
|
+
test("agent_end performs no STATUS call and sends nothing when RDD is off", async () => {
|
|
115
|
+
const statusRequests: unknown[] = [];
|
|
116
|
+
const native = {
|
|
117
|
+
reviewMode: onMode("off"),
|
|
118
|
+
targetStatus: async (request: unknown) => {
|
|
119
|
+
statusRequests.push(request);
|
|
120
|
+
throw new Error("targetStatus must not be called when RDD is off");
|
|
121
|
+
},
|
|
122
|
+
} as unknown as NativeReviewCli;
|
|
123
|
+
const { handlers, sent } = harness(native);
|
|
124
|
+
const agentEnd = handlers.get("agent_end");
|
|
125
|
+
assert.equal(typeof agentEnd, "function");
|
|
126
|
+
await agentEnd!(agentEndEvent, ctx("agent-end-rdd-off"));
|
|
127
|
+
assert.deepEqual(statusRequests, []);
|
|
128
|
+
assert.deepEqual(sent, []);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("agent_end nudges exactly once when RDD is on and STATUS offers review.start", async () => {
|
|
132
|
+
const targetIdentity = `sha256:${"a".repeat(64)}`;
|
|
133
|
+
const statusRequests: Array<{ agent?: string }> = [];
|
|
134
|
+
const native = {
|
|
135
|
+
reviewMode: onMode("on"),
|
|
136
|
+
targetStatus: async (request: { agent?: string }) => {
|
|
137
|
+
statusRequests.push(request);
|
|
138
|
+
return executeStartStatus(targetIdentity);
|
|
139
|
+
},
|
|
140
|
+
} as unknown as NativeReviewCli;
|
|
141
|
+
const { handlers, sent } = harness(native);
|
|
142
|
+
const agentEnd = handlers.get("agent_end");
|
|
143
|
+
await agentEnd!(agentEndEvent, ctx("agent-end-execute"));
|
|
144
|
+
|
|
145
|
+
assert.equal(sent.length, 1);
|
|
146
|
+
const [entry] = sent;
|
|
147
|
+
assert.equal(entry?.message.customType, "gentle-pi.review-preflight");
|
|
148
|
+
const content = String(entry?.message.content);
|
|
149
|
+
assert.match(content, /gentle_review/);
|
|
150
|
+
assert.ok(content.includes(targetIdentity), "message must name the target identity");
|
|
151
|
+
assert.equal(entry?.options.triggerTurn, true);
|
|
152
|
+
assert.equal(statusRequests[0]?.agent, "pi");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("agent_end nudges once per target identity and again for a fresh identity", async () => {
|
|
156
|
+
let targetIdentity = `sha256:${"b".repeat(64)}`;
|
|
157
|
+
const native = {
|
|
158
|
+
reviewMode: onMode("on"),
|
|
159
|
+
targetStatus: async () => executeStartStatus(targetIdentity),
|
|
160
|
+
} as unknown as NativeReviewCli;
|
|
161
|
+
const { handlers, sent } = harness(native);
|
|
162
|
+
const agentEnd = handlers.get("agent_end");
|
|
163
|
+
const session = ctx("agent-end-repeat");
|
|
164
|
+
|
|
165
|
+
await agentEnd!(agentEndEvent, session);
|
|
166
|
+
await agentEnd!(agentEndEvent, session);
|
|
167
|
+
assert.equal(sent.length, 1, "the same target identity nudges only once");
|
|
168
|
+
|
|
169
|
+
targetIdentity = `sha256:${"e".repeat(64)}`;
|
|
170
|
+
await agentEnd!(agentEndEvent, session);
|
|
171
|
+
assert.equal(sent.length, 2, "a different target identity nudges again");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test("agent_end sends nothing when STATUS offers collect or stop", async () => {
|
|
175
|
+
for (const [label, status] of [
|
|
176
|
+
["collect", collectStatus(`sha256:${"c".repeat(64)}`)],
|
|
177
|
+
["stop", stopStatus(`sha256:${"d".repeat(64)}`)],
|
|
178
|
+
] as const) {
|
|
179
|
+
const native = {
|
|
180
|
+
reviewMode: onMode("on"),
|
|
181
|
+
targetStatus: async () => status,
|
|
182
|
+
} as unknown as NativeReviewCli;
|
|
183
|
+
const { handlers, sent } = harness(native);
|
|
184
|
+
const agentEnd = handlers.get("agent_end");
|
|
185
|
+
await agentEnd!(agentEndEvent, ctx(`agent-end-${label}`));
|
|
186
|
+
assert.deepEqual(sent, [], label);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test("agent_end skips headless sessions before any native call", async () => {
|
|
191
|
+
const native = {
|
|
192
|
+
reviewMode: async () => {
|
|
193
|
+
throw new Error("reviewMode must not be called when hasUI is false");
|
|
194
|
+
},
|
|
195
|
+
targetStatus: async () => {
|
|
196
|
+
throw new Error("targetStatus must not be called when hasUI is false");
|
|
197
|
+
},
|
|
198
|
+
} as unknown as NativeReviewCli;
|
|
199
|
+
const { handlers, sent } = harness(native);
|
|
200
|
+
const agentEnd = handlers.get("agent_end");
|
|
201
|
+
await agentEnd!(agentEndEvent, ctx("agent-end-no-ui", false));
|
|
202
|
+
assert.deepEqual(sent, []);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test("agent_end pairs a named agent's start with its own end, then still nudges for the primary loop's end", async () => {
|
|
206
|
+
const targetIdentity = `sha256:${"f".repeat(64)}`;
|
|
207
|
+
const native = {
|
|
208
|
+
reviewMode: onMode("on"),
|
|
209
|
+
targetStatus: async () => executeStartStatus(targetIdentity),
|
|
210
|
+
} as unknown as NativeReviewCli;
|
|
211
|
+
const { handlers, sent } = harness(native);
|
|
212
|
+
const beforeAgentStart = handlers.get("before_agent_start");
|
|
213
|
+
const agentEnd = handlers.get("agent_end");
|
|
214
|
+
assert.equal(typeof beforeAgentStart, "function");
|
|
215
|
+
const session = ctx("agent-end-subagent");
|
|
216
|
+
|
|
217
|
+
await beforeAgentStart!({ agentName: "review-readability", systemPrompt: "" }, session);
|
|
218
|
+
await agentEnd!(agentEndEvent, session);
|
|
219
|
+
assert.deepEqual(sent, [], "the subagent's own loop end is suppressed");
|
|
220
|
+
|
|
221
|
+
await agentEnd!(agentEndEvent, session);
|
|
222
|
+
assert.equal(sent.length, 1, "the primary loop's end still nudges once the subagent's end is paired off");
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("agent_end resets the subagent depth when a fresh primary loop starts", async () => {
|
|
226
|
+
const targetIdentity = `sha256:${"1".repeat(64)}`;
|
|
227
|
+
const native = {
|
|
228
|
+
reviewMode: onMode("on"),
|
|
229
|
+
targetStatus: async () => executeStartStatus(targetIdentity),
|
|
230
|
+
} as unknown as NativeReviewCli;
|
|
231
|
+
const { handlers, sent } = harness(native);
|
|
232
|
+
const beforeAgentStart = handlers.get("before_agent_start");
|
|
233
|
+
const agentEnd = handlers.get("agent_end");
|
|
234
|
+
const session = ctx("agent-end-subagent-reset");
|
|
235
|
+
|
|
236
|
+
await beforeAgentStart!({ agentName: "review-readability", systemPrompt: "" }, session);
|
|
237
|
+
await beforeAgentStart!({ systemPrompt: "" }, session);
|
|
238
|
+
await agentEnd!(agentEndEvent, session);
|
|
239
|
+
|
|
240
|
+
assert.equal(sent.length, 1, "a fresh primary-loop start resets the depth so its own end nudges");
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
test("agent_end handler exists but sends nothing when nativeReviewCli is null", async () => {
|
|
244
|
+
const { handlers, sent } = harness(null);
|
|
245
|
+
const agentEnd = handlers.get("agent_end");
|
|
246
|
+
assert.equal(typeof agentEnd, "function");
|
|
247
|
+
await agentEnd!(agentEndEvent, ctx("agent-end-null-cli"));
|
|
248
|
+
assert.deepEqual(sent, []);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
test("agent_end sends nothing and does not throw when target STATUS rejects", async () => {
|
|
252
|
+
const native = {
|
|
253
|
+
reviewMode: onMode("on"),
|
|
254
|
+
targetStatus: async () => {
|
|
255
|
+
throw new Error("native status unavailable");
|
|
256
|
+
},
|
|
257
|
+
} as unknown as NativeReviewCli;
|
|
258
|
+
const { handlers, sent } = harness(native);
|
|
259
|
+
const agentEnd = handlers.get("agent_end");
|
|
260
|
+
await assert.doesNotReject(async () => agentEnd!(agentEndEvent, ctx("agent-end-status-throws")));
|
|
261
|
+
assert.deepEqual(sent, []);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test("session_shutdown clears the nudged-target set for its session key", async () => {
|
|
265
|
+
const targetIdentity = `sha256:${"9".repeat(64)}`;
|
|
266
|
+
const native = {
|
|
267
|
+
reviewMode: onMode("on"),
|
|
268
|
+
targetStatus: async () => executeStartStatus(targetIdentity),
|
|
269
|
+
} as unknown as NativeReviewCli;
|
|
270
|
+
const { handlers, sent } = harness(native);
|
|
271
|
+
const agentEnd = handlers.get("agent_end");
|
|
272
|
+
const shutdown = handlers.get("session_shutdown");
|
|
273
|
+
assert.equal(typeof shutdown, "function");
|
|
274
|
+
const session = ctx("agent-end-shutdown");
|
|
275
|
+
|
|
276
|
+
await agentEnd!(agentEndEvent, session);
|
|
277
|
+
assert.equal(sent.length, 1);
|
|
278
|
+
|
|
279
|
+
await shutdown!({}, session);
|
|
280
|
+
await agentEnd!(agentEndEvent, session);
|
|
281
|
+
assert.equal(sent.length, 2, "shutdown clears the nudged set so the same identity nudges again");
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test("session_start records the baseline target identity when RDD is on", async () => {
|
|
285
|
+
const targetIdentity = `sha256:${"2".repeat(64)}`;
|
|
286
|
+
const statusRequests: Array<{ agent?: string }> = [];
|
|
287
|
+
const native = {
|
|
288
|
+
reviewMode: onMode("on"),
|
|
289
|
+
targetStatus: async (request: { agent?: string }) => {
|
|
290
|
+
statusRequests.push(request);
|
|
291
|
+
return executeStartStatus(targetIdentity);
|
|
292
|
+
},
|
|
293
|
+
} as unknown as NativeReviewCli;
|
|
294
|
+
await withSessionStartEnv(async (cwd) => {
|
|
295
|
+
const { handlers, sent } = harness(native);
|
|
296
|
+
const sessionStart = handlers.get("session_start");
|
|
297
|
+
assert.equal(typeof sessionStart, "function");
|
|
298
|
+
const notifications: Array<{ message: string; severity: string }> = [];
|
|
299
|
+
const session = {
|
|
300
|
+
...ctx("session-baseline-record", true, cwd),
|
|
301
|
+
ui: { notify: (message: string, severity: string) => notifications.push({ message, severity }) },
|
|
302
|
+
};
|
|
303
|
+
await sessionStart!({}, session);
|
|
304
|
+
assert.equal(statusRequests[0]?.agent, "pi");
|
|
305
|
+
assert.deepEqual(sent, []);
|
|
306
|
+
assert.deepEqual(notifications, []);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test("agent_end skips the candidate that matches the session's recorded baseline, then nudges for a new one", async () => {
|
|
311
|
+
let targetIdentity = `sha256:${"3".repeat(64)}`;
|
|
312
|
+
const native = {
|
|
313
|
+
reviewMode: onMode("on"),
|
|
314
|
+
targetStatus: async () => executeStartStatus(targetIdentity),
|
|
315
|
+
} as unknown as NativeReviewCli;
|
|
316
|
+
await withSessionStartEnv(async (cwd) => {
|
|
317
|
+
const { handlers, sent } = harness(native);
|
|
318
|
+
const sessionStart = handlers.get("session_start");
|
|
319
|
+
const agentEnd = handlers.get("agent_end");
|
|
320
|
+
const session = ctx("session-baseline-skip", true, cwd);
|
|
321
|
+
|
|
322
|
+
await sessionStart!({}, session);
|
|
323
|
+
await agentEnd!(agentEndEvent, session);
|
|
324
|
+
assert.deepEqual(sent, [], "the baseline candidate predates the session and is not nudged");
|
|
325
|
+
|
|
326
|
+
targetIdentity = `sha256:${"4".repeat(64)}`;
|
|
327
|
+
await agentEnd!(agentEndEvent, session);
|
|
328
|
+
assert.equal(sent.length, 1, "a candidate identity different from the baseline still nudges");
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
test("session_start with RDD off records no baseline, so agent_end still reminds once", async () => {
|
|
333
|
+
const targetIdentity = `sha256:${"5".repeat(64)}`;
|
|
334
|
+
let mode: "on" | "off" = "off";
|
|
335
|
+
const statusRequests: unknown[] = [];
|
|
336
|
+
const native = {
|
|
337
|
+
reviewMode: async () => ({
|
|
338
|
+
operation: "status",
|
|
339
|
+
scope: "clone",
|
|
340
|
+
status: { global: "", cloneLocal: mode === "on" ? "on" : "", effective: mode, source: "clone_local" },
|
|
341
|
+
}),
|
|
342
|
+
targetStatus: async (request: unknown) => {
|
|
343
|
+
statusRequests.push(request);
|
|
344
|
+
if (mode === "off") throw new Error("targetStatus must not be called when RDD is off");
|
|
345
|
+
return executeStartStatus(targetIdentity);
|
|
346
|
+
},
|
|
347
|
+
} as unknown as NativeReviewCli;
|
|
348
|
+
await withSessionStartEnv(async (cwd) => {
|
|
349
|
+
const { handlers, sent } = harness(native);
|
|
350
|
+
const sessionStart = handlers.get("session_start");
|
|
351
|
+
const agentEnd = handlers.get("agent_end");
|
|
352
|
+
const session = ctx("session-baseline-rdd-off", true, cwd);
|
|
353
|
+
|
|
354
|
+
await sessionStart!({}, session);
|
|
355
|
+
assert.deepEqual(statusRequests, []);
|
|
356
|
+
|
|
357
|
+
mode = "on";
|
|
358
|
+
await agentEnd!(agentEndEvent, session);
|
|
359
|
+
assert.equal(sent.length, 1, "no baseline was recorded while RDD was off, so the first dirty candidate still reminds");
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
test("session_start whose targetStatus rejects records no baseline, so agent_end still reminds once", async () => {
|
|
364
|
+
const targetIdentity = `sha256:${"6".repeat(64)}`;
|
|
365
|
+
let shouldThrow = true;
|
|
366
|
+
const native = {
|
|
367
|
+
reviewMode: onMode("on"),
|
|
368
|
+
targetStatus: async () => {
|
|
369
|
+
if (shouldThrow) throw new Error("native status unavailable at session start");
|
|
370
|
+
return executeStartStatus(targetIdentity);
|
|
371
|
+
},
|
|
372
|
+
} as unknown as NativeReviewCli;
|
|
373
|
+
await withSessionStartEnv(async (cwd) => {
|
|
374
|
+
const { handlers, sent } = harness(native);
|
|
375
|
+
const sessionStart = handlers.get("session_start");
|
|
376
|
+
const agentEnd = handlers.get("agent_end");
|
|
377
|
+
const session = ctx("session-baseline-throws", true, cwd);
|
|
378
|
+
|
|
379
|
+
await assert.doesNotReject(async () => sessionStart!({}, session));
|
|
380
|
+
|
|
381
|
+
shouldThrow = false;
|
|
382
|
+
await agentEnd!(agentEndEvent, session);
|
|
383
|
+
assert.equal(sent.length, 1, "STATUS threw at session_start, so no baseline was recorded and the candidate still reminds");
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
test("session_shutdown clears the recorded baseline so the same identity reminds again", async () => {
|
|
388
|
+
const targetIdentity = `sha256:${"7".repeat(64)}`;
|
|
389
|
+
const native = {
|
|
390
|
+
reviewMode: onMode("on"),
|
|
391
|
+
targetStatus: async () => executeStartStatus(targetIdentity),
|
|
392
|
+
} as unknown as NativeReviewCli;
|
|
393
|
+
await withSessionStartEnv(async (cwd) => {
|
|
394
|
+
const { handlers, sent } = harness(native);
|
|
395
|
+
const sessionStart = handlers.get("session_start");
|
|
396
|
+
const agentEnd = handlers.get("agent_end");
|
|
397
|
+
const shutdown = handlers.get("session_shutdown");
|
|
398
|
+
const session = ctx("session-baseline-shutdown", true, cwd);
|
|
399
|
+
|
|
400
|
+
await sessionStart!({}, session);
|
|
401
|
+
await agentEnd!(agentEndEvent, session);
|
|
402
|
+
assert.deepEqual(sent, [], "the baseline candidate is skipped");
|
|
403
|
+
|
|
404
|
+
await shutdown!({}, session);
|
|
405
|
+
await agentEnd!(agentEndEvent, session);
|
|
406
|
+
assert.equal(sent.length, 1, "shutdown cleared the baseline, so the same identity reminds again in the next session");
|
|
407
|
+
});
|
|
408
|
+
});
|
|
@@ -17,11 +17,10 @@ test("recovery guidance documents the narrow published native maintenance contra
|
|
|
17
17
|
assert.match(README, /review dispose-result.*unsupported.*pending.*design/i);
|
|
18
18
|
assert.match(README, /RESET.*RECOVER.*destructive/i);
|
|
19
19
|
assert.match(README, /typed envelopes/i);
|
|
20
|
-
assert.match(README, /pre-commit.*pre-push.*pre-PR.*release/is);
|
|
21
20
|
});
|
|
22
21
|
|
|
23
22
|
test("controller help keeps authorization, blocked outcomes, and recovery boundaries explicit", () => {
|
|
24
|
-
assert.match(CONTROLLER, /
|
|
23
|
+
assert.match(CONTROLLER, /REPAIR_LEGACY_ALIAS.*freshly reads native inventory.*interactive approval/is);
|
|
25
24
|
assert.match(CONTROLLER, /unchanged_target,malformed_recovery_authorization/);
|
|
26
25
|
assert.match(CONTROLLER, /provider-selected recovery disposition/);
|
|
27
26
|
assert.match(CONTROLLER, /headlessly|headless/i);
|