gentle-pi 3.6.0 → 4.0.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 +37 -6
- package/assets/agents/gentle-ai-explore.md +4 -4
- package/assets/agents/gentle-ai-verify.md +6 -4
- package/assets/agents/gentle-ai-worker.md +7 -9
- package/assets/orchestrator-delegation.md +40 -41
- package/assets/orchestrator-memory.md +1 -22
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator.md +12 -24
- package/assets/support/strict-tdd-verify.md +4 -266
- package/assets/support/strict-tdd.md +8 -360
- package/bin/gentle-shell.mjs +254 -29
- package/docs/delegated-verification.md +26 -1
- package/docs/gentle-agents-activity.md +24 -0
- package/docs/gentle-shell.md +95 -30
- package/docs/native-authority-architecture.md +2 -2
- package/docs/prompt-history.md +280 -0
- package/docs/readme-reference.md +117 -235
- package/docs/telemetry.md +1 -1
- package/docs/yolo-mode.md +86 -0
- package/extensions/child-context.ts +26 -0
- package/extensions/child-safety.ts +23 -0
- package/extensions/gentle-agents.ts +509 -275
- package/extensions/gentle-ai.ts +781 -683
- package/extensions/gentle-shell.ts +1375 -88
- package/extensions/gentle-stats.ts +101 -0
- package/extensions/gentle-todo.ts +18 -7
- package/extensions/history/atomic-write.ts +38 -0
- package/extensions/history/hide-prompts.ts +183 -0
- package/extensions/history/index.ts +1419 -0
- package/extensions/history/load-shared-history.ts +39 -0
- package/extensions/history/selector-helpers.ts +538 -0
- package/extensions/history/session-scan.ts +233 -0
- package/extensions/history/store.ts +1119 -0
- package/extensions/nan-provider.ts +6 -0
- package/extensions/quiet-tools.ts +179 -87
- package/extensions/resume-hint.ts +60 -0
- package/extensions/skill-registry.ts +16 -12
- package/extensions/startup-banner.ts +60 -31
- package/lib/agent-assets.ts +604 -0
- package/lib/agent-profile-pin.ts +12 -0
- package/lib/agents-message-delivery.ts +181 -0
- package/lib/agents-protocol.ts +60 -0
- package/lib/agents-runner.ts +105 -98
- package/lib/agents-view.ts +26 -3
- package/lib/agents-widget.ts +16 -9
- package/lib/append-system-prompt.ts +21 -0
- package/lib/bounded-writer-admission.ts +147 -0
- package/lib/card-style-policy.ts +60 -0
- package/lib/child-context-files.ts +166 -0
- package/lib/codemode-renderer.ts +185 -0
- package/lib/command-palette-catalog.ts +3 -9
- package/lib/command-palette.ts +25 -14
- package/lib/destructive-command-guard.ts +144 -0
- package/lib/foreign-target-grants.ts +32 -0
- package/lib/gentle-ai-elapsed-store.ts +87 -0
- package/lib/gentle-ai-renderer.ts +196 -39
- package/lib/gentle-shell-launcher.ts +24 -13
- package/lib/gentle-shell-resume-hint.ts +176 -0
- package/lib/history-capture-policy.ts +95 -0
- package/lib/model-routing-authority.ts +5 -1
- package/lib/nan-provider.ts +227 -0
- package/lib/native-review-cli.ts +53 -108
- package/lib/odd-phase-inference.ts +231 -0
- package/lib/odd-phase.ts +141 -0
- package/lib/overlay-repaint.ts +26 -0
- package/lib/pi-tui-keys.ts +53 -0
- package/lib/review-candidate-view-owner.ts +67 -17
- package/lib/review-candidate-view.ts +112 -25
- package/lib/review-reminder-receipt.ts +48 -8
- package/lib/review-risk-assessment.ts +156 -11
- package/lib/review-sidebar-state.ts +223 -0
- package/lib/selection-engine.ts +515 -0
- package/lib/session-change-capture.ts +10 -1
- package/lib/session-messaging-grants.ts +135 -0
- package/lib/session-worktree-registry.ts +14 -2
- package/lib/shell-bar.ts +179 -24
- package/lib/shell-card.ts +287 -18
- package/lib/shell-changes-view.ts +2 -1
- package/lib/shell-prompt.ts +102 -6
- package/lib/shell-sidebar-layout.ts +78 -14
- package/lib/shell-sidebar.ts +15 -1
- package/lib/shell-todo.ts +23 -13
- package/lib/shell-usage-view.ts +9 -4
- package/lib/shell-usage.ts +66 -10
- package/lib/stats-collector.ts +381 -0
- package/lib/stats-view.ts +431 -0
- package/lib/theme-customization.ts +52 -0
- package/lib/vim-editor-adapter.ts +379 -0
- package/lib/vim-normal-engine.ts +154 -0
- package/lib/vim-operator-engine.ts +416 -0
- package/lib/vim-policy.ts +49 -0
- package/lib/vim-visual-engine.ts +107 -0
- package/lib/visual-customization-policy.ts +108 -0
- package/lib/visual-customize-view.ts +330 -0
- package/lib/visual-profiles.ts +228 -0
- package/lib/yolo-session-policy.ts +240 -0
- package/package.json +20 -8
- package/runtime/gentle-shell-launcher.mjs +23 -12
- package/runtime/gentle-shell-resume-hint.mjs +177 -0
- package/runtime/native-review-cli.mjs +53 -108
- package/runtime/review-risk-assessment.mjs +154 -9
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +14 -13
- package/scripts/mirror-odd-routing.mjs +2 -2
- package/scripts/run-test-suite.mjs +76 -0
- package/scripts/test-packed-runner.mjs +31 -14
- package/scripts/verify-package-files.mjs +11 -22
- package/skills/branch-pr/SKILL.md +24 -52
- package/skills/chained-pr/SKILL.md +31 -15
- package/skills/chained-pr/references/chaining-details.md +31 -20
- package/skills/gentle-ai/SKILL.md +9 -15
- package/skills/issue-creation/SKILL.md +8 -2
- package/skills/issue-creation/references/delegated-workflow-actions.md +19 -0
- package/skills/work-unit-commits/SKILL.md +4 -3
- package/tests/agent-profiles.test.ts +18 -0
- package/tests/agents-fake-child.ts +2 -2
- package/tests/agents-message-delivery.test.ts +106 -0
- package/tests/agents-protocol.test.ts +40 -0
- package/tests/agents-runner.test.ts +400 -89
- package/tests/agents-view-thread-identity.test.ts +169 -0
- package/tests/agents-view.test.ts +8 -2
- package/tests/agents-widget.test.ts +154 -15
- package/tests/append-system-prompt-route.test.ts +160 -0
- package/tests/append-system-prompt.test.ts +46 -0
- package/tests/artifact-language.test.ts +19 -213
- package/tests/ask-user-question.test.ts +44 -1
- package/tests/asset-installation-runtime.test.ts +5 -16
- package/tests/autonomous-guard.test.ts +69 -1
- package/tests/bounded-writer-admission.test.ts +95 -0
- package/tests/branch-pr-skill.test.ts +43 -0
- package/tests/card-style-policy.test.ts +55 -0
- package/tests/chained-pr-skill.test.ts +124 -0
- package/tests/child-context-files.test.ts +255 -0
- package/tests/child-safety.test.ts +82 -0
- package/tests/codemode-rendering.test.ts +491 -0
- package/tests/command-palette.test.ts +39 -3
- package/tests/delegated-key-learnings-contract.test.ts +0 -76
- package/tests/destructive-command-guard.test.ts +84 -0
- package/tests/devbinary/native-review-parity.devtest.ts +170 -2
- package/tests/devbinary/non-git-subagent-bootstrap.devtest.ts +193 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/2026-09-28T10-00-00-000Z_aaa.jsonl +7 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/2026-09-29T23-00-00-000Z_bbb.jsonl +3 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/2026-09-30T08-00-00-000Z_ddd.jsonl +2 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/2026-09-30T09-00-00-000Z_eee.jsonl +3 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/run-1/session.jsonl +2 -0
- package/tests/fixtures/stats/sessions/--work-beta--/2026-09-01T12-00-00-000Z_ccc.jsonl +2 -0
- package/tests/fixtures/stats/user-pi/sessions/--work-alpha--/2026-09-28T10-00-00-000Z_aaa.jsonl +2 -0
- package/tests/fixtures/stats/user-pi/sessions/--work-alpha--/2026-09-29T23-00-00-000Z_bbb.jsonl +4 -0
- package/tests/fixtures/stats/user-pi/sessions/--work-gamma--/2026-09-20T09-00-00-000Z_fff.jsonl +3 -0
- package/tests/foreign-target-grants.test.ts +58 -0
- package/tests/generic-agent-tools.test.ts +54 -0
- package/tests/gentle-agents.test.ts +1411 -256
- package/tests/gentle-ai-binary.test.ts +3 -3
- package/tests/gentle-ai-elapsed-store.test.ts +68 -0
- package/tests/gentle-ai-installer.test.ts +68 -54
- package/tests/gentle-ai-renderer.test.ts +487 -8
- package/tests/gentle-ai.test.ts +288 -65
- package/tests/gentle-card-text.ts +2 -1
- package/tests/gentle-shell-bin.test.ts +651 -114
- package/tests/gentle-shell-launcher.test.ts +99 -52
- package/tests/gentle-shell-resume-hint.test.ts +270 -0
- package/tests/gentle-shell.test.ts +3839 -187
- package/tests/gentle-stats.test.ts +152 -0
- package/tests/gentle-theme.test.ts +4 -1
- package/tests/gentle-todo.test.ts +80 -8
- package/tests/history-atomic-write.test.ts +57 -0
- package/tests/history-capture-policy.test.ts +102 -0
- package/tests/history-command-registration.test.ts +164 -0
- package/tests/history-dedupe-entries.test.ts +123 -0
- package/tests/history-delete-backfill.test.ts +190 -0
- package/tests/history-delete-confirm.test.ts +460 -0
- package/tests/history-dispatch.test.ts +180 -0
- package/tests/history-drain-hidden.test.ts +110 -0
- package/tests/history-drain-order.test.ts +98 -0
- package/tests/history-expanded-globals.test.ts +62 -0
- package/tests/history-gc.test.ts +832 -0
- package/tests/history-header-layout.test.ts +265 -0
- package/tests/history-hide-prompts.test.ts +275 -0
- package/tests/history-lazy-windowing.test.ts +508 -0
- package/tests/history-legacy-migrate-v2.test.ts +297 -0
- package/tests/history-load-shared-history.test.ts +53 -0
- package/tests/history-max-results-cap.test.ts +76 -0
- package/tests/history-multi-reader.test.ts +203 -0
- package/tests/history-off-path.test.ts +170 -0
- package/tests/history-openflow-integration.test.ts +173 -0
- package/tests/history-overlay-margin.test.ts +326 -0
- package/tests/history-preview-layout.test.ts +93 -0
- package/tests/history-registry.test.ts +143 -0
- package/tests/history-scope-delete.test.ts +411 -0
- package/tests/history-search-caret-keys.test.ts +142 -0
- package/tests/history-seed-bootstrap.test.ts +170 -0
- package/tests/history-seed-regen.test.ts +129 -0
- package/tests/history-selector-windowing.test.ts +94 -0
- package/tests/history-session-scan-directory.test.ts +87 -0
- package/tests/history-session-scan-extract.test.ts +583 -0
- package/tests/history-session-writer.test.ts +351 -0
- package/tests/history-store-paths.test.ts +79 -0
- package/tests/history-tombstone-exact.test.ts +139 -0
- package/tests/history-wheel-mouse.test.ts +242 -0
- package/tests/inprocess-reviewer.test.ts +29 -19
- package/tests/issue-creation-skill.test.ts +61 -0
- package/tests/model-routing-authority.test.ts +16 -0
- package/tests/nan-provider.test.ts +471 -0
- package/tests/native-review-capability-contract.test.ts +13 -1
- package/tests/native-review-cli.test.ts +6 -120
- package/tests/native-review-parity-runtime.test.ts +100 -3
- package/tests/odd-integration.test.ts +67 -0
- package/tests/odd-phase-inference.test.ts +213 -0
- package/tests/odd-phase-loader.test.ts +253 -0
- package/tests/odd-phase.test.ts +307 -0
- package/tests/odd-routing-canonical-ratchet.test.ts +11 -6
- package/tests/odd-routing-contract.test.ts +86 -35
- package/tests/orchestrator-budget.test.ts +14 -39
- package/tests/orchestrator-rdd-ownership.test.ts +3 -3
- package/tests/overlay-repaint.test.ts +74 -0
- package/tests/package-manifest.test.ts +252 -115
- package/tests/packed-runner-owned-path.test.ts +46 -0
- package/tests/persona-single-channel.test.ts +6 -6
- package/tests/provider-defect-handoff.test.ts +3 -11
- package/tests/quiet-bash-runtime.test.ts +76 -0
- package/tests/quiet-tool-rendering.test.ts +409 -184
- package/tests/rdd-aware-verification-contract.test.ts +76 -1
- package/tests/rdd-status-line.test.ts +9 -4
- package/tests/resume-hint-extension.test.ts +122 -0
- package/tests/review-agent-end-preflight.test.ts +176 -12
- package/tests/review-candidate-owner-retry.test.ts +22 -1
- package/tests/review-candidate-view.test.ts +298 -0
- package/tests/review-contract-prompt.test.ts +108 -43
- package/tests/review-controller-lock-status.test.ts +0 -1
- package/tests/review-controller-native-routing.test.ts +611 -5
- package/tests/review-controller-workspace-root.test.ts +163 -4
- package/tests/review-host-relay-routing.test.ts +338 -2
- package/tests/review-integration-v2-forward.test.ts +200 -0
- package/tests/review-ledger-contract.test.ts +10 -34
- package/tests/review-reminder-receipt.test.ts +47 -1
- package/tests/review-risk-assessment.test.ts +498 -6
- package/tests/review-sidebar-state.test.ts +402 -0
- package/tests/run-test-suite.test.ts +124 -0
- package/tests/runtime-harness.mjs +145 -786
- package/tests/runtime-metrics-children.test.ts +16 -23
- package/tests/selection-engine.test.ts +421 -0
- package/tests/session-change-capture.test.ts +12 -1
- package/tests/session-messaging-grants.test.ts +255 -0
- package/tests/session-worktree-registry.test.ts +77 -0
- package/tests/shell-bar.test.ts +382 -1
- package/tests/shell-card.test.ts +353 -1
- package/tests/shell-changes-view.test.ts +52 -0
- package/tests/shell-prompt.test.ts +94 -2
- package/tests/shell-sidebar-layout.test.ts +325 -21
- package/tests/shell-sidebar-scroll-benchmark.test.ts +255 -0
- package/tests/shell-todo.test.ts +87 -1
- package/tests/shell-usage-view.test.ts +27 -0
- package/tests/shell-usage.test.ts +73 -0
- package/tests/skill-registry.test.ts +50 -1
- package/tests/startup-banner.test.ts +130 -2
- package/tests/stats-collector.test.ts +195 -0
- package/tests/stats-view.test.ts +202 -0
- package/tests/telemetry-trigger.test.ts +81 -20
- package/tests/theme-customization.test.ts +72 -0
- package/tests/vim-editor-adapter-host-resolution.test.ts +37 -0
- package/tests/vim-editor-adapter.test.ts +804 -0
- package/tests/vim-normal-engine.test.ts +101 -0
- package/tests/vim-operator-engine.test.ts +215 -0
- package/tests/vim-policy.test.ts +19 -0
- package/tests/vim-visual-engine.test.ts +52 -0
- package/tests/visual-customization-policy.test.ts +110 -0
- package/tests/visual-customize-view.test.ts +418 -0
- package/tests/visual-profiles.test.ts +87 -0
- package/tests/yolo-customize.test.ts +256 -0
- package/tests/yolo-mode-runtime.test.ts +161 -0
- package/tests/yolo-mode.test.ts +261 -0
- package/tests/yolo-session-policy.test.ts +59 -0
- package/themes/Gentle.json +2 -1
- package/themes/Gentleman-Cute.json +2 -1
- package/themes/Gentleman-Sexy.json +2 -1
- package/assets/agents/sdd-apply.md +0 -159
- package/assets/agents/sdd-archive.md +0 -228
- package/assets/agents/sdd-design.md +0 -49
- package/assets/agents/sdd-explore.md +0 -48
- package/assets/agents/sdd-init.md +0 -56
- package/assets/agents/sdd-onboard.md +0 -52
- package/assets/agents/sdd-proposal.md +0 -64
- package/assets/agents/sdd-remediate.md +0 -37
- package/assets/agents/sdd-research.md +0 -49
- package/assets/agents/sdd-spec.md +0 -192
- package/assets/agents/sdd-status.md +0 -54
- package/assets/agents/sdd-tasks.md +0 -108
- package/assets/agents/sdd-verify.md +0 -124
- package/assets/chains/sdd-full.chain.md +0 -83
- package/assets/chains/sdd-plan.chain.md +0 -56
- package/assets/chains/sdd-verify.chain.md +0 -43
- package/assets/sdd-orchestrator-workflow.md +0 -319
- package/assets/support/sdd-status-contract.md +0 -77
- package/docs/assets/diagrams/sdd-cycle.svg +0 -14
- package/extensions/sdd-init.ts +0 -816
- package/lib/openspec-deltas.ts +0 -156
- package/lib/sdd-preflight.ts +0 -1066
- package/lib/sdd-research-capabilities.ts +0 -94
- package/lib/sdd-status.ts +0 -26
- package/tests/fixtures/legacy/sdd-research-v2.5.0.md +0 -54
- package/tests/fixtures/native-review-cli/v2.1.3/bind-sdd.json +0 -25
- package/tests/fixtures/v0.10.7/assets/agents/sdd-apply.md +0 -132
- package/tests/openspec-deltas.test.ts +0 -209
- package/tests/sdd-agent-tools.test.ts +0 -156
- package/tests/sdd-archive-replay.test.ts +0 -82
- package/tests/sdd-classical-continuation.test.ts +0 -74
- package/tests/sdd-execution-routing-contract.test.ts +0 -44
- package/tests/sdd-managed-runtime-settlement.test.ts +0 -155
- package/tests/sdd-native-managed-uptake.test.ts +0 -243
- package/tests/sdd-no-attempts-contract.test.ts +0 -15
- package/tests/sdd-odd-integration.test.ts +0 -33
- package/tests/sdd-optional-research.test.ts +0 -124
- package/tests/sdd-planning-routing-contract.test.ts +0 -45
- package/tests/sdd-preflight-rpc-input.test.ts +0 -125
- package/tests/sdd-preflight.test.ts +0 -541
- package/tests/sdd-research-capabilities.test.ts +0 -114
- package/tests/sdd-research-live.test.ts +0 -241
- package/tests/sdd-selection-transport.test.ts +0 -653
- package/tests/sdd-status.test.ts +0 -9
- package/tests/sdd-task-truth.test.ts +0 -43
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
2
4
|
import test from "node:test";
|
|
3
5
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
4
6
|
import { createGentleAiExtension, __testing } from "../extensions/gentle-ai.ts";
|
|
@@ -26,6 +28,7 @@ import {
|
|
|
26
28
|
type WriterProfile,
|
|
27
29
|
type NativeReviewOutcome,
|
|
28
30
|
} from "../lib/review-risk-assessment.ts";
|
|
31
|
+
import { consumeReviewMutation, pendingReviewMutation, recordReviewMutation } from "../lib/review-reminder-receipt.ts";
|
|
29
32
|
|
|
30
33
|
// ---------------------------------------------------------------------------
|
|
31
34
|
// gentle-pi#662: decoder for the native `gentle-ai review assess` envelope
|
|
@@ -80,13 +83,225 @@ test("decodeReviewAssessmentV1 rejects a malformed shape", () => {
|
|
|
80
83
|
assert.throws(() => decodeReviewAssessmentV1(null), TypeError);
|
|
81
84
|
assert.throws(() => decodeReviewAssessmentV1("gentle-ai.review-assessment/v1"), TypeError);
|
|
82
85
|
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ reasons: "none" })), TypeError);
|
|
83
|
-
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ reasons: [{ code: "x" }] })), TypeError);
|
|
84
86
|
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ changed_paths: -1 })), TypeError);
|
|
85
87
|
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ changed_lines: 1.5 })), TypeError);
|
|
86
88
|
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ candidate: { kind: "unknown-kind" } })), TypeError);
|
|
87
89
|
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ candidate: { kind: "current-changes", base_ref: "" } })), TypeError);
|
|
88
90
|
});
|
|
89
91
|
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
// gentle-pi#1175: the native v2 `assess.schema.json` requires only `code` on a
|
|
94
|
+
// reason, and adds `candidate.consumed`, `review_due`, `review_due_reason`,
|
|
95
|
+
// and `next_transition`. Older binaries (for example gentle-ai v3.7.0)
|
|
96
|
+
// predate those fields; they must decode without invented values.
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
function nextTransition(overrides: Record<string, unknown> = {}): Record<string, unknown> {
|
|
100
|
+
return {
|
|
101
|
+
operation: "review.status",
|
|
102
|
+
command: "gentle-ai",
|
|
103
|
+
arguments: [
|
|
104
|
+
{ name: "review", value: "" },
|
|
105
|
+
{ name: "--cwd", value: "/repo" },
|
|
106
|
+
{ name: "--next-transition", value: "start", token: "opaque-token" },
|
|
107
|
+
],
|
|
108
|
+
...overrides,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function newEnvelope(overrides: Record<string, unknown> = {}): Record<string, unknown> {
|
|
113
|
+
return validEnvelope({
|
|
114
|
+
risk: "high",
|
|
115
|
+
candidate: { kind: "current-changes", consumed: false },
|
|
116
|
+
review_due: true,
|
|
117
|
+
review_due_reason: "high_risk",
|
|
118
|
+
next_transition: nextTransition(),
|
|
119
|
+
...overrides,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
test("decodeReviewAssessmentV1 accepts a reason carrying only code and never synthesizes path or detail", () => {
|
|
124
|
+
const decoded = decodeReviewAssessmentV1(validEnvelope({ reasons: [{ code: "x" }, { code: "y", path: "a.ts" }, { code: "z", detail: "why" }] }));
|
|
125
|
+
assert.deepEqual(decoded.reasons, [{ code: "x" }, { code: "y", path: "a.ts" }, { code: "z", detail: "why" }]);
|
|
126
|
+
assert.equal(Object.hasOwn(decoded.reasons[0], "path"), false);
|
|
127
|
+
assert.equal(Object.hasOwn(decoded.reasons[0], "detail"), false);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("decodeReviewAssessmentV1 rejects a reason with a missing code or an empty/non-string path or detail", () => {
|
|
131
|
+
for (const reason of [
|
|
132
|
+
{},
|
|
133
|
+
{ code: "" },
|
|
134
|
+
{ code: 1 },
|
|
135
|
+
{ path: "a.ts", detail: "why" },
|
|
136
|
+
{ code: "x", path: "" },
|
|
137
|
+
{ code: "x", detail: "" },
|
|
138
|
+
{ code: "x", path: 1 },
|
|
139
|
+
{ code: "x", detail: null },
|
|
140
|
+
"x",
|
|
141
|
+
]) {
|
|
142
|
+
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ reasons: [reason] })), TypeError, `reason ${JSON.stringify(reason)} must be rejected`);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("decodeReviewAssessmentV1 accepts an older envelope without consumed/review_due/review_due_reason and invents none of them", () => {
|
|
147
|
+
const decoded = decodeReviewAssessmentV1(validEnvelope());
|
|
148
|
+
for (const key of ["reviewDue", "reviewDueReason", "nextTransition"]) {
|
|
149
|
+
assert.equal(Object.hasOwn(decoded, key), false, `${key} must stay absent`);
|
|
150
|
+
}
|
|
151
|
+
assert.equal(Object.hasOwn(decoded.candidate, "consumed"), false, "consumed must stay absent, never defaulted");
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("decodeReviewAssessmentV1 decodes consumed, review_due, review_due_reason, and next_transition verbatim", () => {
|
|
155
|
+
const transition = nextTransition();
|
|
156
|
+
const decoded = decodeReviewAssessmentV1(newEnvelope({ next_transition: transition }));
|
|
157
|
+
assert.deepEqual(decoded.candidate, { kind: "current-changes", baseRef: undefined, consumed: false });
|
|
158
|
+
assert.equal(decoded.reviewDue, true);
|
|
159
|
+
assert.equal(decoded.reviewDueReason, "high_risk");
|
|
160
|
+
assert.deepEqual(decoded.nextTransition, nextTransition());
|
|
161
|
+
assert.equal(JSON.stringify(decoded.nextTransition), JSON.stringify(nextTransition()), "next_transition must keep its native key and argument order");
|
|
162
|
+
|
|
163
|
+
const consumed = decodeReviewAssessmentV1(newEnvelope({ candidate: { kind: "base-diff", base_ref: "origin/main", consumed: true }, review_due: false, review_due_reason: "already_reviewed", next_transition: undefined }));
|
|
164
|
+
assert.deepEqual(consumed.candidate, { kind: "base-diff", baseRef: "origin/main", consumed: true });
|
|
165
|
+
assert.equal(consumed.reviewDue, false);
|
|
166
|
+
assert.equal(consumed.reviewDueReason, "already_reviewed");
|
|
167
|
+
assert.equal(Object.hasOwn(consumed, "nextTransition"), false);
|
|
168
|
+
|
|
169
|
+
for (const pair of CONSISTENT_REVIEW_DUE_PAIRS) {
|
|
170
|
+
assert.equal(decodeReviewAssessmentV1(consistentEnvelope(pair)).reviewDueReason, pair.reason);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const noToken = decodeReviewAssessmentV1(newEnvelope({ next_transition: nextTransition({ arguments: [] }) }));
|
|
174
|
+
assert.deepEqual(noToken.nextTransition, nextTransition({ arguments: [] }));
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("decodeReviewAssessmentV1 rejects malformed consumed, review_due, and review_due_reason values", () => {
|
|
178
|
+
for (const consumed of ["true", 0, null]) {
|
|
179
|
+
assert.throws(() => decodeReviewAssessmentV1(newEnvelope({ candidate: { kind: "current-changes", consumed } })), TypeError, `consumed ${JSON.stringify(consumed)} must be rejected`);
|
|
180
|
+
}
|
|
181
|
+
for (const reviewDueReason of ["low_risk", "", 1, null]) {
|
|
182
|
+
assert.throws(() => decodeReviewAssessmentV1(newEnvelope({ review_due_reason: reviewDueReason })), TypeError, `review_due_reason ${JSON.stringify(reviewDueReason)} must be rejected`);
|
|
183
|
+
}
|
|
184
|
+
for (const reviewDue of ["true", 1, null]) {
|
|
185
|
+
assert.throws(() => decodeReviewAssessmentV1(newEnvelope({ review_due: reviewDue })), TypeError, `review_due ${JSON.stringify(reviewDue)} must be rejected`);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// gentle-pi#1175 (T2): the native schema fixes review_due by reason
|
|
190
|
+
// (true for high_risk and slice_budget_reached, false for passive,
|
|
191
|
+
// under_budget, and already_reviewed), and already_reviewed is reported
|
|
192
|
+
// exactly when the candidate is consumed. A contradictory envelope can never
|
|
193
|
+
// be trusted as closure evidence, so it fails decoding.
|
|
194
|
+
interface ReviewDuePair {
|
|
195
|
+
reason: string;
|
|
196
|
+
due: boolean;
|
|
197
|
+
consumed: boolean;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const CONSISTENT_REVIEW_DUE_PAIRS: readonly ReviewDuePair[] = [
|
|
201
|
+
{ reason: "high_risk", due: true, consumed: false },
|
|
202
|
+
{ reason: "slice_budget_reached", due: true, consumed: false },
|
|
203
|
+
{ reason: "passive", due: false, consumed: false },
|
|
204
|
+
{ reason: "under_budget", due: false, consumed: false },
|
|
205
|
+
{ reason: "already_reviewed", due: false, consumed: true },
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
function consistentEnvelope(pair: ReviewDuePair): Record<string, unknown> {
|
|
209
|
+
return newEnvelope({
|
|
210
|
+
candidate: { kind: "current-changes", consumed: pair.consumed },
|
|
211
|
+
review_due: pair.due,
|
|
212
|
+
review_due_reason: pair.reason,
|
|
213
|
+
next_transition: pair.due ? nextTransition() : undefined,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
test("decodeReviewAssessmentV1 accepts every consistent review_due/review_due_reason/consumed combination", () => {
|
|
218
|
+
for (const pair of CONSISTENT_REVIEW_DUE_PAIRS) {
|
|
219
|
+
const decoded = decodeReviewAssessmentV1(consistentEnvelope(pair));
|
|
220
|
+
assert.equal(decoded.reviewDue, pair.due, pair.reason);
|
|
221
|
+
assert.equal(decoded.reviewDueReason, pair.reason);
|
|
222
|
+
assert.equal(decoded.candidate.consumed, pair.consumed, pair.reason);
|
|
223
|
+
}
|
|
224
|
+
// Without next_transition the due pairs stay consistent too.
|
|
225
|
+
assert.equal(decodeReviewAssessmentV1(newEnvelope({ next_transition: undefined })).reviewDueReason, "high_risk");
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test("decodeReviewAssessmentV1 rejects a review_due boolean that contradicts review_due_reason", () => {
|
|
229
|
+
for (const pair of CONSISTENT_REVIEW_DUE_PAIRS) {
|
|
230
|
+
const contradictory = newEnvelope({
|
|
231
|
+
candidate: { kind: "current-changes", consumed: pair.consumed },
|
|
232
|
+
review_due: !pair.due,
|
|
233
|
+
review_due_reason: pair.reason,
|
|
234
|
+
next_transition: undefined,
|
|
235
|
+
});
|
|
236
|
+
assert.throws(() => decodeReviewAssessmentV1(contradictory), TypeError, `review_due ${!pair.due} with ${pair.reason} must be rejected`);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test("decodeReviewAssessmentV1 rejects already_reviewed unless the candidate is consumed", () => {
|
|
241
|
+
for (const candidate of [{ kind: "current-changes", consumed: false }, { kind: "current-changes" }]) {
|
|
242
|
+
assert.throws(
|
|
243
|
+
() => decodeReviewAssessmentV1(newEnvelope({ candidate, review_due: false, review_due_reason: "already_reviewed", next_transition: undefined })),
|
|
244
|
+
TypeError,
|
|
245
|
+
`already_reviewed with ${JSON.stringify(candidate)} must be rejected`,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test("decodeReviewAssessmentV1 rejects a consumed candidate reported with any reason other than already_reviewed", () => {
|
|
251
|
+
for (const pair of CONSISTENT_REVIEW_DUE_PAIRS.filter((entry) => entry.reason !== "already_reviewed")) {
|
|
252
|
+
assert.throws(
|
|
253
|
+
() => decodeReviewAssessmentV1(newEnvelope({
|
|
254
|
+
candidate: { kind: "current-changes", consumed: true },
|
|
255
|
+
review_due: pair.due,
|
|
256
|
+
review_due_reason: pair.reason,
|
|
257
|
+
next_transition: pair.due ? nextTransition() : undefined,
|
|
258
|
+
})),
|
|
259
|
+
TypeError,
|
|
260
|
+
`consumed with ${pair.reason} must be rejected`,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("decodeReviewAssessmentV1 still accepts an older envelope without the review_due pair", () => {
|
|
266
|
+
assert.equal(decodeReviewAssessmentV1(validEnvelope()).risk, "medium");
|
|
267
|
+
assert.equal(Object.hasOwn(decodeReviewAssessmentV1(validEnvelope({ risk: "passive", reasons: [] })), "reviewDue"), false);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("decodeReviewAssessmentV1 rejects only one of the review_due/review_due_reason pair", () => {
|
|
271
|
+
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ review_due: false })), TypeError);
|
|
272
|
+
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ review_due_reason: "passive" })), TypeError);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
test("decodeReviewAssessmentV1 rejects a malformed next_transition or one not backed by review_due true", () => {
|
|
276
|
+
const malformed: Record<string, unknown>[] = [
|
|
277
|
+
nextTransition({ operation: "review.start" }),
|
|
278
|
+
nextTransition({ extra: true }),
|
|
279
|
+
nextTransition({ command: undefined }),
|
|
280
|
+
nextTransition({ command: "" }),
|
|
281
|
+
nextTransition({ arguments: undefined }),
|
|
282
|
+
nextTransition({ arguments: "--cwd" }),
|
|
283
|
+
nextTransition({ arguments: [{ name: "--cwd", value: "/repo", token: "" }] }),
|
|
284
|
+
nextTransition({ arguments: [{ name: "", value: "/repo" }] }),
|
|
285
|
+
nextTransition({ arguments: [{ name: "--cwd" }] }),
|
|
286
|
+
nextTransition({ arguments: [{ name: "--cwd", value: 1 }] }),
|
|
287
|
+
nextTransition({ arguments: [{ name: "--cwd", value: "/repo", extra: "x" }] }),
|
|
288
|
+
nextTransition({ arguments: [null] }),
|
|
289
|
+
];
|
|
290
|
+
for (const transition of malformed) {
|
|
291
|
+
assert.throws(() => decodeReviewAssessmentV1(newEnvelope({ next_transition: transition })), TypeError, `next_transition ${JSON.stringify(transition)} must be rejected`);
|
|
292
|
+
}
|
|
293
|
+
assert.throws(() => decodeReviewAssessmentV1(newEnvelope({ next_transition: null })), TypeError);
|
|
294
|
+
assert.throws(() => decodeReviewAssessmentV1(newEnvelope({ review_due: false, review_due_reason: "passive" })), TypeError, "next_transition requires review_due true");
|
|
295
|
+
assert.throws(() => decodeReviewAssessmentV1(validEnvelope({ next_transition: nextTransition() })), TypeError, "next_transition requires review_due true");
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
test("decodeReviewAssessmentV1 ignores unknown top-level fields and never projects them", () => {
|
|
299
|
+
const decoded = decodeReviewAssessmentV1(newEnvelope({ future_field: { anything: true } }));
|
|
300
|
+
assert.equal(Object.hasOwn(decoded, "future_field"), false);
|
|
301
|
+
assert.equal(Object.hasOwn(decoded, "futureField"), false);
|
|
302
|
+
assert.equal(decoded.reviewDue, true);
|
|
303
|
+
});
|
|
304
|
+
|
|
90
305
|
// ---------------------------------------------------------------------------
|
|
91
306
|
// verificationPlan: every (rdd, risk, profile) combination from gentle-pi#662.
|
|
92
307
|
// ---------------------------------------------------------------------------
|
|
@@ -501,7 +716,7 @@ function assessOnNativeCli(currentTargetIdentity: () => string): Partial<NativeR
|
|
|
501
716
|
};
|
|
502
717
|
}
|
|
503
718
|
|
|
504
|
-
test("gentle_review assess: derivation is bound to the exact candidate recorded, closed
|
|
719
|
+
test("gentle_review assess: derivation is bound to the exact candidate recorded, and a caller-declared closed is never trusted without native evidence (gentle-pi#668 correction, gentle-pi#1175)", async (t) => {
|
|
505
720
|
t.after(() => __testing.clearNativeReviewOutcomeMemoForTesting());
|
|
506
721
|
__testing.clearNativeReviewOutcomeMemoForTesting();
|
|
507
722
|
let current = "target-a";
|
|
@@ -529,12 +744,240 @@ test("gentle_review assess: derivation is bound to the exact candidate recorded,
|
|
|
529
744
|
assert.equal(forB.outcome_source, "unknown");
|
|
530
745
|
assert.equal(forB.plan.independentVerifier, true);
|
|
531
746
|
|
|
532
|
-
//
|
|
747
|
+
// gentle-pi#1175: a caller-declared closed is only a claim. This older
|
|
748
|
+
// assessment carries no candidate.consumed, so it fails closed to unknown.
|
|
533
749
|
const closed = (await tool.execute("call-14", { operation: "assess", input: JSON.stringify({ nativeReviewOutcome: "closed" }) }, undefined, undefined, ctx)).details as { nativeReviewOutcome: string; outcome_source: string; plan: { independentVerifier: boolean; writerSelfVerification: boolean } };
|
|
534
|
-
assert.equal(closed.nativeReviewOutcome, "
|
|
535
|
-
assert.equal(closed.outcome_source, "
|
|
750
|
+
assert.equal(closed.nativeReviewOutcome, "unknown");
|
|
751
|
+
assert.equal(closed.outcome_source, "unknown");
|
|
536
752
|
assert.equal(closed.plan.writerSelfVerification, true);
|
|
537
|
-
assert.equal(closed.plan.independentVerifier,
|
|
753
|
+
assert.equal(closed.plan.independentVerifier, true, "an uncorroborated closed claim must keep the separate verifier");
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
// ---------------------------------------------------------------------------
|
|
757
|
+
// gentle-pi#1175 (T2): closure comes only from the exact native evidence of
|
|
758
|
+
// THIS assess call -- candidate.consumed === true, which native writes only
|
|
759
|
+
// inside the approved-acknowledgement burn for that exact target identity.
|
|
760
|
+
// ---------------------------------------------------------------------------
|
|
761
|
+
|
|
762
|
+
interface ClosureCliOptions {
|
|
763
|
+
rdd?: "on" | "off";
|
|
764
|
+
risk?: "passive" | "medium" | "high";
|
|
765
|
+
/** undefined models an older binary that reports no consumed/review_due. */
|
|
766
|
+
consumed?: boolean;
|
|
767
|
+
targetIdentity?: () => string;
|
|
768
|
+
unassessable?: boolean;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function closureCli(options: ClosureCliOptions): Partial<NativeReviewCli> {
|
|
772
|
+
const rdd = options.rdd ?? "on";
|
|
773
|
+
const risk = options.risk ?? "high";
|
|
774
|
+
const raw = options.consumed === undefined
|
|
775
|
+
? validEnvelope({ risk, reasons: [] })
|
|
776
|
+
: validEnvelope({
|
|
777
|
+
risk,
|
|
778
|
+
reasons: [],
|
|
779
|
+
candidate: { kind: "current-changes", consumed: options.consumed },
|
|
780
|
+
review_due: options.consumed ? false : risk === "high",
|
|
781
|
+
review_due_reason: options.consumed ? "already_reviewed" : risk === "high" ? "high_risk" : risk === "passive" ? "passive" : "under_budget",
|
|
782
|
+
});
|
|
783
|
+
return {
|
|
784
|
+
reviewMode: async () => ({ operation: "status", scope: "clone", status: { global: rdd, cloneLocal: "", effective: rdd, source: NATIVE_REVIEW_MODE_SOURCE.GLOBAL } }),
|
|
785
|
+
assess: async () => {
|
|
786
|
+
if (options.unassessable) throw new Error("native process failed");
|
|
787
|
+
return decodeReviewAssessmentV1(raw);
|
|
788
|
+
},
|
|
789
|
+
...(options.targetIdentity === undefined ? {} : {
|
|
790
|
+
targetStatus: (async () => ({ applicability: "current_target", targetIdentity: options.targetIdentity!() })) as unknown as NativeReviewCli["targetStatus"],
|
|
791
|
+
}),
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
interface AssessDetails {
|
|
796
|
+
risk: string;
|
|
797
|
+
nativeReviewOutcome: string;
|
|
798
|
+
outcome_source: string;
|
|
799
|
+
writerProfile: string;
|
|
800
|
+
writerProfileSource: string;
|
|
801
|
+
plan: { writerSelfVerification: boolean; independentVerifier: boolean; structuralReadbackOnly: boolean };
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
async function assessWith(cli: Partial<NativeReviewCli>, input?: Record<string, unknown>, context: ExtensionContext = ctx): Promise<AssessDetails> {
|
|
805
|
+
const params = input === undefined ? { operation: "assess" } : { operation: "assess", input: JSON.stringify(input) };
|
|
806
|
+
return (await reviewControllerTool(cli).execute("closure", params, undefined, undefined, context)).details as AssessDetails;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
test("gentle_review assess: native consumed true derives closed for this candidate", async () => {
|
|
810
|
+
const details = await assessWith(closureCli({ consumed: true }));
|
|
811
|
+
assert.equal(details.nativeReviewOutcome, "closed");
|
|
812
|
+
assert.equal(details.outcome_source, "derived");
|
|
813
|
+
assert.equal(details.plan.writerSelfVerification, true);
|
|
814
|
+
assert.equal(details.plan.independentVerifier, false, "a natively closed candidate restores the RDD on-path");
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
test("gentle_review assess: a caller-declared closed without native consumed evidence fails closed to unknown", async () => {
|
|
818
|
+
for (const consumed of [false, undefined]) {
|
|
819
|
+
const details = await assessWith(closureCli({ consumed }), { nativeReviewOutcome: "closed" });
|
|
820
|
+
assert.equal(details.nativeReviewOutcome, "unknown", `consumed ${String(consumed)}`);
|
|
821
|
+
assert.equal(details.outcome_source, "unknown");
|
|
822
|
+
assert.equal(details.plan.independentVerifier, true);
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
test("gentle_review assess: a caller-declared closed corroborated by native consumed stays closed", async () => {
|
|
827
|
+
const details = await assessWith(closureCli({ consumed: true }), { nativeReviewOutcome: "closed" });
|
|
828
|
+
assert.equal(details.nativeReviewOutcome, "closed");
|
|
829
|
+
assert.equal(details.outcome_source, "derived", "closure is attributed to the native evidence, not to the caller's claim");
|
|
830
|
+
assert.equal(details.plan.independentVerifier, false);
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
test("gentle_review assess: explicit declined, unavailable, or unknown beats native consumed (only ever raises the bar)", async () => {
|
|
834
|
+
for (const outcome of ["declined", "unavailable", "unknown"]) {
|
|
835
|
+
const details = await assessWith(closureCli({ consumed: true }), { nativeReviewOutcome: outcome });
|
|
836
|
+
assert.equal(details.nativeReviewOutcome, outcome);
|
|
837
|
+
assert.equal(details.outcome_source, "explicit");
|
|
838
|
+
assert.equal(details.plan.independentVerifier, true, `${outcome} must keep the risk-gated verifier`);
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
test("gentle_review assess: a recorded decline for the same candidate beats native consumed and a caller-declared closed", async (t) => {
|
|
843
|
+
t.after(() => __testing.clearNativeReviewOutcomeMemoForTesting());
|
|
844
|
+
__testing.clearNativeReviewOutcomeMemoForTesting();
|
|
845
|
+
__testing.recordNativeReviewOutcome(ctx.cwd, "target-a", "declined");
|
|
846
|
+
const cli = closureCli({ consumed: true, targetIdentity: () => "target-a" });
|
|
847
|
+
for (const input of [undefined, { nativeReviewOutcome: "closed" }]) {
|
|
848
|
+
const details = await assessWith(cli, input);
|
|
849
|
+
assert.equal(details.nativeReviewOutcome, "declined", JSON.stringify(input));
|
|
850
|
+
assert.equal(details.outcome_source, "derived");
|
|
851
|
+
assert.equal(details.plan.independentVerifier, true);
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
test("gentle_review assess: a different candidate never inherits closure or a recorded decline", async (t) => {
|
|
856
|
+
t.after(() => __testing.clearNativeReviewOutcomeMemoForTesting());
|
|
857
|
+
__testing.clearNativeReviewOutcomeMemoForTesting();
|
|
858
|
+
__testing.recordNativeReviewOutcome(ctx.cwd, "target-a", "declined");
|
|
859
|
+
// Candidate B was natively closed: A's recorded decline must not leak into it.
|
|
860
|
+
const closedB = await assessWith(closureCli({ consumed: true, targetIdentity: () => "target-b" }));
|
|
861
|
+
assert.equal(closedB.nativeReviewOutcome, "closed");
|
|
862
|
+
// Candidate C follows B, but its own assessment is not consumed: B's closure never carries over.
|
|
863
|
+
const openC = await assessWith(closureCli({ consumed: false, targetIdentity: () => "target-c" }));
|
|
864
|
+
assert.equal(openC.nativeReviewOutcome, "unknown");
|
|
865
|
+
assert.equal(openC.outcome_source, "unknown");
|
|
866
|
+
assert.equal(openC.plan.independentVerifier, true);
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
test("gentle_review assess: an unassessable candidate is never closed", async () => {
|
|
870
|
+
for (const input of [undefined, { nativeReviewOutcome: "closed" }]) {
|
|
871
|
+
const details = await assessWith(closureCli({ unassessable: true }), input);
|
|
872
|
+
assert.equal(details.risk, VERIFICATION_TIER.UNASSESSABLE);
|
|
873
|
+
assert.equal(details.nativeReviewOutcome, "unknown");
|
|
874
|
+
assert.equal(details.plan.independentVerifier, true);
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
test("gentle_review assess: derived closure only changes the RDD on-path; RDD off plans are unchanged", async () => {
|
|
879
|
+
for (const risk of ["passive", "medium", "high"] as const) {
|
|
880
|
+
for (const consumed of [true, false]) {
|
|
881
|
+
const off = await assessWith(closureCli({ rdd: "off", risk, consumed }), { writerModelId: "claude-sonnet-5", writerEffort: "high" });
|
|
882
|
+
const expectedOff = verificationPlan({ rddLine: RDD_LINE.OFF, risk, writerProfile: WRITER_PROFILE.LARGE });
|
|
883
|
+
assert.deepEqual(off.plan, { ...expectedOff }, `off ${risk} consumed ${consumed}`);
|
|
884
|
+
const on = await assessWith(closureCli({ rdd: "on", risk, consumed }), { writerModelId: "claude-sonnet-5", writerEffort: "high" });
|
|
885
|
+
const expectedOn = verificationPlan({ rddLine: RDD_LINE.ON, risk, writerProfile: WRITER_PROFILE.LARGE, nativeReviewOutcome: consumed ? NATIVE_REVIEW_OUTCOME.CLOSED : NATIVE_REVIEW_OUTCOME.UNKNOWN });
|
|
886
|
+
assert.deepEqual(on.plan, { ...expectedOn }, `on ${risk} consumed ${consumed}`);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
// ---------------------------------------------------------------------------
|
|
892
|
+
// gentle-pi#1175 (T2): the writer profile comes from the runtime-recorded
|
|
893
|
+
// mutation receipts for this root; caller input is used only when no pending
|
|
894
|
+
// runtime receipt exists.
|
|
895
|
+
// ---------------------------------------------------------------------------
|
|
896
|
+
|
|
897
|
+
interface RuntimeProfileFields {
|
|
898
|
+
writerModelId?: string;
|
|
899
|
+
writerEffort?: string;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
function receiptContext(): { context: ExtensionContext; record(evidence: RuntimeProfileFields & { toolCallId: string }): void; consumeAll(): void } {
|
|
903
|
+
const entries: Array<{ type: string; customType: string; data: unknown }> = [];
|
|
904
|
+
const session = { getSessionId: () => "assess-session", getBranch: () => entries, getCwd: () => process.cwd() };
|
|
905
|
+
const host = { appendEntry: (customType: string, data: unknown) => { entries.push({ type: "custom", customType, data }); } };
|
|
906
|
+
const root = workspaceRoot();
|
|
907
|
+
return {
|
|
908
|
+
context: { cwd: process.cwd(), sessionManager: session } as unknown as ExtensionContext,
|
|
909
|
+
record: (evidence) => recordReviewMutation(host, session, root, { source: "direct", toolName: "write", ...evidence }),
|
|
910
|
+
consumeAll: () => consumeReviewMutation(host, session, root, pendingReviewMutation(session, root), "acknowledged", "target"),
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
function workspaceRoot(): string {
|
|
915
|
+
return realpathSync(execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd: process.cwd(), encoding: "utf8" }).trim());
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
const mediumOffCli = (): Partial<NativeReviewCli> => closureCli({ rdd: "off", risk: "medium" });
|
|
919
|
+
|
|
920
|
+
test("gentle_review assess: the runtime writer profile wins over contradicting caller input", async () => {
|
|
921
|
+
const small = receiptContext();
|
|
922
|
+
small.record({ toolCallId: "w1", writerModelId: "openai/gpt-5-mini", writerEffort: "high" });
|
|
923
|
+
const claimedLarge = await assessWith(mediumOffCli(), { writerModelId: "claude-sonnet-5", writerEffort: "high" }, small.context);
|
|
924
|
+
assert.equal(claimedLarge.writerProfile, "small");
|
|
925
|
+
assert.equal(claimedLarge.writerProfileSource, "runtime");
|
|
926
|
+
assert.equal(claimedLarge.plan.independentVerifier, true, "a caller can never talk a runtime mini writer into a large profile");
|
|
927
|
+
|
|
928
|
+
const large = receiptContext();
|
|
929
|
+
large.record({ toolCallId: "w1", writerModelId: "google/gemini-2.5-pro", writerEffort: "high" });
|
|
930
|
+
const claimedSmall = await assessWith(mediumOffCli(), { writerEffort: "low" }, large.context);
|
|
931
|
+
assert.equal(claimedSmall.writerProfile, "large", "gemini must never count as mini");
|
|
932
|
+
assert.equal(claimedSmall.writerProfileSource, "runtime");
|
|
933
|
+
assert.equal(claimedSmall.plan.independentVerifier, false);
|
|
934
|
+
});
|
|
935
|
+
|
|
936
|
+
test("gentle_review assess: any small or unknown pending runtime writer makes the profile small", async () => {
|
|
937
|
+
const cases: Array<{ name: string; receipts: RuntimeProfileFields[] }> = [
|
|
938
|
+
{ name: "missing model id", receipts: [{ writerModelId: "claude-sonnet-5", writerEffort: "high" }, { writerEffort: "high" }] },
|
|
939
|
+
{ name: "no profile at all", receipts: [{}] },
|
|
940
|
+
{ name: "gpt-5-mini", receipts: [{ writerModelId: "claude-sonnet-5", writerEffort: "high" }, { writerModelId: "gpt-5-mini", writerEffort: "high" }] },
|
|
941
|
+
{ name: "low effort", receipts: [{ writerModelId: "claude-sonnet-5", writerEffort: "low" }] },
|
|
942
|
+
];
|
|
943
|
+
for (const entry of cases) {
|
|
944
|
+
const fixture = receiptContext();
|
|
945
|
+
entry.receipts.forEach((receipt, index) => fixture.record({ toolCallId: `w${index}`, ...receipt }));
|
|
946
|
+
const details = await assessWith(mediumOffCli(), { writerModelId: "claude-sonnet-5", writerEffort: "high" }, fixture.context);
|
|
947
|
+
assert.equal(details.writerProfile, "small", entry.name);
|
|
948
|
+
assert.equal(details.writerProfileSource, "runtime", entry.name);
|
|
949
|
+
assert.equal(details.plan.independentVerifier, true, entry.name);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const known = receiptContext();
|
|
953
|
+
known.record({ toolCallId: "w1", writerModelId: "google/gemini-2.5-pro", writerEffort: "high" });
|
|
954
|
+
known.record({ toolCallId: "w2", writerModelId: "anthropic/claude-sonnet-5", writerEffort: "medium" });
|
|
955
|
+
const details = await assessWith(mediumOffCli(), undefined, known.context);
|
|
956
|
+
assert.equal(details.writerProfile, "large");
|
|
957
|
+
assert.equal(details.writerProfileSource, "runtime");
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
test("gentle_review assess: without pending runtime receipts the caller input path is unchanged", async () => {
|
|
961
|
+
const fixture = receiptContext();
|
|
962
|
+
fixture.record({ toolCallId: "w1", writerModelId: "gpt-5-mini" });
|
|
963
|
+
fixture.consumeAll();
|
|
964
|
+
const caller = await assessWith(mediumOffCli(), { writerModelId: "claude-sonnet-5", writerEffort: "high" }, fixture.context);
|
|
965
|
+
assert.equal(caller.writerProfile, "large", "a consumed runtime receipt is no longer evidence for the next candidate");
|
|
966
|
+
assert.equal(caller.writerProfileSource, "caller");
|
|
967
|
+
|
|
968
|
+
const callerSmall = await assessWith(mediumOffCli(), { writerEffort: "low" }, fixture.context);
|
|
969
|
+
assert.equal(callerSmall.writerProfile, "small");
|
|
970
|
+
assert.equal(callerSmall.writerProfileSource, "caller");
|
|
971
|
+
|
|
972
|
+
const fallback = await assessWith(mediumOffCli(), undefined, fixture.context);
|
|
973
|
+
assert.equal(fallback.writerProfile, "small");
|
|
974
|
+
assert.equal(fallback.writerProfileSource, "fallback");
|
|
975
|
+
assert.equal(fallback.plan.independentVerifier, true);
|
|
976
|
+
|
|
977
|
+
// No session at all behaves exactly the same way.
|
|
978
|
+
const noSession = await assessWith(mediumOffCli());
|
|
979
|
+
assert.equal(noSession.writerProfile, "small");
|
|
980
|
+
assert.equal(noSession.writerProfileSource, "fallback");
|
|
538
981
|
});
|
|
539
982
|
|
|
540
983
|
test("gentle_review assess never requires a lineageId (unlike most other operations)", async () => {
|
|
@@ -715,6 +1158,55 @@ test("native assess: a non-zero exit (an older binary reporting an unknown comma
|
|
|
715
1158
|
);
|
|
716
1159
|
});
|
|
717
1160
|
|
|
1161
|
+
// gentle-pi#1175: the full native path (real decoder through the native CLI
|
|
1162
|
+
// wrapper) must keep a code-only reason assessable and project the new
|
|
1163
|
+
// native facts without fabricating them for older envelopes.
|
|
1164
|
+
|
|
1165
|
+
test("gentle_review assess: a native envelope whose reasons lack path/detail is assessed, not unassessable", async () => {
|
|
1166
|
+
const queue = queuedAdapter([{ stdout: JSON.stringify(validEnvelope({ reasons: [{ code: "touches-auth-path" }] })) }]);
|
|
1167
|
+
const client = nativeClient(queue.adapter);
|
|
1168
|
+
const result = await reviewControllerTool({ assess: client.assess.bind(client) }).execute("code-only", { operation: "assess" }, undefined, undefined, ctx);
|
|
1169
|
+
const details = result.details as { risk: string; reasons: Record<string, unknown>[] };
|
|
1170
|
+
assert.equal(details.risk, "medium");
|
|
1171
|
+
assert.deepEqual(details.reasons, [{ code: "touches-auth-path" }]);
|
|
1172
|
+
});
|
|
1173
|
+
|
|
1174
|
+
test("gentle_review assess: consumed, reviewDue, reviewDueReason, and nextTransition are projected verbatim from native", async () => {
|
|
1175
|
+
const queue = queuedAdapter([{ stdout: JSON.stringify(newEnvelope({ candidate: { kind: "current-changes", consumed: false } })) }]);
|
|
1176
|
+
const client = nativeClient(queue.adapter);
|
|
1177
|
+
const result = await reviewControllerTool({ assess: client.assess.bind(client) }).execute("new-envelope", { operation: "assess" }, undefined, undefined, ctx);
|
|
1178
|
+
const details = result.details as Record<string, unknown> & { candidate: Record<string, unknown> };
|
|
1179
|
+
assert.equal(details.risk, "high");
|
|
1180
|
+
assert.equal(details.candidate.consumed, false);
|
|
1181
|
+
assert.equal(details.reviewDue, true);
|
|
1182
|
+
assert.equal(details.reviewDueReason, "high_risk");
|
|
1183
|
+
assert.deepEqual(details.nextTransition, nextTransition());
|
|
1184
|
+
const text = JSON.parse(result.content[0].text) as Record<string, unknown>;
|
|
1185
|
+
assert.deepEqual(text.nextTransition, nextTransition());
|
|
1186
|
+
});
|
|
1187
|
+
|
|
1188
|
+
test("gentle_review assess: an older native envelope projects no consumed/reviewDue/reviewDueReason/nextTransition", async () => {
|
|
1189
|
+
const queue = queuedAdapter([{ stdout: JSON.stringify(validEnvelope()) }]);
|
|
1190
|
+
const client = nativeClient(queue.adapter);
|
|
1191
|
+
const result = await reviewControllerTool({ assess: client.assess.bind(client) }).execute("old-envelope", { operation: "assess" }, undefined, undefined, ctx);
|
|
1192
|
+
const details = result.details as Record<string, unknown> & { candidate: Record<string, unknown> };
|
|
1193
|
+
assert.equal(details.risk, "medium");
|
|
1194
|
+
for (const key of ["reviewDue", "reviewDueReason", "nextTransition"]) {
|
|
1195
|
+
assert.equal(Object.hasOwn(details, key), false, `${key} must not be fabricated`);
|
|
1196
|
+
}
|
|
1197
|
+
assert.equal(Object.hasOwn(details.candidate, "consumed"), false, "consumed must not be fabricated");
|
|
1198
|
+
});
|
|
1199
|
+
|
|
1200
|
+
test("gentle_review assess: an unassessable projection omits reason.path instead of emitting an empty string", async () => {
|
|
1201
|
+
const result = await reviewControllerTool({}).execute("no-assess", { operation: "assess" }, undefined, undefined, ctx);
|
|
1202
|
+
const details = result.details as { risk: string; reasons: Record<string, unknown>[] };
|
|
1203
|
+
assert.equal(details.risk, VERIFICATION_TIER.UNASSESSABLE);
|
|
1204
|
+
assert.equal(details.reasons.length, 1);
|
|
1205
|
+
assert.equal(Object.hasOwn(details.reasons[0], "path"), false);
|
|
1206
|
+
assert.equal(typeof details.reasons[0].detail, "string");
|
|
1207
|
+
assert.ok((details.reasons[0].detail as string).length > 0);
|
|
1208
|
+
});
|
|
1209
|
+
|
|
718
1210
|
test("native assess: a wrong schema or unrecognized risk value fails closed as schema-incompatible", async () => {
|
|
719
1211
|
const wrongSchema = queuedAdapter([{ stdout: JSON.stringify({ schema: "gentle-ai.review-assessment/v2", risk: "medium", reasons: [], changed_paths: 0, changed_lines: 0, candidate: { kind: "current-changes" } }) }]);
|
|
720
1212
|
await assert.rejects(
|