clinkx 0.3.0 → 1.0.0
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 +33 -0
- package/LICENSE +10 -0
- package/README.md +82 -26
- package/clinkx-workflows/dist/allowed-roots.d.ts +1 -0
- package/clinkx-workflows/dist/allowed-roots.js +5 -0
- package/clinkx-workflows/dist/allowed-roots.js.map +1 -0
- package/clinkx-workflows/dist/artifacts.d.ts +20 -1
- package/clinkx-workflows/dist/artifacts.js +38 -9
- package/clinkx-workflows/dist/artifacts.js.map +1 -1
- package/clinkx-workflows/dist/backend.d.ts +4 -0
- package/clinkx-workflows/dist/citation-check.d.ts +40 -0
- package/clinkx-workflows/dist/citation-check.js +348 -0
- package/clinkx-workflows/dist/citation-check.js.map +1 -0
- package/clinkx-workflows/dist/clink-client.d.ts +2 -1
- package/clinkx-workflows/dist/clink-client.js +17 -4
- package/clinkx-workflows/dist/clink-client.js.map +1 -1
- package/clinkx-workflows/dist/config.d.ts +145 -16
- package/clinkx-workflows/dist/config.js +384 -26
- package/clinkx-workflows/dist/config.js.map +1 -1
- package/clinkx-workflows/dist/contained-file.d.ts +172 -0
- package/clinkx-workflows/dist/contained-file.js +483 -0
- package/clinkx-workflows/dist/contained-file.js.map +1 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-contract.d.ts +416 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-contract.js +328 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-contract.js.map +1 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-router.d.ts +24 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-router.js +39 -0
- package/clinkx-workflows/dist/context-builder-lifecycle-router.js.map +1 -0
- package/clinkx-workflows/dist/context-cache-key.d.ts +53 -0
- package/clinkx-workflows/dist/context-cache-key.js +91 -0
- package/clinkx-workflows/dist/context-cache-key.js.map +1 -0
- package/clinkx-workflows/dist/context-mode-resolver.d.ts +27 -0
- package/clinkx-workflows/dist/context-mode-resolver.js +126 -0
- package/clinkx-workflows/dist/context-mode-resolver.js.map +1 -0
- package/clinkx-workflows/dist/context-preflight.d.ts +184 -0
- package/clinkx-workflows/dist/context-preflight.js +91 -0
- package/clinkx-workflows/dist/context-preflight.js.map +1 -0
- package/clinkx-workflows/dist/council-expander.d.ts +1 -1
- package/clinkx-workflows/dist/council-expander.js +2 -1
- package/clinkx-workflows/dist/council-expander.js.map +1 -1
- package/clinkx-workflows/dist/dashboard/activity-contract.d.ts +165 -0
- package/clinkx-workflows/dist/dashboard/activity-contract.js +105 -0
- package/clinkx-workflows/dist/dashboard/activity-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/activity-lease.d.ts +25 -0
- package/clinkx-workflows/dist/dashboard/activity-lease.js +34 -0
- package/clinkx-workflows/dist/dashboard/activity-lease.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/activity-reader.d.ts +86 -0
- package/clinkx-workflows/dist/dashboard/activity-reader.js +480 -0
- package/clinkx-workflows/dist/dashboard/activity-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/api-routes.d.ts +36 -0
- package/clinkx-workflows/dist/dashboard/api-routes.js +1047 -0
- package/clinkx-workflows/dist/dashboard/api-routes.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/artifact-index.d.ts +37 -0
- package/clinkx-workflows/dist/dashboard/artifact-index.js +145 -0
- package/clinkx-workflows/dist/dashboard/artifact-index.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/challenge-store.d.ts +31 -0
- package/clinkx-workflows/dist/dashboard/auth/challenge-store.js +65 -0
- package/clinkx-workflows/dist/dashboard/auth/challenge-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/controller.d.ts +26 -0
- package/clinkx-workflows/dist/dashboard/auth/controller.js +596 -0
- package/clinkx-workflows/dist/dashboard/auth/controller.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/credential-store.d.ts +60 -0
- package/clinkx-workflows/dist/dashboard/auth/credential-store.js +776 -0
- package/clinkx-workflows/dist/dashboard/auth/credential-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.d.ts +9 -0
- package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.js +44 -0
- package/clinkx-workflows/dist/dashboard/auth/enrollment-gate.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/session-store.d.ts +17 -0
- package/clinkx-workflows/dist/dashboard/auth/session-store.js +77 -0
- package/clinkx-workflows/dist/dashboard/auth/session-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/auth/webauthn-service.d.ts +25 -0
- package/clinkx-workflows/dist/dashboard/auth/webauthn-service.js +71 -0
- package/clinkx-workflows/dist/dashboard/auth/webauthn-service.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/context-run-liveness.d.ts +37 -0
- package/clinkx-workflows/dist/dashboard/context-run-liveness.js +49 -0
- package/clinkx-workflows/dist/dashboard/context-run-liveness.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.d.ts +222 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.js +1178 -0
- package/clinkx-workflows/dist/dashboard/context-run-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/contracts.d.ts +8936 -0
- package/clinkx-workflows/dist/dashboard/contracts.js +1157 -0
- package/clinkx-workflows/dist/dashboard/contracts.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/generation.d.ts +14 -0
- package/clinkx-workflows/dist/dashboard/generation.js +41 -0
- package/clinkx-workflows/dist/dashboard/generation.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/index.d.ts +28 -0
- package/clinkx-workflows/dist/dashboard/index.js +16 -0
- package/clinkx-workflows/dist/dashboard/index.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.d.ts +101 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.js +748 -0
- package/clinkx-workflows/dist/dashboard/lazy-content.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +303 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.js +221 -0
- package/clinkx-workflows/dist/dashboard/progress-report-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-reader.d.ts +50 -0
- package/clinkx-workflows/dist/dashboard/progress-report-reader.js +581 -0
- package/clinkx-workflows/dist/dashboard/progress-report-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.d.ts +89 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.js +71 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-overlay.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.d.ts +28 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js +110 -0
- package/clinkx-workflows/dist/dashboard/progress-report-status-store.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/read-model.d.ts +86 -0
- package/clinkx-workflows/dist/dashboard/read-model.js +440 -0
- package/clinkx-workflows/dist/dashboard/read-model.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/request-admission.d.ts +31 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js +126 -0
- package/clinkx-workflows/dist/dashboard/request-admission.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/scanner.d.ts +75 -0
- package/clinkx-workflows/dist/dashboard/scanner.js +1110 -0
- package/clinkx-workflows/dist/dashboard/scanner.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/server-factory.d.ts +50 -0
- package/clinkx-workflows/dist/dashboard/server-factory.js +431 -0
- package/clinkx-workflows/dist/dashboard/server-factory.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +2611 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.js +480 -0
- package/clinkx-workflows/dist/dashboard/session-log-contract.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-identity.d.ts +21 -0
- package/clinkx-workflows/dist/dashboard/session-log-identity.js +101 -0
- package/clinkx-workflows/dist/dashboard/session-log-identity.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-journal.d.ts +43 -0
- package/clinkx-workflows/dist/dashboard/session-log-journal.js +522 -0
- package/clinkx-workflows/dist/dashboard/session-log-journal.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-reader.d.ts +61 -0
- package/clinkx-workflows/dist/dashboard/session-log-reader.js +378 -0
- package/clinkx-workflows/dist/dashboard/session-log-reader.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-redaction.d.ts +6 -0
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js +367 -0
- package/clinkx-workflows/dist/dashboard/session-log-redaction.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/session-log-retention.d.ts +23 -0
- package/clinkx-workflows/dist/dashboard/session-log-retention.js +212 -0
- package/clinkx-workflows/dist/dashboard/session-log-retention.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/static-responses.d.ts +10 -0
- package/clinkx-workflows/dist/dashboard/static-responses.js +94 -0
- package/clinkx-workflows/dist/dashboard/static-responses.js.map +1 -0
- package/clinkx-workflows/dist/dashboard/worker-lock-observer.d.ts +28 -0
- package/clinkx-workflows/dist/dashboard/worker-lock-observer.js +241 -0
- package/clinkx-workflows/dist/dashboard/worker-lock-observer.js.map +1 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/index-DOkMXTfB.js +25 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/clinkx-workflows/dist/dashboard-ui/assets/style-ChJsn0KD.css +1 -0
- package/clinkx-workflows/dist/dashboard-ui/contracts/council-plan-review-input-v1.json +158 -0
- package/clinkx-workflows/dist/dashboard-ui/index.html +15 -0
- package/clinkx-workflows/dist/dashboard-ui/licenses/IBM-Plex-Mono-OFL.txt +93 -0
- package/clinkx-workflows/dist/dashboard-ui/licenses/IBM-Plex-Sans-OFL.txt +93 -0
- package/clinkx-workflows/dist/dashboard-ui/licenses/JetBrains-Mono-OFL.txt +93 -0
- package/clinkx-workflows/dist/dashboard-ui/licenses/NOTICE.md +32 -0
- package/clinkx-workflows/dist/dashboard-ui/theme-init.js +8 -0
- package/clinkx-workflows/dist/definition-normalizer.d.ts +19 -0
- package/clinkx-workflows/dist/definition-normalizer.js.map +1 -1
- package/clinkx-workflows/dist/delegate-validate.d.ts +78 -0
- package/clinkx-workflows/dist/delegate-validate.js +97 -0
- package/clinkx-workflows/dist/delegate-validate.js.map +1 -0
- package/clinkx-workflows/dist/engine.d.ts +141 -0
- package/clinkx-workflows/dist/engine.js +882 -28
- package/clinkx-workflows/dist/engine.js.map +1 -1
- package/clinkx-workflows/dist/errors.d.ts +2 -0
- package/clinkx-workflows/dist/errors.js.map +1 -1
- package/clinkx-workflows/dist/fingerprint.d.ts +1 -1
- package/clinkx-workflows/dist/fingerprint.js +1 -1
- package/clinkx-workflows/dist/index.d.ts +19 -0
- package/clinkx-workflows/dist/index.js +15 -0
- package/clinkx-workflows/dist/index.js.map +1 -1
- package/clinkx-workflows/dist/loader.d.ts +9 -3
- package/clinkx-workflows/dist/loader.js +92 -21
- package/clinkx-workflows/dist/loader.js.map +1 -1
- package/clinkx-workflows/dist/plan-review/admission.d.ts +160 -0
- package/clinkx-workflows/dist/plan-review/admission.js +290 -0
- package/clinkx-workflows/dist/plan-review/admission.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/context-policy.d.ts +55 -0
- package/clinkx-workflows/dist/plan-review/context-policy.js +146 -0
- package/clinkx-workflows/dist/plan-review/context-policy.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/contract.d.ts +763 -0
- package/clinkx-workflows/dist/plan-review/contract.js +289 -0
- package/clinkx-workflows/dist/plan-review/contract.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/digest.d.ts +68 -0
- package/clinkx-workflows/dist/plan-review/digest.js +241 -0
- package/clinkx-workflows/dist/plan-review/digest.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/discovery.d.ts +45 -0
- package/clinkx-workflows/dist/plan-review/discovery.js +36 -0
- package/clinkx-workflows/dist/plan-review/discovery.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/execution-contract.d.ts +298 -0
- package/clinkx-workflows/dist/plan-review/execution-contract.js +194 -0
- package/clinkx-workflows/dist/plan-review/execution-contract.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/expander.d.ts +48 -0
- package/clinkx-workflows/dist/plan-review/expander.js +243 -0
- package/clinkx-workflows/dist/plan-review/expander.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/projector.d.ts +126 -0
- package/clinkx-workflows/dist/plan-review/projector.js +437 -0
- package/clinkx-workflows/dist/plan-review/projector.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/publication.d.ts +95 -0
- package/clinkx-workflows/dist/plan-review/publication.js +182 -0
- package/clinkx-workflows/dist/plan-review/publication.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/ranking-reducer.d.ts +34 -0
- package/clinkx-workflows/dist/plan-review/ranking-reducer.js +139 -0
- package/clinkx-workflows/dist/plan-review/ranking-reducer.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/resume.d.ts +38 -0
- package/clinkx-workflows/dist/plan-review/resume.js +122 -0
- package/clinkx-workflows/dist/plan-review/resume.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/rubric.d.ts +7 -0
- package/clinkx-workflows/dist/plan-review/rubric.js +24 -0
- package/clinkx-workflows/dist/plan-review/rubric.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/run-state.d.ts +398 -0
- package/clinkx-workflows/dist/plan-review/run-state.js +183 -0
- package/clinkx-workflows/dist/plan-review/run-state.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/runtime-policy.d.ts +74 -0
- package/clinkx-workflows/dist/plan-review/runtime-policy.js +186 -0
- package/clinkx-workflows/dist/plan-review/runtime-policy.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/snapshot.d.ts +81 -0
- package/clinkx-workflows/dist/plan-review/snapshot.js +170 -0
- package/clinkx-workflows/dist/plan-review/snapshot.js.map +1 -0
- package/clinkx-workflows/dist/plan-review/stage-error.d.ts +19 -0
- package/clinkx-workflows/dist/plan-review/stage-error.js +20 -0
- package/clinkx-workflows/dist/plan-review/stage-error.js.map +1 -0
- package/clinkx-workflows/dist/post-processors/index.d.ts +20 -0
- package/clinkx-workflows/dist/post-processors/index.js +21 -0
- package/clinkx-workflows/dist/post-processors/index.js.map +1 -0
- package/clinkx-workflows/dist/prompt-budget.d.ts +7 -0
- package/clinkx-workflows/dist/prompt-budget.js +7 -1
- package/clinkx-workflows/dist/prompt-budget.js.map +1 -1
- package/clinkx-workflows/dist/reducers/index.js +2 -0
- package/clinkx-workflows/dist/reducers/index.js.map +1 -1
- package/clinkx-workflows/dist/run-lock-heartbeat.d.ts +2 -0
- package/clinkx-workflows/dist/run-lock-heartbeat.js +3 -0
- package/clinkx-workflows/dist/run-lock-heartbeat.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/council-plan-review.d.ts +34 -0
- package/clinkx-workflows/dist/run-summary/cards/council-plan-review.js +74 -0
- package/clinkx-workflows/dist/run-summary/cards/council-plan-review.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/index.js +5 -0
- package/clinkx-workflows/dist/run-summary/cards/index.js.map +1 -1
- package/clinkx-workflows/dist/run-summary.d.ts +13 -0
- package/clinkx-workflows/dist/run-summary.js +29 -1
- package/clinkx-workflows/dist/run-summary.js.map +1 -1
- package/clinkx-workflows/dist/schema.d.ts +76 -21
- package/clinkx-workflows/dist/schema.js +10 -1
- package/clinkx-workflows/dist/schema.js.map +1 -1
- package/clinkx-workflows/dist/seed-terms.d.ts +30 -0
- package/clinkx-workflows/dist/seed-terms.js +176 -0
- package/clinkx-workflows/dist/seed-terms.js.map +1 -0
- package/clinkx-workflows/dist/server.d.ts +5 -2
- package/clinkx-workflows/dist/server.js +82 -52
- package/clinkx-workflows/dist/server.js.map +1 -1
- package/clinkx-workflows/dist/shutdown.d.ts +18 -20
- package/clinkx-workflows/dist/shutdown.js +43 -61
- package/clinkx-workflows/dist/shutdown.js.map +1 -1
- package/clinkx-workflows/dist/state-schema.d.ts +38 -0
- package/clinkx-workflows/dist/state.d.ts +170 -3
- package/clinkx-workflows/dist/state.js +1275 -28
- package/clinkx-workflows/dist/state.js.map +1 -1
- package/clinkx-workflows/dist/transport.d.ts +15 -0
- package/clinkx-workflows/dist/transport.js +19 -10
- package/clinkx-workflows/dist/transport.js.map +1 -1
- package/clinkx-workflows/dist/types.d.ts +14 -2
- package/clinkx-workflows/dist/validators/council.d.ts +318 -85
- package/clinkx-workflows/dist/validators/council.js +52 -13
- package/clinkx-workflows/dist/validators/council.js.map +1 -1
- package/clinkx-workflows/dist/validators/index.d.ts +1 -0
- package/clinkx-workflows/dist/validators/index.js +3 -0
- package/clinkx-workflows/dist/validators/index.js.map +1 -1
- package/clinkx-workflows/dist/validators/plan-review.d.ts +398 -0
- package/clinkx-workflows/dist/validators/plan-review.js +316 -0
- package/clinkx-workflows/dist/validators/plan-review.js.map +1 -0
- package/clinkx-workflows/dist/workflow-receipt.js +188 -4
- package/clinkx-workflows/dist/workflow-receipt.js.map +1 -1
- package/clinkx-workflows/dist/workflow-tools.d.ts +48 -3
- package/clinkx-workflows/dist/workflow-tools.js +1402 -59
- package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
- package/clinkx-workflows/dist/workspace-signature.d.ts +16 -0
- package/clinkx-workflows/dist/workspace-signature.js +388 -0
- package/clinkx-workflows/dist/workspace-signature.js.map +1 -0
- package/clinkx-workflows/templates/council/answer-specialist.txt +2 -1
- package/clinkx-workflows/templates/council/code-review-chairman.txt +13 -0
- package/clinkx-workflows/templates/council/code-review-cross-reviewer.txt +4 -1
- package/clinkx-workflows/templates/council/code-review-reviewer.txt +19 -3
- package/clinkx-workflows/templates/council/debug-debugger.txt +2 -1
- package/clinkx-workflows/templates/council/discover-analyst.txt +2 -1
- package/clinkx-workflows/templates/council/member.txt +2 -1
- package/clinkx-workflows/templates/council/plan-review-chairman.txt +68 -0
- package/clinkx-workflows/templates/council/plan-review-cross-reviewer.txt +51 -0
- package/clinkx-workflows/templates/council/plan-review-reviewer.txt +60 -0
- package/clinkx-workflows/templates/plan-review/chairman.txt +48 -0
- package/clinkx-workflows/templates/plan-review/cross-review.txt +52 -0
- package/clinkx-workflows/templates/plan-review/ranking.txt +16 -0
- package/clinkx-workflows/templates/plan-review/reviewer.txt +57 -0
- package/clinkx-workflows/workflows/council-answer.yaml +97 -8
- package/clinkx-workflows/workflows/council-code-review.yaml +103 -8
- package/clinkx-workflows/workflows/council-debug.yaml +97 -8
- package/clinkx-workflows/workflows/council-default.yaml +97 -8
- package/clinkx-workflows/workflows/council-discover.yaml +97 -8
- package/clinkx-workflows/workflows/council-plan-review.yaml +250 -0
- package/clinkx-workflows/workflows/plan-review-receipts.yaml +230 -0
- package/conf/adapters/agy.json +49 -0
- package/conf/adapters/claude.json +5 -0
- package/conf/adapters/codex-app-server.json +44 -0
- package/conf/adapters/codex.json +7 -2
- package/conf/adapters/glm.json +5 -0
- package/conf/adapters/grok.json +60 -0
- package/conf/adapters/hapi/agy.json +52 -0
- package/conf/adapters/hapi/claude.json +5 -0
- package/conf/adapters/hapi/codex.json +7 -2
- package/conf/adapters/hapi/glm.json +5 -0
- package/dist/activity-journal.d.ts +42 -0
- package/dist/activity-journal.js +381 -0
- package/dist/activity-journal.js.map +1 -0
- package/dist/allowed-roots.d.ts +41 -0
- package/dist/allowed-roots.js +125 -3
- package/dist/allowed-roots.js.map +1 -1
- package/dist/codex/activity-session-log.d.ts +14 -0
- package/dist/codex/activity-session-log.js +206 -0
- package/dist/codex/activity-session-log.js.map +1 -0
- package/dist/codex/agent-tools.d.ts +23 -0
- package/dist/codex/agent-tools.js +1270 -0
- package/dist/codex/agent-tools.js.map +1 -0
- package/dist/codex/app-server-client.d.ts +76 -0
- package/dist/codex/app-server-client.js +582 -0
- package/dist/codex/app-server-client.js.map +1 -0
- package/dist/codex/app-server-registry.d.ts +389 -0
- package/dist/codex/app-server-registry.js +1407 -0
- package/dist/codex/app-server-registry.js.map +1 -0
- package/dist/codex/client-types.d.ts +109 -0
- package/dist/codex/client-types.js +2 -0
- package/dist/codex/client-types.js.map +1 -0
- package/dist/codex/protocol.d.ts +5375 -0
- package/dist/codex/protocol.js +614 -0
- package/dist/codex/protocol.js.map +1 -0
- package/dist/codex/session.d.ts +263 -0
- package/dist/codex/session.js +466 -0
- package/dist/codex/session.js.map +1 -0
- package/dist/config.d.ts +185 -19
- package/dist/config.js +82 -16
- package/dist/config.js.map +1 -1
- package/dist/context-builder/anchors.d.ts +1 -0
- package/dist/context-builder/anchors.js +3 -0
- package/dist/context-builder/anchors.js.map +1 -1
- package/dist/context-builder/bundle.d.ts +35 -2
- package/dist/context-builder/bundle.js +342 -2417
- package/dist/context-builder/bundle.js.map +1 -1
- package/dist/context-builder/codemap.d.ts +5 -0
- package/dist/context-builder/codemap.js +387 -13
- package/dist/context-builder/codemap.js.map +1 -1
- package/dist/context-builder/config.d.ts +1 -0
- package/dist/context-builder/config.js +12 -0
- package/dist/context-builder/config.js.map +1 -1
- package/dist/context-builder/context-run-catalog.d.ts +17 -0
- package/dist/context-builder/context-run-catalog.js +99 -0
- package/dist/context-builder/context-run-catalog.js.map +1 -0
- package/dist/context-builder/delegate-packet.d.ts +37 -0
- package/dist/context-builder/delegate-packet.js +359 -67
- package/dist/context-builder/delegate-packet.js.map +1 -1
- package/dist/context-builder/delegate-validation.d.ts +10 -1
- package/dist/context-builder/delegate-validation.js +153 -41
- package/dist/context-builder/delegate-validation.js.map +1 -1
- package/dist/context-builder/delegate.d.ts +2 -0
- package/dist/context-builder/delegate.js +1 -0
- package/dist/context-builder/delegate.js.map +1 -1
- package/dist/context-builder/diagnostics.d.ts +11 -2
- package/dist/context-builder/diagnostics.js +39 -6
- package/dist/context-builder/diagnostics.js.map +1 -1
- package/dist/context-builder/discovery.d.ts +29 -1
- package/dist/context-builder/discovery.js +475 -175
- package/dist/context-builder/discovery.js.map +1 -1
- package/dist/context-builder/globs.js +10 -10
- package/dist/context-builder/globs.js.map +1 -1
- package/dist/context-builder/handler.d.ts +26 -2
- package/dist/context-builder/handler.js +1158 -2416
- package/dist/context-builder/handler.js.map +1 -1
- package/dist/context-builder/lifecycle-contract.d.ts +424 -0
- package/dist/context-builder/lifecycle-contract.js +523 -0
- package/dist/context-builder/lifecycle-contract.js.map +1 -0
- package/dist/context-builder/lifecycle-journal.d.ts +62 -0
- package/dist/context-builder/lifecycle-journal.js +88 -0
- package/dist/context-builder/lifecycle-journal.js.map +1 -0
- package/dist/context-builder/lifecycle-observer.d.ts +102 -0
- package/dist/context-builder/lifecycle-observer.js +258 -0
- package/dist/context-builder/lifecycle-observer.js.map +1 -0
- package/dist/context-builder/lifecycle-reconcile.d.ts +32 -0
- package/dist/context-builder/lifecycle-reconcile.js +191 -0
- package/dist/context-builder/lifecycle-reconcile.js.map +1 -0
- package/dist/context-builder/lifecycle-recovery.d.ts +2 -0
- package/dist/context-builder/lifecycle-recovery.js +14 -0
- package/dist/context-builder/lifecycle-recovery.js.map +1 -0
- package/dist/context-builder/path-signals.js +9 -5
- package/dist/context-builder/path-signals.js.map +1 -1
- package/dist/context-builder/progress.d.ts +3 -1
- package/dist/context-builder/progress.js +23 -0
- package/dist/context-builder/progress.js.map +1 -1
- package/dist/context-builder/receipt.d.ts +6 -4
- package/dist/context-builder/receipt.js +12 -1
- package/dist/context-builder/receipt.js.map +1 -1
- package/dist/context-builder/refine-handler.d.ts +14 -0
- package/dist/context-builder/refine-handler.js +790 -0
- package/dist/context-builder/refine-handler.js.map +1 -0
- package/dist/context-builder/review-coverage.d.ts +84 -0
- package/dist/context-builder/review-coverage.js +437 -0
- package/dist/context-builder/review-coverage.js.map +1 -0
- package/dist/context-builder/schema.d.ts +239 -1
- package/dist/context-builder/schema.js +112 -6
- package/dist/context-builder/schema.js.map +1 -1
- package/dist/context-builder/secrets.d.ts +28 -0
- package/dist/context-builder/secrets.js +1473 -44
- package/dist/context-builder/secrets.js.map +1 -1
- package/dist/context-builder/selection.d.ts +7 -3
- package/dist/context-builder/selection.js +200 -738
- package/dist/context-builder/selection.js.map +1 -1
- package/dist/context-builder/session-log-identity.d.ts +1 -0
- package/dist/context-builder/session-log-identity.js +66 -0
- package/dist/context-builder/session-log-identity.js.map +1 -0
- package/dist/context-builder/slice-range-math.d.ts +16 -0
- package/dist/context-builder/slice-range-math.js +137 -0
- package/dist/context-builder/slice-range-math.js.map +1 -0
- package/dist/context-builder/status.d.ts +22 -1
- package/dist/context-builder/status.js +59 -4
- package/dist/context-builder/status.js.map +1 -1
- package/dist/context-builder/storage.d.ts +35 -2
- package/dist/context-builder/storage.js +271 -14
- package/dist/context-builder/storage.js.map +1 -1
- package/dist/context-builder/token-estimate.d.ts +13 -2
- package/dist/context-builder/token-estimate.js +77 -4
- package/dist/context-builder/token-estimate.js.map +1 -1
- package/dist/context-builder/versions.d.ts +29 -0
- package/dist/context-builder/versions.js +30 -0
- package/dist/context-builder/versions.js.map +1 -0
- package/dist/context-builder/workflow-runner.d.ts +69 -0
- package/dist/context-builder/workflow-runner.js +1051 -0
- package/dist/context-builder/workflow-runner.js.map +1 -0
- package/dist/context-builder/write-watchdog.d.ts +14 -0
- package/dist/context-builder/write-watchdog.js +38 -0
- package/dist/context-builder/write-watchdog.js.map +1 -0
- package/dist/dashboard-adapter-catalog.d.ts +9 -0
- package/dist/dashboard-adapter-catalog.js +46 -0
- package/dist/dashboard-adapter-catalog.js.map +1 -0
- package/dist/dashboard-cli.d.ts +79 -0
- package/dist/dashboard-cli.js +585 -0
- package/dist/dashboard-cli.js.map +1 -0
- package/dist/dashboard-companion/client.d.ts +36 -0
- package/dist/dashboard-companion/client.js +210 -0
- package/dist/dashboard-companion/client.js.map +1 -0
- package/dist/dashboard-companion/config.d.ts +8 -0
- package/dist/dashboard-companion/config.js +52 -0
- package/dist/dashboard-companion/config.js.map +1 -0
- package/dist/dashboard-companion/http-proxy.d.ts +10 -0
- package/dist/dashboard-companion/http-proxy.js +234 -0
- package/dist/dashboard-companion/http-proxy.js.map +1 -0
- package/dist/dashboard-companion/protocol.d.ts +80 -0
- package/dist/dashboard-companion/protocol.js +455 -0
- package/dist/dashboard-companion/protocol.js.map +1 -0
- package/dist/dashboard-companion/standalone-assets.d.ts +12 -0
- package/dist/dashboard-companion/standalone-assets.js +72 -0
- package/dist/dashboard-companion/standalone-assets.js.map +1 -0
- package/dist/dashboard-companion/standalone-entry.d.ts +1 -0
- package/dist/dashboard-companion/standalone-entry.js +17 -0
- package/dist/dashboard-companion/standalone-entry.js.map +1 -0
- package/dist/dashboard-gateway/config.d.ts +9 -0
- package/dist/dashboard-gateway/config.js +44 -0
- package/dist/dashboard-gateway/config.js.map +1 -0
- package/dist/dashboard-gateway/index.d.ts +11 -0
- package/dist/dashboard-gateway/index.js +755 -0
- package/dist/dashboard-gateway/index.js.map +1 -0
- package/dist/dashboard-gateway/main.d.ts +1 -0
- package/dist/dashboard-gateway/main.js +25 -0
- package/dist/dashboard-gateway/main.js.map +1 -0
- package/dist/dashboard-pairing-token.d.ts +1 -0
- package/dist/dashboard-pairing-token.js +5 -0
- package/dist/dashboard-pairing-token.js.map +1 -0
- package/dist/elaris/client.d.ts +73 -0
- package/dist/elaris/client.js +825 -0
- package/dist/elaris/client.js.map +1 -0
- package/dist/elaris/config.d.ts +18 -0
- package/dist/elaris/config.js +75 -0
- package/dist/elaris/config.js.map +1 -0
- package/dist/elaris/errors.d.ts +41 -0
- package/dist/elaris/errors.js +205 -0
- package/dist/elaris/errors.js.map +1 -0
- package/dist/elaris/github-repo.d.ts +18 -0
- package/dist/elaris/github-repo.js +89 -0
- package/dist/elaris/github-repo.js.map +1 -0
- package/dist/elaris/index.d.ts +10 -0
- package/dist/elaris/index.js +11 -0
- package/dist/elaris/index.js.map +1 -0
- package/dist/elaris/redact.d.ts +89 -0
- package/dist/elaris/redact.js +423 -0
- package/dist/elaris/redact.js.map +1 -0
- package/dist/elaris/run-id.d.ts +5 -0
- package/dist/elaris/run-id.js +20 -0
- package/dist/elaris/run-id.js.map +1 -0
- package/dist/elaris/status.d.ts +45 -0
- package/dist/elaris/status.js +122 -0
- package/dist/elaris/status.js.map +1 -0
- package/dist/elaris/tool-schemas.d.ts +314 -0
- package/dist/elaris/tool-schemas.js +208 -0
- package/dist/elaris/tool-schemas.js.map +1 -0
- package/dist/elaris/tools.d.ts +73 -0
- package/dist/elaris/tools.js +1065 -0
- package/dist/elaris/tools.js.map +1 -0
- package/dist/elaris/types.d.ts +1541 -0
- package/dist/elaris/types.js +252 -0
- package/dist/elaris/types.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.js +19 -0
- package/dist/errors.js.map +1 -1
- package/dist/handler.d.ts +4 -0
- package/dist/handler.js +10 -1
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/local-clink-backend.d.ts +3 -0
- package/dist/local-clink-backend.js +4 -0
- package/dist/local-clink-backend.js.map +1 -1
- package/dist/package-info.d.ts +2 -0
- package/dist/package-info.js +18 -0
- package/dist/package-info.js.map +1 -0
- package/dist/parsers/codex-jsonl.js +48 -3
- package/dist/parsers/codex-jsonl.js.map +1 -1
- package/dist/parsers/extract.d.ts +10 -1
- package/dist/parsers/extract.js +11 -3
- package/dist/parsers/extract.js.map +1 -1
- package/dist/pipeline.d.ts +4 -0
- package/dist/pipeline.js +129 -8
- package/dist/pipeline.js.map +1 -1
- package/dist/run-dir.d.ts +24 -0
- package/dist/run-dir.js +201 -2
- package/dist/run-dir.js.map +1 -1
- package/dist/runner.d.ts +13 -0
- package/dist/runner.js +184 -15
- package/dist/runner.js.map +1 -1
- package/dist/safety.d.ts +4 -4
- package/dist/safety.js +4 -4
- package/dist/schema.d.ts +7 -7
- package/dist/server.d.ts +1 -0
- package/dist/server.js +359 -17
- package/dist/server.js.map +1 -1
- package/dist/session-log-stream.d.ts +18 -0
- package/dist/session-log-stream.js +319 -0
- package/dist/session-log-stream.js.map +1 -0
- package/package.json +46 -5
- package/conf/adapters/gemini.json +0 -44
- package/conf/adapters/hapi/gemini.json +0 -47
- package/dist/parsers/gemini-json.d.ts +0 -2
- package/dist/parsers/gemini-json.js +0 -72
- package/dist/parsers/gemini-json.js.map +0 -1
|
@@ -0,0 +1,1110 @@
|
|
|
1
|
+
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
2
|
+
import { lstat, opendir } from "node:fs/promises";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { containedFileFingerprintsEqual, } from "../contained-file.js";
|
|
5
|
+
import { validateRunId } from "../run-id.js";
|
|
6
|
+
import { isPlanReviewRunState } from "../plan-review/admission.js";
|
|
7
|
+
import { MAX_DASHBOARD_LIVE_RUNS, MAX_DASHBOARD_PAGE_SIZE, MAX_DASHBOARD_ROOTS, MAX_DASHBOARD_STAGE_MARKERS, } from "./contracts.js";
|
|
8
|
+
import { createDashboardRunReader, DEFAULT_DASHBOARD_MAX_STATE_BYTES, } from "./read-model.js";
|
|
9
|
+
import { assertValidDashboardArtifactCursor, buildDashboardArtifactReferenceIndex, DEFAULT_DASHBOARD_ARTIFACT_INDEX_BYTE_BUDGET, DEFAULT_DASHBOARD_ARTIFACT_REFERENCE_LIMIT, DashboardInvalidCursorError, } from "./artifact-index.js";
|
|
10
|
+
import { createDashboardLazyContentReader, } from "./lazy-content.js";
|
|
11
|
+
import { createDashboardWorkerLockObserver, } from "./worker-lock-observer.js";
|
|
12
|
+
import { projectContextRunLifecycleState } from "./context-run-reader.js";
|
|
13
|
+
export const DEFAULT_DASHBOARD_CANDIDATE_LIMIT = 10_000;
|
|
14
|
+
export const DEFAULT_DASHBOARD_SCAN_BYTE_BUDGET = 256 * 1_024 * 1_024;
|
|
15
|
+
export const DEFAULT_DASHBOARD_PROJECTION_CACHE_BYTE_BUDGET = 32 * 1_024 * 1_024;
|
|
16
|
+
export const DEFAULT_DASHBOARD_DETAIL_CACHE_ENTRIES = 8;
|
|
17
|
+
export const DEFAULT_DASHBOARD_DETAIL_CACHE_BYTE_BUDGET = 32 * 1_024 * 1_024;
|
|
18
|
+
export const DEFAULT_DASHBOARD_DECODE_QUEUE_LIMIT = 32;
|
|
19
|
+
export const DEFAULT_DASHBOARD_SCANNER_MAX_STATE_BYTES = DEFAULT_DASHBOARD_MAX_STATE_BYTES;
|
|
20
|
+
const WORKER_LOCK_OBSERVATION_CONCURRENCY = 8;
|
|
21
|
+
export class DashboardReadModelError extends Error {
|
|
22
|
+
code;
|
|
23
|
+
status;
|
|
24
|
+
constructor(code) {
|
|
25
|
+
super(code);
|
|
26
|
+
this.name = "DashboardReadModelError";
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.status = 503;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class SerialSingleFlightScheduler {
|
|
32
|
+
#queueLimit;
|
|
33
|
+
#pending = new Map();
|
|
34
|
+
#queue = [];
|
|
35
|
+
#active = false;
|
|
36
|
+
constructor(queueLimit) {
|
|
37
|
+
this.#queueLimit = queueLimit;
|
|
38
|
+
}
|
|
39
|
+
run(key, task) {
|
|
40
|
+
const existing = this.#pending.get(key);
|
|
41
|
+
if (existing !== undefined)
|
|
42
|
+
return existing;
|
|
43
|
+
if (this.#active && this.#queue.length >= this.#queueLimit) {
|
|
44
|
+
return Promise.reject(new DashboardReadModelError("dashboard_busy"));
|
|
45
|
+
}
|
|
46
|
+
let resolveTask;
|
|
47
|
+
let rejectTask;
|
|
48
|
+
const promise = new Promise((resolvePromise, rejectPromise) => {
|
|
49
|
+
resolveTask = resolvePromise;
|
|
50
|
+
rejectTask = rejectPromise;
|
|
51
|
+
});
|
|
52
|
+
this.#pending.set(key, promise);
|
|
53
|
+
const scheduled = { key, task, resolve: resolveTask, reject: rejectTask };
|
|
54
|
+
if (this.#active) {
|
|
55
|
+
this.#queue.push(scheduled);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.#start(scheduled);
|
|
59
|
+
}
|
|
60
|
+
return promise;
|
|
61
|
+
}
|
|
62
|
+
#start(scheduled) {
|
|
63
|
+
this.#active = true;
|
|
64
|
+
void scheduled.task().then(scheduled.resolve, scheduled.reject).finally(() => {
|
|
65
|
+
this.#pending.delete(scheduled.key);
|
|
66
|
+
const next = this.#queue.shift();
|
|
67
|
+
if (next === undefined) {
|
|
68
|
+
this.#active = false;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.#start(next);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function* defaultListCandidates(runsRoot) {
|
|
77
|
+
const directory = await opendir(runsRoot);
|
|
78
|
+
for await (const entry of directory)
|
|
79
|
+
yield entry;
|
|
80
|
+
}
|
|
81
|
+
const defaultScannerFileSystem = {
|
|
82
|
+
listCandidates: defaultListCandidates,
|
|
83
|
+
lstat: async (path) => await lstat(path, { bigint: true }),
|
|
84
|
+
};
|
|
85
|
+
function hasErrorCode(error, code) {
|
|
86
|
+
return error?.code === code;
|
|
87
|
+
}
|
|
88
|
+
async function mapWithFixedConcurrency(items, concurrency, mapper) {
|
|
89
|
+
const results = new Array(items.length);
|
|
90
|
+
let nextIndex = 0;
|
|
91
|
+
async function worker() {
|
|
92
|
+
while (nextIndex < items.length) {
|
|
93
|
+
const index = nextIndex;
|
|
94
|
+
nextIndex += 1;
|
|
95
|
+
results[index] = await mapper(items[index], index);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, async () => await worker()));
|
|
99
|
+
return results;
|
|
100
|
+
}
|
|
101
|
+
function directoryIdentity(stats) {
|
|
102
|
+
return { dev: stats.dev, ino: stats.ino, birthtimeNs: stats.birthtimeNs };
|
|
103
|
+
}
|
|
104
|
+
function fileFingerprint(stats) {
|
|
105
|
+
return {
|
|
106
|
+
dev: stats.dev,
|
|
107
|
+
ino: stats.ino,
|
|
108
|
+
mtimeNs: stats.mtimeNs,
|
|
109
|
+
ctimeNs: stats.ctimeNs,
|
|
110
|
+
size: stats.size,
|
|
111
|
+
nlink: stats.nlink,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function directoryIdentitiesEqual(left, right) {
|
|
115
|
+
return left.dev === right.dev && left.ino === right.ino && left.birthtimeNs === right.birthtimeNs;
|
|
116
|
+
}
|
|
117
|
+
function identityKey(identity) {
|
|
118
|
+
const directory = identity.directoryIdentity;
|
|
119
|
+
const root = identity.rootIdentity;
|
|
120
|
+
const file = identity.fingerprint;
|
|
121
|
+
return [
|
|
122
|
+
root.dev,
|
|
123
|
+
root.ino,
|
|
124
|
+
root.birthtimeNs,
|
|
125
|
+
directory.dev,
|
|
126
|
+
directory.ino,
|
|
127
|
+
directory.birthtimeNs,
|
|
128
|
+
file.dev,
|
|
129
|
+
file.ino,
|
|
130
|
+
file.mtimeNs,
|
|
131
|
+
file.ctimeNs,
|
|
132
|
+
file.size,
|
|
133
|
+
file.nlink,
|
|
134
|
+
].join(":");
|
|
135
|
+
}
|
|
136
|
+
function timeOrFallback(value, fingerprint) {
|
|
137
|
+
if (value !== undefined) {
|
|
138
|
+
const parsed = Date.parse(value);
|
|
139
|
+
if (Number.isFinite(parsed))
|
|
140
|
+
return BigInt(parsed) * 1000000n;
|
|
141
|
+
}
|
|
142
|
+
return fingerprint.mtimeNs;
|
|
143
|
+
}
|
|
144
|
+
function compareStrings(left, right) {
|
|
145
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
146
|
+
}
|
|
147
|
+
function compareAscending(left, right) {
|
|
148
|
+
return left.timeNs < right.timeNs
|
|
149
|
+
? -1
|
|
150
|
+
: left.timeNs > right.timeNs
|
|
151
|
+
? 1
|
|
152
|
+
: compareStrings(left.runId, right.runId);
|
|
153
|
+
}
|
|
154
|
+
function compareDescending(left, right) {
|
|
155
|
+
return left.timeNs > right.timeNs
|
|
156
|
+
? -1
|
|
157
|
+
: left.timeNs < right.timeNs
|
|
158
|
+
? 1
|
|
159
|
+
: compareStrings(right.runId, left.runId);
|
|
160
|
+
}
|
|
161
|
+
function encodeCursor(secret, key) {
|
|
162
|
+
const iv = randomBytes(12);
|
|
163
|
+
const cipher = createCipheriv("aes-256-gcm", secret, iv);
|
|
164
|
+
const ciphertext = Buffer.concat([
|
|
165
|
+
cipher.update(JSON.stringify([key.timeNs.toString(), key.runId]), "utf8"),
|
|
166
|
+
cipher.final(),
|
|
167
|
+
]);
|
|
168
|
+
return Buffer.concat([iv, cipher.getAuthTag(), ciphertext]).toString("base64url");
|
|
169
|
+
}
|
|
170
|
+
function decodeCursor(secret, cursor) {
|
|
171
|
+
if (cursor.length === 0 || cursor.length > 1_024 || !/^[A-Za-z0-9_-]+$/.test(cursor)) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const packed = Buffer.from(cursor, "base64url");
|
|
176
|
+
if (packed.byteLength < 29)
|
|
177
|
+
return undefined;
|
|
178
|
+
const decipher = createDecipheriv("aes-256-gcm", secret, packed.subarray(0, 12));
|
|
179
|
+
decipher.setAuthTag(packed.subarray(12, 28));
|
|
180
|
+
const plaintext = Buffer.concat([
|
|
181
|
+
decipher.update(packed.subarray(28)),
|
|
182
|
+
decipher.final(),
|
|
183
|
+
]).toString("utf8");
|
|
184
|
+
const decoded = JSON.parse(plaintext);
|
|
185
|
+
if (!Array.isArray(decoded) ||
|
|
186
|
+
decoded.length !== 2 ||
|
|
187
|
+
typeof decoded[0] !== "string" ||
|
|
188
|
+
!/^-?[0-9]+$/.test(decoded[0]) ||
|
|
189
|
+
typeof decoded[1] !== "string" ||
|
|
190
|
+
decoded[1].length === 0)
|
|
191
|
+
return undefined;
|
|
192
|
+
return { timeNs: BigInt(decoded[0]), runId: decoded[1] };
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function requireHistoryCursor(secret, cursor) {
|
|
199
|
+
const decoded = decodeCursor(secret, cursor);
|
|
200
|
+
if (decoded === undefined) {
|
|
201
|
+
throw new DashboardInvalidCursorError("invalid dashboard history cursor");
|
|
202
|
+
}
|
|
203
|
+
return decoded;
|
|
204
|
+
}
|
|
205
|
+
function countStates(values) {
|
|
206
|
+
const counts = { pending: 0, running: 0, succeeded: 0, failed: 0, cancelled: 0 };
|
|
207
|
+
for (const value of values)
|
|
208
|
+
counts[value.state] += 1;
|
|
209
|
+
return counts;
|
|
210
|
+
}
|
|
211
|
+
function listProjection(admitted, stateRevision) {
|
|
212
|
+
const { state } = admitted;
|
|
213
|
+
const calls = state.stages.flatMap((stage) => stage.calls);
|
|
214
|
+
const projectFolders = projectFoldersFromVariables(state.variables?.cb_roots);
|
|
215
|
+
const stageMarkers = state.stages.slice(0, MAX_DASHBOARD_STAGE_MARKERS).map((stage) => ({
|
|
216
|
+
stageId: stage.stageId,
|
|
217
|
+
state: stage.state,
|
|
218
|
+
}));
|
|
219
|
+
return {
|
|
220
|
+
availability: "available",
|
|
221
|
+
runId: admitted.runId,
|
|
222
|
+
runGeneration: admitted.runGeneration,
|
|
223
|
+
stateRevision,
|
|
224
|
+
workflowName: state.workflowName,
|
|
225
|
+
workflowVersion: state.workflowVersion,
|
|
226
|
+
status: state.status,
|
|
227
|
+
orphaned: false,
|
|
228
|
+
resumable: state.resumable,
|
|
229
|
+
...(state.startedAt === undefined ? {} : { startedAt: state.startedAt }),
|
|
230
|
+
...(state.completedAt === undefined ? {} : { completedAt: state.completedAt }),
|
|
231
|
+
stateUpdatedAt: new Date(Number(admitted.stateFingerprint.mtimeNs / 1000000n)).toISOString(),
|
|
232
|
+
...(state.failureClass === undefined ? {} : { failureClass: state.failureClass }),
|
|
233
|
+
async: state.async ?? false,
|
|
234
|
+
debugKeepArtifacts: state.debugKeepArtifacts ?? false,
|
|
235
|
+
retryCount: calls.reduce((sum, call) => sum + call.retryCount, 0),
|
|
236
|
+
reportedRunningCalls: calls.filter((call) => call.state === "running").length,
|
|
237
|
+
stageCounts: countStates(state.stages),
|
|
238
|
+
callCounts: countStates(calls),
|
|
239
|
+
stageMarkers,
|
|
240
|
+
additionalStageCount: state.stages.length - stageMarkers.length,
|
|
241
|
+
projectFolders,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Project the run's project folder(s) from persisted `variables.cb_roots`. The
|
|
246
|
+
* decoder guarantees a string array, but `variables` is `Record<string,unknown>`
|
|
247
|
+
* in the frozen state schema, so guard defensively and cap at the dashboard
|
|
248
|
+
* bound. Returns `[]` when no roots were recorded.
|
|
249
|
+
*/
|
|
250
|
+
function projectFoldersFromVariables(cbRoots) {
|
|
251
|
+
if (cbRoots === undefined)
|
|
252
|
+
return [];
|
|
253
|
+
const folders = [];
|
|
254
|
+
for (const entry of cbRoots) {
|
|
255
|
+
if (typeof entry === "string" && entry.length > 0) {
|
|
256
|
+
folders.push(entry);
|
|
257
|
+
if (folders.length >= MAX_DASHBOARD_ROOTS)
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return folders;
|
|
262
|
+
}
|
|
263
|
+
function detailProjection(admitted, listItem) {
|
|
264
|
+
const { state } = admitted;
|
|
265
|
+
const calls = state.stages.flatMap((stage) => stage.calls);
|
|
266
|
+
const failedCall = calls.find((call) => call.state === "failed");
|
|
267
|
+
const result = state.status === "pending"
|
|
268
|
+
? { availability: "unavailable", reason: "run_pending" }
|
|
269
|
+
: state.status === "running"
|
|
270
|
+
? { availability: "unavailable", reason: "run_running" }
|
|
271
|
+
: state.status === "failed"
|
|
272
|
+
? { availability: "unavailable", reason: "run_failed" }
|
|
273
|
+
: state.status === "cancelled"
|
|
274
|
+
? { availability: "unavailable", reason: "run_cancelled" }
|
|
275
|
+
: { availability: "unavailable", reason: "not_persisted" };
|
|
276
|
+
const preflightConfiguration = {
|
|
277
|
+
profile: state.variables?.cb_profile ?? null,
|
|
278
|
+
effectiveMode: state.initialContextPolicy?.effectiveMode ??
|
|
279
|
+
state.workflow_context?.context_builder.context_mode ??
|
|
280
|
+
null,
|
|
281
|
+
failurePolicy: state.initialContextPolicy?.effectiveDelegate === undefined
|
|
282
|
+
? null
|
|
283
|
+
: state.initialContextPolicy.effectiveDelegate.failure_policy ?? "fallback",
|
|
284
|
+
};
|
|
285
|
+
return {
|
|
286
|
+
...listItem,
|
|
287
|
+
contextPreflight: state.context_builder_lifecycle !== undefined
|
|
288
|
+
? {
|
|
289
|
+
availability: "current",
|
|
290
|
+
...projectContextRunLifecycleState(state.context_builder_lifecycle),
|
|
291
|
+
// The ctxop_… operation id pairs with the preflight session-log
|
|
292
|
+
// generation sidecar (<runDir>/.context-preflight); surfaced only for
|
|
293
|
+
// the workflow-embedded preflight (standalone rows carry it as `id`).
|
|
294
|
+
contextRunId: state.context_builder_lifecycle.context_run_id,
|
|
295
|
+
...preflightConfiguration,
|
|
296
|
+
}
|
|
297
|
+
: state.workflow_context !== undefined
|
|
298
|
+
? {
|
|
299
|
+
availability: "legacy_without_telemetry",
|
|
300
|
+
status: state.workflow_context.context_builder.status,
|
|
301
|
+
...preflightConfiguration,
|
|
302
|
+
}
|
|
303
|
+
: state.initialContextPolicy !== undefined
|
|
304
|
+
? {
|
|
305
|
+
availability: state.initialContextPolicy.effectiveMode === "off" ||
|
|
306
|
+
state.initialContextPolicy.effectiveMode === "disabled"
|
|
307
|
+
? "bypassed"
|
|
308
|
+
: state.status === "pending" || state.status === "running"
|
|
309
|
+
? "awaiting_telemetry"
|
|
310
|
+
: "telemetry_unavailable",
|
|
311
|
+
...preflightConfiguration,
|
|
312
|
+
effectiveMode: state.initialContextPolicy.effectiveMode,
|
|
313
|
+
}
|
|
314
|
+
: { availability: "absent" },
|
|
315
|
+
snapshotEnrichment: state.workflowSnapshotPath === undefined
|
|
316
|
+
? { availability: "unavailable", reason: "missing" }
|
|
317
|
+
: { availability: "unavailable", reason: "not_loaded" },
|
|
318
|
+
result,
|
|
319
|
+
...(failedCall === undefined || (failedCall.failureClass ?? state.failureClass) === undefined
|
|
320
|
+
? {}
|
|
321
|
+
: {
|
|
322
|
+
decisiveFailure: {
|
|
323
|
+
stageId: failedCall.stageId,
|
|
324
|
+
callId: failedCall.callId,
|
|
325
|
+
failureClass: failedCall.failureClass ?? state.failureClass,
|
|
326
|
+
},
|
|
327
|
+
}),
|
|
328
|
+
card: {
|
|
329
|
+
kind: "generic",
|
|
330
|
+
stageCounts: countStates(state.stages),
|
|
331
|
+
callCounts: countStates(calls),
|
|
332
|
+
},
|
|
333
|
+
stages: state.stages.map((stage) => ({
|
|
334
|
+
stageId: stage.stageId,
|
|
335
|
+
state: stage.state,
|
|
336
|
+
...(stage.startedAt === undefined ? {} : { startedAt: stage.startedAt }),
|
|
337
|
+
...(stage.completedAt === undefined ? {} : { completedAt: stage.completedAt }),
|
|
338
|
+
calls: stage.calls.map((call) => ({
|
|
339
|
+
stageId: call.stageId,
|
|
340
|
+
callId: call.callId,
|
|
341
|
+
state: call.state,
|
|
342
|
+
retryCount: call.retryCount,
|
|
343
|
+
...(call.attemptsConsumed === undefined ? {} : { attemptsConsumed: call.attemptsConsumed }),
|
|
344
|
+
...(call.startedAt === undefined ? {} : { startedAt: call.startedAt }),
|
|
345
|
+
...(call.completedAt === undefined ? {} : { completedAt: call.completedAt }),
|
|
346
|
+
...(call.durationMs === undefined ? {} : { durationMs: call.durationMs }),
|
|
347
|
+
...(call.failureClass === undefined ? {} : { failureClass: call.failureClass }),
|
|
348
|
+
hasWorkflowInput: call.materializedInputPath !== undefined,
|
|
349
|
+
hasOutput: call.outputInline !== undefined || call.outputPath !== undefined,
|
|
350
|
+
hasRawError: call.errorMessage !== undefined,
|
|
351
|
+
hasArtifactReference: call.artifactPath !== undefined,
|
|
352
|
+
})),
|
|
353
|
+
})),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function emptyRootCache() {
|
|
357
|
+
return {
|
|
358
|
+
entries: new Map(),
|
|
359
|
+
revisions: new Map(),
|
|
360
|
+
details: new Map(),
|
|
361
|
+
detailBytes: 0,
|
|
362
|
+
movedToHistory: new Set(),
|
|
363
|
+
artifactIndexFailed: false,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function candidateListingIdentity(stats) {
|
|
367
|
+
if (!stats.isDirectory() || stats.nlink === 0n)
|
|
368
|
+
return undefined;
|
|
369
|
+
return {
|
|
370
|
+
dev: stats.dev,
|
|
371
|
+
ino: stats.ino,
|
|
372
|
+
birthtimeNs: stats.birthtimeNs,
|
|
373
|
+
mtimeNs: stats.mtimeNs,
|
|
374
|
+
ctimeNs: stats.ctimeNs,
|
|
375
|
+
nlink: stats.nlink,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function candidateListingIdentitiesEqual(left, right) {
|
|
379
|
+
return left.dev === right.dev &&
|
|
380
|
+
left.ino === right.ino &&
|
|
381
|
+
left.birthtimeNs === right.birthtimeNs &&
|
|
382
|
+
left.mtimeNs === right.mtimeNs &&
|
|
383
|
+
left.ctimeNs === right.ctimeNs &&
|
|
384
|
+
left.nlink === right.nlink;
|
|
385
|
+
}
|
|
386
|
+
export function createDashboardRunScanner(options = {}) {
|
|
387
|
+
const fileSystem = options.fileSystem ?? defaultScannerFileSystem;
|
|
388
|
+
const runReader = options.runReader ?? createDashboardRunReader({
|
|
389
|
+
maxStateBytes: options.maxStateBytes ?? DEFAULT_DASHBOARD_SCANNER_MAX_STATE_BYTES,
|
|
390
|
+
includeUnavailableAdmissionMetadata: true,
|
|
391
|
+
});
|
|
392
|
+
const now = options.now ?? (() => new Date());
|
|
393
|
+
const generateStateRevision = options.generateStateRevision ??
|
|
394
|
+
(() => randomBytes(16).toString("base64url"));
|
|
395
|
+
const candidateLimit = options.candidateLimit ?? DEFAULT_DASHBOARD_CANDIDATE_LIMIT;
|
|
396
|
+
const scanByteBudget = options.scanByteBudget ?? DEFAULT_DASHBOARD_SCAN_BYTE_BUDGET;
|
|
397
|
+
const projectionCacheByteBudget = options.projectionCacheByteBudget ??
|
|
398
|
+
DEFAULT_DASHBOARD_PROJECTION_CACHE_BYTE_BUDGET;
|
|
399
|
+
const detailCacheEntries = options.detailCacheEntries ?? DEFAULT_DASHBOARD_DETAIL_CACHE_ENTRIES;
|
|
400
|
+
const detailCacheByteBudget = options.detailCacheByteBudget ??
|
|
401
|
+
DEFAULT_DASHBOARD_DETAIL_CACHE_BYTE_BUDGET;
|
|
402
|
+
const decodeQueueLimit = options.decodeQueueLimit ?? DEFAULT_DASHBOARD_DECODE_QUEUE_LIMIT;
|
|
403
|
+
const scheduler = new SerialSingleFlightScheduler(decodeQueueLimit);
|
|
404
|
+
const rootMutationSchedulers = new Map();
|
|
405
|
+
const liveRunLimit = options.liveRunLimit ?? MAX_DASHBOARD_LIVE_RUNS;
|
|
406
|
+
if (options.workerLockObserver !== undefined &&
|
|
407
|
+
options.observeWorkerLockObservation !== undefined) {
|
|
408
|
+
throw new TypeError("configure only one dashboard worker-lock observer seam");
|
|
409
|
+
}
|
|
410
|
+
const boundWorkerLockObserver = options.workerLockObserver ??
|
|
411
|
+
createDashboardWorkerLockObserver();
|
|
412
|
+
const legacyWorkerLockObserver = options.observeWorkerLockObservation;
|
|
413
|
+
const observeWorkerLock = legacyWorkerLockObserver === undefined
|
|
414
|
+
? async (request) => await boundWorkerLockObserver.observe(request)
|
|
415
|
+
: async (request) => await legacyWorkerLockObserver(request.runsRoot, request.runId, request.runGeneration, request);
|
|
416
|
+
const roots = new Map();
|
|
417
|
+
const lazyContentReader = options.lazyContentReader ?? createDashboardLazyContentReader({
|
|
418
|
+
runReader,
|
|
419
|
+
stateRevisionFor: (runsRoot, admitted) => {
|
|
420
|
+
const rootKey = resolve(runsRoot);
|
|
421
|
+
const cache = roots.get(rootKey) ?? emptyRootCache();
|
|
422
|
+
const revision = revisionFor(cache, admitted);
|
|
423
|
+
roots.set(rootKey, cache);
|
|
424
|
+
return revision;
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
const artifactReferenceLimit = options.artifactReferenceLimit ??
|
|
428
|
+
DEFAULT_DASHBOARD_ARTIFACT_REFERENCE_LIMIT;
|
|
429
|
+
const artifactIndexByteBudget = options.artifactIndexByteBudget ??
|
|
430
|
+
DEFAULT_DASHBOARD_ARTIFACT_INDEX_BYTE_BUDGET;
|
|
431
|
+
const cursorSecret = randomBytes(32);
|
|
432
|
+
const artifactCursorSecret = randomBytes(32);
|
|
433
|
+
function serializeRootMutation(rootKey, operationKey, task) {
|
|
434
|
+
let rootScheduler = rootMutationSchedulers.get(rootKey);
|
|
435
|
+
if (rootScheduler === undefined) {
|
|
436
|
+
rootScheduler = new SerialSingleFlightScheduler(decodeQueueLimit);
|
|
437
|
+
rootMutationSchedulers.set(rootKey, rootScheduler);
|
|
438
|
+
}
|
|
439
|
+
return rootScheduler.run(operationKey, task);
|
|
440
|
+
}
|
|
441
|
+
async function readCandidateListingIdentity(runsRoot) {
|
|
442
|
+
try {
|
|
443
|
+
return candidateListingIdentity(await fileSystem.lstat(runsRoot));
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
if (hasErrorCode(error, "ENOENT"))
|
|
447
|
+
return undefined;
|
|
448
|
+
throw error;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
async function listStableCandidates(runsRoot) {
|
|
452
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
453
|
+
const before = await readCandidateListingIdentity(runsRoot);
|
|
454
|
+
const names = [];
|
|
455
|
+
for await (const candidate of fileSystem.listCandidates(runsRoot)) {
|
|
456
|
+
if (names.length >= candidateLimit) {
|
|
457
|
+
throw new DashboardReadModelError("run_directory_limit_exceeded");
|
|
458
|
+
}
|
|
459
|
+
names.push(candidate.name);
|
|
460
|
+
}
|
|
461
|
+
const after = await readCandidateListingIdentity(runsRoot);
|
|
462
|
+
if (before !== undefined &&
|
|
463
|
+
after !== undefined &&
|
|
464
|
+
candidateListingIdentitiesEqual(before, after)) {
|
|
465
|
+
return names;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
throw new DashboardReadModelError("dashboard_busy");
|
|
469
|
+
}
|
|
470
|
+
function revisionFor(cache, admitted) {
|
|
471
|
+
const current = cache.revisions.get(admitted.runId);
|
|
472
|
+
if (current !== undefined &&
|
|
473
|
+
current.fingerprint !== undefined &&
|
|
474
|
+
directoryIdentitiesEqual(current.directoryIdentity, admitted.directoryIdentity) &&
|
|
475
|
+
containedFileFingerprintsEqual(current.fingerprint, admitted.stateFingerprint))
|
|
476
|
+
return current.revision;
|
|
477
|
+
const revision = generateStateRevision();
|
|
478
|
+
cache.revisions.set(admitted.runId, {
|
|
479
|
+
fingerprint: admitted.stateFingerprint,
|
|
480
|
+
directoryIdentity: admitted.directoryIdentity,
|
|
481
|
+
revision,
|
|
482
|
+
});
|
|
483
|
+
return revision;
|
|
484
|
+
}
|
|
485
|
+
function unavailableRevisionFor(cache, runId, reason, directory, fingerprint) {
|
|
486
|
+
const current = cache.revisions.get(runId);
|
|
487
|
+
const fingerprintsEqual = current?.fingerprint === undefined && fingerprint === undefined ||
|
|
488
|
+
(current?.fingerprint !== undefined && fingerprint !== undefined &&
|
|
489
|
+
containedFileFingerprintsEqual(current.fingerprint, fingerprint));
|
|
490
|
+
if (current !== undefined &&
|
|
491
|
+
directoryIdentitiesEqual(current.directoryIdentity, directory) &&
|
|
492
|
+
current.unavailableReason === reason &&
|
|
493
|
+
fingerprintsEqual)
|
|
494
|
+
return current.revision;
|
|
495
|
+
const revision = generateStateRevision();
|
|
496
|
+
cache.revisions.set(runId, {
|
|
497
|
+
...(fingerprint === undefined ? {} : { fingerprint }),
|
|
498
|
+
directoryIdentity: directory,
|
|
499
|
+
unavailableReason: reason,
|
|
500
|
+
revision,
|
|
501
|
+
});
|
|
502
|
+
return revision;
|
|
503
|
+
}
|
|
504
|
+
function insertDetail(cache, admitted, detail, enrichmentDependencies) {
|
|
505
|
+
const previous = cache.details.get(admitted.runId);
|
|
506
|
+
if (previous !== undefined) {
|
|
507
|
+
cache.details.delete(admitted.runId);
|
|
508
|
+
cache.detailBytes -= previous.sourceBytes;
|
|
509
|
+
}
|
|
510
|
+
if (admitted.sourceBytes > detailCacheByteBudget)
|
|
511
|
+
return;
|
|
512
|
+
cache.details.set(admitted.runId, {
|
|
513
|
+
fingerprint: admitted.stateFingerprint,
|
|
514
|
+
directoryIdentity: admitted.directoryIdentity,
|
|
515
|
+
rootIdentity: admitted.rootIdentity,
|
|
516
|
+
sourceBytes: admitted.sourceBytes,
|
|
517
|
+
state: admitted.state,
|
|
518
|
+
detail,
|
|
519
|
+
...(enrichmentDependencies === undefined
|
|
520
|
+
? {}
|
|
521
|
+
: { enrichmentDependencies: [...enrichmentDependencies] }),
|
|
522
|
+
});
|
|
523
|
+
cache.detailBytes += admitted.sourceBytes;
|
|
524
|
+
while (cache.details.size > detailCacheEntries || cache.detailBytes > detailCacheByteBudget) {
|
|
525
|
+
const oldestKey = cache.details.keys().next().value;
|
|
526
|
+
if (oldestKey === undefined)
|
|
527
|
+
break;
|
|
528
|
+
const oldest = cache.details.get(oldestKey);
|
|
529
|
+
cache.details.delete(oldestKey);
|
|
530
|
+
cache.detailBytes -= oldest.sourceBytes;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
async function candidateIdentity(runsRoot, runId) {
|
|
534
|
+
try {
|
|
535
|
+
const [rootStats, runStats, stateStats] = await Promise.all([
|
|
536
|
+
fileSystem.lstat(runsRoot),
|
|
537
|
+
fileSystem.lstat(resolve(runsRoot, runId)),
|
|
538
|
+
fileSystem.lstat(resolve(runsRoot, runId, "state.json")),
|
|
539
|
+
]);
|
|
540
|
+
if (!runStats.isDirectory() ||
|
|
541
|
+
!rootStats.isDirectory() ||
|
|
542
|
+
!stateStats.isFile() ||
|
|
543
|
+
runStats.nlink === 0n ||
|
|
544
|
+
stateStats.nlink === 0n)
|
|
545
|
+
return undefined;
|
|
546
|
+
return {
|
|
547
|
+
rootIdentity: directoryIdentity(rootStats),
|
|
548
|
+
directoryIdentity: directoryIdentity(runStats),
|
|
549
|
+
fingerprint: fileFingerprint(stateStats),
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
catch (error) {
|
|
553
|
+
if (hasErrorCode(error, "ENOENT"))
|
|
554
|
+
return undefined;
|
|
555
|
+
return undefined;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
async function admit(runsRoot, runId, identity) {
|
|
559
|
+
const key = `${resolve(runsRoot)}\0${runId}\0${identity === undefined ? "unknown" : identityKey(identity)}`;
|
|
560
|
+
return await scheduler.run(key, async () => await runReader.read(runsRoot, runId));
|
|
561
|
+
}
|
|
562
|
+
async function withWorkerLockObservation(runsRoot, item, binding) {
|
|
563
|
+
if (item.availability === "unavailable")
|
|
564
|
+
return item;
|
|
565
|
+
if (item.status !== "pending" && item.status !== "running") {
|
|
566
|
+
return item.orphaned ? { ...item, orphaned: false } : item;
|
|
567
|
+
}
|
|
568
|
+
let workerLockObservation;
|
|
569
|
+
try {
|
|
570
|
+
workerLockObservation = await observeWorkerLock({
|
|
571
|
+
runsRoot,
|
|
572
|
+
runId: item.runId,
|
|
573
|
+
runGeneration: item.runGeneration,
|
|
574
|
+
...binding,
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
catch {
|
|
578
|
+
workerLockObservation = "unknown";
|
|
579
|
+
}
|
|
580
|
+
if (legacyWorkerLockObserver !== undefined && workerLockObservation !== "unknown") {
|
|
581
|
+
const current = await candidateIdentity(runsRoot, item.runId);
|
|
582
|
+
if (current === undefined ||
|
|
583
|
+
!directoryIdentitiesEqual(current.rootIdentity, binding.rootIdentity) ||
|
|
584
|
+
!directoryIdentitiesEqual(current.directoryIdentity, binding.directoryIdentity) ||
|
|
585
|
+
!containedFileFingerprintsEqual(current.fingerprint, binding.stateFingerprint)) {
|
|
586
|
+
workerLockObservation = "unknown";
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
const orphaned = workerLockObservation === "orphaned";
|
|
590
|
+
return orphaned === item.orphaned &&
|
|
591
|
+
item.workerLockObservation === workerLockObservation
|
|
592
|
+
? item
|
|
593
|
+
: { ...item, orphaned, workerLockObservation };
|
|
594
|
+
}
|
|
595
|
+
function entryFor(cache, admitted) {
|
|
596
|
+
const revision = revisionFor(cache, admitted);
|
|
597
|
+
const listItem = listProjection(admitted, revision);
|
|
598
|
+
const detail = detailProjection(admitted, listItem);
|
|
599
|
+
insertDetail(cache, admitted, detail);
|
|
600
|
+
const artifactSources = admitted.state.stages.flatMap((stage, stageOrdinal) => stage.calls.flatMap((call, callOrdinal) => {
|
|
601
|
+
const expectedPath = `artifacts/${stage.stageId}/${String(callOrdinal + 1).padStart(2, "0")}-${call.callId}.json`;
|
|
602
|
+
return call.artifactPath === expectedPath
|
|
603
|
+
? [{
|
|
604
|
+
runId: admitted.runId,
|
|
605
|
+
runGeneration: admitted.runGeneration,
|
|
606
|
+
stateRevision: revision,
|
|
607
|
+
runBirthtimeNs: admitted.directoryIdentity.birthtimeNs,
|
|
608
|
+
stageOrdinal,
|
|
609
|
+
callOrdinal,
|
|
610
|
+
stageId: stage.stageId,
|
|
611
|
+
callId: call.callId,
|
|
612
|
+
}]
|
|
613
|
+
: [];
|
|
614
|
+
}));
|
|
615
|
+
return {
|
|
616
|
+
runId: admitted.runId,
|
|
617
|
+
listItem,
|
|
618
|
+
sourceBytes: admitted.sourceBytes,
|
|
619
|
+
projectionBytes: Buffer.byteLength(JSON.stringify(listItem), "utf8"),
|
|
620
|
+
stateFingerprint: admitted.stateFingerprint,
|
|
621
|
+
directoryIdentity: admitted.directoryIdentity,
|
|
622
|
+
rootIdentity: admitted.rootIdentity,
|
|
623
|
+
liveSortKey: {
|
|
624
|
+
timeNs: timeOrFallback(admitted.state.startedAt, admitted.stateFingerprint),
|
|
625
|
+
runId: admitted.runId,
|
|
626
|
+
},
|
|
627
|
+
historySortKey: {
|
|
628
|
+
timeNs: timeOrFallback(admitted.state.completedAt, admitted.stateFingerprint),
|
|
629
|
+
runId: admitted.runId,
|
|
630
|
+
},
|
|
631
|
+
artifactSources,
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function unavailableEntryFor(cache, result) {
|
|
635
|
+
const admission = result.admission;
|
|
636
|
+
if (admission === undefined)
|
|
637
|
+
return undefined;
|
|
638
|
+
const stateRevision = unavailableRevisionFor(cache, result.runId, result.reason, admission.directoryIdentity, admission.stateFingerprint);
|
|
639
|
+
const chronologyNs = admission.stateFingerprint?.mtimeNs;
|
|
640
|
+
const listItem = {
|
|
641
|
+
availability: "unavailable",
|
|
642
|
+
runId: result.runId,
|
|
643
|
+
runGeneration: admission.runGeneration,
|
|
644
|
+
stateRevision,
|
|
645
|
+
reason: result.reason,
|
|
646
|
+
...(chronologyNs === undefined
|
|
647
|
+
? {}
|
|
648
|
+
: { chronologyAt: new Date(Number(chronologyNs / 1000000n)).toISOString() }),
|
|
649
|
+
};
|
|
650
|
+
return {
|
|
651
|
+
runId: result.runId,
|
|
652
|
+
listItem,
|
|
653
|
+
sourceBytes: admission.sourceBytes,
|
|
654
|
+
projectionBytes: Buffer.byteLength(JSON.stringify(listItem), "utf8"),
|
|
655
|
+
...(admission.stateFingerprint === undefined
|
|
656
|
+
? {}
|
|
657
|
+
: { stateFingerprint: admission.stateFingerprint }),
|
|
658
|
+
directoryIdentity: admission.directoryIdentity,
|
|
659
|
+
rootIdentity: admission.rootIdentity,
|
|
660
|
+
liveSortKey: { timeNs: 0n, runId: result.runId },
|
|
661
|
+
historySortKey: {
|
|
662
|
+
timeNs: chronologyNs ?? 0n,
|
|
663
|
+
runId: result.runId,
|
|
664
|
+
},
|
|
665
|
+
artifactSources: [],
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
async function readEnrichedHealthyDetail(runsRoot, runId, runGeneration, cache) {
|
|
669
|
+
const enrichment = await lazyContentReader.readStructuredProjection({
|
|
670
|
+
runsRoot,
|
|
671
|
+
runId,
|
|
672
|
+
runGeneration,
|
|
673
|
+
});
|
|
674
|
+
if (enrichment.kind === "run_generation_changed")
|
|
675
|
+
return enrichment;
|
|
676
|
+
if (enrichment.kind === "run_state_changed")
|
|
677
|
+
return enrichment;
|
|
678
|
+
if (enrichment.kind === "unavailable")
|
|
679
|
+
return { kind: "missing" };
|
|
680
|
+
const admitted = enrichment.admission;
|
|
681
|
+
const revision = revisionFor(cache, admitted);
|
|
682
|
+
let detail = detailProjection(admitted, listProjection(admitted, revision));
|
|
683
|
+
if (detail.availability !== "available")
|
|
684
|
+
return { kind: "missing" };
|
|
685
|
+
if (enrichment.snapshot.availability === "available") {
|
|
686
|
+
const identities = new Map(enrichment.snapshot.projection.stages.flatMap((stage) => stage.calls.map((call) => [
|
|
687
|
+
`${stage.stageId}\0${call.callId}`,
|
|
688
|
+
{ adapter: call.adapter, role: call.role },
|
|
689
|
+
])));
|
|
690
|
+
detail = {
|
|
691
|
+
...detail,
|
|
692
|
+
snapshotEnrichment: {
|
|
693
|
+
availability: "available",
|
|
694
|
+
stages: enrichment.snapshot.projection.stages.map((stage) => ({
|
|
695
|
+
stageId: stage.stageId,
|
|
696
|
+
...(stage.label === undefined ? {} : { label: stage.label }),
|
|
697
|
+
dependsOn: [...stage.dependsOn],
|
|
698
|
+
})),
|
|
699
|
+
},
|
|
700
|
+
stages: detail.stages.map((stage) => ({
|
|
701
|
+
...stage,
|
|
702
|
+
calls: stage.calls.map((call) => ({
|
|
703
|
+
...call,
|
|
704
|
+
snapshotIdentity: identities.get(`${stage.stageId}\0${call.callId}`),
|
|
705
|
+
})),
|
|
706
|
+
})),
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
710
|
+
detail = {
|
|
711
|
+
...detail,
|
|
712
|
+
snapshotEnrichment: enrichment.snapshot,
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
if (enrichment.genericResult !== undefined) {
|
|
716
|
+
detail = { ...detail, result: enrichment.genericResult };
|
|
717
|
+
}
|
|
718
|
+
if (enrichment.planReviewCard?.kind === "council-plan-review") {
|
|
719
|
+
detail = {
|
|
720
|
+
...detail,
|
|
721
|
+
result: { availability: "available", kind: "plan_review" },
|
|
722
|
+
card: enrichment.planReviewCard,
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
else if (isPlanReviewRunState(admitted.state)) {
|
|
726
|
+
detail = {
|
|
727
|
+
...detail,
|
|
728
|
+
result: { availability: "unavailable", reason: "invalid" },
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
insertDetail(cache, admitted, detail, enrichment.enrichmentDependencies);
|
|
732
|
+
return {
|
|
733
|
+
kind: "available",
|
|
734
|
+
detail: await withWorkerLockObservation(runsRoot, detail, admitted),
|
|
735
|
+
...(cache.movedToHistory.has(runId) ? { notice: "moved_to_history" } : {}),
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
const scanner = {
|
|
739
|
+
async resolveCurrent(runsRoot, runId) {
|
|
740
|
+
try {
|
|
741
|
+
validateRunId(runId);
|
|
742
|
+
}
|
|
743
|
+
catch {
|
|
744
|
+
return { kind: "missing" };
|
|
745
|
+
}
|
|
746
|
+
const rootKey = resolve(runsRoot);
|
|
747
|
+
return await serializeRootMutation(rootKey, JSON.stringify(["resolve-current", runId]), async () => {
|
|
748
|
+
const identity = await candidateIdentity(runsRoot, runId);
|
|
749
|
+
const result = await admit(runsRoot, runId, identity);
|
|
750
|
+
if (result.kind === "missing")
|
|
751
|
+
return { kind: "missing" };
|
|
752
|
+
if (result.kind === "unavailable") {
|
|
753
|
+
return result.admission === undefined
|
|
754
|
+
? { kind: "unavailable" }
|
|
755
|
+
: {
|
|
756
|
+
kind: "resolved",
|
|
757
|
+
runId,
|
|
758
|
+
runGeneration: result.admission.runGeneration,
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
return {
|
|
762
|
+
kind: "resolved",
|
|
763
|
+
runId,
|
|
764
|
+
runGeneration: result.runGeneration,
|
|
765
|
+
};
|
|
766
|
+
});
|
|
767
|
+
},
|
|
768
|
+
async scan(runsRoot, query = {}) {
|
|
769
|
+
const limit = query.limit ?? 100;
|
|
770
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_DASHBOARD_PAGE_SIZE) {
|
|
771
|
+
throw new TypeError("dashboard history limit must be an integer from 1 through 500");
|
|
772
|
+
}
|
|
773
|
+
const cursor = query.before === undefined
|
|
774
|
+
? undefined
|
|
775
|
+
: requireHistoryCursor(cursorSecret, query.before);
|
|
776
|
+
const rootKey = resolve(runsRoot);
|
|
777
|
+
return await serializeRootMutation(rootKey, JSON.stringify(["scan", limit, query.before ?? null]), async () => {
|
|
778
|
+
const committed = roots.get(rootKey) ?? emptyRootCache();
|
|
779
|
+
const staged = {
|
|
780
|
+
entries: new Map(),
|
|
781
|
+
revisions: new Map(committed.revisions),
|
|
782
|
+
details: new Map(committed.details),
|
|
783
|
+
detailBytes: committed.detailBytes,
|
|
784
|
+
movedToHistory: new Set(committed.movedToHistory),
|
|
785
|
+
artifactIndex: committed.artifactIndex,
|
|
786
|
+
artifactIndexFailed: committed.artifactIndexFailed,
|
|
787
|
+
};
|
|
788
|
+
let candidates;
|
|
789
|
+
try {
|
|
790
|
+
candidates = await listStableCandidates(runsRoot);
|
|
791
|
+
}
|
|
792
|
+
catch (error) {
|
|
793
|
+
if (hasErrorCode(error, "ENOENT")) {
|
|
794
|
+
for (const runId of committed.entries.keys()) {
|
|
795
|
+
runReader.forget(runsRoot, runId);
|
|
796
|
+
boundWorkerLockObserver.forget(runsRoot, runId);
|
|
797
|
+
}
|
|
798
|
+
roots.delete(rootKey);
|
|
799
|
+
return { live: [], history: [], serverNow: now().toISOString() };
|
|
800
|
+
}
|
|
801
|
+
throw error;
|
|
802
|
+
}
|
|
803
|
+
let admittedBytes = 0;
|
|
804
|
+
let projectionBytes = 0;
|
|
805
|
+
for (const runId of candidates) {
|
|
806
|
+
try {
|
|
807
|
+
validateRunId(runId);
|
|
808
|
+
}
|
|
809
|
+
catch {
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
const identity = await candidateIdentity(runsRoot, runId);
|
|
813
|
+
const cached = committed.entries.get(runId);
|
|
814
|
+
let entry;
|
|
815
|
+
if (identity !== undefined &&
|
|
816
|
+
cached !== undefined &&
|
|
817
|
+
cached.stateFingerprint !== undefined &&
|
|
818
|
+
directoryIdentitiesEqual(identity.rootIdentity, cached.rootIdentity) &&
|
|
819
|
+
directoryIdentitiesEqual(identity.directoryIdentity, cached.directoryIdentity) &&
|
|
820
|
+
containedFileFingerprintsEqual(identity.fingerprint, cached.stateFingerprint)) {
|
|
821
|
+
entry = cached;
|
|
822
|
+
}
|
|
823
|
+
else {
|
|
824
|
+
const result = await admit(runsRoot, runId, identity);
|
|
825
|
+
if (result.kind === "admitted")
|
|
826
|
+
entry = entryFor(staged, result);
|
|
827
|
+
else if (result.kind === "unavailable")
|
|
828
|
+
entry = unavailableEntryFor(staged, result);
|
|
829
|
+
}
|
|
830
|
+
if (entry === undefined)
|
|
831
|
+
continue;
|
|
832
|
+
staged.entries.set(runId, entry);
|
|
833
|
+
admittedBytes += entry.sourceBytes;
|
|
834
|
+
projectionBytes += entry.projectionBytes;
|
|
835
|
+
if (admittedBytes > scanByteBudget) {
|
|
836
|
+
throw new DashboardReadModelError("scan_byte_budget_exceeded");
|
|
837
|
+
}
|
|
838
|
+
if (projectionBytes > projectionCacheByteBudget) {
|
|
839
|
+
throw new DashboardReadModelError("projection_cache_budget_exceeded");
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
const present = new Set(staged.entries.keys());
|
|
843
|
+
for (const runId of staged.revisions.keys()) {
|
|
844
|
+
if (!present.has(runId))
|
|
845
|
+
staged.revisions.delete(runId);
|
|
846
|
+
}
|
|
847
|
+
for (const [runId, detail] of staged.details) {
|
|
848
|
+
if (present.has(runId))
|
|
849
|
+
continue;
|
|
850
|
+
staged.details.delete(runId);
|
|
851
|
+
staged.detailBytes -= detail.sourceBytes;
|
|
852
|
+
}
|
|
853
|
+
for (const runId of staged.movedToHistory) {
|
|
854
|
+
if (!present.has(runId))
|
|
855
|
+
staged.movedToHistory.delete(runId);
|
|
856
|
+
}
|
|
857
|
+
for (const [runId, entry] of staged.entries) {
|
|
858
|
+
const previous = committed.entries.get(runId);
|
|
859
|
+
const isLive = entry.listItem.availability === "available" &&
|
|
860
|
+
(entry.listItem.status === "pending" || entry.listItem.status === "running");
|
|
861
|
+
const wasLive = previous?.listItem.availability === "available" &&
|
|
862
|
+
(previous.listItem.status === "pending" || previous.listItem.status === "running");
|
|
863
|
+
if (isLive || (previous !== undefined &&
|
|
864
|
+
previous.listItem.runGeneration !== entry.listItem.runGeneration)) {
|
|
865
|
+
staged.movedToHistory.delete(runId);
|
|
866
|
+
}
|
|
867
|
+
else if (wasLive) {
|
|
868
|
+
staged.movedToHistory.add(runId);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
const liveEntries = [...staged.entries.values()]
|
|
872
|
+
.filter((entry) => entry.listItem.availability === "available" &&
|
|
873
|
+
(entry.listItem.status === "pending" || entry.listItem.status === "running") &&
|
|
874
|
+
entry.stateFingerprint !== undefined)
|
|
875
|
+
.sort((left, right) => compareAscending(left.liveSortKey, right.liveSortKey));
|
|
876
|
+
if (liveEntries.length > liveRunLimit) {
|
|
877
|
+
throw new DashboardReadModelError("live_run_limit_exceeded");
|
|
878
|
+
}
|
|
879
|
+
const historyEntries = [...staged.entries.values()]
|
|
880
|
+
.filter((entry) => entry.listItem.availability === "unavailable" ||
|
|
881
|
+
(entry.listItem.status !== "pending" && entry.listItem.status !== "running"))
|
|
882
|
+
.sort((left, right) => compareDescending(left.historySortKey, right.historySortKey));
|
|
883
|
+
const afterCursor = cursor === undefined
|
|
884
|
+
? historyEntries
|
|
885
|
+
: historyEntries.filter((entry) => compareDescending(entry.historySortKey, cursor) > 0);
|
|
886
|
+
const page = afterCursor.slice(0, limit);
|
|
887
|
+
const observedLive = await mapWithFixedConcurrency(liveEntries, WORKER_LOCK_OBSERVATION_CONCURRENCY, async (entry) => await withWorkerLockObservation(runsRoot, entry.listItem, entry));
|
|
888
|
+
const response = {
|
|
889
|
+
live: observedLive,
|
|
890
|
+
history: page.map((entry) => entry.listItem),
|
|
891
|
+
...(afterCursor.length > page.length && page.length > 0
|
|
892
|
+
? { nextBefore: encodeCursor(cursorSecret, page.at(-1).historySortKey) }
|
|
893
|
+
: {}),
|
|
894
|
+
serverNow: now().toISOString(),
|
|
895
|
+
};
|
|
896
|
+
for (const runId of committed.entries.keys()) {
|
|
897
|
+
if (!present.has(runId)) {
|
|
898
|
+
runReader.forget(runsRoot, runId);
|
|
899
|
+
boundWorkerLockObserver.forget(runsRoot, runId);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
const artifactIndex = buildDashboardArtifactReferenceIndex([...staged.entries.values()].flatMap((entry) => entry.artifactSources), {
|
|
903
|
+
referenceLimit: artifactReferenceLimit,
|
|
904
|
+
byteBudget: artifactIndexByteBudget,
|
|
905
|
+
now,
|
|
906
|
+
cursorSecret: artifactCursorSecret,
|
|
907
|
+
});
|
|
908
|
+
if (artifactIndex.kind === "available") {
|
|
909
|
+
staged.artifactIndex = artifactIndex.index;
|
|
910
|
+
staged.artifactIndexFailed = false;
|
|
911
|
+
}
|
|
912
|
+
else {
|
|
913
|
+
staged.artifactIndex = undefined;
|
|
914
|
+
staged.artifactIndexFailed = true;
|
|
915
|
+
}
|
|
916
|
+
roots.set(rootKey, staged);
|
|
917
|
+
return response;
|
|
918
|
+
});
|
|
919
|
+
},
|
|
920
|
+
async readDetail(runsRoot, runId, runGeneration) {
|
|
921
|
+
try {
|
|
922
|
+
validateRunId(runId);
|
|
923
|
+
}
|
|
924
|
+
catch {
|
|
925
|
+
return { kind: "missing" };
|
|
926
|
+
}
|
|
927
|
+
const rootKey = resolve(runsRoot);
|
|
928
|
+
return await serializeRootMutation(rootKey, JSON.stringify(["detail", runId, runGeneration]), async () => {
|
|
929
|
+
const cache = roots.get(rootKey) ?? emptyRootCache();
|
|
930
|
+
const identity = await candidateIdentity(runsRoot, runId);
|
|
931
|
+
const projection = cache.entries.get(runId);
|
|
932
|
+
if (identity !== undefined &&
|
|
933
|
+
projection !== undefined &&
|
|
934
|
+
projection.stateFingerprint !== undefined &&
|
|
935
|
+
directoryIdentitiesEqual(identity.rootIdentity, projection.rootIdentity) &&
|
|
936
|
+
directoryIdentitiesEqual(identity.directoryIdentity, projection.directoryIdentity) &&
|
|
937
|
+
containedFileFingerprintsEqual(identity.fingerprint, projection.stateFingerprint)) {
|
|
938
|
+
if (projection.listItem.runGeneration !== runGeneration) {
|
|
939
|
+
return { kind: "run_generation_changed" };
|
|
940
|
+
}
|
|
941
|
+
if (projection.listItem.availability === "unavailable") {
|
|
942
|
+
return {
|
|
943
|
+
kind: "available",
|
|
944
|
+
detail: projection.listItem,
|
|
945
|
+
...(cache.movedToHistory.has(runId) ? { notice: "moved_to_history" } : {}),
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
const cachedDetail = cache.details.get(runId);
|
|
949
|
+
if (cachedDetail !== undefined &&
|
|
950
|
+
directoryIdentitiesEqual(cachedDetail.directoryIdentity, identity.directoryIdentity) &&
|
|
951
|
+
containedFileFingerprintsEqual(cachedDetail.fingerprint, identity.fingerprint)) {
|
|
952
|
+
cache.details.delete(runId);
|
|
953
|
+
cache.details.set(runId, cachedDetail);
|
|
954
|
+
if (cachedDetail.enrichmentDependencies !== undefined &&
|
|
955
|
+
lazyContentReader.validateEnrichmentDependencies !== undefined) {
|
|
956
|
+
const admitted = {
|
|
957
|
+
kind: "admitted",
|
|
958
|
+
runId,
|
|
959
|
+
runGeneration,
|
|
960
|
+
state: cachedDetail.state,
|
|
961
|
+
sourceBytes: cachedDetail.sourceBytes,
|
|
962
|
+
stateFingerprint: cachedDetail.fingerprint,
|
|
963
|
+
directoryIdentity: cachedDetail.directoryIdentity,
|
|
964
|
+
rootIdentity: cachedDetail.rootIdentity,
|
|
965
|
+
};
|
|
966
|
+
if (await lazyContentReader.validateEnrichmentDependencies({ runsRoot, runId, runGeneration }, admitted, cachedDetail.enrichmentDependencies)) {
|
|
967
|
+
return {
|
|
968
|
+
kind: "available",
|
|
969
|
+
detail: await withWorkerLockObservation(runsRoot, cachedDetail.detail, {
|
|
970
|
+
rootIdentity: cachedDetail.rootIdentity,
|
|
971
|
+
directoryIdentity: cachedDetail.directoryIdentity,
|
|
972
|
+
stateFingerprint: cachedDetail.fingerprint,
|
|
973
|
+
}),
|
|
974
|
+
...(cache.movedToHistory.has(runId)
|
|
975
|
+
? { notice: "moved_to_history" }
|
|
976
|
+
: {}),
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
if (cachedDetail.state.workflowSnapshotPath === undefined &&
|
|
981
|
+
!isPlanReviewRunState(cachedDetail.state) &&
|
|
982
|
+
cachedDetail.state.status !== "succeeded") {
|
|
983
|
+
return {
|
|
984
|
+
kind: "available",
|
|
985
|
+
detail: await withWorkerLockObservation(runsRoot, cachedDetail.detail, {
|
|
986
|
+
rootIdentity: cachedDetail.rootIdentity,
|
|
987
|
+
directoryIdentity: cachedDetail.directoryIdentity,
|
|
988
|
+
stateFingerprint: cachedDetail.fingerprint,
|
|
989
|
+
}),
|
|
990
|
+
...(cache.movedToHistory.has(runId) ? { notice: "moved_to_history" } : {}),
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
const enriched = await readEnrichedHealthyDetail(runsRoot, runId, runGeneration, cache);
|
|
994
|
+
roots.set(rootKey, cache);
|
|
995
|
+
return enriched;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
const result = await admit(runsRoot, runId, identity);
|
|
999
|
+
if (result.kind === "missing")
|
|
1000
|
+
return { kind: "missing" };
|
|
1001
|
+
if (result.kind === "unavailable") {
|
|
1002
|
+
const entry = unavailableEntryFor(cache, result);
|
|
1003
|
+
if (entry === undefined)
|
|
1004
|
+
return { kind: "missing" };
|
|
1005
|
+
if (entry.listItem.availability !== "unavailable")
|
|
1006
|
+
return { kind: "missing" };
|
|
1007
|
+
if (projection?.listItem.availability === "available" &&
|
|
1008
|
+
(projection.listItem.status === "pending" || projection.listItem.status === "running") &&
|
|
1009
|
+
projection.listItem.runGeneration === entry.listItem.runGeneration) {
|
|
1010
|
+
cache.movedToHistory.add(runId);
|
|
1011
|
+
}
|
|
1012
|
+
else if (projection !== undefined &&
|
|
1013
|
+
projection.listItem.runGeneration !== entry.listItem.runGeneration) {
|
|
1014
|
+
cache.movedToHistory.delete(runId);
|
|
1015
|
+
}
|
|
1016
|
+
if (projection !== undefined &&
|
|
1017
|
+
(!directoryIdentitiesEqual(projection.directoryIdentity, entry.directoryIdentity) ||
|
|
1018
|
+
!directoryIdentitiesEqual(projection.rootIdentity, entry.rootIdentity) ||
|
|
1019
|
+
projection.stateFingerprint === undefined ||
|
|
1020
|
+
entry.stateFingerprint === undefined ||
|
|
1021
|
+
!containedFileFingerprintsEqual(projection.stateFingerprint, entry.stateFingerprint))) {
|
|
1022
|
+
cache.entries.delete(runId);
|
|
1023
|
+
const staleDetail = cache.details.get(runId);
|
|
1024
|
+
if (staleDetail !== undefined) {
|
|
1025
|
+
cache.details.delete(runId);
|
|
1026
|
+
cache.detailBytes -= staleDetail.sourceBytes;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
if (entry.listItem.runGeneration !== runGeneration)
|
|
1030
|
+
return { kind: "run_generation_changed" };
|
|
1031
|
+
roots.set(rootKey, cache);
|
|
1032
|
+
return {
|
|
1033
|
+
kind: "available",
|
|
1034
|
+
detail: entry.listItem,
|
|
1035
|
+
...(cache.movedToHistory.has(runId) ? { notice: "moved_to_history" } : {}),
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
if (projection !== undefined &&
|
|
1039
|
+
(!directoryIdentitiesEqual(projection.directoryIdentity, result.directoryIdentity) ||
|
|
1040
|
+
!directoryIdentitiesEqual(projection.rootIdentity, result.rootIdentity) ||
|
|
1041
|
+
projection.stateFingerprint === undefined ||
|
|
1042
|
+
!containedFileFingerprintsEqual(projection.stateFingerprint, result.stateFingerprint))) {
|
|
1043
|
+
if (projection.listItem.availability === "available" &&
|
|
1044
|
+
(projection.listItem.status === "pending" || projection.listItem.status === "running") &&
|
|
1045
|
+
projection.listItem.runGeneration === result.runGeneration &&
|
|
1046
|
+
result.state.status !== "pending" &&
|
|
1047
|
+
result.state.status !== "running") {
|
|
1048
|
+
cache.movedToHistory.add(runId);
|
|
1049
|
+
}
|
|
1050
|
+
else if (projection.listItem.runGeneration !== result.runGeneration) {
|
|
1051
|
+
cache.movedToHistory.delete(runId);
|
|
1052
|
+
}
|
|
1053
|
+
cache.entries.delete(runId);
|
|
1054
|
+
}
|
|
1055
|
+
if (result.runGeneration !== runGeneration) {
|
|
1056
|
+
roots.set(rootKey, cache);
|
|
1057
|
+
return { kind: "run_generation_changed" };
|
|
1058
|
+
}
|
|
1059
|
+
if (result.state.workflowSnapshotPath === undefined &&
|
|
1060
|
+
!isPlanReviewRunState(result.state) &&
|
|
1061
|
+
result.state.status !== "succeeded") {
|
|
1062
|
+
const revision = revisionFor(cache, result);
|
|
1063
|
+
const projected = detailProjection(result, listProjection(result, revision));
|
|
1064
|
+
insertDetail(cache, result, projected);
|
|
1065
|
+
roots.set(rootKey, cache);
|
|
1066
|
+
return {
|
|
1067
|
+
kind: "available",
|
|
1068
|
+
detail: await withWorkerLockObservation(runsRoot, projected, result),
|
|
1069
|
+
...(cache.movedToHistory.has(runId) ? { notice: "moved_to_history" } : {}),
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
const detail = await readEnrichedHealthyDetail(runsRoot, runId, runGeneration, cache);
|
|
1073
|
+
roots.set(rootKey, cache);
|
|
1074
|
+
return detail;
|
|
1075
|
+
});
|
|
1076
|
+
},
|
|
1077
|
+
async readCallContent(request) {
|
|
1078
|
+
return await serializeRootMutation(resolve(request.runsRoot), JSON.stringify([
|
|
1079
|
+
"call",
|
|
1080
|
+
request.runId,
|
|
1081
|
+
request.runGeneration,
|
|
1082
|
+
request.stageId,
|
|
1083
|
+
request.callId,
|
|
1084
|
+
request.kind,
|
|
1085
|
+
]), async () => await lazyContentReader.readCallContent(request));
|
|
1086
|
+
},
|
|
1087
|
+
async readResult(request) {
|
|
1088
|
+
return await serializeRootMutation(resolve(request.runsRoot), JSON.stringify(["result", request.runId, request.runGeneration]), async () => await lazyContentReader.readResult(request));
|
|
1089
|
+
},
|
|
1090
|
+
async listArtifacts(runsRoot, query = {}) {
|
|
1091
|
+
if (query.before !== undefined) {
|
|
1092
|
+
assertValidDashboardArtifactCursor(artifactCursorSecret, query.before);
|
|
1093
|
+
}
|
|
1094
|
+
await scanner.scan(runsRoot);
|
|
1095
|
+
const cache = roots.get(resolve(runsRoot));
|
|
1096
|
+
if (cache === undefined) {
|
|
1097
|
+
return { artifacts: [], serverNow: now().toISOString() };
|
|
1098
|
+
}
|
|
1099
|
+
if (cache.artifactIndexFailed) {
|
|
1100
|
+
throw new DashboardReadModelError("artifact_catalog_limit_exceeded");
|
|
1101
|
+
}
|
|
1102
|
+
return cache.artifactIndex?.list(query) ?? {
|
|
1103
|
+
artifacts: [],
|
|
1104
|
+
serverNow: now().toISOString(),
|
|
1105
|
+
};
|
|
1106
|
+
},
|
|
1107
|
+
};
|
|
1108
|
+
return scanner;
|
|
1109
|
+
}
|
|
1110
|
+
//# sourceMappingURL=scanner.js.map
|