gentle-pi 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +6 -6
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +746 -15
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +24 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +4 -4
- package/assets/orchestrator-full-delegation-card.md +4 -5
- package/assets/orchestrator-full-delegation.md +8 -8
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +18 -22
- package/bin/gentle-shell.mjs +128 -9
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +18 -2
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell.md +39 -16
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +76 -24
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +11 -1
- package/extensions/ask-user-question.ts +2 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +234 -33
- package/extensions/gentle-ai.ts +576 -135
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +105 -52
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/skill-registry.ts +248 -223
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +91 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +79 -4
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +2 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/native-review-cli.mjs +79 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +4 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +40 -19
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +10 -2
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-question.test.ts +2 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/bounded-stop-contract.test.ts +9 -1
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -878
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +20 -29
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/full-delegation-closure.test.ts +29 -0
- package/tests/gentle-agents.test.ts +329 -4
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +121 -6
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +118 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +19 -5
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +11 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +11 -3
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +30 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +11 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +11 -10
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller.test.ts +2 -1
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator.test.ts +271 -4
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +929 -306
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +42 -11
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +87 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +54 -11
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +184 -0
- package/tests/yolo-mode.test.ts +39 -0
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -1009,13 +1009,23 @@ function materializeCandidateView(request: CreateCandidateViewRequest, executor:
|
|
|
1009
1009
|
if (unborn) git(contributorRoot, ["read-tree", "--empty"], environment, executor);
|
|
1010
1010
|
else git(contributorRoot, ["read-tree", candidateCommit.commit], environment, executor);
|
|
1011
1011
|
}
|
|
1012
|
+
if (committedOnly && intendedUntracked !== undefined && intendedUntracked.length > 0) {
|
|
1013
|
+
// An explicit selection may extend HEAD, never replace its tracked
|
|
1014
|
+
// content or expand a directory/pathspec into unrelated dirty inputs.
|
|
1015
|
+
const literalEnvironment = { ...process.env, GIT_LITERAL_PATHSPECS: "1" };
|
|
1016
|
+
const available = new Set((candidateGit(contributorRoot, ["ls-files", "--others", "--exclude-standard", "-z", "--", ...intendedUntracked], literalEnvironment, "utf8", executor) as string).split("\0"));
|
|
1017
|
+
const headEntries = candidateGit(contributorRoot, ["ls-tree", "-r", "--name-only", "-z", candidateCommit.commit, "--", ...intendedUntracked], literalEnvironment, "utf8", executor) as string;
|
|
1018
|
+
if (intendedUntracked.some(path => !available.has(path)) || headEntries.length > 0) {
|
|
1019
|
+
throw new CandidateViewError("committed candidate selection must name exact untracked files outside HEAD", "candidate-untracked-selection-invalid");
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1012
1022
|
if (!committedOnly) {
|
|
1013
1023
|
if (intendedUntracked === undefined) git(contributorRoot, ["add", "-A"], environment, executor);
|
|
1014
1024
|
else {
|
|
1015
1025
|
git(contributorRoot, ["add", "-u"], environment, executor);
|
|
1016
|
-
if (intendedUntracked.length > 0) git(contributorRoot, ["add", "--", ...intendedUntracked], { ...environment, GIT_LITERAL_PATHSPECS: "1" }, executor);
|
|
1017
1026
|
}
|
|
1018
1027
|
}
|
|
1028
|
+
if (intendedUntracked !== undefined && intendedUntracked.length > 0) git(contributorRoot, ["add", "--", ...intendedUntracked], { ...environment, GIT_LITERAL_PATHSPECS: "1" }, executor);
|
|
1019
1029
|
const candidateTree = git(contributorRoot, ["write-tree"], environment, executor);
|
|
1020
1030
|
const root = join(parent, randomUUID());
|
|
1021
1031
|
let owner: CandidateViewOwner;
|
|
@@ -33,6 +33,7 @@ export interface RetainedNativeUntrackedStopSelector {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export type RetainedReviewContinuation =
|
|
36
|
+
| { readonly kind: "committed-range"; readonly baseRef: string; readonly mutation?: string }
|
|
36
37
|
| (RetainedNativeUntrackedSelection & { readonly kind: "selection" })
|
|
37
38
|
| (RetainedPreLineageNativeUntrackedSelection & { readonly kind: "pre-start" })
|
|
38
39
|
| (RetainedNativeCaptureRoute & { readonly kind: "capture" })
|
|
@@ -58,6 +59,22 @@ export class ReviewContinuationRegistry {
|
|
|
58
59
|
return value instanceof ReviewContinuationRegistry ? value : new ReviewContinuationRegistry(value);
|
|
59
60
|
}
|
|
60
61
|
get size(): number { return this.entries.size; }
|
|
62
|
+
readCommittedRange(root: string): string | undefined {
|
|
63
|
+
const entry = this.entries.get(`committed-range\u0000${root}`);
|
|
64
|
+
return entry?.kind === "committed-range" ? entry.baseRef : undefined;
|
|
65
|
+
}
|
|
66
|
+
/** A reminder may reuse a selector only for the generation explicitly assessed. */
|
|
67
|
+
readReminderRange(root: string, mutation: string): string | undefined {
|
|
68
|
+
const entry = this.entries.get(`committed-range\u0000${root}`);
|
|
69
|
+
return entry?.kind === "committed-range" && entry.mutation === mutation ? entry.baseRef : undefined;
|
|
70
|
+
}
|
|
71
|
+
retainCommittedRange(root: string, baseRef: string, mutation?: string): void {
|
|
72
|
+
this.retain(`committed-range\u0000${root}`, { kind: "committed-range", baseRef, ...(mutation === undefined ? {} : { mutation }) });
|
|
73
|
+
}
|
|
74
|
+
clearReminderRange(root: string): void {
|
|
75
|
+
const baseRef = this.readCommittedRange(root);
|
|
76
|
+
if (baseRef !== undefined) this.retainCommittedRange(root, baseRef);
|
|
77
|
+
}
|
|
61
78
|
/** Bound retained hints by evicting the oldest key before a new insertion. */
|
|
62
79
|
private retain(key: string, entry: RetainedReviewContinuation): void {
|
|
63
80
|
if (!this.entries.has(key)) while (this.entries.size >= MAX_RETAINED_CONTINUATIONS) this.entries.delete(this.entries.keys().next().value!);
|
|
@@ -1,9 +1,135 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Host orchestration of one ordinary native review. All authority stays in the existing facade. */
|
|
2
2
|
export type ReviewCoordinatorTool = "gentle_review" | "gentle_review_capture" | "gentle_review_capture_group";
|
|
3
3
|
type Body = Record<string, unknown>;
|
|
4
4
|
const record = (value: unknown): Body => value !== null && typeof value === "object" && !Array.isArray(value) ? value as Body : {};
|
|
5
5
|
const nonempty = (value: unknown): value is string => typeof value === "string" && value.trim().length > 0;
|
|
6
6
|
|
|
7
|
+
// odd/tasks/review-one-call.md S5: what each finding says, in the reviewer's
|
|
8
|
+
// own words. Each id is looked up in `findings` by exact id and its claim is
|
|
9
|
+
// copied unchanged, cut at the last whole character within
|
|
10
|
+
// REVIEW_FINDING_CLAIM_MAX_BYTES. Claims are added in `ids` order until the
|
|
11
|
+
// next one would pass REVIEW_FINDING_CLAIMS_MAX_BYTES in total; the rest get no
|
|
12
|
+
// entry. An id with no matching finding, or with more than one, is omitted.
|
|
13
|
+
// Beside them, `truncated` lists the ids whose kept claim is a cut prefix and
|
|
14
|
+
// `omitted` the ids whose one matching claim the total limit left out, so
|
|
15
|
+
// neither passes for a whole claim. Reviewer text is untrusted: nothing routes
|
|
16
|
+
// on it. Shared by the facade's approved closure (advisory findings) and the
|
|
17
|
+
// run's correction request (correction findings).
|
|
18
|
+
export const REVIEW_FINDING_CLAIM_MAX_BYTES = 1024;
|
|
19
|
+
export const REVIEW_FINDING_CLAIMS_MAX_BYTES = 8192;
|
|
20
|
+
|
|
21
|
+
function withinUtf8Bytes(text: string, maximum: number): string {
|
|
22
|
+
if (Buffer.byteLength(text) <= maximum) return text;
|
|
23
|
+
let kept = "", bytes = 0;
|
|
24
|
+
for (const character of text) {
|
|
25
|
+
bytes += Buffer.byteLength(character);
|
|
26
|
+
if (bytes > maximum) break;
|
|
27
|
+
kept += character;
|
|
28
|
+
}
|
|
29
|
+
return kept;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function boundedFindingClaims(ids: readonly string[], findings: readonly { id: string; claim: string }[]): { claims: Record<string, string>; truncated: string[]; omitted: string[] } | undefined {
|
|
33
|
+
const entries: [string, string][] = [];
|
|
34
|
+
const truncated: string[] = [], omitted: string[] = [];
|
|
35
|
+
let total = 0;
|
|
36
|
+
for (const id of ids) {
|
|
37
|
+
const matches = findings.filter((finding) => finding.id === id);
|
|
38
|
+
if (matches.length !== 1) continue;
|
|
39
|
+
const claim = withinUtf8Bytes(matches[0]!.claim, REVIEW_FINDING_CLAIM_MAX_BYTES);
|
|
40
|
+
if (omitted.length > 0 || total + Buffer.byteLength(claim) > REVIEW_FINDING_CLAIMS_MAX_BYTES) { omitted.push(id); continue; }
|
|
41
|
+
total += Buffer.byteLength(claim);
|
|
42
|
+
entries.push([id, claim]);
|
|
43
|
+
if (claim !== matches[0]!.claim) truncated.push(id);
|
|
44
|
+
}
|
|
45
|
+
// fromEntries defines own data properties, so no id can reach a prototype.
|
|
46
|
+
return entries.length === 0 ? undefined : { claims: Object.fromEntries(entries), truncated, omitted };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// The provider fields of a correction-request finding relayed in
|
|
50
|
+
// correction_findings, unchanged. The claim travels bounded in
|
|
51
|
+
// correction_finding_claims; evidence and proof references stay in the relayed
|
|
52
|
+
// STATUS envelope.
|
|
53
|
+
const CORRECTION_FINDING_REQUIRED = ["id", "lens", "location", "severity"] as const;
|
|
54
|
+
const CORRECTION_FINDING_OPTIONAL = ["evidence_class", "causal_disposition"] as const;
|
|
55
|
+
|
|
56
|
+
/** Relay keys for a correction request's findings, or none when any entry is malformed. Never routed on. */
|
|
57
|
+
function correctionFindingKeys(request: unknown): Body {
|
|
58
|
+
const findings = record(request).findings;
|
|
59
|
+
if (!Array.isArray(findings) || findings.length === 0) return {};
|
|
60
|
+
const plain = (value: unknown): value is Body => value !== null && typeof value === "object" && !Array.isArray(value) && [Object.prototype, null].includes(Object.getPrototypeOf(value));
|
|
61
|
+
if (!findings.every((finding) => plain(finding) && [...CORRECTION_FINDING_REQUIRED, "claim"].every((key) => Object.hasOwn(finding, key) && nonempty(finding[key]))
|
|
62
|
+
&& CORRECTION_FINDING_OPTIONAL.every((key) => !Object.hasOwn(finding, key) || typeof finding[key] === "string"))) return {};
|
|
63
|
+
const entries = findings as Body[];
|
|
64
|
+
const listed = entries.map((finding) => Object.fromEntries([...CORRECTION_FINDING_REQUIRED, ...CORRECTION_FINDING_OPTIONAL]
|
|
65
|
+
.filter((key) => Object.hasOwn(finding, key)).map((key) => [key, finding[key]])));
|
|
66
|
+
const bounded = boundedFindingClaims(entries.map((finding) => finding.id as string), entries as { id: string; claim: string }[]);
|
|
67
|
+
return { correction_findings: listed,
|
|
68
|
+
...(bounded === undefined ? {} : { correction_finding_claims: bounded.claims,
|
|
69
|
+
...(bounded.truncated.length === 0 ? {} : { correction_finding_claims_truncated: bounded.truncated }),
|
|
70
|
+
...(bounded.omitted.length === 0 ? {} : { correction_finding_claims_omitted: bounded.omitted }) }) };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The provider fields of a non-blocking finding relayed in
|
|
74
|
+
// non_blocking_findings, unchanged; the claim travels bounded in
|
|
75
|
+
// non_blocking_finding_claims.
|
|
76
|
+
const NON_BLOCKING_FINDING_REQUIRED = ["id", "severity", "disposition"] as const;
|
|
77
|
+
const NON_BLOCKING_FINDING_OPTIONAL = ["lens", "location"] as const;
|
|
78
|
+
const NON_BLOCKING_FINDING_FIELDS = ["id", "lens", "location", "severity", "disposition"] as const;
|
|
79
|
+
export const NON_BLOCKING_FINDINGS_MAX_BYTES = 16 * 1024;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The run's nested provider record without the raw `non_blocking_findings`
|
|
83
|
+
* (L19): the bounded top-level keys are the only copy. Nothing else changes.
|
|
84
|
+
*/
|
|
85
|
+
function withoutRawNonBlockingFindings(result: Body): Body {
|
|
86
|
+
const nested = result.result;
|
|
87
|
+
if (nested === null || typeof nested !== "object" || Array.isArray(nested) || !Object.hasOwn(nested, "non_blocking_findings")) return result;
|
|
88
|
+
const { non_blocking_findings: _raw, ...rest } = nested as Body;
|
|
89
|
+
return { ...result, result: rest };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Relay keys for STATUS `non_blocking_findings` (gentle-ai#6088), or none when
|
|
94
|
+
* the provider sent no such key or any part of it is malformed. An empty
|
|
95
|
+
* provider list is the provider's answer ("none") and is relayed as such.
|
|
96
|
+
* Never routed on.
|
|
97
|
+
*/
|
|
98
|
+
function nonBlockingFindingKeys(status: unknown): Body {
|
|
99
|
+
const native = record(status);
|
|
100
|
+
if (!Object.hasOwn(native, "non_blocking_findings")) return {};
|
|
101
|
+
const value = native.non_blocking_findings;
|
|
102
|
+
const plain = (entry: unknown): entry is Body => entry !== null && typeof entry === "object" && !Array.isArray(entry) && [Object.prototype, null].includes(Object.getPrototypeOf(entry));
|
|
103
|
+
if (!plain(value) || !nonempty(value.statement) || !Array.isArray(value.findings)) return {};
|
|
104
|
+
const findings = value.findings as unknown[];
|
|
105
|
+
if (!findings.every((finding) => plain(finding) && NON_BLOCKING_FINDING_REQUIRED.every((key) => Object.hasOwn(finding, key) && nonempty(finding[key]))
|
|
106
|
+
&& Object.hasOwn(finding, "claim") && typeof finding.claim === "string"
|
|
107
|
+
&& NON_BLOCKING_FINDING_OPTIONAL.every((key) => !Object.hasOwn(finding, key) || nonempty(finding[key])))) return {};
|
|
108
|
+
// The list is bounded too (L19): findings are listed in provider order until
|
|
109
|
+
// the next one would bring the list past NON_BLOCKING_FINDINGS_MAX_BYTES of
|
|
110
|
+
// JSON; the rest are only counted. Claims are bounded over the listed ones.
|
|
111
|
+
const listed: Body[] = [];
|
|
112
|
+
let listBytes = 2;
|
|
113
|
+
for (const finding of findings as Body[]) {
|
|
114
|
+
const entry = Object.fromEntries(NON_BLOCKING_FINDING_FIELDS.filter((key) => Object.hasOwn(finding, key)).map((key) => [key, finding[key]]));
|
|
115
|
+
const entryBytes = Buffer.byteLength(JSON.stringify(entry)) + (listed.length === 0 ? 0 : 1);
|
|
116
|
+
if (listBytes + entryBytes > NON_BLOCKING_FINDINGS_MAX_BYTES) break;
|
|
117
|
+
listBytes += entryBytes;
|
|
118
|
+
listed.push(entry);
|
|
119
|
+
}
|
|
120
|
+
const omittedCount = findings.length - listed.length;
|
|
121
|
+
const entries = (findings as Body[]).slice(0, listed.length);
|
|
122
|
+
const bounded = boundedFindingClaims(entries.map((finding) => finding.id as string), entries as { id: string; claim: string }[]);
|
|
123
|
+
// Statement text shares the per-claim UTF-8 cap; the host marks a cut prefix explicitly.
|
|
124
|
+
const statement = withinUtf8Bytes(value.statement, REVIEW_FINDING_CLAIM_MAX_BYTES);
|
|
125
|
+
return { non_blocking_findings: { statement, findings: listed,
|
|
126
|
+
...(statement === value.statement ? {} : { statement_truncated: true }) },
|
|
127
|
+
...(omittedCount === 0 ? {} : { non_blocking_findings_omitted_count: omittedCount }),
|
|
128
|
+
...(bounded === undefined ? {} : { non_blocking_finding_claims: bounded.claims,
|
|
129
|
+
...(bounded.truncated.length === 0 ? {} : { non_blocking_finding_claims_truncated: bounded.truncated }),
|
|
130
|
+
...(bounded.omitted.length === 0 ? {} : { non_blocking_finding_claims_omitted: bounded.omitted }) }) };
|
|
131
|
+
}
|
|
132
|
+
|
|
7
133
|
export interface ReviewCoordinatorInput {
|
|
8
134
|
workspaceRoot?: string;
|
|
9
135
|
baseRef?: string;
|
|
@@ -18,7 +144,11 @@ export interface ReviewCoordinatorInput {
|
|
|
18
144
|
|
|
19
145
|
export interface ReviewCoordinatorDeps {
|
|
20
146
|
invoke(tool: ReviewCoordinatorTool, parameters: Body): Promise<Body>;
|
|
21
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* True to continue past an informational reviewer-run forecast: after the
|
|
149
|
+
* host displayed all of it, or when the host has no display and the forecast
|
|
150
|
+
* is only recorded in the result. Absent or false stops with "forecast".
|
|
151
|
+
*/
|
|
22
152
|
presentForecast?(details: Body): Promise<boolean>;
|
|
23
153
|
signal?: AbortSignal;
|
|
24
154
|
now?: () => number;
|
|
@@ -58,6 +188,27 @@ export async function runReviewCoordinator(value: unknown, deps: ReviewCoordinat
|
|
|
58
188
|
let target: string | undefined;
|
|
59
189
|
let started = false;
|
|
60
190
|
const captured = new Set<string>();
|
|
191
|
+
// advisory_findings of the latest admitted closure. The provider emits the key
|
|
192
|
+
// only on an approved closure; once captured, every result this run returns
|
|
193
|
+
// carries it (closed or stopped), so the parent holds it before any resume:
|
|
194
|
+
// a resume that goes straight to the acknowledgement cannot recover it, since
|
|
195
|
+
// neither bound STATUS nor the ACK envelope carries it. Never routed on.
|
|
196
|
+
let closureFindings: { value: unknown } | undefined;
|
|
197
|
+
// The facade's advisory_finding_claims of that same closure (each advisory id's
|
|
198
|
+
// reviewer claim), relayed beside advisory_findings only; never routed on.
|
|
199
|
+
let closureClaims: { value: unknown } | undefined;
|
|
200
|
+
// The facade's marks on those claims: ids whose claim is a cut prefix, and ids
|
|
201
|
+
// whose claim the per-closure limit left out. Relayed with the claims only.
|
|
202
|
+
let closureClaimMarks: Body = {};
|
|
203
|
+
// The correction request's findings and their bounded claims, once STATUS
|
|
204
|
+
// asked for a correction plan: carried by every result after it. Never routed on.
|
|
205
|
+
let correctionKeys: Body = {};
|
|
206
|
+
// The provider's non-blocking findings of the STATUS that stopped the run on
|
|
207
|
+
// a correction request or a stop (escalated). Never routed on.
|
|
208
|
+
let nonBlockingKeys: Body = {};
|
|
209
|
+
// That closure's capture envelope, kept unread for cancelled only while the
|
|
210
|
+
// retained closure carries advisory_findings.
|
|
211
|
+
let pendingCapture: Body | undefined;
|
|
61
212
|
const checkCancelled = () => {
|
|
62
213
|
if (deps.signal?.aborted) throw Object.assign(new Error("Review coordinator cancelled"), { name: "AbortError" });
|
|
63
214
|
};
|
|
@@ -83,12 +234,25 @@ export async function runReviewCoordinator(value: unknown, deps: ReviewCoordinat
|
|
|
83
234
|
}
|
|
84
235
|
steps.push({ tool, operation: parameters.operation, elapsed_ms: now() - start,
|
|
85
236
|
request_bytes: Buffer.byteLength(JSON.stringify({ ...workspace, ...parameters })), response_bytes: Buffer.byteLength(JSON.stringify(result)) });
|
|
86
|
-
|
|
237
|
+
// A capture closure carrying advisory_findings is checked after the outcome
|
|
238
|
+
// gate below, so a cancellation racing with it keeps the findings; any later
|
|
239
|
+
// abort ends in cancelled through runReviewCoordinator's catch.
|
|
240
|
+
if (!acknowledged(result) && !(tool !== "gentle_review" && Object.hasOwn(record(result.closure), "advisory_findings"))) checkCancelled();
|
|
87
241
|
return result;
|
|
88
242
|
};
|
|
89
|
-
|
|
243
|
+
// The run's own inputs without a selection: after selection-required the
|
|
244
|
+
// caller resumes the run with these plus the chosen untracked selection, so
|
|
245
|
+
// START keeps the requested lenses and request context.
|
|
246
|
+
const { untrackedScope: _scope, intendedUntracked: _paths, ...resumeInput } = structuredClone(input);
|
|
247
|
+
const finish = (outcome: string, result: Body) => ({ schema: "gentle-pi.review-coordinator-experiment/v1", outcome, result: withoutRawNonBlockingFindings(result), forecasts, reviewer_runs: reviewerRuns,
|
|
248
|
+
...(closureFindings !== undefined ? { advisory_findings: closureFindings.value } : {}),
|
|
249
|
+
...(closureFindings !== undefined && closureClaims !== undefined ? { advisory_finding_claims: closureClaims.value, ...closureClaimMarks } : {}),
|
|
250
|
+
...structuredClone(correctionKeys),
|
|
251
|
+
...structuredClone(nonBlockingKeys),
|
|
252
|
+
...(outcome === "selection-required" ? { resume_input: resumeInput } : {}),
|
|
90
253
|
...(lineage === undefined ? {} : { lineage_id: lineage }), metrics: { elapsed_ms: now() - began, facade_calls: steps.length, steps } });
|
|
91
254
|
const status = () => invoke("gentle_review", { operation: "status", lineageId: lineage, ...selectorInput });
|
|
255
|
+
const drive = async (): Promise<Body> => {
|
|
92
256
|
let details: Body;
|
|
93
257
|
if (lineage === undefined) {
|
|
94
258
|
const assessment = await invoke("gentle_review", { operation: "assess", ...selectorInput });
|
|
@@ -115,7 +279,11 @@ export async function runReviewCoordinator(value: unknown, deps: ReviewCoordinat
|
|
|
115
279
|
}
|
|
116
280
|
if (details.failure !== undefined || details.native_failure !== undefined || details.reconciliation !== undefined || details.reconciliation_failure !== undefined) return finish("blocked", details);
|
|
117
281
|
const transition = record(native.next_transition);
|
|
118
|
-
if (transition.kind === "stop")
|
|
282
|
+
if (transition.kind === "stop") {
|
|
283
|
+
// Read for relay only, after the routing decision above.
|
|
284
|
+
nonBlockingKeys = nonBlockingFindingKeys(native);
|
|
285
|
+
return finish("stopped", details);
|
|
286
|
+
}
|
|
119
287
|
if (transition.kind === "execute") {
|
|
120
288
|
const operation = record(transition.execute).operation;
|
|
121
289
|
if (operation === "review.start") {
|
|
@@ -142,7 +310,30 @@ export async function runReviewCoordinator(value: unknown, deps: ReviewCoordinat
|
|
|
142
310
|
const entries = Array.isArray(details.collectBindings) ? details.collectBindings.map(record) : [];
|
|
143
311
|
// Native explicitly supplies the authored correction request. Do not derive
|
|
144
312
|
// host routing metadata from submission domains or inspect opaque bindings.
|
|
145
|
-
if (transition.correction_request !== undefined
|
|
313
|
+
if (transition.correction_request !== undefined) {
|
|
314
|
+
// Read for relay only, after the routing decision above. The correction
|
|
315
|
+
// fields are returned only beside the provider's answer to the
|
|
316
|
+
// non-blocking question (L21): without it, a parent holding only the
|
|
317
|
+
// findings to correct would never learn the non-blocking ones, so the
|
|
318
|
+
// result stays as before T11 and the parent reads the review as it did.
|
|
319
|
+
nonBlockingKeys = nonBlockingFindingKeys(native);
|
|
320
|
+
if (Object.hasOwn(nonBlockingKeys, "non_blocking_findings")) correctionKeys = correctionFindingKeys(transition.correction_request);
|
|
321
|
+
return finish("input-required", details);
|
|
322
|
+
}
|
|
323
|
+
// The facade's own pre-lineage intended-untracked selection (selectionBinding
|
|
324
|
+
// and nextStep, no collectBindings): the parent chooses, never the run. The
|
|
325
|
+
// facade's nextStep names the single selection operation, which would start
|
|
326
|
+
// without this run's intent, so only resume_input names the way on; the
|
|
327
|
+
// selectionBinding stays because its eligible paths are what the choice is
|
|
328
|
+
// made from.
|
|
329
|
+
if (entries.length === 0 && typeof details.selectionBinding === "string") {
|
|
330
|
+
const { nextStep: _singleOperation, ...selection } = details;
|
|
331
|
+
// Without a caller root, name the root INSPECT resolved, so a resume from a
|
|
332
|
+
// session in another workspace still reviews the one this selection is for.
|
|
333
|
+
if (input.workspaceRoot === undefined && nonempty(details.workspace_root)) resumeInput.workspaceRoot = details.workspace_root;
|
|
334
|
+
return finish("selection-required", selection);
|
|
335
|
+
}
|
|
336
|
+
if (entries.length === 0) return finish("input-required", details);
|
|
146
337
|
if (lineage === undefined || target === undefined) return finish("blocked", details);
|
|
147
338
|
const bindings = entries.map(entry => entry.collectBinding);
|
|
148
339
|
if (!bindings.every(nonempty)) return finish("blocked", details);
|
|
@@ -155,9 +346,62 @@ export async function runReviewCoordinator(value: unknown, deps: ReviewCoordinat
|
|
|
155
346
|
if (await deps.presentForecast?.(capture) !== true) return finish("forecast", capture);
|
|
156
347
|
capture = await invoke(tool, { ...parameters, reviewerRunAcknowledged: true });
|
|
157
348
|
}
|
|
158
|
-
|
|
159
|
-
|
|
349
|
+
// A group whose every reviewer result was admitted without a closing event
|
|
350
|
+
// reports native-reviewer-group-status-reconciled after the facade's own
|
|
351
|
+
// bound STATUS confirmed lineage and target and offered no further reviewer
|
|
352
|
+
// capture (gentle_review_capture_group). Like any accepted capture, the next
|
|
353
|
+
// step comes only from the bound STATUS read below. Drift, an uncertain
|
|
354
|
+
// submission or a failed reconciliation carries another outcome or a
|
|
355
|
+
// failure/reconciliation field and stays blocked.
|
|
356
|
+
const reconciledGroup = tool === "gentle_review_capture_group" && capture.outcome === "native-reviewer-group-status-reconciled" && capture.status === "reconciled";
|
|
357
|
+
// An older provider's self-contained role vector (--execute=true): Go ran the
|
|
358
|
+
// refuter or validator and admitted it, returning the role artifact instead
|
|
359
|
+
// of a closure. Like an admitted reviewer result, bound STATUS routes next.
|
|
360
|
+
const capturedRole = tool === "gentle_review_capture" && capture.outcome === "native-provider-role-captured" && capture.status === "captured";
|
|
361
|
+
if (!(["native-last-event-closure", "native-reviewer-result-captured"].includes(String(capture.outcome)) || reconciledGroup || capturedRole)
|
|
362
|
+
|| capture.failure !== undefined || capture.reconciliation !== undefined
|
|
363
|
+
|| capture.native_failure !== undefined || capture.reconciliation_failure !== undefined) {
|
|
364
|
+
checkCancelled();
|
|
365
|
+
return finish("blocked", capture);
|
|
366
|
+
}
|
|
367
|
+
if (Object.hasOwn(capture, "closure")) {
|
|
368
|
+
// Read only these keys' presence and value; closure state and variants stay unread.
|
|
369
|
+
const closure = record(capture.closure);
|
|
370
|
+
closureFindings = Object.hasOwn(closure, "advisory_findings") ? { value: structuredClone(closure.advisory_findings) } : undefined;
|
|
371
|
+
// Relayed only as a plain object of strings; any other shape is dropped.
|
|
372
|
+
const claims = closure.advisory_finding_claims;
|
|
373
|
+
const plainStrings = claims !== null && typeof claims === "object" && [Object.prototype, null].includes(Object.getPrototypeOf(claims))
|
|
374
|
+
&& Object.values(claims).every(value => typeof value === "string");
|
|
375
|
+
closureClaims = closureFindings !== undefined && Object.hasOwn(closure, "advisory_finding_claims") && plainStrings ? { value: structuredClone(claims) } : undefined;
|
|
376
|
+
// Each mark is relayed only as an array of strings; any other shape is dropped.
|
|
377
|
+
closureClaimMarks = Object.fromEntries(["advisory_finding_claims_truncated", "advisory_finding_claims_omitted"]
|
|
378
|
+
.filter(key => Array.isArray(closure[key]) && (closure[key] as unknown[]).every(id => typeof id === "string"))
|
|
379
|
+
.map(key => [key, structuredClone(closure[key])]));
|
|
380
|
+
pendingCapture = closureFindings === undefined ? undefined : capture;
|
|
381
|
+
}
|
|
382
|
+
checkCancelled();
|
|
160
383
|
details = await status();
|
|
161
384
|
}
|
|
162
385
|
return finish("transition-limit", details);
|
|
386
|
+
};
|
|
387
|
+
try {
|
|
388
|
+
return await drive();
|
|
389
|
+
} catch (error) {
|
|
390
|
+
// Cancelled after an admitted approved closure with findings, before the
|
|
391
|
+
// acknowledgement completed (which returns closed above): return its findings
|
|
392
|
+
// and dispatch nothing more; resuming by lineageId reaches the acknowledgement.
|
|
393
|
+
// Without such a closure, or for a failure other than the abort, rethrow.
|
|
394
|
+
// The abort itself is an AbortError-named error (checkCancelled, the facade's
|
|
395
|
+
// reviewCancellation, the native CLI's own abort, the signal's default
|
|
396
|
+
// reason) or the signal's own reason (a custom reason, such as a timeout,
|
|
397
|
+
// that a facade wait rejects with); any other error is a real failure.
|
|
398
|
+
const abort = deps.signal?.aborted === true
|
|
399
|
+
&& ((error instanceof Error || error instanceof DOMException) && error.name === "AbortError" || error === deps.signal.reason);
|
|
400
|
+
if (pendingCapture === undefined || !abort) throw error;
|
|
401
|
+
// The capture's status ("closed") and state ("approved") describe the
|
|
402
|
+
// capture, not the run, which is neither closed nor acknowledged: drop them.
|
|
403
|
+
const { status: _status, state: _state, closure, ...envelope } = pendingCapture;
|
|
404
|
+
const { state: _closureState, ...pending } = record(closure);
|
|
405
|
+
return finish("cancelled", { ...envelope, closure: pending });
|
|
406
|
+
}
|
|
163
407
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { NATIVE_UNTRACKED_SCOPE, type NativeReviewCli } from "./native-review-cli.ts";
|
|
4
|
+
import { recognizeReviewDeliveryActions } from "./destructive-command-guard.ts";
|
|
5
|
+
import { resolveSessionWorktree, worktreeGitEnvironment } from "./session-worktree-registry.ts";
|
|
6
|
+
|
|
7
|
+
type Denial = { block: true; reason: string };
|
|
8
|
+
const deny = (reason: string): Denial => ({ block: true, reason: `RDD pre-delivery: ${reason} This delivery command was not run. Review outcomes do not authorize delivery.` });
|
|
9
|
+
|
|
10
|
+
// Compare HEAD/base around this read, without retaining a verdict or snapshot.
|
|
11
|
+
async function identity(root: string, baseRef: string): Promise<string | undefined> {
|
|
12
|
+
return new Promise(done => execFile("git", ["rev-parse", "--revs-only", "--end-of-options", "HEAD^{commit}", `${baseRef}^{commit}`],
|
|
13
|
+
{ cwd: root, encoding: "utf8", timeout: 2_000, maxBuffer: 4096, windowsHide: true, env: worktreeGitEnvironment() },
|
|
14
|
+
(error, stdout) => {
|
|
15
|
+
const ids = stdout.trim().split(/\r?\n/);
|
|
16
|
+
done(!error && ids.length === 2 && ids.every(id => /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(id)) ? ids.join("\n") : undefined);
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* gentle-shell#3169: native assess refuses a committed-only range while any
|
|
22
|
+
* untracked file exists (a PR body written for `gh pr create --body-file`)
|
|
23
|
+
* unless the untracked inventory is declared. A base-diff snapshot never
|
|
24
|
+
* includes untracked files, so excluding them leaves the assessed range
|
|
25
|
+
* unchanged. The digest comes only from native status; without it nothing is
|
|
26
|
+
* declared and native keeps deciding.
|
|
27
|
+
*/
|
|
28
|
+
export async function committedRangeUntrackedExclusion(cli: Pick<NativeReviewCli, "targetStatus"> | null | undefined, cwd: string, baseRef: string,
|
|
29
|
+
signal?: AbortSignal): Promise<{ untrackedScope?: typeof NATIVE_UNTRACKED_SCOPE.EXCLUDE; expectedUntrackedInventory?: string }> {
|
|
30
|
+
if (!cli?.targetStatus) return {};
|
|
31
|
+
try {
|
|
32
|
+
const inventory = (await cli.targetStatus({ cwd, baseRef, committedOnly: true, agent: "pi", ...(signal ? { signal } : {}) })).eligibleUntrackedInventory;
|
|
33
|
+
return typeof inventory === "string" && inventory ? { untrackedScope: NATIVE_UNTRACKED_SCOPE.EXCLUDE, expectedUntrackedInventory: inventory } : {};
|
|
34
|
+
} catch { return {}; }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** One fresh check per repository/batch. The existing session registry supplies only a base-ref hint. */
|
|
38
|
+
export async function checkReviewDeliveryPreflight(cwd: string, toolName: string, command: string, cli: NativeReviewCli | null,
|
|
39
|
+
baseRefFor: (root: string) => string | undefined, declined: (root: string, target: string) => boolean,
|
|
40
|
+
signal?: AbortSignal, current: () => boolean = () => true): Promise<Denial | undefined> {
|
|
41
|
+
const actions = recognizeReviewDeliveryActions(command), deliveries = actions.filter(action => action.kind === "delivery");
|
|
42
|
+
if (!deliveries.length || !cli?.reviewMode) return undefined;
|
|
43
|
+
if (deliveries.some(delivery => delivery.unresolvedDirectory)) return deny("The delivery repository cannot be resolved from this directory or Git/environment redirect; run delivery inside its repository or use literal cd or git -C.");
|
|
44
|
+
if (signal?.aborted || !current()) return deny("Preflight was cancelled or its session changed.");
|
|
45
|
+
const bounded = AbortSignal.any([AbortSignal.timeout(10_000), ...(signal ? [signal] : [])]);
|
|
46
|
+
let abort!: () => void;
|
|
47
|
+
const expired = new Promise<Denial>(done => { abort = () => done(deny("The bounded preflight was cancelled or timed out.")); bounded.addEventListener("abort", abort, { once: true }); });
|
|
48
|
+
const run = async (): Promise<Denial | undefined> => {
|
|
49
|
+
try {
|
|
50
|
+
const checked: Array<{ root: string; baseRef: string; before: string }> = [];
|
|
51
|
+
const roots = new Set(deliveries.map(delivery => {
|
|
52
|
+
const target = (delivery.directories ?? []).reduce((base, directory) => resolve(base, directory), cwd);
|
|
53
|
+
return resolveSessionWorktree(target, cwd)?.root ?? target;
|
|
54
|
+
}));
|
|
55
|
+
for (const root of roots) {
|
|
56
|
+
const mode = await cli.reviewMode!({ cwd: root, operation: "status", signal: bounded });
|
|
57
|
+
if (bounded.aborted || !current()) return deny("Session changed during preflight; assess again.");
|
|
58
|
+
if (mode.status.effective === "off") continue;
|
|
59
|
+
if (mode.status.effective !== "on") return deny("RDD mode is unavailable; resolve it before delivery.");
|
|
60
|
+
if (toolName !== "bash" || deliveries.some(delivery => delivery.background) || actions.some(action => action.kind === "change")) return deny("Finish candidate-changing commands or background waits separately, then issue delivery so the resulting commits can be assessed.");
|
|
61
|
+
const baseRef = baseRefFor(root);
|
|
62
|
+
if (!baseRef) return deny('Select the actual committed range with gentle_review assess input {"baseRef":"<slice base>","committedOnly":true}.');
|
|
63
|
+
const before = await identity(root, baseRef);
|
|
64
|
+
if (!before || !cli.assess) return deny("The selected base or native assessment is unavailable; resolve it before delivery.");
|
|
65
|
+
if (bounded.aborted || !current()) return deny("Session changed during preflight; assess again.");
|
|
66
|
+
const untracked = await committedRangeUntrackedExclusion(cli, root, baseRef, bounded);
|
|
67
|
+
if (bounded.aborted || !current()) return deny("Session changed during preflight; assess again.");
|
|
68
|
+
const assessment = await cli.assess({ cwd: root, baseRef, committedOnly: true, ...untracked, signal: bounded });
|
|
69
|
+
if (bounded.aborted || !current()) return deny("Session changed during preflight; assess again.");
|
|
70
|
+
if (assessment.candidate.kind !== "base-diff" || assessment.candidate.baseRef !== baseRef || typeof assessment.reviewDue !== "boolean") return deny("Native assessment did not confirm the selected committed range.");
|
|
71
|
+
if (assessment.reviewDue) {
|
|
72
|
+
const status = await cli.targetStatus?.({ cwd: root, baseRef, committedOnly: true, agent: "pi", signal: bounded });
|
|
73
|
+
if (!status || status.applicability !== "current_target" || status.projection.kind !== "base-diff" || !declined(root, status.targetIdentity)) return deny("Native assessment reports a due review. Resume the bound review or inspect and follow its native transitions and human consent before delivery.");
|
|
74
|
+
}
|
|
75
|
+
checked.push({ root, baseRef, before });
|
|
76
|
+
}
|
|
77
|
+
for (const { root, baseRef, before } of checked) {
|
|
78
|
+
if (bounded.aborted || !current() || baseRefFor(root) !== baseRef || await identity(root, baseRef) !== before || !current()) return deny("The range or session changed during preflight; assess again.");
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
} catch { return deny("Native preflight is unavailable; resolve it before delivery."); }
|
|
82
|
+
};
|
|
83
|
+
try { return await Promise.race([run(), expired]); }
|
|
84
|
+
finally { bounded.removeEventListener("abort", abort); }
|
|
85
|
+
}
|
package/lib/review-host-relay.ts
CHANGED
|
@@ -34,6 +34,7 @@ import { spawn } from "node:child_process";
|
|
|
34
34
|
import { tmpdir } from "node:os";
|
|
35
35
|
import { isAbsolute, join } from "node:path";
|
|
36
36
|
import { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
37
|
+
import { reviewerStreamLimits, publishReviewerProgress } from "./reviewer-stream.ts";
|
|
37
38
|
import { gentleAiIsolationEnv, resolveGentleAiBinary } from "./gentle-ai-binary.ts";
|
|
38
39
|
import {
|
|
39
40
|
INPROCESS_REVIEWER_FAILURE,
|
|
@@ -591,7 +592,8 @@ function relayReviewerRefusalError(
|
|
|
591
592
|
return new ReviewHostRelayError(
|
|
592
593
|
REVIEW_HOST_RELAY_FAILURE.PI_TIMED_OUT,
|
|
593
594
|
"pi",
|
|
594
|
-
|
|
595
|
+
outcome.evidence?.timeoutPhase === "first-output" || outcome.evidence?.timeoutPhase === "stream-idle"
|
|
596
|
+
? outcome.message : reviewHostRelayPiTimeoutMessage(timing.elapsedMs, timing.timeoutMs, promptByteLength),
|
|
595
597
|
{ ...details, timedOut: true },
|
|
596
598
|
);
|
|
597
599
|
case INPROCESS_REVIEWER_FAILURE.PROVIDER_FAILED:
|
|
@@ -785,10 +787,12 @@ export async function prepareReviewHostRelaySlot(
|
|
|
785
787
|
...(preparedRequest.reviewerSessionId === undefined ? {} : { sessionId: preparedRequest.reviewerSessionId }),
|
|
786
788
|
prompt: promptBytes,
|
|
787
789
|
timeoutMs: piTimeoutMs,
|
|
790
|
+
...reviewerStreamLimits(preparedRequest.environment!),
|
|
788
791
|
...(preparedRequest.signal === undefined ? {} : { signal: preparedRequest.signal }),
|
|
789
792
|
routingKey: preparedRequest.routingKey!,
|
|
790
793
|
},
|
|
791
794
|
{ registry: preparedRequest.reviewerRegistry!, complete: completeSimple,
|
|
795
|
+
onProgress: publishReviewerProgress,
|
|
792
796
|
onEvidence: (evidence) => { reviewerEvidence = evidence; } },
|
|
793
797
|
);
|
|
794
798
|
} catch (error) {
|
|
@@ -689,9 +689,32 @@ export interface ReviewStatusV3 {
|
|
|
689
689
|
validationRequest?: ReviewTargetedValidationRequestV1;
|
|
690
690
|
/** status/v7 only: the eligible untracked-path inventory digest, absent on the `staged` projection. */
|
|
691
691
|
eligibleUntrackedInventory?: string;
|
|
692
|
+
/**
|
|
693
|
+
* status/v9 opt-in (`--non-blocking-findings`, gentle-ai#6088): the admitted
|
|
694
|
+
* findings of a compact correction_required or escalated authority that are
|
|
695
|
+
* neither to correct nor unresolved, with the reviewer's claim. Display
|
|
696
|
+
* data only; nothing routes on it.
|
|
697
|
+
*/
|
|
698
|
+
nonBlockingFindings?: ReviewNonBlockingFindingsV1;
|
|
692
699
|
raw: Readonly<Record<string, unknown>>;
|
|
693
700
|
}
|
|
694
701
|
|
|
702
|
+
export interface ReviewNonBlockingFindingV1 {
|
|
703
|
+
id: string;
|
|
704
|
+
lens?: string;
|
|
705
|
+
location?: string;
|
|
706
|
+
severity: string;
|
|
707
|
+
disposition: ReviewAdvisoryFindingDisposition;
|
|
708
|
+
/** The reviewer's admitted text, unbounded; never an instruction. */
|
|
709
|
+
claim: string;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export interface ReviewNonBlockingFindingsV1 {
|
|
713
|
+
statement: string;
|
|
714
|
+
/** Empty when every finding of the review blocks. */
|
|
715
|
+
findings: readonly ReviewNonBlockingFindingV1[];
|
|
716
|
+
}
|
|
717
|
+
|
|
695
718
|
export interface ReviewConsentChoiceV2 {
|
|
696
719
|
answer: "granted" | "declined";
|
|
697
720
|
label: string;
|
|
@@ -2048,8 +2071,9 @@ export function decodeReviewStatusV3(value: unknown): ReviewStatusV3 {
|
|
|
2048
2071
|
// branch's contract, ahead of the released v8) adds nothing at this top
|
|
2049
2072
|
// level either: its one addition is the host-mediated role `submission`
|
|
2050
2073
|
// on a next_transition.collect input (gentle-pi#311 P3), gated on v9 in
|
|
2051
|
-
// decodeCollectInput, not here.
|
|
2052
|
-
//
|
|
2074
|
+
// decodeCollectInput, not here. Its one top-level key is the opt-in
|
|
2075
|
+
// `non_blocking_findings` (gentle-ai#6088), decoded below. v3 keeps
|
|
2076
|
+
// rejecting every v5/v6/v7/v8/v9-only field.
|
|
2053
2077
|
const schema = typeof value === "object" && value !== null ? (value as Record<string, unknown>).schema : undefined;
|
|
2054
2078
|
const v9 = schema === "gentle-ai.review-integration.status/v9";
|
|
2055
2079
|
const v8 = v9 || schema === "gentle-ai.review-integration.status/v8";
|
|
@@ -2058,7 +2082,7 @@ export function decodeReviewStatusV3(value: unknown): ReviewStatusV3 {
|
|
|
2058
2082
|
const v5 = v6 || schema === "gentle-ai.review-integration.status/v5";
|
|
2059
2083
|
const body = exactRecord(value, "status", [
|
|
2060
2084
|
"schema", "contract", "operation", "applicability", "action", "replayability", "target_identity", "projection", "repair", "candidates",
|
|
2061
|
-
], ["authority", "frozen", "action_disposition", "eligibility", "next_transition", "authority_target_identity", ...(v5 ? ["receipt", "forecast", "repository_context", "validation_request"] : []), ...(v7 ? ["eligible_untracked_inventory", "escalation"] : [])]);
|
|
2085
|
+
], ["authority", "frozen", "action_disposition", "eligibility", "next_transition", "authority_target_identity", ...(v5 ? ["receipt", "forecast", "repository_context", "validation_request"] : []), ...(v7 ? ["eligible_untracked_inventory", "escalation"] : []), ...(v9 ? ["non_blocking_findings"] : [])]);
|
|
2062
2086
|
requireIdentity(body, v9 ? "gentle-ai.review-integration.status/v9" : v8 ? "gentle-ai.review-integration.status/v8" : v7 ? "gentle-ai.review-integration.status/v7" : v6 ? "gentle-ai.review-integration.status/v6" : v5 ? "gentle-ai.review-integration.status/v5" : "gentle-ai.review-integration.status/v3", REVIEW_INTEGRATION_OPERATION.STATUS);
|
|
2063
2087
|
|
|
2064
2088
|
const applicability = enumeration(body.applicability, ["current_target", "unrelated", "ambiguous", "corrupted"] as const, "status.applicability");
|
|
@@ -2155,6 +2179,16 @@ export function decodeReviewStatusV3(value: unknown): ReviewStatusV3 {
|
|
|
2155
2179
|
? sha256(body.eligible_untracked_inventory, "status.eligible_untracked_inventory")
|
|
2156
2180
|
: undefined;
|
|
2157
2181
|
|
|
2182
|
+
// status/v9 opt-in (gentle-ai#6088): the same rule as the provider's schema,
|
|
2183
|
+
// a current compact-v2 authority in correction_required or escalated.
|
|
2184
|
+
let nonBlockingFindings: ReviewNonBlockingFindingsV1 | undefined;
|
|
2185
|
+
if (Object.hasOwn(body, "non_blocking_findings")) {
|
|
2186
|
+
if (authority?.version !== REVIEW_AUTHORITY_VERSION.COMPACT_V2 || (authority.state !== "correction_required" && authority.state !== "escalated")) {
|
|
2187
|
+
throw new TypeError("status.non_blocking_findings requires a current compact-v2 authority in correction_required or escalated");
|
|
2188
|
+
}
|
|
2189
|
+
nonBlockingFindings = decodeReviewNonBlockingFindingsV1(body.non_blocking_findings, "status.non_blocking_findings");
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2158
2192
|
return {
|
|
2159
2193
|
contract: REVIEW_INTEGRATION_CONTRACT,
|
|
2160
2194
|
applicability,
|
|
@@ -2175,10 +2209,29 @@ export function decodeReviewStatusV3(value: unknown): ReviewStatusV3 {
|
|
|
2175
2209
|
...(validationRequest === undefined ? {} : { validationRequest }),
|
|
2176
2210
|
...(escalation === undefined ? {} : { escalation }),
|
|
2177
2211
|
...(eligibleUntrackedInventory === undefined ? {} : { eligibleUntrackedInventory }),
|
|
2212
|
+
...(nonBlockingFindings === undefined ? {} : { nonBlockingFindings }),
|
|
2178
2213
|
raw: body,
|
|
2179
2214
|
};
|
|
2180
2215
|
}
|
|
2181
2216
|
|
|
2217
|
+
function decodeReviewNonBlockingFindingsV1(value: unknown, label: string): ReviewNonBlockingFindingsV1 {
|
|
2218
|
+
const body = exactRecord(value, label, ["statement", "findings"]);
|
|
2219
|
+
return {
|
|
2220
|
+
statement: nonempty(body.statement, `${label}.statement`),
|
|
2221
|
+
findings: array(body.findings, `${label}.findings`, (entry, itemLabel) => {
|
|
2222
|
+
const finding = exactRecord(entry, itemLabel, ["id", "severity", "disposition", "claim"], ["lens", "location"]);
|
|
2223
|
+
return {
|
|
2224
|
+
id: nonempty(finding.id, `${itemLabel}.id`),
|
|
2225
|
+
...(finding.lens === undefined ? {} : { lens: nonempty(finding.lens, `${itemLabel}.lens`) }),
|
|
2226
|
+
...(finding.location === undefined ? {} : { location: nonempty(finding.location, `${itemLabel}.location`) }),
|
|
2227
|
+
severity: nonempty(finding.severity, `${itemLabel}.severity`),
|
|
2228
|
+
disposition: enumeration(finding.disposition, Object.values(REVIEW_ADVISORY_FINDING_DISPOSITION), `${itemLabel}.disposition`),
|
|
2229
|
+
claim: text(finding.claim, `${itemLabel}.claim`),
|
|
2230
|
+
};
|
|
2231
|
+
}),
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2182
2235
|
// ---------------------------------------------------------------------------
|
|
2183
2236
|
// consent/v2 — net-new. The typed per-candidate blocking consent question
|
|
2184
2237
|
// emitted by negotiated v2 START when the caller declared --consent relay.
|