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,76 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { ReviewContinuationRegistry, type RetainedReviewContinuation } from "../lib/review-continuation-registry.ts";
|
|
4
|
+
|
|
5
|
+
const selection = { untrackedScope: "exclude" as const, expectedUntrackedInventory: "inventory", intendedUntracked: [] };
|
|
6
|
+
const preStart = { ...selection, targetIdentity: "target", candidateTree: "tree" };
|
|
7
|
+
const stop = { selectionBinding: "selection", targetIdentity: "target" };
|
|
8
|
+
const route = { workspaceRoot: "/repo", lineageId: "lineage", targetIdentity: "target" };
|
|
9
|
+
|
|
10
|
+
test("four continuation kinds share one capacity and replacement does not refresh insertion order", () => {
|
|
11
|
+
const registry = new ReviewContinuationRegistry();
|
|
12
|
+
registry.retainSelection("/repo", "first", selection);
|
|
13
|
+
registry.retainPreStart("/pre", preStart);
|
|
14
|
+
registry.retainStop("/stop", stop);
|
|
15
|
+
for (let index = 0; index < 61; index++) registry.retainCapture(`binding-${index}`, route);
|
|
16
|
+
assert.equal(registry.size, 64);
|
|
17
|
+
registry.retainSelection("/repo", "first", { ...selection, expectedUntrackedInventory: "replacement" });
|
|
18
|
+
registry.retainCapture("last", route);
|
|
19
|
+
assert.equal(registry.readSelection("/repo", "first"), undefined);
|
|
20
|
+
assert.equal(registry.readPreStart("/pre")?.candidateTree, "tree");
|
|
21
|
+
assert.equal(registry.readStop("/stop")?.selectionBinding, "selection");
|
|
22
|
+
assert.equal(registry.size, 64);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("deleting and reinserting moves an entry behind older retained entries", () => {
|
|
26
|
+
const registry = new ReviewContinuationRegistry();
|
|
27
|
+
registry.retainSelection("/repo", "reinserted", selection);
|
|
28
|
+
registry.retainPreStart("/older", preStart);
|
|
29
|
+
registry.clearSelection("/repo", "reinserted");
|
|
30
|
+
registry.retainSelection("/repo", "reinserted", selection);
|
|
31
|
+
for (let index = 0; index < 63; index++) registry.retainCapture(`binding-${index}`, route);
|
|
32
|
+
assert.equal(registry.readPreStart("/older"), undefined);
|
|
33
|
+
assert.notEqual(registry.readSelection("/repo", "reinserted"), undefined);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("pre-start entries replace stop entries but cannot be read as lineage selections", () => {
|
|
37
|
+
const registry = new ReviewContinuationRegistry();
|
|
38
|
+
registry.retainStop("/repo", stop);
|
|
39
|
+
assert.equal(registry.readPreStart("/repo"), undefined);
|
|
40
|
+
registry.retainPreStart("/repo", preStart);
|
|
41
|
+
assert.equal(registry.readStop("/repo"), undefined);
|
|
42
|
+
assert.equal(registry.readSelection("/repo", ""), undefined);
|
|
43
|
+
assert.equal(registry.size, 1);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("capture cleanup keeps current bindings and other workspaces, lineages and sessions", () => {
|
|
47
|
+
const registry = new ReviewContinuationRegistry(), otherSession = new ReviewContinuationRegistry();
|
|
48
|
+
registry.retainCapture("keep", route);
|
|
49
|
+
registry.retainCapture("expired", route);
|
|
50
|
+
registry.retainCapture("other-root", { ...route, workspaceRoot: "/other" });
|
|
51
|
+
registry.retainCapture("other-lineage", { ...route, lineageId: "other" });
|
|
52
|
+
registry.retainSelection("/repo", "lineage", selection);
|
|
53
|
+
otherSession.retainCapture("expired", route);
|
|
54
|
+
registry.clearCaptureRoutes("/repo", "lineage", ["keep"]);
|
|
55
|
+
assert.equal(registry.readCapture("expired"), undefined);
|
|
56
|
+
for (const binding of ["keep", "other-root", "other-lineage"]) assert.notEqual(registry.readCapture(binding), undefined);
|
|
57
|
+
registry.clearCaptureRoutes("/repo", "lineage");
|
|
58
|
+
assert.equal(registry.readCapture("keep"), undefined);
|
|
59
|
+
assert.notEqual(registry.readSelection("/repo", "lineage"), undefined);
|
|
60
|
+
assert.notEqual(otherSession.readCapture("expired"), undefined);
|
|
61
|
+
assert.equal(registry.readSelection("/other", "lineage"), undefined);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("Map test seam uses the same discriminated entries without copying retained state", () => {
|
|
65
|
+
const backing = new Map<string, RetainedReviewContinuation>();
|
|
66
|
+
const first = ReviewContinuationRegistry.from(backing), next = ReviewContinuationRegistry.from(backing);
|
|
67
|
+
first.retainSelection("/repo", "lineage", selection);
|
|
68
|
+
assert.equal(backing.size, 1);
|
|
69
|
+
assert.equal([...backing.values()][0].kind, "selection");
|
|
70
|
+
assert.notEqual(next.readSelection("/repo", "lineage"), undefined);
|
|
71
|
+
assert.equal("kind" in next.readSelection("/repo", "lineage")!, false, "internal tags never enter native requests");
|
|
72
|
+
first.retainCapture("binding", route);
|
|
73
|
+
assert.deepEqual(next.readCapture("binding"), route);
|
|
74
|
+
next.clearSelection("/repo", "lineage");
|
|
75
|
+
assert.equal(first.size, 1);
|
|
76
|
+
});
|
|
@@ -143,9 +143,12 @@ test("STATUS renders the managed_assets_outdated continuation command as the act
|
|
|
143
143
|
test("caller-relative STATUS approved guidance preserves selected root against a different session", async () => {
|
|
144
144
|
const lineageId = "caller-relative-status";
|
|
145
145
|
const root = realpathSync(process.cwd());
|
|
146
|
-
const
|
|
146
|
+
const offered = approvedAcknowledgementStatus(lineageId, root);
|
|
147
|
+
offered.raw = { ...offered.raw, next_transition: { kind: "execute", execute: { operation: "review.acknowledge-approved" } } };
|
|
148
|
+
const native = { targetStatus: async () => offered } as unknown as NativeReviewCli;
|
|
147
149
|
const result = await __testing.executeReviewControllerOperation({ operation: "status", lineageId, workspaceRoot: root }, dirname(root), native);
|
|
148
150
|
assert.equal(result.next_action, `gentle_review {"operation":"acknowledge-approved","lineageId":"${lineageId}","workspaceRoot":${JSON.stringify(root)}}`);
|
|
151
|
+
assert.equal((result.blocker as Record<string, unknown>).category, "continuation");
|
|
149
152
|
});
|
|
150
153
|
|
|
151
154
|
test("caller-relative approved closure guidance preserves selected root and canonical omission", async () => {
|
|
@@ -423,7 +426,7 @@ function candidateRepository(t: test.TestContext): string {
|
|
|
423
426
|
writeFileSync(join(cwd, "tracked.txt"), "base\n");
|
|
424
427
|
git("add", "tracked.txt");
|
|
425
428
|
git("-c", "user.name=Routing Test", "-c", "user.email=routing@example.invalid", "commit", "-m", "base");
|
|
426
|
-
return realpathSync(
|
|
429
|
+
return realpathSync(git("rev-parse", "--show-toplevel").trim());
|
|
427
430
|
}
|
|
428
431
|
|
|
429
432
|
test("approved acknowledgement burn tears down the retained candidate view and keeps its projection", async (t) => {
|
|
@@ -965,7 +968,7 @@ function repository(t: test.TestContext): string {
|
|
|
965
968
|
execFileSync("git", ["add", "tracked.txt"], { cwd, stdio: "ignore" });
|
|
966
969
|
execFileSync("git", ["-c", "user.name=Routing Test", "-c", "user.email=routing@example.invalid", "commit", "-m", "base"], { cwd, stdio: "ignore" });
|
|
967
970
|
writeFileSync(join(cwd, "tracked.txt"), "candidate\n");
|
|
968
|
-
return cwd;
|
|
971
|
+
return realpathSync(execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf8" }).trim());
|
|
969
972
|
}
|
|
970
973
|
|
|
971
974
|
test("candidate lifecycle sweeps startup and cleans every shutdown including reload", async (t) => {
|
|
@@ -1559,13 +1562,19 @@ for (const statusSchema of ["gentle-ai.review-integration.status/v6", "gentle-ai
|
|
|
1559
1562
|
assert.deepEqual(requests.map((request) => request.cwd), [cwd, cwd, cwd]);
|
|
1560
1563
|
assert.equal(starts[0]!.cwd, cwd);
|
|
1561
1564
|
assert.deepEqual(starts[0]!.intendedUntrackedSelection, { argumentTokens: selection.submission!.argumentTokens, value: JSON.stringify({ schema: "gentle-ai.review-intended-untracked-selection/v1", untracked_scope: "select", expected_untracked_inventory: SHA, intended_untracked: [eligible] }) });
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1565
|
+
// gentle-pi#941: every refusal named its own check, so a caller holding
|
|
1566
|
+
// provider-issued bytes can tell a stale binding from an ineligible path
|
|
1567
|
+
// instead of retrying the same call.
|
|
1568
|
+
for (const { reason, field, ...invalid } of [
|
|
1569
|
+
{ selectionBinding: selectionBinding.replace(eligible, "docs/stale.md"), intendedUntracked: [eligible], reason: "binding-mismatch" },
|
|
1570
|
+
{ selectionBinding, intendedUntracked: [eligible, eligible], reason: "untracked-selection-invalid" },
|
|
1571
|
+
{ selectionBinding, intendedUntracked: ["docs/unknown.md"], reason: "path-not-eligible", field: "docs/unknown.md" },
|
|
1572
|
+
] as ReadonlyArray<{ reason: string; field?: string; selectionBinding: string; intendedUntracked: readonly string[] }>) {
|
|
1566
1573
|
const rejection = await __testing.executeReviewControllerOperation({ operation: "select-intended-untracked", ...invalid } as never, cwd, native, undefined, undefined, undefined, retained);
|
|
1567
1574
|
assert.equal(rejection.status, "blocked", JSON.stringify(invalid));
|
|
1568
1575
|
assert.equal(rejection.outcome, "intended-untracked-selection-binding-rejected", JSON.stringify(invalid));
|
|
1576
|
+
assert.equal(rejection.reason, reason, JSON.stringify(rejection));
|
|
1577
|
+
assert.equal(rejection.field, field, JSON.stringify(rejection));
|
|
1569
1578
|
assert.equal(rejection.mutation_performed, false, JSON.stringify(invalid));
|
|
1570
1579
|
assert.equal(rejection.mutation_outcome, "none", JSON.stringify(invalid));
|
|
1571
1580
|
}
|
|
@@ -1574,6 +1583,71 @@ for (const statusSchema of ["gentle-ai.review-integration.status/v6", "gentle-ai
|
|
|
1574
1583
|
assert.equal(requests.every((request) => !("lineageId" in request)), true);
|
|
1575
1584
|
});
|
|
1576
1585
|
|
|
1586
|
+
// gentle-pi#941: a selection refused because the live status moved names the field
|
|
1587
|
+
// that moved, and an empty selection -- the only honest answer when the candidate
|
|
1588
|
+
// touches no untracked file -- is accepted rather than refused.
|
|
1589
|
+
for (const scenario of [
|
|
1590
|
+
{ name: "target_identity", moved: (status: ReviewStatusV3) => ({ ...status, targetIdentity: `sha256:${"d".repeat(64)}` }) },
|
|
1591
|
+
{ name: "candidate_tree", moved: (status: ReviewStatusV3) => ({ ...status, projection: { ...status.projection, currentCandidateTree: "e".repeat(40) } }) },
|
|
1592
|
+
]) test(`a moved ${scenario.name} refuses the selection by name rather than opaquely`, async (t) => {
|
|
1593
|
+
const cwd = realpathSync(repository(t)), eligible = "selected.md";
|
|
1594
|
+
writeFileSync(join(cwd, eligible), "selected\n");
|
|
1595
|
+
const initialTarget = startStatus(cwd, undefined, [eligible]);
|
|
1596
|
+
const selection = intendedUntrackedSelection(initialTarget, [eligible]);
|
|
1597
|
+
const initial = { ...initialTarget, nextTransition: { kind: "collect", reasonCode: "intended_untracked_selection_required", collect: { inputs: [selection] } }, raw: { schema: "gentle-ai.review-integration.status/v7" } } as ReviewStatusV3;
|
|
1598
|
+
let statusCalls = 0;
|
|
1599
|
+
const starts: Array<Record<string, unknown>> = [], retained = new Map();
|
|
1600
|
+
const native = {
|
|
1601
|
+
reviewMode: async () => ({ operation: "status", scope: "clone", status: { global: "on", cloneLocal: "on", effective: "on", source: "clone_local" } }),
|
|
1602
|
+
// The binding is issued against the first status and revalidated against
|
|
1603
|
+
// the second, which is where a real repository drifts under the caller.
|
|
1604
|
+
targetStatus: async () => (++statusCalls === 1 ? initial : scenario.moved(initial)),
|
|
1605
|
+
start: async (request: Record<string, unknown>) => { starts.push(request); return { lineageId: "unreachable", state: "reviewing", riskLevel: "low", selectedLenses: [], changedFiles: 1, changedLines: 1, correctionBudget: 1, action: "created", lensesRequired: false, riskReasons: [], raw: {} }; },
|
|
1606
|
+
} as unknown as NativeReviewCli;
|
|
1607
|
+
const listed = await __testing.executeReviewControllerOperation({ operation: "status", workspaceRoot: cwd }, cwd, native, undefined, undefined, undefined, retained);
|
|
1608
|
+
const rejection = await __testing.executeReviewControllerOperation({ operation: "select-intended-untracked", selectionBinding: listed.selectionBinding as string, intendedUntracked: [eligible], workspaceRoot: cwd } as never, cwd, native, undefined, undefined, undefined, retained);
|
|
1609
|
+
assert.equal(rejection.outcome, "intended-untracked-selection-binding-rejected", JSON.stringify(rejection));
|
|
1610
|
+
assert.equal(rejection.reason, "status-field-mismatch", JSON.stringify(rejection));
|
|
1611
|
+
assert.equal(rejection.field, scenario.name, JSON.stringify(rejection));
|
|
1612
|
+
assert.equal(starts.length, 0);
|
|
1613
|
+
});
|
|
1614
|
+
|
|
1615
|
+
// The reporter's own case in gentle-pi#941: the candidate touches only tracked
|
|
1616
|
+
// files while the repository carries an unrelated untracked inventory, so the
|
|
1617
|
+
// only honest selection is the empty one. It must start, not be refused.
|
|
1618
|
+
test("an empty intended-untracked selection excludes every eligible path and starts", async (t) => {
|
|
1619
|
+
const cwd = realpathSync(repository(t)), sessionCwd = repository(t);
|
|
1620
|
+
writeFileSync(join(cwd, "qa screenshot 1.png"), "noise\n");
|
|
1621
|
+
writeFileSync(join(cwd, "mcp.log"), "noise\n");
|
|
1622
|
+
const initialTarget = startStatus(cwd), target = startStatus(cwd);
|
|
1623
|
+
const selection = intendedUntrackedSelection(initialTarget, ["qa screenshot 1.png", "mcp.log"]);
|
|
1624
|
+
const initial = { ...initialTarget, nextTransition: { kind: "collect", reasonCode: "intended_untracked_selection_required", collect: { inputs: [selection] } }, raw: { schema: "gentle-ai.review-integration.status/v7" } } as ReviewStatusV3;
|
|
1625
|
+
const starts: Array<Record<string, unknown>> = [], retained = new Map();
|
|
1626
|
+
const native = {
|
|
1627
|
+
reviewMode: async () => ({ operation: "status", scope: "clone", status: { global: "on", cloneLocal: "on", effective: "on", source: "clone_local" } }),
|
|
1628
|
+
targetStatus: async (request: Record<string, unknown>) => ("intendedUntrackedSelection" in request ? target : initial),
|
|
1629
|
+
start: async (request: Record<string, unknown>) => { starts.push(request); return { lineageId: "excluded", state: "reviewing", riskLevel: "low", selectedLenses: [], changedFiles: 1, changedLines: 1, correctionBudget: 1, action: "created", lensesRequired: false, riskReasons: [], raw: {} }; },
|
|
1630
|
+
} as unknown as NativeReviewCli;
|
|
1631
|
+
const listed = await __testing.executeReviewControllerOperation({ operation: "status", workspaceRoot: cwd }, sessionCwd, native, undefined, undefined, undefined, retained);
|
|
1632
|
+
const result = await __testing.executeReviewControllerOperation({ operation: "select-intended-untracked", selectionBinding: listed.selectionBinding as string, intendedUntracked: [], workspaceRoot: cwd } as never, sessionCwd, native, undefined, undefined, undefined, retained);
|
|
1633
|
+
assert.equal(starts.length, 1, JSON.stringify(result));
|
|
1634
|
+
// EXCLUDE, with an empty selection: nothing untracked joins the candidate.
|
|
1635
|
+
assert.deepEqual(starts[0]!.intendedUntrackedSelection, { argumentTokens: selection.submission!.argumentTokens, value: JSON.stringify({ schema: "gentle-ai.review-intended-untracked-selection/v1", untracked_scope: "exclude", expected_untracked_inventory: SHA, intended_untracked: [] }) });
|
|
1636
|
+
assert.equal(result.reason, undefined, JSON.stringify(result));
|
|
1637
|
+
});
|
|
1638
|
+
|
|
1639
|
+
function intendedUntrackedSelection(status: ReviewStatusV3, eligible: readonly string[]): ReviewCollectInputV3 {
|
|
1640
|
+
return {
|
|
1641
|
+
name: "intended_untracked_selection", schema: "gentle-ai.review-intended-untracked-selection/v1", captureOperation: "external.select_intended_untracked",
|
|
1642
|
+
arguments: [
|
|
1643
|
+
{ name: "target_identity", value: SHA }, { name: "projection", value: "workspace" },
|
|
1644
|
+
{ name: "base_tree", value: status.projection.baseTree }, { name: "candidate_tree", value: status.projection.currentCandidateTree },
|
|
1645
|
+
{ name: "eligible_paths_json", value: JSON.stringify([...eligible]) }, { name: "expected_untracked_inventory", value: SHA },
|
|
1646
|
+
],
|
|
1647
|
+
submission: { operationToken: "status", argumentTokens: ["--contract=gentle-ai.review-integration/v2", "--next-transition=true", "--agent=pi", "--projection=workspace", "--intended-untracked-selection={{value}}"], values: [{ slot: "intended_untracked_selection", domain: "schema_bound_json", schema: "gentle-ai.review-intended-untracked-selection/v1", substitutionLocation: 4 }] },
|
|
1648
|
+
} as unknown as ReviewCollectInputV3;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1577
1651
|
test("committed-range inspect stop carries its binding selector into selection STATUS and START, rejecting a mismatched binding", async (t) => {
|
|
1578
1652
|
const { cwd, eligible, selection } = untrackedStopFixture(t);
|
|
1579
1653
|
const baseRef = execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" }).trim();
|
|
@@ -1590,6 +1664,7 @@ test("committed-range inspect stop carries its binding selector into selection S
|
|
|
1590
1664
|
assert.equal(retained.has(`${cwd}\u0000`), true, "plain inspect stop retains its selector");
|
|
1591
1665
|
const mismatch = await __testing.executeReviewControllerOperation({ operation: "select-intended-untracked", selectionBinding: (inspected.selectionBinding as string).replace(eligible, "other.md"), intendedUntracked: [eligible] }, cwd, native, undefined, undefined, undefined, retained);
|
|
1592
1666
|
assert.equal(mismatch.outcome, "intended-untracked-selection-binding-rejected");
|
|
1667
|
+
assert.equal(mismatch.reason, "binding-mismatch");
|
|
1593
1668
|
assert.equal(requests.length, 1, "mismatched binding must not request another STATUS");
|
|
1594
1669
|
assert.equal(starts.length, 0);
|
|
1595
1670
|
const selected = await __testing.executeReviewControllerOperation({ operation: "select-intended-untracked", selectionBinding: inspected.selectionBinding, intendedUntracked: [eligible] }, cwd, native, undefined, undefined, undefined, retained);
|
|
@@ -1620,6 +1695,8 @@ test("committed-range selection rejects target-identity drift before START", asy
|
|
|
1620
1695
|
const rejected = await __testing.executeReviewControllerOperation({ operation: "select-intended-untracked", selectionBinding: inspected.selectionBinding, intendedUntracked: [eligible] }, cwd, native, undefined, undefined, undefined, retained);
|
|
1621
1696
|
assert.equal(rejected.status, "blocked");
|
|
1622
1697
|
assert.equal(rejected.outcome, "intended-untracked-selection-binding-rejected");
|
|
1698
|
+
assert.equal(rejected.reason, "status-field-mismatch");
|
|
1699
|
+
assert.equal(rejected.field, "target_identity");
|
|
1623
1700
|
assert.equal(rejected.mutation_performed, false);
|
|
1624
1701
|
assert.equal(rejected.mutation_outcome, "none");
|
|
1625
1702
|
assert.equal(requests.length, 2);
|
|
@@ -1628,6 +1705,56 @@ test("committed-range selection rejects target-identity drift before START", asy
|
|
|
1628
1705
|
assert.equal(starts, 0);
|
|
1629
1706
|
});
|
|
1630
1707
|
|
|
1708
|
+
// gentle-pi#941: the two remaining refusal reasons had no coverage, so a future
|
|
1709
|
+
// refactor could reorder or drop them without a red test. Name each one.
|
|
1710
|
+
test("a selection answer against a status with no selection input names the absent input", async (t) => {
|
|
1711
|
+
const cwd = repository(t), eligible = "selected.md";
|
|
1712
|
+
writeFileSync(join(cwd, eligible), "selected\n");
|
|
1713
|
+
// v7 schema but no intended-untracked collect: the caller holds a binding
|
|
1714
|
+
// this status cannot answer, so the input itself is absent.
|
|
1715
|
+
const target = { ...startStatus(cwd), raw: { schema: "gentle-ai.review-integration.status/v7" } } as ReviewStatusV3;
|
|
1716
|
+
let starts = 0;
|
|
1717
|
+
const native = {
|
|
1718
|
+
reviewMode: async () => ({ operation: "status", scope: "clone", status: { global: "on", cloneLocal: "on", effective: "on", source: "clone_local" } }),
|
|
1719
|
+
targetStatus: async () => target,
|
|
1720
|
+
start: async () => { starts++; throw new Error("START must not run without a selection input"); },
|
|
1721
|
+
} as unknown as NativeReviewCli;
|
|
1722
|
+
const rejection = await __testing.executeReviewControllerOperation({ operation: "select-intended-untracked", selectionBinding: JSON.stringify({ name: "intended_untracked_selection" }), intendedUntracked: [eligible] } as never, cwd, native);
|
|
1723
|
+
assert.equal(rejection.status, "blocked", JSON.stringify(rejection));
|
|
1724
|
+
assert.equal(rejection.outcome, "intended-untracked-selection-binding-rejected");
|
|
1725
|
+
assert.equal(rejection.reason, "selection-input-absent");
|
|
1726
|
+
assert.equal(rejection.field, undefined);
|
|
1727
|
+
assert.equal(rejection.mutation_performed, false);
|
|
1728
|
+
assert.equal(rejection.mutation_outcome, "none");
|
|
1729
|
+
assert.equal(starts, 0);
|
|
1730
|
+
});
|
|
1731
|
+
|
|
1732
|
+
test("an eligible-paths list that is not a JSON array names the unreadable field", async (t) => {
|
|
1733
|
+
const cwd = repository(t), eligible = "selected.md";
|
|
1734
|
+
writeFileSync(join(cwd, eligible), "selected\n");
|
|
1735
|
+
const initialTarget = startStatus(cwd, undefined, [eligible]);
|
|
1736
|
+
const selection = intendedUntrackedSelection(initialTarget, [eligible]);
|
|
1737
|
+
// Valid JSON, wrong shape: an object where the provider contract promises an
|
|
1738
|
+
// array, so the host cannot read eligibility.
|
|
1739
|
+
for (const argument of selection.arguments) if (argument.name === "eligible_paths_json") argument.value = "{}";
|
|
1740
|
+
const initial = { ...initialTarget, nextTransition: { kind: "collect", reasonCode: "intended_untracked_selection_required", collect: { inputs: [selection] } }, raw: { schema: "gentle-ai.review-integration.status/v7" } } as ReviewStatusV3;
|
|
1741
|
+
const starts: Array<Record<string, unknown>> = [];
|
|
1742
|
+
const native = {
|
|
1743
|
+
reviewMode: async () => ({ operation: "status", scope: "clone", status: { global: "on", cloneLocal: "on", effective: "on", source: "clone_local" } }),
|
|
1744
|
+
targetStatus: async () => initial,
|
|
1745
|
+
start: async (request: Record<string, unknown>) => { starts.push(request); throw new Error("START must not run with an unreadable eligible list"); },
|
|
1746
|
+
} as unknown as NativeReviewCli;
|
|
1747
|
+
const listed = await __testing.executeReviewControllerOperation({ operation: "status", workspaceRoot: cwd }, cwd, native);
|
|
1748
|
+
assert.equal(typeof listed.selectionBinding, "string", JSON.stringify(listed));
|
|
1749
|
+
const rejection = await __testing.executeReviewControllerOperation({ operation: "select-intended-untracked", selectionBinding: listed.selectionBinding, intendedUntracked: [eligible] } as never, cwd, native);
|
|
1750
|
+
assert.equal(rejection.status, "blocked", JSON.stringify(rejection));
|
|
1751
|
+
assert.equal(rejection.outcome, "intended-untracked-selection-binding-rejected");
|
|
1752
|
+
assert.equal(rejection.reason, "eligible-paths-unreadable");
|
|
1753
|
+
assert.equal(rejection.mutation_performed, false);
|
|
1754
|
+
assert.equal(rejection.mutation_outcome, "none");
|
|
1755
|
+
assert.equal(starts.length, 0);
|
|
1756
|
+
});
|
|
1757
|
+
|
|
1631
1758
|
// gentle-pi#706: inspect names the exact continuation for the intended-untracked
|
|
1632
1759
|
// stop and can resolve it in one call through top-level untrackedScope.
|
|
1633
1760
|
function untrackedStopFixture(
|
|
@@ -2962,22 +3089,97 @@ test("INSPECT rejects malformed committed-range selectors before negotiated STAT
|
|
|
2962
3089
|
},
|
|
2963
3090
|
} as unknown as NativeReviewCli;
|
|
2964
3091
|
|
|
2965
|
-
for (const input of [
|
|
2966
|
-
{ baseRef: "HEAD", committedOnly: false },
|
|
2967
|
-
{
|
|
2968
|
-
{
|
|
3092
|
+
for (const { input, reason, field } of [
|
|
3093
|
+
{ input: { baseRef: "HEAD", committedOnly: false }, reason: "committed-only-required" },
|
|
3094
|
+
{ input: { baseRef: "HEAD" }, reason: "committed-only-required" },
|
|
3095
|
+
{ input: { committedOnly: true }, reason: "committed-only-invalid" },
|
|
3096
|
+
{ input: { baseRef: " HEAD", committedOnly: true }, reason: "base-ref-invalid" },
|
|
3097
|
+
{ input: { baseRef: 42, committedOnly: true }, reason: "base-ref-invalid" },
|
|
3098
|
+
{ input: { baseRef: "HEAD", committedOnly: true, mode: "ordinary" }, reason: "unknown-field", field: "mode" },
|
|
2969
3099
|
]) {
|
|
2970
3100
|
const rejected = await __testing.executeReviewControllerOperation(
|
|
2971
3101
|
{ operation: "inspect", input: JSON.stringify(input) },
|
|
2972
3102
|
cwd,
|
|
2973
3103
|
native,
|
|
2974
3104
|
);
|
|
3105
|
+
assert.equal(rejected.status, "blocked");
|
|
3106
|
+
assert.equal(rejected.reason, reason);
|
|
3107
|
+
assert.equal(rejected.field, field);
|
|
2975
3108
|
assert.equal(rejected.outcome, "native-inspect-input-invalid");
|
|
3109
|
+
assert.equal(rejected.mutation_performed, false);
|
|
2976
3110
|
assert.equal(rejected.mutation_outcome, "none");
|
|
3111
|
+
assert.equal(targetCalls, 0);
|
|
2977
3112
|
}
|
|
2978
3113
|
assert.equal(targetCalls, 0);
|
|
2979
3114
|
});
|
|
2980
3115
|
|
|
3116
|
+
test("INSPECT accepts empty object and empty string input for ambient inspection", async (t) => {
|
|
3117
|
+
const cwd = repository(t);
|
|
3118
|
+
let targetCalls = 0;
|
|
3119
|
+
const requests: Array<Record<string, unknown>> = [];
|
|
3120
|
+
const native = {
|
|
3121
|
+
targetStatus: async (request: Record<string, unknown>) => {
|
|
3122
|
+
targetCalls += 1;
|
|
3123
|
+
requests.push(request);
|
|
3124
|
+
return startStatus(cwd);
|
|
3125
|
+
},
|
|
3126
|
+
} as unknown as NativeReviewCli;
|
|
3127
|
+
|
|
3128
|
+
for (const input of ["{}", "", " "]) {
|
|
3129
|
+
const result = await __testing.executeReviewControllerOperation(
|
|
3130
|
+
{ operation: "inspect", input },
|
|
3131
|
+
cwd,
|
|
3132
|
+
native,
|
|
3133
|
+
);
|
|
3134
|
+
assert.equal(result.status, "ready", `expected ready for input ${JSON.stringify(input)}`);
|
|
3135
|
+
}
|
|
3136
|
+
assert.equal(targetCalls, 3);
|
|
3137
|
+
for (const request of requests) {
|
|
3138
|
+
assert.equal(request.baseRef, undefined);
|
|
3139
|
+
assert.equal(request.committedOnly, undefined);
|
|
3140
|
+
}
|
|
3141
|
+
});
|
|
3142
|
+
|
|
3143
|
+
test("INSPECT ambient input with top-level selected-empty stays read-only when selection is not required", async (t) => {
|
|
3144
|
+
const cwd = repository(t);
|
|
3145
|
+
const requests: Array<Record<string, unknown>> = [];
|
|
3146
|
+
let mutationCalls = 0;
|
|
3147
|
+
const mutationMethods = [
|
|
3148
|
+
"start", "answerConsent", "reclaim", "recover", "abandon",
|
|
3149
|
+
"quarantineLegacy", "reconcileAuthority", "repairLegacyAlias", "repair",
|
|
3150
|
+
"captureResult", "captureCorrectionPlan", "captureProviderRole", "captureUnachievableLens",
|
|
3151
|
+
"reviewMode",
|
|
3152
|
+
] as const satisfies readonly (keyof NativeReviewCli)[];
|
|
3153
|
+
const mutationSpies = Object.fromEntries(mutationMethods.map((method) => [method, async () => {
|
|
3154
|
+
mutationCalls += 1;
|
|
3155
|
+
throw new Error(`Unexpected NativeReviewCli.${method} call during ambient INSPECT`);
|
|
3156
|
+
}]));
|
|
3157
|
+
const native = {
|
|
3158
|
+
...mutationSpies,
|
|
3159
|
+
targetStatus: async (request: Record<string, unknown>) => {
|
|
3160
|
+
requests.push(request);
|
|
3161
|
+
return startStatus(cwd);
|
|
3162
|
+
},
|
|
3163
|
+
} as unknown as NativeReviewCli;
|
|
3164
|
+
for (const input of [undefined, "{}", "", " "]) {
|
|
3165
|
+
const parameters = { operation: "inspect", ...(input === undefined ? {} : { input }), untrackedScope: "select", intendedUntracked: [] };
|
|
3166
|
+
const result = await __testing.executeReviewControllerOperation(parameters, cwd, native);
|
|
3167
|
+
assert.equal(result.status, "ready");
|
|
3168
|
+
assert.equal(mutationCalls, 0, `unexpected mutation for input ${JSON.stringify(input)}`);
|
|
3169
|
+
assert.equal(result.untracked_selection, "not-required");
|
|
3170
|
+
assert.deepEqual(parameters.intendedUntracked, []);
|
|
3171
|
+
}
|
|
3172
|
+
assert.equal(requests.length, 4);
|
|
3173
|
+
for (const request of requests) {
|
|
3174
|
+
assert.equal(request.cwd, cwd);
|
|
3175
|
+
assert.equal("baseRef" in request, false);
|
|
3176
|
+
assert.equal("committedOnly" in request, false);
|
|
3177
|
+
// Without a provider selection stop, no selection submission is needed.
|
|
3178
|
+
assert.equal("untrackedScope" in request, false);
|
|
3179
|
+
assert.equal("intendedUntracked" in request, false);
|
|
3180
|
+
}
|
|
3181
|
+
});
|
|
3182
|
+
|
|
2981
3183
|
test("ordinary START keeps default and explicit base selection fail-closed before native mutation", async (t) => {
|
|
2982
3184
|
const cwd = repository(t);
|
|
2983
3185
|
let targetCalls = 0;
|
|
@@ -3274,3 +3476,171 @@ test("collect-state public STATUS, INSPECT, and START serialize each provider co
|
|
|
3274
3476
|
assert.ok(serialized.length < 2 * JSON.stringify(bindings).length, `${parameters.operation} answer (${serialized.length} characters) must not double the ${JSON.stringify(bindings).length}-character binding projection`);
|
|
3275
3477
|
}
|
|
3276
3478
|
});
|
|
3479
|
+
|
|
3480
|
+
test("a correction-plan binding bound to the frozen authority target is captured after the worktree drifts", async () => {
|
|
3481
|
+
// gentle-ai binds correction-plan collect inputs to authority_target_identity
|
|
3482
|
+
// (the frozen candidate), not to the live target_identity, once the
|
|
3483
|
+
// candidate has drifted; the host must accept the target the provider issued.
|
|
3484
|
+
const lineageId = "drifted-correction";
|
|
3485
|
+
const frozenTarget = `sha256:${"c".repeat(64)}`;
|
|
3486
|
+
const input = correctionPlanInput(lineageId);
|
|
3487
|
+
(input.arguments as { name: string; value: string; token?: string }[])[1] = { name: "target", value: frozenTarget, token: `--target=${frozenTarget}` };
|
|
3488
|
+
const drifted = (): ReviewStatusV3 => ({ ...status(lineageId, [input], "correction_required"), authorityTargetIdentity: frozenTarget });
|
|
3489
|
+
let captures = 0;
|
|
3490
|
+
const native = {
|
|
3491
|
+
targetStatus: async () => drifted(),
|
|
3492
|
+
captureCorrectionPlan: async () => {
|
|
3493
|
+
captures += 1;
|
|
3494
|
+
// The provider echoes the frozen target it was invoked with.
|
|
3495
|
+
return { schema: "gentle-ai.review-last-event-closure/v1", operation: "review.capture-correction-plan", lineageId, targetIdentity: frozenTarget, state: "correction_required", storeRevision: SHA };
|
|
3496
|
+
},
|
|
3497
|
+
} as unknown as NativeReviewCli;
|
|
3498
|
+
const { controller, capture } = reviewRuntime(native, new CandidateViewRegistry());
|
|
3499
|
+
const context = reviewContext(process.cwd());
|
|
3500
|
+
const listed = await controller.execute("", { operation: "status", lineageId }, undefined, undefined, context);
|
|
3501
|
+
const captured = await capture.execute("", { lineageId, collectBinding: bindingOf(listed.details as Record<string, unknown>), correctionLines: 1 }, undefined, undefined, context);
|
|
3502
|
+
assert.equal((captured.details as { outcome?: string }).outcome, "native-last-event-closure");
|
|
3503
|
+
assert.equal((captured.details as { mutation_outcome?: string }).mutation_outcome === "none", false);
|
|
3504
|
+
assert.equal(captures, 1);
|
|
3505
|
+
|
|
3506
|
+
// A target that is neither the frozen authority target nor the live one stays refused.
|
|
3507
|
+
const foreign = correctionPlanInput(lineageId);
|
|
3508
|
+
(foreign.arguments as { name: string; value: string; token?: string }[])[1] = { name: "target", value: `sha256:${"d".repeat(64)}`, token: `--target=sha256:${"d".repeat(64)}` };
|
|
3509
|
+
const foreignNative = {
|
|
3510
|
+
targetStatus: async () => ({ ...status(lineageId, [foreign], "correction_required"), authorityTargetIdentity: frozenTarget }),
|
|
3511
|
+
captureCorrectionPlan: async () => { throw new Error("must not capture"); },
|
|
3512
|
+
} as unknown as NativeReviewCli;
|
|
3513
|
+
const runtime = reviewRuntime(foreignNative, new CandidateViewRegistry());
|
|
3514
|
+
const foreignListed = await runtime.controller.execute("", { operation: "status", lineageId }, undefined, undefined, context);
|
|
3515
|
+
const refused = await runtime.capture.execute("", { lineageId, collectBinding: bindingOf(foreignListed.details as Record<string, unknown>), correctionLines: 1 }, undefined, undefined, context);
|
|
3516
|
+
assert.equal((refused.details as { outcome?: string }).outcome, "capture-binding-rejected");
|
|
3517
|
+
});
|
|
3518
|
+
|
|
3519
|
+
test("request context survives unrelated untracked selection and its START continuation", async (t) => {
|
|
3520
|
+
const { cwd, eligible, initial, target } = untrackedStopFixture(t);
|
|
3521
|
+
const retained = new Map(); const starts: Array<Record<string, unknown>> = [];
|
|
3522
|
+
const context = join(cwd, "spec.md"); writeFileSync(context, "Requested behavior");
|
|
3523
|
+
const native = { targetStatus: async (request: Record<string, unknown>) => "intendedUntrackedSelection" in request ? target : initial,
|
|
3524
|
+
start: async (request: Record<string, unknown>) => { starts.push(request); return { lineageId: "context-selected", state: "reviewing", riskLevel: "low", selectedLenses: [], changedFiles: 1, changedLines: 1, correctionBudget: 1, action: "created", lensesRequired: false, riskReasons: [], raw: {} }; }
|
|
3525
|
+
} as unknown as NativeReviewCli;
|
|
3526
|
+
const run = (parameters: Record<string, unknown>) => __testing.executeReviewControllerOperation(parameters, cwd, native, undefined, undefined, undefined, retained);
|
|
3527
|
+
const stopped = await run({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath: "spec.md" }) });
|
|
3528
|
+
assert.equal(typeof stopped.selectionBinding, "string", JSON.stringify(stopped));
|
|
3529
|
+
const selected = await run({ operation: "select-intended-untracked", selectionBinding: stopped.selectionBinding, intendedUntracked: [eligible] });
|
|
3530
|
+
assert.equal(starts.length, 1, JSON.stringify(selected));
|
|
3531
|
+
assert.equal(starts[0].requestContextPath, context);
|
|
3532
|
+
});
|
|
3533
|
+
|
|
3534
|
+
test("START options survive intended-untracked continuation with and without request context", async t => {
|
|
3535
|
+
for (const withContext of [false, true]) for (const selection of ["lenses", "focus"]) for (const includeFile of [false, true]) await t.test(`${selection}, context=${withContext}, include=${includeFile}`, async t => {
|
|
3536
|
+
const { cwd, eligible, initial, target } = untrackedStopFixture(t);
|
|
3537
|
+
const retained = new Map(), starts: Array<Record<string, unknown>> = [];
|
|
3538
|
+
mkdirSync(join(cwd, ".gentle-ai", "policies"), { recursive: true });
|
|
3539
|
+
const policyPath = join(cwd, ".gentle-ai", "policies", "review.json"); writeFileSync(policyPath, "{}\n");
|
|
3540
|
+
if (withContext) writeFileSync(join(cwd, "spec.md"), "Requested behavior");
|
|
3541
|
+
const native = { targetStatus: async (request: Record<string, unknown>) => "intendedUntrackedSelection" in request ? target : initial,
|
|
3542
|
+
start: async (request: Record<string, unknown>) => { starts.push(request); return { lineageId: "options-selected", state: "reviewing", riskLevel: "low", selectedLenses: [], changedFiles: 1, changedLines: 1, correctionBudget: 1, action: "created", lensesRequired: false, riskReasons: [], raw: {} }; }
|
|
3543
|
+
} as unknown as NativeReviewCli;
|
|
3544
|
+
const run = (parameters: Record<string, unknown>) => __testing.executeReviewControllerOperation(parameters, cwd, native, undefined, undefined, undefined, retained);
|
|
3545
|
+
const requested = selection === "lenses" ? { lenses: ["risk"], lensesReason: "permission checks" } : { focus: "reliability" };
|
|
3546
|
+
const stopped = await run({ operation: "start", input: JSON.stringify({ mode: "ordinary", ...requested, policyPath: ".gentle-ai/policies/review.json", ...(withContext ? { requestContextPath: "spec.md" } : {}) }) });
|
|
3547
|
+
assert.equal(typeof stopped.selectionBinding, "string", JSON.stringify(stopped));
|
|
3548
|
+
const resumed = await run({ operation: "select-intended-untracked", selectionBinding: stopped.selectionBinding, intendedUntracked: includeFile ? [eligible] : [] });
|
|
3549
|
+
assert.equal(starts.length, 1, JSON.stringify(resumed));
|
|
3550
|
+
assert.equal(starts[0].policyPath, policyPath);
|
|
3551
|
+
assert.equal(starts[0].untrackedScope, includeFile ? "select" : "exclude");
|
|
3552
|
+
assert.deepEqual(starts[0].intendedUntracked, includeFile ? [eligible] : []);
|
|
3553
|
+
assert.equal(starts[0].requestContextPath, withContext ? join(cwd, "spec.md") : undefined);
|
|
3554
|
+
if (selection === "lenses") { assert.deepEqual(starts[0].lenses, ["review-risk"]); assert.equal(starts[0].lensesReason, "permission checks"); }
|
|
3555
|
+
else assert.equal(starts[0].focus, "reliability");
|
|
3556
|
+
});
|
|
3557
|
+
});
|
|
3558
|
+
|
|
3559
|
+
test("retained START options reject a changed target before resuming", async t => {
|
|
3560
|
+
const { cwd, eligible, initial } = untrackedStopFixture(t);
|
|
3561
|
+
let changed = false, starts = 0;
|
|
3562
|
+
const native = { targetStatus: async () => changed ? { ...initial, targetIdentity: `sha256:${"f".repeat(64)}` } : initial,
|
|
3563
|
+
start: async () => { starts++; throw new Error("changed target must not start"); } } as unknown as NativeReviewCli;
|
|
3564
|
+
const retained = new Map();
|
|
3565
|
+
const run = (parameters: Record<string, unknown>) => __testing.executeReviewControllerOperation(parameters, cwd, native, undefined, undefined, undefined, retained);
|
|
3566
|
+
const stopped = await run({ operation: "start", input: JSON.stringify({ mode: "ordinary", lenses: ["risk"], lensesReason: "permission checks" }) });
|
|
3567
|
+
changed = true;
|
|
3568
|
+
const result = await run({ operation: "select-intended-untracked", selectionBinding: stopped.selectionBinding, intendedUntracked: [eligible] });
|
|
3569
|
+
assert.equal(result.outcome, "intended-untracked-selection-binding-rejected"); assert.equal(result.field, "target_identity"); assert.equal(starts, 0);
|
|
3570
|
+
});
|
|
3571
|
+
|
|
3572
|
+
test("capture routes retain a verified selector when identical offers alternate explicit and omitted selectors", async t => {
|
|
3573
|
+
for (const { explicitFirst, frozenDrift } of [{ explicitFirst: true, frozenDrift: false }, { explicitFirst: false, frozenDrift: false }, { explicitFirst: true, frozenDrift: true }]) await t.test(`explicitFirst=${explicitFirst}, frozenDrift=${frozenDrift}`, async t => {
|
|
3574
|
+
const cwd = repository(t), lineageId = "same-offer", routes = new Map(), requests: Array<Record<string, unknown>> = [];
|
|
3575
|
+
const baseRef = execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" }).trim();
|
|
3576
|
+
const input = correctionPlanInput(lineageId);
|
|
3577
|
+
const native = { targetStatus: async (request: Record<string, unknown>) => { requests.push(request); return { ...status(lineageId, [input], "correction_required"), ...(frozenDrift ? { authorityTargetIdentity: SHA, targetIdentity: requests.length > 1 ? `sha256:${"f".repeat(64)}` : SHA } : {}) }; },
|
|
3578
|
+
captureCorrectionPlan: async () => ({ schema: "gentle-ai.review-last-event-closure/v1", operation: "review.capture-correction-plan", lineageId, state: "correction_required", storeRevision: SHA }) } as unknown as NativeReviewCli;
|
|
3579
|
+
let observed: Record<string, unknown> = {};
|
|
3580
|
+
for (const explicit of [explicitFirst, !explicitFirst]) {
|
|
3581
|
+
observed = await __testing.executeReviewControllerOperation({ operation: "status", lineageId, ...(explicit ? { input: JSON.stringify({ baseRef, committedOnly: true }) } : {}) }, cwd, native, undefined, undefined, undefined, routes);
|
|
3582
|
+
assert.notEqual(observed.outcome, "capture-route-registration-rejected", JSON.stringify(observed));
|
|
3583
|
+
}
|
|
3584
|
+
const captured = await __testing.executeReviewCaptureOperation({ lineageId, collectBinding: bindingOf(observed), correctionLines: 1 }, cwd, native, undefined, undefined, routes, true);
|
|
3585
|
+
assert.equal(captured.outcome, "native-last-event-closure", JSON.stringify(captured));
|
|
3586
|
+
assert.equal(requests.at(-1)?.baseRef, baseRef); assert.equal(requests.at(-1)?.committedOnly, true);
|
|
3587
|
+
});
|
|
3588
|
+
});
|
|
3589
|
+
|
|
3590
|
+
test("capture route registration reports safe reasons for target and selector conflicts", async () => {
|
|
3591
|
+
for (const conflict of ["selector", "target", "unverifiable"]) {
|
|
3592
|
+
const lineageId = "conflicting-offer", input = correctionPlanInput(lineageId), routes = new Map();
|
|
3593
|
+
let calls = 0;
|
|
3594
|
+
const native = { targetStatus: async () => { calls++; return { ...status(lineageId, [input]), targetIdentity: conflict === "unverifiable" ? "not-a-target-hash" : conflict === "target" && calls > 1 ? `sha256:${"f".repeat(64)}` : SHA }; } } as unknown as NativeReviewCli;
|
|
3595
|
+
await __testing.executeReviewControllerOperation({ operation: "status", lineageId, input: JSON.stringify({ baseRef: "base-a", committedOnly: true }) }, process.cwd(), native, undefined, undefined, undefined, routes);
|
|
3596
|
+
const rejected = await __testing.executeReviewControllerOperation({ operation: "status", lineageId, ...(conflict === "selector" ? { input: JSON.stringify({ baseRef: "base-b", committedOnly: true }) } : {}) }, process.cwd(), native, undefined, undefined, undefined, routes);
|
|
3597
|
+
assert.equal(rejected.outcome, "capture-route-registration-rejected");
|
|
3598
|
+
assert.equal(rejected.reason, `${conflict === "unverifiable" ? "target-unverifiable" : conflict + "-mismatch"}`);
|
|
3599
|
+
}
|
|
3600
|
+
});
|
|
3601
|
+
|
|
3602
|
+
test("request context preserves unrelated non-start native stops", async (t) => {
|
|
3603
|
+
const cwd = repository(t); writeFileSync(join(cwd, "spec.md"), "Requested behavior"); const target = startStatus(cwd);
|
|
3604
|
+
target.action = "stop"; target.nextTransition = { kind: "stop", reasonCode: "managed_assets_outdated" };
|
|
3605
|
+
const native = { targetStatus: async () => target } as unknown as NativeReviewCli;
|
|
3606
|
+
const result = await __testing.executeReviewControllerOperation({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath: "spec.md" }) }, cwd, native);
|
|
3607
|
+
assert.notEqual(result.reason, "request-context-requires-fresh-review");
|
|
3608
|
+
assert.equal(result.result, target.raw);
|
|
3609
|
+
});
|
|
3610
|
+
|
|
3611
|
+
test("request context remains host-bound through the consent registry", async (t) => {
|
|
3612
|
+
const cwd = repository(t), registry = new PendingReviewConsentRegistry(), session = Symbol("intent-consent");
|
|
3613
|
+
writeFileSync(join(cwd, "spec.md"), "Requested behavior");
|
|
3614
|
+
const consent = decodeReviewConsentV3(JSON.parse(readFileSync(join(process.cwd(), "tests/fixtures/devbinary/consent-v3.captured.json"), "utf8")));
|
|
3615
|
+
const answers: Array<Record<string, unknown>> = [];
|
|
3616
|
+
const native = { targetStatus: async () => startStatus(cwd), start: async () => { throw new NativeReviewConsentRequiredError(consent, join(cwd, "spec.md")); },
|
|
3617
|
+
answerConsent: async (request: Record<string, unknown>) => { answers.push(request); return { kind: "declined", targetIdentity: consent.targetIdentity, projection: consent.projection, riskLevel: consent.riskLevel, changedFiles: 1, changedLines: 1, consent: "declined_this_candidate", raw: {} }; }
|
|
3618
|
+
} as unknown as NativeReviewCli;
|
|
3619
|
+
const run = (parameters: Record<string, unknown>) => __testing.executeReviewControllerOperation(parameters, cwd, native, undefined, undefined, undefined, new Map(), registry, session);
|
|
3620
|
+
const pending = await run({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath: "spec.md" }) });
|
|
3621
|
+
assert.equal(pending.outcome, "native-review-consent-required");
|
|
3622
|
+
await run({ operation: "answer-consent", input: JSON.stringify({ consentBinding: pending.consent_binding, answer: "declined" }) });
|
|
3623
|
+
assert.equal(answers.length, 1);
|
|
3624
|
+
assert.equal(answers[0].requestContextPath, join(cwd, "spec.md"));
|
|
3625
|
+
});
|
|
3626
|
+
|
|
3627
|
+
test("request context rechecks sensitive aliases before selection and consent continuations", async (t) => {
|
|
3628
|
+
for (const phase of ["selection", "consent"]) {
|
|
3629
|
+
const { cwd, eligible, initial } = untrackedStopFixture(t);
|
|
3630
|
+
fs.mkdirSync(join(cwd, "docs")); writeFileSync(join(cwd, "docs", "request.md"), "allowed fixture");
|
|
3631
|
+
const retained = new Map(), registry = new PendingReviewConsentRegistry(), session = Symbol(phase);
|
|
3632
|
+
const consent = decodeReviewConsentV3(JSON.parse(readFileSync(join(process.cwd(), "tests/fixtures/devbinary/consent-v3.captured.json"), "utf8")));
|
|
3633
|
+
let queries = 0, answers = 0;
|
|
3634
|
+
const native = { targetStatus: async () => { queries++; return phase === "selection" ? initial : startStatus(cwd); },
|
|
3635
|
+
start: async () => { throw new NativeReviewConsentRequiredError(consent, join(cwd, "docs", "request.md")); },
|
|
3636
|
+
answerConsent: async () => { answers++; throw new Error("sensitive alias must not be forwarded"); }
|
|
3637
|
+
} as unknown as NativeReviewCli;
|
|
3638
|
+
const run = (parameters: Record<string, unknown>) => __testing.executeReviewControllerOperation(parameters, cwd, native, undefined, undefined, undefined, retained, registry, session);
|
|
3639
|
+
const stopped = await run({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath: "docs/request.md" }) });
|
|
3640
|
+
fs.renameSync(join(cwd, "docs"), join(cwd, "prior-docs")); fs.mkdirSync(join(cwd, "secrets")); writeFileSync(join(cwd, "secrets", "request.md"), "private fixture");
|
|
3641
|
+
fs.symlinkSync(join(cwd, "secrets"), join(cwd, "docs"), process.platform === "win32" ? "junction" : "dir");
|
|
3642
|
+
const before = queries;
|
|
3643
|
+
const result = await run(phase === "selection" ? { operation: "select-intended-untracked", selectionBinding: stopped.selectionBinding, intendedUntracked: [eligible] } : { operation: "answer-consent", input: JSON.stringify({ consentBinding: stopped.consent_binding, answer: "granted" }) });
|
|
3644
|
+
assert.equal(result.reason, "request-context-sensitive-path", phase); assert.equal(queries, before); assert.equal(answers, 0);
|
|
3645
|
+
}
|
|
3646
|
+
});
|