gentle-pi 4.7.0 → 4.8.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 +55 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +6 -6
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +746 -15
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +24 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +4 -4
- package/assets/orchestrator-full-delegation-card.md +4 -5
- package/assets/orchestrator-full-delegation.md +8 -8
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +18 -22
- package/bin/gentle-shell.mjs +128 -9
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +18 -2
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell.md +39 -16
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +76 -24
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +11 -1
- package/extensions/ask-user-question.ts +2 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +234 -33
- package/extensions/gentle-ai.ts +576 -135
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +105 -52
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/skill-registry.ts +248 -223
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +91 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +79 -4
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +2 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/native-review-cli.mjs +79 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +4 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +40 -19
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +10 -2
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-question.test.ts +2 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/bounded-stop-contract.test.ts +9 -1
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -878
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +20 -29
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/full-delegation-closure.test.ts +29 -0
- package/tests/gentle-agents.test.ts +329 -4
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +121 -6
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +118 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +19 -5
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +11 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +11 -3
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +30 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +11 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +11 -10
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller.test.ts +2 -1
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator.test.ts +271 -4
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +929 -306
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +42 -11
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +87 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +54 -11
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +184 -0
- package/tests/yolo-mode.test.ts +39 -0
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -19,7 +19,7 @@ function withoutSignal<T>(request: T): T {
|
|
|
19
19
|
const { signal: _signal, ...rest } = request as Record<string, unknown>;
|
|
20
20
|
return rest as T;
|
|
21
21
|
}
|
|
22
|
-
import { NATIVE_REVIEW_ERROR_CODE, NativeReviewCliError, type NativeReviewCli } from "../lib/native-review-cli.ts";
|
|
22
|
+
import { NATIVE_REVIEW_ERROR_CODE, NativeReviewCliError, NativeReviewCliV216, type NativeReviewCli } from "../lib/native-review-cli.ts";
|
|
23
23
|
import type { ReviewStatusV3 } from "../lib/review-integration-v2.ts";
|
|
24
24
|
|
|
25
25
|
// gentle-pi#556 / gentle-ai#4051: with RDD enabled, the agent finished an
|
|
@@ -394,6 +394,84 @@ test("agent_end nudges only when the native assessment reports review_due", asyn
|
|
|
394
394
|
}
|
|
395
395
|
});
|
|
396
396
|
|
|
397
|
+
// The range is a routing hint for a fresh assessment, never a cached verdict.
|
|
398
|
+
for (const outcome of ["not-due", "due", "error", "new-write", "workspace", "race", "assessment-race", "reselect"] as const) {
|
|
399
|
+
test(`#3163: committed reminder range stays consistent (${outcome})`, async () => {
|
|
400
|
+
await withSessionStartEnv(async cwd => {
|
|
401
|
+
const git = (...args: string[]) => childProcess.execFileSync("git", ["-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", ...args], { cwd, encoding: "utf8" }).trim();
|
|
402
|
+
git("add", "."); git("commit", "-qm", "base");
|
|
403
|
+
const baseRef = git("rev-parse", "HEAD");
|
|
404
|
+
const requests: Array<Record<string, unknown>> = [];
|
|
405
|
+
const statusRequests: Array<Record<string, unknown>> = [];
|
|
406
|
+
let initial = true;
|
|
407
|
+
let duringAssessment = async () => {};
|
|
408
|
+
const native = {
|
|
409
|
+
reviewMode: onMode("on"),
|
|
410
|
+
targetStatus: async (request: Record<string, unknown>) => { statusRequests.push(withoutSignal(request)); return executeStartStatus(`sha256:${"b".repeat(64)}`); },
|
|
411
|
+
assess: async (request: Record<string, unknown>) => {
|
|
412
|
+
requests.push(withoutSignal(request));
|
|
413
|
+
await duringAssessment();
|
|
414
|
+
if (!initial && outcome === "error") throw new Error("assessment unavailable");
|
|
415
|
+
return { risk: "medium", reasons: [], changedPaths: 1, changedLines: 29,
|
|
416
|
+
candidate: request.baseRef ? { kind: "base-diff", baseRef: request.baseRef, consumed: false } : { kind: "current-changes", consumed: false },
|
|
417
|
+
reviewDue: !initial && (outcome === "due" || request.baseRef === undefined), reviewDueReason: "under_budget" };
|
|
418
|
+
},
|
|
419
|
+
} as unknown as NativeReviewCli;
|
|
420
|
+
const { handlers, sent, tools } = harness(native);
|
|
421
|
+
const session = ctx(`3163-${outcome}`, true, cwd);
|
|
422
|
+
await directWrite(handlers, session);
|
|
423
|
+
if (outcome === "assessment-race") duringAssessment = async () => { duringAssessment = async () => {}; await directWrite(handlers, session); };
|
|
424
|
+
await tools.get("gentle_review")!.execute("select", { operation: "assess", input: { baseRef, committedOnly: true } }, undefined, undefined, toolContext(session));
|
|
425
|
+
if (outcome === "workspace") await tools.get("gentle_review")!.execute("workspace", { operation: "assess" }, undefined, undefined, toolContext(session));
|
|
426
|
+
if (outcome === "new-write") await directWrite(handlers, session);
|
|
427
|
+
if (outcome === "reselect") {
|
|
428
|
+
await directWrite(handlers, session);
|
|
429
|
+
await tools.get("gentle_review")!.execute("reselect", { operation: "assess", input: { baseRef, committedOnly: true } }, undefined, undefined, toolContext(session));
|
|
430
|
+
}
|
|
431
|
+
if (outcome === "race") duringAssessment = async () => { await directWrite(handlers, session); };
|
|
432
|
+
initial = false;
|
|
433
|
+
await handlers.get("agent_end")!(agentEndEvent, session);
|
|
434
|
+
const selected = outcome !== "new-write" && outcome !== "workspace" && outcome !== "assessment-race";
|
|
435
|
+
assert.equal(requests.at(-1)?.baseRef, selected ? baseRef : undefined, "fresh assessment must use the captured candidate selector");
|
|
436
|
+
assert.equal(statusRequests.at(-1)?.baseRef, selected ? baseRef : undefined, "STATUS and ASSESS must describe the same projection");
|
|
437
|
+
assert.equal(statusRequests.at(-1)?.committedOnly, selected ? true : undefined);
|
|
438
|
+
assert.equal(sent.length, outcome === "not-due" || outcome === "race" || outcome === "reselect" ? 0 : 1);
|
|
439
|
+
if (sent.length && selected) assert.ok(String(sent[0].message.content).includes(baseRef), "follow-up inspect must retain the offered range");
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
test("#3163: real native assessment keeps a committed range through the registered end hook", { skip: !process.env.GENTLE_AI_DEV_BINARY }, async () => {
|
|
445
|
+
await withSessionStartEnv(async cwd => {
|
|
446
|
+
const binary = process.env.GENTLE_AI_DEV_BINARY!;
|
|
447
|
+
const git = (...args: string[]) => childProcess.execFileSync("git", ["-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", "-c", "core.autocrlf=false", ...args], { cwd, encoding: "utf8" }).trim();
|
|
448
|
+
git("add", "."); git("commit", "-qm", "base");
|
|
449
|
+
const baseRef = git("rev-parse", "HEAD");
|
|
450
|
+
await writeFile(join(cwd, "CLAUDE.md"), Array.from({ length: 29 }, (_, i) => `Documentation line ${i + 1}.`).join("\n") + "\n");
|
|
451
|
+
git("add", "."); git("commit", "-qm", "documentation");
|
|
452
|
+
const before = git("status", "--porcelain");
|
|
453
|
+
const requests: string[][] = [];
|
|
454
|
+
const client = new NativeReviewCliV216(async request => {
|
|
455
|
+
requests.push([...request.arguments]);
|
|
456
|
+
const result = childProcess.spawnSync(binary, [...request.arguments], { cwd: request.cwd, encoding: "utf8", timeout: 15_000 });
|
|
457
|
+
if (result.error) throw result.error;
|
|
458
|
+
return { stdout: result.stdout, stderr: result.stderr, exitCode: result.status ?? 1, signal: result.signal, timedOut: false, outputLimitExceeded: false };
|
|
459
|
+
}, binary);
|
|
460
|
+
// STATUS supplies a controlled offer; only the assessment process is native.
|
|
461
|
+
const native = { reviewMode: onMode("on"), targetStatus: async () => executeStartStatus(`sha256:${"b".repeat(64)}`), assess: client.assess.bind(client) } as unknown as NativeReviewCli;
|
|
462
|
+
const { handlers, sent, tools } = harness(native);
|
|
463
|
+
const session = ctx("3163-native-assessment", true, cwd);
|
|
464
|
+
await directWrite(handlers, session);
|
|
465
|
+
const result = await tools.get("gentle_review")!.execute("select", { operation: "assess", input: { baseRef, committedOnly: true } }, undefined, undefined, toolContext(session));
|
|
466
|
+
assert.equal((result.details as { reviewDue?: boolean }).reviewDue, false);
|
|
467
|
+
await handlers.get("agent_end")!(agentEndEvent, session);
|
|
468
|
+
assert.equal(requests.length, 2);
|
|
469
|
+
for (const args of requests) { assert.ok(args.includes(baseRef)); assert.ok(args.includes("--committed-only")); }
|
|
470
|
+
assert.equal(sent.length, 0);
|
|
471
|
+
assert.equal(git("status", "--porcelain"), before);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
|
|
397
475
|
test("agent_end nudges once per target identity and again for a fresh identity", async () => {
|
|
398
476
|
let targetIdentity = `sha256:${"b".repeat(64)}`;
|
|
399
477
|
const native = {
|
|
@@ -1075,6 +1075,71 @@ test("committed-only candidate views scope an explicit base to committed changes
|
|
|
1075
1075
|
}
|
|
1076
1076
|
});
|
|
1077
1077
|
|
|
1078
|
+
test("committed-only candidates include only explicitly selected untracked files", (t) => {
|
|
1079
|
+
mockWindowsAcl(t);
|
|
1080
|
+
const contributorRoot = repository(t);
|
|
1081
|
+
const baseCommit = git(contributorRoot, "rev-parse", "HEAD");
|
|
1082
|
+
const baseTree = git(contributorRoot, "rev-parse", "HEAD^{tree}");
|
|
1083
|
+
commitFileAfterBase(contributorRoot);
|
|
1084
|
+
writeFileSync(join(contributorRoot, "tracked.txt"), "staged noise\n");
|
|
1085
|
+
git(contributorRoot, "add", "tracked.txt");
|
|
1086
|
+
writeFileSync(join(contributorRoot, "tracked.txt"), "unstaged noise\n");
|
|
1087
|
+
writeFileSync(join(contributorRoot, "selected.txt"), "selected\n");
|
|
1088
|
+
writeFileSync(join(contributorRoot, "excluded.txt"), "excluded\n");
|
|
1089
|
+
const snapshot = () => ({ status: git(contributorRoot, "status", "--porcelain=v1"), tree: git(contributorRoot, "write-tree"), tracked: readFileSync(join(contributorRoot, "tracked.txt"), "utf8") });
|
|
1090
|
+
const before = snapshot();
|
|
1091
|
+
const oracleIndex = join(contributorRoot, ".git", "oracle-index");
|
|
1092
|
+
const oracle = (...args: string[]) => execFileSync("git", args, { cwd: contributorRoot, encoding: "utf8", env: { ...process.env, GIT_INDEX_FILE: oracleIndex } }).trim();
|
|
1093
|
+
oracle("read-tree", "HEAD");
|
|
1094
|
+
oracle("add", "--", "selected.txt");
|
|
1095
|
+
const expected = oracle("write-tree");
|
|
1096
|
+
for (const selector of [{ baseRef: baseCommit }, { providerBaseTree: baseTree }]) {
|
|
1097
|
+
for (const intendedUntracked of [["selected.txt"], []]) {
|
|
1098
|
+
const view = new CandidateViewRegistry().createOrReuse({ contributorRoot, committedOnly: true, ...selector, intendedUntracked });
|
|
1099
|
+
try {
|
|
1100
|
+
assert.equal(view.candidateTree, intendedUntracked.length ? expected : git(contributorRoot, "rev-parse", "HEAD^{tree}"));
|
|
1101
|
+
assert.equal(existsSync(join(view.root, "selected.txt")), intendedUntracked.length > 0);
|
|
1102
|
+
assert.equal(existsSync(join(view.root, "excluded.txt")), false);
|
|
1103
|
+
assert.equal(readFileSync(join(view.root, "tracked.txt"), "utf8"), "base\n");
|
|
1104
|
+
assert.equal(readFileSync(join(view.root, "committed-after-base.txt"), "utf8"), "committed after base\n");
|
|
1105
|
+
assert.deepEqual(view.intendedUntracked, intendedUntracked);
|
|
1106
|
+
} finally { view.cleanup(); }
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
assert.deepEqual(snapshot(), before);
|
|
1110
|
+
});
|
|
1111
|
+
|
|
1112
|
+
test("committed-only untracked selections reject tracked collisions and directory expansion", (t) => {
|
|
1113
|
+
mockWindowsAcl(t);
|
|
1114
|
+
for (const collision of ["tracked", "removed-from-index", "directory", "staged", "ignored"]) {
|
|
1115
|
+
const contributorRoot = repository(t);
|
|
1116
|
+
const baseRef = git(contributorRoot, "rev-parse", "HEAD");
|
|
1117
|
+
writeFileSync(join(contributorRoot, "tracked.txt"), "dirty tracked input\n");
|
|
1118
|
+
let selection = "tracked.txt";
|
|
1119
|
+
if (collision === "removed-from-index") git(contributorRoot, "rm", "--cached", "tracked.txt");
|
|
1120
|
+
if (collision === "directory") {
|
|
1121
|
+
mkdirSync(join(contributorRoot, "folder"));
|
|
1122
|
+
writeFileSync(join(contributorRoot, "folder", "tracked.txt"), "committed\n");
|
|
1123
|
+
git(contributorRoot, "add", "folder/tracked.txt");
|
|
1124
|
+
git(contributorRoot, "-c", "user.name=Candidate Test", "-c", "user.email=candidate@example.invalid", "commit", "-m", "directory baseline");
|
|
1125
|
+
writeFileSync(join(contributorRoot, "folder", "tracked.txt"), "dirty directory input\n");
|
|
1126
|
+
writeFileSync(join(contributorRoot, "folder", "selected.txt"), "selected\n");
|
|
1127
|
+
selection = "folder";
|
|
1128
|
+
}
|
|
1129
|
+
if (collision === "staged" || collision === "ignored") {
|
|
1130
|
+
selection = "selected.txt";
|
|
1131
|
+
writeFileSync(join(contributorRoot, selection), "selected\n");
|
|
1132
|
+
if (collision === "staged") git(contributorRoot, "add", selection);
|
|
1133
|
+
else writeFileSync(join(contributorRoot, ".gitignore"), selection + "\n");
|
|
1134
|
+
}
|
|
1135
|
+
const before = git(contributorRoot, "write-tree");
|
|
1136
|
+
assert.throws(() => new CandidateViewRegistry().createOrReuse({ contributorRoot, baseRef, committedOnly: true, intendedUntracked: [selection] }),
|
|
1137
|
+
(error: unknown) => error instanceof CandidateViewError && error.reason === "candidate-untracked-selection-invalid");
|
|
1138
|
+
assert.equal(git(contributorRoot, "write-tree"), before);
|
|
1139
|
+
assert.equal(readFileSync(join(contributorRoot, "tracked.txt"), "utf8"), "dirty tracked input\n");
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1078
1143
|
test("explicit base refs reject ambiguous DWIM names even when they resolve identically, while full refs stay valid", (t) => {
|
|
1079
1144
|
const contributorRoot = repository(t);
|
|
1080
1145
|
const baseCommit = git(contributorRoot, "rev-parse", "HEAD");
|
|
@@ -7,6 +7,37 @@ const preStart = { ...selection, targetIdentity: "target", candidateTree: "tree"
|
|
|
7
7
|
const stop = { selectionBinding: "selection", targetIdentity: "target" };
|
|
8
8
|
const route = { workspaceRoot: "/repo", lineageId: "lineage", targetIdentity: "target" };
|
|
9
9
|
|
|
10
|
+
test("reminder range hints are bound to one mutation without caching assessment outcomes", () => {
|
|
11
|
+
const registry = new ReviewContinuationRegistry();
|
|
12
|
+
registry.retainCommittedRange("/repo", "base", "mutation-1");
|
|
13
|
+
assert.equal(registry.readReminderRange("/repo", "mutation-1"), "base");
|
|
14
|
+
assert.equal(registry.readReminderRange("/repo", "mutation-2"), undefined);
|
|
15
|
+
assert.equal(registry.readReminderRange("/other", "mutation-1"), undefined);
|
|
16
|
+
registry.clearReminderRange("/repo");
|
|
17
|
+
assert.equal(registry.readReminderRange("/repo", "mutation-1"), undefined);
|
|
18
|
+
assert.equal(registry.readCommittedRange("/repo"), "base", "a workspace assessment does not erase the delivery base hint");
|
|
19
|
+
registry.retainCommittedRange("/repo", "new-base", "mutation-2");
|
|
20
|
+
assert.equal(registry.readReminderRange("/repo", "mutation-1"), undefined);
|
|
21
|
+
assert.equal(registry.readReminderRange("/repo", "mutation-2"), "new-base");
|
|
22
|
+
assert.equal(new ReviewContinuationRegistry().readReminderRange("/repo", "mutation-2"), undefined);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("committed base hints reuse the session registry without replacing lifecycle continuations", () => {
|
|
26
|
+
const backing = new Map<string, RetainedReviewContinuation>();
|
|
27
|
+
const registry = ReviewContinuationRegistry.from(backing);
|
|
28
|
+
registry.retainPreStart("/repo", preStart);
|
|
29
|
+
registry.retainCommittedRange("/repo", "base");
|
|
30
|
+
assert.equal(registry.readPreStart("/repo")?.targetIdentity, "target");
|
|
31
|
+
assert.equal(ReviewContinuationRegistry.from(backing).readCommittedRange("/repo"), "base");
|
|
32
|
+
assert.equal(new ReviewContinuationRegistry().readCommittedRange("/repo"), undefined);
|
|
33
|
+
assert.equal(registry.readCommittedRange("/other"), undefined);
|
|
34
|
+
registry.retainCommittedRange("/repo", "new-base");
|
|
35
|
+
assert.equal(registry.readCommittedRange("/repo"), "new-base");
|
|
36
|
+
for (let index = 0; index < 64; index++) registry.retainCapture(`extra-${index}`, route);
|
|
37
|
+
assert.equal(registry.size, 64);
|
|
38
|
+
assert.equal(registry.readCommittedRange("/repo"), undefined, "the existing capacity bound also covers hints");
|
|
39
|
+
});
|
|
40
|
+
|
|
10
41
|
test("four continuation kinds share one capacity and replacement does not refresh insertion order", () => {
|
|
11
42
|
const registry = new ReviewContinuationRegistry();
|
|
12
43
|
registry.retainSelection("/repo", "first", selection);
|
|
@@ -114,7 +114,7 @@ test("before_agent_start injects the mirrored review execution contract for the
|
|
|
114
114
|
assert.match(appended, /Organic Driven Development \(ODD\) is the predefined workflow of this orchestrator\. Every request enters it/);
|
|
115
115
|
assert.doesNotMatch(appended, /ODD \(Default Workflow, harness section above\)/);
|
|
116
116
|
assert.doesNotMatch(appended, /Prefer SDD\/OpenSpec artifacts/);
|
|
117
|
-
assert.match(appended, /## Gentle AI review execution contract \(mirrored provider bundle 1\.
|
|
117
|
+
assert.match(appended, /## Gentle AI review execution contract \(mirrored provider bundle 1\.5\.0\)/);
|
|
118
118
|
assert.ok(appended.includes(expected), "the mirrored orchestration/pi.md text must appear verbatim");
|
|
119
119
|
assert.match(appended, /call `gentle_review` with {"operation":"inspect"}/);
|
|
120
120
|
assert.match(appended, /call `gentle_review` with operation `status`, the exact retained `lineageId`, and `workspaceRoot`/);
|
|
@@ -487,7 +487,8 @@ test("shipped controller fails closed while static prompts defer RDD lifecycle o
|
|
|
487
487
|
assert.match(toolContract, /ambiguous START output.*target-scoped native status.*declared action.*ambiguous gentle_review_capture.*never replays/is);
|
|
488
488
|
assert.doesNotMatch(toolContract, /START throws.*lineage does not exist/is);
|
|
489
489
|
|
|
490
|
-
|
|
490
|
+
// cost-speed-painpoints S15 P5a (verdict X1): the contract is injected only while RDD is not off.
|
|
491
|
+
const boundary = "While RDD is not off, this package injects the mirrored provider-bundle review execution contract; Gentle AI writes nothing into this prompt. Absent that mirrored contract, this package invents no lifecycle instructions.";
|
|
491
492
|
const core = readFileSync("assets/orchestrator.md", "utf8");
|
|
492
493
|
assert.match(core, new RegExp(boundary.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")));
|
|
493
494
|
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import test, { after } from "node:test";
|
|
7
|
+
import { createGentleAiExtension, __testing } from "../extensions/gentle-ai.ts";
|
|
8
|
+
import { NativeReviewCliV216, type ExecFileAdapter } from "../lib/native-review-cli.ts";
|
|
9
|
+
|
|
10
|
+
// odd/tasks/review-one-call.md T11 (S5), L21: the run returns the correction
|
|
11
|
+
// fields at the top level only when the provider answered the non-blocking
|
|
12
|
+
// question; otherwise its correction result is what it was before T11.
|
|
13
|
+
|
|
14
|
+
type Body = Record<string, any>;
|
|
15
|
+
// A real contracted v2 STATUS (correction_required, correction_plan_required)
|
|
16
|
+
// from a locally built gentle-ai at gentle-ai#6088 (e7720e6f4), on a scratch
|
|
17
|
+
// lineage with one synthetic CRITICAL to correct and one synthetic WARNING;
|
|
18
|
+
// captured without the opt-in. Fixture text only; not real review output.
|
|
19
|
+
const STATUS: Body = JSON.parse("{\"schema\":\"gentle-ai.review-integration.status/v9\",\"contract\":\"gentle-ai.review-integration/v2\",\"operation\":\"review.status\",\"applicability\":\"current_target\",\"authority\":{\"version\":\"compact-v2\",\"lineage_id\":\"review-0d8b087fff7b6eed\",\"state\":\"correction_required\",\"generation\":1,\"revision\":\"sha256:a7ddf6edace20fa270507183a2a60dbedd3ab6b41f03d0462e9228c80d9c7672\"},\"action\":\"collect\",\"replayability\":\"manual_action_required\",\"frozen\":{\"tier\":\"medium\",\"original_changed_lines\":1,\"correction_budget\":1},\"target_identity\":\"sha256:83e0f87755b27e526b27f89d986374c0b1415a7851718f2ce1aa800bb68e371f\",\"projection\":{\"schema\":\"gentle-ai.review-integration.projection/v1\",\"kind\":\"current-changes\",\"projection\":\"workspace\",\"base_tree\":\"a0b17eb7f8eba95c76ff14a4d2cce51b601e76f2\",\"initial_review_tree\":\"1c46f89a3ac76bcd75f1b1afaef64a6dc089c6df\",\"current_candidate_tree\":\"1c46f89a3ac76bcd75f1b1afaef64a6dc089c6df\",\"paths_digest\":\"sha256:85fde7c14a0bab6e322280540f42e1a3475f31abba2454770081982d81532c0b\",\"paths\":[\"a.ts\"],\"intended_untracked\":[],\"intended_untracked_proof\":\"sha256:b97229718d4c7fe50a8892eb474ae5aa6491697bccb400e3e31dbaca4894d2f3\",\"initial_snapshot_identity\":\"sha256:83e0f87755b27e526b27f89d986374c0b1415a7851718f2ce1aa800bb68e371f\",\"current_snapshot_identity\":\"sha256:83e0f87755b27e526b27f89d986374c0b1415a7851718f2ce1aa800bb68e371f\"},\"eligible_untracked_inventory\":\"sha256:0fc9c89f9fb57a5340cb06a0d61707dbf4d16b8d18d78a55fd8c28d114b47735\",\"repair\":{\"schema\":\"gentle-ai.review-authority-repair-assessment/v1\",\"status\":\"unsupported\",\"counts\":{\"lineages\":0,\"compact_lineages\":0,\"legacy_lineages\":0,\"events\":0,\"bytes\":0,\"eligible_candidates\":0,\"unsupported_lineages\":0,\"conflicts\":0},\"supported_operations\":[\"review/complete-fix\",\"review/validate-fix\"],\"authorization_schema\":\"gentle-ai.review-repair-authorization/v1\"},\"candidates\":[],\"forecast\":{\"horizon\":\"partial\",\"steps\":[{\"step\":1,\"kind\":\"collect\",\"reason_code\":\"correction_plan_required\",\"description\":\"Correction plan required to resolve review findings\"}]},\"next_transition\":{\"kind\":\"collect\",\"reason_code\":\"correction_plan_required\",\"collect\":{\"inputs\":[{\"name\":\"correction_lines\",\"schema\":\"gentle-ai.review-correction-plan/v1\",\"capture_operation\":\"review.capture-correction-plan\",\"arguments\":[{\"name\":\"lineage\",\"value\":\"review-0d8b087fff7b6eed\",\"token\":\"--lineage=review-0d8b087fff7b6eed\"},{\"name\":\"expected-revision\",\"value\":\"sha256:358845cd62d643d9a7b747d8a96891e154f22506e2f4a495ee46bd602e73f020\",\"token\":\"--expected-revision=sha256:358845cd62d643d9a7b747d8a96891e154f22506e2f4a495ee46bd602e73f020\"},{\"name\":\"target\",\"value\":\"sha256:83e0f87755b27e526b27f89d986374c0b1415a7851718f2ce1aa800bb68e371f\",\"token\":\"--target=sha256:83e0f87755b27e526b27f89d986374c0b1415a7851718f2ce1aa800bb68e371f\"},{\"name\":\"repository-context\",\"value\":\"rctx2_16252ab07879c5e12cc36ca2c2051415bdb3af5ce6f1d55457f5cdde6d18753a\",\"token\":\"--repository-context=rctx2_16252ab07879c5e12cc36ca2c2051415bdb3af5ce6f1d55457f5cdde6d18753a\"},{\"name\":\"request-hash\",\"value\":\"sha256:71d2f500490dd020938d25102ed69bf71abfa672dbad70f13ae4e6689a8ea732\",\"token\":\"--request-hash=sha256:71d2f500490dd020938d25102ed69bf71abfa672dbad70f13ae4e6689a8ea732\"}],\"submission\":{\"operation_token\":\"capture-correction-plan\",\"argument_tokens\":[\"--lineage=review-0d8b087fff7b6eed\",\"--expected-revision=sha256:358845cd62d643d9a7b747d8a96891e154f22506e2f4a495ee46bd602e73f020\",\"--target=sha256:83e0f87755b27e526b27f89d986374c0b1415a7851718f2ce1aa800bb68e371f\",\"--request-hash=sha256:71d2f500490dd020938d25102ed69bf71abfa672dbad70f13ae4e6689a8ea732\",\"--repository-context=rctx2_16252ab07879c5e12cc36ca2c2051415bdb3af5ce6f1d55457f5cdde6d18753a\",\"--correction-lines={{value}}\"],\"value\":{\"slot\":\"correction_lines\",\"domain\":\"positive_correction_lines\",\"minimum\":1,\"maximum\":2,\"substitution_location\":5}}}]},\"correction_request\":{\"schema\":\"gentle-ai.review-correction-plan-request/v1\",\"request_hash\":\"sha256:71d2f500490dd020938d25102ed69bf71abfa672dbad70f13ae4e6689a8ea732\",\"lineage_id\":\"review-0d8b087fff7b6eed\",\"expected_revision\":\"sha256:358845cd62d643d9a7b747d8a96891e154f22506e2f4a495ee46bd602e73f020\",\"target_identity\":\"sha256:83e0f87755b27e526b27f89d986374c0b1415a7851718f2ce1aa800bb68e371f\",\"correction_budget\":2,\"fix_finding_ids\":[\"R3-001\"],\"findings\":[{\"id\":\"R3-001\",\"lens\":\"reliability\",\"location\":\"a.ts:2\",\"severity\":\"CRITICAL\",\"claim\":\"Fixture: the added export breaks the reader; not real review output.\",\"proof_refs\":[\"the changed line deterministically causes the reproduced failure\"],\"evidence\":\"the changed line deterministically causes the reproduced failure\",\"evidence_class\":\"deterministic\",\"causal_disposition\":\"introduced\"}]}},\"repository_context\":{\"capability\":\"review.opaque_repository_context\",\"handle\":\"rctx2_16252ab07879c5e12cc36ca2c2051415bdb3af5ce6f1d55457f5cdde6d18753a\",\"revision\":\"sha256:358845cd62d643d9a7b747d8a96891e154f22506e2f4a495ee46bd602e73f020\",\"target_identity\":\"sha256:83e0f87755b27e526b27f89d986374c0b1415a7851718f2ce1aa800bb68e371f\"}}");
|
|
20
|
+
// The same STATUS's non_blocking_findings with --non-blocking-findings (the
|
|
21
|
+
// rest of the body is identical); statement treated as opaque text.
|
|
22
|
+
const NON_BLOCKING: Body = JSON.parse("{\"statement\":\"Every finding listed here is non-blocking: it is not a finding to correct and not an unresolved finding that stopped this review, and it needs no correction in this review. A `follow_up` finding is separate later work; a `refuted` finding needs none.\",\"findings\":[{\"id\":\"R3-W01\",\"lens\":\"reliability\",\"location\":\"a.ts:2\",\"severity\":\"WARNING\",\"disposition\":\"informational\",\"claim\":\"Fixture warning claim; not real review output.\"}]}");
|
|
23
|
+
const lineage: string = STATUS.authority.lineage_id;
|
|
24
|
+
|
|
25
|
+
const scratch = realpathSync(mkdtempSync(join(realpathSync(tmpdir()), "rdd-correction-gate-")));
|
|
26
|
+
after(() => rmSync(scratch, { recursive: true, force: true }));
|
|
27
|
+
execFileSync("git", ["init", "-q"], { cwd: scratch });
|
|
28
|
+
writeFileSync(join(scratch, "a.ts"), "export const a = 1;\n");
|
|
29
|
+
const executable = join(scratch, "gentle-ai-fixture");
|
|
30
|
+
writeFileSync(executable, "fixture provider; never executed");
|
|
31
|
+
const mode = JSON.stringify({ schema: "gentle-ai.review-mode/v1", operation: "status", scope: "both", status: { schema: "gentle-ai.rdd-mode-status/v1", global: "on", clone_local: "", effective: "on", source: "global", revision: `sha256:${"f".repeat(64)}` } });
|
|
32
|
+
const refusal = { schema: "gentle-ai.review-integration.failure/v2", contract: "gentle-ai.review-integration/v2", operation: "review.status", phase: "preflight",
|
|
33
|
+
code: "invalid_request", message: "The negotiated review request is invalid.", mutation_outcome: "not_started", authority_applicability: "not_evaluated",
|
|
34
|
+
retry_safe: true, replayability: "not_replayable", required_inputs: [], next_action: "correct_request", cause: "flag provided but not defined: -non-blocking-findings" };
|
|
35
|
+
|
|
36
|
+
type Provider = "answers" | "answers-empty" | "refuses" | "silent";
|
|
37
|
+
/** answers: the flag adds the key; answers-empty: the key with no findings; refuses: the pinned provider's refusal; silent: accepts the flag and sends no key. */
|
|
38
|
+
function host(kind: Provider) {
|
|
39
|
+
const statusCalls: boolean[] = [];
|
|
40
|
+
const adapter: ExecFileAdapter = async (request) => {
|
|
41
|
+
const args = request.arguments;
|
|
42
|
+
const reply = (body: unknown, exitCode = 0) => ({ stdout: JSON.stringify(body), stderr: exitCode === 0 ? "" : "Error: The negotiated review request is invalid. [invalid_request]\n", exitCode, signal: null, timedOut: false, outputLimitExceeded: false });
|
|
43
|
+
if (args[0] === "review" && args[1] === "mode") return { ...reply(undefined), stdout: mode };
|
|
44
|
+
if (args[0] !== "review" || args[1] !== "status") throw new Error(`unexpected native invocation: ${args.join(" ")}`);
|
|
45
|
+
const flagged = args.includes("--non-blocking-findings");
|
|
46
|
+
statusCalls.push(flagged);
|
|
47
|
+
if (flagged && kind === "refuses") return reply(refusal, 1);
|
|
48
|
+
const body = structuredClone(STATUS);
|
|
49
|
+
if (flagged && kind === "answers") body.non_blocking_findings = structuredClone(NON_BLOCKING);
|
|
50
|
+
if (flagged && kind === "answers-empty") body.non_blocking_findings = { ...structuredClone(NON_BLOCKING), findings: [] };
|
|
51
|
+
return reply(body);
|
|
52
|
+
};
|
|
53
|
+
// One executable per provider kind: a refusal is remembered per binary.
|
|
54
|
+
const binary = join(scratch, `gentle-ai-${kind}-${Math.random().toString(36).slice(2)}`);
|
|
55
|
+
writeFileSync(binary, `fixture provider ${kind} ${binary}`);
|
|
56
|
+
const tools = new Map<string, any>();
|
|
57
|
+
createGentleAiExtension({ nativeReviewCli: new NativeReviewCliV216(adapter, binary, 30_000, 8 * 1024 * 1024), candidateViews: null, processEnv: { GENTLE_AI_TELEMETRY: "0" } })(
|
|
58
|
+
{ on() {}, registerCommand() {}, registerTool: (tool: any) => tools.set(tool.name, tool) } as never);
|
|
59
|
+
const context = { cwd: scratch, hasUI: false, sessionManager: { getSessionId: () => "fixture-gate", getBranch: () => [], getSessionFile: () => undefined } };
|
|
60
|
+
return { statusCalls, run: async () => {
|
|
61
|
+
try {
|
|
62
|
+
const result = await tools.get("gentle_review_run").execute("fixture-call", { lineageId: lineage }, undefined, undefined, context);
|
|
63
|
+
return result.details as Body;
|
|
64
|
+
} finally { __testing.setReviewHostRelayRunnerForTesting(); __testing.setReviewHostRelayGroupRunnersForTesting(); }
|
|
65
|
+
} };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const CORRECTION_KEYS = ["correction_findings", "correction_finding_claims", "correction_finding_claims_truncated", "correction_finding_claims_omitted"];
|
|
69
|
+
const NON_BLOCKING_KEYS = ["non_blocking_findings", "non_blocking_finding_claims", "non_blocking_finding_claims_truncated", "non_blocking_finding_claims_omitted", "non_blocking_findings_omitted_count"];
|
|
70
|
+
const request = STATUS.next_transition.correction_request;
|
|
71
|
+
|
|
72
|
+
test("the provider answered: the correction fields and the non-blocking fields come back together", async () => {
|
|
73
|
+
const provider = host("answers");
|
|
74
|
+
const details = await provider.run();
|
|
75
|
+
assert.equal(details.outcome, "input-required", JSON.stringify(details).slice(0, 300));
|
|
76
|
+
assert.deepEqual(provider.statusCalls, [true]);
|
|
77
|
+
assert.deepEqual(details.correction_findings, request.findings.map(({ id, lens, location, severity, evidence_class, causal_disposition }: Body) => ({ id, lens, location, severity, evidence_class, causal_disposition })));
|
|
78
|
+
assert.deepEqual(details.correction_finding_claims, Object.fromEntries(request.findings.map((finding: Body) => [finding.id, finding.claim])));
|
|
79
|
+
assert.deepEqual(details.non_blocking_findings, { statement: NON_BLOCKING.statement, findings: NON_BLOCKING.findings.map(({ claim: _claim, ...finding }: Body) => finding) });
|
|
80
|
+
assert.deepEqual(details.non_blocking_finding_claims, Object.fromEntries(NON_BLOCKING.findings.map((finding: Body) => [finding.id, finding.claim])));
|
|
81
|
+
assert.equal(Object.hasOwn(details.result.result, "non_blocking_findings"), false);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("the provider answered with an empty list: the correction fields come back with the empty answer", async () => {
|
|
85
|
+
const provider = host("answers-empty");
|
|
86
|
+
const details = await provider.run();
|
|
87
|
+
assert.equal(details.outcome, "input-required");
|
|
88
|
+
assert.equal(details.correction_findings.length, request.findings.length);
|
|
89
|
+
assert.deepEqual(Object.keys(details.correction_finding_claims), request.findings.map((finding: Body) => finding.id));
|
|
90
|
+
assert.deepEqual(details.non_blocking_findings, { statement: NON_BLOCKING.statement, findings: [] });
|
|
91
|
+
assert.equal(Object.hasOwn(details, "non_blocking_finding_claims"), false);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
for (const kind of ["refuses", "silent"] as const) {
|
|
95
|
+
test(`the provider did not answer (${kind}): no top-level correction or non-blocking field; the nested record is the provider's STATUS`, async () => {
|
|
96
|
+
const provider = host(kind);
|
|
97
|
+
const details = await provider.run();
|
|
98
|
+
assert.equal(details.outcome, "input-required");
|
|
99
|
+
assert.deepEqual(provider.statusCalls, kind === "refuses" ? [true, false] : [true]);
|
|
100
|
+
for (const key of [...CORRECTION_KEYS, ...NON_BLOCKING_KEYS]) assert.equal(Object.hasOwn(details, key), false, `${kind}: ${key}`);
|
|
101
|
+
const { collect: _collect, ...transition } = STATUS.next_transition;
|
|
102
|
+
assert.deepEqual(details.result.result, { ...STATUS, next_transition: transition }, `${kind}: the relayed STATUS keeps the correction request`);
|
|
103
|
+
assert.deepEqual(Object.keys(details).sort(), ["forecasts", "lineage_id", "metrics", "outcome", "result", "reviewer_runs", "schema"], `${kind}: the pre-T11 result keys`);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test, { after } from "node:test";
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { createCoordinatorRuntime } from "./support/review-coordinator-runtime.ts";
|
|
8
|
+
import { runReviewCoordinator, type ReviewCoordinatorTool } from "../lib/review-coordinator.ts";
|
|
9
|
+
|
|
10
|
+
// odd/tasks/review-one-call.md T11 (S5), L18: a run that stops on a correction
|
|
11
|
+
// request or an escalation returns the provider's non-blocking findings
|
|
12
|
+
// (STATUS non_blocking_findings, gentle-ai#6088) with bounded reviewer claims.
|
|
13
|
+
|
|
14
|
+
type Body = Record<string, unknown>;
|
|
15
|
+
interface Metrics { steps: Body[] }
|
|
16
|
+
const target = "sha256:" + "a".repeat(64);
|
|
17
|
+
const lineage = "review-fixture";
|
|
18
|
+
const collect = { result: { target_identity: target, authority: { lineage_id: lineage }, next_transition: { kind: "collect" } }, collectBindings: [{ collectBinding: "opaque-not-json" }] };
|
|
19
|
+
const approved = { result: { target_identity: target, authority: { lineage_id: lineage }, next_transition: { kind: "execute", execute: { operation: "review.acknowledge-approved" } } } };
|
|
20
|
+
const closed = { outcome: "native-approved-acknowledgement-completed", status: "closed", authority: "burned", target_identity: target, lineage_id: lineage };
|
|
21
|
+
const captured = { outcome: "native-last-event-closure" };
|
|
22
|
+
function backend(responses: Body[]) {
|
|
23
|
+
const calls: { tool: ReviewCoordinatorTool; parameters: Body }[] = [];
|
|
24
|
+
return { calls, async invoke(tool: ReviewCoordinatorTool, parameters: Body) {
|
|
25
|
+
calls.push({ tool, parameters });
|
|
26
|
+
assert.ok(responses.length, "no unexpected follow-up or retry");
|
|
27
|
+
return responses.shift()!;
|
|
28
|
+
} };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const blocking = { id: "B1", lens: "risk", location: "a.ts:1", severity: "CRITICAL", claim: "blocking claim", proof_refs: ["p"], evidence: "e", evidence_class: "deterministic", causal_disposition: "introduced" };
|
|
32
|
+
const finding = (id: string, claim: unknown, extra: Body = {}) => ({ id, lens: "readability", location: "a.ts:2", severity: "WARNING", disposition: "informational", claim, ...extra });
|
|
33
|
+
const set = (findings: unknown) => ({ statement: "Fixture statement; not real review output.", findings });
|
|
34
|
+
const correction = (nonBlocking?: unknown) => ({ ...collect, result: { ...collect.result,
|
|
35
|
+
next_transition: { kind: "collect", correction_request: { request_hash: "opaque-request", findings: [blocking] } },
|
|
36
|
+
...(nonBlocking === undefined ? {} : { non_blocking_findings: nonBlocking }) }, collectBindings: [{ collectBinding: "plan" }] });
|
|
37
|
+
const escalated = (nonBlocking?: unknown) => ({ ...collect, result: { ...collect.result, authority: { lineage_id: lineage, state: "escalated" },
|
|
38
|
+
escalation: { cause: "unknown_causality", finding_ids: ["B1"] }, next_transition: { kind: "stop", reason_code: "native_stop_required" },
|
|
39
|
+
...(nonBlocking === undefined ? {} : { non_blocking_findings: nonBlocking }) } });
|
|
40
|
+
const NON_BLOCKING_KEYS = ["non_blocking_findings", "non_blocking_finding_claims", "non_blocking_finding_claims_truncated", "non_blocking_finding_claims_omitted"];
|
|
41
|
+
const listed = ({ claim: _claim, ...rest }: Body) => rest;
|
|
42
|
+
|
|
43
|
+
test("a correction request returns the provider's non-blocking findings and their claims beside correction_findings", async () => {
|
|
44
|
+
const findings = [finding("W1", "first claim"), finding("F2", "second claim", { severity: "CRITICAL", disposition: "follow_up", lens: undefined }), finding("R3", "third claim", { disposition: "refuted", location: undefined })]
|
|
45
|
+
.map((entry) => Object.fromEntries(Object.entries(entry).filter(([, value]) => value !== undefined)));
|
|
46
|
+
const response = correction(set(structuredClone(findings)));
|
|
47
|
+
const host = backend([response]);
|
|
48
|
+
const result = await runReviewCoordinator({ lineageId: lineage }, host);
|
|
49
|
+
assert.equal(result.outcome, "input-required"); assert.equal(host.calls.length, 1);
|
|
50
|
+
const { non_blocking_findings: _raw, ...nested } = response.result;
|
|
51
|
+
assert.deepEqual(result.result, { ...response, result: nested }, "the STATUS envelope is relayed with only the raw set left out (L19)");
|
|
52
|
+
assert.deepEqual(result.non_blocking_findings, set(findings.map(listed)), "statement and provider fields in provider order, without the claim");
|
|
53
|
+
assert.deepEqual(result.non_blocking_finding_claims, { W1: "first claim", F2: "second claim", R3: "third claim" });
|
|
54
|
+
for (const key of ["non_blocking_finding_claims_truncated", "non_blocking_finding_claims_omitted"]) assert.equal(Object.hasOwn(result, key), false, key);
|
|
55
|
+
assert.deepEqual(result.correction_findings, [listed({ ...blocking, evidence: undefined, proof_refs: undefined })].map((entry) => Object.fromEntries(Object.entries(entry).filter(([, value]) => value !== undefined))));
|
|
56
|
+
assert.deepEqual(result.correction_finding_claims, { B1: "blocking claim" }, "correction keys unchanged");
|
|
57
|
+
for (const key of ["advisory_findings", "advisory_finding_claims"]) assert.equal(Object.hasOwn(result, key), false, key);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("non-blocking claims keep the 1,024-byte cut, the 8,192-byte limit and their marks; an empty claim is a claim", async () => {
|
|
61
|
+
const many = [finding("N0", "é".repeat(600)), ...Array.from({ length: 8 }, (_, i) => finding(`N${i + 1}`, "z".repeat(1024))), finding("N9", "")];
|
|
62
|
+
const result = await runReviewCoordinator({ lineageId: lineage }, backend([correction(set(structuredClone(many)))]));
|
|
63
|
+
assert.equal((result.non_blocking_finding_claims as Body).N0, "é".repeat(512));
|
|
64
|
+
assert.deepEqual(result.non_blocking_finding_claims_truncated, ["N0"]);
|
|
65
|
+
assert.deepEqual(Object.keys(result.non_blocking_finding_claims as Body), ["N0", "N1", "N2", "N3", "N4", "N5", "N6", "N7"]);
|
|
66
|
+
assert.deepEqual(result.non_blocking_finding_claims_omitted, ["N8", "N9"]);
|
|
67
|
+
assert.deepEqual((result.non_blocking_findings as Body).findings, many.map(listed), "every finding is listed, with or without a claim");
|
|
68
|
+
const empty = await runReviewCoordinator({ lineageId: lineage }, backend([correction(set([finding("E1", "")]))]));
|
|
69
|
+
assert.deepEqual(empty.non_blocking_finding_claims, { E1: "" });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("an escalated stop returns the provider's non-blocking findings with claims", async () => {
|
|
73
|
+
const response = escalated(set([finding("W1", "escalated claim")]));
|
|
74
|
+
const result = await runReviewCoordinator({ lineageId: lineage }, backend([response]));
|
|
75
|
+
assert.equal(result.outcome, "stopped");
|
|
76
|
+
const { non_blocking_findings: _raw, ...nested } = response.result;
|
|
77
|
+
assert.deepEqual(result.result, { ...response, result: nested }, "only the raw set is left out of the nested record (L19)");
|
|
78
|
+
assert.deepEqual(result.non_blocking_findings, set([listed(finding("W1", ""))]));
|
|
79
|
+
assert.deepEqual(result.non_blocking_finding_claims, { W1: "escalated claim" });
|
|
80
|
+
for (const key of ["correction_findings", "correction_finding_claims"]) assert.equal(Object.hasOwn(result, key), false, key);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("an empty provider list is returned as the provider's answer; no key when the provider said nothing", async () => {
|
|
84
|
+
for (const response of [correction(set([])), escalated(set([]))]) {
|
|
85
|
+
const result = await runReviewCoordinator({ lineageId: lineage }, backend([response]));
|
|
86
|
+
assert.deepEqual(result.non_blocking_findings, set([]));
|
|
87
|
+
for (const key of NON_BLOCKING_KEYS.slice(1)) assert.equal(Object.hasOwn(result, key), false, key);
|
|
88
|
+
}
|
|
89
|
+
for (const response of [correction(), escalated()]) {
|
|
90
|
+
const result = await runReviewCoordinator({ lineageId: lineage }, backend([response]));
|
|
91
|
+
for (const key of NON_BLOCKING_KEYS) assert.equal(Object.hasOwn(result, key), false, key);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
for (const [name, statement, kept, cut] of [
|
|
96
|
+
["short", "Provider statement.", "Provider statement.", false],
|
|
97
|
+
["exact UTF-8 boundary", "é".repeat(512), "é".repeat(512), false],
|
|
98
|
+
["oversized ASCII", "x".repeat(1024 * 1024), "x".repeat(1024), true],
|
|
99
|
+
["oversized astral", "😀".repeat(257), "😀".repeat(256), true],
|
|
100
|
+
["partial codepoint boundary", "a".repeat(1023) + "😀", "a".repeat(1023), true],
|
|
101
|
+
] as const) test(`non-blocking statement: ${name}`, async () => {
|
|
102
|
+
for (const responseOf of [correction, escalated]) for (const findings of [[], [finding("N1", "claim")]]) {
|
|
103
|
+
const response = responseOf({ statement, findings });
|
|
104
|
+
const original = structuredClone(response);
|
|
105
|
+
const host = backend([response]);
|
|
106
|
+
const result = await runReviewCoordinator({ lineageId: lineage }, host);
|
|
107
|
+
assert.equal(Buffer.byteLength((result.non_blocking_findings as Body).statement as string), Buffer.byteLength(kept));
|
|
108
|
+
assert.deepEqual(result.non_blocking_findings, { statement: kept, findings: findings.map(listed), ...(cut ? { statement_truncated: true } : {}) });
|
|
109
|
+
assert.equal(result.outcome, response.result.next_transition.kind === "stop" ? "stopped" : "input-required");
|
|
110
|
+
assert.deepEqual(host.calls, [{ tool: "gentle_review", parameters: { operation: "status", lineageId: lineage } }]);
|
|
111
|
+
assert.deepEqual(response, original, "provider input remains untouched");
|
|
112
|
+
const { non_blocking_findings: _raw, ...nested } = original.result;
|
|
113
|
+
assert.deepEqual(result.result, { ...original, result: nested }, "no unbounded nested copy");
|
|
114
|
+
assert.deepEqual(result.non_blocking_finding_claims, findings.length ? { N1: "claim" } : undefined);
|
|
115
|
+
for (const key of ["non_blocking_findings_omitted_count", "non_blocking_finding_claims_truncated", "non_blocking_finding_claims_omitted"]) assert.equal(Object.hasOwn(result, key), false, key);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("a malformed non-blocking set is dropped whole and never changes the outcome", async () => {
|
|
120
|
+
const proto = Object.create({ id: "N1" });
|
|
121
|
+
for (const value of ["s", [], null, { statement: "", findings: [] }, { statement: "s" }, { statement: "s", findings: {} }, set([finding("N1", 3)]), set([{ ...finding("N1", "c"), id: "" }]),
|
|
122
|
+
set([(({ claim: _claim, ...rest }) => rest)(finding("N1", "c"))]), set([{ ...finding("N1", "c"), disposition: 1 }]), set([{ ...finding("N1", "c"), severity: "" }]), set([proto]), set([finding("N1", "c"), "N2"])]) {
|
|
123
|
+
for (const response of [correction(value), escalated(value)]) {
|
|
124
|
+
const result = await runReviewCoordinator({ lineageId: lineage }, backend([response]));
|
|
125
|
+
assert.equal(result.outcome, response.result.next_transition.kind === "stop" ? "stopped" : "input-required", JSON.stringify(value));
|
|
126
|
+
for (const key of NON_BLOCKING_KEYS) assert.equal(Object.hasOwn(result, key), false, `${key}: ${JSON.stringify(value)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("non-blocking findings are read only from the STATUS that ends the run; the approved path is unchanged", async () => {
|
|
132
|
+
// Present on a STATUS that the run continues past: never relayed.
|
|
133
|
+
const continuing = { ...collect, result: { ...collect.result, non_blocking_findings: set([finding("W1", "c")]) } };
|
|
134
|
+
const run = await runReviewCoordinator({ lineageId: lineage }, backend([continuing, { ...captured, closure: { advisory_findings: { statement: "s", findings: [{ id: "F1" }] }, advisory_finding_claims: { F1: "c" } } }, approved, closed]));
|
|
135
|
+
assert.equal(run.outcome, "closed");
|
|
136
|
+
assert.deepEqual(run.advisory_findings, { statement: "s", findings: [{ id: "F1" }] }); assert.deepEqual(run.advisory_finding_claims, { F1: "c" });
|
|
137
|
+
for (const key of [...NON_BLOCKING_KEYS, "correction_findings"]) assert.equal(Object.hasOwn(run, key), false, key);
|
|
138
|
+
// Nothing routes on it: the same STATUS without the key takes the same route.
|
|
139
|
+
const routed = await runReviewCoordinator({ lineageId: lineage }, backend([{ ...collect }, { ...captured }, approved, closed]));
|
|
140
|
+
assert.equal(routed.outcome, "closed"); assert.deepEqual((routed.metrics as Metrics).steps.map((step: Body) => step.tool), (run.metrics as Metrics).steps.map((step: Body) => step.tool));
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("the listed findings fit the 16 KiB JSON boundary and count the unlisted remainder", async () => {
|
|
144
|
+
const base = [finding("N1", "first"), finding("N2", "second")];
|
|
145
|
+
const padding = 16 * 1024 - Buffer.byteLength(JSON.stringify(base.map(listed)));
|
|
146
|
+
for (const delta of [-1, 0, 1]) {
|
|
147
|
+
const findings = [base[0]!, finding("N2", "second", { location: `${base[1]!.location}${"x".repeat(padding + delta)}` })];
|
|
148
|
+
assert.equal(Buffer.byteLength(JSON.stringify(findings.map(listed))), 16 * 1024 + delta);
|
|
149
|
+
const response = escalated(set(findings));
|
|
150
|
+
const host = backend([response]);
|
|
151
|
+
const result = await runReviewCoordinator({ lineageId: lineage }, host);
|
|
152
|
+
const expected = delta > 0 ? findings.slice(0, 1) : findings;
|
|
153
|
+
assert.equal(result.outcome, "stopped");
|
|
154
|
+
assert.equal(host.calls.length, 1);
|
|
155
|
+
assert.deepEqual(result.non_blocking_findings, set(expected.map(listed)));
|
|
156
|
+
assert.deepEqual(result.non_blocking_finding_claims, delta > 0 ? { N1: "first" } : { N1: "first", N2: "second" });
|
|
157
|
+
assert.equal(Object.hasOwn(result, "non_blocking_findings_omitted_count"), delta > 0);
|
|
158
|
+
if (delta > 0) assert.equal(result.non_blocking_findings_omitted_count, 1);
|
|
159
|
+
const { non_blocking_findings: _raw, ...nested } = response.result;
|
|
160
|
+
assert.deepEqual(result.result, { ...response, result: nested });
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
let repo: string | undefined;
|
|
165
|
+
after(() => { if (repo !== undefined) rmSync(repo, { recursive: true, force: true }); });
|
|
166
|
+
function scratchRepo(): string {
|
|
167
|
+
if (repo !== undefined) return repo;
|
|
168
|
+
repo = realpathSync(mkdtempSync(join(realpathSync(tmpdir()), "rdd-nonblocking-")));
|
|
169
|
+
execFileSync("git", ["init", "-q"], { cwd: repo });
|
|
170
|
+
writeFileSync(join(repo, "candidate.ts"), "export const value = 1;\n");
|
|
171
|
+
return repo;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
test("the facade's STATUS operation asks the provider for the non-blocking findings", async () => {
|
|
175
|
+
for (const scenario of ["correction", "escalated"] as const) {
|
|
176
|
+
const runtime = createCoordinatorRuntime(scratchRepo(), "coordinator", { hasUI: false, scenario, correctionFindings: [blocking] });
|
|
177
|
+
try {
|
|
178
|
+
const result = await runtime.invoke("gentle_review_run", { lineageId: runtime.lineage });
|
|
179
|
+
assert.equal(result.outcome, scenario === "correction" ? "input-required" : "stopped");
|
|
180
|
+
const statuses = runtime.nativeRequests.filter((entry) => entry.operation === "target-status").map((entry) => entry.request as Body);
|
|
181
|
+
assert.equal(statuses.length, 1);
|
|
182
|
+
assert.equal(statuses[0].nonBlockingFindings, true, scenario);
|
|
183
|
+
} finally { runtime.close(); }
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("a direct INSPECT never asks for the non-blocking findings; inside the run only facade status reads do", async () => {
|
|
188
|
+
const runtime = createCoordinatorRuntime(scratchRepo(), "coordinator", { hasUI: false, scenario: "escalated" });
|
|
189
|
+
try {
|
|
190
|
+
const inspected = await runtime.invoke("gentle_review", { operation: "inspect" });
|
|
191
|
+
assert.equal(inspected.result?.authority?.state, "escalated", JSON.stringify(inspected).slice(0, 400));
|
|
192
|
+
const statuses = runtime.nativeRequests.filter((entry) => entry.operation === "target-status").map((entry) => entry.request as Body);
|
|
193
|
+
assert.ok(statuses.length >= 1);
|
|
194
|
+
for (const status of statuses) assert.equal(Object.hasOwn(status, "nonBlockingFindings"), false, "L19: a direct gentle_review never asks");
|
|
195
|
+
} finally { runtime.close(); }
|
|
196
|
+
// A reviewer-group capture reads STATUS before and after its submissions without the opt-in.
|
|
197
|
+
const group = createCoordinatorRuntime(scratchRepo(), "coordinator", { hasUI: false, scenario: "refuter" });
|
|
198
|
+
try {
|
|
199
|
+
const result = await group.invoke("gentle_review_run", { lineageId: group.lineage });
|
|
200
|
+
assert.equal(result.outcome, "closed", JSON.stringify(result).slice(0, 400));
|
|
201
|
+
const flagged = group.nativeRequests.filter((entry) => entry.operation === "target-status").map((entry) => (entry.request as Body).nonBlockingFindings === true);
|
|
202
|
+
const statusSteps = (result.metrics as Metrics).steps.filter((step: Body) => step.tool === "gentle_review" && step.operation === "status").length;
|
|
203
|
+
assert.equal(flagged.filter(Boolean).length, statusSteps, "one opted-in read per facade status operation");
|
|
204
|
+
assert.ok(flagged.some((value: boolean) => !value), "capture-side STATUS reads stay as they are");
|
|
205
|
+
} finally { group.close(); }
|
|
206
|
+
});
|