gentle-pi 4.5.1 → 4.7.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 +17 -15
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +8 -1
- package/assets/agents/gentle-ai-worker.md +4 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +162 -0
- package/assets/orchestrator-delegation-reference.md +7 -7
- package/assets/orchestrator-delegation.md +3 -3
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +14 -8
- package/assets/orchestrator.md +11 -11
- package/bin/gentle-shell.mjs +225 -82
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/ci-performance.md +11 -0
- package/docs/delegated-verification.md +35 -7
- package/docs/fast-mode.md +15 -0
- package/docs/gentle-agents-activity.md +22 -0
- package/docs/gentle-shell.md +113 -25
- package/docs/install-wizard.md +2 -2
- package/docs/mcp-status.md +52 -0
- package/docs/permission-modes.md +9 -4
- package/docs/prompt-budget.md +28 -0
- package/docs/readme-reference.md +154 -50
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/session-profile-format.md +20 -5
- package/docs/sound-notifications.md +1 -1
- package/docs/star-prompt.md +32 -0
- package/docs/voice.md +6 -3
- package/docs/work-continuity.md +46 -0
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +2 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/codegraph-tools.ts +38 -4
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +803 -84
- package/extensions/gentle-ai.ts +2491 -596
- package/extensions/gentle-fast.ts +61 -0
- package/extensions/gentle-guide.ts +174 -0
- package/extensions/gentle-herdr-activity.ts +21 -1
- package/extensions/gentle-herdr-agent.ts +144 -0
- package/extensions/gentle-program-identity.ts +61 -0
- package/extensions/gentle-shell.ts +895 -120
- package/extensions/gentle-star-prompt.ts +334 -0
- package/extensions/gentle-stats.ts +5 -5
- package/extensions/gentle-todo.ts +59 -23
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/history/store.ts +18 -12
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +210 -21
- package/extensions/startup-banner.ts +69 -10
- package/lib/agent-assets.ts +74 -17
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +161 -3
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +58 -3
- package/lib/agents-history.ts +24 -5
- package/lib/agents-keys.ts +8 -16
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-protocol.ts +80 -4
- package/lib/agents-runner.ts +287 -15
- package/lib/agents-view.ts +6 -1
- package/lib/agents-widget.ts +132 -9
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/bridge-cost.ts +28 -0
- package/lib/card-content-policy.ts +8 -6
- package/lib/codemode-renderer.ts +16 -0
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/command-palette.ts +154 -25
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +64 -0
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-guide.ts +201 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +47 -8
- package/lib/herdr-activity.ts +23 -5
- package/lib/herdr-busy.ts +45 -0
- package/lib/herdr-task-summary-policy.ts +85 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +282 -132
- package/lib/jobs-sidebar-state.ts +5 -6
- package/lib/jobs-view.ts +198 -11
- package/lib/jobs-widget.ts +16 -52
- package/lib/keymaps-customize.ts +81 -0
- package/lib/keymaps.ts +291 -0
- package/lib/model-fallback-notice.ts +61 -0
- package/lib/model-fallback-policy.ts +141 -0
- package/lib/model-fallback-store.ts +143 -0
- package/lib/model-routing-authority.ts +32 -6
- package/lib/nan-provider.ts +3 -2
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +103 -21
- package/lib/notification-customize.ts +48 -51
- package/lib/openai-fast-tier.ts +22 -0
- package/lib/orchestrator-discovery.ts +5 -1
- package/lib/orchestrator-fallback.ts +75 -0
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/pasted-image-paths.ts +113 -0
- package/lib/questionnaire/questionnaire-view.ts +225 -18
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +85 -44
- package/lib/review-candidate-view.ts +10 -7
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +51 -11
- package/lib/review-integration-v2.ts +29 -8
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-repository.ts +5 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-append-controller.ts +21 -6
- package/lib/session-profile-authority.ts +119 -0
- package/lib/session-profile-binding.ts +54 -5
- package/lib/session-profile-freeze.ts +107 -9
- package/lib/session-profile-integration.ts +313 -0
- package/lib/session-profile-persistence.ts +63 -9
- package/lib/shell-bar.ts +269 -72
- package/lib/shell-card.ts +26 -6
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-page.ts +120 -0
- package/lib/shell-panel.ts +163 -0
- package/lib/shell-prompt.ts +53 -1
- package/lib/shell-sidebar-layout.ts +198 -53
- package/lib/shell-sidebar.ts +61 -1
- package/lib/shell-stats.ts +123 -0
- package/lib/shell-todo.ts +79 -1
- package/lib/shell-usage.ts +12 -2
- package/lib/star-prompt.ts +197 -0
- package/lib/verifier-admission.ts +18 -8
- package/lib/verifier-settle-reminder.ts +64 -0
- package/lib/vim-editor-adapter.ts +6 -1
- package/lib/visual-customization-policy.ts +67 -12
- package/lib/visual-customize-view.ts +373 -40
- package/lib/visual-layout-preview.ts +47 -0
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +68 -16
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +46 -7
- package/runtime/native-review-cli.mjs +100 -18
- package/runtime/review-integration-v2.mjs +29 -8
- package/runtime/windows-session-transport.ps1 +60 -3
- package/scripts/bootstrap.sh +4 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +6 -6
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/pi-update.mjs +113 -3
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +41 -13
- package/scripts/shell-snapshot.mjs +340 -0
- package/scripts/test-packed-runner.mjs +1 -1
- package/scripts/update-agent-body-history.mjs +41 -0
- package/scripts/verify-installer-tap.mjs +45 -0
- package/scripts/verify-package-files.mjs +14 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +4 -4
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/tui-design/NOTICE.md +5 -0
- package/skills/tui-design/SKILL.md +56 -0
- package/skills/tui-design/references/commands.md +75 -0
- package/skills/tui-design/references/critique.md +48 -0
- package/skills/tui-design/references/design-doc.md +44 -0
- package/skills/tui-design/references/terminal-craft.md +64 -0
- package/skills/tui-design/references/visual-loop.md +32 -0
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-protocol.test.ts +53 -1
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +345 -4
- package/tests/agents-view.test.ts +27 -0
- package/tests/agents-widget.test.ts +312 -10
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-scan-contract.test.ts +39 -0
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +47 -0
- package/tests/bundled-install.test.ts +36 -9
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/ci-concurrency.test.ts +11 -0
- package/tests/ci-merge-base-identity.test.ts +114 -0
- package/tests/codegraph-tools.test.ts +80 -5
- package/tests/codemode-rendering.test.ts +22 -2
- package/tests/command-palette.test.ts +300 -3
- package/tests/commit-slice-signal.test.ts +11 -9
- package/tests/delegate-for-reason-contract.test.ts +8 -7
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/exploration-budget.test.ts +128 -0
- package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
- package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -14
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +172 -0
- package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
- package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
- package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
- package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
- package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
- package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
- package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
- package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1491 -38
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +151 -0
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +1101 -52
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-fast.test.ts +73 -0
- package/tests/gentle-guide.test.ts +208 -0
- package/tests/gentle-herdr-activity.test.ts +80 -3
- package/tests/gentle-herdr-agent.test.ts +111 -0
- package/tests/gentle-program-identity.test.ts +197 -0
- package/tests/gentle-shell-bin.test.ts +172 -26
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +93 -10
- package/tests/gentle-shell.test.ts +1937 -66
- package/tests/gentle-stats.test.ts +15 -2
- package/tests/gentle-todo.test.ts +67 -4
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +132 -0
- package/tests/history-store-private-mode.test.ts +40 -0
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/image-paste-chips.test.ts +42 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +298 -4
- package/tests/installer-posix-bootstrap.test.ts +68 -6
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/installer-windows-diagnostics.test.ts +4 -5
- package/tests/isolated-config-home.ts +28 -0
- package/tests/jobs-view.test.ts +260 -6
- package/tests/jobs-widget.test.ts +25 -37
- package/tests/keymaps-customize.test.ts +114 -0
- package/tests/keymaps.test.ts +103 -0
- package/tests/maintainer/mcp-status.maintest.ts +88 -0
- package/tests/maintainer/pi-update-source.maintest.ts +116 -0
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-fallback-notice.test.ts +45 -0
- package/tests/model-fallback-policy.test.ts +83 -0
- package/tests/model-fallback-store.test.ts +111 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/nan-provider.test.ts +4 -4
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +22 -0
- package/tests/notification-customize.test.ts +58 -34
- package/tests/odd-routing-canonical-ratchet.test.ts +6 -6
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-fallback.test.ts +82 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +133 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +169 -14
- package/tests/pasted-image-paths.test.ts +118 -0
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/persona-reply-language.test.ts +20 -1
- package/tests/pi-update-launcher.test.ts +40 -8
- package/tests/pi-update-source.test.ts +162 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-fast-tier.test.ts +311 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +84 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +265 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-owner-sweep.test.ts +93 -0
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +52 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +381 -11
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-gate.test.ts +24 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-inspect-preflight.test.ts +197 -0
- package/tests/review-integration-v2-forward.test.ts +59 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-repository.test.ts +52 -1
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-sidebar-state.test.ts +5 -5
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +183 -6
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +250 -0
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-append-controller.test.ts +63 -0
- package/tests/session-profile-authority.test.ts +259 -0
- package/tests/session-profile-binding.test.ts +34 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-extension.test.ts +615 -0
- package/tests/session-profile-freeze.test.ts +110 -2
- package/tests/session-profile-integration.test.ts +857 -0
- package/tests/session-profile-persistence.test.ts +57 -0
- package/tests/session-profile-v1-compat.test.ts +255 -0
- package/tests/shell-bar.test.ts +274 -72
- package/tests/shell-card.test.ts +13 -1
- package/tests/shell-page.test.ts +108 -0
- package/tests/shell-panel.test.ts +360 -0
- package/tests/shell-prompt.test.ts +54 -0
- package/tests/shell-render-cache.test.ts +5 -0
- package/tests/shell-sidebar-fullscreen.test.ts +13 -1
- package/tests/shell-sidebar-layout.test.ts +447 -44
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-stats.test.ts +90 -0
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/shell-usage.test.ts +14 -0
- package/tests/skill-registry.test.ts +902 -2
- package/tests/star-prompt.test.ts +470 -0
- package/tests/startup-banner.test.ts +209 -2
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +50 -4
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verifier-settle-reminder.test.ts +281 -0
- package/tests/verify-first-launch-contract.test.ts +134 -8
- package/tests/verify-installer-tap.test.ts +57 -0
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +95 -8
- package/tests/visual-customize-view.test.ts +818 -9
- package/tests/visual-layout-preview.test.ts +42 -0
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-bootstrap.test.ts +105 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +114 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/writer-surfaces.test.ts +12 -10
- package/tests/yolo-customize.test.ts +57 -15
- package/tests/yolo-mode-runtime.test.ts +4 -2
- package/tests/yolo-mode.test.ts +39 -20
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { setImmediate as nextTurn } from "node:timers/promises";
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
import { runInProcessReviewer, type InProcessReviewerDeps, type InProcessReviewerOutcome } from "../lib/inprocess-reviewer.ts";
|
|
8
|
+
import { prepareReviewHostRelaySlot, submitReviewHostRelayPreparedResult, ReviewHostRelayError, REVIEW_HOST_RELAY_FAILURE, type ReviewHostRelayRequest } from "../lib/review-host-relay.ts";
|
|
9
|
+
|
|
10
|
+
const model = { id: "fixture-model", provider: "fixture", api: "openai-completions", baseUrl: "https://PRIVATE.invalid", reasoning: false, input: ["text"], cost: { input: 1, output: 1, cacheRead: 1, cacheWrite: 1 }, contextWindow: 1000, maxTokens: 100 };
|
|
11
|
+
const raw = '{"findings":[],"evidence":["fixture"]}\n';
|
|
12
|
+
const request = { selection: "fixture/fixture-model", prompt: Buffer.from("PRIVATE PROMPT"), timeoutMs: 30_000, routingKey: "review-risk" };
|
|
13
|
+
const assistant = (overrides: Record<string, unknown> = {}) => ({ role: "assistant", content: [{ type: "text", text: raw }], api: "openai-completions", provider: "fixture", model: "fixture-model", stopReason: "stop", timestamp: 0,
|
|
14
|
+
usage: { input: 12, output: 3, cacheRead: 2, totalTokens: 17, private: "PRIVATE USAGE", cost: { input: 0.12, output: 0.03, total: 0.15, totalFromProvider: false, private: "PRIVATE COST" } }, ...overrides });
|
|
15
|
+
const deps = (overrides: Record<string, unknown> = {}): InProcessReviewerDeps => ({
|
|
16
|
+
registry: { find: () => model, getApiKeyAndHeaders: async () => ({ ok: true, apiKey: "PRIVATE KEY", headers: { private: "PRIVATE HEADER" }, env: { private: "PRIVATE ENV" } }) },
|
|
17
|
+
complete: async () => assistant(), ...overrides,
|
|
18
|
+
} as unknown as InProcessReviewerDeps);
|
|
19
|
+
/** Require host evidence without narrowing away refused reviewer outcomes. */
|
|
20
|
+
function evidence(outcome: InProcessReviewerOutcome): Record<string, any> {
|
|
21
|
+
const value = (outcome as { evidence?: Record<string, unknown> }).evidence;
|
|
22
|
+
assert.ok(value, "a resolved reviewer run must carry host evidence");
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
/** Check available phase measurements while preserving unknown completion time. */
|
|
26
|
+
function timings(value: Record<string, any>, completion: boolean) {
|
|
27
|
+
assert.equal(typeof value.durationMs, "number"); assert.ok(value.durationMs >= 0);
|
|
28
|
+
assert.equal(typeof value.authDurationMs, "number"); assert.ok(value.authDurationMs >= 0);
|
|
29
|
+
assert.equal(typeof value.completionDurationMs, completion ? "number" : "undefined");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test("reviewer success carries allowlisted reported usage/cost and effective identity without private payloads", async () => {
|
|
33
|
+
const outcome = await runInProcessReviewer(request, deps());
|
|
34
|
+
assert.equal(outcome.kind, "text");
|
|
35
|
+
const value = evidence(outcome);
|
|
36
|
+
assert.equal(value.reviewerModel, "fixture/fixture-model"); assert.equal(value.provider, "fixture"); assert.equal(value.phase, "completion");
|
|
37
|
+
assert.deepEqual(value.usage, { input: 12, output: 3, cacheRead: 2, totalTokens: 17 });
|
|
38
|
+
assert.deepEqual(value.cost, { input: 0.12, output: 0.03, total: 0.15, totalFromProvider: false });
|
|
39
|
+
timings(value, true);
|
|
40
|
+
assert.doesNotMatch(JSON.stringify(value), /PRIVATE|baseUrl|apiKey|headers|signature|prompt|findings|private/);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("reviewer evidence leaves unavailable usage and cost unknown instead of manufacturing zeros", async () => {
|
|
44
|
+
const value = evidence(await runInProcessReviewer(request, deps({ complete: async () => assistant({ usage: undefined }) })));
|
|
45
|
+
assert.equal(Object.hasOwn(value, "usage"), false); assert.equal(Object.hasOwn(value, "cost"), false);
|
|
46
|
+
const partial = evidence(await runInProcessReviewer(request, deps({ complete: async () => assistant({ usage: { input: 0, output: -1, cacheRead: Infinity, totalTokens: "4", cost: { total: NaN, input: -1, private: "PRIVATE" } } }) })));
|
|
47
|
+
assert.deepEqual(partial.usage, { input: 0 }); assert.equal(Object.hasOwn(partial, "cost"), false);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("reviewer refusals preserve available completion usage without promoting private error text to evidence", async () => {
|
|
51
|
+
for (const response of [assistant({ stopReason: "error", errorMessage: "PRIVATE PROVIDER ERROR" }), assistant({ content: [], stopReason: "length" }), assistant({ content: [{ type: "toolCall", name: "PRIVATE TOOL", arguments: { private: "PRIVATE ARG" } }], stopReason: "toolUse" })]) {
|
|
52
|
+
const outcome = await runInProcessReviewer(request, deps({ complete: async () => response }));
|
|
53
|
+
assert.equal(outcome.kind, "refused");
|
|
54
|
+
const value = evidence(outcome); assert.equal(value.phase, "completion"); assert.equal(value.usage.output, 3); assert.equal(value.cost.total, 0.15);
|
|
55
|
+
assert.doesNotMatch(JSON.stringify(value), /PRIVATE|errorMessage|arguments/);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("auth failure and non-cooperative auth timeout carry auth phase without fabricated completion usage", async t => {
|
|
60
|
+
t.mock.timers.enable({ apis: ["setTimeout"] });
|
|
61
|
+
for (const never of [false, true]) {
|
|
62
|
+
let entered!: () => void;
|
|
63
|
+
const began = new Promise<void>(resolve => { entered = resolve; });
|
|
64
|
+
const getApiKeyAndHeaders = async () => { entered(); return never ? await new Promise(() => {}) : { ok: false, error: "fixture auth unavailable" }; };
|
|
65
|
+
const pending = runInProcessReviewer(request, deps({ registry: { find: () => model, getApiKeyAndHeaders }, complete: async () => { throw new Error("must not dispatch"); } }));
|
|
66
|
+
await began;
|
|
67
|
+
if (never) t.mock.timers.tick(request.timeoutMs);
|
|
68
|
+
const outcome = await pending;
|
|
69
|
+
assert.equal(outcome.kind, "refused"); const value = evidence(outcome);
|
|
70
|
+
assert.equal(value.phase, "auth"); timings(value, false);
|
|
71
|
+
assert.equal(Object.hasOwn(value, "usage"), false); assert.equal(Object.hasOwn(value, "cost"), false);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("timeout and abort snapshots keep each phase within the total duration", async t => {
|
|
76
|
+
for (const phase of ["auth", "completion"] as const) for (const stop of ["timeout", "abort"] as const) {
|
|
77
|
+
await t.test(`${phase} ${stop}`, async child => {
|
|
78
|
+
child.mock.timers.enable({ apis: ["setTimeout"] });
|
|
79
|
+
let advancing = false, clock = 0, entered!: () => void;
|
|
80
|
+
child.mock.method(performance, "now", () => advancing ? clock++ : 0);
|
|
81
|
+
const started = new Promise<void>(resolve => { entered = resolve; });
|
|
82
|
+
const hold = async () => { entered(); return await new Promise<never>(() => {}); };
|
|
83
|
+
const controller = new AbortController();
|
|
84
|
+
const pending = runInProcessReviewer({ ...request, timeoutMs: 1000, signal: controller.signal }, deps({
|
|
85
|
+
registry: { find: () => model, getApiKeyAndHeaders: phase === "auth" ? hold : async () => ({ ok: true, apiKey: "fixture" }) },
|
|
86
|
+
complete: phase === "completion" ? hold : async () => assistant(),
|
|
87
|
+
}));
|
|
88
|
+
await started;
|
|
89
|
+
advancing = true; clock = stop === "timeout" ? 1000 : 100;
|
|
90
|
+
if (stop === "timeout") child.mock.timers.tick(1000); else controller.abort();
|
|
91
|
+
const outcome = await pending;
|
|
92
|
+
assert.equal(outcome.kind, "refused");
|
|
93
|
+
if (outcome.kind === "refused") assert.equal(outcome.code, stop === "timeout" ? "timed-out" : "aborted");
|
|
94
|
+
const value = evidence(outcome);
|
|
95
|
+
assert.equal(value.phase, phase);
|
|
96
|
+
for (const key of ["authDurationMs", "completionDurationMs"]) if (typeof value[key] === "number") {
|
|
97
|
+
assert.ok(value.durationMs >= value[key], `${key} must fit within durationMs`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("evidence observers cannot mutate returned facts, change classification, throw or delay settlement", async () => {
|
|
104
|
+
let observed: unknown;
|
|
105
|
+
const outcome = await runInProcessReviewer(request, deps({ onEvidence: (value: Record<string, any>) => { observed = value; value.usage.input = 999; throw new Error("PRIVATE OBSERVER ERROR"); } }));
|
|
106
|
+
assert.ok(observed); assert.equal(outcome.kind, "text"); assert.equal(evidence(outcome).usage.input, 12);
|
|
107
|
+
const thrown = new Error("PRIVATE AUTH ERROR"); let failureEvidence: Record<string, any> | undefined;
|
|
108
|
+
await assert.rejects(runInProcessReviewer(request, deps({ registry: { find: () => model, getApiKeyAndHeaders: async () => { throw thrown; } }, onEvidence: async (value: Record<string, any>) => { failureEvidence = value; throw new Error("PRIVATE ASYNC OBSERVER ERROR"); } })), error => error === thrown);
|
|
109
|
+
await nextTurn(); assert.equal(failureEvidence?.phase, "auth"); assert.doesNotMatch(JSON.stringify(failureEvidence), /PRIVATE/);
|
|
110
|
+
const controller = new AbortController(); controller.abort();
|
|
111
|
+
const cancelled = await runInProcessReviewer({ ...request, signal: controller.signal }, deps({ onEvidence: async () => await new Promise(() => {}) }));
|
|
112
|
+
assert.equal(cancelled.kind, "refused"); if (cancelled.kind === "refused") assert.equal(cancelled.code, "aborted");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("late completion cannot publish usage or notify observers after cancellation settled the run", async () => {
|
|
116
|
+
let release!: (value: unknown) => void, entered!: () => void;
|
|
117
|
+
const started = new Promise<void>(resolve => { entered = resolve; });
|
|
118
|
+
const completion = new Promise(resolve => { release = resolve; });
|
|
119
|
+
const controller = new AbortController(), observed: Record<string, unknown>[] = [];
|
|
120
|
+
const pending = runInProcessReviewer({ ...request, signal: controller.signal }, deps({
|
|
121
|
+
complete: async () => { entered(); return await completion; }, onEvidence: value => { observed.push(value); },
|
|
122
|
+
}));
|
|
123
|
+
await started; controller.abort();
|
|
124
|
+
const outcome = await pending;
|
|
125
|
+
assert.equal(outcome.kind, "refused"); if (outcome.kind === "refused") assert.equal(outcome.code, "aborted");
|
|
126
|
+
const before = structuredClone(evidence(outcome)); assert.equal(before.phase, "completion");
|
|
127
|
+
assert.equal(Object.hasOwn(before, "usage"), false); assert.equal(observed.length, 1);
|
|
128
|
+
release(assistant()); await nextTurn();
|
|
129
|
+
assert.deepEqual(evidence(outcome), before); assert.equal(observed.length, 1);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("malformed diagnostic getters cannot invalidate an otherwise usable completion", async () => {
|
|
133
|
+
const usage = { input: 4 };
|
|
134
|
+
Object.defineProperty(usage, "cost", { get() { throw new Error("PRIVATE DIAGNOSTIC GETTER"); } });
|
|
135
|
+
const outcome = await runInProcessReviewer(request, deps({ complete: async () => assistant({ usage }) }));
|
|
136
|
+
assert.equal(outcome.kind, "text"); if (outcome.kind === "text") assert.equal(outcome.text, raw);
|
|
137
|
+
assert.equal(evidence(outcome).phase, "completion");
|
|
138
|
+
assert.doesNotMatch(JSON.stringify(evidence(outcome)), /PRIVATE/);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
/** Build a disposable Node-backed native transport fixture with no model calls. */
|
|
142
|
+
function relayFixture(t: test.TestContext, rejectSubmission = false): ReviewHostRelayRequest {
|
|
143
|
+
const cwd = mkdtempSync(join(tmpdir(), "reviewer-evidence-"));
|
|
144
|
+
t.after(() => rmSync(cwd, { recursive: true, force: true }));
|
|
145
|
+
// Portable executable fixture: node runs cwd/review. No shebang, fake pi,
|
|
146
|
+
// native state, real model, credentials or network are involved.
|
|
147
|
+
writeFileSync(join(cwd, "review"), `const fs=require('node:fs');const args=process.argv.slice(2);if(args.includes('--materialize=true'))process.stdout.write('PRIVATE FROZEN PROMPT');else{const input=args.find(v=>v.startsWith('--input=')).slice(8);fs.writeFileSync('submitted.raw',fs.readFileSync(input));${rejectSubmission ? "process.stderr.write('fixture refused [invalid_request]');process.exitCode=1;" : "process.stdout.write('{\"admission_decision\":\"completed\"}');"}}`);
|
|
148
|
+
return { captureArgumentTokens: ["--agent=pi", "--materialize=true"], submission: { operationToken: "capture-result", argumentTokens: ["--input={{value}}"], values: [{ slot: "reviewer_result", domain: "artifact_path_or_stdin", substitutionLocation: 0 }] },
|
|
149
|
+
gentleAiExecutable: process.execPath, targetCwd: cwd, reviewerRegistry: deps().registry,
|
|
150
|
+
selection: request.selection, routingKey: request.routingKey, environment: { ...process.env }, gentleAiTimeoutMs: 5_000, piTimeoutMs: 30_000 };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
test("relay preserves reviewer evidence through prepare and submission without altering native artifact bytes", async t => {
|
|
154
|
+
const fixture = relayFixture(t);
|
|
155
|
+
let completionEvidence: Record<string, any> | undefined;
|
|
156
|
+
const prepared = await prepareReviewHostRelaySlot(fixture, async (req, dependencies) => {
|
|
157
|
+
const outcome = await runInProcessReviewer(req, { ...dependencies, complete: deps().complete });
|
|
158
|
+
completionEvidence = evidence(outcome); return outcome;
|
|
159
|
+
});
|
|
160
|
+
assert.equal((prepared as any).reviewerEvidence?.phase, "completion");
|
|
161
|
+
assert.equal((prepared as any).reviewerEvidence?.usage.totalTokens, 17);
|
|
162
|
+
completionEvidence!.usage.totalTokens = 999;
|
|
163
|
+
assert.equal((prepared as any).reviewerEvidence?.usage.totalTokens, 17, "prepare snapshots host facts independently of the completion outcome");
|
|
164
|
+
const result = await submitReviewHostRelayPreparedResult(prepared);
|
|
165
|
+
assert.deepEqual((result as any).reviewerEvidence, (prepared as any).reviewerEvidence);
|
|
166
|
+
assert.equal(readFileSync(join(fixture.targetCwd!, "submitted.raw"), "utf8"), raw);
|
|
167
|
+
assert.equal(result.submission, '{"admission_decision":"completed"}');
|
|
168
|
+
assert.doesNotMatch(JSON.stringify((result as any).reviewerEvidence), /PRIVATE|headers|apiKey|prompt|submission|findings/);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("relay auth throw and admission refusal retain host evidence while preserving failure classification", async t => {
|
|
172
|
+
const fixture = relayFixture(t);
|
|
173
|
+
await assert.rejects(prepareReviewHostRelaySlot(fixture, (req, dependencies) => runInProcessReviewer(req, { ...dependencies, registry: { find: () => model as never, getApiKeyAndHeaders: async () => { throw new Error("fixture auth throw"); } } })), error => {
|
|
174
|
+
assert.ok(error instanceof ReviewHostRelayError); assert.equal(error.kind, REVIEW_HOST_RELAY_FAILURE.PI_FAILED); assert.equal(error.stage, "pi"); assert.equal(error.mutationOutcome, "none");
|
|
175
|
+
assert.equal(error.reviewerEvidence?.phase, "auth"); return true;
|
|
176
|
+
});
|
|
177
|
+
const rejectedFixture = relayFixture(t, true);
|
|
178
|
+
const prepared = await prepareReviewHostRelaySlot(rejectedFixture, (req, dependencies) => runInProcessReviewer(req, { ...dependencies, complete: deps().complete }));
|
|
179
|
+
await assert.rejects(submitReviewHostRelayPreparedResult(prepared), error => {
|
|
180
|
+
assert.ok(error instanceof ReviewHostRelayError); assert.equal(error.kind, REVIEW_HOST_RELAY_FAILURE.SUBMISSION_REFUSED); assert.equal(error.stage, "submit"); assert.equal(error.mutationOutcome, "none");
|
|
181
|
+
assert.equal(error.reviewerEvidence?.phase, "completion"); assert.equal((error.reviewerEvidence?.cost as any)?.total, 0.15); return true;
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { realpathSync } from "node:fs";
|
|
3
|
+
import { mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
4
6
|
import test from "node:test";
|
|
5
7
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
6
8
|
import { createGentleAiExtension, __testing } from "../extensions/gentle-ai.ts";
|
|
@@ -636,6 +638,75 @@ const ctx = { cwd: process.cwd() } as ExtensionContext;
|
|
|
636
638
|
// removes the verifier the plan requires" pass it so a verifier is required.
|
|
637
639
|
const ESCALATE = { escalate: { item: 3, reason: "changes a published export" } } as const;
|
|
638
640
|
|
|
641
|
+
for (const [label, input] of [["normal", undefined], ["escalated", ESCALATE], ["untrusted closure", { nativeReviewOutcome: "closed" }]] as const) test(`RDD off registered assess ${label} skips native calls and retains verification`, async (t) => {
|
|
642
|
+
const root = mkdtempSync(join(tmpdir(), "rdd-off-assess-"));
|
|
643
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
644
|
+
execFileSync("git", ["init", "-q"], { cwd: root, env: { PATH: process.env.PATH, HOME: root, GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null" } });
|
|
645
|
+
const state = join(root, "state.json");
|
|
646
|
+
writeFileSync(state, '{"unchanged":true}\n');
|
|
647
|
+
const calls = { mode: 0, assess: 0, target: 0 };
|
|
648
|
+
const cli = {
|
|
649
|
+
reviewMode: async () => { calls.mode++; return { operation: "status", scope: "clone", status: { global: "off", cloneLocal: "", effective: "off", source: "global" } }; },
|
|
650
|
+
assess: async () => { calls.assess++; return decodeReviewAssessmentV1(newEnvelope()); },
|
|
651
|
+
targetStatus: async () => { calls.target++; return { applicability: "current_target", targetIdentity: "fixture" }; },
|
|
652
|
+
} as unknown as NativeReviewCli;
|
|
653
|
+
const tool = reviewControllerTool(cli);
|
|
654
|
+
const context = { cwd: root } as ExtensionContext;
|
|
655
|
+
{
|
|
656
|
+
const result = await tool.execute("off", { operation: "assess", workspaceRoot: root, ...(input === undefined ? {} : { input: JSON.stringify(input) }) }, undefined, undefined, context);
|
|
657
|
+
const escalated = input !== undefined && "escalate" in input;
|
|
658
|
+
const risk = escalated ? VERIFICATION_TIER.HIGH : VERIFICATION_TIER.MEDIUM;
|
|
659
|
+
assert.deepEqual(result.details, {
|
|
660
|
+
operation: "assess", schema: "gentle-pi.review-assessment-plan/v1", risk, nativeRisk: "unassessable",
|
|
661
|
+
...(escalated ? { agentEscalation: { item: 3, label: "changing or removing contracts others already consume", reason: ESCALATE.escalate.reason, applied: true } } : {}),
|
|
662
|
+
reasons: [{ code: "rdd-off-assessment-skipped", detail: "Native assessment skipped because receipt-driven development is off; changed counts were not measured." }],
|
|
663
|
+
changedPaths: 0, changedLines: 0, candidate: null, rddLine: "off", nativeReviewOutcome: "unknown", outcome_source: "unknown",
|
|
664
|
+
writerProfile: "small", writerProfileSource: "fallback",
|
|
665
|
+
plan: verificationPlan({ rddLine: RDD_LINE.OFF, risk, writerProfile: WRITER_PROFILE.SMALL, nativeReviewOutcome: NATIVE_REVIEW_OUTCOME.UNKNOWN }),
|
|
666
|
+
workspace_root: realpathSync(root),
|
|
667
|
+
});
|
|
668
|
+
assert.deepEqual(result.content, [{ type: "text", text: JSON.stringify(result.details) }]);
|
|
669
|
+
}
|
|
670
|
+
assert.deepEqual(calls, { mode: 1, assess: 0, target: 0 });
|
|
671
|
+
await assert.rejects(() => tool.execute("invalid", { operation: "assess", input: JSON.stringify({ baseRef: "HEAD" }) }, undefined, undefined, context), { message: "Review assess baseRef requires committedOnly: true" });
|
|
672
|
+
await assert.rejects(() => tool.execute("cancelled", { operation: "assess" }, AbortSignal.abort(), undefined, context), { message: "Review controller operation was cancelled" });
|
|
673
|
+
assert.deepEqual(calls, { mode: 1, assess: 0, target: 0 });
|
|
674
|
+
assert.equal(readFileSync(state, "utf8"), '{"unchanged":true}\n');
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
test("registered assess preserves on, malformed and failed mode paths without using a prior off result", async (t) => {
|
|
678
|
+
const root = mkdtempSync(join(tmpdir(), "rdd-assess-modes-"));
|
|
679
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
680
|
+
execFileSync("git", ["init", "-q"], { cwd: root, env: { PATH: process.env.PATH, HOME: root, GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null" } });
|
|
681
|
+
for (const mode of ["on", "malformed", "failed"] as const) {
|
|
682
|
+
const calls = { mode: 0, assess: 0, target: 0 };
|
|
683
|
+
let first = true;
|
|
684
|
+
const cli = {
|
|
685
|
+
reviewMode: async () => {
|
|
686
|
+
calls.mode++;
|
|
687
|
+
if (first) { first = false; return { status: { effective: "off", source: "global" } }; }
|
|
688
|
+
if (mode === "failed") throw new Error("mode unavailable");
|
|
689
|
+
return { status: { effective: mode === "on" ? "on" : "off", source: mode === "malformed" ? "invalid" : "global" } };
|
|
690
|
+
},
|
|
691
|
+
assess: async () => { calls.assess++; return decodeReviewAssessmentV1(newEnvelope()); },
|
|
692
|
+
targetStatus: async () => { calls.target++; return { applicability: "current_target", targetIdentity: "fixture" }; },
|
|
693
|
+
} as unknown as NativeReviewCli;
|
|
694
|
+
const tool = reviewControllerTool(cli);
|
|
695
|
+
const context = { cwd: root } as ExtensionContext;
|
|
696
|
+
await tool.execute("off", { operation: "assess" }, undefined, undefined, context);
|
|
697
|
+
assert.deepEqual(calls, { mode: 1, assess: 0, target: 0 });
|
|
698
|
+
const result = await tool.execute(mode, { operation: "assess" }, undefined, undefined, context);
|
|
699
|
+
const details = result.details as Record<string, unknown>;
|
|
700
|
+
assert.deepEqual(calls, { mode: 2, assess: 1, target: 1 }, mode);
|
|
701
|
+
assert.equal(details.rddLine, mode === "on" ? "on" : "unknown");
|
|
702
|
+
assert.equal(details.nativeRisk, "high");
|
|
703
|
+
assert.equal(details.risk, "medium");
|
|
704
|
+
assert.equal(details.reviewDue, true);
|
|
705
|
+
assert.deepEqual(details.nextTransition, nextTransition());
|
|
706
|
+
assert.deepEqual(result.content, [{ type: "text", text: JSON.stringify(result.details) }]);
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
|
|
639
710
|
// Changed with verification by named risk: an unassessable candidate no longer
|
|
640
711
|
// verifies like high; the plan is medium and the native tier stays visible.
|
|
641
712
|
test("gentle_review assess: an older binary without the assess verb informs only (no verifier without escalate)", async () => {
|
|
@@ -1028,9 +1099,9 @@ test("gentle_review assess: an unassessable candidate is never closed", async ()
|
|
|
1028
1099
|
test("gentle_review assess: derived closure only changes the RDD on-path; RDD off plans are unchanged", async () => {
|
|
1029
1100
|
for (const risk of ["passive", "medium", "high"] as const) {
|
|
1030
1101
|
for (const consumed of [true, false]) {
|
|
1031
|
-
//
|
|
1102
|
+
// Off skips native assessment, so its fallback is unassessable even for a passive fixture.
|
|
1032
1103
|
const off = await assessWith(closureCli({ rdd: "off", risk, consumed }), { writerModelId: "claude-sonnet-5", writerEffort: "high" });
|
|
1033
|
-
const expectedOff = verificationPlan({ rddLine: RDD_LINE.OFF, risk: verificationRisk(
|
|
1104
|
+
const expectedOff = verificationPlan({ rddLine: RDD_LINE.OFF, risk: verificationRisk(VERIFICATION_TIER.UNASSESSABLE, undefined), writerProfile: WRITER_PROFILE.LARGE });
|
|
1034
1105
|
assert.deepEqual(off.plan, { ...expectedOff }, `off ${risk} consumed ${consumed}`);
|
|
1035
1106
|
const on = await assessWith(closureCli({ rdd: "on", risk, consumed }), { writerModelId: "claude-sonnet-5", writerEffort: "high" });
|
|
1036
1107
|
const expectedOn = verificationPlan({ rddLine: RDD_LINE.ON, risk: verificationRisk(risk, undefined), writerProfile: WRITER_PROFILE.LARGE, nativeReviewOutcome: consumed ? NATIVE_REVIEW_OUTCOME.CLOSED : NATIVE_REVIEW_OUTCOME.UNKNOWN });
|
|
@@ -267,6 +267,7 @@ function controllerHarness(cwd: string, processEnv: NodeJS.ProcessEnv = {}, opti
|
|
|
267
267
|
childStandingReviewPermissionClient?: ChildStandingReviewPermissionClient;
|
|
268
268
|
consent?: ReviewConsentEnvelope;
|
|
269
269
|
targetStatus?: (request: Record<string, unknown>) => Promise<ReviewStatusV3>;
|
|
270
|
+
emitted?: Array<{ channel: string; data: unknown }>;
|
|
270
271
|
} = {}) {
|
|
271
272
|
const tools = new Map<string, RegisteredTool>();
|
|
272
273
|
const commands = new Map<string, RegisteredCommand>();
|
|
@@ -300,7 +301,7 @@ function controllerHarness(cwd: string, processEnv: NodeJS.ProcessEnv = {}, opti
|
|
|
300
301
|
on(name: string, handler: RegisteredEvent) { events.set(name, handler); },
|
|
301
302
|
registerCommand(name: string, definition: RegisteredCommand) { commands.set(name, definition); },
|
|
302
303
|
registerTool(definition: RegisteredTool & { name: string }) { tools.set(definition.name, definition); },
|
|
303
|
-
events: { emit() {} },
|
|
304
|
+
events: { emit(channel: string, data: unknown) { options.emitted?.push({ channel, data }); } },
|
|
304
305
|
} as unknown as ExtensionAPI);
|
|
305
306
|
const controller = tools.get("gentle_review");
|
|
306
307
|
assert.ok(controller);
|
|
@@ -413,6 +414,25 @@ test("provider grant and decline remain candidate-only and cancellation stores n
|
|
|
413
414
|
assert.equal(prompts, 3, "neither provider choice creates standing host permission");
|
|
414
415
|
});
|
|
415
416
|
|
|
417
|
+
test("the review consent prompt projects one balanced Herdr blocker while it awaits the human", async (t) => {
|
|
418
|
+
const cwd = reviewRepository(t);
|
|
419
|
+
const emitted: Array<{ channel: string; data: unknown }> = [];
|
|
420
|
+
const runtime = controllerHarness(cwd, {}, { emitted });
|
|
421
|
+
const herdr = () => emitted.filter(({ channel }) => channel === "herdr:blocked").map(({ data }) => data);
|
|
422
|
+
const observedWhilePrompting: unknown[][] = [];
|
|
423
|
+
const ctx = interactiveContext(cwd, {}, async (_title, options) => {
|
|
424
|
+
observedWhilePrompting.push(herdr());
|
|
425
|
+
return options[0];
|
|
426
|
+
});
|
|
427
|
+
await runtime.controller.execute("herdr-consent", { operation: "start", input: JSON.stringify({ mode: "ordinary" }) }, undefined, undefined, ctx);
|
|
428
|
+
assert.deepEqual(observedWhilePrompting, [[{ active: true, label: "Review authorization awaiting input" }]], "Herdr sees the pane as blocked while the authorization is open");
|
|
429
|
+
assert.deepEqual(herdr(), [
|
|
430
|
+
{ active: true, label: "Review authorization awaiting input" },
|
|
431
|
+
{ active: false },
|
|
432
|
+
], "the blocker is released once the human answers");
|
|
433
|
+
assert.deepEqual(runtime.answers, ["granted"]);
|
|
434
|
+
});
|
|
435
|
+
|
|
416
436
|
test("explicit revocation ends the host grant without changing provider mode or authority", async (t) => {
|
|
417
437
|
const cwd = reviewRepository(t);
|
|
418
438
|
const runtime = controllerHarness(cwd);
|
|
@@ -377,12 +377,12 @@ test("RDD labels say what is happening and who acts", () => {
|
|
|
377
377
|
});
|
|
378
378
|
});
|
|
379
379
|
|
|
380
|
-
test("
|
|
381
|
-
assert.doesNotMatch(renderShellSidebarBar(model(), theme, 46).join("\n"), /
|
|
380
|
+
test("the Review section stays hidden without current-session evidence and sits between Changes and Integrations", () => {
|
|
381
|
+
assert.doesNotMatch(renderShellSidebarBar(model(), theme, 46).join("\n"), /REVIEW/);
|
|
382
382
|
const text = renderShellSidebarBar(model({ state: "reviewing", scope: "app.ts +2 files" }), theme, 46).join("\n");
|
|
383
|
-
assert.equal((text.match(/
|
|
384
|
-
assert.ok(text.indexOf("
|
|
385
|
-
assert.ok(text.indexOf("
|
|
383
|
+
assert.equal((text.match(/REVIEW/g) ?? []).length, 1);
|
|
384
|
+
assert.ok(text.indexOf("CHANGES") < text.indexOf("REVIEW"));
|
|
385
|
+
assert.ok(text.indexOf("REVIEW") < text.indexOf("INTEGRATIONS"));
|
|
386
386
|
assert.match(text, /Reviewers running…/);
|
|
387
387
|
assert.match(text, /app\.ts \+2 files/);
|
|
388
388
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { snapshotReviewStartContext } from "../lib/review-start-context.ts";
|
|
4
|
+
|
|
5
|
+
test("retained intent cannot be changed through caller-owned lens arrays", () => {
|
|
6
|
+
const lenses = ["review-risk"];
|
|
7
|
+
const context = snapshotReviewStartContext({ lenses, lensesReason: "permission checks", requestContextPath: "/repo/spec.md", policyPath: "/repo/policy.json" });
|
|
8
|
+
lenses.push("review-readability");
|
|
9
|
+
assert.deepEqual(context.lenses, ["review-risk"]);
|
|
10
|
+
assert.equal(Object.isFrozen(context), true);
|
|
11
|
+
assert.equal(Object.isFrozen(context.lenses), true);
|
|
12
|
+
assert.throws(() => { (context.lenses as string[]).push("review-reliability"); }, TypeError);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("intent snapshot never retains provider authority, scope or executable state", () => {
|
|
16
|
+
const request = { focus: "risk", targetIdentity: "stale-target", baseRef: "stale-base", intendedUntracked: ["stale-file"], consentBinding: "old-consent", signal: new AbortController().signal };
|
|
17
|
+
assert.deepEqual(snapshotReviewStartContext(request), { focus: "risk" });
|
|
18
|
+
assert.deepEqual(snapshotReviewStartContext({}), {});
|
|
19
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
4
|
+
|
|
5
|
+
// The review-family tool declarations are injected into every session's
|
|
6
|
+
// system prompt (description + snippet + guidelines + parameter schemas).
|
|
7
|
+
// They were historically unbudgeted while orchestrator declarations had a
|
|
8
|
+
// hard byte budget (tests/orchestrator-prompt-budget.test.ts), so their
|
|
9
|
+
// operational prose grew until it duplicated the runtime RDD contract.
|
|
10
|
+
// This test pins a hard budget and the security invariants that must
|
|
11
|
+
// survive any future trim. Operational detail lives in the mirrored
|
|
12
|
+
// review contract (contracts/review-provider-contract-mirror) and in
|
|
13
|
+
// docs/delegated-verification.md; the always-on surface keeps only
|
|
14
|
+
// invariants and routing.
|
|
15
|
+
|
|
16
|
+
interface RegisteredDeclaration {
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
promptSnippet?: string;
|
|
20
|
+
promptGuidelines?: readonly string[];
|
|
21
|
+
parameters?: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const REVIEW_FAMILY_TOOLS = [
|
|
25
|
+
"gentle_review",
|
|
26
|
+
"gentle_review_capture",
|
|
27
|
+
"gentle_review_capture_group",
|
|
28
|
+
"gentle_review_scope",
|
|
29
|
+
"gentle_odd_phase",
|
|
30
|
+
] as const;
|
|
31
|
+
|
|
32
|
+
// The whole-declaration JSON (schemas, property names, the operation enum,
|
|
33
|
+
// and test-contracted fragments such as the S5 escalate shape) is
|
|
34
|
+
// irreducible or contract-pinned surface; the budget pins the prose trim:
|
|
35
|
+
// the historical unbudgeted surface was ~21.3 KB and the trimmed surface
|
|
36
|
+
// lands ~16.6 KB. Regrowth past 16.8 KB fails here. Prose-only bytes are
|
|
37
|
+
// reported in the diagnostic for visibility.
|
|
38
|
+
// The original trim measured 16,638 B; rebasing onto main added the requestContextPath
|
|
39
|
+
// guideline and the abandon parameter prose (+~0.5 KB of new upstream capability text),
|
|
40
|
+
// so the cap tracks that state rather than the earlier main.
|
|
41
|
+
// Shared guidance (REVIEW_BLOCKER_GUIDANCE) is declared once on gentle_review:
|
|
42
|
+
// Pi dedupes identical guidelines, so per-tool copies only inflate this count.
|
|
43
|
+
const REVIEW_FAMILY_PROSE_BUDGET_BYTES = 17300;
|
|
44
|
+
|
|
45
|
+
function registerReviewFamily(): Map<string, RegisteredDeclaration> {
|
|
46
|
+
const tools = new Map<string, RegisteredDeclaration>();
|
|
47
|
+
createGentleAiExtension({ nativeReviewCli: null })({
|
|
48
|
+
on() {},
|
|
49
|
+
registerCommand() {},
|
|
50
|
+
registerTool(definition: RegisteredDeclaration) {
|
|
51
|
+
tools.set(definition.name, definition);
|
|
52
|
+
},
|
|
53
|
+
} as never);
|
|
54
|
+
for (const name of REVIEW_FAMILY_TOOLS) {
|
|
55
|
+
assert.ok(tools.get(name), `missing registered review tool ${name}`);
|
|
56
|
+
}
|
|
57
|
+
return tools;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function surfaceBytes(tools: Map<string, RegisteredDeclaration>): number {
|
|
61
|
+
const selected = REVIEW_FAMILY_TOOLS.map((name) => tools.get(name)!);
|
|
62
|
+
return Buffer.byteLength(JSON.stringify(selected), "utf8");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function reviewSurface(tool: RegisteredDeclaration | undefined): string {
|
|
66
|
+
assert.ok(tool, "review tool must be registered");
|
|
67
|
+
return [
|
|
68
|
+
tool.description ?? "",
|
|
69
|
+
tool.promptSnippet ?? "",
|
|
70
|
+
...(tool.promptGuidelines ?? []),
|
|
71
|
+
JSON.stringify(tool.parameters),
|
|
72
|
+
].join("\n");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
test("review-family tool declarations fit the always-on prose budget", t => {
|
|
76
|
+
const tools = registerReviewFamily();
|
|
77
|
+
const bytes = surfaceBytes(tools);
|
|
78
|
+
const proseBytes = REVIEW_FAMILY_TOOLS.reduce((sum, name) => {
|
|
79
|
+
const tool = tools.get(name)!;
|
|
80
|
+
return sum + Buffer.byteLength([tool.description ?? "", tool.promptSnippet ?? "", ...(tool.promptGuidelines ?? [])].join("\n"), "utf8");
|
|
81
|
+
}, 0);
|
|
82
|
+
t.diagnostic(`review-family declarations: ${bytes} B (budget ${REVIEW_FAMILY_PROSE_BUDGET_BYTES} B); prose-only ${proseBytes} B`);
|
|
83
|
+
assert.ok(
|
|
84
|
+
bytes <= REVIEW_FAMILY_PROSE_BUDGET_BYTES,
|
|
85
|
+
`review-family declarations ${bytes} B exceed the always-on budget ${REVIEW_FAMILY_PROSE_BUDGET_BYTES} B`,
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("trimmed review surface keeps the security and authority invariants", () => {
|
|
90
|
+
const tools = registerReviewFamily();
|
|
91
|
+
const controller = reviewSurface(tools.get("gentle_review"));
|
|
92
|
+
const capture = reviewSurface(tools.get("gentle_review_capture"));
|
|
93
|
+
const family = [controller, capture, reviewSurface(tools.get("gentle_review_capture_group")),
|
|
94
|
+
reviewSurface(tools.get("gentle_review_scope")), reviewSurface(tools.get("gentle_odd_phase"))].join("\n");
|
|
95
|
+
|
|
96
|
+
// Delivery boundary.
|
|
97
|
+
assert.match(family, /Review outcomes never authorize delivery/);
|
|
98
|
+
// Provider-issued opaque values are authoritative; never invent tokens.
|
|
99
|
+
assert.match(controller, /native-input-required.*never.*invent/is);
|
|
100
|
+
// Ambiguous output handling is declared, not improvised.
|
|
101
|
+
assert.match(
|
|
102
|
+
controller,
|
|
103
|
+
/ambiguous START output.*target-scoped native status.*declared action.*ambiguous gentle_review_capture.*never replays/is,
|
|
104
|
+
);
|
|
105
|
+
// RESET/RECOVER stay destructive and authorization-gated.
|
|
106
|
+
assert.match(controller, /RESET or RECOVER only after explicit user authorization/is);
|
|
107
|
+
assert.match(controller, /destructive/is);
|
|
108
|
+
// Host consent is host-owned; permission is never created from prose or arguments.
|
|
109
|
+
assert.match(controller, /never create host permission from tool arguments|host-owned/is);
|
|
110
|
+
// Correction-budget units stay named (diff lines vs logical budget).
|
|
111
|
+
assert.match(controller, /diff lines/);
|
|
112
|
+
assert.match(controller, /logical correction/);
|
|
113
|
+
for (const [label, text] of [["capture schema", capture.split("\n").at(-1)!], ["capture guidance", (tools.get("gentle_review_capture")!.promptGuidelines ?? []).join("\n")]] as const) {
|
|
114
|
+
assert.match(text, /diff lines/, label);
|
|
115
|
+
assert.match(text, /logical correction budget/, label);
|
|
116
|
+
}
|
|
117
|
+
assert.ok(controller.includes("The plan adds an independent verifier only when escalate names a Task Size high-risk item; it can never lower a tier."));
|
|
118
|
+
// Native review never removes a tier-required verifier (S1) and stays an outside view.
|
|
119
|
+
assert.match(controller, /native review is an additional outside view/);
|
|
120
|
+
assert.match(controller, /verify-always-rdd-high/);
|
|
121
|
+
});
|