@deksden-com/dd-flow-cli 0.9.0-beta.16 → 0.9.0-beta.161
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +965 -0
- package/README.md +139 -10
- package/dist/build-info.json +8 -8
- package/dist/cli/argument-values.js +38 -0
- package/dist/cli/command-inputs.js +417 -0
- package/dist/cli/command-metadata.js +303 -0
- package/dist/cli/command-option-descriptions.js +192 -0
- package/dist/cli/completion-cli.js +70 -0
- package/dist/cli/completion.js +57 -0
- package/dist/cli/delivery.js +108 -0
- package/dist/cli/diagnostic-invocation.js +62 -0
- package/dist/cli/diagnostic.js +131 -0
- package/dist/cli/error-output.js +62 -0
- package/dist/cli/executor-onboarding.js +76 -0
- package/dist/cli/flows.js +29 -0
- package/dist/cli/harnesses.js +84 -0
- package/dist/cli/help.js +521 -19
- package/dist/cli/hook-ingress.js +89 -0
- package/dist/cli/input-preparation.js +193 -0
- package/dist/cli/interactive-invocation.js +33 -0
- package/dist/cli/interactive.js +114 -0
- package/dist/cli/memory-fix-invocation.js +52 -0
- package/dist/cli/memory-fix.js +100 -0
- package/dist/cli/memory-flow-admission.js +54 -0
- package/dist/cli/memory-init-invocation.js +85 -0
- package/dist/cli/memory-init.js +250 -0
- package/dist/cli/memory-storage-admission.js +54 -0
- package/dist/cli/memory-storage-qualification.js +105 -0
- package/dist/cli/memory-storage-transition.js +123 -0
- package/dist/cli/memory-upgrade.js +189 -0
- package/dist/cli/models.js +39 -0
- package/dist/cli/native-hook-ingress.js +94 -0
- package/dist/cli/native-hook-preparation.js +82 -0
- package/dist/cli/operator-profiles.js +61 -0
- package/dist/cli/output-options.js +35 -0
- package/dist/cli/response-file.js +72 -0
- package/dist/cli/run-cli.js +2020 -555
- package/dist/cli/runtime-maintenance-diagnostics.js +46 -0
- package/dist/cli/runtime-maintenance-ingress.js +52 -0
- package/dist/cli/runtime-process.js +153 -0
- package/dist/cli/setup.js +150 -0
- package/dist/cli.js +103 -2
- package/dist/domain/delivery-flows.js +8 -0
- package/dist/domain/diagnostic-aspects.js +103 -0
- package/dist/domain/diagnostic-flows.js +8 -0
- package/dist/domain/distill-flow.js +20 -0
- package/dist/domain/interactive-flow.js +1 -0
- package/dist/domain/memory-fix-flow.js +2 -0
- package/dist/domain/review-fix-flow.js +2 -0
- package/dist/domain/source-snapshot-flows.js +4 -0
- package/dist/domain/stage-catalog.js +1 -1
- package/dist/domain/stage-handler-identities.js +28 -0
- package/dist/harness-runtime/DD-ZCODE.md +112 -0
- package/dist/harness-runtime/OPENCODE-LICENSE.txt +24 -0
- package/dist/harness-runtime/bin/dd-agy.mjs +71 -0
- package/dist/harness-runtime/bin/dd-codex.mjs +27 -0
- package/dist/harness-runtime/bin/dd-droid.mjs +34 -0
- package/dist/harness-runtime/bin/dd-grok.mjs +50 -0
- package/dist/harness-runtime/bin/dd-opencode.mjs +22 -0
- package/dist/harness-runtime/bin/dd-zcode.mjs +95 -0
- package/dist/harness-runtime/lib/adapter-timeouts.d.mts +5 -0
- package/dist/harness-runtime/lib/adapter-timeouts.mjs +34 -0
- package/dist/harness-runtime/lib/agy-error-boundary.mjs +87 -0
- package/dist/harness-runtime/lib/agy-hooks.d.mts +1 -0
- package/dist/harness-runtime/lib/agy-hooks.mjs +9 -0
- package/dist/harness-runtime/lib/agy-native-inspection.mjs +225 -0
- package/dist/harness-runtime/lib/agy-native-inventory.mjs +19 -0
- package/dist/harness-runtime/lib/agy-native_pb.js +117 -0
- package/dist/harness-runtime/lib/agy-terminal-envelope.mjs +74 -0
- package/dist/harness-runtime/lib/agy-transcript-stream.mjs +54 -0
- package/dist/harness-runtime/lib/daemon-observation.d.mts +3 -0
- package/dist/harness-runtime/lib/daemon-observation.mjs +171 -0
- package/dist/harness-runtime/lib/daemon-operations.d.mts +2 -0
- package/dist/harness-runtime/lib/daemon-operations.mjs +512 -0
- package/dist/harness-runtime/lib/dd-agy-daemon.d.mts +7 -0
- package/dist/harness-runtime/lib/dd-agy-daemon.mjs +1362 -0
- package/dist/harness-runtime/lib/dd-agy.mjs +105 -0
- package/dist/harness-runtime/lib/dd-codex-daemon.d.mts +1 -0
- package/dist/harness-runtime/lib/dd-codex-daemon.mjs +271 -0
- package/dist/harness-runtime/lib/dd-codex.d.mts +1 -0
- package/dist/harness-runtime/lib/dd-codex.mjs +986 -0
- package/dist/harness-runtime/lib/dd-droid-daemon.mjs +155 -0
- package/dist/harness-runtime/lib/dd-droid.mjs +739 -0
- package/dist/harness-runtime/lib/dd-grok-daemon.d.mts +1 -0
- package/dist/harness-runtime/lib/dd-grok-daemon.mjs +667 -0
- package/dist/harness-runtime/lib/dd-grok.mjs +182 -0
- package/dist/harness-runtime/lib/dd-opencode-daemon.mjs +772 -0
- package/dist/harness-runtime/lib/dd-opencode.mjs +411 -0
- package/dist/harness-runtime/lib/dd-zcode-daemon.d.mts +1 -0
- package/dist/harness-runtime/lib/dd-zcode-daemon.mjs +845 -0
- package/dist/harness-runtime/lib/dd-zcode.mjs +1239 -0
- package/dist/harness-runtime/lib/delegation-instructions.d.mts +16 -0
- package/dist/harness-runtime/lib/delegation-instructions.mjs +179 -0
- package/dist/harness-runtime/lib/delivery-command.mjs +84 -0
- package/dist/harness-runtime/lib/dispatch-fence.mjs +14 -0
- package/dist/harness-runtime/lib/driver-recovery.mjs +121 -0
- package/dist/harness-runtime/lib/droid-observation.mjs +70 -0
- package/dist/harness-runtime/lib/entity-references.d.mts +2 -0
- package/dist/harness-runtime/lib/entity-references.mjs +9 -0
- package/dist/harness-runtime/lib/lease-renewal.d.mts +8 -0
- package/dist/harness-runtime/lib/lease-renewal.mjs +37 -0
- package/dist/harness-runtime/lib/lifecycle-command.d.mts +20 -0
- package/dist/harness-runtime/lib/lifecycle-command.mjs +273 -0
- package/dist/harness-runtime/lib/lifecycle-contract.d.mts +11 -0
- package/dist/harness-runtime/lib/lifecycle-contract.mjs +20 -0
- package/dist/harness-runtime/lib/managed-daemon.d.mts +16 -0
- package/dist/harness-runtime/lib/managed-daemon.mjs +698 -0
- package/dist/harness-runtime/lib/managed-flow-env.mjs +15 -0
- package/dist/harness-runtime/lib/model-observations.mjs +113 -0
- package/dist/harness-runtime/lib/native-children.d.mts +34 -0
- package/dist/harness-runtime/lib/native-children.mjs +265 -0
- package/dist/harness-runtime/lib/native-hook-command.d.mts +8 -0
- package/dist/harness-runtime/lib/native-hook-command.mjs +306 -0
- package/dist/harness-runtime/lib/native-request-proof.d.mts +2 -0
- package/dist/harness-runtime/lib/native-request-proof.mjs +65 -0
- package/dist/harness-runtime/lib/native-streams.mjs +38 -0
- package/dist/harness-runtime/lib/observation-clock.d.mts +18 -0
- package/dist/harness-runtime/lib/observation-clock.mjs +95 -0
- package/dist/harness-runtime/lib/opencode-plugin.mjs +112 -0
- package/dist/harness-runtime/lib/operation-context.mjs +5 -0
- package/dist/harness-runtime/lib/operation-errors.d.mts +16 -0
- package/dist/harness-runtime/lib/operation-errors.mjs +140 -0
- package/dist/harness-runtime/lib/operation-progress.d.mts +7 -0
- package/dist/harness-runtime/lib/operation-progress.mjs +118 -0
- package/dist/harness-runtime/lib/process-json.d.mts +5 -0
- package/dist/harness-runtime/lib/process-json.mjs +200 -0
- package/dist/harness-runtime/lib/process-snapshot.mjs +10 -0
- package/dist/harness-runtime/lib/provider-overload-policy.d.mts +23 -0
- package/dist/harness-runtime/lib/provider-overload-policy.mjs +242 -0
- package/dist/harness-runtime/lib/runner-events.mjs +202 -0
- package/dist/harness-runtime/lib/runner-lock.mjs +42 -0
- package/dist/harness-runtime/lib/session-settlement.mjs +30 -0
- package/dist/harness-runtime/lib/setup-progress.d.mts +9 -0
- package/dist/harness-runtime/lib/setup-progress.mjs +53 -0
- package/dist/harness-runtime/lib/tool-observations.d.mts +21 -0
- package/dist/harness-runtime/lib/tool-observations.mjs +238 -0
- package/dist/harness-runtime/lib/zcode-native-hook-ownership.mjs +109 -0
- package/dist/harness-runtime/lib/zcode-usage.mjs +55 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-1y4a697q.js +81 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-2ny4vxct.js +92 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-6mptkzbc.js +0 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-7x67cf1q.js +52 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-9rqn6x4v.js +16 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-9vdz0zwn.js +1661 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-ecs5ftka.js +1466 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-frbwqjmf.js +145 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-gne7h7mq.js +50 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-gx9wnkzr.js +105 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-m2eywc8w.js +0 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-nwcpakzx.js +12 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-q4g3afnw.js +623 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-qav6mfdz.js +0 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-sxt88q69.js +12 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-t1xa31vm.js +39 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-ve4aws36.js +103 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-vmytr4q8.js +4 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-vt9jbch8.js +36 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-vyas3vgt.js +0 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-wjyeq25y.js +30 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-xgnj2w4v.js +20 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-y2etg5bs.js +9 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-ydhz1zrh.js +238 -0
- package/dist/harness-runtime/vendor/opencode-client/chunks/service-probe-z6qdwcsf.js +62 -0
- package/dist/harness-runtime/vendor/opencode-client/contract.d.ts +1 -0
- package/dist/harness-runtime/vendor/opencode-client/contract.js +12 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/api/api.d.ts +2806 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/api/api.js +0 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/api.d.ts +4 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/api.js +0 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/client.d.ts +2530 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/client.js +15 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/generated/client-error.d.ts +7 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/generated/client-error.js +6 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/generated/client.d.ts +2529 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/generated/client.js +8 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/generated/index.d.ts +2 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/generated/index.js +12 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/index.d.ts +35 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/index.js +75 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/rpc.d.ts +20 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/rpc.js +11 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/service.d.ts +90 -0
- package/dist/harness-runtime/vendor/opencode-client/effect/service.js +187 -0
- package/dist/harness-runtime/vendor/opencode-client/package.json +84 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/api.d.ts +21 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/api.js +0 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/client.d.ts +252 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/client.js +14 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/generated/client-error.d.ts +8 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/generated/client-error.js +6 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/generated/client.d.ts +259 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/generated/client.js +7 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/generated/index.d.ts +3 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/generated/index.js +79 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/generated/types.d.ts +8932 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/generated/types.js +70 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/index.d.ts +6 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/index.js +83 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/rpc.d.ts +32 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/rpc.js +7 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/service.d.ts +24 -0
- package/dist/harness-runtime/vendor/opencode-client/promise/service.js +187 -0
- package/dist/harness-runtime/vendor/opencode-client/pty-handoff.d.ts +12 -0
- package/dist/harness-runtime/vendor/opencode-client/pty-handoff.js +14 -0
- package/dist/harness-runtime/vendor/opencode-client/rpc-runtime.d.ts +20 -0
- package/dist/harness-runtime/vendor/opencode-client/rpc-runtime.js +14 -0
- package/dist/harness-runtime/vendor/opencode-client/service-contender.d.ts +37 -0
- package/dist/harness-runtime/vendor/opencode-client/service-contender.js +10 -0
- package/dist/harness-runtime/vendor/opencode-client/service-probe.d.ts +70 -0
- package/dist/harness-runtime/vendor/opencode-client/service-probe.js +16 -0
- package/dist/harness-runtime/vendor/opencode-client/service-timing.d.ts +12 -0
- package/dist/harness-runtime/vendor/opencode-client/service-timing.js +10 -0
- package/dist/harness-runtime/vendor/opencode-client/service-version.d.ts +2 -0
- package/dist/harness-runtime/vendor/opencode-client/service-version.js +6 -0
- package/dist/harness-runtime/vendor/opencode-client/service.d.ts +52 -0
- package/dist/harness-runtime/vendor/opencode-client/service.js +1 -0
- package/dist/harness-runtime/vendor/opencode-client/shared-events.d.ts +11 -0
- package/dist/harness-runtime/vendor/opencode-client/shared-events.js +8 -0
- package/dist/harness-runtime/vendor/opencode-client/solid/connection.d.ts +37 -0
- package/dist/harness-runtime/vendor/opencode-client/solid/connection.js +10 -0
- package/dist/harness-runtime/vendor/opencode-client/solid/data.d.ts +211 -0
- package/dist/harness-runtime/vendor/opencode-client/solid/data.js +18 -0
- package/dist/harness-runtime/vendor/opencode-client/solid/index.d.ts +3 -0
- package/dist/harness-runtime/vendor/opencode-client/solid/index.js +32 -0
- package/dist/harness-runtime/vendor/opencode-client/solid/pty.d.ts +22 -0
- package/dist/harness-runtime/vendor/opencode-client/solid/pty.js +8 -0
- package/dist/harness-runtime/vendor/opencode-plugin.mjs +3 -0
- package/dist/protocol/local-files.js +18 -9
- package/dist/runtime/context.js +8 -4
- package/dist/schemas/agent-profile.schema.json +1 -1
- package/dist/schemas/code-review-decision.schema.json +9 -0
- package/dist/schemas/code-review-result.schema.json +1 -1
- package/dist/schemas/code-verification.schema.json +7 -5
- package/dist/schemas/code-work-batch.schema.json +2 -2
- package/dist/schemas/code-work-result.schema.json +2 -1
- package/dist/schemas/delivery-stage-result.schema.json +286 -0
- package/dist/schemas/diagnostic-stage-result.schema.json +354 -0
- package/dist/schemas/diagnostic-work-result.schema.json +296 -0
- package/dist/schemas/discovery-result.schema.json +184 -0
- package/dist/schemas/distill-stage-result.schema.json +667 -0
- package/dist/schemas/distill-work-result.schema.json +428 -0
- package/dist/schemas/execution-bundle.schema.json +215 -0
- package/dist/schemas/execution-settings.schema.json +162 -0
- package/dist/schemas/flow-descriptor.schema.json +54 -0
- package/dist/schemas/flow-run.schema.json +29 -0
- package/dist/schemas/harness-catalog.schema.json +80 -0
- package/dist/schemas/interactive-stage-result.schema.json +47 -0
- package/dist/schemas/interactive-work-result.schema.json +63 -0
- package/dist/schemas/mb-fix-stage-result.schema.json +93 -0
- package/dist/schemas/mb-init-compose-result.schema.json +457 -0
- package/dist/schemas/mb-init-discover-result.schema.json +500 -0
- package/dist/schemas/mb-init-finish-result.schema.json +422 -0
- package/dist/schemas/mb-init-preflight-result.schema.json +367 -0
- package/dist/schemas/mb-init-review-result.schema.json +396 -0
- package/dist/schemas/mb-init-verify-result.schema.json +391 -0
- package/dist/schemas/mb-upgrade-stage-result.schema.json +863 -0
- package/dist/schemas/memory-bootstrap-receipt-v2.schema.json +67 -0
- package/dist/schemas/memory-bootstrap-receipt.schema.json +354 -0
- package/dist/schemas/memory-composition-work-result.schema.json +38 -0
- package/dist/schemas/memory-repair-work-result.schema.json +56 -0
- package/dist/schemas/memory-review-correction-plan.schema.json +30 -0
- package/dist/schemas/memory-review-work-result.schema.json +43 -0
- package/dist/schemas/model-catalog.schema.json +153 -0
- package/dist/schemas/plan-review-decision.schema.json +12 -3
- package/dist/schemas/plan-review-result.schema.json +2 -2
- package/dist/schemas/profile-settings.schema.json +122 -0
- package/dist/schemas/project-flow-pack-manifest.schema.json +2 -2
- package/dist/schemas/release-impact.schema.json +3 -3
- package/dist/schemas/release-manifest.schema.json +291 -0
- package/dist/schemas/review-fix-stage-result.schema.json +210 -0
- package/dist/schemas/run-control-receipt.schema.json +119 -0
- package/dist/schemas/run-control-request.schema.json +36 -0
- package/dist/schemas/run-engine-binding.schema.json +1 -1
- package/dist/schemas/stage-start-response.schema.json +4 -0
- package/dist/schemas/vnext-protocol-plan.schema.json +3 -3
- package/dist/services/accepted-intent.js +139 -0
- package/dist/services/assigned-lifecycle.js +382 -0
- package/dist/services/branch-context.js +3 -3
- package/dist/services/canon.js +54 -15
- package/dist/services/check-environment.js +21 -0
- package/dist/services/check-runner-evidence.js +344 -0
- package/dist/services/check-runner-proof.js +373 -0
- package/dist/services/cleanup.js +133 -40
- package/dist/services/cli-operation-classifier.js +32 -64
- package/dist/services/cli-upgrade-allowlist.js +27 -0
- package/dist/services/code-checks.js +1426 -121
- package/dist/services/codex-capacity.js +367 -0
- package/dist/services/codex-hook-delivery.js +41 -0
- package/dist/services/command-context.js +80 -0
- package/dist/services/compatibility-preflight.js +16 -3
- package/dist/services/config.js +11 -8
- package/dist/services/continuation-outcome.js +25 -0
- package/dist/services/controller-child-capacity.js +71 -0
- package/dist/services/controller-child-observer.js +121 -0
- package/dist/services/controller-child-repair.js +117 -0
- package/dist/services/controller-execution.js +97 -0
- package/dist/services/controller-fanout.js +277 -0
- package/dist/services/controller-memory-task.js +45 -0
- package/dist/services/controller-memory-worker.js +51 -0
- package/dist/services/controller-result-authority.js +127 -0
- package/dist/services/controller-work-failure.js +198 -0
- package/dist/services/dashboard.js +145 -58
- package/dist/services/delivery-access.js +123 -0
- package/dist/services/delivery-approval.js +68 -0
- package/dist/services/delivery-artifact.js +86 -0
- package/dist/services/delivery-checks.js +178 -0
- package/dist/services/delivery-execution.js +181 -0
- package/dist/services/delivery-intents.js +212 -0
- package/dist/services/delivery-operation.js +81 -0
- package/dist/services/delivery-policy.js +91 -0
- package/dist/services/delivery-procedures.js +43 -0
- package/dist/services/delivery-request.js +99 -0
- package/dist/services/delivery-result.js +144 -0
- package/dist/services/delivery-stage-commands.js +26 -0
- package/dist/services/delivery-stage-entry.js +56 -0
- package/dist/services/delivery-stage-handlers.js +135 -0
- package/dist/services/delivery-stage-results.js +94 -0
- package/dist/services/descriptor-coordinator-session.js +37 -0
- package/dist/services/descriptor-root-work.js +53 -0
- package/dist/services/descriptor-run-settlement.js +107 -0
- package/dist/services/descriptor-run-start.js +495 -0
- package/dist/services/descriptor-stage-coordinator.js +318 -0
- package/dist/services/descriptor-stage-settlement.js +268 -0
- package/dist/services/descriptor-stage-start.js +175 -0
- package/dist/services/diagnostic-evidence.js +73 -0
- package/dist/services/diagnostic-repair-intake.js +123 -0
- package/dist/services/diagnostic-repair-source-intake.js +102 -0
- package/dist/services/diagnostic-report-publication.js +72 -0
- package/dist/services/diagnostic-report.js +97 -0
- package/dist/services/diagnostic-run-bundle.js +113 -0
- package/dist/services/diagnostic-snapshot.js +159 -0
- package/dist/services/diagnostic-stage-handlers.js +109 -0
- package/dist/services/diagnostic-stage-results.js +158 -0
- package/dist/services/diagnostic-start.js +134 -0
- package/dist/services/diagnostic-work-batch.js +34 -0
- package/dist/services/diagnostic-work-collection.js +97 -0
- package/dist/services/diagnostic-work-registration.js +101 -0
- package/dist/services/diagnostic-work-results.js +93 -0
- package/dist/services/discovery/agy-discovery.js +2 -0
- package/dist/services/discovery/codex-discovery.js +2 -0
- package/dist/services/discovery/droid-discovery.js +2 -0
- package/dist/services/discovery/grok-discovery.js +2 -0
- package/dist/services/discovery/opencode-discovery.js +2 -0
- package/dist/services/discovery/static.js +31 -0
- package/dist/services/discovery/zcode-discovery.js +2 -0
- package/dist/services/distill-document-publication.js +280 -0
- package/dist/services/distill-promotion.js +197 -0
- package/dist/services/distill-publication-custody.js +162 -0
- package/dist/services/distill-stage-handlers.js +249 -0
- package/dist/services/distill-stage-results.js +105 -0
- package/dist/services/distill-user-inputs.js +4 -0
- package/dist/services/distill-work-batch.js +42 -0
- package/dist/services/distill-work-collection.js +74 -0
- package/dist/services/distill-work-registration.js +93 -0
- package/dist/services/distill-work-results.js +98 -0
- package/dist/services/engines.js +354 -163
- package/dist/services/eval-snapshots.js +1326 -150
- package/dist/services/execution-bundles.js +275 -0
- package/dist/services/execution-policy.js +185 -0
- package/dist/services/executor-onboarding.js +56 -0
- package/dist/services/external-work-launch.js +316 -0
- package/dist/services/flow-catalog.js +54 -0
- package/dist/services/flow-descriptors.js +82 -0
- package/dist/services/frozen-engine.js +404 -0
- package/dist/services/generic-execution.js +165 -0
- package/dist/services/harness-adapter.js +342 -35
- package/dist/services/harness-config.js +2 -0
- package/dist/services/harness-discovery.js +29 -0
- package/dist/services/harness-doctor.js +75 -0
- package/dist/services/harness-probe-effects.js +51 -0
- package/dist/services/harness-version-probe.js +100 -0
- package/dist/services/hook-memory-routing.js +188 -0
- package/dist/services/hook-recovery-guard.js +14 -0
- package/dist/services/hook-session-observation.js +24 -0
- package/dist/services/hooks.js +813 -327
- package/dist/services/hybrid-contracts.js +479 -0
- package/dist/services/hybrid-digest.js +14 -0
- package/dist/services/ids.js +29 -1
- package/dist/services/installation-lock.js +95 -0
- package/dist/services/installed-flow-source.js +261 -0
- package/dist/services/interactive-attached-session.js +215 -0
- package/dist/services/interactive-baseline-custody.js +54 -0
- package/dist/services/interactive-before-versions.js +148 -0
- package/dist/services/interactive-bundle-data.js +85 -0
- package/dist/services/interactive-checks.js +179 -0
- package/dist/services/interactive-execution.js +33 -0
- package/dist/services/interactive-finish-integration.js +236 -0
- package/dist/services/interactive-git-baseline.js +230 -0
- package/dist/services/interactive-git-dispatch.js +278 -0
- package/dist/services/interactive-input-delivery.js +82 -0
- package/dist/services/interactive-mutation-scope.js +231 -0
- package/dist/services/interactive-request.js +287 -0
- package/dist/services/interactive-run-bundle.js +109 -0
- package/dist/services/interactive-stage-entry.js +41 -0
- package/dist/services/interactive-stage-handlers.js +289 -0
- package/dist/services/interactive-stage-observation.js +136 -0
- package/dist/services/interactive-stage-results.js +111 -0
- package/dist/services/interactive-user-inputs.js +142 -0
- package/dist/services/interactive-work-batch.js +43 -0
- package/dist/services/interactive-work-collection.js +119 -0
- package/dist/services/interactive-work-completion.js +180 -0
- package/dist/services/interactive-work-context.js +249 -0
- package/dist/services/interactive-work-history.js +112 -0
- package/dist/services/interactive-work-registration.js +124 -0
- package/dist/services/interactive-work-results.js +115 -0
- package/dist/services/interactive-work-start.js +155 -0
- package/dist/services/lanes.js +78 -65
- package/dist/services/lifecycle-command.js +1 -288
- package/dist/services/lifecycle-contract.js +1 -0
- package/dist/services/lifecycle-invocations.js +2549 -0
- package/dist/services/managed-daemon-binding.js +129 -0
- package/dist/services/managed-lease-monitor.js +133 -0
- package/dist/services/managed-processes.js +449 -69
- package/dist/services/memory-accepted-composition.js +78 -0
- package/dist/services/memory-baseline-preservation.js +65 -0
- package/dist/services/memory-completed-correction-wave.js +328 -0
- package/dist/services/memory-compose-handler.js +380 -0
- package/dist/services/memory-composition-acceptance.js +375 -0
- package/dist/services/memory-composition-graph.js +165 -0
- package/dist/services/memory-composition-registration.js +161 -0
- package/dist/services/memory-composition-work-custody.js +156 -0
- package/dist/services/memory-composition-work-results.js +108 -0
- package/dist/services/memory-corrected-review-acceptance.js +129 -0
- package/dist/services/memory-corrected-review-batch.js +37 -0
- package/dist/services/memory-corrected-review-findings.js +108 -0
- package/dist/services/memory-corrected-review-inputs.js +215 -0
- package/dist/services/memory-corrected-review-projection.js +78 -0
- package/dist/services/memory-corrected-review-receipt.js +178 -0
- package/dist/services/memory-corrected-review-registration.js +192 -0
- package/dist/services/memory-correction-check-receipt.js +235 -0
- package/dist/services/memory-correction-input-owner.js +6 -0
- package/dist/services/memory-custody-snapshot.js +36 -0
- package/dist/services/memory-discover-handler.js +104 -0
- package/dist/services/memory-finish-evidence.js +457 -0
- package/dist/services/memory-finish-handler.js +229 -0
- package/dist/services/memory-finish-integration.js +491 -0
- package/dist/services/memory-finish-readiness.js +169 -0
- package/dist/services/memory-fix-finish-integration.js +129 -0
- package/dist/services/memory-fix-git-dispatch.js +139 -0
- package/dist/services/memory-fix-intake-custody.js +11 -0
- package/dist/services/memory-fix-intake-settlement.js +127 -0
- package/dist/services/memory-fix-publication.js +196 -0
- package/dist/services/memory-fix-repair-admission.js +116 -0
- package/dist/services/memory-fix-request.js +141 -0
- package/dist/services/memory-fix-run-bundle.js +83 -0
- package/dist/services/memory-fix-scope.js +78 -0
- package/dist/services/memory-fix-sources.js +85 -0
- package/dist/services/memory-fix-stage-entry.js +24 -0
- package/dist/services/memory-fix-stage-handlers.js +282 -0
- package/dist/services/memory-fix-stage-results.js +106 -0
- package/dist/services/memory-fix-workspace.js +127 -0
- package/dist/services/memory-flow-user-inputs.js +88 -0
- package/dist/services/memory-git-integration.js +220 -0
- package/dist/services/memory-historical-corrected-review.js +212 -0
- package/dist/services/memory-historical-original-review.js +143 -0
- package/dist/services/memory-historical-repair-registration.js +105 -0
- package/dist/services/memory-historical-second-review.js +147 -0
- package/dist/services/memory-init-bootstrap-readiness.js +210 -0
- package/dist/services/memory-init-contexts.js +181 -0
- package/dist/services/memory-init-controller-start.js +119 -0
- package/dist/services/memory-init-engine-release.js +223 -0
- package/dist/services/memory-init-git-policy.js +165 -0
- package/dist/services/memory-init-lint-capability.js +203 -0
- package/dist/services/memory-init-native-capacity.js +309 -0
- package/dist/services/memory-init-preflight.js +334 -0
- package/dist/services/memory-init-project-bootstrap.js +599 -0
- package/dist/services/memory-init-request-candidate.js +213 -0
- package/dist/services/memory-init-request-input.js +82 -0
- package/dist/services/memory-init-resource-storage.js +125 -0
- package/dist/services/memory-init-run-allocation.js +81 -0
- package/dist/services/memory-init-run-bundle.js +135 -0
- package/dist/services/memory-init-start.js +181 -0
- package/dist/services/memory-init-startup-custody.js +80 -0
- package/dist/services/memory-init-startup-input.js +240 -0
- package/dist/services/memory-init-storage.js +91 -0
- package/dist/services/memory-init-stores.js +359 -0
- package/dist/services/memory-init-worktrunk-capability.js +174 -0
- package/dist/services/memory-layer-publication.js +611 -0
- package/dist/services/memory-layer.js +225 -0
- package/dist/services/memory-lint-config.js +194 -0
- package/dist/services/memory-native-review-copy.js +127 -0
- package/dist/services/memory-normal-flow-entry.js +87 -0
- package/dist/services/memory-ordinary-defaults.js +129 -0
- package/dist/services/memory-preflight-bootstrap-custody.js +115 -0
- package/dist/services/memory-preflight-handler.js +274 -0
- package/dist/services/memory-repair-current-view.js +299 -0
- package/dist/services/memory-repair-document-delta.js +489 -0
- package/dist/services/memory-repair-history.js +496 -0
- package/dist/services/memory-repair-physical-binding.js +194 -0
- package/dist/services/memory-repair-publication-files.js +152 -0
- package/dist/services/memory-repair-publication-intent.js +27 -0
- package/dist/services/memory-repair-publication-plan.js +162 -0
- package/dist/services/memory-repair-publication-source.js +225 -0
- package/dist/services/memory-repair-publication.js +795 -0
- package/dist/services/memory-repair-registration.js +240 -0
- package/dist/services/memory-repair-work-baseline.js +415 -0
- package/dist/services/memory-repair-work-completion.js +117 -0
- package/dist/services/memory-repair-work-custody.js +73 -0
- package/dist/services/memory-repair-work-results.js +108 -0
- package/dist/services/memory-repair-workspace.js +261 -0
- package/dist/services/memory-repair-writer-copy.js +736 -0
- package/dist/services/memory-result-binding.js +239 -0
- package/dist/services/memory-retained-review-authority.js +138 -0
- package/dist/services/memory-retained-review-results.js +70 -0
- package/dist/services/memory-retained-second-baseline.js +102 -0
- package/dist/services/memory-retained-second-repairs.js +162 -0
- package/dist/services/memory-review-acceptance.js +214 -0
- package/dist/services/memory-review-correction-plan.js +206 -0
- package/dist/services/memory-review-handler.js +585 -0
- package/dist/services/memory-review-inputs.js +246 -0
- package/dist/services/memory-review-limits.js +10 -0
- package/dist/services/memory-review-receipt.js +180 -0
- package/dist/services/memory-review-registration.js +117 -0
- package/dist/services/memory-review-work-custody.js +126 -0
- package/dist/services/memory-review-work-input.js +91 -0
- package/dist/services/memory-review-work-results.js +95 -0
- package/dist/services/memory-second-corrected-review-inputs.js +167 -0
- package/dist/services/memory-second-correction-plan.js +77 -0
- package/dist/services/memory-second-repair-baseline.js +91 -0
- package/dist/services/memory-second-repair-launch.js +614 -0
- package/dist/services/memory-second-repair-registration.js +88 -0
- package/dist/services/memory-second-repair-source.js +187 -0
- package/dist/services/memory-second-review-acceptance.js +115 -0
- package/dist/services/memory-source-observations.js +117 -0
- package/dist/services/memory-stage-dispatch.js +65 -0
- package/dist/services/memory-stage-results.js +290 -0
- package/dist/services/memory-tool-probe.js +25 -0
- package/dist/services/memory-upgrade-analysis-handler.js +243 -0
- package/dist/services/memory-upgrade-bootstrap-readiness.js +251 -0
- package/dist/services/memory-upgrade-evidence.js +100 -0
- package/dist/services/memory-upgrade-inventory.js +442 -0
- package/dist/services/memory-upgrade-publication-custody.js +73 -0
- package/dist/services/memory-upgrade-publication.js +413 -0
- package/dist/services/memory-upgrade-selection.js +430 -0
- package/dist/services/memory-upgrade-start.js +60 -0
- package/dist/services/memory-upgrade-storage-readiness.js +340 -0
- package/dist/services/memory-verification-acceptance.js +156 -0
- package/dist/services/memory-verification-checks.js +317 -0
- package/dist/services/memory-verification-receipt.js +160 -0
- package/dist/services/memory-verify-handler.js +137 -0
- package/dist/services/memory-work-result-json.js +12 -0
- package/dist/services/memory-work-result-preparation.js +64 -0
- package/dist/services/merge-queue.js +228 -149
- package/dist/services/merge-server.js +163 -35
- package/dist/services/migrations.js +164 -114
- package/dist/services/model-catalog.js +109 -0
- package/dist/services/model-discovery.js +46 -0
- package/dist/services/native-daemon-history.js +50 -0
- package/dist/services/native-session-control.js +39 -0
- package/dist/services/operator-profiles.js +236 -0
- package/dist/services/physical-startup.js +45 -0
- package/dist/services/plan-runtime.js +26 -11
- package/dist/services/plans.js +28 -25
- package/dist/services/project-flow-source.js +195 -0
- package/dist/services/project-git-integration.js +92 -0
- package/dist/services/project-registry.js +97 -0
- package/dist/services/project-summary.js +1 -1
- package/dist/services/projects.js +17 -87
- package/dist/services/prompt-delivery.js +71 -0
- package/dist/services/prompts.js +28 -17
- package/dist/services/protocols.js +163 -87
- package/dist/services/provider-capacity.js +463 -0
- package/dist/services/recovery-observation-budget.js +121 -0
- package/dist/services/recovery-snapshot-database.js +588 -0
- package/dist/services/release-archive-producer.js +52 -0
- package/dist/services/release-archive.js +143 -0
- package/dist/services/release-cache.js +150 -0
- package/dist/services/release-compatibility.js +18 -0
- package/dist/services/release-download.js +67 -0
- package/dist/services/release-envelope.js +104 -0
- package/dist/services/release-manifest.js +45 -0
- package/dist/services/release-payload.js +114 -0
- package/dist/services/release-producer.js +63 -0
- package/dist/services/release-provenance.js +160 -0
- package/dist/services/release-registry.js +66 -0
- package/dist/services/release-source.js +194 -0
- package/dist/services/repair-intents.js +29 -0
- package/dist/services/repair-receipt.js +13 -0
- package/dist/services/retained-native-hook.js +274 -0
- package/dist/services/review-copy.js +165 -0
- package/dist/services/review-deferral.js +23 -0
- package/dist/services/review-fix-handoff.js +82 -0
- package/dist/services/review-fix-intake-custody.js +17 -0
- package/dist/services/review-fix-stage-entry.js +43 -0
- package/dist/services/review-fix-stage-handlers.js +176 -0
- package/dist/services/review-fix-stage-results.js +86 -0
- package/dist/services/run-control-receipt.js +56 -0
- package/dist/services/run-control-worker.js +469 -0
- package/dist/services/run-control.js +1109 -0
- package/dist/services/run-controller-adapter.js +434 -0
- package/dist/services/run-controller-capture.js +186 -0
- package/dist/services/run-controller-process.js +226 -0
- package/dist/services/run-controller-recovery.js +335 -0
- package/dist/services/run-controller-state.js +106 -0
- package/dist/services/run-controller.js +1717 -0
- package/dist/services/run-engine-bindings.js +1 -1
- package/dist/services/run-fork.js +147 -0
- package/dist/services/run-health.js +149 -0
- package/dist/services/run-observations.js +152 -0
- package/dist/services/run-projection.js +22 -64
- package/dist/services/run-recovery-guard.js +107 -0
- package/dist/services/run-recovery-runtime.js +112 -0
- package/dist/services/run-recovery.js +485 -0
- package/dist/services/run-start-custody.js +189 -0
- package/dist/services/run-timeline.js +59 -0
- package/dist/services/runs.js +996 -271
- package/dist/services/runtime-budget.js +446 -0
- package/dist/services/runtime-command.js +43 -0
- package/dist/services/runtime-scope-capture.js +52 -0
- package/dist/services/runtime-scope-control.js +468 -0
- package/dist/services/runtime-scope-resume.js +605 -0
- package/dist/services/runtime-scope-stop.js +211 -0
- package/dist/services/runtime-scope-worker.js +314 -0
- package/dist/services/runtime-service.js +19 -14
- package/dist/services/schema-validation.js +10 -8
- package/dist/services/scope-writer-cleanup.js +27 -0
- package/dist/services/sessions.js +37 -91
- package/dist/services/setup.js +427 -0
- package/dist/services/stage-blocker.js +17 -7
- package/dist/services/stage-context.js +240 -18
- package/dist/services/stage-handlers.js +141 -0
- package/dist/services/stage-lifecycle.js +156 -119
- package/dist/services/stage-pause.js +222 -94
- package/dist/services/stage-report-renderer.js +230 -6
- package/dist/services/stage-work-graph.js +52 -0
- package/dist/services/technical-notes.js +31 -0
- package/dist/services/tooling.js +111 -44
- package/dist/services/usage.js +49 -101
- package/dist/services/verification-matrix.js +393 -0
- package/dist/services/version-status.js +1 -1
- package/dist/services/vnext-code-review.js +302 -91
- package/dist/services/vnext-code.js +325 -251
- package/dist/services/vnext-contracts.js +10 -1
- package/dist/services/vnext-execution-profile.js +80 -5
- package/dist/services/vnext-fanout.js +399 -20
- package/dist/services/vnext-merge.js +336 -114
- package/dist/services/vnext-plan-review.js +288 -133
- package/dist/services/vnext-plan.js +257 -110
- package/dist/services/vnext-protocolize.js +534 -96
- package/dist/services/vnext-specify.js +131 -84
- package/dist/services/vnext-workspace-policy.js +7 -2
- package/dist/services/work-registry.js +1950 -215
- package/dist/services/work-retry-context.js +55 -0
- package/dist/services/workspace-bootstrap.js +53 -15
- package/dist/services/workspace-files.js +85 -0
- package/dist/services/worktrees.js +108 -48
- package/dist/shared/entity-references.js +1 -0
- package/dist/shared/errors.js +27 -0
- package/dist/storage/agent-output.js +26 -0
- package/dist/storage/data-preservation.js +65 -0
- package/dist/storage/database.js +931 -40
- package/dist/storage/foreign-key-transaction.js +39 -0
- package/dist/storage/immutable-input.js +45 -0
- package/dist/storage/import-guard.js +159 -0
- package/dist/storage/memory-upgrade-schema-bootstrap.js +38 -0
- package/dist/storage/native-cleanup.js +52 -0
- package/dist/storage/paired-writer-migration.js +424 -0
- package/dist/storage/paths.js +17 -4
- package/dist/storage/projection-lock.js +73 -0
- package/dist/storage/work-references.js +23 -0
- package/dist/storage/writer-contract.js +96 -0
- package/dist/storage/writer-migration.js +346 -0
- package/dist/storage/writer-restore.js +217 -0
- package/dist/verification-components.json +384 -0
- package/package.json +52 -13
- package/tools/create-canon-release.mjs +33 -0
- package/tools/probe-codex-history.mjs +37 -0
- package/tools/produce-hybrid-release.mjs +41 -0
- package/tools/repair-paused-run-status.mjs +84 -0
- package/tools/verification-jobs.mjs +342 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { AppError } from "../shared/errors.js";
|
|
5
|
+
import { hybridDigest } from "./hybrid-contracts.js";
|
|
6
|
+
import { appendAudit } from "./audit.js";
|
|
7
|
+
import { projectCheckoutRoot } from "../storage/paths.js";
|
|
8
|
+
import { prepareMemoryFixRepairAdmission } from "./memory-fix-repair-admission.js";
|
|
9
|
+
import { RetainedMemoryRepairPublicationPlan } from "./memory-repair-publication-plan.js";
|
|
10
|
+
import { prepareMemoryFixDocumentPlan, applyMemoryFixDocumentStep, captureDistillBeforeDocuments, validateDistillBeforeDocuments, publishMemoryFixBeforeDocuments, memoryFixBeforeDocumentReferences } from "./distill-document-publication.js";
|
|
11
|
+
import { readFlowRunExecutionBundle } from "./runs.js";
|
|
12
|
+
import { prepareStagePacket, acceptStagePacket, resolveStagePublicationPath } from "./stage-report-renderer.js";
|
|
13
|
+
const intent = "memory_fix.publication_intent", complete = "memory_fix.publication_complete";
|
|
14
|
+
const key = (scope) => `memory_fix_publication:${hybridDigest({ project_id: scope.project_id, run_id: scope.run_id })}`;
|
|
15
|
+
function refuse(reason) {
|
|
16
|
+
throw new AppError("memory_fix_publication_invalid", "Repair publication requires its original admitted output and retained plan", 2, { reason, effect: "no_effect" });
|
|
17
|
+
}
|
|
18
|
+
const receipt = (binding, plan, completed = false) => ({
|
|
19
|
+
schema_id: completed ? "dd-flow/mb-fix-publication-complete@1" : "dd-flow/mb-fix-publication-intent@1",
|
|
20
|
+
run_id: binding.run_id, binding_sha256: hybridDigest(binding), plan_sha256: plan.sha256
|
|
21
|
+
});
|
|
22
|
+
/** SQL custody only, never current write admission or proof of independent
|
|
23
|
+
* verification. Consumers must match this binding to their own frozen RUN.
|
|
24
|
+
* Missing either the retained value or independent receipt is not a new intent.
|
|
25
|
+
*/
|
|
26
|
+
export function readMemoryFixPublication(context, scope) {
|
|
27
|
+
return context.db.readSnapshot(() => {
|
|
28
|
+
const row = context.db.get("SELECT value_json FROM runtime_config WHERE key=?", [key(scope)]);
|
|
29
|
+
const anchor = context.db.get("SELECT json_extract(index_json,'$.variables.\"memory_fix.publication\"') anchor FROM runs WHERE project_id=? AND id=?", [scope.project_id, scope.run_id])?.anchor;
|
|
30
|
+
const events = (type) => context.db.all("SELECT payload_json FROM audit_events WHERE project_id=? AND event_type=? AND json_extract(payload_json,'$.run_id')=? LIMIT 2", [scope.project_id, type, scope.run_id]);
|
|
31
|
+
const starts = events(intent), ends = events(complete);
|
|
32
|
+
if (!row && !starts.length && !ends.length && !anchor)
|
|
33
|
+
return null;
|
|
34
|
+
if (!row || !anchor || starts.length !== 1 || ends.length > 1 || Buffer.byteLength(row.value_json) > 180 * 1024 * 1024
|
|
35
|
+
|| [...starts, ...ends].some(event => Buffer.byteLength(event.payload_json) > 32768))
|
|
36
|
+
refuse("publication_custody_missing");
|
|
37
|
+
try {
|
|
38
|
+
const value = JSON.parse(row.value_json), binding = value.binding;
|
|
39
|
+
if (Object.keys(value).sort().join() !== "before_documents,binding,plan_json,plan_sha256" || !binding
|
|
40
|
+
|| binding.project_id !== scope.project_id || binding.run_id !== scope.run_id || typeof value.plan_json !== "string")
|
|
41
|
+
refuse("publication_binding_changed");
|
|
42
|
+
const plan = RetainedMemoryRepairPublicationPlan.restore(Buffer.from(value.plan_json), value.plan_sha256);
|
|
43
|
+
const beforeDocuments = validateDistillBeforeDocuments(plan, value.before_documents);
|
|
44
|
+
const paths = JSON.parse(plan.state(0).bytes().toString("utf8")).write_paths;
|
|
45
|
+
if (hybridDigest([...paths].sort()) !== hybridDigest([...binding.write_scope.paths].sort())
|
|
46
|
+
|| anchor !== hybridDigest(receipt(binding, plan))
|
|
47
|
+
|| hybridDigest(JSON.parse(starts[0].payload_json)) !== hybridDigest(receipt(binding, plan))
|
|
48
|
+
|| ends.length && hybridDigest(JSON.parse(ends[0].payload_json)) !== hybridDigest(receipt(binding, plan, true)))
|
|
49
|
+
refuse("publication_receipt_changed");
|
|
50
|
+
return { binding: structuredClone(binding), plan, beforeDocuments, completed: ends.length === 1 };
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (error instanceof AppError)
|
|
54
|
+
throw error;
|
|
55
|
+
return refuse("invalid_publication_custody");
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** Exact handoff bytes include removed paths and original retained text refs.
|
|
60
|
+
* Serialization alone is not publication, Stage acceptance or finding closure. */
|
|
61
|
+
export function memoryFixPublicationArtifact(binding, plan) {
|
|
62
|
+
const entries = new Map(plan.state(plan.actions().length).entries().map(entry => [entry.path, entry]));
|
|
63
|
+
return Buffer.from(JSON.stringify({ schema_id: "dd-flow/mb-fix-publication@1", binding, plan_sha256: plan.sha256,
|
|
64
|
+
documents: binding.write_scope.paths.map(logical => ({ path: logical, after: entries.get(logical) ?? null })),
|
|
65
|
+
before_documents: memoryFixBeforeDocumentReferences(plan), receipt: receipt(binding, plan, true) }));
|
|
66
|
+
}
|
|
67
|
+
export function readMemoryFixPublicationReference(context, retained, logical) {
|
|
68
|
+
if (!retained.completed)
|
|
69
|
+
refuse("publication_not_complete");
|
|
70
|
+
if (!logical || path.isAbsolute(logical) || logical.includes("\\") || logical.split("/").some(part => !part || part === "." || part === ".."))
|
|
71
|
+
refuse("invalid_publication_locator");
|
|
72
|
+
const { binding, plan } = retained;
|
|
73
|
+
const run = context.db.get("SELECT run_root FROM runs WHERE project_id=? AND id=?", [binding.project_id, binding.run_id]);
|
|
74
|
+
if (!run?.run_root)
|
|
75
|
+
refuse("run_home_required");
|
|
76
|
+
const file = path.join(run.run_root, logical), bytes = memoryFixPublicationArtifact(binding, plan);
|
|
77
|
+
const rows = context.db.all("SELECT payload_json FROM audit_events WHERE project_id=? AND event_type='flow_run.stage_packet' AND json_extract(payload_json,'$.run_id')=? AND json_extract(payload_json,'$.stage')='repair' AND json_extract(payload_json,'$.attempt')=? LIMIT 33", [binding.project_id, binding.run_id, binding.attempt]);
|
|
78
|
+
if (rows.length > 32 || rows.some(row => Buffer.byteLength(row.payload_json) > 8 * 1024 * 1024))
|
|
79
|
+
refuse("unbounded_publication_packets");
|
|
80
|
+
const packets = rows.map(row => JSON.parse(row.payload_json)).filter(packet => typeof packet.file === "string"
|
|
81
|
+
&& resolveStagePublicationPath(context, binding.project_id, binding.run_id, packet.file) === file);
|
|
82
|
+
if (!packets.length)
|
|
83
|
+
return null;
|
|
84
|
+
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
85
|
+
if (packets.some(packet => packet.sha256 !== sha256 || packet.base64 !== bytes.toString("base64")))
|
|
86
|
+
refuse("publication_packet_changed");
|
|
87
|
+
return { root: "run", path: logical, sha256 };
|
|
88
|
+
}
|
|
89
|
+
/** Internal publisher: actual active author + accepted intake, SQL intent before
|
|
90
|
+
* effects, exact retained prefix and effect-aware retry. No public registration,
|
|
91
|
+
* new Session allocation, independent verification or finding closure here. */
|
|
92
|
+
export function prepareMemoryFixPublication(context, input) {
|
|
93
|
+
const admission = prepareMemoryFixRepairAdmission(context, input), selected = admission.snapshot();
|
|
94
|
+
const proposal = structuredClone(input.proposal), scope = selected.intake.write_scope;
|
|
95
|
+
if (!proposal || Object.keys(proposal).join() !== "outputs" || !Array.isArray(proposal.outputs) || !proposal.outputs.length || proposal.outputs.length > 512
|
|
96
|
+
|| proposal.outputs.some(output => !output || Object.keys(output).sort().join() !== "content,finding_ids,path"
|
|
97
|
+
|| typeof output.path !== "string" || output.content !== null && typeof output.content !== "string"
|
|
98
|
+
|| !Array.isArray(output.finding_ids) || !output.finding_ids.length || new Set(output.finding_ids).size !== output.finding_ids.length
|
|
99
|
+
|| output.finding_ids.some(id => !scope.finding_ids.includes(id) || !selected.intake.routing.some(decision => decision.finding_id === id && decision.route === "memory_repair" && decision.write_paths.includes(output.path))))
|
|
100
|
+
|| hybridDigest(proposal.outputs.map(output => output.path).sort()) !== hybridDigest([...scope.paths].sort())
|
|
101
|
+
|| scope.finding_ids.some(id => !proposal.outputs.some(output => output.finding_ids.includes(id))))
|
|
102
|
+
refuse("output_scope_changed");
|
|
103
|
+
if (proposal.outputs.some(output => output.content !== null && Buffer.byteLength(output.content) > 16 * 1024 * 1024)
|
|
104
|
+
|| proposal.outputs.reduce((total, output) => total + (output.content === null ? 0 : Buffer.byteLength(output.content)), 0) > 64 * 1024 * 1024)
|
|
105
|
+
refuse("unbounded_output");
|
|
106
|
+
const { intake, run_root: runRoot, ...identity } = selected;
|
|
107
|
+
const checkoutRelative = path.relative(projectCheckoutRoot(context.ddFlowHome, selected.project_id), selected.workspace_root);
|
|
108
|
+
const managedCheckout = !!checkoutRelative && !path.isAbsolute(checkoutRelative)
|
|
109
|
+
&& checkoutRelative !== ".." && !checkoutRelative.startsWith(`..${path.sep}`);
|
|
110
|
+
// The bound project checkout is productive workspace, even when its owner
|
|
111
|
+
// stores it in Home. Other Home areas and every RUN root remain protected.
|
|
112
|
+
for (const protectedRoot of [...(managedCheckout ? [] : [context.ddFlowHome]), runRoot]) {
|
|
113
|
+
const root = fs.realpathSync(protectedRoot);
|
|
114
|
+
for (const output of proposal.outputs) {
|
|
115
|
+
const destination = path.join(selected.workspace_root, output.path), relative = path.relative(root, destination);
|
|
116
|
+
if (!relative || !path.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path.sep}`))
|
|
117
|
+
refuse("output_overlaps_runtime");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const binding = { ...identity, intake_sha256: intake.intake_sha256, source_observation_sha256: intake.source_observation_sha256,
|
|
121
|
+
user_inputs_sha256: intake.user_inputs_sha256, write_scope: scope, proposal_sha256: hybridDigest(proposal),
|
|
122
|
+
assignments: proposal.outputs.map(output => ({ path: output.path, finding_ids: [...output.finding_ids] })) };
|
|
123
|
+
const selection = { project_id: binding.project_id, run_id: binding.run_id };
|
|
124
|
+
const prior = readMemoryFixPublication(context, selection);
|
|
125
|
+
if (prior && hybridDigest(prior.binding) !== hybridDigest(binding))
|
|
126
|
+
refuse("original_publication_required");
|
|
127
|
+
if (!prior)
|
|
128
|
+
admission.assertOriginalSources();
|
|
129
|
+
const plan = prior?.plan ?? prepareMemoryFixDocumentPlan(selected.workspace_root, proposal.outputs.map(output => ({ path: output.path, bytes: output.content === null ? null : Buffer.from(output.content) })));
|
|
130
|
+
const beforeDocuments = prior?.beforeDocuments ?? captureDistillBeforeDocuments(selected.workspace_root, plan);
|
|
131
|
+
const bundle = readFlowRunExecutionBundle(context, input);
|
|
132
|
+
if (!bundle || bundle.sha256 !== selected.bundle_sha256)
|
|
133
|
+
refuse("bundle_changed");
|
|
134
|
+
const logical = `${bundle.descriptor.stage("repair").directory}/publication.json`, file = path.join(runRoot, logical);
|
|
135
|
+
const assertIntent = () => {
|
|
136
|
+
const current = readMemoryFixPublication(context, selection);
|
|
137
|
+
if (!current || hybridDigest(current.binding) !== hybridDigest(binding) || current.plan.sha256 !== plan.sha256)
|
|
138
|
+
refuse("publication_intent_changed");
|
|
139
|
+
return current;
|
|
140
|
+
};
|
|
141
|
+
const fence = () => { admission.assertCustody(context); admission.assertPlanSources(plan); assertIntent(); };
|
|
142
|
+
const applyStep = () => {
|
|
143
|
+
admission.assertPhysical();
|
|
144
|
+
admission.assertPlanSources(plan);
|
|
145
|
+
context.db.writeTransaction(() => {
|
|
146
|
+
admission.assertCustody(context);
|
|
147
|
+
const current = readMemoryFixPublication(context, selection);
|
|
148
|
+
if (current) {
|
|
149
|
+
assertIntent();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (prior)
|
|
153
|
+
refuse("publication_custody_missing");
|
|
154
|
+
const value = JSON.stringify({ binding, plan_json: plan.bytes().toString("utf8"), plan_sha256: plan.sha256, before_documents: beforeDocuments });
|
|
155
|
+
if (Buffer.byteLength(value) > 180 * 1024 * 1024)
|
|
156
|
+
refuse("unbounded_publication_custody");
|
|
157
|
+
context.db.run("INSERT INTO runtime_config(key,value_json,created_at,updated_at) VALUES (?,?,?,?)", [key(selection), value, context.now(), context.now()]);
|
|
158
|
+
appendAudit(context, { projectId: binding.project_id, eventType: intent, payload: receipt(binding, plan) });
|
|
159
|
+
context.db.run("UPDATE runs SET index_json=json_set(index_json,'$.variables.\"memory_fix.publication\"',?) WHERE project_id=? AND id=?", [hybridDigest(receipt(binding, plan)), binding.project_id, binding.run_id]);
|
|
160
|
+
assertIntent();
|
|
161
|
+
});
|
|
162
|
+
publishMemoryFixBeforeDocuments(runRoot, plan, beforeDocuments);
|
|
163
|
+
const result = applyMemoryFixDocumentStep(selected.workspace_root, plan, fence);
|
|
164
|
+
if (result.status !== "applied")
|
|
165
|
+
return result;
|
|
166
|
+
try {
|
|
167
|
+
fence();
|
|
168
|
+
const packet = prepareStagePacket(file, memoryFixPublicationArtifact(binding, plan));
|
|
169
|
+
context.db.writeTransaction(() => {
|
|
170
|
+
admission.assertCustody(context);
|
|
171
|
+
const current = assertIntent();
|
|
172
|
+
if (!current.completed)
|
|
173
|
+
appendAudit(context, { projectId: binding.project_id, eventType: complete, payload: receipt(binding, plan, true) });
|
|
174
|
+
const completed = assertIntent();
|
|
175
|
+
if (!readMemoryFixPublicationReference(context, completed, logical))
|
|
176
|
+
acceptStagePacket(context, { projectId: binding.project_id, runId: binding.run_id, stage: "repair", prepared: packet });
|
|
177
|
+
});
|
|
178
|
+
fence();
|
|
179
|
+
const reference = readMemoryFixPublicationReference(context, assertIntent(), logical);
|
|
180
|
+
if (!reference)
|
|
181
|
+
refuse("publication_reference_missing");
|
|
182
|
+
return { ...result, publication: reference };
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
throw new AppError("memory_fix_publication_pending", "Reconcile this retained publication before claiming repair completion", 1, { effect: "publication_pending", plan_sha256: plan.sha256, cause: error instanceof Error ? error.message : String(error) });
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
return { binding: () => structuredClone(binding), applyStep, apply: () => {
|
|
189
|
+
for (let step = 0; step <= plan.actions().length; step++) {
|
|
190
|
+
const result = applyStep();
|
|
191
|
+
if (result.status === "applied")
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
return refuse("publication_did_not_progress");
|
|
195
|
+
} };
|
|
196
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AppError } from "../shared/errors.js";
|
|
4
|
+
import { entityReferenceVariants } from "../shared/entity-references.js";
|
|
5
|
+
import { resolveProjectRoot } from "../storage/paths.js";
|
|
6
|
+
import { requireProjectByRoot } from "./projects.js";
|
|
7
|
+
import { readFlowRunExecutionBundle, assertPreparedRunBundleSqlAuthority } from "./runs.js";
|
|
8
|
+
import { readDescriptorStageInput } from "./descriptor-stage-coordinator.js";
|
|
9
|
+
import { readAcceptedDescriptorStageSettlement, readActiveDescriptorStageCoordinator } from "./descriptor-stage-settlement.js";
|
|
10
|
+
import { readAcceptedStageData } from "./stage-report-renderer.js";
|
|
11
|
+
import { stageLifecycleMatchKey } from "./hooks.js";
|
|
12
|
+
import { readMemoryFixSourceIntake, assertMemoryFixSourceIntakeCustody } from "./memory-fix-intake-custody.js";
|
|
13
|
+
import { readAcceptedMemoryFixIntakeEvidence } from "./memory-fix-intake-settlement.js";
|
|
14
|
+
import { readPreparedMemoryFlowUserInputs } from "./memory-flow-user-inputs.js";
|
|
15
|
+
import { observeRetainedMemoryFixSources, observeMemoryFixWriteTargets, memoryFixWriteTargetsFromBaseline } from "./memory-fix-sources.js";
|
|
16
|
+
import { RetainedMemoryRepairPublicationPlan } from "./memory-repair-publication-plan.js";
|
|
17
|
+
import { hybridDigest } from "./hybrid-contracts.js";
|
|
18
|
+
function refuse(reason) {
|
|
19
|
+
throw new AppError("memory_fix_repair_admission_invalid", "Repair requires its accepted intake and current delivered scope", 2, { reason, effect: "no_effect" });
|
|
20
|
+
}
|
|
21
|
+
/** Intake/Stage/user and active author Work custody, not publication permission.
|
|
22
|
+
* The publisher must also admit the author's exact output and retain its original
|
|
23
|
+
* plan before effects. Fresh plans require assertOriginalSources; resumed plans
|
|
24
|
+
* require assertPlanSources on that same SQL-retained plan, never a new baseline.
|
|
25
|
+
*/
|
|
26
|
+
export function prepareMemoryFixRepairAdmission(context, input) {
|
|
27
|
+
if (context.db.isOwnedWriteTransaction?.())
|
|
28
|
+
refuse("preparation_outside_writer_required");
|
|
29
|
+
const project = requireProjectByRoot(context, resolveProjectRoot(input.projectRoot));
|
|
30
|
+
const bundle = readFlowRunExecutionBundle(context, input);
|
|
31
|
+
if (!bundle || bundle.manifest.flow_id !== "mb-fix")
|
|
32
|
+
refuse("memory_fix_bundle_required");
|
|
33
|
+
const scope = { projectId: project.id, runId: input.runId, stage: "repair" };
|
|
34
|
+
const source = readMemoryFixSourceIntake(context, input, bundle);
|
|
35
|
+
const run = assertPreparedRunBundleSqlAuthority(context, scope, bundle);
|
|
36
|
+
const stage = readDescriptorStageInput(context, scope, bundle);
|
|
37
|
+
const accepted = readAcceptedStageData(context, { ...scope, stage: "intake" });
|
|
38
|
+
if (stage.input.predecessor?.stage !== "intake" || hybridDigest(stage.input.predecessor.result) !== hybridDigest(accepted.result))
|
|
39
|
+
refuse("accepted_intake_predecessor_required");
|
|
40
|
+
const keys = entityReferenceVariants(input.runId).map(reference => stageLifecycleMatchKey("stage_finish", reference, "intake", input.projectRoot));
|
|
41
|
+
const settlement = readAcceptedDescriptorStageSettlement(context, { ...scope, stage: "intake" }, bundle, keys);
|
|
42
|
+
const author = readActiveDescriptorStageCoordinator(context, scope, bundle);
|
|
43
|
+
const file = path.join(stage.runRoot, bundle.descriptor.stage("intake").directory, "intake-evidence.json");
|
|
44
|
+
const evidence = readAcceptedMemoryFixIntakeEvidence(context, scope, file);
|
|
45
|
+
if (evidence.intake_sha256 !== source.sha256 || !evidence.write_scope)
|
|
46
|
+
refuse("accepted_repair_scope_required");
|
|
47
|
+
const workspace = resolveProjectRoot(run.workspace_root);
|
|
48
|
+
const physical = () => {
|
|
49
|
+
if (fs.realpathSync(workspace) !== workspace)
|
|
50
|
+
refuse("workspace_identity_changed");
|
|
51
|
+
const stat = fs.lstatSync(workspace);
|
|
52
|
+
if (!stat.isDirectory())
|
|
53
|
+
refuse("workspace_identity_changed");
|
|
54
|
+
return { dev: stat.dev, ino: stat.ino };
|
|
55
|
+
};
|
|
56
|
+
const identity = physical();
|
|
57
|
+
const assertPhysical = () => {
|
|
58
|
+
if (context.db.isOwnedWriteTransaction?.())
|
|
59
|
+
refuse("physical_check_outside_writer_required");
|
|
60
|
+
if (hybridDigest(physical()) !== hybridDigest(identity))
|
|
61
|
+
refuse("workspace_identity_changed");
|
|
62
|
+
};
|
|
63
|
+
const assertCustody = (writer) => {
|
|
64
|
+
assertMemoryFixSourceIntakeCustody(writer, scope, bundle, source.sha256);
|
|
65
|
+
const current = assertPreparedRunBundleSqlAuthority(writer, scope, bundle);
|
|
66
|
+
if (current.workspace_root !== workspace || current.run_root !== stage.runRoot
|
|
67
|
+
|| hybridDigest(readDescriptorStageInput(writer, scope, bundle)) !== hybridDigest(stage)
|
|
68
|
+
|| hybridDigest(readAcceptedStageData(writer, { ...scope, stage: "intake" })) !== hybridDigest(accepted)
|
|
69
|
+
|| hybridDigest(readAcceptedDescriptorStageSettlement(writer, { ...scope, stage: "intake" }, bundle, keys)) !== hybridDigest(settlement)
|
|
70
|
+
|| hybridDigest(readActiveDescriptorStageCoordinator(writer, scope, bundle)) !== hybridDigest(author)
|
|
71
|
+
|| hybridDigest(readAcceptedMemoryFixIntakeEvidence(writer, scope, file)) !== hybridDigest(evidence)
|
|
72
|
+
|| hybridDigest(readPreparedMemoryFlowUserInputs(writer, scope, "mb-fix", bundle)) !== evidence.user_inputs_sha256)
|
|
73
|
+
refuse("accepted_scope_changed");
|
|
74
|
+
};
|
|
75
|
+
assertCustody(context);
|
|
76
|
+
const observe = () => { assertPhysical(); return observeRetainedMemoryFixSources(workspace, source.intake).snapshot(); };
|
|
77
|
+
return {
|
|
78
|
+
snapshot: () => structuredClone({ project_id: project.id, run_id: input.runId, workspace_root: workspace,
|
|
79
|
+
workspace_identity: identity, run_root: stage.runRoot, intake: evidence,
|
|
80
|
+
intake_result: accepted.result, bundle_sha256: bundle.sha256, author, attempt: stage.attempt, input_sha256: stage.inputSha256 }),
|
|
81
|
+
assertCustody, assertPhysical,
|
|
82
|
+
assertOriginalSources: () => {
|
|
83
|
+
const current = { ...observe(), write_targets: observeMemoryFixWriteTargets(workspace, evidence.write_scope.paths) };
|
|
84
|
+
if (hybridDigest(current) !== hybridDigest(evidence.source_observation))
|
|
85
|
+
refuse("sources_changed_since_intake");
|
|
86
|
+
},
|
|
87
|
+
assertPlanSources: (plan) => {
|
|
88
|
+
assertPhysical();
|
|
89
|
+
if (!(plan instanceof RetainedMemoryRepairPublicationPlan))
|
|
90
|
+
refuse("retained_plan_required");
|
|
91
|
+
const before = JSON.parse(plan.state(0).bytes().toString("utf8"));
|
|
92
|
+
if (hybridDigest([...before.write_paths].sort()) !== hybridDigest([...evidence.write_scope.paths].sort())
|
|
93
|
+
|| plan.state(0).canonicalWritePaths().size)
|
|
94
|
+
refuse("plan_scope_changed");
|
|
95
|
+
if (hybridDigest(memoryFixWriteTargetsFromBaseline(plan.state(0))) !== hybridDigest(evidence.source_observation.write_targets))
|
|
96
|
+
refuse("write_targets_changed_since_intake");
|
|
97
|
+
const current = plan.classify(workspace), entries = plan.state(current.completed).entries();
|
|
98
|
+
const actual = observe();
|
|
99
|
+
for (const original of evidence.source_observation.observations) {
|
|
100
|
+
const observed = actual.observations.find(item => item.path === original.path);
|
|
101
|
+
if (!observed)
|
|
102
|
+
refuse("source_inventory_changed");
|
|
103
|
+
if (before.write_paths.includes(original.path)) {
|
|
104
|
+
const baseline = before.entries.find((entry) => entry.path === original.path);
|
|
105
|
+
if ((baseline?.sha256 ?? null) !== original.current_sha256)
|
|
106
|
+
refuse("plan_rebased_after_intake");
|
|
107
|
+
const expected = entries.find(entry => entry.path === original.path);
|
|
108
|
+
if ((expected?.sha256 ?? null) !== observed.current_sha256)
|
|
109
|
+
refuse("source_differs_from_retained_prefix");
|
|
110
|
+
}
|
|
111
|
+
else if (hybridDigest(observed) !== hybridDigest(original))
|
|
112
|
+
refuse("sources_changed_since_intake");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { AppError } from "../shared/errors.js";
|
|
2
|
+
import { requireProjectByRoot } from "./projects.js";
|
|
3
|
+
import { hybridDigest } from "./hybrid-contracts.js";
|
|
4
|
+
import { appendAudit } from "./audit.js";
|
|
5
|
+
import { prepareMemoryFixRunBundle } from "./memory-fix-run-bundle.js";
|
|
6
|
+
import { PreparedInstalledFlowSource } from "./installed-flow-source.js";
|
|
7
|
+
import { FrozenGenericExecution } from "./generic-execution.js";
|
|
8
|
+
import { AdmittedFrozenEngine } from "./frozen-engine.js";
|
|
9
|
+
import { PreparedDescriptorRunStart } from "./descriptor-run-start.js";
|
|
10
|
+
import { readRunStartRequest } from "./run-start-custody.js";
|
|
11
|
+
import { prepareMemoryFixGitPolicy } from "./memory-fix-finish-integration.js";
|
|
12
|
+
const event = "memory_fix.request";
|
|
13
|
+
function refuse(reason) {
|
|
14
|
+
throw new AppError("memory_fix_request_invalid", "Repair launch requires its original retained request", 2, { reason, effect: "no_effect" });
|
|
15
|
+
}
|
|
16
|
+
function selection(input) {
|
|
17
|
+
return hybridDigest({ source_sha256: input.source.sha256, execution_sha256: input.execution.sha256,
|
|
18
|
+
engine_manifest_sha256: input.engine.manifestSha256, request_text: input.requestText,
|
|
19
|
+
source_run_id: input.sourceRunId, finding_ids: input.findingIds, git_executable: input.gitExecutable, git_policy: input.gitPolicy,
|
|
20
|
+
receipts: [...input.receipts ?? []], receipt_bytes: [...input.receiptBytes ?? []].map(([key, bytes]) => [key, Buffer.from(bytes).toString("base64")]) });
|
|
21
|
+
}
|
|
22
|
+
/** SQL-only lookup, also used by the allocation writer. No neighboring audit,
|
|
23
|
+
* current canon/profile settings or filesystem observation is consulted. */
|
|
24
|
+
export function readMemoryFixRequest(context, { projectRoot, requestId }) {
|
|
25
|
+
const scope = { projectRoot, requestId };
|
|
26
|
+
const project = context.db.get("SELECT id FROM projects WHERE root=? AND status='active'", [scope.projectRoot]);
|
|
27
|
+
if (!project)
|
|
28
|
+
refuse("project_not_registered");
|
|
29
|
+
const rows = context.db.all("SELECT payload_json FROM audit_events WHERE project_id=? AND event_type=? AND json_extract(payload_json,'$.scope.requestId')=? LIMIT 2", [project.id, event, scope.requestId]);
|
|
30
|
+
if (!rows.length)
|
|
31
|
+
return null;
|
|
32
|
+
if (rows.length !== 1 || Buffer.byteLength(rows[0].payload_json) > 48 * 1024 * 1024)
|
|
33
|
+
refuse("ambiguous_request");
|
|
34
|
+
let value;
|
|
35
|
+
try {
|
|
36
|
+
value = JSON.parse(rows[0].payload_json);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return refuse("invalid_request");
|
|
40
|
+
}
|
|
41
|
+
if (value.schema_id !== "dd-flow/memory-fix-request@1" || value.project_id !== project.id
|
|
42
|
+
|| hybridDigest(value.scope) !== hybridDigest(scope) || !/^[a-f0-9]{64}$/.test(value.selection_sha256)
|
|
43
|
+
|| !Number.isFinite(Date.parse(value.bound_at)) || typeof value.request_text !== "string" || !value.request_text.trim()
|
|
44
|
+
|| Buffer.byteLength(value.request_text) > 64 * 1024 || !Array.isArray(value.artifacts) || value.artifacts.length !== 2
|
|
45
|
+
|| new Set(value.artifacts.map(item => item.path)).size !== 2
|
|
46
|
+
|| value.artifacts.some(item => !["runtime/repair-intake.json", "runtime/git-policy.json"].includes(item.path)
|
|
47
|
+
|| typeof item.base64 !== "string" || !item.base64 || item.base64.length > 2 * 1024 * 1024
|
|
48
|
+
|| Buffer.from(item.base64, "base64").toString("base64") !== item.base64)
|
|
49
|
+
|| !Array.isArray(value.receipts) || !Array.isArray(value.receipt_bytes)
|
|
50
|
+
|| value.launch_selection !== null && (!value.launch_selection || typeof value.launch_selection !== "object" || Array.isArray(value.launch_selection))
|
|
51
|
+
|| value.execution?.scope?.projectRoot !== scope.projectRoot || value.execution.scope.requestId !== scope.requestId
|
|
52
|
+
|| value.execution.settings.flow_id !== "mb-fix")
|
|
53
|
+
refuse("request_scope_changed");
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
export function readMemoryFixRequestArtifacts(context, input) {
|
|
57
|
+
const frozen = input.execution.snapshot(), request = readMemoryFixRequest(context, { projectRoot: frozen.scope.projectRoot, requestId: frozen.scope.requestId });
|
|
58
|
+
if (request && request.selection_sha256 !== selection(input))
|
|
59
|
+
refuse("request_changed");
|
|
60
|
+
return request;
|
|
61
|
+
}
|
|
62
|
+
/** Allocation fence: metadata and retained bytes only. Historical RUN replay
|
|
63
|
+
* owns its bundle independently and does not need the neighboring source RUN. */
|
|
64
|
+
export function assertMemoryFixRequestBundle(context, projectId, bundle) {
|
|
65
|
+
const frozen = bundle.execution.snapshot(), request = readMemoryFixRequest(context, { projectRoot: frozen.scope.projectRoot, requestId: frozen.scope.requestId });
|
|
66
|
+
if (!request || request.project_id !== projectId || bundle.manifest.flow_id !== "mb-fix" || bundle.manifest.bootstrap_receipts.length
|
|
67
|
+
|| bundle.execution.sha256 !== request.execution_sha256 || bundle.manifest.descriptor.sha256 !== request.source.descriptor.sha256
|
|
68
|
+
|| bundle.blob("runtime/source-request.md").toString("utf8") !== request.request_text
|
|
69
|
+
|| bundle.manifest.engine_manifest.sha256 !== request.engine.manifest_sha256
|
|
70
|
+
|| request.artifacts.some(item => bundle.blob(item.path).toString("base64") !== item.base64)
|
|
71
|
+
|| request.source.blobs.some(item => bundle.blob(item.path).toString("base64") !== item.base64))
|
|
72
|
+
refuse("request_bundle_changed");
|
|
73
|
+
}
|
|
74
|
+
/** Preserve prepared input before allocating a RUN. IDs are selected only by
|
|
75
|
+
* common RUN-start, so another request may allocate between retain and start. */
|
|
76
|
+
export function retainMemoryFixRequest(context, input, launchSelection) {
|
|
77
|
+
if (context.db.isOwnedWriteTransaction?.())
|
|
78
|
+
refuse("preparation_outside_writer_required");
|
|
79
|
+
const frozen = input.execution.snapshot(), scope = { projectRoot: frozen.scope.projectRoot, requestId: frozen.scope.requestId };
|
|
80
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,95}$/.test(scope.requestId))
|
|
81
|
+
refuse("invalid_request_id");
|
|
82
|
+
const project = requireProjectByRoot(context, scope.projectRoot), digest = selection(input), prior = readMemoryFixRequest(context, scope);
|
|
83
|
+
const raw = structuredClone(launchSelection ?? null);
|
|
84
|
+
const assertSame = (request) => {
|
|
85
|
+
if (request.selection_sha256 !== digest || launchSelection !== undefined && hybridDigest(request.launch_selection) !== hybridDigest(raw))
|
|
86
|
+
refuse("request_changed");
|
|
87
|
+
};
|
|
88
|
+
if (prior) {
|
|
89
|
+
assertSame(prior);
|
|
90
|
+
return prior;
|
|
91
|
+
}
|
|
92
|
+
if (readRunStartRequest(context, project.id, scope.requestId))
|
|
93
|
+
refuse("foreign_run_request");
|
|
94
|
+
const bundle = prepareMemoryFixRunBundle(context, input), manifest = input.engine.manifest();
|
|
95
|
+
const value = { schema_id: "dd-flow/memory-fix-request@1", project_id: project.id, scope, selection_sha256: digest,
|
|
96
|
+
bound_at: input.boundAt, request_text: input.requestText, source_run_id: input.sourceRunId, finding_ids: [...input.findingIds],
|
|
97
|
+
source: input.source.snapshot(), source_sha256: input.source.sha256, execution: frozen, execution_sha256: input.execution.sha256,
|
|
98
|
+
engine: { identity: { package_name: manifest.package_name, package_version: manifest.package_version, engine_version: manifest.engine_version,
|
|
99
|
+
integrity_checksum: manifest.integrity.checksum, snapshot_root: manifest.snapshot_root }, manifest_sha256: input.engine.manifestSha256 },
|
|
100
|
+
git_executable: input.gitExecutable, git_policy: structuredClone(input.gitPolicy),
|
|
101
|
+
launch_selection: raw,
|
|
102
|
+
artifacts: ["runtime/repair-intake.json", "runtime/git-policy.json"].map(path => ({ path, base64: bundle.blob(path).toString("base64") })),
|
|
103
|
+
receipts: [...input.receipts ?? []], receipt_bytes: [...input.receiptBytes ?? []].map(([key, bytes]) => [key, Buffer.from(bytes).toString("base64")]) };
|
|
104
|
+
if (Buffer.byteLength(JSON.stringify(value)) > 48 * 1024 * 1024)
|
|
105
|
+
refuse("request_exceeds_bound");
|
|
106
|
+
return context.db.writeTransaction(() => {
|
|
107
|
+
const current = readMemoryFixRequest(context, scope);
|
|
108
|
+
if (current) {
|
|
109
|
+
assertSame(current);
|
|
110
|
+
return current;
|
|
111
|
+
}
|
|
112
|
+
if (readRunStartRequest(context, project.id, scope.requestId))
|
|
113
|
+
refuse("foreign_run_request");
|
|
114
|
+
appendAudit(context, { projectId: project.id, eventType: event, payload: value });
|
|
115
|
+
return value;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/** Existing allocations resume the common publisher. Before allocation only
|
|
119
|
+
* retained source/execution and input artifacts are restored, never refreshed. */
|
|
120
|
+
export function startMemoryFixRun(context, scope) {
|
|
121
|
+
const request = readMemoryFixRequest(context, scope);
|
|
122
|
+
if (!request)
|
|
123
|
+
refuse("original_request_required");
|
|
124
|
+
const allocation = readRunStartRequest(context, request.project_id, scope.requestId);
|
|
125
|
+
if (allocation) {
|
|
126
|
+
if (allocation.payload.initial_index.flow_kind !== "mb-fix")
|
|
127
|
+
refuse("foreign_run_request");
|
|
128
|
+
return PreparedDescriptorRunStart.restore(context, scope).apply(context);
|
|
129
|
+
}
|
|
130
|
+
const source = PreparedInstalledFlowSource.restoreRetained(request.source, request.source_sha256), receipts = new Map(request.receipts);
|
|
131
|
+
const execution = FrozenGenericExecution.restore(request.execution, request.execution_sha256, source.resolveRegisteredFlow(), request.execution.scope, receipts);
|
|
132
|
+
const engine = AdmittedFrozenEngine.admitSelection(request.engine.identity, request.engine.manifest_sha256);
|
|
133
|
+
const actualGit = prepareMemoryFixGitPolicy(context.env, { scope: { ...scope, workspaceRoot: request.execution.scope.workspace },
|
|
134
|
+
gitExecutable: request.git_executable, selection: request.git_policy });
|
|
135
|
+
if (actualGit.bytes.toString("base64") !== request.artifacts.find(item => item.path === actualGit.path)?.base64)
|
|
136
|
+
refuse("git_selection_changed_before_start");
|
|
137
|
+
const bundle = prepareMemoryFixRunBundle(context, { source, execution, engine, boundAt: request.bound_at, requestText: request.request_text,
|
|
138
|
+
sourceRunId: request.source_run_id, findingIds: request.finding_ids, gitExecutable: request.git_executable, gitPolicy: request.git_policy,
|
|
139
|
+
receipts, receiptBytes: new Map(request.receipt_bytes.map(([key, bytes]) => [key, Buffer.from(bytes, "base64")])) });
|
|
140
|
+
return PreparedDescriptorRunStart.prepare(context, { bundle }).apply(context);
|
|
141
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { AppError } from "../shared/errors.js";
|
|
3
|
+
import { PreparedInstalledFlowSource } from "./installed-flow-source.js";
|
|
4
|
+
import { FrozenGenericExecution } from "./generic-execution.js";
|
|
5
|
+
import { AdmittedFrozenEngine } from "./frozen-engine.js";
|
|
6
|
+
import { RetainedExecutionBundle } from "./execution-bundles.js";
|
|
7
|
+
import { nextDescriptorRunId } from "./descriptor-run-start.js";
|
|
8
|
+
import { bundledHandlerContext } from "./stage-handlers.js";
|
|
9
|
+
import { hybridDigest } from "./hybrid-contracts.js";
|
|
10
|
+
import { prepareMemoryFixSourceIntake } from "./memory-fix-intake-custody.js";
|
|
11
|
+
import { prepareMemoryFixGitPolicy } from "./memory-fix-finish-integration.js";
|
|
12
|
+
import { readMemoryFixRequestArtifacts } from "./memory-fix-request.js";
|
|
13
|
+
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
14
|
+
const encode = (value) => Buffer.from(JSON.stringify(value));
|
|
15
|
+
function refuse(reason) {
|
|
16
|
+
throw new AppError("memory_fix_run_bundle_invalid", "Repair RUN requires its original source selection, request and Git policy", 2, { reason, effect: "no_effect" });
|
|
17
|
+
}
|
|
18
|
+
/** Initial construction outside the writer only; no RUN or workspace is created.
|
|
19
|
+
* The request owner must retain this selection before allocation and use the
|
|
20
|
+
* retained bundle on retry, never recapture a later diagnostic or Git policy.
|
|
21
|
+
*/
|
|
22
|
+
export function prepareMemoryFixRunBundle(context, input) {
|
|
23
|
+
if (context.db.isOwnedWriteTransaction?.())
|
|
24
|
+
refuse("preparation_outside_writer_required");
|
|
25
|
+
if (!(input.source instanceof PreparedInstalledFlowSource) || !(input.execution instanceof FrozenGenericExecution)
|
|
26
|
+
|| !(input.engine instanceof AdmittedFrozenEngine) || !Number.isFinite(Date.parse(input.boundAt)))
|
|
27
|
+
refuse("unprepared_selection");
|
|
28
|
+
if (typeof input.requestText !== "string" || !input.requestText.trim() || Buffer.byteLength(input.requestText) > 64 * 1024)
|
|
29
|
+
refuse("original_request_required");
|
|
30
|
+
const frozen = input.execution.snapshot(), flow = input.source.resolveRegisteredFlow();
|
|
31
|
+
if (frozen.settings.flow_id !== "mb-fix" || flow.descriptor.id !== "mb-fix"
|
|
32
|
+
|| flow.sha256 !== frozen.settings.descriptor_sha256)
|
|
33
|
+
refuse("flow_selection_changed");
|
|
34
|
+
input.source.revalidate();
|
|
35
|
+
input.engine.admitMemoryFixFlow(input.source);
|
|
36
|
+
const retained = readMemoryFixRequestArtifacts(context, input);
|
|
37
|
+
const restored = (path) => ({ path, bytes: Buffer.from(retained.artifacts.find(item => item.path === path).base64, "base64") });
|
|
38
|
+
const intake = retained ? restored("runtime/repair-intake.json") : prepareMemoryFixSourceIntake(context, { projectRoot: frozen.scope.projectRoot,
|
|
39
|
+
sourceRunId: input.sourceRunId, findingIds: input.findingIds });
|
|
40
|
+
const git = retained ? restored("runtime/git-policy.json") : prepareMemoryFixGitPolicy(context.env, { scope: { requestId: frozen.scope.requestId,
|
|
41
|
+
projectRoot: frozen.scope.projectRoot, workspaceRoot: frozen.scope.workspace }, gitExecutable: input.gitExecutable, selection: input.gitPolicy });
|
|
42
|
+
const manifest = input.engine.manifest(), checksum = manifest.integrity.checksum;
|
|
43
|
+
if (typeof checksum !== "string")
|
|
44
|
+
refuse("engine_identity_missing");
|
|
45
|
+
const runId = nextDescriptorRunId(context, { projectRoot: frozen.scope.projectRoot, requestId: frozen.scope.requestId, slug: "mb-fix" });
|
|
46
|
+
const binding = { schema_id: "dd-flow/run-engine-binding@1", run_id: runId,
|
|
47
|
+
project_root: frozen.scope.projectRoot, bound_at: retained?.bound_at ?? input.boundAt, source: "run_creation", reason: "Request-bound selected Memory Bank repair",
|
|
48
|
+
engine: { package_name: manifest.package_name, package_version: manifest.package_version, engine_version: manifest.engine_version,
|
|
49
|
+
integrity_checksum: checksum, snapshot_root: manifest.snapshot_root }, probe: { status: "not_required", command: null } };
|
|
50
|
+
const blobs = input.source.blobs();
|
|
51
|
+
const put = (logical, content) => {
|
|
52
|
+
if (blobs.has(logical) || !content.length || content.length > 1024 * 1024)
|
|
53
|
+
refuse("bundle_path_collision_or_size");
|
|
54
|
+
blobs.set(logical, content);
|
|
55
|
+
return { path: logical, sha256: hash(content) };
|
|
56
|
+
};
|
|
57
|
+
put("runtime/source-request.md", Buffer.from(input.requestText));
|
|
58
|
+
put(intake.path, intake.bytes);
|
|
59
|
+
put(git.path, git.bytes);
|
|
60
|
+
for (const reference of [frozen.settings.attached_session_receipt, frozen.settings.delegation.native_capacity_receipt]) {
|
|
61
|
+
if (!reference)
|
|
62
|
+
continue;
|
|
63
|
+
const content = input.receiptBytes?.get(reference.sha256);
|
|
64
|
+
if (!content || hash(content) !== reference.sha256 || !input.receipts?.has(reference.sha256))
|
|
65
|
+
refuse("execution_receipt_missing");
|
|
66
|
+
put(reference.path, Buffer.from(content));
|
|
67
|
+
}
|
|
68
|
+
const profiles = { schema_id: "dd-flow/profile-settings@1", profiles: frozen.profiles, aliases: {}, default_profile: null };
|
|
69
|
+
const profile = put("runtime/profiles.json", encode({ ...profiles, revision: hybridDigest(profiles) }));
|
|
70
|
+
const execution = put("runtime/execution.json", encode(frozen.settings));
|
|
71
|
+
const engineBinding = put("runtime/engine-binding.json", encode(binding));
|
|
72
|
+
const engineManifest = put("runtime/engine-manifest.json", input.engine.manifestBytes());
|
|
73
|
+
const provenance = { canon: input.source.canonProvenance(), project_pack: null };
|
|
74
|
+
const bundle = { schema_id: "dd-flow/execution-bundle@1", run_id: runId, flow_id: "mb-fix",
|
|
75
|
+
descriptor: input.source.descriptorReference(), execution_settings: execution, profile_settings: profile,
|
|
76
|
+
engine_binding: engineBinding, engine_manifest: engineManifest, bootstrap_receipts: [], ...provenance,
|
|
77
|
+
inventory: [...blobs].map(([logical, content]) => ({ path: logical, sha256: hash(content) })) };
|
|
78
|
+
const bytes = encode(bundle);
|
|
79
|
+
return RetainedExecutionBundle.admit(bytes, hash(bytes), blobs, { runId, executionScope: frozen.scope,
|
|
80
|
+
bundleProjectRoot: frozen.scope.projectRoot, descriptorSha256: flow.sha256, engineChecksum: checksum,
|
|
81
|
+
engineBindingSha256: engineBinding.sha256, engineManifestSha256: engineManifest.sha256,
|
|
82
|
+
descriptorContext: bundledHandlerContext(new Map()), bundleProvenance: provenance, receipts: input.receipts ?? new Map() });
|
|
83
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AppError } from "../shared/errors.js";
|
|
2
|
+
import { resolveProjectRoot } from "../storage/paths.js";
|
|
3
|
+
import { requireProjectByRoot } from "./projects.js";
|
|
4
|
+
import { readFlowRunExecutionBundle, assertPreparedRunBundleSqlAuthority } from "./runs.js";
|
|
5
|
+
import { hybridDigest } from "./hybrid-contracts.js";
|
|
6
|
+
import { validateMemoryFixRouting } from "./diagnostic-repair-intake.js";
|
|
7
|
+
import { readMemoryFixSourceIntake, assertMemoryFixSourceIntakeCustody } from "./memory-fix-intake-custody.js";
|
|
8
|
+
import { observeRetainedMemoryFixSources, observeMemoryFixWriteTargets } from "./memory-fix-sources.js";
|
|
9
|
+
import { readPreparedMemoryFlowUserInputs } from "./memory-flow-user-inputs.js";
|
|
10
|
+
import { assertMemoryRepairWritePaths } from "./memory-review-correction-plan.js";
|
|
11
|
+
function refuse(reason) {
|
|
12
|
+
throw new AppError("memory_fix_scope_invalid", "Memory repair scope requires the selected findings and actual delivered user agreement", 2, { reason, effect: "no_effect" });
|
|
13
|
+
}
|
|
14
|
+
/** Prepares scope evidence, not semantic consent, Stage settlement or permission
|
|
15
|
+
* to apply files. The active intake coordinator must read the full delivered
|
|
16
|
+
* conversation, assess drift and bind its decision through the ordinary hook.
|
|
17
|
+
* Later publication must fence this same input set and original baseline again.
|
|
18
|
+
*/
|
|
19
|
+
export function prepareMemoryFixScopeEvidence(context, input) {
|
|
20
|
+
if (context.db.isOwnedWriteTransaction?.())
|
|
21
|
+
refuse("preparation_outside_writer_required");
|
|
22
|
+
const project = requireProjectByRoot(context, resolveProjectRoot(input.projectRoot));
|
|
23
|
+
const bundle = readFlowRunExecutionBundle(context, input);
|
|
24
|
+
if (!bundle || bundle.manifest.flow_id !== "mb-fix")
|
|
25
|
+
refuse("memory_fix_bundle_required");
|
|
26
|
+
const scope = { projectId: project.id, runId: input.runId };
|
|
27
|
+
const run = assertPreparedRunBundleSqlAuthority(context, scope, bundle);
|
|
28
|
+
const source = readMemoryFixSourceIntake(context, input, bundle);
|
|
29
|
+
const routing = validateMemoryFixRouting(source.intake.selected_findings.map(finding => finding.id), input.routing);
|
|
30
|
+
const users = readPreparedMemoryFlowUserInputs(context, scope, "mb-fix", bundle), userInputsSha256 = hybridDigest(users);
|
|
31
|
+
const writeScope = structuredClone(input.writeScope);
|
|
32
|
+
const repairs = routing.filter(decision => decision.route === "memory_repair").map(decision => decision.finding_id);
|
|
33
|
+
if (!repairs.length) {
|
|
34
|
+
if (writeScope !== null)
|
|
35
|
+
refuse("scope_without_repair_findings");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (!writeScope || typeof writeScope !== "object" || Array.isArray(writeScope)
|
|
39
|
+
|| Object.keys(writeScope).sort().join() !== "approval_source,finding_ids,paths,user_inputs_sha256"
|
|
40
|
+
|| !Array.isArray(writeScope.finding_ids) || !Array.isArray(writeScope.paths)
|
|
41
|
+
|| hybridDigest(writeScope.finding_ids) !== hybridDigest(repairs))
|
|
42
|
+
refuse("exact_selected_scope_required");
|
|
43
|
+
assertMemoryRepairWritePaths(writeScope.paths);
|
|
44
|
+
const paths = [...new Set(routing.flatMap(decision => decision.write_paths))].sort();
|
|
45
|
+
if (hybridDigest([...writeScope.paths].sort()) !== hybridDigest(paths))
|
|
46
|
+
refuse("routing_write_scope_changed");
|
|
47
|
+
const agreement = writeScope.approval_source;
|
|
48
|
+
if (!agreement || Object.keys(agreement).sort().join() !== "path,root,sha256" || agreement.root !== "run"
|
|
49
|
+
|| !users.sources.some(packet => ["request", "answer"].includes(packet.role)
|
|
50
|
+
&& packet.path === agreement.path && packet.sha256 === agreement.sha256))
|
|
51
|
+
refuse("delivered_agreement_required");
|
|
52
|
+
if (writeScope.user_inputs_sha256 !== userInputsSha256)
|
|
53
|
+
refuse("user_inputs_changed");
|
|
54
|
+
}
|
|
55
|
+
const workspaceRoot = resolveProjectRoot(run.workspace_root), runRoot = run.run_root;
|
|
56
|
+
if (workspaceRoot !== run.workspace_root || !runRoot)
|
|
57
|
+
refuse("workspace_identity_required");
|
|
58
|
+
const observation = observeRetainedMemoryFixSources(workspaceRoot, source.intake);
|
|
59
|
+
const writeTargets = observeMemoryFixWriteTargets(workspaceRoot, writeScope?.paths ?? []);
|
|
60
|
+
const sourceObservation = { ...observation.snapshot(), write_targets: writeTargets };
|
|
61
|
+
const evidence = { intake_sha256: source.sha256, user_inputs_sha256: userInputsSha256,
|
|
62
|
+
workspace_root: workspaceRoot, routing, write_scope: writeScope, source_observation: sourceObservation,
|
|
63
|
+
source_observation_sha256: hybridDigest(sourceObservation) };
|
|
64
|
+
return { snapshot: () => structuredClone(evidence), assertSourcesCurrent: () => {
|
|
65
|
+
if (context.db.isOwnedWriteTransaction?.())
|
|
66
|
+
refuse("physical_observation_outside_writer_required");
|
|
67
|
+
observation.revalidate();
|
|
68
|
+
if (hybridDigest(observeMemoryFixWriteTargets(workspaceRoot, writeScope?.paths ?? [])) !== hybridDigest(writeTargets))
|
|
69
|
+
refuse("write_targets_changed");
|
|
70
|
+
}, assertCustody: (writer) => {
|
|
71
|
+
assertMemoryFixSourceIntakeCustody(writer, scope, bundle, source.sha256);
|
|
72
|
+
const current = assertPreparedRunBundleSqlAuthority(writer, scope, bundle);
|
|
73
|
+
if (current.workspace_root !== workspaceRoot || current.run_root !== runRoot)
|
|
74
|
+
refuse("workspace_identity_changed");
|
|
75
|
+
if (hybridDigest(readPreparedMemoryFlowUserInputs(writer, scope, "mb-fix", bundle)) !== userInputsSha256)
|
|
76
|
+
refuse("user_inputs_changed");
|
|
77
|
+
} };
|
|
78
|
+
}
|