@interf/compiler 0.22.2 → 0.50.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/README.md +119 -282
- package/dist/bin-mcp.d.ts +2 -0
- package/dist/bin-mcp.js +63 -0
- package/dist/bin-runtime.d.ts +2 -0
- package/dist/bin-runtime.js +111 -0
- package/dist/cli/commands/agents.js +4 -35
- package/dist/cli/commands/auth.d.ts +20 -0
- package/dist/cli/commands/auth.js +161 -0
- package/dist/cli/commands/benchmark.d.ts +9 -0
- package/dist/cli/commands/benchmark.js +58 -0
- package/dist/cli/commands/build-plan.js +107 -139
- package/dist/cli/commands/build.d.ts +3 -4
- package/dist/cli/commands/build.js +16 -45
- package/dist/cli/commands/doctor.js +3 -3
- package/dist/cli/commands/graphs.d.ts +2 -0
- package/dist/cli/commands/graphs.js +344 -0
- package/dist/cli/commands/login.js +4 -6
- package/dist/cli/commands/logout.js +1 -1
- package/dist/cli/commands/mcp.d.ts +4 -2
- package/dist/cli/commands/mcp.js +846 -232
- package/dist/cli/commands/project.d.ts +2 -0
- package/dist/cli/commands/project.js +176 -0
- package/dist/cli/commands/reset.d.ts +3 -4
- package/dist/cli/commands/reset.js +10 -31
- package/dist/cli/commands/runs.js +136 -57
- package/dist/cli/commands/runtime.d.ts +24 -0
- package/dist/cli/commands/runtime.js +373 -0
- package/dist/cli/commands/status.d.ts +1 -0
- package/dist/cli/commands/status.js +35 -45
- package/dist/cli/commands/traces.d.ts +2 -0
- package/dist/cli/commands/traces.js +97 -0
- package/dist/cli/commands/wizard.js +171 -178
- package/dist/cli/index.d.ts +7 -4
- package/dist/cli/index.js +13 -7
- package/dist/cli/lib/http-client.d.ts +39 -0
- package/dist/cli/lib/http-client.js +73 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/packages/build-plans/authoring/brief.d.ts +538 -0
- package/dist/packages/build-plans/authoring/brief.js +89 -0
- package/dist/packages/build-plans/authoring/build-plan-authoring.d.ts +52 -11
- package/dist/packages/build-plans/authoring/build-plan-authoring.js +493 -46
- package/dist/packages/build-plans/authoring/build-plan-edit-session.d.ts +10 -1
- package/dist/packages/build-plans/authoring/build-plan-edit-session.js +27 -4
- package/dist/packages/build-plans/authoring/build-plan-improvement.d.ts +9 -6
- package/dist/packages/build-plans/authoring/build-plan-improvement.js +97 -46
- package/dist/packages/build-plans/authoring/lib/build-plan-edit-utils.d.ts +1 -0
- package/dist/packages/build-plans/authoring/lib/build-plan-edit-utils.js +7 -7
- package/dist/packages/build-plans/build-plan-resolution.d.ts +1 -1
- package/dist/packages/build-plans/build-plan-resolution.js +3 -3
- package/dist/packages/build-plans/index.d.ts +1 -1
- package/dist/packages/build-plans/index.js +1 -1
- package/dist/packages/build-plans/package/build-plan-definitions.d.ts +14 -13
- package/dist/packages/build-plans/package/build-plan-definitions.js +45 -42
- package/dist/packages/build-plans/package/build-plan-helpers.d.ts +3 -2
- package/dist/packages/build-plans/package/build-plan-helpers.js +27 -13
- package/dist/packages/build-plans/package/build-plan-review-paths.d.ts +5 -5
- package/dist/packages/build-plans/package/build-plan-review-paths.js +15 -15
- package/dist/packages/build-plans/package/build-plan-stage-runner.d.ts +5 -4
- package/dist/packages/build-plans/package/build-plan-stage-runner.js +23 -11
- package/dist/packages/build-plans/package/builtin-build-plan.d.ts +7 -8
- package/dist/packages/build-plans/package/builtin-build-plan.js +10 -11
- package/dist/packages/build-plans/package/context-interface.d.ts +14 -9
- package/dist/packages/build-plans/package/context-interface.js +14 -33
- package/dist/packages/build-plans/package/interf-build-plan-package.d.ts +6 -17
- package/dist/packages/build-plans/package/interf-build-plan-package.js +68 -64
- package/dist/packages/build-plans/package/local-build-plans.d.ts +21 -14
- package/dist/packages/build-plans/package/local-build-plans.js +105 -55
- package/dist/packages/build-plans/package/user-build-plans.js +1 -1
- package/dist/packages/contracts/index.d.ts +5 -2
- package/dist/packages/contracts/index.js +3 -1
- package/dist/packages/contracts/lib/context-graph-layer.d.ts +161 -0
- package/dist/packages/contracts/lib/context-graph-layer.js +216 -0
- package/dist/packages/contracts/lib/project-paths.d.ts +144 -0
- package/dist/packages/contracts/lib/project-paths.js +220 -0
- package/dist/packages/contracts/lib/project-schema.d.ts +423 -0
- package/dist/packages/contracts/lib/project-schema.js +138 -0
- package/dist/packages/contracts/lib/schema.d.ts +1273 -81
- package/dist/packages/contracts/lib/schema.js +675 -79
- package/dist/packages/contracts/utils/filesystem.d.ts +1 -0
- package/dist/packages/contracts/utils/filesystem.js +29 -1
- package/dist/packages/contracts/utils/parse.js +67 -0
- package/dist/packages/projects/index.d.ts +6 -0
- package/dist/packages/{project → projects}/index.js +0 -3
- package/dist/packages/{project → projects}/interf-detect.d.ts +12 -12
- package/dist/packages/{project → projects}/interf-detect.js +56 -50
- package/dist/packages/projects/interf.d.ts +2 -0
- package/dist/packages/projects/interf.js +1 -0
- package/dist/packages/projects/lib/schema.d.ts +77 -0
- package/dist/packages/projects/lib/schema.js +91 -0
- package/dist/packages/projects/source-config.d.ts +53 -0
- package/dist/packages/projects/source-config.js +339 -0
- package/dist/packages/projects/source-folders.d.ts +11 -0
- package/dist/packages/{project → projects}/source-folders.js +26 -26
- package/dist/packages/{engine → runtime}/action-planner.d.ts +1 -1
- package/dist/packages/{engine → runtime}/action-planner.js +20 -22
- package/dist/packages/runtime/action-values.d.ts +1 -0
- package/dist/packages/runtime/action-values.js +1 -0
- package/dist/packages/runtime/actions/errors.d.ts +2 -0
- package/dist/packages/runtime/actions/errors.js +12 -0
- package/dist/packages/runtime/actions/fields.d.ts +86 -0
- package/dist/packages/runtime/actions/form-builders.d.ts +14 -0
- package/dist/packages/runtime/actions/form-builders.js +667 -0
- package/dist/packages/runtime/actions/form-validators.d.ts +8 -0
- package/dist/packages/runtime/actions/form-validators.js +134 -0
- package/dist/packages/runtime/actions/helpers.d.ts +11 -0
- package/dist/packages/runtime/actions/helpers.js +80 -0
- package/dist/packages/runtime/actions/index.d.ts +8 -0
- package/dist/packages/runtime/actions/index.js +11 -0
- package/dist/packages/runtime/actions/registry.d.ts +64 -0
- package/dist/packages/runtime/actions/registry.js +62 -0
- package/dist/packages/runtime/actions/requests.d.ts +45 -0
- package/dist/packages/runtime/actions/requests.js +164 -0
- package/dist/packages/runtime/actions/schemas.d.ts +161 -0
- package/dist/packages/runtime/actions/schemas.js +37 -0
- package/dist/packages/runtime/agent-handoff.d.ts +11 -0
- package/dist/packages/runtime/agent-handoff.js +102 -0
- package/dist/packages/{engine → runtime}/agents/index.d.ts +1 -2
- package/dist/packages/{engine → runtime}/agents/index.js +1 -2
- package/dist/packages/runtime/agents/lib/args.d.ts +14 -0
- package/dist/packages/runtime/agents/lib/args.js +24 -0
- package/dist/packages/{engine → runtime}/agents/lib/constants.d.ts +4 -1
- package/dist/packages/runtime/agents/lib/constants.js +13 -0
- package/dist/packages/runtime/agents/lib/context-graph-bootstrap.d.ts +3 -0
- package/dist/packages/{engine/agents/lib/verifiable-context-bootstrap.js → runtime/agents/lib/context-graph-bootstrap.js} +5 -6
- package/dist/packages/{engine → runtime}/agents/lib/detection.d.ts +5 -0
- package/dist/packages/{engine → runtime}/agents/lib/detection.js +16 -7
- package/dist/packages/{engine → runtime}/agents/lib/execution-profile.d.ts +14 -0
- package/dist/packages/{engine → runtime}/agents/lib/execution-profile.js +31 -14
- package/dist/packages/{engine → runtime}/agents/lib/execution.js +22 -6
- package/dist/packages/{engine → runtime}/agents/lib/executors.d.ts +1 -0
- package/dist/packages/{engine → runtime}/agents/lib/executors.js +11 -2
- package/dist/packages/runtime/agents/lib/logs.d.ts +12 -0
- package/dist/packages/runtime/agents/lib/logs.js +41 -0
- package/dist/packages/{engine → runtime}/agents/lib/preflight.js +19 -14
- package/dist/packages/runtime/agents/lib/render.d.ts +26 -0
- package/dist/packages/{engine → runtime}/agents/lib/render.js +48 -22
- package/dist/packages/runtime/agents/lib/shell-fs.d.ts +18 -0
- package/dist/packages/runtime/agents/lib/shell-fs.js +190 -0
- package/dist/packages/runtime/agents/lib/shell-paths.d.ts +16 -0
- package/dist/packages/runtime/agents/lib/shell-paths.js +63 -0
- package/dist/packages/runtime/agents/lib/shell-projection.d.ts +25 -0
- package/dist/packages/runtime/agents/lib/shell-projection.js +314 -0
- package/dist/packages/runtime/agents/lib/shell-templates.d.ts +30 -0
- package/dist/packages/runtime/agents/lib/shell-templates.js +494 -0
- package/dist/packages/runtime/agents/lib/shell-workspace.d.ts +17 -0
- package/dist/packages/runtime/agents/lib/shell-workspace.js +70 -0
- package/dist/packages/runtime/agents/lib/shells.d.ts +92 -0
- package/dist/packages/runtime/agents/lib/shells.js +509 -0
- package/dist/packages/runtime/agents/lib/source-context-scan.d.ts +10 -0
- package/dist/packages/runtime/agents/lib/source-context-scan.js +388 -0
- package/dist/packages/{engine → runtime}/agents/lib/status.js +1 -14
- package/dist/packages/runtime/agents/lib/string-utils.d.ts +16 -0
- package/dist/packages/runtime/agents/lib/string-utils.js +36 -0
- package/dist/packages/{engine → runtime}/agents/lib/types.d.ts +1 -0
- package/dist/packages/{engine → runtime}/agents/lib/user-config.d.ts +8 -2
- package/dist/packages/{engine → runtime}/agents/lib/user-config.js +8 -2
- package/dist/packages/runtime/agents/providers/claude-code.d.ts +13 -0
- package/dist/packages/runtime/agents/providers/claude-code.js +45 -0
- package/dist/packages/runtime/agents/providers/codex.d.ts +17 -0
- package/dist/packages/runtime/agents/providers/codex.js +66 -0
- package/dist/packages/runtime/agents/providers/cursor.d.ts +9 -0
- package/dist/packages/runtime/agents/providers/cursor.js +24 -0
- package/dist/packages/runtime/agents/providers/index.d.ts +9 -0
- package/dist/packages/runtime/agents/providers/index.js +31 -0
- package/dist/packages/runtime/agents/providers/types.d.ts +50 -0
- package/dist/packages/{engine → runtime}/agents/registry.d.ts +13 -2
- package/dist/packages/{engine → runtime}/agents/registry.js +48 -10
- package/dist/packages/{engine → runtime}/agents/role-executors.d.ts +1 -1
- package/dist/packages/{engine → runtime}/agents/role-executors.js +9 -7
- package/dist/packages/{engine → runtime}/agents/role-router.js +7 -5
- package/dist/packages/runtime/auth/account-context.d.ts +52 -0
- package/dist/packages/runtime/auth/account-context.js +68 -0
- package/dist/packages/runtime/auth/auth-flow.d.ts +73 -0
- package/dist/packages/runtime/auth/auth-flow.js +189 -0
- package/dist/packages/runtime/auth/jwt-validator.d.ts +58 -0
- package/dist/packages/runtime/auth/jwt-validator.js +86 -0
- package/dist/packages/runtime/auth/keychain.d.ts +35 -0
- package/dist/packages/runtime/auth/keychain.js +85 -0
- package/dist/packages/runtime/auth/session-store.d.ts +38 -0
- package/dist/packages/runtime/auth/session-store.js +96 -0
- package/dist/packages/runtime/auth/workos-client.d.ts +58 -0
- package/dist/packages/runtime/auth/workos-client.js +87 -0
- package/dist/packages/runtime/benchmark-question-draft.d.ts +23 -0
- package/dist/packages/runtime/benchmark-question-draft.js +153 -0
- package/dist/packages/runtime/build/artifact-counts.d.ts +1 -0
- package/dist/packages/{engine → runtime}/build/artifact-counts.js +5 -9
- package/dist/packages/{engine → runtime}/build/artifact-status.d.ts +6 -6
- package/dist/packages/{engine → runtime}/build/artifact-status.js +26 -24
- package/dist/packages/runtime/build/atomic-fs.d.ts +3 -0
- package/dist/packages/runtime/build/atomic-fs.js +95 -0
- package/dist/packages/runtime/build/billing-events.d.ts +78 -0
- package/dist/packages/{engine → runtime}/build/billing-events.js +17 -19
- package/dist/packages/runtime/build/build-evidence.d.ts +16 -0
- package/dist/packages/runtime/build/build-evidence.js +179 -0
- package/dist/packages/{engine → runtime}/build/build-pipeline.d.ts +12 -8
- package/dist/packages/runtime/build/build-pipeline.js +388 -0
- package/dist/packages/{engine → runtime}/build/build-plan-primitives.d.ts +1 -1
- package/dist/packages/{engine → runtime}/build/build-plan-primitives.js +0 -1
- package/dist/packages/runtime/build/build-plan-runs.d.ts +14 -0
- package/dist/packages/runtime/build/build-plan-runs.js +31 -0
- package/dist/packages/runtime/build/build-stage-plan.d.ts +16 -0
- package/dist/packages/runtime/build/build-stage-plan.js +101 -0
- package/dist/packages/{engine → runtime}/build/build-stage-runner.d.ts +2 -1
- package/dist/packages/runtime/build/build-stage-runner.js +302 -0
- package/dist/packages/{engine → runtime}/build/build-target.d.ts +7 -4
- package/dist/packages/runtime/build/build-target.js +40 -0
- package/dist/packages/{engine → runtime}/build/check-evaluator.d.ts +14 -16
- package/dist/packages/runtime/build/check-evaluator.js +1226 -0
- package/dist/packages/runtime/build/context-graph-paths.d.ts +64 -0
- package/dist/packages/runtime/build/context-graph-paths.js +160 -0
- package/dist/packages/runtime/build/context-graph-schema.d.ts +19 -0
- package/dist/packages/runtime/build/context-graph-schema.js +39 -0
- package/dist/packages/{engine → runtime}/build/discovery.d.ts +2 -2
- package/dist/packages/{engine → runtime}/build/discovery.js +4 -4
- package/dist/packages/{engine → runtime}/build/index.d.ts +7 -5
- package/dist/packages/{engine → runtime}/build/index.js +7 -5
- package/dist/packages/runtime/build/inspect-map.d.ts +10 -0
- package/dist/packages/runtime/build/inspect-map.js +270 -0
- package/dist/packages/{engine → runtime}/build/lib/schema.d.ts +449 -123
- package/dist/packages/runtime/build/lib/schema.js +494 -0
- package/dist/packages/runtime/build/native-entrypoint.d.ts +2 -0
- package/dist/packages/runtime/build/native-entrypoint.js +286 -0
- package/dist/packages/runtime/build/reset.d.ts +2 -0
- package/dist/packages/runtime/build/reset.js +62 -0
- package/dist/packages/{engine → runtime}/build/runtime-contracts.js +13 -7
- package/dist/packages/runtime/build/runtime-inventory.d.ts +7 -0
- package/dist/packages/{engine → runtime}/build/runtime-inventory.js +3 -3
- package/dist/packages/runtime/build/runtime-log-paths.d.ts +3 -0
- package/dist/packages/runtime/build/runtime-log-paths.js +16 -0
- package/dist/packages/{engine → runtime}/build/runtime-prompt.js +12 -9
- package/dist/packages/{engine → runtime}/build/runtime-reconcile.d.ts +1 -1
- package/dist/packages/{engine → runtime}/build/runtime-reconcile.js +25 -21
- package/dist/packages/runtime/build/runtime-runs.d.ts +10 -0
- package/dist/packages/runtime/build/runtime-runs.js +318 -0
- package/dist/packages/{engine → runtime}/build/runtime-types.d.ts +9 -6
- package/dist/packages/runtime/build/runtime-types.js +1 -0
- package/dist/packages/runtime/build/runtime.d.ts +8 -0
- package/dist/packages/runtime/build/runtime.js +7 -0
- package/dist/packages/runtime/build/source-files.d.ts +58 -0
- package/dist/packages/runtime/build/source-files.js +193 -0
- package/dist/packages/runtime/build/source-inventory.d.ts +28 -0
- package/dist/packages/runtime/build/source-inventory.js +512 -0
- package/dist/packages/runtime/build/source-manifest.d.ts +63 -0
- package/dist/packages/runtime/build/source-manifest.js +220 -0
- package/dist/packages/runtime/build/stage-evidence.d.ts +22 -0
- package/dist/packages/runtime/build/stage-evidence.js +386 -0
- package/dist/packages/runtime/build/stage-manifest.d.ts +45 -0
- package/dist/packages/runtime/build/stage-manifest.js +1125 -0
- package/dist/packages/runtime/build/stage-reuse.d.ts +11 -0
- package/dist/packages/runtime/build/stage-reuse.js +154 -0
- package/dist/packages/runtime/build/stage-session.d.ts +81 -0
- package/dist/packages/runtime/build/stage-session.js +308 -0
- package/dist/packages/runtime/build/state-artifacts.d.ts +9 -0
- package/dist/packages/runtime/build/state-artifacts.js +14 -0
- package/dist/packages/runtime/build/state-health.d.ts +4 -0
- package/dist/packages/{engine → runtime}/build/state-health.js +21 -26
- package/dist/packages/runtime/build/state-io.d.ts +12 -0
- package/dist/packages/runtime/build/state-io.js +118 -0
- package/dist/packages/runtime/build/state-view.d.ts +5 -0
- package/dist/packages/runtime/build/state-view.js +121 -0
- package/dist/packages/runtime/build/state.d.ts +7 -0
- package/dist/packages/runtime/build/state.js +12 -0
- package/dist/packages/runtime/build/summary-coverage-index.d.ts +21 -0
- package/dist/packages/runtime/build/summary-coverage-index.js +189 -0
- package/dist/packages/runtime/build/traces.d.ts +30 -0
- package/dist/packages/runtime/build/traces.js +133 -0
- package/dist/packages/{engine/build/validate-verifiable-context.d.ts → runtime/build/validate-context-graph.d.ts} +6 -6
- package/dist/packages/{engine/build/validate-verifiable-context.js → runtime/build/validate-context-graph.js} +49 -36
- package/dist/packages/{engine → runtime}/build/validate.d.ts +5 -5
- package/dist/packages/{engine → runtime}/build/validate.js +26 -26
- package/dist/packages/{engine → runtime}/client.d.ts +18 -18
- package/dist/packages/{engine → runtime}/client.js +48 -36
- package/dist/packages/{engine → runtime}/connection-config.d.ts +3 -2
- package/dist/packages/{engine → runtime}/connection-config.js +9 -8
- package/dist/packages/runtime/context-checks.d.ts +10 -0
- package/dist/packages/runtime/context-checks.js +127 -0
- package/dist/packages/runtime/context-graph-scaffold.d.ts +9 -0
- package/dist/packages/runtime/context-graph-scaffold.js +135 -0
- package/dist/packages/runtime/context-graph-semantic-graph.d.ts +9 -0
- package/dist/packages/runtime/context-graph-semantic-graph.js +416 -0
- package/dist/packages/runtime/entitlement-guard.d.ts +43 -0
- package/dist/packages/runtime/entitlement-guard.js +70 -0
- package/dist/packages/{engine → runtime}/execution/index.d.ts +2 -2
- package/dist/packages/{engine → runtime}/execution/index.js +1 -1
- package/dist/packages/{engine → runtime}/execution/lib/schema.d.ts +272 -191
- package/dist/packages/{engine → runtime}/execution/lib/schema.js +35 -32
- package/dist/packages/runtime/index.d.ts +29 -0
- package/dist/packages/runtime/index.js +21 -0
- package/dist/packages/runtime/instance-paths.d.ts +30 -0
- package/dist/packages/runtime/instance-paths.js +29 -0
- package/dist/packages/runtime/native-run-handlers.d.ts +63 -0
- package/dist/packages/{engine → runtime}/native-run-handlers.js +217 -166
- package/dist/packages/runtime/plan-artifact-contract.d.ts +17 -0
- package/dist/packages/runtime/plan-artifact-contract.js +42 -0
- package/dist/packages/runtime/project-entries.d.ts +11 -0
- package/dist/packages/runtime/project-entries.js +49 -0
- package/dist/packages/runtime/project-source-state.d.ts +26 -0
- package/dist/packages/runtime/project-source-state.js +56 -0
- package/dist/packages/runtime/project-store.d.ts +90 -0
- package/dist/packages/runtime/project-store.js +195 -0
- package/dist/packages/runtime/requested-artifacts.d.ts +7 -0
- package/dist/packages/{engine → runtime}/requested-artifacts.js +23 -1
- package/dist/packages/{engine → runtime}/run-observability.d.ts +2 -1
- package/dist/packages/{engine → runtime}/run-observability.js +174 -87
- package/dist/packages/runtime/runtime-action-proposals.d.ts +7 -0
- package/dist/packages/runtime/runtime-action-proposals.js +542 -0
- package/dist/packages/runtime/runtime-build-plans.d.ts +5 -0
- package/dist/packages/runtime/runtime-build-plans.js +175 -0
- package/dist/packages/runtime/runtime-build-runs.d.ts +47 -0
- package/dist/packages/runtime/runtime-build-runs.js +555 -0
- package/dist/packages/runtime/runtime-caches.d.ts +117 -0
- package/dist/packages/runtime/runtime-caches.js +266 -0
- package/dist/packages/{engine → runtime}/runtime-event-applier.d.ts +3 -1
- package/dist/packages/{engine → runtime}/runtime-event-applier.js +53 -17
- package/dist/packages/runtime/runtime-executor.d.ts +22 -0
- package/dist/packages/runtime/runtime-executor.js +131 -0
- package/dist/packages/runtime/runtime-jobs.d.ts +13 -0
- package/dist/packages/runtime/runtime-jobs.js +463 -0
- package/dist/packages/runtime/runtime-observability.d.ts +11 -0
- package/dist/packages/runtime/runtime-observability.js +39 -0
- package/dist/packages/{engine → runtime}/runtime-persistence.d.ts +9 -18
- package/dist/packages/{engine → runtime}/runtime-persistence.js +25 -25
- package/dist/packages/runtime/runtime-project-mutations.d.ts +7 -0
- package/dist/packages/runtime/runtime-project-mutations.js +65 -0
- package/dist/packages/runtime/runtime-project-reads.d.ts +18 -0
- package/dist/packages/runtime/runtime-project-reads.js +574 -0
- package/dist/packages/runtime/runtime-proposal-helpers.d.ts +22 -0
- package/dist/packages/runtime/runtime-proposal-helpers.js +223 -0
- package/dist/packages/{engine → runtime}/runtime-resource-builders.d.ts +23 -16
- package/dist/packages/{engine → runtime}/runtime-resource-builders.js +58 -46
- package/dist/packages/runtime/runtime-status.d.ts +14 -0
- package/dist/packages/runtime/runtime-status.js +15 -0
- package/dist/packages/runtime/runtime-verify-runs.d.ts +84 -0
- package/dist/packages/runtime/runtime-verify-runs.js +296 -0
- package/dist/packages/runtime/runtime.d.ts +1582 -0
- package/dist/packages/runtime/runtime.js +431 -0
- package/dist/packages/runtime/schemas/actions.d.ts +1206 -0
- package/dist/packages/runtime/schemas/actions.js +117 -0
- package/dist/packages/runtime/schemas/agents.d.ts +104 -0
- package/dist/packages/runtime/schemas/agents.js +74 -0
- package/dist/packages/runtime/schemas/build-plans.d.ts +1132 -0
- package/dist/packages/runtime/schemas/build-plans.js +141 -0
- package/dist/packages/runtime/schemas/context-graphs.d.ts +1522 -0
- package/dist/packages/runtime/schemas/context-graphs.js +110 -0
- package/dist/packages/runtime/schemas/files.d.ts +227 -0
- package/dist/packages/runtime/schemas/files.js +28 -0
- package/dist/packages/runtime/schemas/index.d.ts +9 -0
- package/dist/packages/runtime/schemas/index.js +13 -0
- package/dist/packages/runtime/schemas/instance.d.ts +141 -0
- package/dist/packages/runtime/schemas/instance.js +143 -0
- package/dist/packages/runtime/schemas/jobs.d.ts +339 -0
- package/dist/packages/runtime/schemas/jobs.js +107 -0
- package/dist/packages/runtime/schemas/projects.d.ts +366 -0
- package/dist/packages/runtime/schemas/projects.js +160 -0
- package/dist/packages/runtime/schemas/runs.d.ts +3445 -0
- package/dist/packages/runtime/schemas/runs.js +115 -0
- package/dist/packages/runtime/service/index.d.ts +3 -0
- package/dist/packages/runtime/service/index.js +3 -0
- package/dist/packages/runtime/service/openapi.d.ts +7 -0
- package/dist/packages/runtime/service/openapi.js +118 -0
- package/dist/packages/runtime/service/operations.d.ts +3011 -0
- package/dist/packages/runtime/service/operations.js +375 -0
- package/dist/packages/runtime/service/routes.d.ts +114 -0
- package/dist/packages/runtime/service/routes.js +128 -0
- package/dist/packages/runtime/service/server-api-files.d.ts +10 -0
- package/dist/packages/runtime/service/server-api-files.js +85 -0
- package/dist/packages/runtime/service/server-app-boot.d.ts +4 -0
- package/dist/packages/runtime/service/server-app-boot.js +46 -0
- package/dist/packages/runtime/service/server-guards.d.ts +63 -0
- package/dist/packages/runtime/service/server-guards.js +181 -0
- package/dist/packages/runtime/service/server-helpers.d.ts +38 -0
- package/dist/packages/runtime/service/server-helpers.js +108 -0
- package/dist/packages/runtime/service/server-instance-helpers.d.ts +30 -0
- package/dist/packages/runtime/service/server-instance-helpers.js +114 -0
- package/dist/packages/runtime/service/server-routes-action-proposals.d.ts +3 -0
- package/dist/packages/runtime/service/server-routes-action-proposals.js +45 -0
- package/dist/packages/runtime/service/server-routes-agents.d.ts +4 -0
- package/dist/packages/runtime/service/server-routes-agents.js +132 -0
- package/dist/packages/runtime/service/server-routes-auth.d.ts +33 -0
- package/dist/packages/runtime/service/server-routes-auth.js +138 -0
- package/dist/packages/runtime/service/server-routes-build-plans.d.ts +3 -0
- package/dist/packages/runtime/service/server-routes-build-plans.js +86 -0
- package/dist/packages/runtime/service/server-routes-discovery.d.ts +4 -0
- package/dist/packages/runtime/service/server-routes-discovery.js +196 -0
- package/dist/packages/runtime/service/server-routes-events.d.ts +5 -0
- package/dist/packages/runtime/service/server-routes-events.js +99 -0
- package/dist/packages/runtime/service/server-routes-project-context.d.ts +9 -0
- package/dist/packages/runtime/service/server-routes-project-context.js +287 -0
- package/dist/packages/runtime/service/server-routes-project-jobs.d.ts +9 -0
- package/dist/packages/runtime/service/server-routes-project-jobs.js +137 -0
- package/dist/packages/runtime/service/server-routes-project-runs.d.ts +14 -0
- package/dist/packages/runtime/service/server-routes-project-runs.js +88 -0
- package/dist/packages/runtime/service/server-routes-projects.d.ts +4 -0
- package/dist/packages/runtime/service/server-routes-projects.js +96 -0
- package/dist/packages/runtime/service/server-routes-runs.d.ts +3 -0
- package/dist/packages/runtime/service/server-routes-runs.js +119 -0
- package/dist/packages/runtime/service/server.d.ts +37 -0
- package/dist/packages/runtime/service/server.js +300 -0
- package/dist/packages/{engine → runtime/service}/service-registry.d.ts +5 -5
- package/dist/packages/{engine → runtime/service}/service-registry.js +7 -7
- package/dist/packages/runtime/verify/benchmark-run.d.ts +81 -0
- package/dist/packages/runtime/verify/benchmark-run.js +303 -0
- package/dist/packages/{engine → runtime}/verify/index.d.ts +2 -2
- package/dist/packages/{engine → runtime}/verify/index.js +1 -1
- package/dist/packages/{engine → runtime}/verify/lib/schema.d.ts +83 -16
- package/dist/packages/{engine → runtime}/verify/lib/schema.js +38 -18
- package/dist/packages/runtime/verify/test-file-guard.d.ts +2 -0
- package/dist/packages/runtime/verify/test-file-guard.js +29 -0
- package/dist/packages/{engine → runtime}/verify/verify-execution.d.ts +7 -0
- package/dist/packages/{engine → runtime}/verify/verify-execution.js +119 -45
- package/dist/packages/{engine → runtime}/verify/verify-paths.d.ts +5 -4
- package/dist/packages/runtime/verify/verify-paths.js +65 -0
- package/dist/packages/{engine → runtime}/verify/verify-sandbox.d.ts +1 -1
- package/dist/packages/runtime/verify/verify-sandbox.js +88 -0
- package/dist/packages/{engine → runtime}/verify/verify-specs.d.ts +2 -0
- package/dist/packages/runtime/verify/verify-specs.js +126 -0
- package/dist/packages/runtime/verify/verify-targets.d.ts +5 -0
- package/dist/packages/{engine → runtime}/verify/verify-targets.js +12 -12
- package/dist/packages/runtime/verify/verify-types.js +1 -0
- package/dist/packages/{engine → runtime}/verify/verify.d.ts +1 -1
- package/dist/packages/{engine → runtime}/verify/verify.js +1 -1
- package/dist/packages/runtime/wire-schemas.d.ts +18 -0
- package/dist/packages/runtime/wire-schemas.js +27 -0
- package/package.json +32 -30
- package/public-repo/CONTRIBUTING.md +16 -18
- package/public-repo/README.md +119 -282
- package/public-repo/SECURITY.md +3 -4
- package/public-repo/build-plans/interf-default/README.md +24 -16
- package/public-repo/build-plans/interf-default/build/stages/entrypoint/SKILL.md +74 -0
- package/public-repo/build-plans/interf-default/build/stages/knowledge/SKILL.md +95 -0
- package/public-repo/build-plans/interf-default/build/stages/summarize/SKILL.md +49 -4
- package/public-repo/build-plans/interf-default/build-plan.json +49 -39
- package/public-repo/build-plans/interf-default/build-plan.schema.json +59 -33
- package/public-repo/build-plans/interf-default/improve/SKILL.md +3 -3
- package/public-repo/build-plans/interf-default/use/query/SKILL.md +18 -11
- package/public-repo/openapi/local-service.openapi.json +14227 -0
- package/public-repo/skills/interf/SKILL.md +508 -187
- package/dist/cli/commands/prep.d.ts +0 -2
- package/dist/cli/commands/prep.js +0 -240
- package/dist/cli/commands/test.d.ts +0 -10
- package/dist/cli/commands/test.js +0 -85
- package/dist/cli/commands/web.d.ts +0 -2
- package/dist/cli/commands/web.js +0 -286
- package/dist/interf-ui/404.html +0 -1
- package/dist/interf-ui/__next.__PAGE__.txt +0 -10
- package/dist/interf-ui/__next._full.txt +0 -20
- package/dist/interf-ui/__next._head.txt +0 -5
- package/dist/interf-ui/__next._index.txt +0 -5
- package/dist/interf-ui/__next._tree.txt +0 -5
- package/dist/interf-ui/_next/static/--reS3xBzM5zc6QxNjZd6/_buildManifest.js +0 -11
- package/dist/interf-ui/_next/static/--reS3xBzM5zc6QxNjZd6/_clientMiddlewareManifest.js +0 -1
- package/dist/interf-ui/_next/static/--reS3xBzM5zc6QxNjZd6/_ssgManifest.js +0 -1
- package/dist/interf-ui/_next/static/chunks/0.tjb6f4golw..css +0 -3
- package/dist/interf-ui/_next/static/chunks/03~yq9q893hmn.js +0 -1
- package/dist/interf-ui/_next/static/chunks/085-n_jv2ng_q.css +0 -1
- package/dist/interf-ui/_next/static/chunks/0dn41fa_zvgsl.js +0 -1
- package/dist/interf-ui/_next/static/chunks/0g-ea0zj5d-0k.js +0 -1
- package/dist/interf-ui/_next/static/chunks/0gwqglc4iz583.js +0 -1
- package/dist/interf-ui/_next/static/chunks/0haldgm65ve6l.js +0 -1
- package/dist/interf-ui/_next/static/chunks/0nv3am99vjzn4.js +0 -1
- package/dist/interf-ui/_next/static/chunks/0s77gt_o4jwtx.js +0 -1
- package/dist/interf-ui/_next/static/chunks/0y5z3t-z1c8ks.js.map +0 -5
- package/dist/interf-ui/_next/static/chunks/0~a36ujuzpaz..js +0 -116
- package/dist/interf-ui/_next/static/chunks/10jeodxe4nkgj.js +0 -31
- package/dist/interf-ui/_next/static/chunks/119h2rouych2t.js +0 -1
- package/dist/interf-ui/_next/static/chunks/13c8b~m8knjsf.js +0 -1
- package/dist/interf-ui/_next/static/chunks/14dznb2qpt-ho.js +0 -91
- package/dist/interf-ui/_next/static/chunks/15z_en80lrq-3.js +0 -5
- package/dist/interf-ui/_next/static/chunks/turbopack-0p.pvcjrtq-jh.js +0 -1
- package/dist/interf-ui/_next/static/chunks/turbopack-0usj_75.8frlw.js +0 -1
- package/dist/interf-ui/_next/static/chunks/turbopack-worker-0sjn--fhq~1cg.js +0 -1
- package/dist/interf-ui/_next/static/media/GeistMono_Variable.p.17jn9btb_52pq.woff2 +0 -0
- package/dist/interf-ui/_next/static/media/Geist_Variable-s.p.0-te~ja_gpvcf.woff2 +0 -0
- package/dist/interf-ui/_next/static/media/worker.102zas1s52_pf.js +0 -109
- package/dist/interf-ui/_not-found/__next._full.txt +0 -15
- package/dist/interf-ui/_not-found/__next._head.txt +0 -5
- package/dist/interf-ui/_not-found/__next._index.txt +0 -5
- package/dist/interf-ui/_not-found/__next._not-found.__PAGE__.txt +0 -5
- package/dist/interf-ui/_not-found/__next._not-found.txt +0 -5
- package/dist/interf-ui/_not-found/__next._tree.txt +0 -2
- package/dist/interf-ui/_not-found.html +0 -1
- package/dist/interf-ui/_not-found.txt +0 -15
- package/dist/interf-ui/index.html +0 -1
- package/dist/interf-ui/index.txt +0 -20
- package/dist/packages/contracts/lib/preparation-paths.d.ts +0 -117
- package/dist/packages/contracts/lib/preparation-paths.js +0 -177
- package/dist/packages/engine/action-definitions.d.ts +0 -407
- package/dist/packages/engine/action-definitions.js +0 -1158
- package/dist/packages/engine/action-values.d.ts +0 -1
- package/dist/packages/engine/action-values.js +0 -1
- package/dist/packages/engine/agents/lib/args.d.ts +0 -4
- package/dist/packages/engine/agents/lib/args.js +0 -52
- package/dist/packages/engine/agents/lib/chart-guidance.d.ts +0 -1
- package/dist/packages/engine/agents/lib/chart-guidance.js +0 -8
- package/dist/packages/engine/agents/lib/constants.js +0 -28
- package/dist/packages/engine/agents/lib/logs.d.ts +0 -2
- package/dist/packages/engine/agents/lib/logs.js +0 -17
- package/dist/packages/engine/agents/lib/render.d.ts +0 -8
- package/dist/packages/engine/agents/lib/schema.d.ts +0 -8
- package/dist/packages/engine/agents/lib/schema.js +0 -7
- package/dist/packages/engine/agents/lib/shells.d.ts +0 -74
- package/dist/packages/engine/agents/lib/shells.js +0 -1052
- package/dist/packages/engine/agents/lib/verifiable-context-bootstrap.d.ts +0 -3
- package/dist/packages/engine/build/artifact-counts.d.ts +0 -1
- package/dist/packages/engine/build/billing-events.d.ts +0 -89
- package/dist/packages/engine/build/build-pipeline.js +0 -175
- package/dist/packages/engine/build/build-plan-runs.d.ts +0 -14
- package/dist/packages/engine/build/build-plan-runs.js +0 -31
- package/dist/packages/engine/build/build-stage-plan.d.ts +0 -16
- package/dist/packages/engine/build/build-stage-plan.js +0 -100
- package/dist/packages/engine/build/build-stage-runner.js +0 -94
- package/dist/packages/engine/build/build-target.js +0 -16
- package/dist/packages/engine/build/check-evaluator.js +0 -298
- package/dist/packages/engine/build/lib/schema.js +0 -316
- package/dist/packages/engine/build/reset.d.ts +0 -2
- package/dist/packages/engine/build/reset.js +0 -74
- package/dist/packages/engine/build/runtime-inventory.d.ts +0 -7
- package/dist/packages/engine/build/runtime-paths.d.ts +0 -8
- package/dist/packages/engine/build/runtime-paths.js +0 -26
- package/dist/packages/engine/build/runtime-runs.d.ts +0 -10
- package/dist/packages/engine/build/runtime-runs.js +0 -224
- package/dist/packages/engine/build/runtime.d.ts +0 -5
- package/dist/packages/engine/build/runtime.js +0 -4
- package/dist/packages/engine/build/source-files.d.ts +0 -46
- package/dist/packages/engine/build/source-files.js +0 -149
- package/dist/packages/engine/build/state-artifacts.d.ts +0 -9
- package/dist/packages/engine/build/state-artifacts.js +0 -14
- package/dist/packages/engine/build/state-health.d.ts +0 -4
- package/dist/packages/engine/build/state-io.d.ts +0 -11
- package/dist/packages/engine/build/state-io.js +0 -82
- package/dist/packages/engine/build/state-paths.d.ts +0 -5
- package/dist/packages/engine/build/state-paths.js +0 -16
- package/dist/packages/engine/build/state-view.d.ts +0 -5
- package/dist/packages/engine/build/state-view.js +0 -94
- package/dist/packages/engine/build/state.d.ts +0 -7
- package/dist/packages/engine/build/state.js +0 -12
- package/dist/packages/engine/build/validate-helpers.d.ts +0 -12
- package/dist/packages/engine/build/validate-helpers.js +0 -41
- package/dist/packages/engine/build/verifiable-context-paths.d.ts +0 -47
- package/dist/packages/engine/build/verifiable-context-paths.js +0 -121
- package/dist/packages/engine/build/verifiable-context-schema.d.ts +0 -21
- package/dist/packages/engine/build/verifiable-context-schema.js +0 -126
- package/dist/packages/engine/cloud-seams.d.ts +0 -115
- package/dist/packages/engine/cloud-seams.js +0 -84
- package/dist/packages/engine/index.d.ts +0 -22
- package/dist/packages/engine/index.js +0 -15
- package/dist/packages/engine/instance-paths.d.ts +0 -106
- package/dist/packages/engine/instance-paths.js +0 -171
- package/dist/packages/engine/lib/schema.d.ts +0 -6304
- package/dist/packages/engine/lib/schema.js +0 -730
- package/dist/packages/engine/native-run-handlers.d.ts +0 -25
- package/dist/packages/engine/preparation-store.d.ts +0 -105
- package/dist/packages/engine/preparation-store.js +0 -213
- package/dist/packages/engine/readiness-check-draft.d.ts +0 -20
- package/dist/packages/engine/readiness-check-draft.js +0 -111
- package/dist/packages/engine/requested-artifacts.d.ts +0 -5
- package/dist/packages/engine/routes.d.ts +0 -85
- package/dist/packages/engine/routes.js +0 -99
- package/dist/packages/engine/runtime-caches.d.ts +0 -76
- package/dist/packages/engine/runtime-caches.js +0 -191
- package/dist/packages/engine/runtime-proposal-helpers.d.ts +0 -35
- package/dist/packages/engine/runtime-proposal-helpers.js +0 -247
- package/dist/packages/engine/runtime.d.ts +0 -371
- package/dist/packages/engine/runtime.js +0 -2463
- package/dist/packages/engine/server.d.ts +0 -58
- package/dist/packages/engine/server.js +0 -1399
- package/dist/packages/engine/verify/readiness-check-run.d.ts +0 -82
- package/dist/packages/engine/verify/readiness-check-run.js +0 -265
- package/dist/packages/engine/verify/verify-paths.js +0 -61
- package/dist/packages/engine/verify/verify-sandbox.js +0 -88
- package/dist/packages/engine/verify/verify-specs.js +0 -114
- package/dist/packages/engine/verify/verify-targets.d.ts +0 -5
- package/dist/packages/engine/wire-schemas.d.ts +0 -547
- package/dist/packages/engine/wire-schemas.js +0 -59
- package/dist/packages/project/index.d.ts +0 -9
- package/dist/packages/project/interf-bootstrap.d.ts +0 -1
- package/dist/packages/project/interf-bootstrap.js +0 -1
- package/dist/packages/project/interf-scaffold.d.ts +0 -3
- package/dist/packages/project/interf-scaffold.js +0 -136
- package/dist/packages/project/interf.d.ts +0 -4
- package/dist/packages/project/interf.js +0 -3
- package/dist/packages/project/lib/schema.d.ts +0 -328
- package/dist/packages/project/lib/schema.js +0 -136
- package/dist/packages/project/preparation-entries.d.ts +0 -11
- package/dist/packages/project/preparation-entries.js +0 -49
- package/dist/packages/project/source-config.d.ts +0 -46
- package/dist/packages/project/source-config.js +0 -394
- package/dist/packages/project/source-folders.d.ts +0 -11
- package/public-repo/build-plans/interf-default/build/stages/shape/SKILL.md +0 -27
- package/public-repo/build-plans/interf-default/build/stages/structure/SKILL.md +0 -21
- package/public-repo/plugins/README.md +0 -9
- package/public-repo/plugins/interf/.claude-plugin/plugin.json +0 -21
- package/public-repo/plugins/interf/.mcp.json +0 -12
- package/public-repo/plugins/interf/README.md +0 -32
- package/public-repo/plugins/interf/skills/interf/SKILL.md +0 -376
- /package/dist/packages/{engine/agents/lib/types.js → runtime/actions/fields.js} +0 -0
- /package/dist/packages/{engine → runtime}/agents/lib/agents.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/agents/lib/agents.js +0 -0
- /package/dist/packages/{engine → runtime}/agents/lib/execution.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/agents/lib/preflight.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/agents/lib/status.d.ts +0 -0
- /package/dist/packages/{engine/build/runtime-types.js → runtime/agents/lib/types.js} +0 -0
- /package/dist/packages/{engine/verify/verify-types.js → runtime/agents/providers/types.js} +0 -0
- /package/dist/packages/{engine → runtime}/agents/role-router.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/build/build-execution.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/build/build-execution.js +0 -0
- /package/dist/packages/{engine → runtime}/build/runtime-contracts.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/build/runtime-prompt.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/execution/adapters.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/execution/adapters.js +0 -0
- /package/dist/packages/{engine → runtime}/execution/events.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/execution/events.js +0 -0
- /package/dist/packages/{engine → runtime}/verify/verify-profile-presets.d.ts +0 -0
- /package/dist/packages/{engine → runtime}/verify/verify-profile-presets.js +0 -0
- /package/dist/packages/{engine → runtime}/verify/verify-types.d.ts +0 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { mkdirSync, } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { listProjectConfigs, loadSourceFolderConfig, markProjectLatestContextGraphRun, resolveProjectSourceBindingPath, } from "../projects/source-config.js";
|
|
4
|
+
import { BuildRunSchema, } from "./execution/lib/schema.js";
|
|
5
|
+
import { createRunEventId, createRunEventTimestamp, } from "./execution/events.js";
|
|
6
|
+
import { loadState, } from "./build/state.js";
|
|
7
|
+
import { loadContextGraphSourceManifest, } from "./build/source-manifest.js";
|
|
8
|
+
import { byCreatedAtDesc, listJsonFiles, projectBuildRunPath, projectBuildRunsRoot, readBuildRunAt, readExecutionStageLedgerHistory, timestampKey, writeJsonFile, } from "./runtime-persistence.js";
|
|
9
|
+
import { applyEventToBuildRun, INTERRUPTED_BUILD_RUN_REASON, reconcileBuildRunTerminalStatus, } from "./runtime-event-applier.js";
|
|
10
|
+
import { createRunId, logsForExecutionStageLedger, logsForStageRun, evidenceForStage, stageArtifactRefs, } from "./runtime-resource-builders.js";
|
|
11
|
+
import { computeArtifactStatuses } from "./build/artifact-status.js";
|
|
12
|
+
import { buildPlanContextChecks, projectContextChecksForRun, } from "./context-checks.js";
|
|
13
|
+
import { JsonlBillingEventSink, buildBillingEventsForRun, defaultBillingEventLogPath, } from "./build/billing-events.js";
|
|
14
|
+
import { getBuildPlan } from "../build-plans/package/build-plan-definitions.js";
|
|
15
|
+
import { BuildRunCreateRequestSchema, BuildRunResourceSchema, LocalRunHandlerResultSchema, } from "./schemas/index.js";
|
|
16
|
+
import { uniqueArtifacts } from "./run-observability.js";
|
|
17
|
+
import { requireSelectedBuildPlan } from "./runtime-proposal-helpers.js";
|
|
18
|
+
import { readinessUpdatedEvent } from "./runtime-verify-runs.js";
|
|
19
|
+
import { isTerminalStatus } from "./runtime-status.js";
|
|
20
|
+
/** TTL for `POST .../build-runs` idempotency-key dedupe entries. */
|
|
21
|
+
const IDEMPOTENCY_TTL_MS = 60 * 60 * 1000;
|
|
22
|
+
/** Idempotency cache size at which to schedule an opportunistic prune. */
|
|
23
|
+
const IDEMPOTENCY_PRUNE_THRESHOLD = 64;
|
|
24
|
+
function countsFromContextGraphState(state, contextGraphPath) {
|
|
25
|
+
const counts = {};
|
|
26
|
+
const sourceManifest = loadContextGraphSourceManifest(contextGraphPath);
|
|
27
|
+
if (sourceManifest)
|
|
28
|
+
counts.source_total = sourceManifest.source_total;
|
|
29
|
+
for (const stage of Object.values(state.stages ?? {})) {
|
|
30
|
+
for (const [key, value] of Object.entries(stage.counts ?? {})) {
|
|
31
|
+
if (Number.isFinite(value))
|
|
32
|
+
counts[key] = Math.max(counts[key] ?? 0, value);
|
|
33
|
+
}
|
|
34
|
+
for (const [key, value] of Object.entries(stage.artifact_counts ?? {})) {
|
|
35
|
+
if (Number.isFinite(value))
|
|
36
|
+
counts[key] = Math.max(counts[key] ?? 0, value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return counts;
|
|
40
|
+
}
|
|
41
|
+
function buildRunRecordFilesForProject(projectDataDir, projectName) {
|
|
42
|
+
void projectName;
|
|
43
|
+
return listJsonFiles(projectBuildRunsRoot(projectDataDir));
|
|
44
|
+
}
|
|
45
|
+
function readBuildRunRecordsForProject(projectDataDir, projectName) {
|
|
46
|
+
const byRunId = new Map();
|
|
47
|
+
for (const filePath of buildRunRecordFilesForProject(projectDataDir, projectName)) {
|
|
48
|
+
const run = readBuildRunAt(filePath);
|
|
49
|
+
if (!run || run.project !== projectName)
|
|
50
|
+
continue;
|
|
51
|
+
if (!byRunId.has(run.run_id))
|
|
52
|
+
byRunId.set(run.run_id, run);
|
|
53
|
+
}
|
|
54
|
+
return [...byRunId.values()];
|
|
55
|
+
}
|
|
56
|
+
export function listBuildRuns(runtime, projectDataDir) {
|
|
57
|
+
return byCreatedAtDesc(listProjectConfigs(loadSourceFolderConfig(projectDataDir))
|
|
58
|
+
.flatMap((project) => listBuildRunsForProject(runtime, projectDataDir, project.name))).map((run) => BuildRunResourceSchema.parse({ run }));
|
|
59
|
+
}
|
|
60
|
+
export function listBuildRunsForProject(runtime, projectDataDir, projectName) {
|
|
61
|
+
return runtime.buildRunCache.get(projectDataDir, projectName, () => byCreatedAtDesc(readBuildRunRecordsForProject(projectDataDir, projectName)), (run) => run.run_id);
|
|
62
|
+
}
|
|
63
|
+
export function getBuildRun(runtime, projectDataDir, runId) {
|
|
64
|
+
// Fast path: if the runId was seen during a recent listing, look up
|
|
65
|
+
// its owning Project directly and return that Project's
|
|
66
|
+
// cached entry instead of scanning every project on disk.
|
|
67
|
+
const known = runtime.buildRunCache.projectFor(projectDataDir, runId);
|
|
68
|
+
if (known) {
|
|
69
|
+
const found = listBuildRunsForProject(runtime, projectDataDir, known).find((entry) => entry.run_id === runId);
|
|
70
|
+
if (found)
|
|
71
|
+
return BuildRunResourceSchema.parse({ run: found });
|
|
72
|
+
}
|
|
73
|
+
// Slow path: scan all projects. Falls through after a cache
|
|
74
|
+
// miss for an in-flight run created before this process restarted.
|
|
75
|
+
for (const resource of listBuildRuns(runtime, projectDataDir)) {
|
|
76
|
+
if (resource.run.run_id === runId)
|
|
77
|
+
return resource;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
export function getBuildRunEvents(runtime, projectDataDir, runId) {
|
|
82
|
+
return getBuildRun(runtime, projectDataDir, runId)?.run.events ?? null;
|
|
83
|
+
}
|
|
84
|
+
export function getBuildRunEvidence(runtime, projectDataDir, runId) {
|
|
85
|
+
const run = getBuildRun(runtime, projectDataDir, runId)?.run;
|
|
86
|
+
if (!run)
|
|
87
|
+
return null;
|
|
88
|
+
return run.stages
|
|
89
|
+
.map((stage) => stage.latest_evidence ?? null)
|
|
90
|
+
.filter((evidence) => evidence !== null);
|
|
91
|
+
}
|
|
92
|
+
export function getBuildRunArtifacts(runtime, projectDataDir, runId) {
|
|
93
|
+
const run = getBuildRun(runtime, projectDataDir, runId)?.run;
|
|
94
|
+
if (!run)
|
|
95
|
+
return null;
|
|
96
|
+
return uniqueArtifacts(run.stages.flatMap((stage) => stage.artifacts));
|
|
97
|
+
}
|
|
98
|
+
export async function createBuildRun(runtime, projectDataDir, requestValue) {
|
|
99
|
+
const request = BuildRunCreateRequestSchema.parse(requestValue);
|
|
100
|
+
const projectConfig = runtime.resolveProjectConfig(projectDataDir, request.project);
|
|
101
|
+
const runId = createRunId("build");
|
|
102
|
+
const contextGraphPath = runtime.ensureContextGraphForRun(projectDataDir, projectConfig, runId);
|
|
103
|
+
const now = new Date().toISOString();
|
|
104
|
+
const buildPlan = getBuildPlan(requireSelectedBuildPlan(projectConfig), {
|
|
105
|
+
projectDataDir,
|
|
106
|
+
});
|
|
107
|
+
const stageTotal = buildPlan.stages.length;
|
|
108
|
+
const run = BuildRunSchema.parse({
|
|
109
|
+
kind: "interf-build-run",
|
|
110
|
+
version: 1,
|
|
111
|
+
run_id: runId,
|
|
112
|
+
status: "running",
|
|
113
|
+
project: projectConfig.name,
|
|
114
|
+
build_plan: buildPlan.id,
|
|
115
|
+
backend: "native",
|
|
116
|
+
source_path: resolveProjectSourceBindingPath(projectDataDir, projectConfig),
|
|
117
|
+
context_graph_path: contextGraphPath,
|
|
118
|
+
created_at: now,
|
|
119
|
+
started_at: now,
|
|
120
|
+
stages: buildPlan.stages
|
|
121
|
+
.map((stage, index) => {
|
|
122
|
+
return {
|
|
123
|
+
run_id: runId,
|
|
124
|
+
stage_id: stage.id,
|
|
125
|
+
stage_label: stage.label,
|
|
126
|
+
stage_index: index,
|
|
127
|
+
stage_total: stageTotal,
|
|
128
|
+
status: "queued",
|
|
129
|
+
contract: {
|
|
130
|
+
stage_label: stage.label,
|
|
131
|
+
stage_index: index,
|
|
132
|
+
stage_total: stageTotal,
|
|
133
|
+
reads: stage.reads,
|
|
134
|
+
writes: stage.writes,
|
|
135
|
+
},
|
|
136
|
+
artifacts: [],
|
|
137
|
+
};
|
|
138
|
+
}),
|
|
139
|
+
events: [],
|
|
140
|
+
context_checks: buildPlanContextChecks({
|
|
141
|
+
brief: buildPlan.brief ?? null,
|
|
142
|
+
artifacts: buildPlan.contextInterface?.artifacts ?? [],
|
|
143
|
+
}),
|
|
144
|
+
});
|
|
145
|
+
writeBuildRun(runtime, projectDataDir, run);
|
|
146
|
+
runtime.activeBuildRuns.set(runId, {
|
|
147
|
+
projectDataDir,
|
|
148
|
+
contextGraphPath,
|
|
149
|
+
project: projectConfig.name,
|
|
150
|
+
cancelled: false,
|
|
151
|
+
});
|
|
152
|
+
await recordBuildRunEvent(runtime, projectDataDir, contextGraphPath, runId, {
|
|
153
|
+
type: "run.started",
|
|
154
|
+
event_id: createRunEventId("event"),
|
|
155
|
+
run_id: runId,
|
|
156
|
+
timestamp: now,
|
|
157
|
+
project: projectConfig.name,
|
|
158
|
+
build_plan: buildPlan.id,
|
|
159
|
+
context_graph_path: contextGraphPath,
|
|
160
|
+
backend: "native",
|
|
161
|
+
});
|
|
162
|
+
const sink = {
|
|
163
|
+
emit: (event) => recordBuildRunEvent(runtime, projectDataDir, contextGraphPath, runId, event),
|
|
164
|
+
};
|
|
165
|
+
void runBuildInBackground(runtime, projectDataDir, request, {
|
|
166
|
+
runId,
|
|
167
|
+
sourcePath: projectDataDir,
|
|
168
|
+
contextGraphPath,
|
|
169
|
+
projectConfig,
|
|
170
|
+
events: sink,
|
|
171
|
+
});
|
|
172
|
+
const saved = readBuildRun(projectDataDir, runId) ?? run;
|
|
173
|
+
return BuildRunResourceSchema.parse({ run: saved });
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Cancel an in-flight Build run. Marks the persisted record as
|
|
177
|
+
* `cancelled`, emits a `run.cancelled` event to capture the cancellation in
|
|
178
|
+
* the run timeline, and clears the active handle so retries may start a
|
|
179
|
+
* fresh run. If the run already finished, returns
|
|
180
|
+
* `{ cancelled: false, reason: "already finished" }` and persists nothing.
|
|
181
|
+
*/
|
|
182
|
+
export function cancelBuildRun(runtime, runId) {
|
|
183
|
+
const handle = runtime.activeBuildRuns.get(runId);
|
|
184
|
+
if (!handle) {
|
|
185
|
+
// Either unknown or already terminal. The server route already 404s
|
|
186
|
+
// unknown ids before calling this, so anything reaching here is a run
|
|
187
|
+
// we already finalized.
|
|
188
|
+
return { cancelled: false, reason: "already finished" };
|
|
189
|
+
}
|
|
190
|
+
if (handle.cancelled) {
|
|
191
|
+
return { cancelled: false, reason: "already cancelled" };
|
|
192
|
+
}
|
|
193
|
+
const cancelledAt = new Date().toISOString();
|
|
194
|
+
handle.cancelled = true;
|
|
195
|
+
handle.cancelledAt = cancelledAt;
|
|
196
|
+
const current = readBuildRun(handle.projectDataDir, runId);
|
|
197
|
+
if (current && !isTerminalStatus(current.status)) {
|
|
198
|
+
writeBuildRun(runtime, handle.projectDataDir, applyEventToBuildRun(current, {
|
|
199
|
+
type: "run.cancelled",
|
|
200
|
+
event_id: createRunEventId("event"),
|
|
201
|
+
run_id: runId,
|
|
202
|
+
timestamp: cancelledAt,
|
|
203
|
+
reason: "Build cancelled by request.",
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
return { cancelled: true };
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Look up the run id previously associated with this idempotency key in
|
|
210
|
+
* `projectDataDir`. Returns null when the key is unknown or its TTL has
|
|
211
|
+
* elapsed. The project argument is required so that the same key in
|
|
212
|
+
* two different projects always returns two different runs.
|
|
213
|
+
*/
|
|
214
|
+
export function findIdempotentBuildRun(runtime, projectDataDir, key) {
|
|
215
|
+
const resolvedRoot = resolve(projectDataDir);
|
|
216
|
+
const bucket = runtime.idempotencyKeyCache.get(resolvedRoot);
|
|
217
|
+
if (!bucket)
|
|
218
|
+
return null;
|
|
219
|
+
const entry = bucket.get(key);
|
|
220
|
+
if (!entry)
|
|
221
|
+
return null;
|
|
222
|
+
if (entry.expiresAt <= Date.now()) {
|
|
223
|
+
// Opportunistic single-key prune. The bulk prune runs on writes
|
|
224
|
+
// when the cache crosses the size threshold (see
|
|
225
|
+
// {@link recordIdempotentBuildRun}).
|
|
226
|
+
bucket.delete(key);
|
|
227
|
+
if (bucket.size === 0)
|
|
228
|
+
runtime.idempotencyKeyCache.delete(resolvedRoot);
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
return entry.runId;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Cache the run id created (or returned) for this idempotency key in
|
|
235
|
+
* `projectDataDir`. Entries expire after `IDEMPOTENCY_TTL_MS`. Pruning
|
|
236
|
+
* is opportunistic: the previous implementation walked every entry on
|
|
237
|
+
* every read AND write, which was O(N) per request. Now we only sweep
|
|
238
|
+
* when the cache grows past {@link IDEMPOTENCY_PRUNE_THRESHOLD}.
|
|
239
|
+
*/
|
|
240
|
+
export function recordIdempotentBuildRun(runtime, projectDataDir, key, runId) {
|
|
241
|
+
const resolvedRoot = resolve(projectDataDir);
|
|
242
|
+
let bucket = runtime.idempotencyKeyCache.get(resolvedRoot);
|
|
243
|
+
if (!bucket) {
|
|
244
|
+
bucket = new Map();
|
|
245
|
+
runtime.idempotencyKeyCache.set(resolvedRoot, bucket);
|
|
246
|
+
}
|
|
247
|
+
bucket.set(key, {
|
|
248
|
+
runId,
|
|
249
|
+
expiresAt: Date.now() + IDEMPOTENCY_TTL_MS,
|
|
250
|
+
});
|
|
251
|
+
if (totalIdempotencyEntries(runtime) > IDEMPOTENCY_PRUNE_THRESHOLD) {
|
|
252
|
+
pruneIdempotencyKeyCache(runtime);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/** Total cached idempotency entries across all projects. */
|
|
256
|
+
function totalIdempotencyEntries(runtime) {
|
|
257
|
+
let total = 0;
|
|
258
|
+
for (const bucket of runtime.idempotencyKeyCache.values())
|
|
259
|
+
total += bucket.size;
|
|
260
|
+
return total;
|
|
261
|
+
}
|
|
262
|
+
function pruneIdempotencyKeyCache(runtime) {
|
|
263
|
+
const now = Date.now();
|
|
264
|
+
for (const [projectDataDir, bucket] of runtime.idempotencyKeyCache) {
|
|
265
|
+
for (const [key, entry] of bucket) {
|
|
266
|
+
if (entry.expiresAt <= now)
|
|
267
|
+
bucket.delete(key);
|
|
268
|
+
}
|
|
269
|
+
if (bucket.size === 0)
|
|
270
|
+
runtime.idempotencyKeyCache.delete(projectDataDir);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Test seam: force the cached entry for `key` in `projectDataDir` to be
|
|
275
|
+
* expired so the next lookup returns null. Returns true when an entry was
|
|
276
|
+
* found and expired. Tests use this in place of fake timers because the
|
|
277
|
+
* idempotency TTL is one hour and faking `Date.now()` would destabilize
|
|
278
|
+
* unrelated runtime state.
|
|
279
|
+
*/
|
|
280
|
+
export function expireIdempotencyKeyForTesting(runtime, projectDataDir, key) {
|
|
281
|
+
const bucket = runtime.idempotencyKeyCache.get(resolve(projectDataDir));
|
|
282
|
+
if (!bucket)
|
|
283
|
+
return false;
|
|
284
|
+
const entry = bucket.get(key);
|
|
285
|
+
if (!entry)
|
|
286
|
+
return false;
|
|
287
|
+
entry.expiresAt = Date.now() - 1;
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
async function runBuildInBackground(runtime, projectDataDir, request, context) {
|
|
291
|
+
runtime.beginActiveRun();
|
|
292
|
+
try {
|
|
293
|
+
if (!runtime.handlers.createBuildRun) {
|
|
294
|
+
throw new Error("No build-run handler is configured for this local service.");
|
|
295
|
+
}
|
|
296
|
+
const result = LocalRunHandlerResultSchema.parse(await runtime.handlers.createBuildRun(request, context));
|
|
297
|
+
const wasCancelled = runtime.activeBuildRuns.get(context.runId)?.cancelled === true;
|
|
298
|
+
if (wasCancelled) {
|
|
299
|
+
// The run was cancelled while the handler was still running. The
|
|
300
|
+
// cancellation path already wrote a `cancelled` record; just refresh
|
|
301
|
+
// observability and skip emitting a second terminal event.
|
|
302
|
+
refreshBuildRunFromRuntime(runtime, projectDataDir, context.contextGraphPath, context.runId);
|
|
303
|
+
await emitRuntimeDerivedEvents(runtime, projectDataDir, context.contextGraphPath, context.runId);
|
|
304
|
+
await recordBuildRunEvent(runtime, projectDataDir, context.contextGraphPath, context.runId, readinessUpdatedEvent(context.runId, context.projectConfig.name, runtime.computeProjectReadiness(projectDataDir, context.projectConfig)));
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
refreshBuildRunFromRuntime(runtime, projectDataDir, context.contextGraphPath, context.runId);
|
|
308
|
+
await emitRuntimeDerivedEvents(runtime, projectDataDir, context.contextGraphPath, context.runId);
|
|
309
|
+
let readinessProjectConfig = context.projectConfig;
|
|
310
|
+
if (!result.ok) {
|
|
311
|
+
await recordBuildRunEvent(runtime, projectDataDir, context.contextGraphPath, context.runId, {
|
|
312
|
+
type: "run.failed",
|
|
313
|
+
event_id: createRunEventId("event"),
|
|
314
|
+
run_id: context.runId,
|
|
315
|
+
timestamp: createRunEventTimestamp(),
|
|
316
|
+
error: result.error ?? "Build failed.",
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
await recordBuildRunEvent(runtime, projectDataDir, context.contextGraphPath, context.runId, {
|
|
321
|
+
type: "run.completed",
|
|
322
|
+
event_id: createRunEventId("event"),
|
|
323
|
+
run_id: context.runId,
|
|
324
|
+
timestamp: createRunEventTimestamp(),
|
|
325
|
+
summary: "Context Graph ready.",
|
|
326
|
+
});
|
|
327
|
+
readinessProjectConfig = markProjectLatestContextGraphRun(projectDataDir, context.projectConfig.name, context.runId);
|
|
328
|
+
runtime.readinessCache.invalidateProject(projectDataDir, context.projectConfig.name);
|
|
329
|
+
}
|
|
330
|
+
await recordBuildRunEvent(runtime, projectDataDir, context.contextGraphPath, context.runId, readinessUpdatedEvent(context.runId, context.projectConfig.name, runtime.computeProjectReadiness(projectDataDir, readinessProjectConfig)));
|
|
331
|
+
emitBillingEventsForRun(projectDataDir, context, runtime);
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
await recordBuildRunEvent(runtime, projectDataDir, context.contextGraphPath, context.runId, {
|
|
335
|
+
type: "run.failed",
|
|
336
|
+
event_id: createRunEventId("event"),
|
|
337
|
+
run_id: context.runId,
|
|
338
|
+
timestamp: createRunEventTimestamp(),
|
|
339
|
+
error: error instanceof Error ? error.message : String(error),
|
|
340
|
+
});
|
|
341
|
+
await recordBuildRunEvent(runtime, projectDataDir, context.contextGraphPath, context.runId, readinessUpdatedEvent(context.runId, context.projectConfig.name, runtime.computeProjectReadiness(projectDataDir, context.projectConfig)));
|
|
342
|
+
}
|
|
343
|
+
finally {
|
|
344
|
+
runtime.activeBuildRuns.delete(context.runId);
|
|
345
|
+
runtime.endActiveRun();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
export function readBuildRun(projectDataDir, runId) {
|
|
349
|
+
return readBuildRunAt(projectBuildRunPath(projectDataDir, runId));
|
|
350
|
+
}
|
|
351
|
+
export function finalizeInterruptedBuildRuns(runtime, projectDataDir) {
|
|
352
|
+
let projects;
|
|
353
|
+
try {
|
|
354
|
+
projects = listProjectConfigs(loadSourceFolderConfig(projectDataDir));
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
for (const project of projects) {
|
|
360
|
+
for (const run of readBuildRunRecordsForProject(projectDataDir, project.name)) {
|
|
361
|
+
if (isTerminalStatus(run.status) || runtime.activeBuildRuns.has(run.run_id))
|
|
362
|
+
continue;
|
|
363
|
+
const timestamp = createRunEventTimestamp();
|
|
364
|
+
const interruptedRun = {
|
|
365
|
+
...run,
|
|
366
|
+
stages: run.stages.map((stage) => {
|
|
367
|
+
if (stage.status !== "running")
|
|
368
|
+
return stage;
|
|
369
|
+
return {
|
|
370
|
+
...stage,
|
|
371
|
+
status: "failed",
|
|
372
|
+
finished_at: stage.finished_at ?? timestamp,
|
|
373
|
+
summary: stage.summary ?? INTERRUPTED_BUILD_RUN_REASON,
|
|
374
|
+
failure: stage.failure ?? INTERRUPTED_BUILD_RUN_REASON,
|
|
375
|
+
};
|
|
376
|
+
}),
|
|
377
|
+
};
|
|
378
|
+
writeBuildRun(runtime, projectDataDir, applyEventToBuildRun(interruptedRun, {
|
|
379
|
+
type: "run.cancelled",
|
|
380
|
+
event_id: createRunEventId("event"),
|
|
381
|
+
run_id: run.run_id,
|
|
382
|
+
timestamp,
|
|
383
|
+
reason: INTERRUPTED_BUILD_RUN_REASON,
|
|
384
|
+
}));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Emit per-Artifact billing events when a Build run reaches a terminal
|
|
390
|
+
* state. Writes a JSONL file under hidden context-graph runtime
|
|
391
|
+
* metadata. The JSONL output is an observability/dev fixture, NOT
|
|
392
|
+
* production billing data.
|
|
393
|
+
*/
|
|
394
|
+
function emitBillingEventsForRun(projectDataDir, context, runtime) {
|
|
395
|
+
try {
|
|
396
|
+
const run = readBuildRun(projectDataDir, context.runId);
|
|
397
|
+
if (!run || run.artifacts.length === 0)
|
|
398
|
+
return;
|
|
399
|
+
const sink = new JsonlBillingEventSink(defaultBillingEventLogPath({
|
|
400
|
+
projectDataDir: projectDataDir,
|
|
401
|
+
projectName: run.project,
|
|
402
|
+
runId: context.runId,
|
|
403
|
+
}));
|
|
404
|
+
const events = buildBillingEventsForRun({
|
|
405
|
+
runId: context.runId,
|
|
406
|
+
project: run.project,
|
|
407
|
+
buildPlanId: run.build_plan,
|
|
408
|
+
accountId: runtime?.currentAccount?.user_id ?? null,
|
|
409
|
+
artifacts: run.artifacts,
|
|
410
|
+
startedAt: run.started_at ?? null,
|
|
411
|
+
finishedAt: run.finished_at ?? null,
|
|
412
|
+
});
|
|
413
|
+
for (const event of events) {
|
|
414
|
+
sink.emit(event);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
// Billing is observability-only locally; never let sink failures
|
|
419
|
+
// block a successful build.
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
export function writeBuildRun(runtime, projectDataDir, run) {
|
|
423
|
+
mkdirSync(projectBuildRunsRoot(projectDataDir), { recursive: true });
|
|
424
|
+
writeJsonFile(projectBuildRunPath(projectDataDir, run.run_id), BuildRunSchema.parse(run));
|
|
425
|
+
// Bust per-Project list + readiness caches so the next read
|
|
426
|
+
// reflects the write. We invalidate broadly (per-Project, not
|
|
427
|
+
// per-record) because list recompute cost is bounded by run count
|
|
428
|
+
// and the simpler model avoids fan-out bugs.
|
|
429
|
+
runtime.buildRunCache.invalidateProject(projectDataDir, run.project);
|
|
430
|
+
runtime.readinessCache.invalidateProject(projectDataDir, run.project);
|
|
431
|
+
// The Context Graph resource embeds the joined readiness verdict, so bust it
|
|
432
|
+
// whenever a Build run is written (build completion, refresh, cancel).
|
|
433
|
+
runtime.contextGraphResourceCache.invalidateProject(projectDataDir);
|
|
434
|
+
}
|
|
435
|
+
async function recordBuildRunEvent(runtime, projectDataDir, contextGraphPath, runId, event) {
|
|
436
|
+
const current = readBuildRun(projectDataDir, runId);
|
|
437
|
+
if (!current)
|
|
438
|
+
return;
|
|
439
|
+
writeBuildRun(runtime, projectDataDir, applyEventToBuildRun(current, event));
|
|
440
|
+
if (event.type === "stage.passed" || event.type === "stage.failed") {
|
|
441
|
+
refreshBuildRunFromRuntime(runtime, projectDataDir, contextGraphPath, runId);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
function refreshBuildRunFromRuntime(runtime, projectDataDir, contextGraphPath, runId) {
|
|
445
|
+
const current = readBuildRun(projectDataDir, runId);
|
|
446
|
+
if (!current)
|
|
447
|
+
return;
|
|
448
|
+
const state = loadState(contextGraphPath);
|
|
449
|
+
if (!state?.stages)
|
|
450
|
+
return;
|
|
451
|
+
const historyByStage = new Map();
|
|
452
|
+
for (const run of readExecutionStageLedgerHistory(contextGraphPath)) {
|
|
453
|
+
if (run.target_name !== current.project)
|
|
454
|
+
continue;
|
|
455
|
+
const existing = historyByStage.get(run.stage);
|
|
456
|
+
if (!existing || timestampKey(run.updated_at) >= timestampKey(existing.updated_at)) {
|
|
457
|
+
historyByStage.set(run.stage, run);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
const next = {
|
|
461
|
+
...current,
|
|
462
|
+
stages: current.stages.map((stage) => {
|
|
463
|
+
const stageState = state.stages?.[stage.stage_id];
|
|
464
|
+
if (!stageState)
|
|
465
|
+
return stage;
|
|
466
|
+
const runtimeRun = historyByStage.get(stage.stage_id);
|
|
467
|
+
const artifacts = uniqueArtifacts([
|
|
468
|
+
...(stage.artifacts ?? []),
|
|
469
|
+
...stageArtifactRefs(stage.stage_id, stageState.artifacts),
|
|
470
|
+
]);
|
|
471
|
+
const evidence = stage.latest_evidence ?? (stageState.status === "succeeded"
|
|
472
|
+
? evidenceForStage({
|
|
473
|
+
runId,
|
|
474
|
+
stageId: stage.stage_id,
|
|
475
|
+
summary: stageState.summary,
|
|
476
|
+
stageState,
|
|
477
|
+
artifacts,
|
|
478
|
+
})
|
|
479
|
+
: null);
|
|
480
|
+
return {
|
|
481
|
+
...stage,
|
|
482
|
+
started_at: stage.started_at ?? stageState.started_at,
|
|
483
|
+
finished_at: stage.finished_at ?? stageState.finished_at,
|
|
484
|
+
summary: stage.summary ?? stageState.summary ?? null,
|
|
485
|
+
executor: stage.executor ?? runtimeRun?.executor ?? null,
|
|
486
|
+
artifacts,
|
|
487
|
+
logs: stage.logs ?? logsForExecutionStageLedger(runtimeRun) ?? logsForStageRun(stageState),
|
|
488
|
+
latest_evidence: evidence,
|
|
489
|
+
};
|
|
490
|
+
}),
|
|
491
|
+
};
|
|
492
|
+
next.latest_evidence = [...next.stages].reverse().find((stage) => Boolean(stage.latest_evidence))?.latest_evidence ?? next.latest_evidence;
|
|
493
|
+
// Recompute per-Artifact status whenever the Build run is
|
|
494
|
+
// refreshed from runtime state.
|
|
495
|
+
try {
|
|
496
|
+
const buildPlan = getBuildPlan(current.build_plan, { projectDataDir });
|
|
497
|
+
next.artifacts = computeArtifactStatuses({
|
|
498
|
+
buildPlan,
|
|
499
|
+
contextGraphPath,
|
|
500
|
+
stageRuns: next.stages,
|
|
501
|
+
counts: countsFromContextGraphState(state, contextGraphPath),
|
|
502
|
+
});
|
|
503
|
+
next.context_checks = projectContextChecksForRun({
|
|
504
|
+
contextChecks: buildPlanContextChecks({
|
|
505
|
+
brief: buildPlan.brief ?? null,
|
|
506
|
+
artifacts: buildPlan.contextInterface?.artifacts ?? [],
|
|
507
|
+
}),
|
|
508
|
+
artifactStatuses: next.artifacts,
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
catch {
|
|
512
|
+
next.artifacts = current.artifacts ?? [];
|
|
513
|
+
next.context_checks = current.context_checks ?? [];
|
|
514
|
+
}
|
|
515
|
+
writeBuildRun(runtime, projectDataDir, reconcileBuildRunTerminalStatus(next));
|
|
516
|
+
}
|
|
517
|
+
async function emitRuntimeDerivedEvents(runtime, projectDataDir, contextGraphPath, runId) {
|
|
518
|
+
const state = loadState(contextGraphPath);
|
|
519
|
+
const run = readBuildRun(projectDataDir, runId);
|
|
520
|
+
if (!state?.stages || !run)
|
|
521
|
+
return;
|
|
522
|
+
for (const stage of run.stages) {
|
|
523
|
+
const stageState = state.stages[stage.stage_id];
|
|
524
|
+
if (!stageState)
|
|
525
|
+
continue;
|
|
526
|
+
const artifacts = stageArtifactRefs(stage.stage_id, stageState.artifacts);
|
|
527
|
+
const eventTimestamp = stage.finished_at ?? stageState.finished_at ?? createRunEventTimestamp();
|
|
528
|
+
for (const artifact of artifacts) {
|
|
529
|
+
await recordBuildRunEvent(runtime, projectDataDir, contextGraphPath, runId, {
|
|
530
|
+
type: "artifact.written",
|
|
531
|
+
event_id: createRunEventId("event"),
|
|
532
|
+
run_id: runId,
|
|
533
|
+
timestamp: eventTimestamp,
|
|
534
|
+
stage_id: stage.stage_id,
|
|
535
|
+
artifact,
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
if (stageState.status === "succeeded") {
|
|
539
|
+
await recordBuildRunEvent(runtime, projectDataDir, contextGraphPath, runId, {
|
|
540
|
+
type: "evidence.updated",
|
|
541
|
+
event_id: createRunEventId("event"),
|
|
542
|
+
run_id: runId,
|
|
543
|
+
timestamp: eventTimestamp,
|
|
544
|
+
stage_id: stage.stage_id,
|
|
545
|
+
evidence: evidenceForStage({
|
|
546
|
+
runId,
|
|
547
|
+
stageId: stage.stage_id,
|
|
548
|
+
summary: stageState.summary,
|
|
549
|
+
stageState,
|
|
550
|
+
artifacts,
|
|
551
|
+
}),
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime read-side caches.
|
|
3
|
+
*
|
|
4
|
+
* The local service runtime fronts a filesystem-backed model: every
|
|
5
|
+
* "list" or "get" call walks `.interf/runtime/...`, parses each JSON
|
|
6
|
+
* record through Zod, and returns the typed shape. Polling clients
|
|
7
|
+
* (Interf Desktop renderer, CLI status loops) hit those endpoints multiple times
|
|
8
|
+
* per second; on instances with hundreds of Build / benchmark runs this
|
|
9
|
+
* shows up as the dominant CPU cost.
|
|
10
|
+
*
|
|
11
|
+
* The caches here memoize the parsed-and-validated results. Each cache
|
|
12
|
+
* is keyed by Project data directory so independent Projects do
|
|
13
|
+
* not cross-pollinate, and each cache exposes both a read path (`get(...)`) and an explicit
|
|
14
|
+
* invalidation hook (`invalidate(...)`). The runtime calls
|
|
15
|
+
* `invalidate*` whenever it writes, so the next read repopulates from
|
|
16
|
+
* disk. Invalidation is intentionally broad (per-Project, not
|
|
17
|
+
* per-record) — staleness is the only correctness bug worth avoiding,
|
|
18
|
+
* and per-record invalidation introduces fan-out without measurably
|
|
19
|
+
* lowering recompute cost.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Per-(Project data directory, project) cache for Build records, plus a
|
|
23
|
+
* runId -> project index so `getBuildRun(runId)` can resolve to
|
|
24
|
+
* the owning Project without scanning every Project's runs.
|
|
25
|
+
*/
|
|
26
|
+
export declare class RunListingCache<TRecord> {
|
|
27
|
+
/** projectDataDir -> project id -> records (newest-first sorted). */
|
|
28
|
+
private byProjectRoot;
|
|
29
|
+
/** projectDataDir -> runId -> project. */
|
|
30
|
+
private runIndex;
|
|
31
|
+
get(projectDataDir: string, project: string, fill: () => TRecord[], runIdOf: (record: TRecord) => string): TRecord[];
|
|
32
|
+
/** Look up which project owns this runId, if known. */
|
|
33
|
+
projectFor(projectDataDir: string, runId: string): string | null;
|
|
34
|
+
/** Invalidate a single project's cached records and id index. */
|
|
35
|
+
invalidateProject(projectDataDir: string, project: string): void;
|
|
36
|
+
/** Drop everything for a Project data directory (e.g. after a reset). */
|
|
37
|
+
invalidateProjectRoot(projectDataDir: string): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Per-(Project data directory, project) readiness cache. Readiness joins build
|
|
41
|
+
* runs, benchmark runs, and the Project config; it
|
|
42
|
+
* is computed on every poll. The cache invalidates when the runtime
|
|
43
|
+
* writes any of those underlying objects for a given project.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ReadinessCache<TReadiness> {
|
|
46
|
+
private byProjectRoot;
|
|
47
|
+
get(projectDataDir: string, project: string, compute: () => TReadiness): TReadiness;
|
|
48
|
+
invalidateProject(projectDataDir: string, project: string): void;
|
|
49
|
+
invalidateProjectRoot(projectDataDir: string): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Source-folder listing cache keyed by `(cacheKey, folderRootMtime)`.
|
|
53
|
+
* `cacheKey` is the slot identifier; `folderPath` is the directory the
|
|
54
|
+
* cache stats for an mtime probe. UI polling is the hot path; CLI
|
|
55
|
+
* commands rarely hit the same path twice in <2s, hence the short TTL
|
|
56
|
+
* fallback.
|
|
57
|
+
*/
|
|
58
|
+
export declare class MtimeListingCache<TList> {
|
|
59
|
+
private static readonly TTL_MS;
|
|
60
|
+
private cache;
|
|
61
|
+
get(cacheKey: string, folderPath: string, fill: () => TList): TList;
|
|
62
|
+
invalidate(cacheKey: string): void;
|
|
63
|
+
invalidateAll(): void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build Plan listing cache keyed by the joined mtimes of the
|
|
67
|
+
* bundled / user-library / Project-local Build Plan package roots. If
|
|
68
|
+
* any of those ticks (a new local Build Plan package, an edit to the user library, etc.) the cache
|
|
69
|
+
* misses and we re-resolve.
|
|
70
|
+
*/
|
|
71
|
+
export declare class BuildPlanListingCache<TList> {
|
|
72
|
+
private cache;
|
|
73
|
+
get(cacheKey: string, rootPaths: string[], fill: () => TList): TList;
|
|
74
|
+
invalidate(cacheKey: string): void;
|
|
75
|
+
invalidateAll(): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Per-Project source-state cache.
|
|
79
|
+
*
|
|
80
|
+
* Computing the file index hash requires reading every source file's first
|
|
81
|
+
* 64KB; on Projects with thousands of files this is the dominant cost of a
|
|
82
|
+
* drift check. The cache keys by Project id and invalidates on Build
|
|
83
|
+
* completion (which produces a new Context Graph the drift verdict compares to).
|
|
84
|
+
*/
|
|
85
|
+
export declare class ProjectSourceStateCache<TState> {
|
|
86
|
+
private byProjectId;
|
|
87
|
+
get(projectId: string, compute: () => TState): TState;
|
|
88
|
+
set(projectId: string, value: TState): void;
|
|
89
|
+
invalidateProject(projectId: string): void;
|
|
90
|
+
invalidateAll(): void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Per-Build-run Context Graph resource cache.
|
|
94
|
+
*
|
|
95
|
+
* A succeeded Build's Context Graph is immutable: its on-disk folder
|
|
96
|
+
* (`graph-manifest.json`, source manifest, stage sessions, semantic graph) is
|
|
97
|
+
* frozen once the run reaches `succeeded`. Rebuilding the full
|
|
98
|
+
* `ContextGraphResource` — readiness join, semantic graph, build evidence,
|
|
99
|
+
* validation — on every read is the dominant cost of opening a built Project.
|
|
100
|
+
*
|
|
101
|
+
* The cache keys by `(projectDataDir, runId, manifestMtimeMs)`:
|
|
102
|
+
* - `runId` scopes a single Build's output.
|
|
103
|
+
* - `manifestMtimeMs` is the mtime of the Build's
|
|
104
|
+
* `.interf/runtime/graph-manifest.json`. It busts the entry if the graph is
|
|
105
|
+
* rebuilt or edited in place; a fresh Build produces a fresh `runId`, so
|
|
106
|
+
* those never collide either.
|
|
107
|
+
*
|
|
108
|
+
* Entries without a readable manifest mtime (mtime 0) are not cached — that
|
|
109
|
+
* only happens for an in-flight or malformed Build, where the resource is
|
|
110
|
+
* still changing and must be recomputed.
|
|
111
|
+
*/
|
|
112
|
+
export declare class ContextGraphResourceCache<TResource> {
|
|
113
|
+
private byKey;
|
|
114
|
+
get(projectDataDir: string, runId: string, manifestPath: string, compute: () => TResource): TResource;
|
|
115
|
+
invalidateProject(projectDataDir: string): void;
|
|
116
|
+
invalidateAll(): void;
|
|
117
|
+
}
|