@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,11 @@
|
|
|
1
|
+
import type { BuildStageExecutionDefinition } from "./build-target.js";
|
|
2
|
+
export declare function computeStageFingerprint(contextGraphPath: string, stageDefinition: BuildStageExecutionDefinition): string | null;
|
|
3
|
+
export interface StageReuseDecision {
|
|
4
|
+
reuse: boolean;
|
|
5
|
+
fingerprint: string | null;
|
|
6
|
+
summary: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function stageReuseDecision(options: {
|
|
9
|
+
contextGraphPath: string;
|
|
10
|
+
stageDefinition: BuildStageExecutionDefinition;
|
|
11
|
+
}): StageReuseDecision;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
import { buildPlanPackagePathForContextGraph, } from "./context-graph-paths.js";
|
|
5
|
+
import { buildBuildStageExecutionPlan } from "./build-stage-plan.js";
|
|
6
|
+
import { loadState } from "./state.js";
|
|
7
|
+
import { loadBuildStageInputs, loadContextGraphSourceManifest } from "./source-manifest.js";
|
|
8
|
+
import { validateBuildStage } from "./validate.js";
|
|
9
|
+
import { StageFingerprintSchema } from "./lib/schema.js";
|
|
10
|
+
import { listFilesRecursive } from "../../contracts/utils/filesystem.js";
|
|
11
|
+
import { readExecutionStageLedgerHistory } from "../runtime-persistence.js";
|
|
12
|
+
import { stageEvidenceAcceptanceFailure, supportsStageEvidenceHarness, } from "./stage-evidence.js";
|
|
13
|
+
function stableValue(value) {
|
|
14
|
+
if (Array.isArray(value))
|
|
15
|
+
return value.map(stableValue);
|
|
16
|
+
if (!value || typeof value !== "object")
|
|
17
|
+
return value;
|
|
18
|
+
return Object.fromEntries(Object.entries(value)
|
|
19
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
20
|
+
.map(([key, entry]) => [key, stableValue(entry)]));
|
|
21
|
+
}
|
|
22
|
+
function stableJson(value) {
|
|
23
|
+
return JSON.stringify(stableValue(value));
|
|
24
|
+
}
|
|
25
|
+
function sha256(value) {
|
|
26
|
+
return createHash("sha256").update(value).digest("hex");
|
|
27
|
+
}
|
|
28
|
+
function fileHash(path) {
|
|
29
|
+
if (!existsSync(path))
|
|
30
|
+
return null;
|
|
31
|
+
return sha256(readFileSync(path));
|
|
32
|
+
}
|
|
33
|
+
function latestStageRun(runs, runId, stageId) {
|
|
34
|
+
if (!runId)
|
|
35
|
+
return null;
|
|
36
|
+
return runs
|
|
37
|
+
.filter((run) => run.run_id === runId && run.stage === stageId)
|
|
38
|
+
.sort((left, right) => left.updated_at.localeCompare(right.updated_at))
|
|
39
|
+
.at(-1) ?? null;
|
|
40
|
+
}
|
|
41
|
+
function buildPlanPackageHash(contextGraphPath) {
|
|
42
|
+
const root = buildPlanPackagePathForContextGraph(contextGraphPath);
|
|
43
|
+
const files = listFilesRecursive(root)
|
|
44
|
+
.map((path) => ({
|
|
45
|
+
path,
|
|
46
|
+
relativePath: relative(root, path).replaceAll("\\", "/"),
|
|
47
|
+
}))
|
|
48
|
+
.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
|
|
49
|
+
return sha256(stableJson(files.map((file) => ({
|
|
50
|
+
path: file.relativePath,
|
|
51
|
+
hash: fileHash(file.path),
|
|
52
|
+
}))));
|
|
53
|
+
}
|
|
54
|
+
function stageFingerprintProjectIntent(stageDefinition, projectIntent) {
|
|
55
|
+
if (stageDefinition.contractType === "build-file-evidence")
|
|
56
|
+
return null;
|
|
57
|
+
return projectIntent;
|
|
58
|
+
}
|
|
59
|
+
export function computeStageFingerprint(contextGraphPath, stageDefinition) {
|
|
60
|
+
const stageInputs = loadBuildStageInputs(contextGraphPath, stageDefinition.id);
|
|
61
|
+
if (!stageInputs)
|
|
62
|
+
return null;
|
|
63
|
+
if (stageInputs.version !== 3 || !stageInputs.source_manifest_id)
|
|
64
|
+
return null;
|
|
65
|
+
const sourceManifest = loadContextGraphSourceManifest(contextGraphPath);
|
|
66
|
+
if (!sourceManifest || sourceManifest.manifest_id !== stageInputs.source_manifest_id)
|
|
67
|
+
return null;
|
|
68
|
+
const plan = buildBuildStageExecutionPlan(contextGraphPath, stageDefinition);
|
|
69
|
+
const stageSkillPath = join(buildPlanPackagePathForContextGraph(contextGraphPath), "build", "stages", stageDefinition.skillDir, "SKILL.md");
|
|
70
|
+
const payload = {
|
|
71
|
+
build_plan: {
|
|
72
|
+
id: plan.context.buildPlanId,
|
|
73
|
+
package_hash: buildPlanPackageHash(contextGraphPath),
|
|
74
|
+
},
|
|
75
|
+
project: {
|
|
76
|
+
id: plan.context.project.id,
|
|
77
|
+
intent: stageFingerprintProjectIntent(stageDefinition, plan.context.projectIntent),
|
|
78
|
+
},
|
|
79
|
+
source_manifest: {
|
|
80
|
+
manifest_id: sourceManifest.manifest_id,
|
|
81
|
+
generated_at: sourceManifest.generated_at,
|
|
82
|
+
source_total: sourceManifest.source_total,
|
|
83
|
+
},
|
|
84
|
+
source_slice: stageInputs.inputs
|
|
85
|
+
.map((input) => ({
|
|
86
|
+
source_file_id: input.source_file_id,
|
|
87
|
+
path: input.path,
|
|
88
|
+
locator: input.locator,
|
|
89
|
+
kind: input.kind,
|
|
90
|
+
size_bytes: input.size_bytes,
|
|
91
|
+
page_count: input.page_count,
|
|
92
|
+
inspectable_units: input.inspectable_units,
|
|
93
|
+
content_hash: input.content_hash,
|
|
94
|
+
}))
|
|
95
|
+
.sort((left, right) => `${left.source_file_id}:${left.path}`.localeCompare(`${right.source_file_id}:${right.path}`)),
|
|
96
|
+
stage: {
|
|
97
|
+
id: stageDefinition.id,
|
|
98
|
+
skill_dir: stageDefinition.skillDir,
|
|
99
|
+
skill_hash: fileHash(stageSkillPath),
|
|
100
|
+
},
|
|
101
|
+
contract: {
|
|
102
|
+
stage: stageDefinition.id,
|
|
103
|
+
contract_type: stageDefinition.contractType,
|
|
104
|
+
counts: plan.contract.counts,
|
|
105
|
+
artifacts: {
|
|
106
|
+
reads: [...plan.contract.artifacts.reads].sort((left, right) => left.localeCompare(right)),
|
|
107
|
+
writes: [...plan.contract.artifacts.writes].sort((left, right) => left.localeCompare(right)),
|
|
108
|
+
write_contracts: [...plan.contract.artifacts.write_contracts]
|
|
109
|
+
.map((contract) => ({
|
|
110
|
+
artifact_id: contract.artifact_id,
|
|
111
|
+
path: contract.path,
|
|
112
|
+
checks: contract.checks,
|
|
113
|
+
}))
|
|
114
|
+
.sort((left, right) => `${left.artifact_id}:${left.path}`.localeCompare(`${right.artifact_id}:${right.path}`)),
|
|
115
|
+
},
|
|
116
|
+
context_checks: stageDefinition.contractType === "build-file-evidence"
|
|
117
|
+
? []
|
|
118
|
+
: [...plan.contract.context_checks],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
return StageFingerprintSchema.parse(sha256(stableJson(payload)));
|
|
122
|
+
}
|
|
123
|
+
export function stageReuseDecision(options) {
|
|
124
|
+
const fingerprint = computeStageFingerprint(options.contextGraphPath, options.stageDefinition);
|
|
125
|
+
if (!fingerprint) {
|
|
126
|
+
return { reuse: false, fingerprint, summary: "missing stage fingerprint input" };
|
|
127
|
+
}
|
|
128
|
+
const state = loadState(options.contextGraphPath);
|
|
129
|
+
const record = state?.stages?.[options.stageDefinition.id];
|
|
130
|
+
if (!record || record.status !== "succeeded") {
|
|
131
|
+
return { reuse: false, fingerprint, summary: "stage has not succeeded yet" };
|
|
132
|
+
}
|
|
133
|
+
if (record.fingerprint !== fingerprint) {
|
|
134
|
+
return { reuse: false, fingerprint, summary: "stage fingerprint changed" };
|
|
135
|
+
}
|
|
136
|
+
if (supportsStageEvidenceHarness(options.stageDefinition)) {
|
|
137
|
+
const acceptedEvidenceRun = latestStageRun(readExecutionStageLedgerHistory(options.contextGraphPath), record.run_id, options.stageDefinition.id);
|
|
138
|
+
if (acceptedEvidenceRun?.status !== "succeeded") {
|
|
139
|
+
return { reuse: false, fingerprint, summary: "stage evidence run has not succeeded" };
|
|
140
|
+
}
|
|
141
|
+
const evidenceFailure = stageEvidenceAcceptanceFailure(acceptedEvidenceRun?.evidence ?? null);
|
|
142
|
+
if (evidenceFailure) {
|
|
143
|
+
return { reuse: false, fingerprint, summary: evidenceFailure };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const validation = validateBuildStage(options.contextGraphPath, options.stageDefinition.id);
|
|
147
|
+
if (!validation.required) {
|
|
148
|
+
return { reuse: false, fingerprint, summary: "stage is not required yet" };
|
|
149
|
+
}
|
|
150
|
+
if (!validation.ok) {
|
|
151
|
+
return { reuse: false, fingerprint, summary: validation.summary };
|
|
152
|
+
}
|
|
153
|
+
return { reuse: true, fingerprint, summary: "reused (verified, unchanged)" };
|
|
154
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type AgentExecutor } from "../agents/lib/executors.js";
|
|
2
|
+
import { type ExecutionStageLedger, type RuntimeStageContract, type StageExecutionSession } from "./lib/schema.js";
|
|
3
|
+
import type { AgentJobType } from "./lib/schema.js";
|
|
4
|
+
import type { BuildPlanId, ProjectId, RuntimeContractType, RuntimeExecutorInfo, RuntimeStage } from "../../contracts/lib/schema.js";
|
|
5
|
+
export declare function writeStageExecutionSessionStarted(options: {
|
|
6
|
+
contextGraphPath: string;
|
|
7
|
+
jobType?: AgentJobType;
|
|
8
|
+
project: ProjectId;
|
|
9
|
+
projectIntent?: string | null;
|
|
10
|
+
buildPlanId: BuildPlanId;
|
|
11
|
+
buildRunId?: string | null;
|
|
12
|
+
stageId: RuntimeStage | null;
|
|
13
|
+
stageLabel: string | null;
|
|
14
|
+
contractType: RuntimeContractType | null;
|
|
15
|
+
stageRunId: string;
|
|
16
|
+
attempt?: number;
|
|
17
|
+
executor: RuntimeExecutorInfo | AgentExecutor;
|
|
18
|
+
shellRoot: string | null;
|
|
19
|
+
contractPath: string | null;
|
|
20
|
+
promptPath: string | null;
|
|
21
|
+
eventStreamPath: string | null;
|
|
22
|
+
statusPath: string | null;
|
|
23
|
+
summary: string | null;
|
|
24
|
+
}): StageExecutionSession;
|
|
25
|
+
export declare function writeStageExecutionSessionStartedFromLedger(options: {
|
|
26
|
+
contextGraphPath: string;
|
|
27
|
+
run: ExecutionStageLedger;
|
|
28
|
+
contract: RuntimeStageContract;
|
|
29
|
+
buildRunId?: string | null;
|
|
30
|
+
shellRoot: string | null;
|
|
31
|
+
promptPath: string | null;
|
|
32
|
+
eventStreamPath: string | null;
|
|
33
|
+
statusPath: string | null;
|
|
34
|
+
}): StageExecutionSession;
|
|
35
|
+
/**
|
|
36
|
+
* Project the terminal session state from a finished ExecutionStageLedger. The
|
|
37
|
+
* session is a projection of the ledger, so the ledger→session field mapping
|
|
38
|
+
* (stage, run id, terminal status, summary, error) lives HERE, once, instead of
|
|
39
|
+
* being re-stated by hand at every ledger-terminal write site. A `running`
|
|
40
|
+
* ledger is not terminal and is ignored (no-op) so callers can pass the record
|
|
41
|
+
* unconditionally. Returns null when no session exists for the run (same
|
|
42
|
+
* contract as `writeStageExecutionSessionFinished`).
|
|
43
|
+
*/
|
|
44
|
+
export declare function projectSessionFinishedFromLedger(contextGraphPath: string, ledger: ExecutionStageLedger): StageExecutionSession | null;
|
|
45
|
+
export declare function writeStageExecutionSessionFinished(options: {
|
|
46
|
+
contextGraphPath: string;
|
|
47
|
+
stageId: string | null;
|
|
48
|
+
stageRunId: string;
|
|
49
|
+
status: "succeeded" | "failed";
|
|
50
|
+
summary: string;
|
|
51
|
+
error?: string | null;
|
|
52
|
+
}): StageExecutionSession | null;
|
|
53
|
+
export declare function recordStageExecutionSessionValidationAttempt(options: {
|
|
54
|
+
contextGraphPath: string;
|
|
55
|
+
stageId: string;
|
|
56
|
+
stageRunId: string;
|
|
57
|
+
attempt: number;
|
|
58
|
+
status: "succeeded" | "failed";
|
|
59
|
+
summary: string;
|
|
60
|
+
}): StageExecutionSession | null;
|
|
61
|
+
export declare function markStageExecutionSessionsShellPreserved(options: {
|
|
62
|
+
contextGraphPath: string;
|
|
63
|
+
shellRoot: string;
|
|
64
|
+
}): void;
|
|
65
|
+
/**
|
|
66
|
+
* Reconcile sessions after their stage execution shells were pruned. The build
|
|
67
|
+
* pipeline deletes the whole execution-shells root on a successful build under
|
|
68
|
+
* non-"always" retention, but the session records live in a SEPARATE
|
|
69
|
+
* stage-sessions dir and would keep pointing at the deleted shell with
|
|
70
|
+
* `replay_ready: true` — a dangling pointer (F2). For every session whose shell
|
|
71
|
+
* root no longer exists on disk, downgrade it so "session exists" still implies
|
|
72
|
+
* "session is real": `replay_ready` false, preserved-shell manifest path
|
|
73
|
+
* nulled, and a retention reason recorded. Already-downgraded sessions and
|
|
74
|
+
* sessions whose shell still exists are left untouched. Best-effort and
|
|
75
|
+
* idempotent; runs in the build's `finally`, so it must never throw.
|
|
76
|
+
*/
|
|
77
|
+
export declare function reconcilePrunedStageExecutionSessions(options: {
|
|
78
|
+
contextGraphPath: string;
|
|
79
|
+
reason?: string;
|
|
80
|
+
}): void;
|
|
81
|
+
export declare function listStageExecutionSessions(contextGraphPath: string): StageExecutionSession[];
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, } from "node:fs";
|
|
2
|
+
import { isAbsolute, join, relative, } from "node:path";
|
|
3
|
+
import { preservedShellManifestPath, shellWorkspaceManifestPath, } from "../agents/lib/shell-paths.js";
|
|
4
|
+
import { buildRuntimeExecutorInfo, } from "../agents/lib/executors.js";
|
|
5
|
+
import { contextGraphRuntimeStageSessionPath, contextGraphRuntimeStageSessionsRoot, } from "./context-graph-paths.js";
|
|
6
|
+
import { writeJsonAtomic } from "./atomic-fs.js";
|
|
7
|
+
import { ExecutionShellPathsSchema, StageExecutionSessionSchema, } from "./lib/schema.js";
|
|
8
|
+
function contextRelative(contextGraphPath, path) {
|
|
9
|
+
if (!path)
|
|
10
|
+
return null;
|
|
11
|
+
const rel = isAbsolute(path) ? relative(contextGraphPath, path) : path;
|
|
12
|
+
return rel.replaceAll("\\", "/");
|
|
13
|
+
}
|
|
14
|
+
function shellRuntimeFile(contextGraphPath, shellRoot, fileName) {
|
|
15
|
+
if (!shellRoot)
|
|
16
|
+
return null;
|
|
17
|
+
return contextRelative(contextGraphPath, join(shellRoot, "runtime", fileName));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Context-relative path to a shell runtime file ONLY when it exists on disk.
|
|
21
|
+
* Used for artifacts that are written DURING the run (e.g. the agent reasoning
|
|
22
|
+
* transcript), so a session never advertises a dangling path: null at session
|
|
23
|
+
* start (the file does not exist yet, and a non-reasoning run never creates it),
|
|
24
|
+
* the real path once it has been teed. `shellRootRel` is the context-relative
|
|
25
|
+
* shell root (`.` for the no-shell case, which has no runtime dir to reference).
|
|
26
|
+
*/
|
|
27
|
+
function runtimeFileIfExists(contextGraphPath, shellRootRel, fileName) {
|
|
28
|
+
if (!shellRootRel || shellRootRel === ".")
|
|
29
|
+
return null;
|
|
30
|
+
const rel = `${shellRootRel.replace(/\/+$/, "")}/runtime/${fileName}`;
|
|
31
|
+
return existsSync(join(contextGraphPath, rel)) ? rel : null;
|
|
32
|
+
}
|
|
33
|
+
function readShellPaths(shellRoot) {
|
|
34
|
+
if (!shellRoot)
|
|
35
|
+
return null;
|
|
36
|
+
const filePath = join(shellRoot, "runtime", "paths.json");
|
|
37
|
+
if (!existsSync(filePath))
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
return ExecutionShellPathsSchema.parse(JSON.parse(readFileSync(filePath, "utf8")));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Stage jobs key the session dir off `stage_id`. Non-stage jobs (job_type !==
|
|
47
|
+
// "stage"/"source-inventory") carry a null stage_id, so they bucket under a
|
|
48
|
+
// stable "_job" segment keyed by stage_run_id. Stage layout is unchanged: every
|
|
49
|
+
// current writer passes a real stage id.
|
|
50
|
+
function stageSessionPath(contextGraphPath, stageId, stageRunId) {
|
|
51
|
+
return contextGraphRuntimeStageSessionPath(contextGraphPath, stageId ?? "_job", stageRunId);
|
|
52
|
+
}
|
|
53
|
+
function readSessionAt(path) {
|
|
54
|
+
if (!existsSync(path))
|
|
55
|
+
return null;
|
|
56
|
+
try {
|
|
57
|
+
return StageExecutionSessionSchema.parse(JSON.parse(readFileSync(path, "utf8")));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function readSession(contextGraphPath, stageId, stageRunId) {
|
|
64
|
+
return readSessionAt(stageSessionPath(contextGraphPath, stageId, stageRunId));
|
|
65
|
+
}
|
|
66
|
+
function writeSession(contextGraphPath, session) {
|
|
67
|
+
const parsed = StageExecutionSessionSchema.parse(session);
|
|
68
|
+
writeJsonAtomic(stageSessionPath(contextGraphPath, parsed.stage_id, parsed.stage_run_id), parsed);
|
|
69
|
+
return parsed;
|
|
70
|
+
}
|
|
71
|
+
function nextAttemptForStage(contextGraphPath, stageId) {
|
|
72
|
+
return listStageExecutionSessions(contextGraphPath)
|
|
73
|
+
.filter((session) => session.stage_id === stageId)
|
|
74
|
+
.length + 1;
|
|
75
|
+
}
|
|
76
|
+
export function writeStageExecutionSessionStarted(options) {
|
|
77
|
+
const now = new Date().toISOString();
|
|
78
|
+
const shellRoot = options.shellRoot;
|
|
79
|
+
const paths = readShellPaths(shellRoot);
|
|
80
|
+
const shellRootPath = contextRelative(options.contextGraphPath, shellRoot) ?? ".";
|
|
81
|
+
const workspacePath = shellRoot ? shellWorkspaceManifestPath(shellRoot) : null;
|
|
82
|
+
const preservedPath = shellRoot ? preservedShellManifestPath(shellRoot) : null;
|
|
83
|
+
const executor = "execute" in options.executor
|
|
84
|
+
? buildRuntimeExecutorInfo(options.executor)
|
|
85
|
+
: options.executor;
|
|
86
|
+
const existing = readSession(options.contextGraphPath, options.stageId, options.stageRunId);
|
|
87
|
+
return writeSession(options.contextGraphPath, {
|
|
88
|
+
kind: "interf-stage-execution-session",
|
|
89
|
+
version: 1,
|
|
90
|
+
job_type: existing?.job_type ?? options.jobType ?? "stage",
|
|
91
|
+
generated_at: existing?.generated_at ?? now,
|
|
92
|
+
updated_at: now,
|
|
93
|
+
project: options.project,
|
|
94
|
+
project_intent: options.projectIntent ?? null,
|
|
95
|
+
context_graph_path: options.contextGraphPath,
|
|
96
|
+
build_plan: options.buildPlanId,
|
|
97
|
+
build_run_id: options.buildRunId ?? null,
|
|
98
|
+
stage_id: options.stageId,
|
|
99
|
+
stage_label: options.stageLabel,
|
|
100
|
+
contract_type: options.contractType,
|
|
101
|
+
stage_run_id: options.stageRunId,
|
|
102
|
+
attempt: existing?.attempt ?? options.attempt ?? nextAttemptForStage(options.contextGraphPath, options.stageId),
|
|
103
|
+
status: existing?.status ?? "running",
|
|
104
|
+
executor,
|
|
105
|
+
shell: {
|
|
106
|
+
root_path: shellRootPath,
|
|
107
|
+
workspace_manifest_path: workspacePath && existsSync(workspacePath)
|
|
108
|
+
? contextRelative(options.contextGraphPath, workspacePath)
|
|
109
|
+
: null,
|
|
110
|
+
preserved_shell_manifest_path: preservedPath && existsSync(preservedPath)
|
|
111
|
+
? contextRelative(options.contextGraphPath, preservedPath)
|
|
112
|
+
: null,
|
|
113
|
+
replay_ready: Boolean(shellRoot && existsSync(join(shellRoot, "AGENTS.md"))),
|
|
114
|
+
retention_reason: existing?.shell.retention_reason ?? null,
|
|
115
|
+
},
|
|
116
|
+
logs: {
|
|
117
|
+
prompt_path: contextRelative(options.contextGraphPath, options.promptPath),
|
|
118
|
+
event_stream_path: contextRelative(options.contextGraphPath, options.eventStreamPath),
|
|
119
|
+
status_path: contextRelative(options.contextGraphPath, options.statusPath),
|
|
120
|
+
},
|
|
121
|
+
runtime_files: {
|
|
122
|
+
project_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "project.json"),
|
|
123
|
+
contract_path: contextRelative(options.contextGraphPath, options.contractPath),
|
|
124
|
+
paths_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "paths.json"),
|
|
125
|
+
source_locator_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "source-locator.json"),
|
|
126
|
+
source_manifest_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "source-manifest.json"),
|
|
127
|
+
source_state_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "source-state.json"),
|
|
128
|
+
stage_inputs_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "stage-inputs.json"),
|
|
129
|
+
expected_inputs_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "expected-inputs.json"),
|
|
130
|
+
reviewed_inputs_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "reviewed-inputs.json"),
|
|
131
|
+
previous_attempts_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "previous-attempts.json"),
|
|
132
|
+
retry_feedback_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "retry-feedback.md"),
|
|
133
|
+
last_validation_failure_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "last-validation-failure.txt"),
|
|
134
|
+
verifier_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "check-stage.mjs"),
|
|
135
|
+
stage_evidence_path: shellRuntimeFile(options.contextGraphPath, shellRoot, "stage-evidence.json"),
|
|
136
|
+
reasoning_path: existing?.runtime_files.reasoning_path
|
|
137
|
+
?? runtimeFileIfExists(options.contextGraphPath, shellRootPath, "agent-reasoning.jsonl"),
|
|
138
|
+
},
|
|
139
|
+
artifacts: {
|
|
140
|
+
reads: paths?.reads ?? [],
|
|
141
|
+
writes: paths?.writes ?? [],
|
|
142
|
+
},
|
|
143
|
+
validation_attempts: existing?.validation_attempts ?? [],
|
|
144
|
+
summary: options.summary,
|
|
145
|
+
error: existing?.error ?? null,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
export function writeStageExecutionSessionStartedFromLedger(options) {
|
|
149
|
+
return writeStageExecutionSessionStarted({
|
|
150
|
+
contextGraphPath: options.contextGraphPath,
|
|
151
|
+
project: options.contract.project.id,
|
|
152
|
+
projectIntent: options.contract.project.intent,
|
|
153
|
+
buildPlanId: options.contract.build_plan.id,
|
|
154
|
+
buildRunId: options.buildRunId ?? null,
|
|
155
|
+
stageId: options.run.stage,
|
|
156
|
+
stageLabel: options.run.stage_label,
|
|
157
|
+
contractType: options.run.contract_type,
|
|
158
|
+
stageRunId: options.run.run_id,
|
|
159
|
+
executor: options.run.executor,
|
|
160
|
+
shellRoot: options.shellRoot,
|
|
161
|
+
contractPath: options.shellRoot
|
|
162
|
+
? join(options.shellRoot, "runtime", "stage-contract.json")
|
|
163
|
+
: join(options.contextGraphPath, options.run.contract_path),
|
|
164
|
+
promptPath: options.promptPath,
|
|
165
|
+
eventStreamPath: options.eventStreamPath,
|
|
166
|
+
statusPath: options.statusPath,
|
|
167
|
+
summary: options.run.summary,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Project the terminal session state from a finished ExecutionStageLedger. The
|
|
172
|
+
* session is a projection of the ledger, so the ledger→session field mapping
|
|
173
|
+
* (stage, run id, terminal status, summary, error) lives HERE, once, instead of
|
|
174
|
+
* being re-stated by hand at every ledger-terminal write site. A `running`
|
|
175
|
+
* ledger is not terminal and is ignored (no-op) so callers can pass the record
|
|
176
|
+
* unconditionally. Returns null when no session exists for the run (same
|
|
177
|
+
* contract as `writeStageExecutionSessionFinished`).
|
|
178
|
+
*/
|
|
179
|
+
export function projectSessionFinishedFromLedger(contextGraphPath, ledger) {
|
|
180
|
+
if (ledger.status === "running")
|
|
181
|
+
return null;
|
|
182
|
+
return writeStageExecutionSessionFinished({
|
|
183
|
+
contextGraphPath,
|
|
184
|
+
stageId: ledger.stage,
|
|
185
|
+
stageRunId: ledger.run_id,
|
|
186
|
+
status: ledger.status,
|
|
187
|
+
summary: ledger.summary,
|
|
188
|
+
error: ledger.error,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
export function writeStageExecutionSessionFinished(options) {
|
|
192
|
+
const current = readSession(options.contextGraphPath, options.stageId, options.stageRunId);
|
|
193
|
+
if (!current)
|
|
194
|
+
return null;
|
|
195
|
+
return writeSession(options.contextGraphPath, {
|
|
196
|
+
...current,
|
|
197
|
+
updated_at: new Date().toISOString(),
|
|
198
|
+
status: options.status,
|
|
199
|
+
summary: options.summary,
|
|
200
|
+
error: options.error ?? null,
|
|
201
|
+
runtime_files: {
|
|
202
|
+
...current.runtime_files,
|
|
203
|
+
// The reasoning transcript is teed DURING the run, so resolve it at finish:
|
|
204
|
+
// set the path iff the agent actually emitted reasoning (file exists), else
|
|
205
|
+
// leave null. Keeps "session references a reasoning file" => "the file is real".
|
|
206
|
+
reasoning_path: current.runtime_files.reasoning_path
|
|
207
|
+
?? runtimeFileIfExists(options.contextGraphPath, current.shell.root_path, "agent-reasoning.jsonl"),
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
export function recordStageExecutionSessionValidationAttempt(options) {
|
|
212
|
+
const current = readSession(options.contextGraphPath, options.stageId, options.stageRunId);
|
|
213
|
+
if (!current)
|
|
214
|
+
return null;
|
|
215
|
+
const withoutExisting = current.validation_attempts
|
|
216
|
+
.filter((attempt) => attempt.attempt !== options.attempt);
|
|
217
|
+
return writeSession(options.contextGraphPath, {
|
|
218
|
+
...current,
|
|
219
|
+
updated_at: new Date().toISOString(),
|
|
220
|
+
validation_attempts: [
|
|
221
|
+
...withoutExisting,
|
|
222
|
+
{
|
|
223
|
+
attempt: options.attempt,
|
|
224
|
+
recorded_at: new Date().toISOString(),
|
|
225
|
+
status: options.status,
|
|
226
|
+
summary: options.summary,
|
|
227
|
+
},
|
|
228
|
+
].sort((left, right) => left.attempt - right.attempt),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
export function markStageExecutionSessionsShellPreserved(options) {
|
|
232
|
+
const shellRootPath = contextRelative(options.contextGraphPath, options.shellRoot);
|
|
233
|
+
const preservedPath = preservedShellManifestPath(options.shellRoot);
|
|
234
|
+
const preservedRel = existsSync(preservedPath)
|
|
235
|
+
? contextRelative(options.contextGraphPath, preservedPath)
|
|
236
|
+
: null;
|
|
237
|
+
for (const session of listStageExecutionSessions(options.contextGraphPath)) {
|
|
238
|
+
if (session.shell.root_path !== shellRootPath)
|
|
239
|
+
continue;
|
|
240
|
+
writeSession(options.contextGraphPath, {
|
|
241
|
+
...session,
|
|
242
|
+
updated_at: new Date().toISOString(),
|
|
243
|
+
shell: {
|
|
244
|
+
...session.shell,
|
|
245
|
+
preserved_shell_manifest_path: preservedRel,
|
|
246
|
+
replay_ready: session.shell.replay_ready && existsSync(join(options.shellRoot, "AGENTS.md")),
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Reconcile sessions after their stage execution shells were pruned. The build
|
|
253
|
+
* pipeline deletes the whole execution-shells root on a successful build under
|
|
254
|
+
* non-"always" retention, but the session records live in a SEPARATE
|
|
255
|
+
* stage-sessions dir and would keep pointing at the deleted shell with
|
|
256
|
+
* `replay_ready: true` — a dangling pointer (F2). For every session whose shell
|
|
257
|
+
* root no longer exists on disk, downgrade it so "session exists" still implies
|
|
258
|
+
* "session is real": `replay_ready` false, preserved-shell manifest path
|
|
259
|
+
* nulled, and a retention reason recorded. Already-downgraded sessions and
|
|
260
|
+
* sessions whose shell still exists are left untouched. Best-effort and
|
|
261
|
+
* idempotent; runs in the build's `finally`, so it must never throw.
|
|
262
|
+
*/
|
|
263
|
+
export function reconcilePrunedStageExecutionSessions(options) {
|
|
264
|
+
const reason = options.reason
|
|
265
|
+
?? "Stage execution shell pruned after a successful Build (on-failure retention).";
|
|
266
|
+
for (const session of listStageExecutionSessions(options.contextGraphPath)) {
|
|
267
|
+
const shellRootAbsolute = join(options.contextGraphPath, session.shell.root_path);
|
|
268
|
+
if (existsSync(shellRootAbsolute))
|
|
269
|
+
continue;
|
|
270
|
+
if (!session.shell.replay_ready
|
|
271
|
+
&& session.shell.preserved_shell_manifest_path === null
|
|
272
|
+
&& session.shell.retention_reason !== null) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
writeSession(options.contextGraphPath, {
|
|
276
|
+
...session,
|
|
277
|
+
updated_at: new Date().toISOString(),
|
|
278
|
+
shell: {
|
|
279
|
+
...session.shell,
|
|
280
|
+
preserved_shell_manifest_path: null,
|
|
281
|
+
replay_ready: false,
|
|
282
|
+
retention_reason: reason,
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
export function listStageExecutionSessions(contextGraphPath) {
|
|
288
|
+
const root = contextGraphRuntimeStageSessionsRoot(contextGraphPath);
|
|
289
|
+
if (!existsSync(root))
|
|
290
|
+
return [];
|
|
291
|
+
const sessions = [];
|
|
292
|
+
for (const stageId of readdirSync(root)) {
|
|
293
|
+
const stageRoot = join(root, stageId);
|
|
294
|
+
if (!existsSync(stageRoot))
|
|
295
|
+
continue;
|
|
296
|
+
for (const stageRunId of readdirSync(stageRoot)) {
|
|
297
|
+
const session = readSessionAt(join(stageRoot, stageRunId, "session.json"));
|
|
298
|
+
if (session)
|
|
299
|
+
sessions.push(session);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return sessions.sort((left, right) => {
|
|
303
|
+
const byGenerated = Date.parse(left.generated_at) - Date.parse(right.generated_at);
|
|
304
|
+
if (byGenerated !== 0)
|
|
305
|
+
return byGenerated;
|
|
306
|
+
return left.stage_run_id.localeCompare(right.stage_run_id);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ContextGraphHealth, type ContextGraphViewSpec, type SourceFiles, type SourceState } from "./lib/schema.js";
|
|
2
|
+
export declare function refreshContextGraphArtifacts(dirPath: string, options?: {
|
|
3
|
+
ensureViewSpec?: boolean;
|
|
4
|
+
}): {
|
|
5
|
+
health: ContextGraphHealth;
|
|
6
|
+
viewSpec?: ContextGraphViewSpec;
|
|
7
|
+
sourceFiles: SourceFiles;
|
|
8
|
+
sourceState: SourceState;
|
|
9
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { saveContextGraphHealth, } from "./state-io.js";
|
|
2
|
+
import { computeContextGraphHealth, } from "./state-health.js";
|
|
3
|
+
import { ensureContextGraphSourceFiles, ensureContextGraphSourceState, ensureContextGraphViewSpec, } from "./state-view.js";
|
|
4
|
+
export function refreshContextGraphArtifacts(dirPath, options) {
|
|
5
|
+
const health = computeContextGraphHealth(dirPath);
|
|
6
|
+
saveContextGraphHealth(dirPath, health);
|
|
7
|
+
const sourceFiles = ensureContextGraphSourceFiles(dirPath);
|
|
8
|
+
const sourceState = ensureContextGraphSourceState(dirPath, sourceFiles);
|
|
9
|
+
let viewSpec;
|
|
10
|
+
if (options?.ensureViewSpec) {
|
|
11
|
+
viewSpec = ensureContextGraphViewSpec(dirPath);
|
|
12
|
+
}
|
|
13
|
+
return { health, viewSpec, sourceFiles, sourceState };
|
|
14
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ContextGraphHealth, type BuildStage, type RuntimeStatus } from "./lib/schema.js";
|
|
2
|
+
export declare function computeContextGraphHealth(dirPath: string): ContextGraphHealth;
|
|
3
|
+
export declare function resolveContextGraphStatus(..._args: unknown[]): RuntimeStatus;
|
|
4
|
+
export declare function resolveBuildStage(...args: unknown[]): BuildStage;
|