gsd-pi 2.71.0-dev.06b86c6 → 2.71.0-dev.246c32d
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 +34 -1
- package/dist/cli.js +17 -0
- package/dist/headless-events.d.ts +2 -0
- package/dist/headless-events.js +7 -0
- package/dist/headless.js +16 -3
- package/dist/mcp-server.js +37 -14
- package/dist/resource-loader.js +6 -3
- package/dist/resources/agents/debugger.md +58 -0
- package/dist/resources/agents/doc-writer.md +43 -0
- package/dist/resources/agents/git-ops.md +56 -0
- package/dist/resources/agents/javascript-pro.md +46 -271
- package/dist/resources/agents/planner.md +55 -0
- package/dist/resources/agents/refactorer.md +47 -0
- package/dist/resources/agents/reviewer.md +48 -0
- package/dist/resources/agents/security.md +59 -0
- package/dist/resources/agents/tester.md +50 -0
- package/dist/resources/agents/typescript-pro.md +41 -235
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +113 -10
- package/dist/resources/extensions/gsd/auto/infra-errors.js +34 -0
- package/dist/resources/extensions/gsd/auto/loop.js +32 -1
- package/dist/resources/extensions/gsd/auto/phases.js +5 -1
- package/dist/resources/extensions/gsd/auto/session.js +11 -0
- package/dist/resources/extensions/gsd/auto-dashboard.js +22 -16
- package/dist/resources/extensions/gsd/auto-model-selection.js +10 -2
- package/dist/resources/extensions/gsd/auto-prompts.js +88 -33
- package/dist/resources/extensions/gsd/auto-start.js +33 -6
- package/dist/resources/extensions/gsd/auto-worktree.js +1 -1
- package/dist/resources/extensions/gsd/auto.js +56 -0
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +3 -3
- package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +63 -51
- package/dist/resources/extensions/gsd/commands/handlers/auto.js +10 -33
- package/dist/resources/extensions/gsd/commands/handlers/core.js +56 -11
- package/dist/resources/extensions/gsd/commands/handlers/notifications-handler.js +15 -6
- package/dist/resources/extensions/gsd/commands/handlers/workflow.js +4 -10
- package/dist/resources/extensions/gsd/dashboard-overlay.js +8 -3
- package/dist/resources/extensions/gsd/doctor-providers.js +23 -0
- package/dist/resources/extensions/gsd/error-classifier.js +4 -1
- package/dist/resources/extensions/gsd/forensics.js +19 -6
- package/dist/resources/extensions/gsd/gate-registry.js +208 -0
- package/dist/resources/extensions/gsd/gsd-db.js +41 -0
- package/dist/resources/extensions/gsd/guided-flow.js +5 -10
- package/dist/resources/extensions/gsd/metrics.js +1 -0
- package/dist/resources/extensions/gsd/milestone-actions.js +10 -4
- package/dist/resources/extensions/gsd/milestone-validation-gates.js +11 -12
- package/dist/resources/extensions/gsd/notification-overlay.js +42 -13
- package/dist/resources/extensions/gsd/notification-store.js +35 -4
- package/dist/resources/extensions/gsd/notification-widget.js +5 -13
- package/dist/resources/extensions/gsd/parallel-monitor-overlay.js +8 -3
- package/dist/resources/extensions/gsd/prompt-validation.js +126 -0
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +3 -1
- package/dist/resources/extensions/gsd/prompts/execute-task.md +2 -0
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
- package/dist/resources/extensions/gsd/session-model-override.js +25 -0
- package/dist/resources/extensions/gsd/shortcut-defs.js +40 -0
- package/dist/resources/extensions/gsd/state.js +9 -2
- package/dist/resources/extensions/gsd/tools/complete-slice.js +52 -1
- package/dist/resources/extensions/gsd/tools/complete-task.js +51 -1
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +4 -1
- package/dist/resources/extensions/ollama/index.js +13 -5
- package/dist/resources/extensions/shared/gsd-phase-state.js +35 -0
- package/dist/resources/extensions/subagent/agents.js +8 -0
- package/dist/resources/extensions/subagent/index.js +17 -0
- package/dist/startup-model-validation.d.ts +0 -1
- package/dist/startup-model-validation.js +6 -2
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +17 -17
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/required-server-files.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +17 -17
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/server.js +1 -1
- package/package.json +1 -1
- package/packages/mcp-server/dist/server.d.ts +12 -1
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +90 -42
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +1 -1
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/src/server.ts +110 -38
- package/packages/mcp-server/src/workflow-tools.ts +1 -1
- package/packages/pi-ai/dist/providers/anthropic-auth.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/anthropic-auth.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js +20 -0
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/anthropic.d.ts +2 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +7 -4
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/src/providers/anthropic-auth.test.ts +32 -0
- package/packages/pi-ai/src/providers/anthropic.ts +8 -4
- package/packages/pi-coding-agent/dist/core/agent-session-renderable-tools.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/agent-session-renderable-tools.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/agent-session-renderable-tools.test.js +61 -0
- package/packages/pi-coding-agent/dist/core/agent-session-renderable-tools.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +2 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +10 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.js +27 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.test.js +85 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver-initial-model-auth.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-resolver-initial-model-auth.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver-initial-model-auth.test.js +64 -0
- package/packages/pi-coding-agent/dist/core/model-resolver-initial-model-auth.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.js +22 -18
- package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.test.d.ts +8 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.test.js +75 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.d.ts +5 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/retry-handler.js +55 -1
- package/packages/pi-coding-agent/dist/core/retry-handler.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/retry-handler.test.js +57 -0
- package/packages/pi-coding-agent/dist/core/retry-handler.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.d.ts +11 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +38 -5
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/sdk.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.test.js +71 -0
- package/packages/pi-coding-agent/dist/core/sdk.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js +1 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/login-dialog.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/login-dialog.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/login-dialog.test.js +13 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/login-dialog.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +4 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +24 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js +9 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +4 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +43 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +7 -2
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.js +6 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/model-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +4 -3
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +4 -2
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-renderable-tools.test.ts +70 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +2 -1
- package/packages/pi-coding-agent/src/core/auth-storage.test.ts +108 -0
- package/packages/pi-coding-agent/src/core/auth-storage.ts +30 -0
- package/packages/pi-coding-agent/src/core/model-resolver-initial-model-auth.test.ts +78 -0
- package/packages/pi-coding-agent/src/core/model-resolver.test.ts +85 -0
- package/packages/pi-coding-agent/src/core/model-resolver.ts +22 -18
- package/packages/pi-coding-agent/src/core/retry-handler.test.ts +83 -0
- package/packages/pi-coding-agent/src/core/retry-handler.ts +60 -1
- package/packages/pi-coding-agent/src/core/sdk.test.ts +89 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +45 -9
- package/packages/pi-coding-agent/src/index.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/login-dialog.test.ts +24 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +30 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +15 -6
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +47 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +7 -2
- package/packages/pi-coding-agent/src/modes/interactive/controllers/model-controller.ts +6 -1
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +4 -3
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +4 -2
- package/src/resources/agents/debugger.md +58 -0
- package/src/resources/agents/doc-writer.md +43 -0
- package/src/resources/agents/git-ops.md +56 -0
- package/src/resources/agents/javascript-pro.md +46 -271
- package/src/resources/agents/planner.md +55 -0
- package/src/resources/agents/refactorer.md +47 -0
- package/src/resources/agents/reviewer.md +48 -0
- package/src/resources/agents/security.md +59 -0
- package/src/resources/agents/tester.md +50 -0
- package/src/resources/agents/typescript-pro.md +41 -235
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +122 -8
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +189 -6
- package/src/resources/extensions/gsd/auto/infra-errors.ts +38 -0
- package/src/resources/extensions/gsd/auto/loop-deps.ts +2 -0
- package/src/resources/extensions/gsd/auto/loop.ts +45 -1
- package/src/resources/extensions/gsd/auto/phases.ts +6 -0
- package/src/resources/extensions/gsd/auto/session.ts +11 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +29 -18
- package/src/resources/extensions/gsd/auto-model-selection.ts +9 -1
- package/src/resources/extensions/gsd/auto-prompts.ts +111 -33
- package/src/resources/extensions/gsd/auto-start.ts +40 -6
- package/src/resources/extensions/gsd/auto-worktree.ts +1 -1
- package/src/resources/extensions/gsd/auto.ts +72 -0
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +3 -3
- package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +79 -60
- package/src/resources/extensions/gsd/commands/handlers/auto.ts +10 -36
- package/src/resources/extensions/gsd/commands/handlers/core.ts +58 -11
- package/src/resources/extensions/gsd/commands/handlers/notifications-handler.ts +17 -7
- package/src/resources/extensions/gsd/commands/handlers/workflow.ts +4 -10
- package/src/resources/extensions/gsd/dashboard-overlay.ts +10 -3
- package/src/resources/extensions/gsd/doctor-providers.ts +24 -0
- package/src/resources/extensions/gsd/error-classifier.ts +4 -1
- package/src/resources/extensions/gsd/forensics.ts +23 -7
- package/src/resources/extensions/gsd/gate-registry.ts +251 -0
- package/src/resources/extensions/gsd/gsd-db.ts +51 -0
- package/src/resources/extensions/gsd/guided-flow.ts +5 -10
- package/src/resources/extensions/gsd/interrupted-session.ts +1 -0
- package/src/resources/extensions/gsd/metrics.ts +12 -1
- package/src/resources/extensions/gsd/milestone-actions.ts +10 -3
- package/src/resources/extensions/gsd/milestone-validation-gates.ts +11 -13
- package/src/resources/extensions/gsd/notification-overlay.ts +47 -14
- package/src/resources/extensions/gsd/notification-store.ts +35 -4
- package/src/resources/extensions/gsd/notification-widget.ts +5 -14
- package/src/resources/extensions/gsd/parallel-monitor-overlay.ts +10 -3
- package/src/resources/extensions/gsd/prompt-validation.ts +157 -0
- package/src/resources/extensions/gsd/prompts/complete-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/execute-task.md +2 -0
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
- package/src/resources/extensions/gsd/session-model-override.ts +36 -0
- package/src/resources/extensions/gsd/shortcut-defs.ts +56 -0
- package/src/resources/extensions/gsd/state.ts +13 -2
- package/src/resources/extensions/gsd/tests/auto-start-model-capture.test.ts +25 -9
- package/src/resources/extensions/gsd/tests/complete-slice-gate-closure.test.ts +167 -0
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +36 -0
- package/src/resources/extensions/gsd/tests/forensics-stuck-loops.test.ts +62 -0
- package/src/resources/extensions/gsd/tests/format-shortcut.test.ts +31 -0
- package/src/resources/extensions/gsd/tests/gate-dispatch.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/gate-registry.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/infra-errors-cooldown.test.ts +180 -0
- package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +66 -1
- package/src/resources/extensions/gsd/tests/model-isolation.test.ts +36 -51
- package/src/resources/extensions/gsd/tests/notification-store.test.ts +18 -0
- package/src/resources/extensions/gsd/tests/notification-widget.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/notifications-handler.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/parallel-monitor-overlay.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/park-db-sync.test.ts +18 -0
- package/src/resources/extensions/gsd/tests/prompt-system-gate-coverage.test.ts +208 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/register-shortcuts.test.ts +63 -5
- package/src/resources/extensions/gsd/tests/session-model-override.test.ts +35 -0
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +90 -0
- package/src/resources/extensions/gsd/tools/complete-slice.ts +63 -0
- package/src/resources/extensions/gsd/tools/complete-task.ts +63 -0
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +4 -1
- package/src/resources/extensions/gsd/types.ts +26 -0
- package/src/resources/extensions/ollama/index.ts +13 -3
- package/src/resources/extensions/ollama/ollama-status-indicator.test.ts +28 -0
- package/src/resources/extensions/shared/gsd-phase-state.ts +42 -0
- package/src/resources/extensions/shared/tests/gsd-phase-state.test.ts +48 -0
- package/src/resources/extensions/subagent/agents.ts +10 -0
- package/src/resources/extensions/subagent/index.ts +18 -0
- package/src/resources/extensions/subagent/tests/agents-conflicts.test.ts +33 -0
- /package/dist/web/standalone/.next/static/{dYVdRaunb2ZSEA8fjkT-V → hnGGkVMxIGGpxSJkf5jIV}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{dYVdRaunb2ZSEA8fjkT-V → hnGGkVMxIGGpxSJkf5jIV}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* complete-slice gate closure integration test.
|
|
3
|
+
*
|
|
4
|
+
* Pins the fix for the Q8-stall bug: complete-slice must close every gate
|
|
5
|
+
* owned by the complete-slice turn based on the content of the matching
|
|
6
|
+
* CompleteSliceParams field. Without this, Q8 stays pending forever and
|
|
7
|
+
* blocks state derivation on subsequent loops.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, test, beforeEach, afterEach } from "node:test";
|
|
11
|
+
import assert from "node:assert/strict";
|
|
12
|
+
import * as fs from "node:fs";
|
|
13
|
+
import * as path from "node:path";
|
|
14
|
+
import * as os from "node:os";
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
openDatabase,
|
|
18
|
+
closeDatabase,
|
|
19
|
+
insertMilestone,
|
|
20
|
+
insertSlice,
|
|
21
|
+
insertTask,
|
|
22
|
+
insertGateRow,
|
|
23
|
+
getGateResults,
|
|
24
|
+
} from "../gsd-db.ts";
|
|
25
|
+
import { handleCompleteSlice } from "../tools/complete-slice.ts";
|
|
26
|
+
import type { CompleteSliceParams } from "../types.ts";
|
|
27
|
+
|
|
28
|
+
function makeValidSliceParams(overrides: Partial<CompleteSliceParams> = {}): CompleteSliceParams {
|
|
29
|
+
return {
|
|
30
|
+
sliceId: "S01",
|
|
31
|
+
milestoneId: "M001",
|
|
32
|
+
sliceTitle: "Test Slice",
|
|
33
|
+
oneLiner: "Implemented test slice",
|
|
34
|
+
narrative: "Built and tested.",
|
|
35
|
+
verification: "All tests pass.",
|
|
36
|
+
deviations: "None.",
|
|
37
|
+
knownLimitations: "None.",
|
|
38
|
+
followUps: "None.",
|
|
39
|
+
keyFiles: ["src/foo.ts"],
|
|
40
|
+
keyDecisions: [],
|
|
41
|
+
patternsEstablished: [],
|
|
42
|
+
observabilitySurfaces: [],
|
|
43
|
+
provides: [],
|
|
44
|
+
requirementsSurfaced: [],
|
|
45
|
+
drillDownPaths: [],
|
|
46
|
+
affects: [],
|
|
47
|
+
requirementsAdvanced: [],
|
|
48
|
+
requirementsValidated: [],
|
|
49
|
+
requirementsInvalidated: [],
|
|
50
|
+
filesModified: [],
|
|
51
|
+
requires: [],
|
|
52
|
+
uatContent: "## Smoke Test\n\nVerify happy path.",
|
|
53
|
+
...overrides,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
describe("complete-slice closes complete-slice-owned gates", () => {
|
|
58
|
+
let dbPath: string;
|
|
59
|
+
let basePath: string;
|
|
60
|
+
|
|
61
|
+
beforeEach(() => {
|
|
62
|
+
dbPath = path.join(
|
|
63
|
+
fs.mkdtempSync(path.join(os.tmpdir(), "gsd-slice-gate-")),
|
|
64
|
+
"test.db",
|
|
65
|
+
);
|
|
66
|
+
openDatabase(dbPath);
|
|
67
|
+
|
|
68
|
+
basePath = fs.mkdtempSync(path.join(os.tmpdir(), "gsd-slice-gate-handler-"));
|
|
69
|
+
const sliceDir = path.join(
|
|
70
|
+
basePath, ".gsd", "milestones", "M001", "slices", "S01", "tasks",
|
|
71
|
+
);
|
|
72
|
+
fs.mkdirSync(sliceDir, { recursive: true });
|
|
73
|
+
fs.writeFileSync(
|
|
74
|
+
path.join(basePath, ".gsd", "milestones", "M001", "M001-ROADMAP.md"),
|
|
75
|
+
[
|
|
76
|
+
"# M001: Test Milestone",
|
|
77
|
+
"",
|
|
78
|
+
"## Slices",
|
|
79
|
+
"",
|
|
80
|
+
'- [ ] **S01: Test Slice** `risk:medium` `depends:[]`',
|
|
81
|
+
" - After this: basic functionality works",
|
|
82
|
+
].join("\n"),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
insertMilestone({ id: "M001" });
|
|
86
|
+
insertSlice({ id: "S01", milestoneId: "M001" });
|
|
87
|
+
insertTask({
|
|
88
|
+
id: "T01", sliceId: "S01", milestoneId: "M001",
|
|
89
|
+
status: "complete", title: "Task 1",
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Seed Q8 as pending — this is what plan-slice does today.
|
|
93
|
+
insertGateRow({
|
|
94
|
+
milestoneId: "M001", sliceId: "S01",
|
|
95
|
+
gateId: "Q8", scope: "slice",
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
afterEach(() => {
|
|
100
|
+
closeDatabase();
|
|
101
|
+
fs.rmSync(path.dirname(dbPath), { recursive: true, force: true });
|
|
102
|
+
fs.rmSync(basePath, { recursive: true, force: true });
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("Q8 closes as 'pass' when operationalReadiness is populated", async () => {
|
|
106
|
+
const params = makeValidSliceParams({
|
|
107
|
+
operationalReadiness: [
|
|
108
|
+
"- Health signal: /health endpoint returns 200",
|
|
109
|
+
"- Failure signal: error rate alert in observability dashboard",
|
|
110
|
+
"- Recovery: systemd auto-restart",
|
|
111
|
+
].join("\n"),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const result = await handleCompleteSlice(params, basePath);
|
|
115
|
+
assert.ok(!("error" in result), `handler failed: ${(result as any).error}`);
|
|
116
|
+
|
|
117
|
+
const gates = getGateResults("M001", "S01", "slice");
|
|
118
|
+
const q8 = gates.find((g) => g.gate_id === "Q8");
|
|
119
|
+
assert.ok(q8, "Q8 row must exist after complete-slice");
|
|
120
|
+
assert.equal(q8.status, "complete");
|
|
121
|
+
assert.equal(q8.verdict, "pass");
|
|
122
|
+
assert.ok(
|
|
123
|
+
q8.findings.includes("Health signal"),
|
|
124
|
+
"Q8 findings must capture the operationalReadiness content",
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("Q8 closes as 'omitted' when operationalReadiness is empty", async () => {
|
|
129
|
+
const params = makeValidSliceParams({ operationalReadiness: "" });
|
|
130
|
+
|
|
131
|
+
const result = await handleCompleteSlice(params, basePath);
|
|
132
|
+
assert.ok(!("error" in result), `handler failed: ${(result as any).error}`);
|
|
133
|
+
|
|
134
|
+
const gates = getGateResults("M001", "S01", "slice");
|
|
135
|
+
const q8 = gates.find((g) => g.gate_id === "Q8");
|
|
136
|
+
assert.ok(q8, "Q8 row must exist after complete-slice");
|
|
137
|
+
assert.equal(q8.status, "complete");
|
|
138
|
+
assert.equal(q8.verdict, "omitted");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("Q8 also closes when operationalReadiness is omitted entirely", async () => {
|
|
142
|
+
// A model that doesn't pass operationalReadiness at all must still
|
|
143
|
+
// move Q8 out of 'pending' — leaving it pending produces the stall.
|
|
144
|
+
const params = makeValidSliceParams();
|
|
145
|
+
const result = await handleCompleteSlice(params, basePath);
|
|
146
|
+
assert.ok(!("error" in result), `handler failed: ${(result as any).error}`);
|
|
147
|
+
|
|
148
|
+
const gates = getGateResults("M001", "S01", "slice");
|
|
149
|
+
const q8 = gates.find((g) => g.gate_id === "Q8");
|
|
150
|
+
assert.ok(q8);
|
|
151
|
+
assert.notEqual(q8.status, "pending", "Q8 must never remain pending after complete-slice");
|
|
152
|
+
assert.equal(q8.verdict, "omitted");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("summary markdown contains Operational Readiness section", async () => {
|
|
156
|
+
const params = makeValidSliceParams({
|
|
157
|
+
operationalReadiness: "- Health signal: /health\n- Failure signal: alert",
|
|
158
|
+
});
|
|
159
|
+
const result = await handleCompleteSlice(params, basePath);
|
|
160
|
+
assert.ok(!("error" in result));
|
|
161
|
+
if (!("error" in result)) {
|
|
162
|
+
const summary = fs.readFileSync(result.summaryPath, "utf-8");
|
|
163
|
+
assert.match(summary, /^## Operational Readiness/m);
|
|
164
|
+
assert.match(summary, /Health signal: \/health/);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
@@ -574,6 +574,42 @@ test("runProviderChecks reports ok for OpenAI via openai-codex auth.json (#2922)
|
|
|
574
574
|
rmSync(tmpHome, { recursive: true, force: true });
|
|
575
575
|
});
|
|
576
576
|
|
|
577
|
+
test("runProviderChecks reports ok for claude-code without any API key", () => {
|
|
578
|
+
const repo = realpathSync(mkdtempSync(join(tmpdir(), "gsd-providers-cc-repo-")));
|
|
579
|
+
mkdirSync(join(repo, ".gsd"), { recursive: true });
|
|
580
|
+
writeFileSync(
|
|
581
|
+
join(repo, ".gsd", "PREFERENCES.md"),
|
|
582
|
+
[
|
|
583
|
+
"---",
|
|
584
|
+
"models:",
|
|
585
|
+
" execution:",
|
|
586
|
+
" model: claude-sonnet-4-6",
|
|
587
|
+
" provider: claude-code",
|
|
588
|
+
"---",
|
|
589
|
+
"",
|
|
590
|
+
].join("\n"),
|
|
591
|
+
);
|
|
592
|
+
|
|
593
|
+
const tmpHome = realpathSync(mkdtempSync(join(tmpdir(), "gsd-providers-cc-home-")));
|
|
594
|
+
|
|
595
|
+
withEnv({
|
|
596
|
+
HOME: tmpHome,
|
|
597
|
+
ANTHROPIC_API_KEY: undefined,
|
|
598
|
+
ANTHROPIC_OAUTH_TOKEN: undefined,
|
|
599
|
+
}, () => {
|
|
600
|
+
withCwd(repo, () => {
|
|
601
|
+
const results = runProviderChecks();
|
|
602
|
+
const cc = results.find(r => r.name === "claude-code");
|
|
603
|
+
assert.ok(cc, "claude-code result should exist");
|
|
604
|
+
assert.equal(cc!.status, "ok", "claude-code uses CLI auth — must be ok without API keys");
|
|
605
|
+
assert.ok(cc!.message.includes("CLI auth"), "should indicate CLI auth");
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
rmSync(repo, { recursive: true, force: true });
|
|
610
|
+
rmSync(tmpHome, { recursive: true, force: true });
|
|
611
|
+
});
|
|
612
|
+
|
|
577
613
|
test("PROVIDER_ROUTES includes google-gemini-cli as route for google (#2922)", async () => {
|
|
578
614
|
const { readFileSync: readFS } = await import("node:fs");
|
|
579
615
|
const { dirname: dirn, join: joinPath } = await import("node:path");
|
|
@@ -101,3 +101,65 @@ test("#1943 detectStuckLoops ignores watchdog duplicates but flags real re-dispa
|
|
|
101
101
|
assert.equal(anomalies.length, 1, `expected 1 anomaly (for the 3x dispatched task), got ${anomalies.length}`);
|
|
102
102
|
assert.ok(anomalies[0].summary.includes("3 times"));
|
|
103
103
|
});
|
|
104
|
+
|
|
105
|
+
test("#3760 detectStuckLoops ignores cross-session recovery re-dispatches", () => {
|
|
106
|
+
const anomalies: ForensicAnomaly[] = [];
|
|
107
|
+
|
|
108
|
+
const units: UnitMetrics[] = [
|
|
109
|
+
makeUnit({
|
|
110
|
+
type: "plan-slice",
|
|
111
|
+
id: "M001/S02",
|
|
112
|
+
startedAt: 1000,
|
|
113
|
+
finishedAt: 2000,
|
|
114
|
+
autoSessionKey: "session-a",
|
|
115
|
+
}),
|
|
116
|
+
makeUnit({
|
|
117
|
+
type: "plan-slice",
|
|
118
|
+
id: "M001/S02",
|
|
119
|
+
startedAt: 5000,
|
|
120
|
+
finishedAt: 6000,
|
|
121
|
+
autoSessionKey: "session-b",
|
|
122
|
+
}),
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
detectStuckLoops(units, anomalies);
|
|
126
|
+
|
|
127
|
+
assert.equal(anomalies.length, 0, "cross-session recovery should not be flagged as a stuck loop");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("#3760 detectStuckLoops still flags repeated dispatches within one auto session", () => {
|
|
131
|
+
const anomalies: ForensicAnomaly[] = [];
|
|
132
|
+
|
|
133
|
+
const units: UnitMetrics[] = [
|
|
134
|
+
makeUnit({
|
|
135
|
+
type: "complete-slice",
|
|
136
|
+
id: "M011/S02",
|
|
137
|
+
startedAt: 1000,
|
|
138
|
+
finishedAt: 2000,
|
|
139
|
+
autoSessionKey: "session-a",
|
|
140
|
+
}),
|
|
141
|
+
makeUnit({
|
|
142
|
+
type: "complete-slice",
|
|
143
|
+
id: "M011/S02",
|
|
144
|
+
startedAt: 5000,
|
|
145
|
+
finishedAt: 6000,
|
|
146
|
+
autoSessionKey: "session-a",
|
|
147
|
+
}),
|
|
148
|
+
makeUnit({
|
|
149
|
+
type: "complete-slice",
|
|
150
|
+
id: "M011/S02",
|
|
151
|
+
startedAt: 9000,
|
|
152
|
+
finishedAt: 10000,
|
|
153
|
+
autoSessionKey: "session-b",
|
|
154
|
+
}),
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
detectStuckLoops(units, anomalies);
|
|
158
|
+
|
|
159
|
+
assert.equal(anomalies.length, 1, "within-session retries should still be flagged");
|
|
160
|
+
assert.ok(anomalies[0].summary.includes("2 times"), `summary should reflect the worst same-session loop: ${anomalies[0].summary}`);
|
|
161
|
+
assert.ok(
|
|
162
|
+
anomalies[0].details.includes("Cross-session recovery runs are ignored"),
|
|
163
|
+
`details should explain the session-aware rule: ${anomalies[0].details}`,
|
|
164
|
+
);
|
|
165
|
+
});
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import test from 'node:test';
|
|
5
5
|
import assert from 'node:assert/strict';
|
|
6
6
|
import { formatShortcut } from '../files.ts';
|
|
7
|
+
import { formattedShortcutPair, primaryShortcutCombo, fallbackShortcutCombo } from '../shortcut-defs.ts';
|
|
7
8
|
|
|
8
9
|
// ─── formatShortcut renders per-platform shortcuts ──────────────────────
|
|
9
10
|
|
|
@@ -67,3 +68,33 @@ test('formatShortcut: passes through plain key names', () => {
|
|
|
67
68
|
assert.strictEqual(formatShortcut('Escape'), 'Escape');
|
|
68
69
|
assert.strictEqual(formatShortcut('Enter'), 'Enter');
|
|
69
70
|
});
|
|
71
|
+
|
|
72
|
+
test("shortcut-defs: exposes canonical dashboard combos", () => {
|
|
73
|
+
assert.equal(primaryShortcutCombo("dashboard"), "Ctrl+Alt+G");
|
|
74
|
+
assert.equal(fallbackShortcutCombo("dashboard"), "Ctrl+Shift+G");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("shortcut-defs: formats shortcut pair using platform symbols", () => {
|
|
78
|
+
const pair = formattedShortcutPair("notifications");
|
|
79
|
+
if (process.platform === "darwin") {
|
|
80
|
+
assert.equal(pair, "⌃⌥N / ⌃⇧N");
|
|
81
|
+
} else {
|
|
82
|
+
assert.equal(pair, "Ctrl+Alt+N / Ctrl+Shift+N");
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("shortcut-defs: parallel shortcut omits fallback (hasFallback: false)", () => {
|
|
87
|
+
const pair = formattedShortcutPair("parallel");
|
|
88
|
+
if (process.platform === "darwin") {
|
|
89
|
+
assert.equal(pair, "⌃⌥P", "parallel should only show primary combo");
|
|
90
|
+
} else {
|
|
91
|
+
assert.equal(pair, "Ctrl+Alt+P", "parallel should only show primary combo");
|
|
92
|
+
}
|
|
93
|
+
// Verify it does NOT contain the fallback separator
|
|
94
|
+
assert.ok(!pair.includes("/"), "parallel pair should not contain fallback separator");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("shortcut-defs: dashboard shortcut includes fallback (hasFallback: true)", () => {
|
|
98
|
+
const pair = formattedShortcutPair("dashboard");
|
|
99
|
+
assert.ok(pair.includes("/"), "dashboard pair should contain fallback separator");
|
|
100
|
+
});
|
|
@@ -186,4 +186,31 @@ describe("evaluating-gates phase", () => {
|
|
|
186
186
|
insertGateRow({ milestoneId: "M001", sliceId: "S01", gateId: "Q5", scope: "task", taskId: "T01" });
|
|
187
187
|
assert.equal(getPendingSliceGateCount("M001", "S01"), 1);
|
|
188
188
|
});
|
|
189
|
+
|
|
190
|
+
test("Q8 (owned by complete-slice) does not block evaluating-gates phase", async () => {
|
|
191
|
+
// Regression: Q8 is stored with scope:"slice" but owned by the
|
|
192
|
+
// complete-slice turn. Before the gate registry landed, deriveState
|
|
193
|
+
// counted Q8 as a blocker for evaluating-gates while the gate-evaluate
|
|
194
|
+
// prompt silently dropped Q8 — an unrecoverable stall. After the
|
|
195
|
+
// registry change, deriveState filters by owner turn, so Q8 never
|
|
196
|
+
// blocks evaluating-gates.
|
|
197
|
+
planSlice(tmpDir);
|
|
198
|
+
await renderPlanFromDb(tmpDir, "M001", "S01");
|
|
199
|
+
|
|
200
|
+
insertGateRow({ milestoneId: "M001", sliceId: "S01", gateId: "Q3", scope: "slice" });
|
|
201
|
+
insertGateRow({ milestoneId: "M001", sliceId: "S01", gateId: "Q4", scope: "slice" });
|
|
202
|
+
insertGateRow({ milestoneId: "M001", sliceId: "S01", gateId: "Q8", scope: "slice" });
|
|
203
|
+
|
|
204
|
+
saveGateResult({ milestoneId: "M001", sliceId: "S01", gateId: "Q3", verdict: "pass", rationale: "OK", findings: "" });
|
|
205
|
+
saveGateResult({ milestoneId: "M001", sliceId: "S01", gateId: "Q4", verdict: "omitted", rationale: "N/A", findings: "" });
|
|
206
|
+
// Q8 deliberately left pending — it's complete-slice's problem.
|
|
207
|
+
|
|
208
|
+
invalidateStateCache();
|
|
209
|
+
const state = await deriveState(tmpDir);
|
|
210
|
+
assert.equal(
|
|
211
|
+
state.phase,
|
|
212
|
+
"executing",
|
|
213
|
+
`pending Q8 must not stall evaluating-gates — got phase=${state.phase}`,
|
|
214
|
+
);
|
|
215
|
+
});
|
|
189
216
|
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate registry tests — enforce that every declared GateId has a registry
|
|
3
|
+
* entry, that every owner-turn bucket is non-empty, and that coverage
|
|
4
|
+
* assertions fail loudly instead of silently skipping unknown gates.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, test } from "node:test";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
GATE_REGISTRY,
|
|
12
|
+
assertGateCoverage,
|
|
13
|
+
getGateDefinition,
|
|
14
|
+
getGateIdsForTurn,
|
|
15
|
+
getGatesForTurn,
|
|
16
|
+
getOwnerTurn,
|
|
17
|
+
type OwnerTurn,
|
|
18
|
+
} from "../gate-registry.ts";
|
|
19
|
+
import type { GateId } from "../types.ts";
|
|
20
|
+
|
|
21
|
+
/** Authoritative list of GateIds as declared in types.ts. */
|
|
22
|
+
const ALL_GATE_IDS: readonly GateId[] = [
|
|
23
|
+
"Q3", "Q4", "Q5", "Q6", "Q7", "Q8",
|
|
24
|
+
"MV01", "MV02", "MV03", "MV04",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const ALL_OWNER_TURNS: readonly OwnerTurn[] = [
|
|
28
|
+
"gate-evaluate",
|
|
29
|
+
"execute-task",
|
|
30
|
+
"complete-slice",
|
|
31
|
+
"validate-milestone",
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
describe("gate-registry", () => {
|
|
35
|
+
test("every declared GateId has a registry entry", () => {
|
|
36
|
+
for (const id of ALL_GATE_IDS) {
|
|
37
|
+
const def = GATE_REGISTRY[id];
|
|
38
|
+
assert.ok(def, `missing registry entry for gate ${id}`);
|
|
39
|
+
assert.equal(def.id, id);
|
|
40
|
+
assert.ok(def.question.length > 0, `${id} missing question`);
|
|
41
|
+
assert.ok(def.guidance.length > 0, `${id} missing guidance`);
|
|
42
|
+
assert.ok(def.promptSection.length > 0, `${id} missing promptSection`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("registry contains no extra gate entries", () => {
|
|
47
|
+
const registryIds = new Set(Object.keys(GATE_REGISTRY));
|
|
48
|
+
const declaredIds = new Set<string>(ALL_GATE_IDS);
|
|
49
|
+
for (const id of registryIds) {
|
|
50
|
+
assert.ok(declaredIds.has(id), `registry has unknown gate ${id}`);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("every owner turn owns at least one gate", () => {
|
|
55
|
+
for (const turn of ALL_OWNER_TURNS) {
|
|
56
|
+
const gates = getGatesForTurn(turn);
|
|
57
|
+
assert.ok(
|
|
58
|
+
gates.length > 0,
|
|
59
|
+
`owner turn "${turn}" has no gates — likely a registry mistake`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("owner turn buckets are disjoint", () => {
|
|
65
|
+
const seen = new Set<string>();
|
|
66
|
+
for (const turn of ALL_OWNER_TURNS) {
|
|
67
|
+
for (const def of getGatesForTurn(turn)) {
|
|
68
|
+
assert.ok(!seen.has(def.id), `gate ${def.id} claimed by two turns`);
|
|
69
|
+
seen.add(def.id);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Every gate should appear in exactly one bucket.
|
|
73
|
+
assert.equal(seen.size, ALL_GATE_IDS.length);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("getOwnerTurn round-trips against GATE_REGISTRY", () => {
|
|
77
|
+
for (const id of ALL_GATE_IDS) {
|
|
78
|
+
const turn = getOwnerTurn(id);
|
|
79
|
+
const idsForTurn = getGateIdsForTurn(turn);
|
|
80
|
+
assert.ok(idsForTurn.has(id), `${id} not in ${turn} bucket`);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("getGateDefinition returns undefined for unknown ids", () => {
|
|
85
|
+
assert.equal(getGateDefinition("Q99"), undefined);
|
|
86
|
+
assert.equal(getGateDefinition("not-a-gate"), undefined);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("assertGateCoverage", () => {
|
|
91
|
+
test("throws when a row is owned by a different turn", () => {
|
|
92
|
+
// Q8 is owned by complete-slice, not gate-evaluate — this used to be
|
|
93
|
+
// silently dropped by the old `if (!meta) continue;` filter, causing
|
|
94
|
+
// the evaluating-gates phase to stall.
|
|
95
|
+
assert.throws(
|
|
96
|
+
() => assertGateCoverage([{ gate_id: "Q8" }], "gate-evaluate"),
|
|
97
|
+
(err: Error) =>
|
|
98
|
+
err.message.includes("Q8") && err.message.includes("gate-evaluate"),
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("throws when a row has an unknown gate id", () => {
|
|
103
|
+
assert.throws(
|
|
104
|
+
() => assertGateCoverage([{ gate_id: "Q999" as GateId }], "gate-evaluate", { requireAll: false }),
|
|
105
|
+
(err: Error) => err.message.includes("Q999"),
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("throws when requireAll is true and an owned gate is missing", () => {
|
|
110
|
+
// gate-evaluate owns Q3 and Q4. Passing only Q3 should fail.
|
|
111
|
+
assert.throws(
|
|
112
|
+
() => assertGateCoverage([{ gate_id: "Q3" }], "gate-evaluate", { requireAll: true }),
|
|
113
|
+
(err: Error) => err.message.includes("Q4"),
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("passes when requireAll is false and only a subset is pending", () => {
|
|
118
|
+
// execute-task owns Q5/Q6/Q7, but a task with no external dependencies
|
|
119
|
+
// may only have Q7 seeded. That's still valid coverage.
|
|
120
|
+
assert.doesNotThrow(() =>
|
|
121
|
+
assertGateCoverage([{ gate_id: "Q7" }], "execute-task", { requireAll: false }),
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test("passes when requireAll is true and every owned gate is pending", () => {
|
|
126
|
+
assert.doesNotThrow(() =>
|
|
127
|
+
assertGateCoverage(
|
|
128
|
+
[{ gate_id: "Q3" }, { gate_id: "Q4" }],
|
|
129
|
+
"gate-evaluate",
|
|
130
|
+
{ requireAll: true },
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("empty pending list passes when requireAll is false", () => {
|
|
136
|
+
assert.doesNotThrow(() =>
|
|
137
|
+
assertGateCoverage([], "complete-slice", { requireAll: false }),
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// gsd / infra-errors cooldown detection tests
|
|
2
|
+
// Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
|
|
3
|
+
|
|
4
|
+
import test, { describe } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
isTransientCooldownError,
|
|
9
|
+
getCooldownRetryAfterMs,
|
|
10
|
+
MAX_COOLDOWN_RETRIES,
|
|
11
|
+
COOLDOWN_FALLBACK_WAIT_MS,
|
|
12
|
+
} from "../auto/infra-errors.js";
|
|
13
|
+
|
|
14
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
describe("infra-errors cooldown constants", () => {
|
|
17
|
+
test("COOLDOWN_FALLBACK_WAIT_MS is a positive number greater than the 30s rate-limit backoff", () => {
|
|
18
|
+
assert.ok(typeof COOLDOWN_FALLBACK_WAIT_MS === "number");
|
|
19
|
+
assert.ok(COOLDOWN_FALLBACK_WAIT_MS > 30_000, "should exceed the 30s rate-limit window");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("MAX_COOLDOWN_RETRIES is a positive integer", () => {
|
|
23
|
+
assert.ok(typeof MAX_COOLDOWN_RETRIES === "number");
|
|
24
|
+
assert.ok(Number.isInteger(MAX_COOLDOWN_RETRIES));
|
|
25
|
+
assert.ok(MAX_COOLDOWN_RETRIES > 0);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("COOLDOWN_FALLBACK_WAIT_MS is 35_000", () => {
|
|
29
|
+
assert.equal(COOLDOWN_FALLBACK_WAIT_MS, 35_000);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("MAX_COOLDOWN_RETRIES is 5", () => {
|
|
33
|
+
assert.equal(MAX_COOLDOWN_RETRIES, 5);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ─── isTransientCooldownError: structured detection ──────────────────────────
|
|
38
|
+
|
|
39
|
+
describe("isTransientCooldownError — structured code detection", () => {
|
|
40
|
+
test("returns true for an object with code === AUTH_COOLDOWN", () => {
|
|
41
|
+
const err = { code: "AUTH_COOLDOWN", message: "credentials in cooldown" };
|
|
42
|
+
assert.equal(isTransientCooldownError(err), true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("returns true for a real CredentialCooldownError-shaped error", () => {
|
|
46
|
+
// Simulate CredentialCooldownError without importing sdk.ts (leaf-module rule)
|
|
47
|
+
const err = Object.assign(new Error('All credentials for "anthropic" are in a cooldown window.'), {
|
|
48
|
+
code: "AUTH_COOLDOWN",
|
|
49
|
+
retryAfterMs: 30_000,
|
|
50
|
+
name: "CredentialCooldownError",
|
|
51
|
+
});
|
|
52
|
+
assert.equal(isTransientCooldownError(err), true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("returns false for an object with a different code", () => {
|
|
56
|
+
const err = { code: "ENOSPC", message: "disk full" };
|
|
57
|
+
assert.equal(isTransientCooldownError(err), false);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("returns false for an object with no code property", () => {
|
|
61
|
+
const err = { message: "some random error" };
|
|
62
|
+
assert.equal(isTransientCooldownError(err), false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// ─── isTransientCooldownError: message fallback ───────────────────────────────
|
|
67
|
+
|
|
68
|
+
describe("isTransientCooldownError — message fallback (cross-process)", () => {
|
|
69
|
+
test("returns true when message contains 'in a cooldown window'", () => {
|
|
70
|
+
const err = new Error('All credentials for "openai" are in a cooldown window. Please wait.');
|
|
71
|
+
assert.equal(isTransientCooldownError(err), true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("returns true when message matches case-insensitively", () => {
|
|
75
|
+
const err = new Error("credentials IN A COOLDOWN WINDOW");
|
|
76
|
+
assert.equal(isTransientCooldownError(err), true);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("returns true for a plain string containing cooldown window phrase", () => {
|
|
80
|
+
assert.equal(isTransientCooldownError("all keys in a cooldown window"), true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("returns false for a generic error message", () => {
|
|
84
|
+
const err = new Error("rate limit exceeded");
|
|
85
|
+
assert.equal(isTransientCooldownError(err), false);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("returns false for an error message about auth failure without cooldown phrase", () => {
|
|
89
|
+
const err = new Error("Authentication failed: invalid API key");
|
|
90
|
+
assert.equal(isTransientCooldownError(err), false);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// ─── isTransientCooldownError: edge cases ────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
describe("isTransientCooldownError — edge cases", () => {
|
|
97
|
+
test("returns false for null", () => {
|
|
98
|
+
assert.equal(isTransientCooldownError(null), false);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("returns false for undefined", () => {
|
|
102
|
+
assert.equal(isTransientCooldownError(undefined), false);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("returns false for a number", () => {
|
|
106
|
+
assert.equal(isTransientCooldownError(42), false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("returns false for an empty object", () => {
|
|
110
|
+
assert.equal(isTransientCooldownError({}), false);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("returns false for an object with code === AUTH_COOLDOWN as a non-string", () => {
|
|
114
|
+
// code must be a string matching "AUTH_COOLDOWN" exactly
|
|
115
|
+
const err = { code: 42 };
|
|
116
|
+
assert.equal(isTransientCooldownError(err), false);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// ─── getCooldownRetryAfterMs: structured extraction ──────────────────────────
|
|
121
|
+
|
|
122
|
+
describe("getCooldownRetryAfterMs — structured extraction", () => {
|
|
123
|
+
test("returns retryAfterMs when code is AUTH_COOLDOWN and retryAfterMs is set", () => {
|
|
124
|
+
const err = { code: "AUTH_COOLDOWN", retryAfterMs: 30_000 };
|
|
125
|
+
assert.equal(getCooldownRetryAfterMs(err), 30_000);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("returns undefined when code is AUTH_COOLDOWN but retryAfterMs is absent", () => {
|
|
129
|
+
const err = { code: "AUTH_COOLDOWN" };
|
|
130
|
+
assert.equal(getCooldownRetryAfterMs(err), undefined);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("returns 0 when retryAfterMs is explicitly 0", () => {
|
|
134
|
+
const err = { code: "AUTH_COOLDOWN", retryAfterMs: 0 };
|
|
135
|
+
assert.equal(getCooldownRetryAfterMs(err), 0);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("returns undefined for an error with a different code even if retryAfterMs is set", () => {
|
|
139
|
+
const err = { code: "ENOSPC", retryAfterMs: 5_000 };
|
|
140
|
+
assert.equal(getCooldownRetryAfterMs(err), undefined);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("returns undefined for a plain Error with no code property", () => {
|
|
144
|
+
const err = new Error("something went wrong");
|
|
145
|
+
assert.equal(getCooldownRetryAfterMs(err), undefined);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test("returns retryAfterMs from a full CredentialCooldownError-shaped object", () => {
|
|
149
|
+
const err = Object.assign(new Error('All credentials for "anthropic" are in a cooldown window.'), {
|
|
150
|
+
code: "AUTH_COOLDOWN",
|
|
151
|
+
retryAfterMs: 15_000,
|
|
152
|
+
name: "CredentialCooldownError",
|
|
153
|
+
});
|
|
154
|
+
assert.equal(getCooldownRetryAfterMs(err), 15_000);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// ─── getCooldownRetryAfterMs: edge cases ─────────────────────────────────────
|
|
159
|
+
|
|
160
|
+
describe("getCooldownRetryAfterMs — edge cases", () => {
|
|
161
|
+
test("returns undefined for null", () => {
|
|
162
|
+
assert.equal(getCooldownRetryAfterMs(null), undefined);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test("returns undefined for undefined", () => {
|
|
166
|
+
assert.equal(getCooldownRetryAfterMs(undefined), undefined);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("returns undefined for a plain string", () => {
|
|
170
|
+
assert.equal(getCooldownRetryAfterMs("AUTH_COOLDOWN"), undefined);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("returns undefined for an empty object", () => {
|
|
174
|
+
assert.equal(getCooldownRetryAfterMs({}), undefined);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("returns undefined for a number", () => {
|
|
178
|
+
assert.equal(getCooldownRetryAfterMs(42), undefined);
|
|
179
|
+
});
|
|
180
|
+
});
|