gsd-pi 2.74.0-dev.2b524c3 → 2.74.0-dev.6e23363
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.js +85 -0
- package/dist/headless-query.js +4 -1
- package/dist/help-text.js +23 -0
- package/dist/resources/extensions/gsd/activity-log.js +16 -0
- package/dist/resources/extensions/gsd/auto/detect-stuck.js +11 -4
- package/dist/resources/extensions/gsd/auto/loop.js +147 -10
- package/dist/resources/extensions/gsd/auto/phases.js +158 -4
- package/dist/resources/extensions/gsd/auto/session.js +10 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +11 -1
- package/dist/resources/extensions/gsd/auto-model-selection.js +51 -5
- package/dist/resources/extensions/gsd/auto-post-unit.js +213 -14
- package/dist/resources/extensions/gsd/auto-prompts.js +12 -0
- package/dist/resources/extensions/gsd/auto-unit-closeout.js +18 -0
- package/dist/resources/extensions/gsd/auto-verification.js +100 -2
- package/dist/resources/extensions/gsd/auto.js +36 -4
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +21 -8
- package/dist/resources/extensions/gsd/commands/catalog.js +26 -1
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +20 -0
- package/dist/resources/extensions/gsd/commands/handlers/workflow.js +68 -9
- package/dist/resources/extensions/gsd/commands-add-tests.js +111 -0
- package/dist/resources/extensions/gsd/commands-backlog.js +140 -0
- package/dist/resources/extensions/gsd/commands-do.js +79 -0
- package/dist/resources/extensions/gsd/commands-maintenance.js +6 -6
- package/dist/resources/extensions/gsd/commands-pr-branch.js +180 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +1 -1
- package/dist/resources/extensions/gsd/commands-session-report.js +82 -0
- package/dist/resources/extensions/gsd/commands-ship.js +187 -0
- package/dist/resources/extensions/gsd/db-writer.js +3 -5
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +14 -1
- package/dist/resources/extensions/gsd/git-service.js +49 -1
- package/dist/resources/extensions/gsd/graph-context.js +157 -0
- package/dist/resources/extensions/gsd/gsd-db.js +581 -2
- package/dist/resources/extensions/gsd/guided-flow.js +23 -0
- package/dist/resources/extensions/gsd/index.js +15 -2
- package/dist/resources/extensions/gsd/init-wizard.js +1 -0
- package/dist/resources/extensions/gsd/journal.js +27 -0
- package/dist/resources/extensions/gsd/md-importer.js +3 -4
- package/dist/resources/extensions/gsd/memory-store.js +19 -51
- package/dist/resources/extensions/gsd/metrics.js +19 -0
- package/dist/resources/extensions/gsd/milestone-validation-gates.js +13 -12
- package/dist/resources/extensions/gsd/native-git-bridge.js +7 -4
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +33 -1
- package/dist/resources/extensions/gsd/preferences-models.js +20 -3
- package/dist/resources/extensions/gsd/preferences-types.js +1 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +108 -2
- package/dist/resources/extensions/gsd/preferences.js +26 -0
- package/dist/resources/extensions/gsd/prompts/add-tests.md +35 -0
- package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +12 -2
- package/dist/resources/extensions/gsd/state.js +5 -1
- package/dist/resources/extensions/gsd/templates/PREFERENCES.md +18 -0
- package/dist/resources/extensions/gsd/tools/complete-slice.js +20 -0
- package/dist/resources/extensions/gsd/tools/validate-milestone.js +39 -4
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +3 -14
- package/dist/resources/extensions/gsd/triage-resolution.js +2 -5
- package/dist/resources/extensions/gsd/unit-ownership.js +1 -1
- package/dist/resources/extensions/gsd/uok/audit-toggle.js +7 -0
- package/dist/resources/extensions/gsd/uok/audit.js +40 -0
- package/dist/resources/extensions/gsd/uok/contracts.js +1 -0
- package/dist/resources/extensions/gsd/uok/execution-graph.js +179 -0
- package/dist/resources/extensions/gsd/uok/flags.js +29 -0
- package/dist/resources/extensions/gsd/uok/gate-runner.js +109 -0
- package/dist/resources/extensions/gsd/uok/gitops.js +53 -0
- package/dist/resources/extensions/gsd/uok/kernel.js +80 -0
- package/dist/resources/extensions/gsd/uok/loop-adapter.js +133 -0
- package/dist/resources/extensions/gsd/uok/model-policy.js +66 -0
- package/dist/resources/extensions/gsd/uok/plan-v2.js +132 -0
- package/dist/resources/extensions/gsd/workflow-logger.js +22 -0
- package/dist/resources/extensions/gsd/workflow-manifest.js +8 -69
- package/dist/resources/extensions/gsd/workflow-migration.js +21 -22
- package/dist/resources/extensions/gsd/workflow-projections.js +4 -1
- package/dist/resources/extensions/gsd/workflow-reconcile.js +14 -11
- package/dist/resources/extensions/ttsr/ttsr-manager.js +3 -1
- package/dist/tsconfig.extensions.tsbuildinfo +1 -0
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +9 -9
- 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 +9 -9
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- 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 +3 -2
- package/packages/daemon/package.json +2 -2
- package/packages/mcp-server/dist/index.d.ts +3 -0
- package/packages/mcp-server/dist/index.d.ts.map +1 -1
- package/packages/mcp-server/dist/index.js +3 -0
- package/packages/mcp-server/dist/index.js.map +1 -1
- package/packages/mcp-server/dist/readers/graph.d.ts +87 -0
- package/packages/mcp-server/dist/readers/graph.d.ts.map +1 -0
- package/packages/mcp-server/dist/readers/graph.js +548 -0
- package/packages/mcp-server/dist/readers/graph.js.map +1 -0
- package/packages/mcp-server/dist/readers/index.d.ts +2 -0
- package/packages/mcp-server/dist/readers/index.d.ts.map +1 -1
- package/packages/mcp-server/dist/readers/index.js +1 -0
- package/packages/mcp-server/dist/readers/index.js.map +1 -1
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +65 -0
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/package.json +2 -2
- package/packages/mcp-server/src/index.ts +15 -0
- package/packages/mcp-server/src/readers/graph.test.ts +426 -0
- package/packages/mcp-server/src/readers/graph.ts +708 -0
- package/packages/mcp-server/src/readers/index.ts +12 -0
- package/packages/mcp-server/src/server.ts +83 -0
- package/packages/mcp-server/tsconfig.json +1 -0
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -0
- package/packages/native/package.json +2 -2
- package/packages/native/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-agent-core/tsconfig.json +1 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-ai/tsconfig.json +1 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +120 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.js +52 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +2 -2
- package/packages/pi-coding-agent/dist/core/model-registry.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 +48 -4
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +166 -0
- package/packages/pi-coding-agent/src/core/model-registry-env-fallback.test.ts +59 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +2 -1
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +53 -4
- package/packages/pi-coding-agent/src/types/ambient-modules.d.ts +69 -0
- package/packages/pi-coding-agent/tsconfig.json +3 -2
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-tui/package.json +1 -1
- package/packages/pi-tui/tsconfig.json +1 -0
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -0
- package/packages/rpc-client/package.json +1 -1
- package/packages/rpc-client/tsconfig.json +1 -0
- package/packages/rpc-client/tsconfig.tsbuildinfo +1 -0
- package/src/resources/extensions/gsd/activity-log.ts +21 -0
- package/src/resources/extensions/gsd/auto/detect-stuck.ts +12 -4
- package/src/resources/extensions/gsd/auto/loop-deps.ts +10 -0
- package/src/resources/extensions/gsd/auto/loop.ts +159 -10
- package/src/resources/extensions/gsd/auto/phases.ts +191 -4
- package/src/resources/extensions/gsd/auto/session.ts +10 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +16 -6
- package/src/resources/extensions/gsd/auto-model-selection.ts +66 -5
- package/src/resources/extensions/gsd/auto-post-unit.ts +231 -15
- package/src/resources/extensions/gsd/auto-prompts.ts +13 -0
- package/src/resources/extensions/gsd/auto-unit-closeout.ts +25 -1
- package/src/resources/extensions/gsd/auto-verification.ts +129 -2
- package/src/resources/extensions/gsd/auto.ts +41 -2
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +24 -8
- package/src/resources/extensions/gsd/commands/catalog.ts +26 -1
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +20 -0
- package/src/resources/extensions/gsd/commands/handlers/workflow.ts +74 -9
- package/src/resources/extensions/gsd/commands-add-tests.ts +137 -0
- package/src/resources/extensions/gsd/commands-backlog.ts +182 -0
- package/src/resources/extensions/gsd/commands-do.ts +109 -0
- package/src/resources/extensions/gsd/commands-maintenance.ts +6 -6
- package/src/resources/extensions/gsd/commands-pr-branch.ts +234 -0
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +1 -1
- package/src/resources/extensions/gsd/commands-session-report.ts +101 -0
- package/src/resources/extensions/gsd/commands-ship.ts +219 -0
- package/src/resources/extensions/gsd/db-writer.ts +3 -5
- package/src/resources/extensions/gsd/docs/preferences-reference.md +14 -1
- package/src/resources/extensions/gsd/git-service.ts +68 -0
- package/src/resources/extensions/gsd/graph-context.ts +212 -0
- package/src/resources/extensions/gsd/gsd-db.ts +788 -3
- package/src/resources/extensions/gsd/guided-flow.ts +32 -0
- package/src/resources/extensions/gsd/index.ts +18 -2
- package/src/resources/extensions/gsd/init-wizard.ts +3 -2
- package/src/resources/extensions/gsd/journal.ts +30 -0
- package/src/resources/extensions/gsd/md-importer.ts +3 -5
- package/src/resources/extensions/gsd/memory-store.ts +31 -62
- package/src/resources/extensions/gsd/metrics.ts +26 -0
- package/src/resources/extensions/gsd/milestone-validation-gates.ts +13 -14
- package/src/resources/extensions/gsd/native-git-bridge.ts +11 -12
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +40 -1
- package/src/resources/extensions/gsd/preferences-models.ts +20 -3
- package/src/resources/extensions/gsd/preferences-types.ts +32 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +107 -2
- package/src/resources/extensions/gsd/preferences.ts +28 -0
- package/src/resources/extensions/gsd/prompts/add-tests.md +35 -0
- package/src/resources/extensions/gsd/session-lock.ts +14 -2
- package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +20 -1
- package/src/resources/extensions/gsd/state.ts +9 -2
- package/src/resources/extensions/gsd/templates/PREFERENCES.md +18 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +7 -3
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +7 -3
- package/src/resources/extensions/gsd/tests/cold-resume-db-reopen.test.ts +6 -2
- package/src/resources/extensions/gsd/tests/commands-backlog.test.ts +158 -0
- package/src/resources/extensions/gsd/tests/commands-do.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/commands-pr-branch.test.ts +68 -0
- package/src/resources/extensions/gsd/tests/commands-session-report.test.ts +82 -0
- package/src/resources/extensions/gsd/tests/commands-ship.test.ts +71 -0
- package/src/resources/extensions/gsd/tests/commands-workflow-custom.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/extension-bootstrap-isolation.test.ts +154 -0
- package/src/resources/extensions/gsd/tests/finalize-timeout-guard.test.ts +10 -7
- package/src/resources/extensions/gsd/tests/graph-context.test.ts +337 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +68 -1
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +1 -2
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -3
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
- package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +2 -1
- package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +40 -1
- package/src/resources/extensions/gsd/tests/single-writer-invariant.test.ts +180 -0
- package/src/resources/extensions/gsd/tests/token-profile.test.ts +8 -5
- package/src/resources/extensions/gsd/tests/uok-audit-unified.test.ts +101 -0
- package/src/resources/extensions/gsd/tests/uok-contracts.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/uok-execution-graph.test.ts +69 -0
- package/src/resources/extensions/gsd/tests/uok-flags.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/uok-gate-runner.test.ts +70 -0
- package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/uok-gitops-wiring.test.ts +35 -0
- package/src/resources/extensions/gsd/tests/uok-model-policy.test.ts +89 -0
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +167 -0
- package/src/resources/extensions/gsd/tests/uok-preferences.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +223 -0
- package/src/resources/extensions/gsd/tools/complete-slice.ts +26 -0
- package/src/resources/extensions/gsd/tools/validate-milestone.ts +48 -3
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +3 -11
- package/src/resources/extensions/gsd/triage-resolution.ts +2 -7
- package/src/resources/extensions/gsd/types.ts +1 -1
- package/src/resources/extensions/gsd/unit-ownership.ts +2 -2
- package/src/resources/extensions/gsd/uok/audit-toggle.ts +9 -0
- package/src/resources/extensions/gsd/uok/audit.ts +51 -0
- package/src/resources/extensions/gsd/uok/contracts.ts +135 -0
- package/src/resources/extensions/gsd/uok/execution-graph.ts +241 -0
- package/src/resources/extensions/gsd/uok/flags.ts +45 -0
- package/src/resources/extensions/gsd/uok/gate-runner.ts +146 -0
- package/src/resources/extensions/gsd/uok/gitops.ts +75 -0
- package/src/resources/extensions/gsd/uok/kernel.ts +105 -0
- package/src/resources/extensions/gsd/uok/loop-adapter.ts +162 -0
- package/src/resources/extensions/gsd/uok/model-policy.ts +112 -0
- package/src/resources/extensions/gsd/uok/plan-v2.ts +156 -0
- package/src/resources/extensions/gsd/workflow-logger.ts +25 -0
- package/src/resources/extensions/gsd/workflow-manifest.ts +9 -104
- package/src/resources/extensions/gsd/workflow-migration.ts +21 -29
- package/src/resources/extensions/gsd/workflow-projections.ts +8 -1
- package/src/resources/extensions/gsd/workflow-reconcile.ts +15 -15
- package/src/resources/extensions/ttsr/ttsr-manager.ts +10 -5
- /package/dist/web/standalone/.next/static/{YzIEI9sxJy4t5xgClF08g → bc2gRVFTgD7j--BsJE7vP}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{YzIEI9sxJy4t5xgClF08g → bc2gRVFTgD7j--BsJE7vP}/_ssgManifest.js +0 -0
|
@@ -14,7 +14,7 @@ import { join } from "node:path";
|
|
|
14
14
|
|
|
15
15
|
import { runPostUnitVerification, type VerificationContext } from "../auto-verification.ts";
|
|
16
16
|
import { AutoSession } from "../auto/session.ts";
|
|
17
|
-
import { openDatabase, closeDatabase, insertMilestone, insertSlice, insertTask } from "../gsd-db.ts";
|
|
17
|
+
import { openDatabase, closeDatabase, insertMilestone, insertSlice, insertTask, _getAdapter } from "../gsd-db.ts";
|
|
18
18
|
import { invalidateAllCaches } from "../cache.ts";
|
|
19
19
|
import { _clearGsdRootCache } from "../paths.ts";
|
|
20
20
|
|
|
@@ -140,6 +140,43 @@ function createBasicTask(): void {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
function createPostExecFailureTask(): void {
|
|
144
|
+
insertMilestone({ id: "M001" });
|
|
145
|
+
insertSlice({
|
|
146
|
+
id: "S01",
|
|
147
|
+
milestoneId: "M001",
|
|
148
|
+
title: "Test Slice",
|
|
149
|
+
risk: "low",
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const srcDir = join(tempDir, "src");
|
|
153
|
+
mkdirSync(srcDir, { recursive: true });
|
|
154
|
+
writeFileSync(
|
|
155
|
+
join(srcDir, "broken.ts"),
|
|
156
|
+
"import { missing } from './does-not-exist.js';\nexport const ok = 1;\n",
|
|
157
|
+
"utf-8",
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
insertTask({
|
|
161
|
+
id: "T01",
|
|
162
|
+
sliceId: "S01",
|
|
163
|
+
milestoneId: "M001",
|
|
164
|
+
title: "Task with broken import",
|
|
165
|
+
status: "pending",
|
|
166
|
+
keyFiles: ["src/broken.ts"],
|
|
167
|
+
planning: {
|
|
168
|
+
description: "Task that introduces an unresolved import in key files",
|
|
169
|
+
estimate: "1h",
|
|
170
|
+
files: ["src/broken.ts"],
|
|
171
|
+
verify: "echo pass",
|
|
172
|
+
inputs: [],
|
|
173
|
+
expectedOutput: [],
|
|
174
|
+
observabilityImpact: "",
|
|
175
|
+
},
|
|
176
|
+
sequence: 0,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
143
180
|
// ─── Tests ───────────────────────────────────────────────────────────────────
|
|
144
181
|
|
|
145
182
|
describe("Post-execution blocking failure retry bypass", () => {
|
|
@@ -249,6 +286,47 @@ describe("Post-execution blocking failure retry bypass", () => {
|
|
|
249
286
|
// This test mainly confirms the wiring is correct
|
|
250
287
|
assert.equal(result, "continue");
|
|
251
288
|
});
|
|
289
|
+
|
|
290
|
+
test("uok gate runner persists post-execution gate failures when enabled", async () => {
|
|
291
|
+
createPostExecFailureTask();
|
|
292
|
+
writePreferences({
|
|
293
|
+
enhanced_verification: true,
|
|
294
|
+
enhanced_verification_post: true,
|
|
295
|
+
verification_auto_fix: true,
|
|
296
|
+
verification_max_retries: 2,
|
|
297
|
+
uok: {
|
|
298
|
+
enabled: true,
|
|
299
|
+
gates: { enabled: true },
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const ctx = makeMockCtx();
|
|
304
|
+
const pi = makeMockPi();
|
|
305
|
+
const pauseAutoMock = mock.fn(async () => {});
|
|
306
|
+
const s = makeMockSession(tempDir, { type: "execute-task", id: "M001/S01/T01" });
|
|
307
|
+
const vctx: VerificationContext = { s, ctx, pi };
|
|
308
|
+
|
|
309
|
+
const result = await runPostUnitVerification(vctx, pauseAutoMock);
|
|
310
|
+
|
|
311
|
+
assert.equal(result, "pause");
|
|
312
|
+
assert.equal(pauseAutoMock.mock.callCount(), 1);
|
|
313
|
+
|
|
314
|
+
const adapter = _getAdapter();
|
|
315
|
+
const row = adapter
|
|
316
|
+
?.prepare(
|
|
317
|
+
`SELECT gate_id, outcome, failure_class
|
|
318
|
+
FROM gate_runs
|
|
319
|
+
WHERE gate_id = 'post-execution-checks'
|
|
320
|
+
ORDER BY id DESC
|
|
321
|
+
LIMIT 1`,
|
|
322
|
+
)
|
|
323
|
+
.get() as { gate_id: string; outcome: string; failure_class: string } | undefined;
|
|
324
|
+
|
|
325
|
+
assert.ok(row, "post-execution gate run should be persisted when uok.gates is enabled");
|
|
326
|
+
assert.equal(row?.gate_id, "post-execution-checks");
|
|
327
|
+
assert.equal(row?.outcome, "fail");
|
|
328
|
+
assert.equal(row?.failure_class, "artifact");
|
|
329
|
+
});
|
|
252
330
|
});
|
|
253
331
|
|
|
254
332
|
describe("Post-execution retry behavior", () => {
|
|
@@ -21,7 +21,8 @@ test("postUnitPreVerification rebuilds STATE.md before worktree sync", () => {
|
|
|
21
21
|
const fnStart = source.indexOf("export async function postUnitPreVerification");
|
|
22
22
|
assert.ok(fnStart > 0, "postUnitPreVerification should exist");
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const fnEnd = source.indexOf("export async function postUnitPostVerification", fnStart);
|
|
25
|
+
const section = source.slice(fnStart, fnEnd > fnStart ? fnEnd : undefined);
|
|
25
26
|
const rebuildIdx = section.indexOf('await runSafely("postUnit", "state-rebuild"');
|
|
26
27
|
const syncIdx = section.indexOf('await runSafely("postUnit", "worktree-sync"');
|
|
27
28
|
|
|
@@ -17,7 +17,7 @@ import { join } from "node:path";
|
|
|
17
17
|
|
|
18
18
|
import { postUnitPostVerification, type PostUnitContext } from "../auto-post-unit.ts";
|
|
19
19
|
import { AutoSession } from "../auto/session.ts";
|
|
20
|
-
import { openDatabase, closeDatabase, insertMilestone, insertSlice, insertTask } from "../gsd-db.ts";
|
|
20
|
+
import { openDatabase, closeDatabase, insertMilestone, insertSlice, insertTask, _getAdapter } from "../gsd-db.ts";
|
|
21
21
|
import { invalidateAllCaches } from "../cache.ts";
|
|
22
22
|
import { _clearGsdRootCache } from "../paths.ts";
|
|
23
23
|
|
|
@@ -454,4 +454,43 @@ describe("Pre-execution checks → pauseAuto wiring", () => {
|
|
|
454
454
|
"postUnitPostVerification should return 'continue' when pre-execution checks are disabled"
|
|
455
455
|
);
|
|
456
456
|
});
|
|
457
|
+
|
|
458
|
+
test("uok gate runner persists pre-execution gate outcomes when enabled", async () => {
|
|
459
|
+
writePreferences({
|
|
460
|
+
enhanced_verification: true,
|
|
461
|
+
enhanced_verification_pre: true,
|
|
462
|
+
enhanced_verification_strict: true,
|
|
463
|
+
uok: {
|
|
464
|
+
enabled: true,
|
|
465
|
+
gates: { enabled: true },
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
createFailingTasks();
|
|
470
|
+
|
|
471
|
+
const ctx = makeMockCtx();
|
|
472
|
+
const pi = makeMockPi();
|
|
473
|
+
const pauseAutoMock = mock.fn(async () => {});
|
|
474
|
+
const s = makeMockSession(tempDir, { type: "plan-slice", id: "M001/S01" });
|
|
475
|
+
const pctx = makePostUnitContext(s, ctx, pi, pauseAutoMock);
|
|
476
|
+
|
|
477
|
+
const result = await postUnitPostVerification(pctx);
|
|
478
|
+
assert.equal(result, "stopped");
|
|
479
|
+
|
|
480
|
+
const adapter = _getAdapter();
|
|
481
|
+
const row = adapter
|
|
482
|
+
?.prepare(
|
|
483
|
+
`SELECT gate_id, outcome, failure_class
|
|
484
|
+
FROM gate_runs
|
|
485
|
+
WHERE gate_id = 'pre-execution-checks'
|
|
486
|
+
ORDER BY id DESC
|
|
487
|
+
LIMIT 1`,
|
|
488
|
+
)
|
|
489
|
+
.get() as { gate_id: string; outcome: string; failure_class: string } | undefined;
|
|
490
|
+
|
|
491
|
+
assert.ok(row, "pre-execution gate run should be persisted when uok.gates is enabled");
|
|
492
|
+
assert.equal(row?.gate_id, "pre-execution-checks");
|
|
493
|
+
assert.equal(row?.outcome, "fail");
|
|
494
|
+
assert.equal(row?.failure_class, "input");
|
|
495
|
+
});
|
|
457
496
|
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// Structural invariant: gsd-db.ts is the single writer for .gsd/gsd.db.
|
|
2
|
+
//
|
|
3
|
+
// No file under src/resources/extensions/gsd/ may issue raw write SQL
|
|
4
|
+
// (INSERT/UPDATE/DELETE/REPLACE) or raw transaction control (BEGIN/COMMIT/
|
|
5
|
+
// ROLLBACK via `.exec(...)`) against the engine database. Every bypass must
|
|
6
|
+
// route through a typed wrapper exported from gsd-db.ts.
|
|
7
|
+
//
|
|
8
|
+
// Allowlist:
|
|
9
|
+
// - gsd-db.ts itself — the single writer
|
|
10
|
+
// - unit-ownership.ts — manages a separate .gsd/unit-claims.db for
|
|
11
|
+
// cross-worktree claim races; intentionally outside this invariant
|
|
12
|
+
// - tests/** — fixtures and direct DB inspection are fair game
|
|
13
|
+
//
|
|
14
|
+
// When this test fails, do not add a new suppression. Instead:
|
|
15
|
+
// 1. Add a typed wrapper to gsd-db.ts that captures the SQL
|
|
16
|
+
// 2. Switch the flagged site to call the wrapper
|
|
17
|
+
//
|
|
18
|
+
// See `.claude/plans/joyful-doodling-pony.md` for the full rationale.
|
|
19
|
+
|
|
20
|
+
import test from "node:test";
|
|
21
|
+
import assert from "node:assert/strict";
|
|
22
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
23
|
+
import { join, relative } from "node:path";
|
|
24
|
+
|
|
25
|
+
const gsdDir = join(process.cwd(), "src/resources/extensions/gsd");
|
|
26
|
+
|
|
27
|
+
const ALLOWLIST = new Set([
|
|
28
|
+
"gsd-db.ts",
|
|
29
|
+
"unit-ownership.ts",
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
/** Walk the gsd extension dir and return all .ts files outside tests/. */
|
|
33
|
+
function walkTsFiles(root: string): string[] {
|
|
34
|
+
const out: string[] = [];
|
|
35
|
+
const stack: string[] = [root];
|
|
36
|
+
|
|
37
|
+
while (stack.length > 0) {
|
|
38
|
+
const dir = stack.pop()!;
|
|
39
|
+
let entries;
|
|
40
|
+
try {
|
|
41
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
42
|
+
} catch {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for (const ent of entries) {
|
|
47
|
+
const full = join(dir, ent.name);
|
|
48
|
+
if (ent.isDirectory()) {
|
|
49
|
+
// Skip tests/ — fixtures and direct DB inspection are expected there
|
|
50
|
+
if (ent.name === "tests") continue;
|
|
51
|
+
stack.push(full);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (!ent.isFile()) continue;
|
|
55
|
+
if (!ent.name.endsWith(".ts")) continue;
|
|
56
|
+
// Skip dotfiles and backup/generated files
|
|
57
|
+
if (ent.name.startsWith(".")) continue;
|
|
58
|
+
out.push(full);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface Violation {
|
|
66
|
+
file: string;
|
|
67
|
+
line: number;
|
|
68
|
+
snippet: string;
|
|
69
|
+
kind: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Match .prepare("... INSERT|UPDATE|DELETE|REPLACE ...") in any quoting style.
|
|
73
|
+
const PREPARE_WRITE_RE = /\.prepare\s*\(\s*[`'"][^`'"]*\b(INSERT|UPDATE|DELETE|REPLACE)\b/i;
|
|
74
|
+
|
|
75
|
+
// Match .exec("... INSERT|UPDATE|DELETE|REPLACE ...") or raw BEGIN/COMMIT/ROLLBACK.
|
|
76
|
+
const EXEC_WRITE_RE = /\.exec\s*\(\s*[`'"][^`'"]*\b(INSERT|UPDATE|DELETE|REPLACE|BEGIN|COMMIT|ROLLBACK)\b/i;
|
|
77
|
+
|
|
78
|
+
test("no module outside gsd-db.ts issues raw write SQL against the engine DB", () => {
|
|
79
|
+
const files = walkTsFiles(gsdDir);
|
|
80
|
+
assert.ok(files.length >= 20, `Expected at least 20 .ts files under gsd/, found ${files.length}`);
|
|
81
|
+
|
|
82
|
+
const violations: Violation[] = [];
|
|
83
|
+
|
|
84
|
+
for (const abs of files) {
|
|
85
|
+
const rel = relative(gsdDir, abs);
|
|
86
|
+
const base = rel.split("/").pop()!;
|
|
87
|
+
if (ALLOWLIST.has(base)) continue;
|
|
88
|
+
|
|
89
|
+
let content: string;
|
|
90
|
+
try {
|
|
91
|
+
content = readFileSync(abs, "utf-8");
|
|
92
|
+
} catch {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const lines = content.split("\n");
|
|
97
|
+
for (let i = 0; i < lines.length; i++) {
|
|
98
|
+
const line = lines[i];
|
|
99
|
+
|
|
100
|
+
const prepareMatch = PREPARE_WRITE_RE.exec(line);
|
|
101
|
+
if (prepareMatch) {
|
|
102
|
+
violations.push({
|
|
103
|
+
file: rel,
|
|
104
|
+
line: i + 1,
|
|
105
|
+
snippet: line.trim(),
|
|
106
|
+
kind: `prepare(${prepareMatch[1].toUpperCase()})`,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const execMatch = EXEC_WRITE_RE.exec(line);
|
|
111
|
+
if (execMatch) {
|
|
112
|
+
violations.push({
|
|
113
|
+
file: rel,
|
|
114
|
+
line: i + 1,
|
|
115
|
+
snippet: line.trim(),
|
|
116
|
+
kind: `exec(${execMatch[1].toUpperCase()})`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (violations.length > 0) {
|
|
123
|
+
const lines = violations.map(
|
|
124
|
+
(v) => ` ${v.file}:${v.line} [${v.kind}] — ${v.snippet}`,
|
|
125
|
+
);
|
|
126
|
+
assert.fail(
|
|
127
|
+
`Found ${violations.length} raw write SQL bypass(es) outside gsd-db.ts:\n` +
|
|
128
|
+
lines.join("\n") +
|
|
129
|
+
"\n\nEach of these must be replaced with a typed wrapper exported from gsd-db.ts.",
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("gsd-db.ts exports the expected single-writer wrappers", async () => {
|
|
135
|
+
// Positive assertion — fail loudly if the module layout changes so this
|
|
136
|
+
// structural test can't silently become a no-op.
|
|
137
|
+
const db = await import("../gsd-db.js");
|
|
138
|
+
|
|
139
|
+
const expected = [
|
|
140
|
+
"deleteDecisionById",
|
|
141
|
+
"deleteRequirementById",
|
|
142
|
+
"deleteArtifactByPath",
|
|
143
|
+
"clearEngineHierarchy",
|
|
144
|
+
"insertOrIgnoreSlice",
|
|
145
|
+
"insertOrIgnoreTask",
|
|
146
|
+
"setSliceReplanTriggeredAt",
|
|
147
|
+
"upsertQualityGate",
|
|
148
|
+
"restoreManifest",
|
|
149
|
+
"bulkInsertLegacyHierarchy",
|
|
150
|
+
"readTransaction",
|
|
151
|
+
"insertMemoryRow",
|
|
152
|
+
"rewriteMemoryId",
|
|
153
|
+
"updateMemoryContentRow",
|
|
154
|
+
"incrementMemoryHitCount",
|
|
155
|
+
"supersedeMemoryRow",
|
|
156
|
+
"markMemoryUnitProcessed",
|
|
157
|
+
"decayMemoriesBefore",
|
|
158
|
+
"supersedeLowestRankedMemories",
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
for (const name of expected) {
|
|
162
|
+
assert.ok(
|
|
163
|
+
typeof (db as Record<string, unknown>)[name] === "function",
|
|
164
|
+
`gsd-db.ts must export ${name} as a function`,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("the invariant test touches every .ts module under gsd/ (sanity check)", () => {
|
|
170
|
+
const files = walkTsFiles(gsdDir);
|
|
171
|
+
// Rough sanity: ensure we're not accidentally walking an empty tree
|
|
172
|
+
assert.ok(files.length >= 30, `Expected to scan at least 30 .ts files, scanned ${files.length}`);
|
|
173
|
+
|
|
174
|
+
// Spot-check a couple of known files that must be included
|
|
175
|
+
const rels = files.map((f) => relative(gsdDir, f));
|
|
176
|
+
assert.ok(rels.includes("gsd-db.ts"), "walker must include gsd-db.ts");
|
|
177
|
+
assert.ok(rels.includes("memory-store.ts"), "walker must include memory-store.ts");
|
|
178
|
+
assert.ok(rels.includes("workflow-manifest.ts"), "walker must include workflow-manifest.ts");
|
|
179
|
+
});
|
|
180
|
+
|
|
@@ -34,11 +34,12 @@ const typesSrc = readFileSync(join(__dirname, "..", "types.ts"), "utf-8");
|
|
|
34
34
|
// Type Definitions
|
|
35
35
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
36
36
|
|
|
37
|
-
test("types: TokenProfile type exported with budget/balanced/quality", () => {
|
|
37
|
+
test("types: TokenProfile type exported with budget/balanced/quality/burn-max", () => {
|
|
38
38
|
assert.ok(typesSrc.includes("export type TokenProfile"), "TokenProfile should be exported");
|
|
39
39
|
assert.match(typesSrc, /["']budget["']/, "should include budget");
|
|
40
40
|
assert.match(typesSrc, /["']balanced["']/, "should include balanced");
|
|
41
41
|
assert.match(typesSrc, /["']quality["']/, "should include quality");
|
|
42
|
+
assert.match(typesSrc, /["']burn-max["']/, "should include burn-max");
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
test("types: InlineLevel type exported with full/standard/minimal", () => {
|
|
@@ -91,7 +92,7 @@ test("preferences: KNOWN_PREFERENCE_KEYS includes token_profile and phases", ()
|
|
|
91
92
|
// Profile Resolution
|
|
92
93
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
93
94
|
|
|
94
|
-
test("profile: resolveProfileDefaults exists and handles all
|
|
95
|
+
test("profile: resolveProfileDefaults exists and handles all 4 tiers", () => {
|
|
95
96
|
assert.ok(
|
|
96
97
|
preferencesSrc.includes("export function resolveProfileDefaults"),
|
|
97
98
|
"resolveProfileDefaults should be exported",
|
|
@@ -99,8 +100,9 @@ test("profile: resolveProfileDefaults exists and handles all 3 tiers", () => {
|
|
|
99
100
|
assert.ok(
|
|
100
101
|
preferencesSrc.includes('case "budget"') &&
|
|
101
102
|
preferencesSrc.includes('case "balanced"') &&
|
|
102
|
-
preferencesSrc.includes('case "quality"')
|
|
103
|
-
|
|
103
|
+
preferencesSrc.includes('case "quality"') &&
|
|
104
|
+
preferencesSrc.includes('case "burn-max"'),
|
|
105
|
+
"resolveProfileDefaults should handle all 4 tiers",
|
|
104
106
|
);
|
|
105
107
|
});
|
|
106
108
|
|
|
@@ -158,6 +160,7 @@ test("profile: resolveInlineLevel maps profile to inline level", () => {
|
|
|
158
160
|
assert.ok(preferencesSrc.includes('case "budget": return "minimal"'), "budget → minimal");
|
|
159
161
|
assert.ok(preferencesSrc.includes('case "balanced": return "standard"'), "balanced → standard");
|
|
160
162
|
assert.ok(preferencesSrc.includes('case "quality": return "full"'), "quality → full");
|
|
163
|
+
assert.ok(preferencesSrc.includes('case "burn-max": return "full"'), "burn-max → full");
|
|
161
164
|
});
|
|
162
165
|
|
|
163
166
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -167,7 +170,7 @@ test("profile: resolveInlineLevel maps profile to inline level", () => {
|
|
|
167
170
|
test("validate: validatePreferences handles token_profile", () => {
|
|
168
171
|
assert.ok(
|
|
169
172
|
preferencesSrc.includes("preferences.token_profile") &&
|
|
170
|
-
preferencesSrc.includes("budget, balanced, quality"),
|
|
173
|
+
preferencesSrc.includes("budget, balanced, quality, burn-max"),
|
|
171
174
|
"validatePreferences should validate token_profile enum values",
|
|
172
175
|
);
|
|
173
176
|
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtempSync, readFileSync, rmSync, existsSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { emitJournalEvent } from "../journal.ts";
|
|
7
|
+
import { saveActivityLog } from "../activity-log.ts";
|
|
8
|
+
import { initMetrics, resetMetrics, snapshotUnitMetrics } from "../metrics.ts";
|
|
9
|
+
import { setLogBasePath, logWarning } from "../workflow-logger.ts";
|
|
10
|
+
import { setUnifiedAuditEnabled } from "../uok/audit-toggle.ts";
|
|
11
|
+
|
|
12
|
+
function readAuditEvents(basePath: string): Array<Record<string, unknown>> {
|
|
13
|
+
const file = join(basePath, ".gsd", "audit", "events.jsonl");
|
|
14
|
+
if (!existsSync(file)) return [];
|
|
15
|
+
const raw = readFileSync(file, "utf-8");
|
|
16
|
+
return raw
|
|
17
|
+
.split("\n")
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.map((line) => JSON.parse(line) as Record<string, unknown>);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function makeMockContext(entries: unknown[]): any {
|
|
23
|
+
return {
|
|
24
|
+
sessionManager: {
|
|
25
|
+
getEntries: () => entries,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
test("unified audit plane bridges journal/activity/metrics/workflow logger into audit envelope log", () => {
|
|
31
|
+
const basePath = mkdtempSync(join(tmpdir(), "gsd-uok-audit-"));
|
|
32
|
+
setUnifiedAuditEnabled(true);
|
|
33
|
+
try {
|
|
34
|
+
emitJournalEvent(basePath, {
|
|
35
|
+
ts: new Date().toISOString(),
|
|
36
|
+
flowId: "trace-123",
|
|
37
|
+
seq: 1,
|
|
38
|
+
eventType: "iteration-start",
|
|
39
|
+
data: { turnId: "turn-123", unitId: "M001/S01/T01" },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const activityCtx = makeMockContext([
|
|
43
|
+
{ type: "message", message: { role: "assistant", content: [{ type: "text", text: "hello" }] } },
|
|
44
|
+
]);
|
|
45
|
+
const activityPath = saveActivityLog(activityCtx, basePath, "execute-task", "M001/S01/T01");
|
|
46
|
+
assert.ok(activityPath);
|
|
47
|
+
|
|
48
|
+
initMetrics(basePath);
|
|
49
|
+
const metricsCtx = makeMockContext([
|
|
50
|
+
{
|
|
51
|
+
type: "message",
|
|
52
|
+
message: {
|
|
53
|
+
role: "assistant",
|
|
54
|
+
usage: { input: 10, output: 5, cacheRead: 0, cacheWrite: 0, totalTokens: 15, cost: 0.01 },
|
|
55
|
+
content: [],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
const unit = snapshotUnitMetrics(
|
|
60
|
+
metricsCtx,
|
|
61
|
+
"execute-task",
|
|
62
|
+
"M001/S01/T01",
|
|
63
|
+
Date.now() - 1000,
|
|
64
|
+
"openai/gpt-5.4",
|
|
65
|
+
{ traceId: "trace-123", turnId: "turn-123" },
|
|
66
|
+
);
|
|
67
|
+
assert.ok(unit);
|
|
68
|
+
resetMetrics();
|
|
69
|
+
|
|
70
|
+
setLogBasePath(basePath);
|
|
71
|
+
logWarning("engine", "audit bridge check", { id: "turn-123" });
|
|
72
|
+
|
|
73
|
+
const events = readAuditEvents(basePath);
|
|
74
|
+
const types = new Set(events.map((event) => String(event.type ?? "")));
|
|
75
|
+
assert.ok(types.has("journal-iteration-start"));
|
|
76
|
+
assert.ok(types.has("activity-log-saved"));
|
|
77
|
+
assert.ok(types.has("unit-metrics-snapshot"));
|
|
78
|
+
assert.ok(types.has("workflow-log-warn"));
|
|
79
|
+
} finally {
|
|
80
|
+
setUnifiedAuditEnabled(false);
|
|
81
|
+
resetMetrics();
|
|
82
|
+
rmSync(basePath, { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("unified audit bridge is disabled when toggle is off", () => {
|
|
87
|
+
const basePath = mkdtempSync(join(tmpdir(), "gsd-uok-audit-off-"));
|
|
88
|
+
setUnifiedAuditEnabled(false);
|
|
89
|
+
try {
|
|
90
|
+
emitJournalEvent(basePath, {
|
|
91
|
+
ts: new Date().toISOString(),
|
|
92
|
+
flowId: "trace-off",
|
|
93
|
+
seq: 1,
|
|
94
|
+
eventType: "iteration-start",
|
|
95
|
+
});
|
|
96
|
+
const events = readAuditEvents(basePath);
|
|
97
|
+
assert.equal(events.length, 0);
|
|
98
|
+
} finally {
|
|
99
|
+
rmSync(basePath, { recursive: true, force: true });
|
|
100
|
+
}
|
|
101
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
AuditEventEnvelope,
|
|
6
|
+
GateResult,
|
|
7
|
+
TurnContract,
|
|
8
|
+
TurnResult,
|
|
9
|
+
UokNodeKind,
|
|
10
|
+
} from "../uok/contracts.ts";
|
|
11
|
+
import { buildAuditEnvelope } from "../uok/audit.ts";
|
|
12
|
+
|
|
13
|
+
test("uok contracts serialize/deserialize turn envelopes", () => {
|
|
14
|
+
const contract: TurnContract = {
|
|
15
|
+
traceId: "trace-1",
|
|
16
|
+
turnId: "turn-1",
|
|
17
|
+
iteration: 1,
|
|
18
|
+
basePath: "/tmp/project",
|
|
19
|
+
unitType: "execute-task",
|
|
20
|
+
unitId: "M001.S01.T01",
|
|
21
|
+
startedAt: new Date().toISOString(),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const gate: GateResult = {
|
|
25
|
+
gateId: "Q3",
|
|
26
|
+
gateType: "policy",
|
|
27
|
+
outcome: "pass",
|
|
28
|
+
failureClass: "none",
|
|
29
|
+
attempt: 1,
|
|
30
|
+
maxAttempts: 1,
|
|
31
|
+
retryable: false,
|
|
32
|
+
evaluatedAt: new Date().toISOString(),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const result: TurnResult = {
|
|
36
|
+
traceId: contract.traceId,
|
|
37
|
+
turnId: contract.turnId,
|
|
38
|
+
iteration: contract.iteration,
|
|
39
|
+
unitType: contract.unitType,
|
|
40
|
+
unitId: contract.unitId,
|
|
41
|
+
status: "completed",
|
|
42
|
+
failureClass: "none",
|
|
43
|
+
phaseResults: [
|
|
44
|
+
{ phase: "dispatch", action: "next", ts: new Date().toISOString() },
|
|
45
|
+
{ phase: "unit", action: "continue", ts: new Date().toISOString() },
|
|
46
|
+
{ phase: "finalize", action: "next", ts: new Date().toISOString() },
|
|
47
|
+
],
|
|
48
|
+
gateResults: [gate],
|
|
49
|
+
startedAt: contract.startedAt,
|
|
50
|
+
finishedAt: new Date().toISOString(),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const roundTrip = JSON.parse(JSON.stringify(result)) as TurnResult;
|
|
54
|
+
assert.equal(roundTrip.turnId, "turn-1");
|
|
55
|
+
assert.equal(roundTrip.gateResults?.[0]?.gateId, "Q3");
|
|
56
|
+
assert.equal(roundTrip.phaseResults.length, 3);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("uok contracts include required DAG node kinds", () => {
|
|
60
|
+
const required: UokNodeKind[] = [
|
|
61
|
+
"unit",
|
|
62
|
+
"hook",
|
|
63
|
+
"subagent",
|
|
64
|
+
"team-worker",
|
|
65
|
+
"verification",
|
|
66
|
+
"reprocess",
|
|
67
|
+
];
|
|
68
|
+
assert.deepEqual(required.length, 6);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("uok audit envelope includes trace/turn/causality fields", () => {
|
|
72
|
+
const event: AuditEventEnvelope = buildAuditEnvelope({
|
|
73
|
+
traceId: "trace-xyz",
|
|
74
|
+
turnId: "turn-xyz",
|
|
75
|
+
causedBy: "turn-start",
|
|
76
|
+
category: "orchestration",
|
|
77
|
+
type: "turn-result",
|
|
78
|
+
payload: { status: "completed" },
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
assert.equal(event.traceId, "trace-xyz");
|
|
82
|
+
assert.equal(event.turnId, "turn-xyz");
|
|
83
|
+
assert.equal(event.causedBy, "turn-start");
|
|
84
|
+
assert.equal(event.payload.status, "completed");
|
|
85
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import type { SidecarItem } from "../auto/session.ts";
|
|
4
|
+
import {
|
|
5
|
+
selectConflictFreeBatch,
|
|
6
|
+
selectReactiveDispatchBatch,
|
|
7
|
+
buildSidecarQueueNodes,
|
|
8
|
+
scheduleSidecarQueue,
|
|
9
|
+
} from "../uok/execution-graph.ts";
|
|
10
|
+
|
|
11
|
+
test("uok execution graph selects deterministic conflict-free IDs", () => {
|
|
12
|
+
const selected = selectConflictFreeBatch({
|
|
13
|
+
orderedIds: ["S01", "S02", "S03", "S04"],
|
|
14
|
+
maxParallel: 4,
|
|
15
|
+
hasConflict: (candidate, existing) =>
|
|
16
|
+
(candidate === "S02" && existing === "S01") ||
|
|
17
|
+
(candidate === "S01" && existing === "S02"),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
assert.deepEqual(selected, ["S01", "S03", "S04"]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("uok execution graph reactive batch honors file conflicts and in-flight writes", () => {
|
|
24
|
+
const result = selectReactiveDispatchBatch({
|
|
25
|
+
graph: [
|
|
26
|
+
{ id: "T01", dependsOn: [], outputFiles: ["src/a.ts"] },
|
|
27
|
+
{ id: "T02", dependsOn: [], outputFiles: ["src/a.ts"] },
|
|
28
|
+
{ id: "T03", dependsOn: [], outputFiles: ["src/b.ts"] },
|
|
29
|
+
{ id: "T04", dependsOn: ["T03"], outputFiles: ["src/c.ts"] },
|
|
30
|
+
],
|
|
31
|
+
readyIds: ["T01", "T02", "T03", "T04"],
|
|
32
|
+
maxParallel: 3,
|
|
33
|
+
inFlightOutputs: new Set(["src/c.ts"]),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
assert.deepEqual(result.selected, ["T01", "T03"]);
|
|
37
|
+
assert.ok(
|
|
38
|
+
result.conflicts.some((c) => c.nodeA === "T01" && c.nodeB === "T02" && c.file === "src/a.ts"),
|
|
39
|
+
"conflict list should include overlapping outputs",
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("uok execution graph sidecar nodes map queue kinds to supported DAG kinds", () => {
|
|
44
|
+
const queue: SidecarItem[] = [
|
|
45
|
+
{ kind: "hook", unitType: "execute-task", unitId: "M001/S01/T01", prompt: "hook" },
|
|
46
|
+
{ kind: "triage", unitType: "triage", unitId: "M001/S01", prompt: "triage" },
|
|
47
|
+
{ kind: "quick-task", unitType: "quick-task", unitId: "M001/S01/Q01", prompt: "quick" },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const nodes = buildSidecarQueueNodes(queue);
|
|
51
|
+
assert.equal(nodes[0]?.kind, "hook");
|
|
52
|
+
assert.equal(nodes[1]?.kind, "verification");
|
|
53
|
+
assert.equal(nodes[2]?.kind, "team-worker");
|
|
54
|
+
assert.equal(nodes[1]?.dependsOn.length, 1);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("uok execution graph sidecar scheduler preserves deterministic queue order", async () => {
|
|
58
|
+
const queue: SidecarItem[] = [
|
|
59
|
+
{ kind: "quick-task", unitType: "quick-task", unitId: "M001/S01/Q01", prompt: "q1" },
|
|
60
|
+
{ kind: "hook", unitType: "hook", unitId: "M001/S01/H01", prompt: "h1" },
|
|
61
|
+
{ kind: "triage", unitType: "triage", unitId: "M001/S01/TR1", prompt: "t1" },
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
const scheduled = await scheduleSidecarQueue(queue);
|
|
65
|
+
assert.deepEqual(
|
|
66
|
+
scheduled.map((item) => item.unitId),
|
|
67
|
+
queue.map((item) => item.unitId),
|
|
68
|
+
);
|
|
69
|
+
});
|