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
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
mkdtempSync,
|
|
7
7
|
readFileSync,
|
|
8
8
|
renameSync,
|
|
9
|
+
writeFileSync,
|
|
9
10
|
} from "node:fs";
|
|
10
11
|
import { tmpdir } from "node:os";
|
|
11
12
|
import { dirname, join } from "node:path";
|
|
@@ -28,10 +29,12 @@ const metadata = join(
|
|
|
28
29
|
);
|
|
29
30
|
const version: string = JSON.parse(readFileSync(metadata, "utf8")).version;
|
|
30
31
|
assert.match(version, /^\d+\.\d+\.\d+$/);
|
|
32
|
+
const [major, minor] = version.split(".").map(Number);
|
|
31
33
|
assert.ok(
|
|
32
|
-
|
|
34
|
+
major >= 1,
|
|
33
35
|
`Public fixtures require Pi >=1.0.0, installed ${version}`,
|
|
34
36
|
);
|
|
37
|
+
const rollsBackFailedAppend = major > 1 || (major === 1 && minor >= 5);
|
|
35
38
|
console.info(
|
|
36
39
|
`Public append controller fixture API: ${version}; minimum tested baseline 1.0.0`,
|
|
37
40
|
);
|
|
@@ -147,7 +150,7 @@ for (const prior of ["bound", "invalid", "future"] as const) {
|
|
|
147
150
|
}
|
|
148
151
|
for (const failure of ["bind", "clear"] as const) {
|
|
149
152
|
for (const recovery of ["bind", "clear"] as const) {
|
|
150
|
-
test(`public EISDIR
|
|
153
|
+
test(`public EISDIR ${failure} preserves authority; new ${recovery} survives reopen`, () => {
|
|
151
154
|
const { manager, sessions, adapter, errors } = fixture();
|
|
152
155
|
assert.equal(
|
|
153
156
|
adapter.bind("good", {
|
|
@@ -160,6 +163,10 @@ for (const failure of ["bind", "clear"] as const) {
|
|
|
160
163
|
bound(adapter.refresh(), "good");
|
|
161
164
|
const file = manager.getSessionFile();
|
|
162
165
|
assert.ok(file);
|
|
166
|
+
const original = readFileSync(file, "utf8");
|
|
167
|
+
const before = structuredClone(manager.getBranch());
|
|
168
|
+
const retained = manager.getLeafId();
|
|
169
|
+
assert.ok(retained);
|
|
163
170
|
const saved = `${file}.saved`;
|
|
164
171
|
renameSync(file, saved);
|
|
165
172
|
mkdirSync(file);
|
|
@@ -168,23 +175,39 @@ for (const failure of ["bind", "clear"] as const) {
|
|
|
168
175
|
assert.equal(failed.status, "indeterminate");
|
|
169
176
|
assert.equal(errors.length, 1);
|
|
170
177
|
assert.equal((errors[0] as NodeJS.ErrnoException).code, "EISDIR");
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
const after = manager.getBranch();
|
|
179
|
+
let failedLeaf = retained;
|
|
180
|
+
if (rollsBackFailedAppend) {
|
|
181
|
+
assert.deepEqual(after, before, "SDK rolls back the failed entry and leaf");
|
|
182
|
+
assert.equal(manager.getLeafId(), retained);
|
|
183
|
+
} else {
|
|
184
|
+
assert.equal(after.length, before.length + 1);
|
|
185
|
+
assert.deepEqual(after.slice(0, before.length), before);
|
|
186
|
+
const ghost = after.at(-1);
|
|
187
|
+
assert.ok(ghost);
|
|
188
|
+
assert.equal(ghost.type, "custom");
|
|
189
|
+
assert.equal(ghost.customType, SESSION_PROFILE_CUSTOM_TYPE);
|
|
190
|
+
assert.deepEqual(ghost.data, failure === "bind"
|
|
191
|
+
? { kind: "bind", origin: "user", name: "failed", modelProfiles: {} }
|
|
192
|
+
: { kind: "clear" });
|
|
193
|
+
assert.equal(ghost.parentId, retained);
|
|
194
|
+
assert.ok(ghost.id);
|
|
195
|
+
assert.notEqual(ghost.id, retained);
|
|
196
|
+
assert.equal(manager.getLeafId(), ghost.id);
|
|
197
|
+
failedLeaf = ghost.id;
|
|
198
|
+
}
|
|
199
|
+
assert.equal(readFileSync(saved, "utf8"), original, "rejected append preserves stored bytes");
|
|
174
200
|
// Recover fixture filesystem by moves, not history edits or private APIs.
|
|
175
201
|
renameSync(file, `${file}.fault-directory`);
|
|
176
202
|
renameSync(saved, file);
|
|
177
203
|
const preserved = adapter.refresh();
|
|
178
204
|
assert.equal(preserved.status, "persisted");
|
|
179
205
|
bound(preserved, "good");
|
|
180
|
-
const
|
|
181
|
-
const good = branch.find(
|
|
182
|
-
(entry) => entry.type === "custom" && entry.id !== ghost.id,
|
|
183
|
-
);
|
|
206
|
+
const good = manager.getBranch().find((entry) => entry.type === "custom");
|
|
184
207
|
assert.ok(good);
|
|
185
208
|
manager.branch(good.id);
|
|
186
209
|
bound(adapter.refresh(), "good");
|
|
187
|
-
manager.branch(
|
|
210
|
+
manager.branch(failedLeaf);
|
|
188
211
|
bound(adapter.refresh(), "good");
|
|
189
212
|
const recovered =
|
|
190
213
|
recovery === "bind" ? adapter.bind("recovered", {}) : adapter.clear();
|
|
@@ -195,15 +218,13 @@ for (const failure of ["bind", "clear"] as const) {
|
|
|
195
218
|
);
|
|
196
219
|
const latest = manager.getBranch().at(-1);
|
|
197
220
|
assert.ok(latest);
|
|
198
|
-
assert.equal(latest.parentId,
|
|
221
|
+
assert.equal(latest.parentId, failedLeaf);
|
|
199
222
|
const disk = readFileSync(file, "utf8")
|
|
200
223
|
.trim()
|
|
201
224
|
.split("\n")
|
|
202
225
|
.map((line) => JSON.parse(line));
|
|
203
|
-
assert.equal(
|
|
204
|
-
|
|
205
|
-
false,
|
|
206
|
-
);
|
|
226
|
+
assert.equal(disk.some((row) => row.id === retained), true);
|
|
227
|
+
if (!rollsBackFailedAppend) assert.equal(disk.some((row) => row.id === failedLeaf), false);
|
|
207
228
|
assert.deepEqual(
|
|
208
229
|
disk.find((row) => row.id === latest.id),
|
|
209
230
|
JSON.parse(JSON.stringify(latest)),
|
|
@@ -211,19 +232,27 @@ for (const failure of ["bind", "clear"] as const) {
|
|
|
211
232
|
const reopened = SessionManager.open(file, sessions);
|
|
212
233
|
const restored = controller(reopened).refresh();
|
|
213
234
|
assert.equal(restored.status, "persisted");
|
|
214
|
-
assert.equal(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
235
|
+
assert.equal(restored.state.status, recovery === "bind" ? "bound" : "cleared");
|
|
236
|
+
if (recovery === "bind") bound(restored, "recovered");
|
|
237
|
+
if (rollsBackFailedAppend) {
|
|
238
|
+
assert.deepEqual(reopened.getBranch(), manager.getBranch());
|
|
239
|
+
// With rollback, use a separately damaged test-owned file for a disk gap.
|
|
240
|
+
const orphanFile = `${file}.orphan.jsonl`;
|
|
241
|
+
writeFileSync(orphanFile,
|
|
242
|
+
disk.filter((row) => row.id !== retained)
|
|
243
|
+
.map((row) => JSON.stringify(row)).join("\n") + "\n",
|
|
244
|
+
);
|
|
245
|
+
const orphan = SessionManager.open(orphanFile, sessions);
|
|
246
|
+
assert.deepEqual(orphan.getBranch(), [JSON.parse(JSON.stringify(latest))]);
|
|
247
|
+
const orphanRestored = controller(orphan).refresh();
|
|
248
|
+
assert.equal(orphanRestored.status, "persisted");
|
|
249
|
+
assert.equal(orphanRestored.state.status, recovery === "bind" ? "bound" : "cleared");
|
|
250
|
+
if (recovery === "bind") bound(orphanRestored, "recovered");
|
|
251
|
+
} else {
|
|
252
|
+
// The real failed parent is absent on disk; Pi reopens the recovered suffix.
|
|
253
|
+
assert.deepEqual(reopened.getBranch(), [JSON.parse(JSON.stringify(latest))]);
|
|
254
|
+
}
|
|
255
|
+
manager.branch(failedLeaf);
|
|
227
256
|
bound(adapter.refresh(), "good");
|
|
228
257
|
});
|
|
229
258
|
}
|
|
@@ -262,8 +291,8 @@ for (const failedOperation of ["bind", "clear"] as const) {
|
|
|
262
291
|
: f.adapter.clear();
|
|
263
292
|
assert.equal(failed.status, "indeterminate");
|
|
264
293
|
assert.equal(readFileSync(`${file}.saved`, "utf8"), original);
|
|
265
|
-
const
|
|
266
|
-
assert.ok(
|
|
294
|
+
const failedLeaf = f.manager.getLeafId();
|
|
295
|
+
assert.ok(failedLeaf);
|
|
267
296
|
renameSync(file, `${file}.fault-directory`);
|
|
268
297
|
renameSync(`${file}.saved`, file);
|
|
269
298
|
f.adapter.detach();
|
|
@@ -283,7 +312,7 @@ for (const failedOperation of ["bind", "clear"] as const) {
|
|
|
283
312
|
assert.equal(calls, 0);
|
|
284
313
|
assert.equal(current.clear().status, "persisted");
|
|
285
314
|
assert.equal(calls, 1);
|
|
286
|
-
f.manager.branch(
|
|
315
|
+
f.manager.branch(failedLeaf);
|
|
287
316
|
bound(current.refresh(), "trusted");
|
|
288
317
|
assert.equal(f.errors.length, 1);
|
|
289
318
|
});
|
|
@@ -729,3 +729,66 @@ for (const changed of ["data", "timestamp", "parentId", "extra"] as const) {
|
|
|
729
729
|
assert.equal(current.refresh().status, "indeterminate");
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
|
+
|
|
733
|
+
test("the attachment appends the A2 startup bind, explicit startup state and startup-none clear", () => {
|
|
734
|
+
const f = fixture();
|
|
735
|
+
f.mode = "disk";
|
|
736
|
+
const team = { worker: { model: "provider/team" }, orchestrator: { model: "provider/main" } };
|
|
737
|
+
const startup = { origin: "repo" as const, name: "team", modelProfiles: team };
|
|
738
|
+
const outcomes = [
|
|
739
|
+
f.controller.bindStartup("repo", "team", team),
|
|
740
|
+
f.controller.bind("chosen", {}, startup),
|
|
741
|
+
f.controller.clear("none"),
|
|
742
|
+
];
|
|
743
|
+
assert.deepEqual(outcomes, [
|
|
744
|
+
{ status: "persisted", state: { status: "bound", binding: { kind: "bind", ...startup }, entryIndex: 0, lineNumber: 2 } },
|
|
745
|
+
{ status: "persisted", state: { status: "bound", binding: { kind: "bind", origin: "user", name: "chosen", modelProfiles: {}, startup }, entryIndex: 1, lineNumber: 3 } },
|
|
746
|
+
{ status: "persisted", state: { status: "cleared", startup: "none", entryIndex: 2, lineNumber: 4 } },
|
|
747
|
+
]);
|
|
748
|
+
assert.deepEqual(f.rows.map((row) => row.data), [
|
|
749
|
+
{ kind: "bind", ...startup },
|
|
750
|
+
{ kind: "bind", origin: "user", name: "chosen", modelProfiles: {}, startup },
|
|
751
|
+
{ kind: "clear", startup: "none" },
|
|
752
|
+
]);
|
|
753
|
+
});
|
|
754
|
+
test("detached and reloaded attachments reject bindStartup, bind and clear without appending", () => {
|
|
755
|
+
const f = fixture();
|
|
756
|
+
f.mode = "disk";
|
|
757
|
+
let calls = 0;
|
|
758
|
+
const counted = (t: string, d: unknown) => {
|
|
759
|
+
calls++;
|
|
760
|
+
f.append(t, d);
|
|
761
|
+
};
|
|
762
|
+
const owner = createSessionProfileAppendController(f.source, counted, {
|
|
763
|
+
readFile: f.readFile,
|
|
764
|
+
}) as ReturnType<typeof createSessionProfileAppendController> & {
|
|
765
|
+
detach(): void;
|
|
766
|
+
attach(
|
|
767
|
+
source: typeof f.source,
|
|
768
|
+
appendEntry: (type: string, data: unknown) => void,
|
|
769
|
+
context: { reason: string },
|
|
770
|
+
options?: { readFile: typeof f.readFile },
|
|
771
|
+
): typeof f.controller;
|
|
772
|
+
};
|
|
773
|
+
const team = { worker: { model: "provider/team" } };
|
|
774
|
+
const startup = { origin: "repo" as const, name: "team", modelProfiles: team };
|
|
775
|
+
assert.equal(owner.bindStartup("repo", "team", team).status, "persisted");
|
|
776
|
+
const rejected = {
|
|
777
|
+
status: "indeterminate",
|
|
778
|
+
state: { status: "indeterminate", reason: "detached-source" },
|
|
779
|
+
};
|
|
780
|
+
const attempt = () => [
|
|
781
|
+
owner.bindStartup("repo", "stale", team),
|
|
782
|
+
owner.bind("stale", {}, startup),
|
|
783
|
+
owner.clear("none"),
|
|
784
|
+
];
|
|
785
|
+
const entries = structuredClone(f.rows);
|
|
786
|
+
owner.detach();
|
|
787
|
+
assert.deepEqual(attempt(), [rejected, rejected, rejected]);
|
|
788
|
+
assert.deepEqual(f.rows, entries);
|
|
789
|
+
assert.equal(calls, 1);
|
|
790
|
+
owner.attach(f.source, counted, { reason: "reload" }, { readFile: f.readFile });
|
|
791
|
+
assert.deepEqual(attempt(), [rejected, rejected, rejected]);
|
|
792
|
+
assert.deepEqual(f.rows, entries);
|
|
793
|
+
assert.equal(calls, 1);
|
|
794
|
+
});
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import {
|
|
4
|
+
mkdirSync,
|
|
5
|
+
mkdtempSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import {
|
|
13
|
+
createEventBus,
|
|
14
|
+
createExtensionRuntime,
|
|
15
|
+
ExtensionRunner,
|
|
16
|
+
SessionManager,
|
|
17
|
+
type ExtensionAPI,
|
|
18
|
+
type ExtensionUIContext,
|
|
19
|
+
} from "@earendil-works/pi-coding-agent";
|
|
20
|
+
import { loadExtensionFromFactory } from "../node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js";
|
|
21
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
22
|
+
import gentleAgents, {
|
|
23
|
+
type SessionTransportFactory,
|
|
24
|
+
} from "../extensions/gentle-agents.ts";
|
|
25
|
+
import { bindSessionRepositoryPreparation } from "../lib/bounded-writer-admission.ts";
|
|
26
|
+
import { SESSION_PROFILE_CUSTOM_TYPE } from "../lib/session-profile-persistence.ts";
|
|
27
|
+
import { publishSessionProfileOutcome, readSessionProfileAuthority } from "../lib/session-profile-authority.ts";
|
|
28
|
+
import { bindSessionProfile, readSessionProfileBinding, readSessionProfileStartupNone } from "../lib/session-profile-binding.ts";
|
|
29
|
+
import type { SessionProfileLifecycleManager } from "../lib/session-profile-integration.ts";
|
|
30
|
+
|
|
31
|
+
// Admission tests use actual factory loader/runner and manager. They do not
|
|
32
|
+
// claim runtime lifecycle or visual evidence: those are separate fixtures.
|
|
33
|
+
for (const order of ["agents-only", "agents-first", "owner-first"] as const)
|
|
34
|
+
for (const agent of ["explore", "worker"] as const)
|
|
35
|
+
test(`U3 unavailable authority blocks ${agent} admission before effects (${order})`, async (t) => {
|
|
36
|
+
const root = mkdtempSync(join(tmpdir(), "u3-admission-")),
|
|
37
|
+
home = join(root, "home");
|
|
38
|
+
const definitions = join(home, ".pi", "agent", "agents");
|
|
39
|
+
mkdirSync(definitions, { recursive: true });
|
|
40
|
+
for (const name of ["explore", "worker"])
|
|
41
|
+
writeFileSync(
|
|
42
|
+
join(definitions, `${name}.md`),
|
|
43
|
+
"---\ndescription: fixture\nmodel: openai/gpt-4o\ntools: [read]\n---\nOffline fixture",
|
|
44
|
+
);
|
|
45
|
+
const manager = SessionManager.create(root, join(root, "sessions"));
|
|
46
|
+
manager.appendMessage({ role: "user", content: "fixture", timestamp: 1 });
|
|
47
|
+
manager.appendCustomEntry("gentle-pi.session-profile/v99", {
|
|
48
|
+
kind: "future",
|
|
49
|
+
});
|
|
50
|
+
const initialDisk = readFileSync(manager.getSessionFile()!, "utf8");
|
|
51
|
+
const counts = { registry: 0, prepare: 0, child: 0, config: 0 };
|
|
52
|
+
const transport: SessionTransportFactory = {
|
|
53
|
+
createRegistry: async () => ({
|
|
54
|
+
list: async () => [],
|
|
55
|
+
listActivations: async () => [],
|
|
56
|
+
}),
|
|
57
|
+
createListener: (registry) => ({
|
|
58
|
+
registry,
|
|
59
|
+
start: async () => {},
|
|
60
|
+
close: async () => {},
|
|
61
|
+
}),
|
|
62
|
+
createClient: () => ({
|
|
63
|
+
close() {},
|
|
64
|
+
sendNotification: async () => {
|
|
65
|
+
throw Error("no messaging in fixture");
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
const runtime = createExtensionRuntime(),
|
|
70
|
+
bus = createEventBus();
|
|
71
|
+
const agentsFactory = (pi: ExtensionAPI) =>
|
|
72
|
+
gentleAgents(
|
|
73
|
+
pi,
|
|
74
|
+
{},
|
|
75
|
+
{
|
|
76
|
+
home,
|
|
77
|
+
agentHome: join(home, ".pi", "agent"),
|
|
78
|
+
env: { GENTLE_PI_CONFIG_HOME: join(root, "config") },
|
|
79
|
+
sessionTransport: transport,
|
|
80
|
+
schedule: () => () => {},
|
|
81
|
+
childExtensionPaths: [],
|
|
82
|
+
resolveWorktree: () => {
|
|
83
|
+
counts.registry++;
|
|
84
|
+
return undefined;
|
|
85
|
+
},
|
|
86
|
+
spawn: () => {
|
|
87
|
+
counts.child++;
|
|
88
|
+
throw Error("fixture forbids actual children");
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
const ownerFactory = createGentleAiExtension({
|
|
93
|
+
nativeReviewCli: null,
|
|
94
|
+
candidateViews: null,
|
|
95
|
+
processEnv: { GENTLE_PI_AGENTS_CHILD: "1" },
|
|
96
|
+
});
|
|
97
|
+
const factories =
|
|
98
|
+
order === "agents-only"
|
|
99
|
+
? [agentsFactory]
|
|
100
|
+
: order === "agents-first"
|
|
101
|
+
? [agentsFactory, ownerFactory]
|
|
102
|
+
: [ownerFactory, agentsFactory];
|
|
103
|
+
const extensions = [];
|
|
104
|
+
for (const factory of factories)
|
|
105
|
+
extensions.push(
|
|
106
|
+
await loadExtensionFromFactory(factory, root, bus, runtime),
|
|
107
|
+
);
|
|
108
|
+
const runner = new ExtensionRunner(extensions, runtime, root, manager, {
|
|
109
|
+
find: () => {
|
|
110
|
+
counts.config++;
|
|
111
|
+
return { provider: "openai", id: "gpt-4o" };
|
|
112
|
+
},
|
|
113
|
+
getAll: () => [],
|
|
114
|
+
} as never);
|
|
115
|
+
runner.setUIContext(
|
|
116
|
+
{
|
|
117
|
+
notify() {},
|
|
118
|
+
setStatus() {},
|
|
119
|
+
setWidget() {},
|
|
120
|
+
} as unknown as ExtensionUIContext,
|
|
121
|
+
"tui",
|
|
122
|
+
);
|
|
123
|
+
runner.bindCommandContext();
|
|
124
|
+
await runner.emit({ type: "session_start", reason: "startup" });
|
|
125
|
+
const unbind = bindSessionRepositoryPreparation(
|
|
126
|
+
manager,
|
|
127
|
+
root,
|
|
128
|
+
async () => {
|
|
129
|
+
counts.prepare++;
|
|
130
|
+
return false;
|
|
131
|
+
},
|
|
132
|
+
() => true,
|
|
133
|
+
);
|
|
134
|
+
t.after(async () => {
|
|
135
|
+
unbind();
|
|
136
|
+
await runner.emit({ type: "session_shutdown", reason: "quit" });
|
|
137
|
+
runner.invalidate();
|
|
138
|
+
rmSync(root, { recursive: true, force: true });
|
|
139
|
+
});
|
|
140
|
+
counts.registry = 0;
|
|
141
|
+
counts.config = 0;
|
|
142
|
+
const entries = manager.getEntries().length;
|
|
143
|
+
const tool = runner
|
|
144
|
+
.getAllRegisteredTools()
|
|
145
|
+
.find(({ definition }) => definition.name === "subagent_run")!.definition;
|
|
146
|
+
await assert.rejects(
|
|
147
|
+
tool.execute(
|
|
148
|
+
"unavailable",
|
|
149
|
+
{
|
|
150
|
+
agent,
|
|
151
|
+
task:
|
|
152
|
+
agent === "worker"
|
|
153
|
+
? "Implement\n## Allowed edit surfaces\nsrc/app.ts"
|
|
154
|
+
: "Map safely",
|
|
155
|
+
mode: "background",
|
|
156
|
+
} as never,
|
|
157
|
+
undefined,
|
|
158
|
+
undefined,
|
|
159
|
+
runner.createCommandContext() as never,
|
|
160
|
+
),
|
|
161
|
+
/session profile authority unavailable/i,
|
|
162
|
+
);
|
|
163
|
+
assert.deepEqual(
|
|
164
|
+
counts,
|
|
165
|
+
{ registry: 0, prepare: 0, child: 0, config: 0 },
|
|
166
|
+
"unavailable authority cannot silently fall through to shared routing",
|
|
167
|
+
);
|
|
168
|
+
assert.equal(
|
|
169
|
+
manager.getEntries().length,
|
|
170
|
+
entries,
|
|
171
|
+
"no queue/publication entries",
|
|
172
|
+
);
|
|
173
|
+
assert.equal(
|
|
174
|
+
readFileSync(manager.getSessionFile()!, "utf8"),
|
|
175
|
+
initialDisk,
|
|
176
|
+
"rejected data and disk remain unchanged",
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("U3 independently evaluated binding readers share only process-local snapshots", async () => {
|
|
181
|
+
const {
|
|
182
|
+
bindSessionProfile,
|
|
183
|
+
readSessionProfileBinding,
|
|
184
|
+
clearSessionProfileBinding,
|
|
185
|
+
} = await import("../lib/session-profile-binding.ts");
|
|
186
|
+
const moduleUrl = new URL(
|
|
187
|
+
"../lib/session-profile-binding.ts?u3-module-isolation",
|
|
188
|
+
import.meta.url,
|
|
189
|
+
).href;
|
|
190
|
+
const copy = (await import(
|
|
191
|
+
moduleUrl
|
|
192
|
+
)) as typeof import("../lib/session-profile-binding.ts");
|
|
193
|
+
const models = { worker: { model: "openai/gpt-4o" } };
|
|
194
|
+
bindSessionProfile("u3-module", "team", models);
|
|
195
|
+
models.worker.model = "changed";
|
|
196
|
+
assert.equal(
|
|
197
|
+
copy.readSessionProfileBinding("u3-module")?.modelProfiles.worker?.model,
|
|
198
|
+
"openai/gpt-4o",
|
|
199
|
+
);
|
|
200
|
+
const snapshot = copy.readSessionProfileBinding("u3-module")!;
|
|
201
|
+
snapshot.modelProfiles.worker.model = "changed-reader";
|
|
202
|
+
assert.equal(
|
|
203
|
+
readSessionProfileBinding("u3-module")?.modelProfiles.worker?.model,
|
|
204
|
+
"openai/gpt-4o",
|
|
205
|
+
);
|
|
206
|
+
clearSessionProfileBinding("u3-module");
|
|
207
|
+
assert.equal(copy.readSessionProfileBinding("u3-module"), undefined);
|
|
208
|
+
assert.equal(SESSION_PROFILE_CUSTOM_TYPE, "gentle-pi.session-profile/v1");
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Profile-less branches never depend on parsing the rest of the session file.
|
|
212
|
+
function savedProfileLessSession(t: test.TestContext) {
|
|
213
|
+
const root = mkdtempSync(join(tmpdir(), "u3-profileless-"));
|
|
214
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
215
|
+
const manager = SessionManager.create(root, join(root, "sessions"));
|
|
216
|
+
manager.appendMessage({ role: "user", content: "fixture", timestamp: 1 });
|
|
217
|
+
manager.appendMessage({ role: "assistant", content: [{ type: "text", text: "ok" }], api: "openai-completions", provider: "openai", model: "gpt-4o", usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } }, stopReason: "stop", timestamp: 2 } as never);
|
|
218
|
+
const file = manager.getSessionFile()!;
|
|
219
|
+
assert.ok(readFileSync(file, "utf8").length > 0, "fixture session is flushed");
|
|
220
|
+
return { manager, file };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
test("unrelated session-file corruption does not block a profile-less branch", (t) => {
|
|
224
|
+
const { manager, file } = savedProfileLessSession(t);
|
|
225
|
+
writeFileSync(file, `${readFileSync(file, "utf8")}{not json\n`);
|
|
226
|
+
assert.deepEqual(readSessionProfileAuthority(manager), { available: true });
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("a profile-less saved branch drops a binding left from another branch", (t) => {
|
|
230
|
+
const { manager } = savedProfileLessSession(t);
|
|
231
|
+
bindSessionProfile(manager.getSessionId(), "other-branch", { worker: { model: "openai/gpt-4o" } });
|
|
232
|
+
assert.deepEqual(readSessionProfileAuthority(manager), { available: true });
|
|
233
|
+
assert.equal(readSessionProfileBinding(manager.getSessionId()), undefined);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// A2 (gentle-shell#2742, section 4): the newest corroborated record publishes
|
|
237
|
+
// its origin and startup state, and a startup-none clear stays distinct from a
|
|
238
|
+
// legacy clear; each later record replaces it, as on /tree.
|
|
239
|
+
test("publishing keeps the record's origin and startup state, and the newest record replaces them", () => {
|
|
240
|
+
const manager = { getSessionId: () => "a2-publish" } as SessionProfileLifecycleManager;
|
|
241
|
+
const publish = (state: unknown) => publishSessionProfileOutcome(manager, { status: "persisted", state } as never);
|
|
242
|
+
const team = { worker: { model: "openai/gpt-5" }, orchestrator: { model: "openai/gpt-5" } };
|
|
243
|
+
const startup = publish({ status: "bound", binding: { kind: "bind", origin: "repo", name: "team", modelProfiles: team } });
|
|
244
|
+
assert.deepEqual(startup, { available: true, binding: { name: "team", origin: "repo", modelProfiles: team } });
|
|
245
|
+
const known = { origin: "global" as const, name: "team", modelProfiles: team };
|
|
246
|
+
publish({ status: "bound", binding: { kind: "bind", origin: "user", name: "fast", modelProfiles: team, startup: known } });
|
|
247
|
+
assert.deepEqual(readSessionProfileBinding("a2-publish")?.startup, known);
|
|
248
|
+
assert.deepEqual(publish({ status: "cleared", startup: "none" }), { available: true });
|
|
249
|
+
assert.equal(readSessionProfileBinding("a2-publish"), undefined);
|
|
250
|
+
assert.equal(readSessionProfileStartupNone("a2-publish"), true);
|
|
251
|
+
publish({ status: "cleared" });
|
|
252
|
+
assert.equal(readSessionProfileStartupNone("a2-publish"), false, "a legacy clear carries no startup state");
|
|
253
|
+
publish({ status: "cleared", startup: "none" });
|
|
254
|
+
publish({ status: "bound", binding: { kind: "bind", origin: "user", name: "fast", modelProfiles: team } });
|
|
255
|
+
assert.equal(readSessionProfileStartupNone("a2-publish"), false, "a newer bind wins");
|
|
256
|
+
publish({ status: "cleared", startup: "none" });
|
|
257
|
+
assert.deepEqual(publish({ status: "invalid" }), { available: false });
|
|
258
|
+
assert.equal(readSessionProfileStartupNone("a2-publish"), false, "an unreadable record keeps no startup state");
|
|
259
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
2
|
+
import test, { afterEach, beforeEach } from "node:test";
|
|
3
3
|
import type { AgentModelConfig } from "../lib/model-routing-authority.ts";
|
|
4
4
|
import {
|
|
5
5
|
bindSessionProfile,
|
|
@@ -9,6 +9,16 @@ import {
|
|
|
9
9
|
sessionOrPinModelProfiles,
|
|
10
10
|
} from "../lib/session-profile-binding.ts";
|
|
11
11
|
|
|
12
|
+
// Suite-level reset hooks guarantee pristine state on entry and reliable teardown
|
|
13
|
+
// on exit for every test in this focused file, protecting against mid-test exception leaks (#1768).
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
resetSessionProfileBindingsForTesting();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
resetSessionProfileBindingsForTesting();
|
|
20
|
+
});
|
|
21
|
+
|
|
12
22
|
const ROUTING: AgentModelConfig = {
|
|
13
23
|
worker: { model: "zai/glm-4.7", thinking: "medium" },
|
|
14
24
|
reviewer: { model: "openai/o4-mini" },
|
|
@@ -161,3 +171,26 @@ test("each entrypoint still hands out private copies of the shared store", (t) =
|
|
|
161
171
|
);
|
|
162
172
|
resetSessionProfileBindingsForTesting();
|
|
163
173
|
});
|
|
174
|
+
|
|
175
|
+
test("the store keeps a binding's origin and startup state as private copies", () => {
|
|
176
|
+
resetSessionProfileBindingsForTesting();
|
|
177
|
+
bindSessionProfile("session-a", "work", ROUTING);
|
|
178
|
+
assert.deepEqual(readSessionProfileBinding("session-a"), { name: "work", origin: "user", modelProfiles: ROUTING });
|
|
179
|
+
const startup = { origin: "repo" as const, name: "team", modelProfiles: ROUTING };
|
|
180
|
+
bindSessionProfile("session-b", "work", ROUTING, { startup });
|
|
181
|
+
bindSessionProfile("session-c", "team", ROUTING, { origin: "global" });
|
|
182
|
+
startup.modelProfiles = {};
|
|
183
|
+
const read = readSessionProfileBinding("session-b");
|
|
184
|
+
assert.deepEqual(read, { name: "work", origin: "user", modelProfiles: ROUTING, startup: { origin: "repo", name: "team", modelProfiles: ROUTING } });
|
|
185
|
+
if (typeof read?.startup === "object") read.startup.modelProfiles.worker!.model = "edited/model";
|
|
186
|
+
assert.deepEqual(readSessionProfileBinding("session-b")?.startup, { origin: "repo", name: "team", modelProfiles: ROUTING });
|
|
187
|
+
assert.deepEqual(readSessionProfileBinding("session-c"), { name: "team", origin: "global", modelProfiles: ROUTING });
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test("afterEach teardown cleans the binding store without manual in-test reset (#1768)", (t) => {
|
|
191
|
+
t.after(() => {
|
|
192
|
+
assert.equal(readSessionProfileBinding("session-teardown"), undefined, "store is cleaned after teardown");
|
|
193
|
+
});
|
|
194
|
+
bindSessionProfile("session-teardown", "work", ROUTING);
|
|
195
|
+
assert.equal(readSessionProfileBinding("session-teardown")?.name, "work");
|
|
196
|
+
});
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
readFileSync,
|
|
10
10
|
renameSync,
|
|
11
11
|
rmSync,
|
|
12
|
+
writeFileSync,
|
|
12
13
|
} from "node:fs";
|
|
13
14
|
import { tmpdir } from "node:os";
|
|
14
15
|
import { dirname, join } from "node:path";
|
|
@@ -26,10 +27,12 @@ const packagePath = join(
|
|
|
26
27
|
const version: string = JSON.parse(readFileSync(packagePath, "utf8")).version;
|
|
27
28
|
// Fail closed rather than silently skipping tests against stale feature deps.
|
|
28
29
|
assert.match(version, /^\d+\.\d+\.\d+$/);
|
|
30
|
+
const [major, minor] = version.split(".").map(Number);
|
|
29
31
|
assert.ok(
|
|
30
|
-
|
|
32
|
+
major >= 1,
|
|
31
33
|
`Pi >=1.0.0 required, installed ${version}`,
|
|
32
34
|
);
|
|
35
|
+
const rollsBackFailedAppend = major > 1 || (major === 1 && minor >= 5);
|
|
33
36
|
console.info(
|
|
34
37
|
`Public SessionManager fixture API: ${version}; minimum tested baseline 1.0.0`,
|
|
35
38
|
);
|
|
@@ -122,12 +125,16 @@ test("public selected branch, sibling and extracted session stay separated", (t)
|
|
|
122
125
|
});
|
|
123
126
|
|
|
124
127
|
for (const recovery of ["bind", "clear"] as const) {
|
|
125
|
-
test(`real EISDIR
|
|
128
|
+
test(`real EISDIR preserves corroboration; new ${recovery} survives a missing parent`, (t) => {
|
|
126
129
|
const { manager, sessions } = fixture(t);
|
|
127
130
|
manager.appendCustomEntry(customType, bind("good"));
|
|
128
131
|
flushFixture(manager);
|
|
129
132
|
const file = manager.getSessionFile();
|
|
130
133
|
assert.ok(file);
|
|
134
|
+
const original = readFileSync(file, "utf8");
|
|
135
|
+
const before = structuredClone(manager.getBranch());
|
|
136
|
+
const retained = manager.getLeafId();
|
|
137
|
+
assert.ok(retained);
|
|
131
138
|
const saved = `${file}.saved`;
|
|
132
139
|
renameSync(file, saved);
|
|
133
140
|
mkdirSync(file);
|
|
@@ -138,31 +145,52 @@ for (const recovery of ["bind", "clear"] as const) {
|
|
|
138
145
|
return true;
|
|
139
146
|
},
|
|
140
147
|
);
|
|
141
|
-
const
|
|
142
|
-
|
|
148
|
+
const after = manager.getBranch();
|
|
149
|
+
let failedLeaf = retained;
|
|
150
|
+
const knownFailedEntryIds = new Set<string>();
|
|
151
|
+
if (rollsBackFailedAppend) {
|
|
152
|
+
assert.deepEqual(after, before, "SDK rolls back the failed entry and leaf");
|
|
153
|
+
assert.equal(manager.getLeafId(), retained);
|
|
154
|
+
} else {
|
|
155
|
+
assert.equal(after.length, before.length + 1);
|
|
156
|
+
assert.deepEqual(after.slice(0, before.length), before);
|
|
157
|
+
const ghost = after.at(-1);
|
|
158
|
+
assert.ok(ghost);
|
|
159
|
+
assert.equal(ghost.type, "custom");
|
|
160
|
+
assert.equal(ghost.customType, customType);
|
|
161
|
+
assert.deepEqual(ghost.data, bind("failed"));
|
|
162
|
+
assert.equal(ghost.parentId, retained);
|
|
163
|
+
assert.ok(ghost.id);
|
|
164
|
+
assert.notEqual(ghost.id, retained);
|
|
165
|
+
assert.equal(manager.getLeafId(), ghost.id);
|
|
166
|
+
failedLeaf = ghost.id;
|
|
167
|
+
knownFailedEntryIds.add(ghost.id);
|
|
168
|
+
}
|
|
169
|
+
assert.equal(readFileSync(saved, "utf8"), original);
|
|
143
170
|
assert.equal(readSessionProfileDisk(manager).status, "indeterminate");
|
|
144
171
|
renameSync(file, `${file}.fault-directory`);
|
|
145
172
|
renameSync(saved, file);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
173
|
+
if (rollsBackFailedAppend) {
|
|
174
|
+
expectBound(manager, "good");
|
|
175
|
+
} else {
|
|
176
|
+
assert.deepEqual(readSessionProfileDisk(manager), { status: "indeterminate", reason: "selected-record-missing" });
|
|
177
|
+
const old = readSessionProfileDisk(manager, { knownFailedEntryIds });
|
|
178
|
+
assert.equal(old.status, "bound");
|
|
179
|
+
if (old.status === "bound") assert.equal(old.binding.name, "good");
|
|
180
|
+
}
|
|
151
181
|
manager.appendCustomEntry(
|
|
152
182
|
customType,
|
|
153
183
|
recovery === "bind" ? bind("recovered") : { kind: "clear" },
|
|
154
184
|
);
|
|
155
185
|
const latest = manager.getBranch().at(-1);
|
|
156
186
|
assert.ok(latest);
|
|
157
|
-
assert.equal(latest.parentId,
|
|
187
|
+
assert.equal(latest.parentId, failedLeaf);
|
|
158
188
|
const disk = readFileSync(file, "utf8")
|
|
159
189
|
.trim()
|
|
160
190
|
.split("\n")
|
|
161
191
|
.map((line) => JSON.parse(line));
|
|
162
|
-
assert.equal(
|
|
163
|
-
|
|
164
|
-
false,
|
|
165
|
-
);
|
|
192
|
+
assert.equal(disk.some((row) => row.id === retained), true);
|
|
193
|
+
if (!rollsBackFailedAppend) assert.equal(disk.some((row) => row.id === failedLeaf), false);
|
|
166
194
|
assert.deepEqual(
|
|
167
195
|
disk.find((row) => row.id === latest.id),
|
|
168
196
|
JSON.parse(JSON.stringify(latest)),
|
|
@@ -172,8 +200,22 @@ for (const recovery of ["bind", "clear"] as const) {
|
|
|
172
200
|
recovery === "bind" ? "bound" : "cleared",
|
|
173
201
|
);
|
|
174
202
|
const reopened = SessionManager.open(file, sessions);
|
|
175
|
-
|
|
176
|
-
|
|
203
|
+
if (rollsBackFailedAppend) {
|
|
204
|
+
assert.deepEqual(reopened.getBranch(), manager.getBranch());
|
|
205
|
+
// With rollback, use a separately damaged test-owned file for a disk gap.
|
|
206
|
+
const orphanFile = `${file}.orphan.jsonl`;
|
|
207
|
+
writeFileSync(orphanFile,
|
|
208
|
+
disk.filter((row) => row.id !== retained)
|
|
209
|
+
.map((row) => JSON.stringify(row)).join("\n") + "\n",
|
|
210
|
+
);
|
|
211
|
+
const orphan = SessionManager.open(orphanFile, sessions);
|
|
212
|
+
assert.deepEqual(orphan.getBranch(), [JSON.parse(JSON.stringify(latest))]);
|
|
213
|
+
assert.equal(readSessionProfileDisk(orphan).status, recovery === "bind" ? "bound" : "cleared");
|
|
214
|
+
if (recovery === "bind") expectBound(orphan, "recovered");
|
|
215
|
+
} else {
|
|
216
|
+
// The real failed parent is absent on disk; Pi reopens the recovered suffix.
|
|
217
|
+
assert.deepEqual(reopened.getBranch(), [JSON.parse(JSON.stringify(latest))]);
|
|
218
|
+
}
|
|
177
219
|
assert.equal(
|
|
178
220
|
readSessionProfileDisk(reopened).status,
|
|
179
221
|
recovery === "bind" ? "bound" : "cleared",
|