clinkx 1.0.0 → 1.1.1
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/CHANGELOG.md +95 -0
- package/README.md +184 -112
- package/clinkx-workflows/dist/chairman-knobs.d.ts +24 -0
- package/clinkx-workflows/dist/chairman-knobs.js +27 -0
- package/clinkx-workflows/dist/chairman-knobs.js.map +1 -0
- package/clinkx-workflows/dist/clink-client.d.ts +10 -0
- package/clinkx-workflows/dist/clink-client.js +39 -1
- package/clinkx-workflows/dist/clink-client.js.map +1 -1
- package/clinkx-workflows/dist/config.d.ts +29 -1
- package/clinkx-workflows/dist/config.js +35 -2
- package/clinkx-workflows/dist/config.js.map +1 -1
- package/clinkx-workflows/dist/context-preflight.d.ts +5 -0
- package/clinkx-workflows/dist/context-preflight.js.map +1 -1
- package/clinkx-workflows/dist/council-execution-policy.d.ts +68 -0
- package/clinkx-workflows/dist/council-execution-policy.js +110 -0
- package/clinkx-workflows/dist/council-execution-policy.js.map +1 -0
- package/clinkx-workflows/dist/council-expander.d.ts +9 -8
- package/clinkx-workflows/dist/council-expander.js +18 -9
- package/clinkx-workflows/dist/council-expander.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/activity-contract.d.ts +5557 -4
- package/clinkx-workflows/dist/dashboard/activity-contract.js +55 -3
- package/clinkx-workflows/dist/dashboard/activity-contract.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/activity-reader.d.ts +9 -5
- package/clinkx-workflows/dist/dashboard/activity-reader.js +15 -2
- package/clinkx-workflows/dist/dashboard/activity-reader.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/api-routes.d.ts +4 -0
- package/clinkx-workflows/dist/dashboard/api-routes.js +133 -25
- package/clinkx-workflows/dist/dashboard/api-routes.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.d.ts +3865 -0
- package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.js +69 -0
- package/clinkx-workflows/dist/dashboard/context-builder-invocation-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.d.ts +36 -2
- package/clinkx-workflows/dist/dashboard/context-run-reader.js +142 -19
- package/clinkx-workflows/dist/dashboard/context-run-reader.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/contracts.d.ts +20027 -480
- package/clinkx-workflows/dist/dashboard/contracts.js +133 -6
- package/clinkx-workflows/dist/dashboard/contracts.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/index.d.ts +4 -0
- package/clinkx-workflows/dist/dashboard/index.js +4 -0
- package/clinkx-workflows/dist/dashboard/index.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/invocation-contract.d.ts +786 -0
- package/clinkx-workflows/dist/dashboard/invocation-contract.js +201 -0
- package/clinkx-workflows/dist/dashboard/invocation-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.d.ts +14 -1
- package/clinkx-workflows/dist/dashboard/lazy-content.js +53 -2
- package/clinkx-workflows/dist/dashboard/lazy-content.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.d.ts +90 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.js +31 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.d.ts +12 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.js +286 -0
- package/clinkx-workflows/dist/dashboard/native-transcript/projection.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +147 -4
- package/clinkx-workflows/dist/dashboard/progress-report-contract.js +11 -11
- package/clinkx-workflows/dist/dashboard/progress-report-contract.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/progress-report-reader.js +4 -56
- package/clinkx-workflows/dist/dashboard/progress-report-reader.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.d.ts +2 -1
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js +6 -5
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.d.ts +194 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.js +89 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.d.ts +26 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.js +102 -0
- package/clinkx-workflows/dist/dashboard/prompt-builder-library-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js +4 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/scanner.d.ts +3 -0
- package/clinkx-workflows/dist/dashboard/scanner.js +52 -8
- package/clinkx-workflows/dist/dashboard/scanner.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/server-factory.d.ts +14 -1
- package/clinkx-workflows/dist/dashboard/server-factory.js +73 -21
- package/clinkx-workflows/dist/dashboard/server-factory.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +223 -56
- package/clinkx-workflows/dist/dashboard/session-log-contract.js +26 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/session-log-journal.js +10 -3
- package/clinkx-workflows/dist/dashboard/session-log-journal.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/session-log-redaction.d.ts +9 -1
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js +793 -59
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js.map +1 -1
- package/clinkx-workflows/dist/dashboard-ui/assets/index-JPHQVtn9.js +106 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/style-DOMHk-j6.css +1 -0
- package/clinkx-workflows/dist/dashboard-ui/index.html +2 -2
- package/clinkx-workflows/dist/delegate-finalizer-policy.d.ts +26 -0
- package/clinkx-workflows/dist/delegate-finalizer-policy.js +72 -0
- package/clinkx-workflows/dist/delegate-finalizer-policy.js.map +1 -0
- package/clinkx-workflows/dist/delegate-signature.d.ts +14 -0
- package/clinkx-workflows/dist/delegate-signature.js +14 -0
- package/clinkx-workflows/dist/delegate-signature.js.map +1 -0
- package/clinkx-workflows/dist/delegate-validate.d.ts +32 -2
- package/clinkx-workflows/dist/delegate-validate.js +51 -0
- package/clinkx-workflows/dist/delegate-validate.js.map +1 -1
- package/clinkx-workflows/dist/engine.d.ts +113 -3
- package/clinkx-workflows/dist/engine.js +476 -80
- package/clinkx-workflows/dist/engine.js.map +1 -1
- package/clinkx-workflows/dist/errors.d.ts +22 -2
- package/clinkx-workflows/dist/errors.js +30 -2
- package/clinkx-workflows/dist/errors.js.map +1 -1
- package/clinkx-workflows/dist/fidelity.d.ts +47 -1
- package/clinkx-workflows/dist/fidelity.js +54 -1
- package/clinkx-workflows/dist/fidelity.js.map +1 -1
- package/clinkx-workflows/dist/fingerprint.d.ts +24 -6
- package/clinkx-workflows/dist/fingerprint.js +32 -9
- package/clinkx-workflows/dist/fingerprint.js.map +1 -1
- package/clinkx-workflows/dist/index.js +53 -1
- package/clinkx-workflows/dist/index.js.map +1 -1
- package/clinkx-workflows/dist/logger.d.ts +1 -1
- package/clinkx-workflows/dist/logger.js +17 -3
- package/clinkx-workflows/dist/logger.js.map +1 -1
- package/clinkx-workflows/dist/monotonic-clock.d.ts +19 -0
- package/clinkx-workflows/dist/monotonic-clock.js +22 -0
- package/clinkx-workflows/dist/monotonic-clock.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/contract.d.ts +52 -52
- package/clinkx-workflows/dist/plan-review/publication.d.ts +4 -4
- package/clinkx-workflows/dist/plan-review/run-state.d.ts +16 -16
- package/clinkx-workflows/dist/roster-contract.d.ts +889 -0
- package/clinkx-workflows/dist/roster-contract.js +180 -0
- package/clinkx-workflows/dist/roster-contract.js.map +1 -0
- package/clinkx-workflows/dist/rosters.d.ts +14 -0
- package/clinkx-workflows/dist/rosters.js +169 -0
- package/clinkx-workflows/dist/rosters.js.map +1 -0
- package/clinkx-workflows/dist/run-health.d.ts +7 -0
- package/clinkx-workflows/dist/run-health.js +25 -0
- package/clinkx-workflows/dist/run-health.js.map +1 -0
- package/clinkx-workflows/dist/schema.d.ts +64 -0
- package/clinkx-workflows/dist/schema.js +24 -0
- package/clinkx-workflows/dist/schema.js.map +1 -1
- package/clinkx-workflows/dist/server.js +2 -0
- package/clinkx-workflows/dist/server.js.map +1 -1
- package/clinkx-workflows/dist/shutdown.d.ts +15 -2
- package/clinkx-workflows/dist/shutdown.js +60 -16
- package/clinkx-workflows/dist/shutdown.js.map +1 -1
- package/clinkx-workflows/dist/state-schema.d.ts +23 -0
- package/clinkx-workflows/dist/state.d.ts +5 -0
- package/clinkx-workflows/dist/state.js +128 -21
- package/clinkx-workflows/dist/state.js.map +1 -1
- package/clinkx-workflows/dist/stdio-watchdog.d.ts +52 -0
- package/clinkx-workflows/dist/stdio-watchdog.js +212 -0
- package/clinkx-workflows/dist/stdio-watchdog.js.map +1 -0
- package/clinkx-workflows/dist/types.d.ts +6 -0
- package/clinkx-workflows/dist/validators/council.d.ts +50 -50
- package/clinkx-workflows/dist/validators/plan-review.d.ts +3 -3
- package/clinkx-workflows/dist/workflow-tools.d.ts +70 -0
- package/clinkx-workflows/dist/workflow-tools.js +760 -168
- package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
- package/clinkx-workflows/templates/council/answer-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/answer-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/answer-specialist.txt +3 -0
- package/clinkx-workflows/templates/council/chairman.txt +3 -0
- package/clinkx-workflows/templates/council/code-review-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/code-review-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/code-review-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/debug-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/debug-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/debug-debugger.txt +3 -0
- package/clinkx-workflows/templates/council/discover-analyst.txt +3 -0
- package/clinkx-workflows/templates/council/discover-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/discover-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/member.txt +3 -0
- package/clinkx-workflows/templates/council/plan-review-chairman.txt +3 -0
- package/clinkx-workflows/templates/council/plan-review-cross-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/plan-review-reviewer.txt +3 -0
- package/clinkx-workflows/templates/council/reviewer.txt +3 -0
- package/clinkx-workflows/workflows/council-answer.yaml +3 -0
- package/clinkx-workflows/workflows/council-code-review.yaml +3 -0
- package/clinkx-workflows/workflows/council-debug.yaml +3 -0
- package/clinkx-workflows/workflows/council-default.yaml +7 -0
- package/clinkx-workflows/workflows/council-discover.yaml +3 -0
- package/clinkx-workflows/workflows/council-plan-review.yaml +3 -0
- package/conf/adapters/agy.json +9 -2
- package/conf/adapters/claude.json +7 -0
- package/conf/adapters/codex.json +7 -0
- package/conf/adapters/glm.json +19 -3
- package/conf/adapters/grok.json +9 -2
- package/conf/adapters/hapi/agy.json +9 -2
- package/conf/adapters/hapi/claude.json +7 -0
- package/conf/adapters/hapi/codex.json +7 -0
- package/conf/adapters/hapi/glm.json +20 -4
- package/conf/rosters/default-council.json +21 -0
- package/dist/activity-journal.d.ts +17 -3
- package/dist/activity-journal.js +404 -79
- package/dist/activity-journal.js.map +1 -1
- package/dist/codex/agent-tools.js +36 -0
- package/dist/codex/agent-tools.js.map +1 -1
- package/dist/codex/app-server-client.d.ts +3 -0
- package/dist/codex/app-server-client.js +11 -0
- package/dist/codex/app-server-client.js.map +1 -1
- package/dist/codex/app-server-registry.d.ts +18 -0
- package/dist/codex/app-server-registry.js +88 -2
- package/dist/codex/app-server-registry.js.map +1 -1
- package/dist/codex/client-types.d.ts +7 -1
- package/dist/codex/protocol.d.ts +4 -4
- package/dist/config.d.ts +220 -23
- package/dist/config.js +104 -1
- package/dist/config.js.map +1 -1
- package/dist/context-builder/bundle.d.ts +13 -0
- package/dist/context-builder/bundle.js +46 -0
- package/dist/context-builder/bundle.js.map +1 -1
- package/dist/context-builder/delegate-finalizer-effective.d.ts +33 -0
- package/dist/context-builder/delegate-finalizer-effective.js +82 -0
- package/dist/context-builder/delegate-finalizer-effective.js.map +1 -0
- package/dist/context-builder/delegate-packet.d.ts +18 -0
- package/dist/context-builder/delegate-packet.js +73 -9
- package/dist/context-builder/delegate-packet.js.map +1 -1
- package/dist/context-builder/delegate-reconstruction.d.ts +29 -0
- package/dist/context-builder/delegate-reconstruction.js +110 -41
- package/dist/context-builder/delegate-reconstruction.js.map +1 -1
- package/dist/context-builder/delegate-validation.d.ts +31 -0
- package/dist/context-builder/delegate-validation.js +87 -10
- package/dist/context-builder/delegate-validation.js.map +1 -1
- package/dist/context-builder/delegate.d.ts +9 -0
- package/dist/context-builder/delegate.js +210 -59
- package/dist/context-builder/delegate.js.map +1 -1
- package/dist/context-builder/diagnostics.d.ts +1 -1
- package/dist/context-builder/diagnostics.js.map +1 -1
- package/dist/context-builder/discovery-progress.d.ts +25 -0
- package/dist/context-builder/discovery-progress.js +64 -0
- package/dist/context-builder/discovery-progress.js.map +1 -0
- package/dist/context-builder/discovery-watchdog.d.ts +15 -0
- package/dist/context-builder/discovery-watchdog.js +39 -0
- package/dist/context-builder/discovery-watchdog.js.map +1 -0
- package/dist/context-builder/discovery.d.ts +7 -0
- package/dist/context-builder/discovery.js +119 -7
- package/dist/context-builder/discovery.js.map +1 -1
- package/dist/context-builder/external-gaps.d.ts +73 -0
- package/dist/context-builder/external-gaps.js +248 -0
- package/dist/context-builder/external-gaps.js.map +1 -0
- package/dist/context-builder/globs.d.ts +1 -0
- package/dist/context-builder/globs.js +15 -0
- package/dist/context-builder/globs.js.map +1 -1
- package/dist/context-builder/handler.d.ts +42 -1
- package/dist/context-builder/handler.js +690 -62
- package/dist/context-builder/handler.js.map +1 -1
- package/dist/context-builder/invocation-sidecar.d.ts +41 -0
- package/dist/context-builder/invocation-sidecar.js +189 -0
- package/dist/context-builder/invocation-sidecar.js.map +1 -0
- package/dist/context-builder/lifecycle-contract.d.ts +51 -51
- package/dist/context-builder/mutation-lock.d.ts +32 -0
- package/dist/context-builder/mutation-lock.js +321 -0
- package/dist/context-builder/mutation-lock.js.map +1 -0
- package/dist/context-builder/review-coverage.d.ts +32 -0
- package/dist/context-builder/review-coverage.js +130 -23
- package/dist/context-builder/review-coverage.js.map +1 -1
- package/dist/context-builder/schema.d.ts +76 -1
- package/dist/context-builder/schema.js +21 -1
- package/dist/context-builder/schema.js.map +1 -1
- package/dist/context-builder/secrets.d.ts +31 -0
- package/dist/context-builder/secrets.js +871 -84
- package/dist/context-builder/secrets.js.map +1 -1
- package/dist/context-builder/status.d.ts +1 -1
- package/dist/context-builder/status.js +1 -0
- package/dist/context-builder/status.js.map +1 -1
- package/dist/context-builder/storage.d.ts +29 -5
- package/dist/context-builder/storage.js +311 -236
- package/dist/context-builder/storage.js.map +1 -1
- package/dist/context-builder/versions.d.ts +19 -4
- package/dist/context-builder/versions.js +19 -4
- package/dist/context-builder/versions.js.map +1 -1
- package/dist/context-builder/workflow-runner.d.ts +6 -0
- package/dist/context-builder/workflow-runner.js +363 -173
- package/dist/context-builder/workflow-runner.js.map +1 -1
- package/dist/dashboard-adapter-catalog.js +7 -0
- package/dist/dashboard-adapter-catalog.js.map +1 -1
- package/dist/dashboard-cli.d.ts +2 -0
- package/dist/dashboard-cli.js +40 -2
- package/dist/dashboard-cli.js.map +1 -1
- package/dist/dashboard-companion/client.d.ts +1 -0
- package/dist/dashboard-companion/client.js +22 -3
- package/dist/dashboard-companion/client.js.map +1 -1
- package/dist/dashboard-companion/protocol.js +4 -1
- package/dist/dashboard-companion/protocol.js.map +1 -1
- package/dist/dashboard-gateway/index.d.ts +1 -0
- package/dist/dashboard-gateway/index.js +33 -2
- package/dist/dashboard-gateway/index.js.map +1 -1
- package/dist/handler.js +5 -1
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +145 -7
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +18 -3
- package/dist/logger.js.map +1 -1
- package/dist/parsers/agy-stream-json.d.ts +14 -0
- package/dist/parsers/agy-stream-json.js +172 -0
- package/dist/parsers/agy-stream-json.js.map +1 -0
- package/dist/parsers/extract.js +5 -1
- package/dist/parsers/extract.js.map +1 -1
- package/dist/parsers/observed-invocation.d.ts +20 -0
- package/dist/parsers/observed-invocation.js +42 -0
- package/dist/parsers/observed-invocation.js.map +1 -0
- package/dist/pipeline.d.ts +13 -0
- package/dist/pipeline.js +60 -10
- package/dist/pipeline.js.map +1 -1
- package/dist/progress-report/lock.d.ts +74 -0
- package/dist/progress-report/lock.js +343 -0
- package/dist/progress-report/lock.js.map +1 -0
- package/dist/progress-report/schema.d.ts +808 -0
- package/dist/progress-report/schema.js +119 -0
- package/dist/progress-report/schema.js.map +1 -0
- package/dist/progress-report/store.d.ts +66 -0
- package/dist/progress-report/store.js +766 -0
- package/dist/progress-report/store.js.map +1 -0
- package/dist/progress-report/tools.d.ts +20 -0
- package/dist/progress-report/tools.js +141 -0
- package/dist/progress-report/tools.js.map +1 -0
- package/dist/prompt-mode.d.ts +1 -1
- package/dist/prompt-mode.js +7 -2
- package/dist/prompt-mode.js.map +1 -1
- package/dist/runner.d.ts +7 -0
- package/dist/runner.js +10 -3
- package/dist/runner.js.map +1 -1
- package/dist/safety.d.ts +50 -0
- package/dist/safety.js +182 -1
- package/dist/safety.js.map +1 -1
- package/dist/schema.d.ts +8 -0
- package/dist/schema.js +20 -0
- package/dist/schema.js.map +1 -1
- package/dist/server.d.ts +6 -1
- package/dist/server.js +94 -8
- package/dist/server.js.map +1 -1
- package/dist/session-log-stream.d.ts +1 -1
- package/dist/session-log-stream.js +280 -33
- package/dist/session-log-stream.js.map +1 -1
- package/dist/stdio-activity.d.ts +28 -0
- package/dist/stdio-activity.js +72 -0
- package/dist/stdio-activity.js.map +1 -0
- package/docs/configuration.md +426 -0
- package/docs/security.md +293 -0
- package/package.json +5 -5
- package/clinkx-workflows/dist/dashboard-ui/assets/index-DOkMXTfB.js +0 -25
- package/clinkx-workflows/dist/dashboard-ui/assets/style-ChJsn0KD.css +0 -1
|
@@ -6,17 +6,20 @@ import { dirname, basename, isAbsolute, join, relative, resolve } from "node:pat
|
|
|
6
6
|
import { hostname } from "node:os";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { WorkflowError } from "./errors.js";
|
|
9
|
+
import { computeRunHealth } from "./run-health.js";
|
|
9
10
|
import { buildFidelityMetadata, } from "./fidelity.js";
|
|
10
11
|
import { fingerprintsMatch, generateFingerprint, generateWorkflowFingerprint, } from "./fingerprint.js";
|
|
12
|
+
import { effectiveFinalizerEnabled } from "./delegate-finalizer-policy.js";
|
|
11
13
|
import { parseWorkflowContext, } from "./context-preflight.js";
|
|
12
14
|
import { isLegalContextBuilderLifecycleTransition, parseContextBuilderLifecycleStateV1, } from "./context-builder-lifecycle-contract.js";
|
|
15
|
+
import { ResolvedRosterSchema, RosterNameSchema } from "./roster-contract.js";
|
|
13
16
|
import { PlanReviewRunStateSchema, } from "./plan-review/run-state.js";
|
|
14
17
|
import { CouncilPlanReviewErrorSchema, createPlanReviewPublicationError, serializePlanReviewResult, writeSerializedPlanReviewResultSidecar, } from "./plan-review/publication.js";
|
|
15
18
|
import { isPlanReviewPublicationEligible, projectPlanReviewRun, } from "./plan-review/projector.js";
|
|
16
19
|
import { isPlanReviewRunState } from "./plan-review/admission.js";
|
|
17
20
|
import { restorePlanReviewRun } from "./plan-review/resume.js";
|
|
18
21
|
import { PlanReviewStageError } from "./plan-review/stage-error.js";
|
|
19
|
-
import { DEFAULT_RETAIN_ASYNC_DAYS, DEFAULT_RETAIN_CANCELLED_DAYS, DEFAULT_RETAIN_DEBUG_DAYS, DEFAULT_RETAIN_FAILED_DAYS, DEFAULT_RETAIN_SUCCEEDED_DAYS, deriveAllowedRoots, getArtifactsDir, getChildConfigPath, getChildMaxConcurrent, getChildMaxOutputBytes, getChildMaxPromptBytes, getChildMaxResponseChars, getLogLevel, getRetentionConfig, getRunsDir, getRunStateDir, getStateDir, resolveWorkspaceRoot, } from "./config.js";
|
|
22
|
+
import { DEFAULT_RETAIN_ASYNC_DAYS, DEFAULT_RETAIN_CANCELLED_DAYS, DEFAULT_RETAIN_DEBUG_DAYS, DEFAULT_RETAIN_FAILED_DAYS, DEFAULT_RETAIN_SUCCEEDED_DAYS, deriveAllowedRoots, getArtifactsDir, getChildConfigPath, getChildMaxConcurrent, getChildMaxOutputBytes, getChildMaxPromptBytes, getChildMaxResponseChars, getLogLevel, getRetentionConfig, getRunsDir, getRunStateDir, getStateDir, invocationAuditV2PersistenceEnabled, observedInvocationPersistenceEnabled, resolveWorkspaceRoot, } from "./config.js";
|
|
20
23
|
import { logger } from "./logger.js";
|
|
21
24
|
import { resolveOpenedDescriptorPath } from "./contained-file.js";
|
|
22
25
|
import { deriveWorkflowRunGeneration } from "./dashboard/generation.js";
|
|
@@ -186,38 +189,44 @@ class RunLockOwnershipLostError extends Error {
|
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
191
|
export function classifyRunDirectory(runDirPath) {
|
|
192
|
+
return inspectRunDirectory(runDirPath).classification;
|
|
193
|
+
}
|
|
194
|
+
function inspectRunDirectory(runDirPath) {
|
|
189
195
|
try {
|
|
190
196
|
const state = readRunStateSync(runDirPath);
|
|
191
197
|
const lockStatus = classifyRunLockSync(join(runDirPath, RUN_LOCK_FILENAME));
|
|
192
198
|
if (lockStatus === "held") {
|
|
193
|
-
return "active_locked";
|
|
199
|
+
return { classification: "active_locked" };
|
|
194
200
|
}
|
|
195
201
|
if (lockStatus === "unknown") {
|
|
196
|
-
return "unknown";
|
|
202
|
+
return { classification: "unknown" };
|
|
197
203
|
}
|
|
198
204
|
switch (state.status) {
|
|
199
205
|
case "failed":
|
|
200
|
-
return "failed";
|
|
206
|
+
return { classification: "failed", state };
|
|
201
207
|
case "cancelled":
|
|
202
|
-
return "cancelled";
|
|
208
|
+
return { classification: "cancelled", state };
|
|
203
209
|
case "succeeded": {
|
|
204
210
|
if ((state.debugKeepArtifacts !== undefined && typeof state.debugKeepArtifacts !== "boolean") ||
|
|
205
211
|
(state.async !== undefined && typeof state.async !== "boolean")) {
|
|
206
|
-
return "unknown";
|
|
212
|
+
return { classification: "unknown" };
|
|
207
213
|
}
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
|
|
214
|
+
return {
|
|
215
|
+
classification: state.debugKeepArtifacts === true
|
|
216
|
+
? "debug_kept"
|
|
217
|
+
: (state.async === true ? "succeeded_async" : "succeeded_sync"),
|
|
218
|
+
state,
|
|
219
|
+
};
|
|
211
220
|
}
|
|
212
221
|
case "running":
|
|
213
222
|
case "pending":
|
|
214
|
-
return "running_or_pending";
|
|
223
|
+
return { classification: "running_or_pending" };
|
|
215
224
|
default:
|
|
216
|
-
return "unknown";
|
|
225
|
+
return { classification: "unknown" };
|
|
217
226
|
}
|
|
218
227
|
}
|
|
219
228
|
catch {
|
|
220
|
-
return "unknown";
|
|
229
|
+
return { classification: "unknown" };
|
|
221
230
|
}
|
|
222
231
|
}
|
|
223
232
|
export async function pruneRunDirectories(runsRootDir, options) {
|
|
@@ -246,8 +255,17 @@ export async function pruneRunDirectories(runsRootDir, options) {
|
|
|
246
255
|
}
|
|
247
256
|
const runDirPath = join(runsRootDir, entry.name);
|
|
248
257
|
try {
|
|
249
|
-
const classification =
|
|
250
|
-
|
|
258
|
+
const { classification, state } = inspectRunDirectory(runDirPath);
|
|
259
|
+
let retainDays = retentionDaysForClassification(classification, retention);
|
|
260
|
+
if ((classification === "succeeded_async" || classification === "succeeded_sync") &&
|
|
261
|
+
state != null && retainDays != null && retainDays > 0 &&
|
|
262
|
+
computeRunHealth(state, state.context_builder_lifecycle).classification === "degraded") {
|
|
263
|
+
// Zero means unlimited retention, not the smallest TTL. Keep explicit
|
|
264
|
+
// debug policy separate and never shorten a longer success override.
|
|
265
|
+
retainDays = retention.retainFailedDays === 0
|
|
266
|
+
? 0
|
|
267
|
+
: Math.max(retainDays, retention.retainFailedDays);
|
|
268
|
+
}
|
|
251
269
|
if (retainDays == null || retainDays === 0) {
|
|
252
270
|
result.skipped += 1;
|
|
253
271
|
continue;
|
|
@@ -391,6 +409,8 @@ export class WorkflowStateStore {
|
|
|
391
409
|
heartbeat;
|
|
392
410
|
heartbeatInFlight;
|
|
393
411
|
heartbeatError;
|
|
412
|
+
persistInvocationAuditV2;
|
|
413
|
+
persistObservedInvocation;
|
|
394
414
|
constructor(options) {
|
|
395
415
|
this.runDir = options.runDir;
|
|
396
416
|
this.sessionLogGeneration = options.sessionLogGeneration;
|
|
@@ -402,6 +422,8 @@ export class WorkflowStateStore {
|
|
|
402
422
|
this.debugKeepArtifacts = options.debugKeepArtifacts;
|
|
403
423
|
this.lockPath = join(options.runDir, RUN_LOCK_FILENAME);
|
|
404
424
|
this.lockToken = options.lockToken;
|
|
425
|
+
this.persistInvocationAuditV2 = invocationAuditV2PersistenceEnabled();
|
|
426
|
+
this.persistObservedInvocation = observedInvocationPersistenceEnabled();
|
|
405
427
|
this.startHeartbeat();
|
|
406
428
|
this.hooks = {
|
|
407
429
|
onRunStateChange: async (event) => {
|
|
@@ -426,7 +448,9 @@ export class WorkflowStateStore {
|
|
|
426
448
|
}
|
|
427
449
|
const nextState = structuredClone(this.state);
|
|
428
450
|
nextState.status = event.state;
|
|
429
|
-
|
|
451
|
+
// First emit to set startedAt wins: a fresh run fills an empty
|
|
452
|
+
// field, and a resume can never overwrite the original run start.
|
|
453
|
+
nextState.startedAt = nextState.startedAt ?? event.startedAt;
|
|
430
454
|
nextState.completedAt = event.completedAt;
|
|
431
455
|
nextState.error = cappedError;
|
|
432
456
|
nextState.failureClass = event.failureClass;
|
|
@@ -443,6 +467,10 @@ export class WorkflowStateStore {
|
|
|
443
467
|
callEntry.materializedInputPath = inputPath;
|
|
444
468
|
callEntry.contextProducing = event.contextProducing;
|
|
445
469
|
callEntry.retryCount = event.retryCount;
|
|
470
|
+
if (this.persistInvocationAuditV2 &&
|
|
471
|
+
event.invocation !== undefined) {
|
|
472
|
+
callEntry.invocation = event.invocation;
|
|
473
|
+
}
|
|
446
474
|
this.state = nextState;
|
|
447
475
|
await this.writeState();
|
|
448
476
|
});
|
|
@@ -460,9 +488,33 @@ export class WorkflowStateStore {
|
|
|
460
488
|
callEntry.completedAt = event.completedAt;
|
|
461
489
|
callEntry.durationMs = event.durationMs;
|
|
462
490
|
callEntry.errorMessage = capPersistedError(event.error);
|
|
463
|
-
|
|
491
|
+
// Two opposite hazards, hence three branches:
|
|
492
|
+
// (1) ERASURE — a terminal emit that omits failureClass would, under
|
|
493
|
+
// an unconditional assignment, wipe a class the engine did
|
|
494
|
+
// classify. Only assign from the event when it carries one.
|
|
495
|
+
// (2) STALE CARRY-OVER — the succeeded emit carries no failureClass
|
|
496
|
+
// (engine.ts), while applyRetryUpdate persists one on every
|
|
497
|
+
// scheduled retry. Without the explicit clear, a call that
|
|
498
|
+
// finally succeeds after a retry stays stamped with the failed
|
|
499
|
+
// attempt's class forever, and is read as such by
|
|
500
|
+
// dashboard/scanner.ts and run-summary-derived.ts.
|
|
501
|
+
// "running" is deliberately in neither branch: a running emit must
|
|
502
|
+
// not clear the prior attempt's class, which resume reads.
|
|
503
|
+
if (event.failureClass !== undefined) {
|
|
504
|
+
callEntry.failureClass = event.failureClass;
|
|
505
|
+
}
|
|
506
|
+
else if (event.state === "succeeded") {
|
|
507
|
+
callEntry.failureClass = undefined;
|
|
508
|
+
}
|
|
464
509
|
callEntry.childDebugMetadata = event.childDebugMetadata;
|
|
465
510
|
callEntry.contextProducing = callEntry.contextProducing ?? false;
|
|
511
|
+
// Observed-invocation telemetry rides only the terminal succeeded
|
|
512
|
+
// emit; running/failed events carry none and must not write it.
|
|
513
|
+
if (this.persistObservedInvocation &&
|
|
514
|
+
event.observedInvocation !== undefined &&
|
|
515
|
+
event.state === "succeeded") {
|
|
516
|
+
callEntry.observedInvocation = event.observedInvocation;
|
|
517
|
+
}
|
|
466
518
|
if (event.outputText != null) {
|
|
467
519
|
const { outputInline, outputPath } = await persistOutput(this.runDir, event.stageId, event.callId, event.outputText);
|
|
468
520
|
callEntry.outputInline = outputInline;
|
|
@@ -511,13 +563,19 @@ export class WorkflowStateStore {
|
|
|
511
563
|
const childConfigPath = getChildConfigPath();
|
|
512
564
|
const resumable = childConfigPath != null;
|
|
513
565
|
const fingerprintData = resumable
|
|
514
|
-
? await buildChildConfigFingerprint(options.definition)
|
|
566
|
+
? await buildChildConfigFingerprint(options.definition, options.initialContextPolicy, options.variables)
|
|
515
567
|
: undefined;
|
|
516
568
|
if (fingerprintData != null) {
|
|
517
569
|
const childConfigDir = join(runDir, CHILD_CONFIG_DIRNAME);
|
|
518
570
|
await mkdir(childConfigDir, { recursive: true });
|
|
519
571
|
await writeJsonAtomic(join(childConfigDir, CHILD_CONFIG_SNAPSHOT_FILENAME), fingerprintData.snapshot);
|
|
520
572
|
}
|
|
573
|
+
const resolvedRoster = options.resolvedRoster !== undefined
|
|
574
|
+
? ResolvedRosterSchema.parse(options.resolvedRoster)
|
|
575
|
+
: undefined;
|
|
576
|
+
const rosterName = options.rosterName !== undefined
|
|
577
|
+
? RosterNameSchema.parse(options.rosterName)
|
|
578
|
+
: undefined;
|
|
521
579
|
const state = {
|
|
522
580
|
state_version: 1,
|
|
523
581
|
runId: options.runId,
|
|
@@ -549,6 +607,8 @@ export class WorkflowStateStore {
|
|
|
549
607
|
initialContextPolicy: options.initialContextPolicy,
|
|
550
608
|
debugKeepArtifacts,
|
|
551
609
|
async: options.async ?? false,
|
|
610
|
+
...(resolvedRoster !== undefined ? { resolvedRoster } : {}),
|
|
611
|
+
...(rosterName !== undefined ? { rosterName } : {}),
|
|
552
612
|
};
|
|
553
613
|
await writeJsonAtomic(join(runDir, STATE_FILENAME), state);
|
|
554
614
|
if (recycled.recycled) {
|
|
@@ -635,10 +695,12 @@ export class WorkflowStateStore {
|
|
|
635
695
|
// Also verify live config hasn't drifted from original run
|
|
636
696
|
const childConfigPath = getChildConfigPath();
|
|
637
697
|
if (childConfigPath != null) {
|
|
638
|
-
const currentFingerprint = await buildChildConfigFingerprint(definition);
|
|
698
|
+
const currentFingerprint = await buildChildConfigFingerprint(definition, state.initialContextPolicy, state.variables);
|
|
639
699
|
if (!fingerprintsMatch(state.fingerprint, currentFingerprint.fingerprint)) {
|
|
640
700
|
throw new Error(`Run ${options.runId} cannot be resumed: live child config at ${childConfigPath} has changed since the original run. ` +
|
|
641
|
-
`Restore the original config or start a new run
|
|
701
|
+
`Restore the original config or start a new run. ` +
|
|
702
|
+
`The fingerprint can also mismatch after a ClinkX upgrade that changes fingerprint composition ` +
|
|
703
|
+
`(for example context-delegate curator/finalizer refs), not only after live adapter JSON edits.`);
|
|
642
704
|
}
|
|
643
705
|
}
|
|
644
706
|
else {
|
|
@@ -1409,6 +1471,22 @@ function validateStrictStateSubtrees(state, statePath) {
|
|
|
1409
1471
|
.join("; ")}`);
|
|
1410
1472
|
}
|
|
1411
1473
|
}
|
|
1474
|
+
if (state.resolvedRoster !== undefined) {
|
|
1475
|
+
const parsed = ResolvedRosterSchema.safeParse(state.resolvedRoster);
|
|
1476
|
+
if (!parsed.success) {
|
|
1477
|
+
throw new Error(`Invalid resolvedRoster in ${statePath}: ${parsed.error.issues
|
|
1478
|
+
.map((issue) => `${issue.path.join(".") || "resolvedRoster"}: ${issue.message}`)
|
|
1479
|
+
.join("; ")}`);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
if (state.rosterName !== undefined) {
|
|
1483
|
+
const parsed = RosterNameSchema.safeParse(state.rosterName);
|
|
1484
|
+
if (!parsed.success) {
|
|
1485
|
+
throw new Error(`Invalid rosterName in ${statePath}: ${parsed.error.issues
|
|
1486
|
+
.map((issue) => `${issue.path.join(".") || "rosterName"}: ${issue.message}`)
|
|
1487
|
+
.join("; ")}`);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1412
1490
|
}
|
|
1413
1491
|
function lifecycleSnapshotsEqual(left, right) {
|
|
1414
1492
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
@@ -1958,7 +2036,27 @@ function buildPersistedFidelity(fidelity, contextProducing) {
|
|
|
1958
2036
|
resultContractEnabled: fidelity.parseSource === "result_contract",
|
|
1959
2037
|
});
|
|
1960
2038
|
}
|
|
1961
|
-
|
|
2039
|
+
function resolveEnabledDelegateFingerprintRefs(policy, variables) {
|
|
2040
|
+
const delegate = policy?.effectiveDelegate;
|
|
2041
|
+
if (delegate?.enabled !== true) {
|
|
2042
|
+
return undefined;
|
|
2043
|
+
}
|
|
2044
|
+
const curator = {
|
|
2045
|
+
cli_name: delegate.curator.cli_name,
|
|
2046
|
+
role: delegate.curator.role,
|
|
2047
|
+
};
|
|
2048
|
+
if (!effectiveFinalizerEnabled(delegate, variables)) {
|
|
2049
|
+
return { curator };
|
|
2050
|
+
}
|
|
2051
|
+
return {
|
|
2052
|
+
curator,
|
|
2053
|
+
finalizer: {
|
|
2054
|
+
cli_name: delegate.finalizer.cli_name,
|
|
2055
|
+
role: delegate.finalizer.role,
|
|
2056
|
+
},
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
async function buildChildConfigFingerprint(definition, policy, variables) {
|
|
1962
2060
|
const configPath = getChildConfigPath();
|
|
1963
2061
|
if (configPath == null) {
|
|
1964
2062
|
throw new Error("Persistent resume requires CLINKX_WORKFLOWS_CHILD_CONFIG_PATH");
|
|
@@ -1975,7 +2073,10 @@ async function buildChildConfigFingerprint(definition) {
|
|
|
1975
2073
|
CLINKX_ALLOWED_ROOTS: deriveAllowedRoots(workspaceRoot, getStateDir(), getArtifactsDir()),
|
|
1976
2074
|
CLINKX_LOG_LEVEL: getLogLevel(),
|
|
1977
2075
|
};
|
|
1978
|
-
|
|
2076
|
+
const delegateRefs = resolveEnabledDelegateFingerprintRefs(policy, variables);
|
|
2077
|
+
return delegateRefs === undefined
|
|
2078
|
+
? generateWorkflowFingerprint(definition, adapterConfigs, resolvedPrompts, childEnv)
|
|
2079
|
+
: generateWorkflowFingerprint(definition, adapterConfigs, resolvedPrompts, childEnv, delegateRefs);
|
|
1979
2080
|
}
|
|
1980
2081
|
async function loadNormalizedAdapterConfigs(configPath) {
|
|
1981
2082
|
const paths = await listConfigFiles(configPath);
|
|
@@ -2039,6 +2140,8 @@ async function resolveRolePrompt(configFilePath, role) {
|
|
|
2039
2140
|
function normalizeAdapterConfig(raw) {
|
|
2040
2141
|
const rolesRecord = asRecord(raw["roles"]);
|
|
2041
2142
|
const roles = Object.fromEntries(Object.entries(rolesRecord).map(([name, value]) => [name, normalizeRoleConfig(asRecord(value))]));
|
|
2143
|
+
const invocationOverrides = raw["invocation_overrides"];
|
|
2144
|
+
const promptFileFlag = asOptionalString(raw["prompt_file_flag"]);
|
|
2042
2145
|
return {
|
|
2043
2146
|
name: expectString(raw["name"], "adapter.name"),
|
|
2044
2147
|
command: expectString(raw["command"], "adapter.command"),
|
|
@@ -2061,6 +2164,10 @@ function normalizeAdapterConfig(raw) {
|
|
|
2061
2164
|
stdin_placeholder_arg: asOptionalString(raw["stdin_placeholder_arg"]),
|
|
2062
2165
|
native_output_file_flag: asOptionalString(raw["native_output_file_flag"]),
|
|
2063
2166
|
suppress_stdout: asOptionalBoolean(raw["suppress_stdout"]) ?? false,
|
|
2167
|
+
...(invocationOverrides !== undefined
|
|
2168
|
+
? { invocation_overrides: invocationOverrides }
|
|
2169
|
+
: {}),
|
|
2170
|
+
...(promptFileFlag !== undefined ? { prompt_file_flag: promptFileFlag } : {}),
|
|
2064
2171
|
};
|
|
2065
2172
|
}
|
|
2066
2173
|
function normalizeRoleConfig(raw) {
|