@opengsd/gsd-pi 1.2.0-dev.9ad8ae33 → 1.2.0-dev.a6376d75
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/dist/cli-model-override.d.ts +15 -0
- package/dist/cli-model-override.js +21 -0
- package/dist/cli.js +1 -18
- package/dist/loader.js +6 -4
- package/dist/register-agent-bundles.d.ts +11 -2
- package/dist/register-agent-bundles.js +18 -4
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/ask-user-questions.js +3 -2
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +447 -215
- package/dist/resources/extensions/claude-code-cli/turn-assembler.js +33 -1
- package/dist/resources/extensions/gsd/auto/closeout.js +215 -0
- package/dist/resources/extensions/gsd/auto/dispatch-history.js +21 -6
- package/dist/resources/extensions/gsd/auto/dispatch.js +365 -0
- package/dist/resources/extensions/gsd/auto/finalize.js +347 -0
- package/dist/resources/extensions/gsd/auto/loop.js +4 -1
- package/dist/resources/extensions/gsd/auto/milestone-lease-reclaim.js +56 -0
- package/dist/resources/extensions/gsd/auto/orchestrator.js +85 -15
- package/dist/resources/extensions/gsd/auto/phase-helpers.js +146 -0
- package/dist/resources/extensions/gsd/auto/phases.js +17 -2372
- package/dist/resources/extensions/gsd/auto/pre-dispatch.js +534 -0
- package/dist/resources/extensions/gsd/auto/unit-phase.js +694 -0
- package/dist/resources/extensions/gsd/auto/workflow-unit-dispatch.js +1 -1
- package/dist/resources/extensions/gsd/auto/worktree-safety-phase.js +125 -0
- package/dist/resources/extensions/gsd/auto-worktree.js +1 -1
- package/dist/resources/extensions/gsd/auto.js +15 -1
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +37 -7
- package/dist/resources/extensions/gsd/commands-mcp-status.js +2 -2
- package/dist/resources/extensions/gsd/commands-workflow-templates.js +9 -2
- package/dist/resources/extensions/gsd/db/queries.js +30 -0
- package/dist/resources/extensions/gsd/doctor-environment.js +256 -125
- package/dist/resources/extensions/gsd/guided-flow.js +88 -2
- package/dist/resources/extensions/gsd/health-widget.js +87 -28
- package/dist/resources/extensions/gsd/mcp-bridge.js +10 -0
- package/dist/resources/extensions/gsd/milestone-settlement.js +2 -2
- package/dist/resources/extensions/gsd/notifications.js +12 -7
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/execute-task.md +2 -1
- package/dist/resources/extensions/gsd/prompts/run-uat.md +2 -0
- package/dist/resources/extensions/gsd/prompts/workflow-start.md +2 -1
- package/dist/resources/extensions/gsd/skill-activation.js +3 -6
- package/dist/resources/extensions/gsd/state.js +6 -2
- package/dist/resources/extensions/gsd/tool-surface-readiness.js +83 -31
- package/dist/resources/extensions/gsd/tools/complete-task.js +62 -0
- package/dist/resources/extensions/gsd/unit-context-composer.js +1 -1
- package/dist/resources/extensions/gsd/unit-registry.js +34 -4
- package/dist/resources/extensions/gsd/workflow-mcp-auto-prep.js +2 -0
- package/dist/resources/extensions/gsd/workflow-mcp-readiness-cache.js +105 -0
- package/dist/resources/extensions/gsd/worktree-safety.js +28 -26
- package/dist/resources/extensions/mcp-client/manager.js +6 -1
- package/dist/runtime-checks.d.ts +10 -0
- package/dist/runtime-checks.js +27 -0
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +8 -8
- 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/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 +8 -8
- 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/package.json +2 -2
- package/packages/cloud-mcp-gateway/package.json +2 -2
- package/packages/contracts/package.json +1 -1
- package/packages/daemon/package.json +4 -4
- package/packages/gsd-agent-core/dist/sdk.d.ts.map +1 -1
- package/packages/gsd-agent-core/dist/sdk.js +6 -4
- package/packages/gsd-agent-core/dist/sdk.js.map +1 -1
- package/packages/gsd-agent-core/package.json +5 -5
- package/packages/gsd-agent-modes/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/settings-selector.js +10 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts +8 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js +50 -6
- package/packages/gsd-agent-modes/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.d.ts +2 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.js +34 -5
- package/packages/gsd-agent-modes/dist/modes/interactive/components/transcript-design.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.js +12 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-settings.d.ts.map +1 -1
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-settings.js +4 -0
- package/packages/gsd-agent-modes/dist/modes/interactive/interactive-selectors-settings.js.map +1 -1
- package/packages/gsd-agent-modes/package.json +7 -7
- package/packages/mcp-server/README.md +12 -3
- package/packages/mcp-server/dist/cli-runner.d.ts +40 -0
- package/packages/mcp-server/dist/cli-runner.d.ts.map +1 -0
- package/packages/mcp-server/dist/cli-runner.js +137 -0
- package/packages/mcp-server/dist/cli-runner.js.map +1 -0
- package/packages/mcp-server/dist/cli.js +2 -58
- package/packages/mcp-server/dist/cli.js.map +1 -1
- package/packages/mcp-server/dist/pid-registry.d.ts +46 -0
- package/packages/mcp-server/dist/pid-registry.d.ts.map +1 -0
- package/packages/mcp-server/dist/pid-registry.js +452 -0
- package/packages/mcp-server/dist/pid-registry.js.map +1 -0
- package/packages/mcp-server/dist/probe-mode.d.ts +4 -0
- package/packages/mcp-server/dist/probe-mode.d.ts.map +1 -0
- package/packages/mcp-server/dist/probe-mode.js +10 -0
- package/packages/mcp-server/dist/probe-mode.js.map +1 -0
- package/packages/mcp-server/dist/stdio-watchdog.d.ts +8 -0
- package/packages/mcp-server/dist/stdio-watchdog.d.ts.map +1 -0
- package/packages/mcp-server/dist/stdio-watchdog.js +40 -0
- package/packages/mcp-server/dist/stdio-watchdog.js.map +1 -0
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +62 -43
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +5 -5
- package/packages/native/package.json +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +43 -2
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +3 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +11 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/theme/theme.js +45 -17
- package/packages/pi-coding-agent/dist/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/package.json +7 -7
- package/packages/pi-tui/dist/index.d.ts +1 -1
- package/packages/pi-tui/dist/index.d.ts.map +1 -1
- package/packages/pi-tui/dist/index.js +1 -1
- package/packages/pi-tui/dist/index.js.map +1 -1
- package/packages/pi-tui/dist/terminal-image.d.ts +33 -0
- package/packages/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/packages/pi-tui/dist/terminal-image.js +54 -2
- package/packages/pi-tui/dist/terminal-image.js.map +1 -1
- package/packages/pi-tui/dist/tui.d.ts +8 -0
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +63 -18
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/dist/utils.d.ts.map +1 -1
- package/packages/pi-tui/dist/utils.js +110 -36
- package/packages/pi-tui/dist/utils.js.map +1 -1
- package/packages/pi-tui/package.json +2 -2
- package/packages/rpc-client/package.json +2 -2
- package/pkg/dist/theme/theme.d.ts.map +1 -1
- package/pkg/dist/theme/theme.js +45 -17
- package/pkg/dist/theme/theme.js.map +1 -1
- package/pkg/package.json +1 -1
- package/src/resources/extensions/ask-user-questions.ts +7 -2
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +531 -226
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +672 -7
- package/src/resources/extensions/claude-code-cli/turn-assembler.ts +38 -1
- package/src/resources/extensions/gsd/auto/closeout.ts +309 -0
- package/src/resources/extensions/gsd/auto/dispatch-history.ts +22 -6
- package/src/resources/extensions/gsd/auto/dispatch.ts +449 -0
- package/src/resources/extensions/gsd/auto/finalize.ts +445 -0
- package/src/resources/extensions/gsd/auto/loop.ts +4 -1
- package/src/resources/extensions/gsd/auto/milestone-lease-reclaim.ts +74 -0
- package/src/resources/extensions/gsd/auto/orchestrator.ts +95 -15
- package/src/resources/extensions/gsd/auto/phase-helpers.ts +199 -0
- package/src/resources/extensions/gsd/auto/phases.ts +58 -3061
- package/src/resources/extensions/gsd/auto/pre-dispatch.ts +704 -0
- package/src/resources/extensions/gsd/auto/unit-phase.ts +910 -0
- package/src/resources/extensions/gsd/auto/workflow-unit-dispatch.ts +1 -1
- package/src/resources/extensions/gsd/auto/worktree-safety-phase.ts +149 -0
- package/src/resources/extensions/gsd/auto-worktree.ts +1 -1
- package/src/resources/extensions/gsd/auto.ts +20 -1
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +56 -6
- package/src/resources/extensions/gsd/commands-mcp-status.ts +2 -2
- package/src/resources/extensions/gsd/commands-workflow-templates.ts +11 -4
- package/src/resources/extensions/gsd/db/queries.ts +29 -0
- package/src/resources/extensions/gsd/doctor-environment.ts +267 -142
- package/src/resources/extensions/gsd/guided-flow.ts +128 -2
- package/src/resources/extensions/gsd/health-widget.ts +91 -27
- package/src/resources/extensions/gsd/mcp-bridge.ts +39 -0
- package/src/resources/extensions/gsd/milestone-settlement.ts +2 -2
- package/src/resources/extensions/gsd/notifications.ts +13 -6
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/execute-task.md +2 -1
- package/src/resources/extensions/gsd/prompts/run-uat.md +2 -0
- package/src/resources/extensions/gsd/prompts/workflow-start.md +2 -1
- package/src/resources/extensions/gsd/skill-activation.ts +3 -6
- package/src/resources/extensions/gsd/state.ts +7 -1
- package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/auto-blocked-remediation-message.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +206 -22
- package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +76 -12
- package/src/resources/extensions/gsd/tests/auto-pause-double-entry-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/auto-paused-ui-cleanup.test.ts +77 -1
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +2 -1
- package/src/resources/extensions/gsd/tests/auto-unit-closeout.test.ts +169 -1
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +141 -5
- package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +2 -1
- package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +36 -0
- package/src/resources/extensions/gsd/tests/dispatch-history.test.ts +55 -0
- package/src/resources/extensions/gsd/tests/dist-redirect.mjs +8 -0
- package/src/resources/extensions/gsd/tests/engine-interfaces-contract.test.ts +117 -91
- package/src/resources/extensions/gsd/tests/ensure-db-open.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/guided-dispatch-root.test.ts +16 -0
- package/src/resources/extensions/gsd/tests/integration/auto-worktree.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/integration/doctor-environment-async.test.ts +104 -0
- package/src/resources/extensions/gsd/tests/integration/run-uat.test.ts +18 -0
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +47 -16
- package/src/resources/extensions/gsd/tests/mcp-readiness-preflight.test.ts +205 -0
- package/src/resources/extensions/gsd/tests/mcp-status.test.ts +6 -5
- package/src/resources/extensions/gsd/tests/milestone-merge-stash-restore.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/milestone-report-path.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/milestone-settlement.test.ts +92 -0
- package/src/resources/extensions/gsd/tests/milestone-transition-state-rebuild.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/notifications.test.ts +64 -9
- package/src/resources/extensions/gsd/tests/parallel-skill-prompt-integration.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/parsers-legacy-importers.test.ts +5 -0
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/phases-terminal-complete-idempotent.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/plan-gate-failed-doctor-heal-hint.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +10 -2
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +2 -4
- package/src/resources/extensions/gsd/tests/remote-notification-from-desktop.test.ts +31 -81
- package/src/resources/extensions/gsd/tests/runtime-invariant-modules.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/skill-activation.test.ts +20 -17
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +7 -3
- package/src/resources/extensions/gsd/tests/stop-auto-race-null-unit.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +4 -2
- package/src/resources/extensions/gsd/tests/tool-surface-readiness.test.ts +184 -10
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/workflow-mcp-readiness-cache.test.ts +119 -0
- package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +65 -2
- package/src/resources/extensions/gsd/tests/workflow-phase-contract-matrix.test.ts +332 -0
- package/src/resources/extensions/gsd/tests/workflow-templates.test.ts +92 -0
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/worktree-project-root-degrade.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/worktree-safety-phase.test.ts +100 -0
- package/src/resources/extensions/gsd/tests/worktree-safety.test.ts +72 -0
- package/src/resources/extensions/gsd/tool-surface-readiness.ts +126 -19
- package/src/resources/extensions/gsd/tools/complete-task.ts +87 -0
- package/src/resources/extensions/gsd/unit-context-composer.ts +1 -1
- package/src/resources/extensions/gsd/unit-registry.ts +34 -4
- package/src/resources/extensions/gsd/workflow-mcp-auto-prep.ts +2 -0
- package/src/resources/extensions/gsd/workflow-mcp-readiness-cache.ts +150 -0
- package/src/resources/extensions/gsd/worktree-safety.ts +41 -39
- package/src/resources/extensions/mcp-client/manager.ts +7 -1
- /package/dist/web/standalone/.next/static/{FBNo5cT_chy7YNoAQsU3o → xyMkEaICFHJoa98VgJyzY}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{FBNo5cT_chy7YNoAQsU3o → xyMkEaICFHJoa98VgJyzY}/_ssgManifest.js +0 -0
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
// Project/App: gsd-pi
|
|
2
2
|
// File Purpose: Regression tests for auto-unit closeout activity classification.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { mkdtempSync, writeFileSync, rmSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { execSync } from "node:child_process";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import test, { type TestContext } from "node:test";
|
|
5
9
|
import assert from "node:assert/strict";
|
|
6
10
|
|
|
7
11
|
import {
|
|
8
12
|
isSuspiciousGhostCompletion,
|
|
9
13
|
snapshotUnitActivity,
|
|
10
14
|
} from "../auto-unit-closeout.ts";
|
|
15
|
+
import {
|
|
16
|
+
closeUnit,
|
|
17
|
+
type UnitCloseoutRequest,
|
|
18
|
+
type UnitCloseoutDeps,
|
|
19
|
+
} from "../unit-closeout.ts";
|
|
20
|
+
import type { NotifySeverity } from "../notification-store.js";
|
|
11
21
|
|
|
12
22
|
function makeCtx(entries: unknown[]) {
|
|
13
23
|
return {
|
|
@@ -17,6 +27,38 @@ function makeCtx(entries: unknown[]) {
|
|
|
17
27
|
} as any;
|
|
18
28
|
}
|
|
19
29
|
|
|
30
|
+
function createTempGitRepo(t: TestContext): string {
|
|
31
|
+
const dir = mkdtempSync(join(tmpdir(), "closeout-test-"));
|
|
32
|
+
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
33
|
+
execSync("git init", { cwd: dir });
|
|
34
|
+
execSync("git config user.email test@test.com", { cwd: dir });
|
|
35
|
+
execSync("git config user.name Test", { cwd: dir });
|
|
36
|
+
return dir;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function makeMockDeps(overrides: Partial<UnitCloseoutDeps> = {}): UnitCloseoutDeps & { notifications: Array<{ message: string; severity: NotifySeverity }> } {
|
|
40
|
+
const notifications: Array<{ message: string; severity: NotifySeverity }> = [];
|
|
41
|
+
return {
|
|
42
|
+
isolationMode: () => "none",
|
|
43
|
+
currentBranch: () => "main",
|
|
44
|
+
commit: () => null,
|
|
45
|
+
notify: (message, severity) => notifications.push({ message, severity }),
|
|
46
|
+
notifications,
|
|
47
|
+
...overrides,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function baseRequest(overrides: Partial<UnitCloseoutRequest> = {}): UnitCloseoutRequest {
|
|
52
|
+
return {
|
|
53
|
+
basePath: "/tmp/ignored",
|
|
54
|
+
unitType: "complete-milestone",
|
|
55
|
+
unitId: "M001",
|
|
56
|
+
boundary: "milestone",
|
|
57
|
+
outcome: "complete",
|
|
58
|
+
...overrides,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
20
62
|
test("isSuspiciousGhostCompletion rejects fast completions with no assistant output or tools", () => {
|
|
21
63
|
const startedAt = Date.now();
|
|
22
64
|
const ctx = makeCtx([]);
|
|
@@ -66,3 +108,129 @@ test("snapshotUnitActivity counts assistant messages and tool calls", () => {
|
|
|
66
108
|
assistantMessages: 1,
|
|
67
109
|
});
|
|
68
110
|
});
|
|
111
|
+
|
|
112
|
+
test("closeUnit: nothing-to-commit / isolation none", (t) => {
|
|
113
|
+
const dir = createTempGitRepo(t);
|
|
114
|
+
const deps = makeMockDeps({
|
|
115
|
+
isolationMode: () => "none",
|
|
116
|
+
commit: () => null,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const result = closeUnit(baseRequest({ basePath: dir, boundary: "milestone" }), deps);
|
|
120
|
+
|
|
121
|
+
assert.equal(result.gitVerdict, "nothing-to-commit");
|
|
122
|
+
assert.equal(result.commitMessage, null);
|
|
123
|
+
assert.equal(result.notice, undefined);
|
|
124
|
+
assert.equal(deps.notifications.length, 0);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("closeUnit: committed / isolation none", (t) => {
|
|
128
|
+
const dir = createTempGitRepo(t);
|
|
129
|
+
writeFileSync(join(dir, "file.txt"), "hello");
|
|
130
|
+
execSync("git add file.txt", { cwd: dir });
|
|
131
|
+
|
|
132
|
+
const deps = makeMockDeps({
|
|
133
|
+
isolationMode: () => "none",
|
|
134
|
+
commit: () => "Add file.txt",
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const result = closeUnit(baseRequest({ basePath: dir, boundary: "milestone" }), deps);
|
|
138
|
+
|
|
139
|
+
assert.equal(result.gitVerdict, "committed");
|
|
140
|
+
assert.equal(result.commitMessage, "Add file.txt");
|
|
141
|
+
assert.equal(result.notice, undefined);
|
|
142
|
+
assert.equal(deps.notifications.length, 0);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test("closeUnit: milestone-branch / worktree isolation", (t) => {
|
|
146
|
+
const dir = createTempGitRepo(t);
|
|
147
|
+
const deps = makeMockDeps({
|
|
148
|
+
isolationMode: () => "worktree",
|
|
149
|
+
currentBranch: () => "milestone/M001",
|
|
150
|
+
commit: () => "Complete M001",
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const result = closeUnit(baseRequest({ basePath: dir, boundary: "milestone" }), deps);
|
|
154
|
+
|
|
155
|
+
assert.equal(result.gitVerdict, "milestone-branch");
|
|
156
|
+
assert.equal(result.commitMessage, "Complete M001");
|
|
157
|
+
assert.ok(result.notice);
|
|
158
|
+
assert.equal(deps.notifications.length, 1);
|
|
159
|
+
assert.equal(deps.notifications[0].severity, "info");
|
|
160
|
+
assert.match(deps.notifications[0].message, /Merge it to the integration branch/);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("closeUnit: isolation-bypassed / worktree isolation", (t) => {
|
|
164
|
+
const dir = createTempGitRepo(t);
|
|
165
|
+
const deps = makeMockDeps({
|
|
166
|
+
isolationMode: () => "worktree",
|
|
167
|
+
currentBranch: () => "main",
|
|
168
|
+
commit: () => "Complete M001",
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const result = closeUnit(baseRequest({ basePath: dir, boundary: "milestone" }), deps);
|
|
172
|
+
|
|
173
|
+
assert.equal(result.gitVerdict, "isolation-bypassed");
|
|
174
|
+
assert.equal(result.commitMessage, "Complete M001");
|
|
175
|
+
assert.ok(result.notice);
|
|
176
|
+
assert.equal(deps.notifications.length, 1);
|
|
177
|
+
assert.equal(deps.notifications[0].severity, "warning");
|
|
178
|
+
assert.match(deps.notifications[0].message, /completed outside a milestone worktree\/branch/);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("closeUnit: isolation-bypassed / branch isolation", (t) => {
|
|
182
|
+
const dir = createTempGitRepo(t);
|
|
183
|
+
const deps = makeMockDeps({
|
|
184
|
+
isolationMode: () => "branch",
|
|
185
|
+
currentBranch: () => "main",
|
|
186
|
+
commit: () => "Complete M001",
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const result = closeUnit(baseRequest({ basePath: dir, boundary: "milestone" }), deps);
|
|
190
|
+
|
|
191
|
+
assert.equal(result.gitVerdict, "isolation-bypassed");
|
|
192
|
+
assert.equal(result.commitMessage, "Complete M001");
|
|
193
|
+
assert.ok(result.notice);
|
|
194
|
+
assert.equal(deps.notifications.length, 1);
|
|
195
|
+
assert.equal(deps.notifications[0].severity, "warning");
|
|
196
|
+
assert.match(deps.notifications[0].message, /completed outside a milestone worktree\/branch/);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("closeUnit: commit-failed", (t) => {
|
|
200
|
+
const dir = createTempGitRepo(t);
|
|
201
|
+
const deps = makeMockDeps({
|
|
202
|
+
isolationMode: () => "none",
|
|
203
|
+
commit: () => {
|
|
204
|
+
throw new Error("simulated commit failure");
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const result = closeUnit(baseRequest({ basePath: dir, boundary: "milestone" }), deps);
|
|
209
|
+
|
|
210
|
+
assert.equal(result.gitVerdict, "commit-failed");
|
|
211
|
+
assert.equal(result.commitMessage, null);
|
|
212
|
+
assert.ok(result.notice);
|
|
213
|
+
assert.match(result.notice!, /simulated commit failure/);
|
|
214
|
+
assert.equal(deps.notifications.length, 1);
|
|
215
|
+
assert.equal(deps.notifications[0].severity, "error");
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("closeUnit: task boundary ignores isolation verdict", (t) => {
|
|
219
|
+
const dir = createTempGitRepo(t);
|
|
220
|
+
const deps = makeMockDeps({
|
|
221
|
+
isolationMode: () => "worktree",
|
|
222
|
+
currentBranch: () => "main",
|
|
223
|
+
commit: () => "Complete task",
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const result = closeUnit(
|
|
227
|
+
baseRequest({ basePath: dir, boundary: "task", unitType: "execute-task", unitId: "M001/S01/T01" }),
|
|
228
|
+
deps,
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
assert.equal(result.gitVerdict, "committed");
|
|
232
|
+
assert.equal(result.commitMessage, "Complete task");
|
|
233
|
+
assert.equal(result.notice, undefined);
|
|
234
|
+
assert.equal(deps.notifications.length, 0);
|
|
235
|
+
});
|
|
236
|
+
|
|
@@ -80,6 +80,20 @@ function createTempProject(): { basePath: string; planPath: string } {
|
|
|
80
80
|
return { basePath, planPath };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
function writeProjectPreferences(basePath: string, yaml: string): void {
|
|
84
|
+
fs.writeFileSync(path.join(basePath, '.gsd', 'PREFERENCES.md'), `---\n${yaml}---\n`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function withWorkingDirectory<T>(cwd: string, action: () => Promise<T>): Promise<T> {
|
|
88
|
+
const previousCwd = process.cwd();
|
|
89
|
+
process.chdir(cwd);
|
|
90
|
+
try {
|
|
91
|
+
return await action();
|
|
92
|
+
} finally {
|
|
93
|
+
process.chdir(previousCwd);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
83
97
|
function makeValidParams() {
|
|
84
98
|
return {
|
|
85
99
|
taskId: 'T01',
|
|
@@ -104,6 +118,13 @@ function makeValidParams() {
|
|
|
104
118
|
};
|
|
105
119
|
}
|
|
106
120
|
|
|
121
|
+
function makeEscalationOptions() {
|
|
122
|
+
return [
|
|
123
|
+
{ id: 'continue', label: 'Continue', tradeoffs: 'Keeps execution moving with the default path.' },
|
|
124
|
+
{ id: 'pause', label: 'Pause', tradeoffs: 'Stops execution until the blocker is reviewed.' },
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
108
129
|
// complete-task: Fresh DB is migrated to the current schema version
|
|
109
130
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -359,6 +380,105 @@ console.log('\n=== complete-task: handler happy path ===');
|
|
|
359
380
|
cleanup(dbPath);
|
|
360
381
|
}
|
|
361
382
|
|
|
383
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
384
|
+
// complete-task: hard-blocker escalation with mid-execution escalation disabled
|
|
385
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
386
|
+
|
|
387
|
+
console.log('\n=== complete-task: disabled hard-blocker escalation rolls back completion ===');
|
|
388
|
+
{
|
|
389
|
+
const dbPath = tempDbPath();
|
|
390
|
+
openDatabase(dbPath);
|
|
391
|
+
|
|
392
|
+
const { basePath } = createTempProject();
|
|
393
|
+
writeProjectPreferences(basePath, 'phases:\n mid_execution_escalation: false\n');
|
|
394
|
+
|
|
395
|
+
insertMilestone({ id: 'M001', title: 'Test Milestone' });
|
|
396
|
+
insertSlice({ id: 'S01', milestoneId: 'M001', title: 'Test Slice' });
|
|
397
|
+
|
|
398
|
+
const params = {
|
|
399
|
+
...makeValidParams(),
|
|
400
|
+
blockerDiscovered: true,
|
|
401
|
+
escalation: {
|
|
402
|
+
question: 'Should execution pause for the hard blocker?',
|
|
403
|
+
options: makeEscalationOptions(),
|
|
404
|
+
recommendation: 'pause',
|
|
405
|
+
recommendationRationale: 'The blocker should not be silently advanced.',
|
|
406
|
+
continueWithDefault: false,
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
const result = await withWorkingDirectory(basePath, () => handleCompleteTask(params, basePath));
|
|
411
|
+
|
|
412
|
+
assertTrue('error' in result, 'hard-blocker escalation should fail when escalation handling is disabled');
|
|
413
|
+
if ('error' in result) {
|
|
414
|
+
assertMatch(result.error, /hard-blocker escalation/, 'error should mention hard-blocker escalation');
|
|
415
|
+
assertMatch(result.error, /mid_execution_escalation is disabled/, 'error should mention disabled preference');
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const task = getTask('M001', 'S01', 'T01');
|
|
419
|
+
assertTrue(task !== null, 'task row should remain after rollback');
|
|
420
|
+
assertEq(task!.status, 'pending', 'task status should be rolled back to pending');
|
|
421
|
+
assertEq(task!.blocker_discovered, true, 'blocker flag should remain recorded for visibility');
|
|
422
|
+
assertEq(task!.escalation_pending, 0, 'disabled preference should not create a pending escalation flag');
|
|
423
|
+
assertEq(task!.escalation_awaiting_review, 0, 'disabled preference should not create an awaiting-review flag');
|
|
424
|
+
|
|
425
|
+
const adapter = _getAdapter()!;
|
|
426
|
+
const evRows = adapter.prepare(
|
|
427
|
+
"SELECT * FROM verification_evidence WHERE task_id = 'T01' AND slice_id = 'S01' AND milestone_id = 'M001'"
|
|
428
|
+
).all();
|
|
429
|
+
assertEq(evRows.length, 0, 'verification evidence should be deleted when completion rolls back');
|
|
430
|
+
|
|
431
|
+
cleanupDir(basePath);
|
|
432
|
+
cleanup(dbPath);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
436
|
+
// complete-task: soft escalation with mid-execution escalation disabled
|
|
437
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
438
|
+
|
|
439
|
+
console.log('\n=== complete-task: disabled soft escalation still completes ===');
|
|
440
|
+
{
|
|
441
|
+
const dbPath = tempDbPath();
|
|
442
|
+
openDatabase(dbPath);
|
|
443
|
+
|
|
444
|
+
const { basePath } = createTempProject();
|
|
445
|
+
writeProjectPreferences(basePath, 'phases:\n mid_execution_escalation: false\n');
|
|
446
|
+
|
|
447
|
+
insertMilestone({ id: 'M001', title: 'Test Milestone' });
|
|
448
|
+
insertSlice({ id: 'S01', milestoneId: 'M001', title: 'Test Slice' });
|
|
449
|
+
|
|
450
|
+
const params = {
|
|
451
|
+
...makeValidParams(),
|
|
452
|
+
escalation: {
|
|
453
|
+
question: 'Should execution continue with the default?',
|
|
454
|
+
options: makeEscalationOptions(),
|
|
455
|
+
recommendation: 'continue',
|
|
456
|
+
recommendationRationale: 'The default path is safe enough to continue.',
|
|
457
|
+
continueWithDefault: true,
|
|
458
|
+
},
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
const result = await withWorkingDirectory(basePath, () => handleCompleteTask(params, basePath));
|
|
462
|
+
|
|
463
|
+
assertTrue(!('error' in result), 'soft escalation should still complete when escalation handling is disabled');
|
|
464
|
+
if (!('error' in result)) {
|
|
465
|
+
assertTrue(!result.escalation, 'disabled preference should not return escalation metadata');
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
const task = getTask('M001', 'S01', 'T01');
|
|
469
|
+
assertTrue(task !== null, 'task row should exist');
|
|
470
|
+
assertEq(task!.status, 'complete', 'soft escalation should leave task complete');
|
|
471
|
+
|
|
472
|
+
const adapter = _getAdapter()!;
|
|
473
|
+
const evRows = adapter.prepare(
|
|
474
|
+
"SELECT * FROM verification_evidence WHERE task_id = 'T01' AND slice_id = 'S01' AND milestone_id = 'M001'"
|
|
475
|
+
).all();
|
|
476
|
+
assertEq(evRows.length, 1, 'verification evidence should remain for soft escalation completion');
|
|
477
|
+
|
|
478
|
+
cleanupDir(basePath);
|
|
479
|
+
cleanup(dbPath);
|
|
480
|
+
}
|
|
481
|
+
|
|
362
482
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
363
483
|
// complete-task: Handler validation errors
|
|
364
484
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -414,6 +534,9 @@ console.log('\n=== complete-task: handler idempotency ===');
|
|
|
414
534
|
// First call should succeed
|
|
415
535
|
const r1 = await handleCompleteTask(params, basePath);
|
|
416
536
|
assertTrue(!('error' in r1), 'first call should succeed');
|
|
537
|
+
if ('error' in r1) {
|
|
538
|
+
throw new Error(r1.error);
|
|
539
|
+
}
|
|
417
540
|
|
|
418
541
|
// Verify complete-task did not duplicate T01. S01-PLAN.md is a projection,
|
|
419
542
|
// so the remaining plan task is not imported implicitly.
|
|
@@ -421,16 +544,29 @@ console.log('\n=== complete-task: handler idempotency ===');
|
|
|
421
544
|
assertEq(tasks.length, 1, 'should only have the completed DB task after first call');
|
|
422
545
|
assertEq(tasks.filter(t => t.id === 'T01').length, 1, 'should have exactly one T01 row after first call');
|
|
423
546
|
|
|
424
|
-
//
|
|
547
|
+
// If the DB row is complete but the projection was lost, the duplicate call
|
|
548
|
+
// should repair the missing summary from full_summary_md instead of forcing a
|
|
549
|
+
// reopen/re-complete loop.
|
|
550
|
+
fs.unlinkSync(r1.summaryPath);
|
|
551
|
+
assertTrue(!fs.existsSync(r1.summaryPath), 'fixture should remove the task summary before repair');
|
|
425
552
|
const r2 = await handleCompleteTask(params, basePath);
|
|
426
|
-
assertTrue('error' in r2, 'second call should
|
|
553
|
+
assertTrue(!('error' in r2), 'second call should repair missing summary for DB-complete task');
|
|
427
554
|
if ('error' in r2) {
|
|
428
|
-
|
|
555
|
+
throw new Error(r2.error);
|
|
556
|
+
}
|
|
557
|
+
assertTrue(fs.existsSync(r2.summaryPath), 'missing summary should be restored on disk');
|
|
558
|
+
assertEq(r2.duplicate, true, 'repair should be reported as a duplicate/no-op state mutation');
|
|
559
|
+
|
|
560
|
+
// Third call with the summary present — state machine guard rejects (task is already complete)
|
|
561
|
+
const r3 = await handleCompleteTask(params, basePath);
|
|
562
|
+
assertTrue('error' in r3, 'third call should return error (task already complete)');
|
|
563
|
+
if ('error' in r3) {
|
|
564
|
+
assertMatch(r3.error, /already complete/, 'error should mention already complete');
|
|
429
565
|
}
|
|
430
566
|
|
|
431
|
-
// Still no duplicate rows from the rejected
|
|
567
|
+
// Still no duplicate rows from the repair or rejected third call.
|
|
432
568
|
const tasksAfter = getSliceTasks('M001', 'S01');
|
|
433
|
-
assertEq(tasksAfter.length, 1, 'should still only have T01 after rejected
|
|
569
|
+
assertEq(tasksAfter.length, 1, 'should still only have T01 after duplicate repair and rejected third call');
|
|
434
570
|
assertEq(tasksAfter.filter(t => t.id === 'T01').length, 1, 'should still have exactly one T01 row');
|
|
435
571
|
|
|
436
572
|
cleanupDir(basePath);
|
|
@@ -6,7 +6,8 @@ import { tmpdir } from "node:os";
|
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
8
|
|
|
9
|
-
import { runDispatch
|
|
9
|
+
import { runDispatch } from "../auto/dispatch.ts";
|
|
10
|
+
import { runPreDispatch } from "../auto/pre-dispatch.ts";
|
|
10
11
|
import { AutoSession } from "../auto/session.ts";
|
|
11
12
|
import { resolveUnitSupervisionTimeouts } from "../auto-timers.ts";
|
|
12
13
|
import { bootstrapAutoSession } from "../auto-start.ts";
|
|
@@ -569,6 +569,42 @@ describe('derive-state-helpers', () => {
|
|
|
569
569
|
}
|
|
570
570
|
});
|
|
571
571
|
|
|
572
|
+
// ─── Batch slice query: multi-milestone slices loaded in one query ─────
|
|
573
|
+
test('buildRegistryAndFindActive: batched slice query preserves ordering across milestones', async () => {
|
|
574
|
+
const base = createFixtureBase();
|
|
575
|
+
try {
|
|
576
|
+
// M001 is complete so the loop advances past it.
|
|
577
|
+
writeFile(base, 'milestones/M001/M001-ROADMAP.md', ROADMAP_CONTENT);
|
|
578
|
+
writeFile(base, 'milestones/M001/M001-SUMMARY.md', '# M001 Summary\n\nDone.');
|
|
579
|
+
// M002 is a queued shell milestone with no context and no slices — should be deferred.
|
|
580
|
+
mkdirSync(join(base, '.gsd', 'milestones', 'M002'), { recursive: true });
|
|
581
|
+
// M003 is the real active milestone with slices in non-trivial sequence order.
|
|
582
|
+
writeFile(base, 'milestones/M003/M003-CONTEXT.md', '# M003: Real\n\nReal milestone.');
|
|
583
|
+
|
|
584
|
+
openDatabase(':memory:');
|
|
585
|
+
insertMilestone({ id: 'M001', title: 'Complete', status: 'complete' });
|
|
586
|
+
insertMilestone({ id: 'M002', title: 'Shell', status: 'queued' });
|
|
587
|
+
insertMilestone({ id: 'M003', title: 'Real', status: 'active' });
|
|
588
|
+
// Slices intentionally inserted with out-of-order sequences to prove ordering.
|
|
589
|
+
insertSlice({ id: 'S01', milestoneId: 'M001', title: 'M1 Second', status: 'complete', risk: 'low', depends: [], sequence: 2 });
|
|
590
|
+
insertSlice({ id: 'S02', milestoneId: 'M001', title: 'M1 First', status: 'complete', risk: 'low', depends: [], sequence: 1 });
|
|
591
|
+
insertSlice({ id: 'S03', milestoneId: 'M003', title: 'M3 Second', status: 'active', risk: 'low', depends: [], sequence: 5 });
|
|
592
|
+
insertSlice({ id: 'S04', milestoneId: 'M003', title: 'M3 First', status: 'active', risk: 'low', depends: [], sequence: 3 });
|
|
593
|
+
|
|
594
|
+
invalidateStateCache();
|
|
595
|
+
const state = await deriveStateFromDb(base);
|
|
596
|
+
|
|
597
|
+
assert.equal(state.activeMilestone?.id, 'M003', 'batched: M003 is active after complete M001 and shell M002');
|
|
598
|
+
assert.equal(state.activeSlice?.id, 'S04', 'batched: first slice by sequence is active');
|
|
599
|
+
assert.equal(state.registry.find(e => e.id === 'M001')?.status, 'complete', 'batched: M001 complete');
|
|
600
|
+
assert.equal(state.registry.find(e => e.id === 'M002')?.status, 'pending', 'batched: shell M002 deferred to pending');
|
|
601
|
+
assert.equal(state.registry.find(e => e.id === 'M003')?.status, 'active', 'batched: M003 active');
|
|
602
|
+
} finally {
|
|
603
|
+
closeDatabase();
|
|
604
|
+
cleanup(base);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
572
608
|
// ─── Deferred queued shell: shell milestone deferred, real one promoted ──
|
|
573
609
|
test('buildRegistryAndFindActive: queued shell deferred, later real milestone becomes active (#3470)', async () => {
|
|
574
610
|
const base = createFixtureBase();
|
|
@@ -23,6 +23,7 @@ import { recordDispatchClaim, markFailed, markCanceled } from "../db/unit-dispat
|
|
|
23
23
|
import {
|
|
24
24
|
buildDispatchKey,
|
|
25
25
|
createDispatchHistory,
|
|
26
|
+
lookupLatestLedgerError,
|
|
26
27
|
normalizeDispatchKey,
|
|
27
28
|
parseDispatchKey,
|
|
28
29
|
STUCK_WINDOW_SIZE,
|
|
@@ -157,6 +158,31 @@ test("recordDispatch attaches the latest ledger error on repeats so repeat-error
|
|
|
157
158
|
assert.match(verdict?.reason ?? "", /Same error repeated/);
|
|
158
159
|
});
|
|
159
160
|
|
|
161
|
+
test("lookupLatestLedgerError matches the bare unit id, not the compound key", (t) => {
|
|
162
|
+
const f = makeLedgerFixture(t);
|
|
163
|
+
const dispatchId = f.claim("execute-task", "M001/S01/T01");
|
|
164
|
+
markFailed(dispatchId, { errorSummary: "boom: deterministic failure" });
|
|
165
|
+
|
|
166
|
+
// The ledger keys rows by the bare unit id with the unit type in its own
|
|
167
|
+
// column. The shared lookup (also used by dispatch.ts's runDispatch path)
|
|
168
|
+
// must use the bare id; a compound `unitType/unitId` value misses entirely,
|
|
169
|
+
// which previously silently dropped repeat-error detection on that path.
|
|
170
|
+
assert.equal(
|
|
171
|
+
lookupLatestLedgerError("execute-task", "M001/S01/T01"),
|
|
172
|
+
"boom: deterministic failure",
|
|
173
|
+
);
|
|
174
|
+
assert.equal(
|
|
175
|
+
lookupLatestLedgerError("execute-task", "execute-task/M001/S01/T01"),
|
|
176
|
+
undefined,
|
|
177
|
+
"a compound key must not match the bare-id ledger row",
|
|
178
|
+
);
|
|
179
|
+
assert.equal(
|
|
180
|
+
lookupLatestLedgerError("plan-slice", "M001/S01/T01"),
|
|
181
|
+
undefined,
|
|
182
|
+
"a different unit type on the same id must not be attached",
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
|
|
160
186
|
test("recordDispatch never attaches another unit type's ledger error for the same unit id", (t) => {
|
|
161
187
|
const f = makeLedgerFixture(t);
|
|
162
188
|
const dispatchId = f.claim("plan-slice", "M001/S01");
|
|
@@ -262,6 +288,35 @@ test("#482 regression: a re-dispatch loop spanning a session restart is detected
|
|
|
262
288
|
assert.match(verdict?.reason ?? "", /execute-task:M001\/S01\/T01 derived 3 consecutive times/);
|
|
263
289
|
});
|
|
264
290
|
|
|
291
|
+
test("rehydrate mirrors recordDispatch error attachment so repeat-error detection fires after the next dispatch", (t) => {
|
|
292
|
+
const f = makeLedgerFixture(t);
|
|
293
|
+
// Session 1: two failed dispatches for the same unit, same error summary.
|
|
294
|
+
for (let i = 0; i < 2; i++) {
|
|
295
|
+
const id = f.claim("execute-task", "M001/S01/T01");
|
|
296
|
+
markFailed(id, { errorSummary: "boom: deterministic failure" });
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Session 2: fresh history rehydrates from the ledger. Just like the live
|
|
300
|
+
// recordDispatch path, the first occurrence of a unit skips the ledger
|
|
301
|
+
// lookup; only repeats carry the error. So rehydration alone does not trip
|
|
302
|
+
// Rule 1 — keeping the post-restart window no more aggressive than the live
|
|
303
|
+
// one (Rule 1 has no retry-budget suppression).
|
|
304
|
+
const restarted = historyFor(f.base);
|
|
305
|
+
const count = restarted.rehydrate();
|
|
306
|
+
assert.equal(count, 2);
|
|
307
|
+
const window = restarted.getRecentWindow();
|
|
308
|
+
assert.equal(window[0].error, undefined);
|
|
309
|
+
assert.equal(window[1].error, "boom: deterministic failure");
|
|
310
|
+
assert.equal(restarted.detectStuck(), null);
|
|
311
|
+
|
|
312
|
+
// The next dispatch of the same unit attaches the error again, giving two
|
|
313
|
+
// consecutive matching errors → Rule 1 fires, exactly as in the live path.
|
|
314
|
+
restarted.recordDispatch("execute-task", "M001/S01/T01");
|
|
315
|
+
const verdict = restarted.detectStuck();
|
|
316
|
+
assert.equal(verdict?.stuck, true);
|
|
317
|
+
assert.match(verdict?.reason ?? "", /Same error repeated/);
|
|
318
|
+
});
|
|
319
|
+
|
|
265
320
|
test("rehydrate degrades to an empty window without a scope or ledger", () => {
|
|
266
321
|
const noScope = historyFor(null);
|
|
267
322
|
assert.equal(noScope.rehydrate(), 0);
|
|
@@ -7,6 +7,10 @@ const require = createRequire(import.meta.url);
|
|
|
7
7
|
const ROOT = new URL("../../../../../", import.meta.url);
|
|
8
8
|
|
|
9
9
|
export function resolve(specifier, context, nextResolve) {
|
|
10
|
+
if (specifier.startsWith('node:')) {
|
|
11
|
+
return { url: specifier, format: 'builtin', shortCircuit: true };
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
// 1. Redirect all workspace package bare imports to source.
|
|
11
15
|
// CI portability runs don't build any packages/ dist artifacts, so every
|
|
12
16
|
// @gsd/* specifier (including transitive ones pulled in by pi-coding-agent
|
|
@@ -100,6 +104,10 @@ export function resolve(specifier, context, nextResolve) {
|
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
export function load(url, context, nextLoad) {
|
|
107
|
+
if (url.startsWith('node:') || context.format === 'builtin') {
|
|
108
|
+
return { format: 'builtin', source: '', shortCircuit: true };
|
|
109
|
+
}
|
|
110
|
+
|
|
103
111
|
// jiti/CJS may still enter through stale packages/*/dist/index.js — redirect to src.
|
|
104
112
|
if (url.includes('/packages/pi-ai/dist/index.js')) {
|
|
105
113
|
url = url.replace('/dist/index.js', '/src/index.ts');
|