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
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// GSD Extension — workflow-logger wiring regression tests
|
|
2
|
+
//
|
|
3
|
+
// Verifies the plumbing between workflow-logger and the rest of the state
|
|
4
|
+
// system (auto-loop phases, detect-stuck, notification store). Without this
|
|
5
|
+
// wiring, warnings/errors logged during a unit leak across units, never
|
|
6
|
+
// reach the user as a consolidated post-unit alert, and don't enrich
|
|
7
|
+
// stuck-detection reasons.
|
|
8
|
+
|
|
9
|
+
import test from "node:test";
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
logWarning,
|
|
16
|
+
logError,
|
|
17
|
+
peekLogs,
|
|
18
|
+
_resetLogs,
|
|
19
|
+
setStderrLoggingEnabled,
|
|
20
|
+
} from "../workflow-logger.ts";
|
|
21
|
+
import { detectStuck } from "../auto/detect-stuck.ts";
|
|
22
|
+
|
|
23
|
+
const phasesSrc = readFileSync(
|
|
24
|
+
join(import.meta.dirname, "..", "auto", "phases.ts"),
|
|
25
|
+
"utf-8",
|
|
26
|
+
);
|
|
27
|
+
const autoSrc = readFileSync(
|
|
28
|
+
join(import.meta.dirname, "..", "auto.ts"),
|
|
29
|
+
"utf-8",
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// ─── Source-scan: phases.ts calls the logger lifecycle API ─────────────────
|
|
33
|
+
|
|
34
|
+
test("auto/phases.ts imports _resetLogs, drainAndSummarize, formatForNotification, hasAnyIssues", () => {
|
|
35
|
+
assert.match(
|
|
36
|
+
phasesSrc,
|
|
37
|
+
/from\s+"\.\.\/workflow-logger\.js"/,
|
|
38
|
+
"phases.ts imports from workflow-logger",
|
|
39
|
+
);
|
|
40
|
+
for (const name of [
|
|
41
|
+
"_resetLogs",
|
|
42
|
+
"drainLogs",
|
|
43
|
+
"drainAndSummarize",
|
|
44
|
+
"formatForNotification",
|
|
45
|
+
"hasAnyIssues",
|
|
46
|
+
]) {
|
|
47
|
+
assert.ok(
|
|
48
|
+
phasesSrc.includes(name),
|
|
49
|
+
`phases.ts should reference ${name}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("runUnitPhase calls _resetLogs() before assigning s.currentUnit", () => {
|
|
55
|
+
// Find the "s.currentUnit = { type: unitType" assignment line and check
|
|
56
|
+
// the preceding ~500 chars contain a _resetLogs() call.
|
|
57
|
+
const idx = phasesSrc.indexOf("s.currentUnit = { type: unitType");
|
|
58
|
+
assert.ok(idx > 0, "runUnitPhase should assign s.currentUnit");
|
|
59
|
+
const before = phasesSrc.slice(Math.max(0, idx - 500), idx);
|
|
60
|
+
assert.match(
|
|
61
|
+
before,
|
|
62
|
+
/_resetLogs\(\)/,
|
|
63
|
+
"_resetLogs() must be called immediately before s.currentUnit assignment",
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("runFinalize drains and surfaces logger buffer via ctx.ui.notify", () => {
|
|
68
|
+
// Locate the runFinalize success path and verify it calls drainAndSummarize
|
|
69
|
+
// and routes the result through ctx.ui.notify.
|
|
70
|
+
const runFinalizeIdx = phasesSrc.indexOf("export async function runFinalize");
|
|
71
|
+
assert.ok(runFinalizeIdx > 0, "runFinalize export should exist");
|
|
72
|
+
const finalizeBody = phasesSrc.slice(runFinalizeIdx);
|
|
73
|
+
assert.match(
|
|
74
|
+
finalizeBody,
|
|
75
|
+
/hasAnyIssues\(\)/,
|
|
76
|
+
"runFinalize should gate drain on hasAnyIssues",
|
|
77
|
+
);
|
|
78
|
+
assert.match(
|
|
79
|
+
finalizeBody,
|
|
80
|
+
/drainAndSummarize\(\)/,
|
|
81
|
+
"runFinalize should call drainAndSummarize on success",
|
|
82
|
+
);
|
|
83
|
+
assert.match(
|
|
84
|
+
finalizeBody,
|
|
85
|
+
/formatForNotification\(logs\)/,
|
|
86
|
+
"runFinalize should format drained logs for the notification",
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("runFinalize timeout branches drain the buffer to prevent bleed", () => {
|
|
91
|
+
// Both timeout branches null out s.currentUnit — they should also drain
|
|
92
|
+
// so accumulated logs for the timed-out unit don't leak into the next.
|
|
93
|
+
const runFinalizeIdx = phasesSrc.indexOf("export async function runFinalize");
|
|
94
|
+
const finalizeBody = phasesSrc.slice(runFinalizeIdx);
|
|
95
|
+
const drainCallCount =
|
|
96
|
+
(finalizeBody.match(/drainLogs\(\)/g) ?? []).length;
|
|
97
|
+
assert.ok(
|
|
98
|
+
drainCallCount >= 2,
|
|
99
|
+
`runFinalize timeout branches should each call drainLogs() (found ${drainCallCount}, expected >= 2)`,
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// ─── Source-scan: auto.ts calls setLogBasePath in startAuto ────────────────
|
|
104
|
+
|
|
105
|
+
test("startAuto calls setLogBasePath(base) so audit log is pinned on resume", () => {
|
|
106
|
+
const startAutoIdx = autoSrc.indexOf("export async function startAuto");
|
|
107
|
+
assert.ok(startAutoIdx > 0, "startAuto export should exist");
|
|
108
|
+
const body = autoSrc.slice(startAutoIdx);
|
|
109
|
+
assert.match(
|
|
110
|
+
body,
|
|
111
|
+
/setLogBasePath\(base\)/,
|
|
112
|
+
"startAuto must call setLogBasePath(base) to pin the audit log",
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// ─── Runtime: detect-stuck enriches reason with summarizeLogs() ────────────
|
|
117
|
+
|
|
118
|
+
test("detectStuck reason includes workflow-logger summary when logs present", () => {
|
|
119
|
+
setStderrLoggingEnabled(false);
|
|
120
|
+
try {
|
|
121
|
+
_resetLogs();
|
|
122
|
+
logWarning("projection", "STATE.md render failed");
|
|
123
|
+
logError("db", "WAL checkpoint failed");
|
|
124
|
+
|
|
125
|
+
const result = detectStuck([
|
|
126
|
+
{ key: "execute-task/slice-A/task-1", error: "ENOENT: no such file" },
|
|
127
|
+
{ key: "execute-task/slice-A/task-1", error: "ENOENT: no such file" },
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
assert.notEqual(result, null);
|
|
131
|
+
assert.equal(result!.stuck, true);
|
|
132
|
+
assert.match(
|
|
133
|
+
result!.reason,
|
|
134
|
+
/Same error repeated:/,
|
|
135
|
+
"reason should still start with the rule string",
|
|
136
|
+
);
|
|
137
|
+
assert.match(
|
|
138
|
+
result!.reason,
|
|
139
|
+
/STATE\.md render failed/,
|
|
140
|
+
"reason should include the accumulated logger warning",
|
|
141
|
+
);
|
|
142
|
+
assert.match(
|
|
143
|
+
result!.reason,
|
|
144
|
+
/WAL checkpoint failed/,
|
|
145
|
+
"reason should include the accumulated logger error",
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// Critical: summarizeLogs must not drain — the auto-loop's finalize
|
|
149
|
+
// step owns the buffer lifecycle, detect-stuck is read-only.
|
|
150
|
+
assert.equal(
|
|
151
|
+
peekLogs().length,
|
|
152
|
+
2,
|
|
153
|
+
"detect-stuck must not drain the buffer",
|
|
154
|
+
);
|
|
155
|
+
} finally {
|
|
156
|
+
_resetLogs();
|
|
157
|
+
setStderrLoggingEnabled(true);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("detectStuck reason unchanged when logger buffer is empty", () => {
|
|
162
|
+
setStderrLoggingEnabled(false);
|
|
163
|
+
try {
|
|
164
|
+
_resetLogs();
|
|
165
|
+
const result = detectStuck([
|
|
166
|
+
{ key: "A", error: "boom" },
|
|
167
|
+
{ key: "A", error: "boom" },
|
|
168
|
+
]);
|
|
169
|
+
assert.notEqual(result, null);
|
|
170
|
+
// No trailing " — " suffix when there are no logs to summarize.
|
|
171
|
+
assert.doesNotMatch(
|
|
172
|
+
result!.reason,
|
|
173
|
+
/ — \d+ (error|warning)/,
|
|
174
|
+
"reason should have no logger suffix when buffer is empty",
|
|
175
|
+
);
|
|
176
|
+
} finally {
|
|
177
|
+
setStderrLoggingEnabled(true);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// ─── Runtime: readTransaction rollback failure surfaces via logError ────────
|
|
182
|
+
//
|
|
183
|
+
// snapshotState now delegates its transaction to readTransaction() in
|
|
184
|
+
// gsd-db.ts (single-writer refactor in #4198), so the split-brain
|
|
185
|
+
// ROLLBACK-failure log lives there, not in workflow-manifest.ts.
|
|
186
|
+
|
|
187
|
+
test("readTransaction logs ROLLBACK failures as split-brain signal", () => {
|
|
188
|
+
const dbSrc = readFileSync(
|
|
189
|
+
join(import.meta.dirname, "..", "gsd-db.ts"),
|
|
190
|
+
"utf-8",
|
|
191
|
+
);
|
|
192
|
+
assert.match(
|
|
193
|
+
dbSrc,
|
|
194
|
+
/logError\("db",\s*"snapshotState ROLLBACK failed"/,
|
|
195
|
+
"readTransaction ROLLBACK catch should call logError",
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// ─── Runtime: state.ts and workflow-projections.ts log silent bailouts ─────
|
|
200
|
+
|
|
201
|
+
test("state.ts logs roadmap read failures instead of silently continuing", () => {
|
|
202
|
+
const stateSrc = readFileSync(
|
|
203
|
+
join(import.meta.dirname, "..", "state.ts"),
|
|
204
|
+
"utf-8",
|
|
205
|
+
);
|
|
206
|
+
assert.match(
|
|
207
|
+
stateSrc,
|
|
208
|
+
/logWarning\("state",\s*"reconcileDiskToDb: roadmap read failed/,
|
|
209
|
+
"state.ts reconcileDiskToDb should log roadmap read failures",
|
|
210
|
+
);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("workflow-projections.ts logs DB probe failures instead of silent return", () => {
|
|
214
|
+
const projectionsSrc = readFileSync(
|
|
215
|
+
join(import.meta.dirname, "..", "workflow-projections.ts"),
|
|
216
|
+
"utf-8",
|
|
217
|
+
);
|
|
218
|
+
assert.match(
|
|
219
|
+
projectionsSrc,
|
|
220
|
+
/logWarning\("projection",\s*"renderStateProjection: DB handle probe failed/,
|
|
221
|
+
"renderStateProjection DB probe should log on failure",
|
|
222
|
+
);
|
|
223
|
+
});
|
|
@@ -424,6 +424,32 @@ export async function handleCompleteSlice(
|
|
|
424
424
|
logError("tool", `complete-slice event log FAILED — completion invisible to reconciliation`, { error: (eventErr as Error).message });
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
+
// Fire-and-forget graph rebuild — must NOT await, must NOT crash slice completion.
|
|
428
|
+
// Dynamic import of the package name (not a relative path) so it resolves
|
|
429
|
+
// correctly via package.json#exports in both development and production.
|
|
430
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
431
|
+
(async () => {
|
|
432
|
+
try {
|
|
433
|
+
const graphMod = await import("@gsd-build/mcp-server") as unknown as Partial<{
|
|
434
|
+
buildGraph: (dir: string) => Promise<{ nodes: unknown[]; edges: unknown[]; builtAt: string }>;
|
|
435
|
+
writeGraph: (gsdRoot: string, graph: unknown) => Promise<void>;
|
|
436
|
+
resolveGsdRoot: (basePath: string) => string;
|
|
437
|
+
}>;
|
|
438
|
+
if (
|
|
439
|
+
typeof graphMod.buildGraph !== "function"
|
|
440
|
+
|| typeof graphMod.writeGraph !== "function"
|
|
441
|
+
|| typeof graphMod.resolveGsdRoot !== "function"
|
|
442
|
+
) {
|
|
443
|
+
throw new Error("graph helpers unavailable from @gsd-build/mcp-server");
|
|
444
|
+
}
|
|
445
|
+
const g = await graphMod.buildGraph(basePath);
|
|
446
|
+
await graphMod.writeGraph(graphMod.resolveGsdRoot(basePath), g);
|
|
447
|
+
} catch (graphErr) {
|
|
448
|
+
// Graph rebuild is best-effort — log at warning level but never propagate
|
|
449
|
+
logWarning("tool", `complete-slice graph rebuild failed (non-fatal): ${(graphErr as Error).message ?? String(graphErr)}`);
|
|
450
|
+
}
|
|
451
|
+
})();
|
|
452
|
+
|
|
427
453
|
return {
|
|
428
454
|
sliceId: params.sliceId,
|
|
429
455
|
milestoneId: params.milestoneId,
|
|
@@ -23,6 +23,9 @@ import { invalidateStateCache } from "../state.js";
|
|
|
23
23
|
import { VALIDATION_VERDICTS, isValidMilestoneVerdict } from "../verdict-parser.js";
|
|
24
24
|
import { insertMilestoneValidationGates } from "../milestone-validation-gates.js";
|
|
25
25
|
import { logWarning } from "../workflow-logger.js";
|
|
26
|
+
import { UokGateRunner } from "../uok/gate-runner.js";
|
|
27
|
+
import { loadEffectiveGSDPreferences } from "../preferences.js";
|
|
28
|
+
import { resolveUokFlags } from "../uok/flags.js";
|
|
26
29
|
|
|
27
30
|
export interface ValidateMilestoneParams {
|
|
28
31
|
milestoneId: string;
|
|
@@ -43,6 +46,12 @@ export interface ValidateMilestoneResult {
|
|
|
43
46
|
validationPath: string;
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
export interface ValidateMilestoneOptions {
|
|
50
|
+
uokGatesEnabled?: boolean;
|
|
51
|
+
traceId?: string;
|
|
52
|
+
turnId?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
function renderValidationMarkdown(params: ValidateMilestoneParams): string {
|
|
47
56
|
let md = `---
|
|
48
57
|
verdict: ${params.verdict}
|
|
@@ -81,6 +90,7 @@ ${params.verdictRationale}
|
|
|
81
90
|
export async function handleValidateMilestone(
|
|
82
91
|
params: ValidateMilestoneParams,
|
|
83
92
|
basePath: string,
|
|
93
|
+
opts?: ValidateMilestoneOptions,
|
|
84
94
|
): Promise<ValidateMilestoneResult | { error: string }> {
|
|
85
95
|
if (!params.milestoneId || typeof params.milestoneId !== "string" || params.milestoneId.trim() === "") {
|
|
86
96
|
return { error: "milestoneId is required and must be a non-empty string" };
|
|
@@ -108,6 +118,8 @@ export async function handleValidateMilestone(
|
|
|
108
118
|
// rendering can regenerate. The inverse (file exists, no DB row) is
|
|
109
119
|
// harder to detect and recover from (#2725).
|
|
110
120
|
const validatedAt = new Date().toISOString();
|
|
121
|
+
const slices = getMilestoneSlices(params.milestoneId);
|
|
122
|
+
const gateSliceId = slices.length > 0 ? slices[0].id : "_milestone";
|
|
111
123
|
|
|
112
124
|
transaction(() => {
|
|
113
125
|
insertAssessment({
|
|
@@ -123,11 +135,9 @@ export async function handleValidateMilestone(
|
|
|
123
135
|
// #2945 Bug 4: persist quality_gates records alongside the assessment.
|
|
124
136
|
// Previously only the assessment was written, leaving M002+ milestones
|
|
125
137
|
// with zero quality_gate records despite passing validation.
|
|
126
|
-
const slices = getMilestoneSlices(params.milestoneId);
|
|
127
|
-
const sliceId = slices.length > 0 ? slices[0].id : "_milestone";
|
|
128
138
|
insertMilestoneValidationGates(
|
|
129
139
|
params.milestoneId,
|
|
130
|
-
|
|
140
|
+
gateSliceId,
|
|
131
141
|
params.verdict,
|
|
132
142
|
validatedAt,
|
|
133
143
|
);
|
|
@@ -147,6 +157,41 @@ export async function handleValidateMilestone(
|
|
|
147
157
|
clearPathCache();
|
|
148
158
|
clearParseCache();
|
|
149
159
|
|
|
160
|
+
const prefs = loadEffectiveGSDPreferences()?.preferences;
|
|
161
|
+
const gatesEnabled = opts?.uokGatesEnabled ?? resolveUokFlags(prefs).gates;
|
|
162
|
+
if (gatesEnabled) {
|
|
163
|
+
try {
|
|
164
|
+
const gateRunner = new UokGateRunner();
|
|
165
|
+
const nonPassVerdict = params.verdict !== "pass";
|
|
166
|
+
gateRunner.register({
|
|
167
|
+
id: "milestone-validation-gates",
|
|
168
|
+
type: "verification",
|
|
169
|
+
execute: async () => ({
|
|
170
|
+
outcome: nonPassVerdict ? "manual-attention" : "pass",
|
|
171
|
+
failureClass: nonPassVerdict ? "manual-attention" : "none",
|
|
172
|
+
rationale: `milestone validation verdict: ${params.verdict}`,
|
|
173
|
+
findings: nonPassVerdict
|
|
174
|
+
? [params.verdictRationale, params.remediationPlan ?? ""].filter(Boolean).join("\n")
|
|
175
|
+
: "",
|
|
176
|
+
}),
|
|
177
|
+
});
|
|
178
|
+
await gateRunner.run("milestone-validation-gates", {
|
|
179
|
+
basePath,
|
|
180
|
+
traceId: opts?.traceId ?? `validate-milestone:${params.milestoneId}`,
|
|
181
|
+
turnId: opts?.turnId ?? `${params.milestoneId}:validate`,
|
|
182
|
+
milestoneId: params.milestoneId,
|
|
183
|
+
sliceId: gateSliceId,
|
|
184
|
+
unitType: "validate-milestone",
|
|
185
|
+
unitId: params.milestoneId,
|
|
186
|
+
});
|
|
187
|
+
} catch (err) {
|
|
188
|
+
logWarning(
|
|
189
|
+
"tool",
|
|
190
|
+
`validate_milestone — failed to persist UOK gate result: ${(err as Error).message}`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
150
195
|
return {
|
|
151
196
|
milestoneId: params.milestoneId,
|
|
152
197
|
verdict: params.verdict,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getMilestone,
|
|
6
6
|
getSliceStatusSummary,
|
|
7
7
|
getSliceTaskCounts,
|
|
8
|
-
|
|
8
|
+
readTransaction,
|
|
9
9
|
saveGateResult,
|
|
10
10
|
} from "../gsd-db.js";
|
|
11
11
|
import { GATE_REGISTRY } from "../gate-registry.js";
|
|
@@ -616,12 +616,9 @@ export async function executeMilestoneStatus(
|
|
|
616
616
|
};
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
-
|
|
620
|
-
adapter.exec("BEGIN");
|
|
621
|
-
try {
|
|
619
|
+
return readTransaction(() => {
|
|
622
620
|
const milestone = getMilestone(params.milestoneId);
|
|
623
621
|
if (!milestone) {
|
|
624
|
-
adapter.exec("COMMIT");
|
|
625
622
|
return {
|
|
626
623
|
content: [{ type: "text", text: `Milestone ${params.milestoneId} not found in database.` }],
|
|
627
624
|
details: { operation: "milestone_status", milestoneId: params.milestoneId, found: false },
|
|
@@ -635,8 +632,6 @@ export async function executeMilestoneStatus(
|
|
|
635
632
|
taskCounts: getSliceTaskCounts(params.milestoneId, s.id),
|
|
636
633
|
}));
|
|
637
634
|
|
|
638
|
-
adapter.exec("COMMIT");
|
|
639
|
-
|
|
640
635
|
const result = {
|
|
641
636
|
milestoneId: milestone.id,
|
|
642
637
|
title: milestone.title,
|
|
@@ -651,10 +646,7 @@ export async function executeMilestoneStatus(
|
|
|
651
646
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
652
647
|
details: { operation: "milestone_status", milestoneId: milestone.id, sliceCount: slices.length },
|
|
653
648
|
};
|
|
654
|
-
}
|
|
655
|
-
try { adapter.exec("ROLLBACK"); } catch { /* swallow */ }
|
|
656
|
-
throw txErr;
|
|
657
|
-
}
|
|
649
|
+
});
|
|
658
650
|
} catch (err) {
|
|
659
651
|
const msg = err instanceof Error ? err.message : String(err);
|
|
660
652
|
logWarning("tool", `gsd_milestone_status tool failed: ${msg}`);
|
|
@@ -111,14 +111,9 @@ export function executeReplan(
|
|
|
111
111
|
// Also write replan_triggered_at column for DB-backed detection
|
|
112
112
|
try {
|
|
113
113
|
const req = createRequire(import.meta.url);
|
|
114
|
-
const { isDbAvailable,
|
|
114
|
+
const { isDbAvailable, setSliceReplanTriggeredAt } = req("./gsd-db.js");
|
|
115
115
|
if (isDbAvailable()) {
|
|
116
|
-
|
|
117
|
-
if (adapter) {
|
|
118
|
-
adapter.prepare(
|
|
119
|
-
"UPDATE slices SET replan_triggered_at = :ts WHERE milestone_id = :mid AND id = :sid",
|
|
120
|
-
).run({ ":ts": ts, ":mid": mid, ":sid": sid });
|
|
121
|
-
}
|
|
116
|
+
setSliceReplanTriggeredAt(mid, sid, ts);
|
|
122
117
|
}
|
|
123
118
|
} catch {
|
|
124
119
|
// DB write is best-effort — disk file is the primary trigger for fallback path
|
|
@@ -306,7 +306,7 @@ export interface HookDispatchResult {
|
|
|
306
306
|
|
|
307
307
|
export type BudgetEnforcementMode = "warn" | "pause" | "halt";
|
|
308
308
|
|
|
309
|
-
export type TokenProfile = "budget" | "balanced" | "quality";
|
|
309
|
+
export type TokenProfile = "budget" | "balanced" | "quality" | "burn-max";
|
|
310
310
|
|
|
311
311
|
export type InlineLevel = "full" | "standard" | "minimal";
|
|
312
312
|
|
|
@@ -46,8 +46,8 @@ let loadAttempted = false;
|
|
|
46
46
|
|
|
47
47
|
function suppressSqliteWarning(): void {
|
|
48
48
|
const origEmit = process.emit;
|
|
49
|
-
//
|
|
50
|
-
process.emit = function (event: string, ...args: unknown[]): boolean {
|
|
49
|
+
// Override via loose cast: Node's overloaded emit signature is not directly assignable.
|
|
50
|
+
(process as any).emit = function (event: string, ...args: unknown[]): boolean {
|
|
51
51
|
if (
|
|
52
52
|
event === "warning" &&
|
|
53
53
|
args[0] &&
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const AUDIT_ENV_KEY = "GSD_UOK_AUDIT_UNIFIED";
|
|
2
|
+
|
|
3
|
+
export function setUnifiedAuditEnabled(enabled: boolean): void {
|
|
4
|
+
process.env[AUDIT_ENV_KEY] = enabled ? "1" : "0";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function isUnifiedAuditEnabled(): boolean {
|
|
8
|
+
return process.env[AUDIT_ENV_KEY] === "1";
|
|
9
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
import { gsdRoot } from "../paths.js";
|
|
6
|
+
import { isDbAvailable, insertAuditEvent } from "../gsd-db.js";
|
|
7
|
+
import type { AuditEventEnvelope } from "./contracts.js";
|
|
8
|
+
|
|
9
|
+
function auditLogPath(basePath: string): string {
|
|
10
|
+
return join(gsdRoot(basePath), "audit", "events.jsonl");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function ensureAuditDir(basePath: string): void {
|
|
14
|
+
mkdirSync(join(gsdRoot(basePath), "audit"), { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function buildAuditEnvelope(args: {
|
|
18
|
+
traceId: string;
|
|
19
|
+
turnId?: string;
|
|
20
|
+
causedBy?: string;
|
|
21
|
+
category: AuditEventEnvelope["category"];
|
|
22
|
+
type: string;
|
|
23
|
+
payload?: Record<string, unknown>;
|
|
24
|
+
}): AuditEventEnvelope {
|
|
25
|
+
return {
|
|
26
|
+
eventId: randomUUID(),
|
|
27
|
+
traceId: args.traceId,
|
|
28
|
+
turnId: args.turnId,
|
|
29
|
+
causedBy: args.causedBy,
|
|
30
|
+
category: args.category,
|
|
31
|
+
type: args.type,
|
|
32
|
+
ts: new Date().toISOString(),
|
|
33
|
+
payload: args.payload ?? {},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function emitUokAuditEvent(basePath: string, event: AuditEventEnvelope): void {
|
|
38
|
+
try {
|
|
39
|
+
ensureAuditDir(basePath);
|
|
40
|
+
appendFileSync(auditLogPath(basePath), `${JSON.stringify(event)}\n`, "utf-8");
|
|
41
|
+
} catch {
|
|
42
|
+
// Best-effort: audit writes must never break orchestration.
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!isDbAvailable()) return;
|
|
46
|
+
try {
|
|
47
|
+
insertAuditEvent(event);
|
|
48
|
+
} catch {
|
|
49
|
+
// Projection failures are non-fatal while legacy readers are still active.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export type FailureClass =
|
|
2
|
+
| "none"
|
|
3
|
+
| "policy"
|
|
4
|
+
| "input"
|
|
5
|
+
| "execution"
|
|
6
|
+
| "artifact"
|
|
7
|
+
| "verification"
|
|
8
|
+
| "closeout"
|
|
9
|
+
| "git"
|
|
10
|
+
| "timeout"
|
|
11
|
+
| "manual-attention"
|
|
12
|
+
| "unknown";
|
|
13
|
+
|
|
14
|
+
export type GateOutcome = "pass" | "fail" | "retry" | "manual-attention";
|
|
15
|
+
|
|
16
|
+
export interface GateResult {
|
|
17
|
+
gateId: string;
|
|
18
|
+
gateType: string;
|
|
19
|
+
outcome: GateOutcome;
|
|
20
|
+
failureClass: FailureClass;
|
|
21
|
+
rationale?: string;
|
|
22
|
+
findings?: string;
|
|
23
|
+
attempt: number;
|
|
24
|
+
maxAttempts: number;
|
|
25
|
+
retryable: boolean;
|
|
26
|
+
evaluatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type TurnPhase =
|
|
30
|
+
| "pre-dispatch"
|
|
31
|
+
| "dispatch"
|
|
32
|
+
| "unit"
|
|
33
|
+
| "finalize"
|
|
34
|
+
| "guard"
|
|
35
|
+
| "custom-engine";
|
|
36
|
+
|
|
37
|
+
export type TurnStatus =
|
|
38
|
+
| "completed"
|
|
39
|
+
| "failed"
|
|
40
|
+
| "paused"
|
|
41
|
+
| "stopped"
|
|
42
|
+
| "skipped"
|
|
43
|
+
| "retry";
|
|
44
|
+
|
|
45
|
+
export interface TurnContract {
|
|
46
|
+
traceId: string;
|
|
47
|
+
turnId: string;
|
|
48
|
+
iteration: number;
|
|
49
|
+
basePath: string;
|
|
50
|
+
unitType?: string;
|
|
51
|
+
unitId?: string;
|
|
52
|
+
sidecarKind?: string;
|
|
53
|
+
startedAt: string;
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface TurnCloseoutRecord {
|
|
58
|
+
traceId: string;
|
|
59
|
+
turnId: string;
|
|
60
|
+
unitType?: string;
|
|
61
|
+
unitId?: string;
|
|
62
|
+
status: TurnStatus;
|
|
63
|
+
failureClass: FailureClass;
|
|
64
|
+
gitAction: "commit" | "snapshot" | "status-only";
|
|
65
|
+
gitPushed: boolean;
|
|
66
|
+
activityFile?: string;
|
|
67
|
+
finishedAt: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface TurnResult {
|
|
71
|
+
traceId: string;
|
|
72
|
+
turnId: string;
|
|
73
|
+
iteration: number;
|
|
74
|
+
unitType?: string;
|
|
75
|
+
unitId?: string;
|
|
76
|
+
status: TurnStatus;
|
|
77
|
+
failureClass: FailureClass;
|
|
78
|
+
phaseResults: Array<{
|
|
79
|
+
phase: TurnPhase;
|
|
80
|
+
action: string;
|
|
81
|
+
ts: string;
|
|
82
|
+
data?: Record<string, unknown>;
|
|
83
|
+
}>;
|
|
84
|
+
gateResults?: GateResult[];
|
|
85
|
+
closeout?: TurnCloseoutRecord;
|
|
86
|
+
error?: string;
|
|
87
|
+
startedAt: string;
|
|
88
|
+
finishedAt: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface AuditEventEnvelope {
|
|
92
|
+
eventId: string;
|
|
93
|
+
traceId: string;
|
|
94
|
+
turnId?: string;
|
|
95
|
+
causedBy?: string;
|
|
96
|
+
category:
|
|
97
|
+
| "orchestration"
|
|
98
|
+
| "gate"
|
|
99
|
+
| "model-policy"
|
|
100
|
+
| "gitops"
|
|
101
|
+
| "verification"
|
|
102
|
+
| "metrics"
|
|
103
|
+
| "plan"
|
|
104
|
+
| "execution";
|
|
105
|
+
type: string;
|
|
106
|
+
ts: string;
|
|
107
|
+
payload: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type UokNodeKind =
|
|
111
|
+
| "unit"
|
|
112
|
+
| "hook"
|
|
113
|
+
| "subagent"
|
|
114
|
+
| "team-worker"
|
|
115
|
+
| "verification"
|
|
116
|
+
| "reprocess";
|
|
117
|
+
|
|
118
|
+
export interface UokGraphNode {
|
|
119
|
+
id: string;
|
|
120
|
+
kind: UokNodeKind;
|
|
121
|
+
dependsOn: string[];
|
|
122
|
+
writes?: string[];
|
|
123
|
+
reads?: string[];
|
|
124
|
+
metadata?: Record<string, unknown>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface UokTurnObserver {
|
|
128
|
+
onTurnStart(contract: TurnContract): void;
|
|
129
|
+
onPhaseResult(
|
|
130
|
+
phase: TurnPhase,
|
|
131
|
+
action: string,
|
|
132
|
+
data?: Record<string, unknown>,
|
|
133
|
+
): void;
|
|
134
|
+
onTurnResult(result: TurnResult): void;
|
|
135
|
+
}
|