@wildo-ai/dev-companion 1.1.8 → 1.1.9
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/bin/companion-supervisor.d.mts +33 -0
- package/bin/companion-supervisor.mjs +174 -0
- package/bin/wildo-dev-companion-supervised.mjs +16 -0
- package/dist/esm/brand/models/logo-generation.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/brand/models/logo-generation.actors-system.definitions.js +8 -2
- package/dist/esm/brand/models/logo-generation.actors-system.definitions.js.map +1 -1
- package/dist/esm/brand/models/logo-judge.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/brand/models/logo-judge.actors-system.definitions.js +8 -2
- package/dist/esm/brand/models/logo-judge.actors-system.definitions.js.map +1 -1
- package/dist/esm/brand/services/brand-accept.companion.service.d.ts +1 -1
- package/dist/esm/brand/services/brand-accept.companion.service.d.ts.map +1 -1
- package/dist/esm/brand/services/brand-accept.companion.service.js +9 -11
- package/dist/esm/brand/services/brand-accept.companion.service.js.map +1 -1
- package/dist/esm/claude-cli/models/application-coding-run-checkpoint.models.d.ts +21 -0
- package/dist/esm/claude-cli/models/application-coding-run-checkpoint.models.d.ts.map +1 -1
- package/dist/esm/claude-cli/models/application-coding-run-checkpoint.models.js +33 -1
- package/dist/esm/claude-cli/models/application-coding-run-checkpoint.models.js.map +1 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +41 -2
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts.map +1 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js +43 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
- package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts +57 -1
- package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts.map +1 -1
- package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js +75 -1
- package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js.map +1 -1
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts +90 -5
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +242 -22
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
- package/dist/esm/companion-api/companion-api.schemas.d.ts +23 -2
- package/dist/esm/companion-api/companion-api.schemas.d.ts.map +1 -1
- package/dist/esm/companion-api/companion-api.schemas.js +13 -2
- package/dist/esm/companion-api/companion-api.schemas.js.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.d.ts +63 -7
- package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.js +315 -39
- package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
- package/dist/esm/core/config/primary-language.companion.utils.d.ts +5 -4
- package/dist/esm/core/config/primary-language.companion.utils.d.ts.map +1 -1
- package/dist/esm/core/config/primary-language.companion.utils.js +5 -4
- package/dist/esm/core/config/primary-language.companion.utils.js.map +1 -1
- package/dist/esm/core/context/application-module-generations.companion.d.ts +103 -0
- package/dist/esm/core/context/application-module-generations.companion.d.ts.map +1 -0
- package/dist/esm/core/context/application-module-generations.companion.js +313 -0
- package/dist/esm/core/context/application-module-generations.companion.js.map +1 -0
- package/dist/esm/core/context/companion-package-loaders.companion.d.ts +19 -19
- package/dist/esm/core/context/companion-package-loaders.companion.d.ts.map +1 -1
- package/dist/esm/core/context/companion-package-loaders.companion.js +52 -40
- package/dist/esm/core/context/companion-package-loaders.companion.js.map +1 -1
- package/dist/esm/core/inject/models/container.d.ts.map +1 -1
- package/dist/esm/core/inject/models/container.js +4 -0
- package/dist/esm/core/inject/models/container.js.map +1 -1
- package/dist/esm/core/inject/models/service-types.d.ts +4 -0
- package/dist/esm/core/inject/models/service-types.d.ts.map +1 -1
- package/dist/esm/core/inject/models/service-types.js +4 -0
- package/dist/esm/core/inject/models/service-types.js.map +1 -1
- package/dist/esm/core/introspection/resources/creation-console-answer.companion.d.ts +15 -1
- package/dist/esm/core/introspection/resources/creation-console-answer.companion.d.ts.map +1 -1
- package/dist/esm/core/introspection/resources/creation-console-answer.companion.js +38 -3
- package/dist/esm/core/introspection/resources/creation-console-answer.companion.js.map +1 -1
- package/dist/esm/core/introspection/resources/creation-console-projection.companion.d.ts +21 -0
- package/dist/esm/core/introspection/resources/creation-console-projection.companion.d.ts.map +1 -1
- package/dist/esm/core/introspection/resources/creation-console-projection.companion.js +64 -25
- package/dist/esm/core/introspection/resources/creation-console-projection.companion.js.map +1 -1
- package/dist/esm/core/introspection/resources/creation-home-projection.companion.d.ts.map +1 -1
- package/dist/esm/core/introspection/resources/creation-home-projection.companion.js +2 -0
- package/dist/esm/core/introspection/resources/creation-home-projection.companion.js.map +1 -1
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.d.ts +0 -28
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.js +192 -19
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js +27 -5
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/resources/launch-blockers.companion.d.ts +47 -0
- package/dist/esm/core/introspection/resources/launch-blockers.companion.d.ts.map +1 -0
- package/dist/esm/core/introspection/resources/launch-blockers.companion.js +98 -0
- package/dist/esm/core/introspection/resources/launch-blockers.companion.js.map +1 -0
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts +6 -1
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.js +20 -1
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.d.ts +34 -8
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.js +61 -12
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/services/introspection-input-closure.companion.d.ts +44 -0
- package/dist/esm/core/introspection/services/introspection-input-closure.companion.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-input-closure.companion.js +104 -0
- package/dist/esm/core/introspection/services/introspection-input-closure.companion.js.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts +41 -22
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js +64 -47
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/subprocess/expert-persona-brief.renderer.d.ts +7 -1
- package/dist/esm/core/introspection/subprocess/expert-persona-brief.renderer.d.ts.map +1 -1
- package/dist/esm/core/introspection/subprocess/expert-persona-brief.renderer.js +13 -4
- package/dist/esm/core/introspection/subprocess/expert-persona-brief.renderer.js.map +1 -1
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts.map +1 -1
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js +7 -0
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js.map +1 -1
- package/dist/esm/core/lock/wildo-saas-lock.schemas.d.ts +4 -4
- package/dist/esm/core/runtime/companion-env-file.d.ts +39 -9
- package/dist/esm/core/runtime/companion-env-file.d.ts.map +1 -1
- package/dist/esm/core/runtime/companion-env-file.js +75 -16
- package/dist/esm/core/runtime/companion-env-file.js.map +1 -1
- package/dist/esm/core/runtime/services/start-companion-application.service.d.ts +7 -3
- package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
- package/dist/esm/core/runtime/services/start-companion-application.service.js +29 -11
- package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
- package/dist/esm/core/utils/bounded-concurrency.utils.d.ts +17 -0
- package/dist/esm/core/utils/bounded-concurrency.utils.d.ts.map +1 -0
- package/dist/esm/core/utils/bounded-concurrency.utils.js +37 -0
- package/dist/esm/core/utils/bounded-concurrency.utils.js.map +1 -0
- package/dist/esm/core/utils/derived-input-signature.companion.utils.d.ts +10 -1
- package/dist/esm/core/utils/derived-input-signature.companion.utils.d.ts.map +1 -1
- package/dist/esm/core/utils/derived-input-signature.companion.utils.js +9 -2
- package/dist/esm/core/utils/derived-input-signature.companion.utils.js.map +1 -1
- package/dist/esm/creation-conversation/creation-conversation.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/creation-conversation/creation-conversation.actors-system.definitions.js +2 -0
- package/dist/esm/creation-conversation/creation-conversation.actors-system.definitions.js.map +1 -1
- package/dist/esm/creation-conversation/creation-conversation.function-tools.d.ts.map +1 -1
- package/dist/esm/creation-conversation/creation-conversation.function-tools.js +66 -6
- package/dist/esm/creation-conversation/creation-conversation.function-tools.js.map +1 -1
- package/dist/esm/deliberations/models/deliberation-agents.actors-system.definitions.d.ts +0 -17
- package/dist/esm/deliberations/models/deliberation-agents.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/deliberations/models/deliberation-agents.actors-system.definitions.js +10 -4
- package/dist/esm/deliberations/models/deliberation-agents.actors-system.definitions.js.map +1 -1
- package/dist/esm/email/services/email-template.companion.service.d.ts +6 -1
- package/dist/esm/email/services/email-template.companion.service.d.ts.map +1 -1
- package/dist/esm/email/services/email-template.companion.service.js +4 -1
- package/dist/esm/email/services/email-template.companion.service.js.map +1 -1
- package/dist/esm/expert-personas/models/expert-persona-critique.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/expert-personas/models/expert-persona-critique.actors-system.definitions.js +8 -2
- package/dist/esm/expert-personas/models/expert-persona-critique.actors-system.definitions.js.map +1 -1
- package/dist/esm/expert-personas/models/expert-persona-derivation.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/expert-personas/models/expert-persona-derivation.actors-system.definitions.js +8 -2
- package/dist/esm/expert-personas/models/expert-persona-derivation.actors-system.definitions.js.map +1 -1
- package/dist/esm/expert-personas/services/expert-persona.companion.service.d.ts.map +1 -1
- package/dist/esm/expert-personas/services/expert-persona.companion.service.js +7 -7
- package/dist/esm/expert-personas/services/expert-persona.companion.service.js.map +1 -1
- package/dist/esm/i18n/composite_views/app.creation-conversation.en.d.ts.map +1 -1
- package/dist/esm/i18n/composite_views/app.creation-conversation.en.js +41 -1
- package/dist/esm/i18n/composite_views/app.creation-conversation.en.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchAspects.en.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchAspects.en.js +7 -0
- package/dist/esm/i18n/resources/workbenchAspects.en.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.en.d.ts +5 -0
- package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.en.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.en.js +5 -0
- package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.en.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts +1 -1
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js +2 -1
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchDossierEntries.en.d.ts +46 -0
- package/dist/esm/i18n/resources/workbenchDossierEntries.en.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchDossierEntries.en.js +12 -0
- package/dist/esm/i18n/resources/workbenchDossierEntries.en.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +266 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +91 -5
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -1
- package/dist/esm/i18n/system_enums/application-creation.en.d.ts +41 -0
- package/dist/esm/i18n/system_enums/application-creation.en.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/application-creation.en.js +45 -1
- package/dist/esm/i18n/system_enums/application-creation.en.js.map +1 -1
- package/dist/esm/i18n/system_enums/localization.en.d.ts +82 -0
- package/dist/esm/i18n/system_enums/localization.en.d.ts.map +1 -0
- package/dist/esm/i18n/system_enums/localization.en.js +82 -0
- package/dist/esm/i18n/system_enums/localization.en.js.map +1 -0
- package/dist/esm/i18n/system_enums/risk-register.en.d.ts +1 -0
- package/dist/esm/i18n/system_enums/risk-register.en.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/risk-register.en.js +1 -0
- package/dist/esm/i18n/system_enums/risk-register.en.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-dossier.en.d.ts +10 -0
- package/dist/esm/i18n/system_enums/workbench-dossier.en.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-dossier.en.js +13 -0
- package/dist/esm/i18n/system_enums/workbench-dossier.en.js.map +1 -1
- package/dist/esm/i18n-labelling/models/labelling-progress.models.d.ts +43 -0
- package/dist/esm/i18n-labelling/models/labelling-progress.models.d.ts.map +1 -0
- package/dist/esm/i18n-labelling/models/labelling-progress.models.js +34 -0
- package/dist/esm/i18n-labelling/models/labelling-progress.models.js.map +1 -0
- package/dist/esm/i18n-labelling/services/labellize-orchestrator.companion.service.d.ts +8 -0
- package/dist/esm/i18n-labelling/services/labellize-orchestrator.companion.service.d.ts.map +1 -1
- package/dist/esm/i18n-labelling/services/labellize-orchestrator.companion.service.js +97 -56
- package/dist/esm/i18n-labelling/services/labellize-orchestrator.companion.service.js.map +1 -1
- package/dist/esm/i18n-labelling/services/translate-orchestrator.companion.service.d.ts +18 -0
- package/dist/esm/i18n-labelling/services/translate-orchestrator.companion.service.d.ts.map +1 -1
- package/dist/esm/i18n-labelling/services/translate-orchestrator.companion.service.js +269 -153
- package/dist/esm/i18n-labelling/services/translate-orchestrator.companion.service.js.map +1 -1
- package/dist/esm/i18n-labelling/utils/labelling-concurrency.utils.d.ts +41 -0
- package/dist/esm/i18n-labelling/utils/labelling-concurrency.utils.d.ts.map +1 -0
- package/dist/esm/i18n-labelling/utils/labelling-concurrency.utils.js +47 -0
- package/dist/esm/i18n-labelling/utils/labelling-concurrency.utils.js.map +1 -0
- package/dist/esm/i18n-labelling/utils/per-unit-file.utils.d.ts +12 -0
- package/dist/esm/i18n-labelling/utils/per-unit-file.utils.d.ts.map +1 -1
- package/dist/esm/i18n-labelling/utils/per-unit-file.utils.js +10 -2
- package/dist/esm/i18n-labelling/utils/per-unit-file.utils.js.map +1 -1
- package/dist/esm/i18n-labelling/utils/staged-label-file-writer.utils.d.ts +89 -0
- package/dist/esm/i18n-labelling/utils/staged-label-file-writer.utils.d.ts.map +1 -0
- package/dist/esm/i18n-labelling/utils/staged-label-file-writer.utils.js +229 -0
- package/dist/esm/i18n-labelling/utils/staged-label-file-writer.utils.js.map +1 -0
- package/dist/esm/meta-workflows/models/build-task-rearm.models.d.ts +67 -1
- package/dist/esm/meta-workflows/models/build-task-rearm.models.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/build-task-rearm.models.js +64 -0
- package/dist/esm/meta-workflows/models/build-task-rearm.models.js.map +1 -1
- package/dist/esm/meta-workflows/models/creation-intervention.models.d.ts +308 -0
- package/dist/esm/meta-workflows/models/creation-intervention.models.d.ts.map +1 -0
- package/dist/esm/meta-workflows/models/creation-intervention.models.js +365 -0
- package/dist/esm/meta-workflows/models/creation-intervention.models.js.map +1 -0
- package/dist/esm/meta-workflows/models/generation-step-progress.models.d.ts +61 -0
- package/dist/esm/meta-workflows/models/generation-step-progress.models.d.ts.map +1 -0
- package/dist/esm/meta-workflows/models/generation-step-progress.models.js +58 -0
- package/dist/esm/meta-workflows/models/generation-step-progress.models.js.map +1 -0
- package/dist/esm/meta-workflows/models/meta-workflows-lane.models.d.ts +10 -6
- package/dist/esm/meta-workflows/models/meta-workflows-lane.models.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/meta-workflows-lane.models.js +11 -6
- package/dist/esm/meta-workflows/models/meta-workflows-lane.models.js.map +1 -1
- package/dist/esm/meta-workflows/models/playbook-run-checkpoint.models.d.ts +3 -0
- package/dist/esm/meta-workflows/models/playbook-run-checkpoint.models.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/playbook-run-checkpoint.models.js +8 -1
- package/dist/esm/meta-workflows/models/playbook-run-checkpoint.models.js.map +1 -1
- package/dist/esm/meta-workflows/models/playbook-run-record.models.d.ts +26 -0
- package/dist/esm/meta-workflows/models/playbook-run-record.models.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/playbook-run-record.models.js +66 -10
- package/dist/esm/meta-workflows/models/playbook-run-record.models.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.d.ts +13 -0
- package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.d.ts.map +1 -0
- package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.js +33 -0
- package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.js.map +1 -0
- package/dist/esm/meta-workflows/services/application-assembly-repair.companion.utils.d.ts +145 -0
- package/dist/esm/meta-workflows/services/application-assembly-repair.companion.utils.d.ts.map +1 -0
- package/dist/esm/meta-workflows/services/application-assembly-repair.companion.utils.js +179 -0
- package/dist/esm/meta-workflows/services/application-assembly-repair.companion.utils.js.map +1 -0
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +376 -17
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +805 -39
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts +93 -7
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js +142 -25
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts +120 -3
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js +325 -16
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.js +15 -6
- package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-maturity-executor.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-maturity-executor.companion.service.js +10 -11
- package/dist/esm/meta-workflows/services/application-maturity-executor.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/capability-composition-executor.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/capability-composition-executor.companion.service.js +10 -11
- package/dist/esm/meta-workflows/services/capability-composition-executor.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.d.ts +82 -0
- package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.d.ts.map +1 -0
- package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.js +291 -0
- package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.js.map +1 -0
- package/dist/esm/meta-workflows/services/creation-lane-preflight.companion.service.d.ts +60 -0
- package/dist/esm/meta-workflows/services/creation-lane-preflight.companion.service.d.ts.map +1 -0
- package/dist/esm/meta-workflows/services/creation-lane-preflight.companion.service.js +66 -0
- package/dist/esm/meta-workflows/services/creation-lane-preflight.companion.service.js.map +1 -0
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts +53 -0
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts.map +1 -0
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js +164 -0
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js.map +1 -0
- package/dist/esm/meta-workflows/services/dossier-write-queue.companion.utils.d.ts +37 -0
- package/dist/esm/meta-workflows/services/dossier-write-queue.companion.utils.d.ts.map +1 -0
- package/dist/esm/meta-workflows/services/dossier-write-queue.companion.utils.js +52 -0
- package/dist/esm/meta-workflows/services/dossier-write-queue.companion.utils.js.map +1 -0
- package/dist/esm/meta-workflows/services/dossier.companion.service.d.ts +74 -14
- package/dist/esm/meta-workflows/services/dossier.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/dossier.companion.service.js +180 -28
- package/dist/esm/meta-workflows/services/dossier.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/foundation-executor.companion.service.d.ts +2 -3
- package/dist/esm/meta-workflows/services/foundation-executor.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/foundation-executor.companion.service.js +2 -8
- package/dist/esm/meta-workflows/services/foundation-executor.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/interview-answer-proposal.companion.d.ts +67 -0
- package/dist/esm/meta-workflows/services/interview-answer-proposal.companion.d.ts.map +1 -0
- package/dist/esm/meta-workflows/services/interview-answer-proposal.companion.js +64 -0
- package/dist/esm/meta-workflows/services/interview-answer-proposal.companion.js.map +1 -0
- package/dist/esm/meta-workflows/services/playbook-instance.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-instance.companion.service.js +11 -3
- package/dist/esm/meta-workflows/services/playbook-instance.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts +92 -4
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js +328 -7
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +105 -6
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +309 -39
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-spend-meter.companion.service.d.ts +62 -1
- package/dist/esm/meta-workflows/services/playbook-spend-meter.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-spend-meter.companion.service.js +152 -2
- package/dist/esm/meta-workflows/services/playbook-spend-meter.companion.service.js.map +1 -1
- package/package.json +22 -18
- package/dist/esm/.tsbuildinfo +0 -1
- package/dist/esm/__tests__/asset-noop.d.ts +0 -3
- package/dist/esm/__tests__/asset-noop.d.ts.map +0 -1
- package/dist/esm/__tests__/asset-noop.js +0 -2
- package/dist/esm/__tests__/asset-noop.js.map +0 -1
- package/dist/esm/__tests__/chdir-dogfood-app.setup.d.ts +0 -2
- package/dist/esm/__tests__/chdir-dogfood-app.setup.d.ts.map +0 -1
- package/dist/esm/__tests__/chdir-dogfood-app.setup.js +0 -44
- package/dist/esm/__tests__/chdir-dogfood-app.setup.js.map +0 -1
- package/dist/esm/__tests__/internal-test-view.d.ts +0 -39
- package/dist/esm/__tests__/internal-test-view.d.ts.map +0 -1
- package/dist/esm/__tests__/internal-test-view.js +0 -2
- package/dist/esm/__tests__/internal-test-view.js.map +0 -1
- package/dist/esm/claude-cli/services/__tests__/support/in-memory-coding-actor-plane.d.ts +0 -50
- package/dist/esm/claude-cli/services/__tests__/support/in-memory-coding-actor-plane.d.ts.map +0 -1
- package/dist/esm/claude-cli/services/__tests__/support/in-memory-coding-actor-plane.js +0 -157
- package/dist/esm/claude-cli/services/__tests__/support/in-memory-coding-actor-plane.js.map +0 -1
- package/dist/esm/meta-workflows/services/__tests__/application-build-task-coding.companion.test-fixtures.d.ts +0 -8
- package/dist/esm/meta-workflows/services/__tests__/application-build-task-coding.companion.test-fixtures.d.ts.map +0 -1
- package/dist/esm/meta-workflows/services/__tests__/application-build-task-coding.companion.test-fixtures.js +0 -43
- package/dist/esm/meta-workflows/services/__tests__/application-build-task-coding.companion.test-fixtures.js.map +0 -1
- package/dist/esm/meta-workflows/services/__tests__/support/in-memory-actor-plane.d.ts +0 -79
- package/dist/esm/meta-workflows/services/__tests__/support/in-memory-actor-plane.d.ts.map +0 -1
- package/dist/esm/meta-workflows/services/__tests__/support/in-memory-actor-plane.js +0 -193
- package/dist/esm/meta-workflows/services/__tests__/support/in-memory-actor-plane.js.map +0 -1
|
@@ -10,11 +10,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
|
-
import {
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
|
+
import { mkdir, readFile, readdir, rm, stat, unlink, writeFile } from 'node:fs/promises';
|
|
14
15
|
import * as path from 'node:path';
|
|
15
16
|
import { inject, injectable } from 'inversify';
|
|
16
17
|
import { z } from 'zod';
|
|
17
|
-
import { ApplicationSpecificationLandingConcurrency } from '@wildo-ai/application-creation-runtime';
|
|
18
|
+
import { ApplicationSpecificationLandingConcurrency, writeSpecificationFileAtomically, } from '@wildo-ai/application-creation-runtime';
|
|
18
19
|
import { SAAS_SERVICE_TYPES } from '@wildo-ai/saas-backend-lib';
|
|
19
20
|
import { COMPANION_SERVICE_TYPES } from '../../core/inject/models/service-types.js';
|
|
20
21
|
import { renderUnifiedDiff } from '../utils/unified-diff.companion.utils.js';
|
|
@@ -44,6 +45,27 @@ const RunWriteRecordSchema = z.strictObject({
|
|
|
44
45
|
*/
|
|
45
46
|
traceSessionId: z.string().min(1).optional(),
|
|
46
47
|
at: z.string().min(1),
|
|
48
|
+
/**
|
|
49
|
+
* When the run STARTED — before it read anything it derives from (review F7, 2026-10-01). `at` is when its
|
|
50
|
+
* writes were recorded, which is later; a run admitted beside a writer of a family it reads lands after
|
|
51
|
+
* that writer, so judging it by `at` would call its output current although it was derived from the old
|
|
52
|
+
* input. Optional: a record from before it existed is judged by `at`.
|
|
53
|
+
*/
|
|
54
|
+
startedAt: z.string().min(1).optional(),
|
|
55
|
+
/**
|
|
56
|
+
* The catalog VERSION of the playbook that ran (#2158). A landing made by a version other than the one the
|
|
57
|
+
* catalog holds now is a REFRESH, so a changed method re-derives unattended. Optional: older records carry
|
|
58
|
+
* none and are not judged out of date.
|
|
59
|
+
*/
|
|
60
|
+
playbookVersion: z.string().min(1).optional(),
|
|
61
|
+
/**
|
|
62
|
+
* Per family the run landed, the aspects it MEASURABLY changed (`measureChangedAspects`, #2146); `null` when the
|
|
63
|
+
* change could not be confined to aspects, which counts as a change of the whole family. A record without this
|
|
64
|
+
* field predates measurement, and only then does the writer's declaration decide.
|
|
65
|
+
*/
|
|
66
|
+
aspectsChanged: z.record(z.string(), z.array(z.string().min(1)).nullable()).optional(),
|
|
67
|
+
/** Aspect keys the brief-adequacy gate added to this run's brief: read by it, beyond what it declares. */
|
|
68
|
+
readAspectsAdded: z.array(z.string().min(1)).optional(),
|
|
47
69
|
files: z.array(RunWriteFileSchema).min(1),
|
|
48
70
|
/**
|
|
49
71
|
* Stamped when the run's writes were ACCEPTED through the workbench (#1454, Step 7) — a cache of
|
|
@@ -52,6 +74,43 @@ const RunWriteRecordSchema = z.strictObject({
|
|
|
52
74
|
*/
|
|
53
75
|
acceptedAt: z.string().min(1).optional(),
|
|
54
76
|
acceptedCommitSha: z.string().min(1).optional(),
|
|
77
|
+
/**
|
|
78
|
+
* The criteria the advisory judge rated GAP, stamped after the run when its overall verdict was GAP
|
|
79
|
+
* (#2142). The judge answers AFTER the writes are recorded, so this arrives by a second write
|
|
80
|
+
* (`markJudgedGap`). Read back as `PlaybookLandingHistory.lastLandingJudgedGapByPlaybook`, so an
|
|
81
|
+
* unattended round reports a rejected-and-unchanged playbook as STUCK rather than as finished.
|
|
82
|
+
* Optional: a record from before it existed, an unjudged run and a non-GAP verdict all carry none.
|
|
83
|
+
*/
|
|
84
|
+
judgedGapCriteria: z.array(z.strictObject({ criterionRef: z.string().min(1), rationale: z.string().min(1).optional() })).min(1).optional(),
|
|
85
|
+
});
|
|
86
|
+
/** How long after a revert's marker instant its own file write may still carry a later mtime. */
|
|
87
|
+
const REVERT_WRITE_SLACK_SECONDS = 2;
|
|
88
|
+
/**
|
|
89
|
+
* A REVERT, kept after its run's record is gone (#2157): which files it put back, and when. Without it, a revert
|
|
90
|
+
* left the family holding an OLDER run's bytes, so its change was dated at that older landing, and a reader that
|
|
91
|
+
* landed between the reverted write and the revert read CURRENT although it was derived from content that no
|
|
92
|
+
* longer exists. Kept under `reverts/`, which `list()` never reads as a run.
|
|
93
|
+
*/
|
|
94
|
+
const RunRevertMarkerSchema = z.strictObject({
|
|
95
|
+
runId: z.string().min(1),
|
|
96
|
+
playbookRef: z.string().min(1),
|
|
97
|
+
at: z.string().min(1),
|
|
98
|
+
paths: z.array(z.string().min(1)).min(1),
|
|
99
|
+
/**
|
|
100
|
+
* The revert was FORCED over files edited since the run (`wildo creation revert --force`) and did discard such
|
|
101
|
+
* an edit (#2231): set only when a file that would otherwise have been refused was reverted, never for a `--force`
|
|
102
|
+
* that changed nothing a plain revert would not. Read by the intervention ledger; absent on an ordinary revert and on every marker
|
|
103
|
+
* written before the field.
|
|
104
|
+
*/
|
|
105
|
+
forced: z.literal(true).optional(),
|
|
106
|
+
/**
|
|
107
|
+
* What the reverted run WROTE, when it ran (#2231): its instant and each file's written bytes' sha256. A full
|
|
108
|
+
* revert deletes the run's write record, and with it the only footprint that let the intervention ledger
|
|
109
|
+
* attribute a commit of those files made before the revert. Kept here so the run still owns what it wrote.
|
|
110
|
+
* Absent on markers written before the field.
|
|
111
|
+
*/
|
|
112
|
+
runAt: z.string().min(1).optional(),
|
|
113
|
+
writtenFiles: z.array(z.strictObject({ path: z.string().min(1), sha256: z.string().min(1) })).optional(),
|
|
55
114
|
});
|
|
56
115
|
/** Why a run's written file no longer holds its bytes: a later recorded run landed there, or something else changed it. */
|
|
57
116
|
export var PlaybookRunFileSuccession;
|
|
@@ -74,9 +133,14 @@ export class PlaybookRunWriteRecordNotFoundError extends Error {
|
|
|
74
133
|
*
|
|
75
134
|
* Records live in the gitignored companion state directory. Deleting them all costs exactly the
|
|
76
135
|
* convenience — git still holds every accepted state, and `git diff` still shows every un-accepted write.
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
136
|
+
* (`.claude/rules/one-source-of-truth.md`: cache, not ledger — losing it costs time, never truth.)
|
|
137
|
+
*
|
|
138
|
+
* ONE decision reads them, and it is a decision to NOT SPEND (2026-10-01): {@link deriveLandingHistory}
|
|
139
|
+
* tells the eligibility board when each playbook last landed, so an unattended selection stops re-running
|
|
140
|
+
* a playbook whose inputs have not moved (`PlaybookEligibility.rerun`). Deleting the records makes every
|
|
141
|
+
* playbook read as a first run again (once the companion re-reads the register: the summary is kept until
|
|
142
|
+
* the next record, revert or restart) — a re-run, never a lost fact — which is the one kind of refusal
|
|
143
|
+
* Rule 5 lets runtime state make. Everything else here serves the list/revert doors a human operates.
|
|
80
144
|
*
|
|
81
145
|
* ## Revert protects the human's later edits
|
|
82
146
|
*
|
|
@@ -106,6 +170,7 @@ let PlaybookRunWriteRegisterCompanionService = class PlaybookRunWriteRegisterCom
|
|
|
106
170
|
this.mutationListeners.push(listener);
|
|
107
171
|
}
|
|
108
172
|
notifyMutation() {
|
|
173
|
+
this.landingSummary = undefined;
|
|
109
174
|
for (const listener of this.mutationListeners) {
|
|
110
175
|
try {
|
|
111
176
|
listener();
|
|
@@ -118,6 +183,192 @@ let PlaybookRunWriteRegisterCompanionService = class PlaybookRunWriteRegisterCom
|
|
|
118
183
|
this.companionContext = companionContext;
|
|
119
184
|
this.logDebug = this.logger.debugByType('PlaybookRunWriteRegister');
|
|
120
185
|
}
|
|
186
|
+
/** The record-derived half of {@link deriveLandingHistory}, kept until the register next changes. */
|
|
187
|
+
landingSummary;
|
|
188
|
+
/**
|
|
189
|
+
* When each playbook last landed, and when each family's file last changed — the host's record of its
|
|
190
|
+
* own runs that `PlaybookEligibility.rerun` reads (2026-10-01).
|
|
191
|
+
*
|
|
192
|
+
* Why the register and not git: during the definition phase nothing is committed (on
|
|
193
|
+
* app-creation-test-004 every family after the vision was a working edit), and a commit time is when a
|
|
194
|
+
* change was ACCEPTED, not when it was derived. The register holds the instant each run landed.
|
|
195
|
+
*
|
|
196
|
+
* A family's change is the latest run that wrote its file — unless a REVERT came after it (`revertOf`, read from
|
|
197
|
+
* the markers under `reverts/`, #2157), or the file no longer holds the bytes that run wrote, which is the same
|
|
198
|
+
* test `revert` uses (`diverged`): then somebody changed it OUTSIDE the runs, dated by the file's mtime. Outside
|
|
199
|
+
* edits are also reported on their own (`lastOutsideEditByFamily`), including one hidden BETWEEN two landings, so
|
|
200
|
+
* no later landing can mask them. A family no run ever wrote is left out, and the runtime falls back to git.
|
|
201
|
+
*
|
|
202
|
+
* On the board's hot path, so the parse of every record is memoised until the register changes; what is
|
|
203
|
+
* read per call is only the handful of family files given here.
|
|
204
|
+
*
|
|
205
|
+
* @param familyFiles family → its file, app-root-relative, for the families that have content.
|
|
206
|
+
*/
|
|
207
|
+
async deriveLandingHistory(familyFiles) {
|
|
208
|
+
this.landingSummary ??= this.summarizeLandings();
|
|
209
|
+
/*
|
|
210
|
+
* An unreadable register is NO history — `undefined`, so every verdict is UNTRACKED and offered as before
|
|
211
|
+
* this existed — never an empty one, which would label every playbook a first run (review F11). Asked
|
|
212
|
+
* again on the next call.
|
|
213
|
+
*/
|
|
214
|
+
const summary = await this.landingSummary.catch(() => {
|
|
215
|
+
this.landingSummary = undefined;
|
|
216
|
+
return undefined;
|
|
217
|
+
});
|
|
218
|
+
if (summary === undefined)
|
|
219
|
+
return undefined;
|
|
220
|
+
const lastChangeByFamily = new Map();
|
|
221
|
+
const landingsByFamily = new Map();
|
|
222
|
+
const landedAspectsByFamily = new Map();
|
|
223
|
+
const lastOutsideEditByFamily = new Map();
|
|
224
|
+
const noteOutsideEdit = (family, at) => {
|
|
225
|
+
if (at > (lastOutsideEditByFamily.get(family) ?? 0))
|
|
226
|
+
lastOutsideEditByFamily.set(family, at);
|
|
227
|
+
};
|
|
228
|
+
for (const [family, appRelativePath] of familyFiles) {
|
|
229
|
+
const writers = summary.latestByPathAndWriter.get(appRelativePath);
|
|
230
|
+
if (writers !== undefined)
|
|
231
|
+
landingsByFamily.set(family, writers);
|
|
232
|
+
// What each writer's latest landing measurably changed in THIS family, when it was measured (#2146).
|
|
233
|
+
const measured = new Map();
|
|
234
|
+
for (const [writer, changed] of summary.latestAspectsByPathAndWriter.get(appRelativePath) ?? []) {
|
|
235
|
+
// A measured record names every family it landed; `null` there is a whole-family change (review R1).
|
|
236
|
+
if (changed !== undefined && Object.hasOwn(changed, family))
|
|
237
|
+
measured.set(writer, changed[family] ?? null);
|
|
238
|
+
}
|
|
239
|
+
if (measured.size > 0)
|
|
240
|
+
landedAspectsByFamily.set(family, measured);
|
|
241
|
+
// An edit hidden BETWEEN two landings: a later run found bytes the earlier run did not write (review F1).
|
|
242
|
+
const hidden = summary.latestHiddenOutsideEditByPath.get(appRelativePath);
|
|
243
|
+
if (hidden !== undefined)
|
|
244
|
+
noteOutsideEdit(family, hidden);
|
|
245
|
+
const landing = summary.latestByPath.get(appRelativePath);
|
|
246
|
+
const absolutePath = path.join(this.companionContext.saasRoot, appRelativePath);
|
|
247
|
+
// A revert after the latest landing is the family's latest change, attributed to the run it undid (#2157).
|
|
248
|
+
const revert = summary.latestRevertByPath.get(appRelativePath);
|
|
249
|
+
if (revert !== undefined && (landing === undefined || revert.at > landing.at)) {
|
|
250
|
+
lastChangeByFamily.set(family, { at: revert.at, revertOf: revert.playbookRef });
|
|
251
|
+
// A file touched after the revert wrote it was edited outside the runs since (review F2). The revert's own
|
|
252
|
+
// write precedes its marker, so its mtime is never later than the marker's instant plus a moment.
|
|
253
|
+
const modifiedAt = await stat(absolutePath).then((entry) => entry.mtimeMs / 1000).catch(() => undefined);
|
|
254
|
+
if (modifiedAt !== undefined && modifiedAt > revert.at + REVERT_WRITE_SLACK_SECONDS)
|
|
255
|
+
noteOutsideEdit(family, modifiedAt);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (landing === undefined)
|
|
259
|
+
continue;
|
|
260
|
+
const current = await readFile(absolutePath, 'utf8').catch(() => undefined);
|
|
261
|
+
if (current === undefined || current === landing.writtenContent) {
|
|
262
|
+
lastChangeByFamily.set(family, { at: landing.at, byPlaybookRef: landing.playbookRef });
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
const modifiedAt = await stat(absolutePath).then((entry) => entry.mtimeMs / 1000).catch(() => landing.at);
|
|
266
|
+
lastChangeByFamily.set(family, { at: Math.max(landing.at, modifiedAt) });
|
|
267
|
+
noteOutsideEdit(family, Math.max(landing.at, modifiedAt));
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
lastLandedAtByPlaybook: summary.lastLandedAtByPlaybook,
|
|
271
|
+
lastChangeByFamily,
|
|
272
|
+
landingsByFamily,
|
|
273
|
+
lastLandingJudgedGapByPlaybook: summary.lastLandingJudgedGapByPlaybook,
|
|
274
|
+
...(summary.lastLandedVersionByPlaybook.size > 0 ? { lastLandedVersionByPlaybook: summary.lastLandedVersionByPlaybook } : {}),
|
|
275
|
+
...(lastOutsideEditByFamily.size > 0 ? { lastOutsideEditByFamily } : {}),
|
|
276
|
+
...(landedAspectsByFamily.size > 0 ? { landedAspectsByFamily } : {}),
|
|
277
|
+
...(summary.addedReadAspectsByPlaybook.size > 0 ? { addedReadAspectsByPlaybook: summary.addedReadAspectsByPlaybook } : {}),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
async summarizeLandings() {
|
|
281
|
+
const lastLandedAtByPlaybook = new Map();
|
|
282
|
+
const lastLandingJudgedGapByPlaybook = new Map();
|
|
283
|
+
const latestByPath = new Map();
|
|
284
|
+
const latestByPathAndWriter = new Map();
|
|
285
|
+
const lastLandedVersionByPlaybook = new Map();
|
|
286
|
+
const addedReadAspectsByPlaybook = new Map();
|
|
287
|
+
const latestAspectsByPathAndWriter = new Map();
|
|
288
|
+
// Every landing of each path, oldest first, to find an edit made between two of them (review F1).
|
|
289
|
+
const landingsOfPath = new Map();
|
|
290
|
+
/*
|
|
291
|
+
* `list()` is newest first, so the first sighting of a playbook or a path is its latest. Seconds keep
|
|
292
|
+
* their fraction: two landings in one second must still order (review F7).
|
|
293
|
+
*
|
|
294
|
+
* A playbook is judged by when it STARTED (it derived from what it read then); a family changed when a
|
|
295
|
+
* run's writes LANDED. A file rewritten with the bytes it already held is no change (review F4): measured
|
|
296
|
+
* on app-creation-test-004, value-proposition's 06:15 run rewrote the market snapshot byte for byte, and
|
|
297
|
+
* counting it would have made every reader of the snapshot a refresh with nothing changed.
|
|
298
|
+
*/
|
|
299
|
+
for (const record of await this.list()) {
|
|
300
|
+
const at = Date.parse(record.at) / 1000;
|
|
301
|
+
if (Number.isNaN(at))
|
|
302
|
+
continue;
|
|
303
|
+
const startedAt = record.startedAt !== undefined ? Date.parse(record.startedAt) / 1000 : Number.NaN;
|
|
304
|
+
if (!lastLandedAtByPlaybook.has(record.playbookRef)) {
|
|
305
|
+
lastLandedAtByPlaybook.set(record.playbookRef, Number.isNaN(startedAt) ? at : startedAt);
|
|
306
|
+
// The LATEST landing's verdict only: a later landing the judge did not reject supersedes an earlier GAP.
|
|
307
|
+
if (record.judgedGapCriteria !== undefined)
|
|
308
|
+
lastLandingJudgedGapByPlaybook.set(record.playbookRef, record.judgedGapCriteria);
|
|
309
|
+
if (record.playbookVersion !== undefined)
|
|
310
|
+
lastLandedVersionByPlaybook.set(record.playbookRef, record.playbookVersion);
|
|
311
|
+
if (record.readAspectsAdded !== undefined && record.readAspectsAdded.length > 0)
|
|
312
|
+
addedReadAspectsByPlaybook.set(record.playbookRef, record.readAspectsAdded);
|
|
313
|
+
}
|
|
314
|
+
for (const file of record.files) {
|
|
315
|
+
landingsOfPath.set(file.path, [{
|
|
316
|
+
at: Number.isNaN(startedAt) ? at : startedAt,
|
|
317
|
+
existedBefore: file.existedBefore,
|
|
318
|
+
...(file.previousContent !== undefined ? { previousContent: file.previousContent } : {}),
|
|
319
|
+
writtenContent: file.writtenContent,
|
|
320
|
+
}, ...(landingsOfPath.get(file.path) ?? [])]);
|
|
321
|
+
if (file.existedBefore && file.previousContent === file.writtenContent)
|
|
322
|
+
continue;
|
|
323
|
+
const writerAspects = latestAspectsByPathAndWriter.get(file.path) ?? new Map();
|
|
324
|
+
if (!writerAspects.has(record.playbookRef))
|
|
325
|
+
writerAspects.set(record.playbookRef, record.aspectsChanged);
|
|
326
|
+
latestAspectsByPathAndWriter.set(file.path, writerAspects);
|
|
327
|
+
if (!latestByPath.has(file.path))
|
|
328
|
+
latestByPath.set(file.path, { at, playbookRef: record.playbookRef, writtenContent: file.writtenContent });
|
|
329
|
+
const writers = latestByPathAndWriter.get(file.path) ?? new Map();
|
|
330
|
+
if (!writers.has(record.playbookRef))
|
|
331
|
+
writers.set(record.playbookRef, at);
|
|
332
|
+
latestByPathAndWriter.set(file.path, writers);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const latestRevertByPath = new Map();
|
|
336
|
+
const markers = await readdir(this.resolveRevertDirectory()).catch(() => []);
|
|
337
|
+
for (const entry of markers.filter((name) => name.endsWith('.json'))) {
|
|
338
|
+
const parsed = await readFile(path.join(this.resolveRevertDirectory(), entry), 'utf8')
|
|
339
|
+
.then((raw) => RunRevertMarkerSchema.safeParse(JSON.parse(raw)))
|
|
340
|
+
.catch(() => undefined);
|
|
341
|
+
if (parsed?.success !== true)
|
|
342
|
+
continue;
|
|
343
|
+
const at = Date.parse(parsed.data.at) / 1000;
|
|
344
|
+
if (Number.isNaN(at))
|
|
345
|
+
continue;
|
|
346
|
+
for (const revertedPath of parsed.data.paths) {
|
|
347
|
+
const known = latestRevertByPath.get(revertedPath);
|
|
348
|
+
if (known === undefined || at > known.at)
|
|
349
|
+
latestRevertByPath.set(revertedPath, { at, playbookRef: parsed.data.playbookRef });
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/*
|
|
353
|
+
* An edit hidden between two landings: a run's pre-image is not what the run before it wrote — or the file was
|
|
354
|
+
* gone although that run had written it. Dated at the later run's start, the latest moment it can have happened,
|
|
355
|
+
* so a reader that landed in between is reopened (the safe direction).
|
|
356
|
+
*/
|
|
357
|
+
const latestHiddenOutsideEditByPath = new Map();
|
|
358
|
+
for (const [filePath, landings] of landingsOfPath) {
|
|
359
|
+
for (let index = 1; index < landings.length; index += 1) {
|
|
360
|
+
const earlier = landings[index - 1];
|
|
361
|
+
const later = landings[index];
|
|
362
|
+
const editedBetween = later.existedBefore ? later.previousContent !== undefined && later.previousContent !== earlier.writtenContent : true;
|
|
363
|
+
if (editedBetween)
|
|
364
|
+
latestHiddenOutsideEditByPath.set(filePath, Math.max(latestHiddenOutsideEditByPath.get(filePath) ?? 0, later.at));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return {
|
|
368
|
+
lastLandedAtByPlaybook, lastLandingJudgedGapByPlaybook, latestByPath, latestByPathAndWriter, lastLandedVersionByPlaybook,
|
|
369
|
+
latestRevertByPath, addedReadAspectsByPlaybook, latestAspectsByPathAndWriter, latestHiddenOutsideEditByPath,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
121
372
|
async record(record) {
|
|
122
373
|
const parsed = RunWriteRecordSchema.parse(record);
|
|
123
374
|
const registerDirectory = this.resolveRegisterDirectory();
|
|
@@ -180,6 +431,20 @@ let PlaybookRunWriteRegisterCompanionService = class PlaybookRunWriteRegisterCom
|
|
|
180
431
|
});
|
|
181
432
|
await this.record({ ...RunWriteRecordSchema.parse(JSON.parse(raw)), acceptedAt: at, acceptedCommitSha: commitSha });
|
|
182
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Stamp the criteria the judge rated GAP onto a recorded run (#2142). Same read-modify-record shape as
|
|
436
|
+
* `markAccepted`; `record` notifies, so the memoised landing summary is re-derived.
|
|
437
|
+
*/
|
|
438
|
+
async markJudgedGap(runId, criteria) {
|
|
439
|
+
if (criteria.length === 0)
|
|
440
|
+
return;
|
|
441
|
+
const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error) => {
|
|
442
|
+
if (error?.code === 'ENOENT')
|
|
443
|
+
throw new PlaybookRunWriteRecordNotFoundError(runId);
|
|
444
|
+
throw error;
|
|
445
|
+
});
|
|
446
|
+
await this.record({ ...RunWriteRecordSchema.parse(JSON.parse(raw)), judgedGapCriteria: criteria.map((criterion) => ({ ...criterion })) });
|
|
447
|
+
}
|
|
183
448
|
async describeRunDiff(runId) {
|
|
184
449
|
const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error) => {
|
|
185
450
|
if (error?.code === 'ENOENT')
|
|
@@ -215,6 +480,7 @@ let PlaybookRunWriteRegisterCompanionService = class PlaybookRunWriteRegisterCom
|
|
|
215
480
|
const reverted = [];
|
|
216
481
|
const refusedDiverged = [];
|
|
217
482
|
const refusedLaterRun = [];
|
|
483
|
+
let overwroteEdits = false;
|
|
218
484
|
const laterRecords = (await this.list()).filter((candidate) => candidate.runId !== record.runId && candidate.at > record.at);
|
|
219
485
|
for (const file of record.files) {
|
|
220
486
|
const absolutePath = path.resolve(this.companionContext.saasRoot, file.path);
|
|
@@ -231,12 +497,17 @@ let PlaybookRunWriteRegisterCompanionService = class PlaybookRunWriteRegisterCom
|
|
|
231
497
|
refusedLaterRun.push({ path: file.path, runId: laterWriter.runId });
|
|
232
498
|
continue;
|
|
233
499
|
}
|
|
234
|
-
|
|
500
|
+
const diverged = !createdFileAlreadyAbsent && current !== file.writtenContent;
|
|
501
|
+
if (options.force !== true && diverged) {
|
|
235
502
|
refusedDiverged.push(file.path);
|
|
236
503
|
continue;
|
|
237
504
|
}
|
|
505
|
+
// Forced AND it mattered: this file held an edit made since the run, which the revert now discards.
|
|
506
|
+
if (diverged)
|
|
507
|
+
overwroteEdits = true;
|
|
238
508
|
if (file.existedBefore && file.previousContent !== undefined) {
|
|
239
|
-
|
|
509
|
+
// Atomically: a revert rewrites specification files the companion is reading (#2250).
|
|
510
|
+
await writeSpecificationFileAtomically(absolutePath, file.previousContent);
|
|
240
511
|
}
|
|
241
512
|
else {
|
|
242
513
|
await unlink(absolutePath).catch((error) => {
|
|
@@ -256,10 +527,57 @@ let PlaybookRunWriteRegisterCompanionService = class PlaybookRunWriteRegisterCom
|
|
|
256
527
|
else if (reverted.length > 0) {
|
|
257
528
|
await this.record({ ...record, files: record.files.filter((file) => unsettled.has(file.path)) });
|
|
258
529
|
}
|
|
530
|
+
if (reverted.length > 0) {
|
|
531
|
+
// Best-effort: losing the marker costs only the dating of this revert, never the revert itself.
|
|
532
|
+
const marker = RunRevertMarkerSchema.parse({
|
|
533
|
+
runId,
|
|
534
|
+
playbookRef: record.playbookRef,
|
|
535
|
+
at: new Date().toISOString(),
|
|
536
|
+
paths: reverted,
|
|
537
|
+
...(overwroteEdits ? { forced: true } : {}),
|
|
538
|
+
runAt: record.at,
|
|
539
|
+
writtenFiles: record.files.map((file) => ({ path: file.path, sha256: createHash('sha256').update(file.writtenContent).digest('hex') })),
|
|
540
|
+
});
|
|
541
|
+
await mkdir(this.resolveRevertDirectory(), { recursive: true })
|
|
542
|
+
// One file per revert, never per run: a partial revert followed by a forced one must keep both dates (review F3).
|
|
543
|
+
.then(() => writeFile(path.join(this.resolveRevertDirectory(), `${runId}-${Date.now()}.json`), `${JSON.stringify(marker, null, 2)}\n`, 'utf8'))
|
|
544
|
+
.catch((error) => this.logDebug('Could not record the revert marker', { runId, error: String(error) }));
|
|
545
|
+
}
|
|
259
546
|
this.logDebug('Reverted run writes', { runId, reverted: reverted.length, refused: refusedDiverged.length, refusedLaterRun: refusedLaterRun.length });
|
|
260
547
|
this.notifyMutation();
|
|
261
548
|
return { runId, reverted, refusedDiverged, refusedLaterRun };
|
|
262
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* Every revert marker, oldest first (#2231): what the intervention ledger counts as a person's revert. A marker
|
|
552
|
+
* that no longer parses is skipped, as `list` skips a record — the register is a cache, never a reader's failure.
|
|
553
|
+
*/
|
|
554
|
+
async listReverts() {
|
|
555
|
+
const directory = this.resolveRevertDirectory();
|
|
556
|
+
const entries = await readdir(directory).catch((error) => {
|
|
557
|
+
if (error?.code === 'ENOENT')
|
|
558
|
+
return [];
|
|
559
|
+
throw error;
|
|
560
|
+
});
|
|
561
|
+
const markers = [];
|
|
562
|
+
for (const entry of entries.filter((name) => name.endsWith('.json'))) {
|
|
563
|
+
try {
|
|
564
|
+
const marker = RunRevertMarkerSchema.parse(JSON.parse(await readFile(path.join(directory, entry), 'utf8')));
|
|
565
|
+
markers.push({
|
|
566
|
+
markerId: entry.replace(/\.json$/, ''),
|
|
567
|
+
runId: marker.runId,
|
|
568
|
+
playbookRef: marker.playbookRef,
|
|
569
|
+
at: marker.at,
|
|
570
|
+
paths: marker.paths,
|
|
571
|
+
forced: marker.forced === true,
|
|
572
|
+
...(marker.runAt && marker.writtenFiles ? { runFootprint: { runAt: marker.runAt, writtenFiles: marker.writtenFiles } } : {}),
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
catch {
|
|
576
|
+
this.logDebug('Skipping unreadable revert marker', { entry });
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return markers.sort((left, right) => left.at.localeCompare(right.at));
|
|
580
|
+
}
|
|
263
581
|
/**
|
|
264
582
|
* Why each of a run's files no longer holds what the run wrote (#1614): a LATER recorded run wrote the
|
|
265
583
|
* same path, or nothing recorded did. Acceptance reads this so a run whose work was refined by a later
|
|
@@ -280,6 +598,9 @@ let PlaybookRunWriteRegisterCompanionService = class PlaybookRunWriteRegisterCom
|
|
|
280
598
|
resolveRegisterDirectory() {
|
|
281
599
|
return path.resolve(this.companionContext.saasRoot, '.wildo-saas/state/meta-workflows/run-writes');
|
|
282
600
|
}
|
|
601
|
+
resolveRevertDirectory() {
|
|
602
|
+
return path.join(this.resolveRegisterDirectory(), 'reverts');
|
|
603
|
+
}
|
|
283
604
|
resolveRecordPath(runId) {
|
|
284
605
|
// The runId doubles as a file name; refuse anything path-shaped.
|
|
285
606
|
if (!/^[a-zA-Z0-9._-]+$/.test(runId))
|
package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playbook-run-write-register.companion.service.js","sourceRoot":"","sources":["../../../../../src/meta-workflows/services/playbook-run-write-register.companion.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,0CAA0C,EAAE,MAAM,wCAAwC,CAAC;AAEpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,4DAA4D;AAC5D,MAAM,kBAAkB,GAAG,CAAC,CAAC,YAAY,CAAC;IACxC,kDAAkD;IAClD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;IAC1B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AEO,wBAAwB;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,6CAA6C,CAAC,CAAC;IACrG,CAAC;IAEO,iBAAiB,CAAC,KAAa;QACrC,iEAAiE;QACjE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,WAAW,KAAK,+BAA+B,CAAC,CAAC;QACvG,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC;IACrE,CAAC;CACF,CAAA;AAtMY,wCAAwC;IADpD,UAAU,EAAE;IA0BR,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAA;;GA1BxC,wCAAwC,CAsMpD","sourcesContent":["import { mkdir, readFile, readdir, rm, unlink, writeFile } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { inject, injectable } from 'inversify';\nimport { z } from 'zod';\n\nimport { ApplicationSpecificationLandingConcurrency } from '@wildo-ai/application-creation-runtime';\nimport type { LoggerService } from '@wildo-ai/saas-backend-lib';\nimport { SAAS_SERVICE_TYPES } from '@wildo-ai/saas-backend-lib';\n\nimport { COMPANION_SERVICE_TYPES } from '../../core/inject/models/service-types';\nimport type { CompanionContext } from '../../core/context/companion-context';\nimport { renderUnifiedDiff } from '../utils/unified-diff.companion.utils';\n\n/** One file a run wrote, with everything a revert needs. */\nconst RunWriteFileSchema = z.strictObject({\n /** App-root-relative path of the written file. */\n path: z.string().min(1),\n existedBefore: z.boolean(),\n /** The file's bytes before the run, when one existed. */\n previousContent: z.string().optional(),\n /** The exact bytes the run wrote — revert refuses when the file has moved on from these (unless forced). */\n writtenContent: z.string().min(1),\n /**\n * What the landing found against the bytes the run READ (#1614): unchanged since, merged over another\n * writer's entries, or not compared. Absent on records from before it existed, and on files a run\n * derives rather than lands (wiring, diagrams, decision records).\n */\n concurrency: z.enum(ApplicationSpecificationLandingConcurrency).optional(),\n});\n\nconst RunWriteRecordSchema = z.strictObject({\n /** The actor execution's id — the run's one identity (#1358). */\n runId: z.string().min(1),\n playbookRef: z.string().min(1),\n /**\n * The trace session the run recorded under, when its request carried one. RECORDED here because the\n * run id no longer encodes it (#1358): a reader that wants the run's evidence joins on this field.\n */\n traceSessionId: z.string().min(1).optional(),\n at: z.string().min(1),\n files: z.array(RunWriteFileSchema).min(1),\n /**\n * Stamped when the run's writes were ACCEPTED through the workbench (#1454, Step 7) — a cache of\n * what `git log` already knows, so a row can say \"accepted\" without asking git. Optional, so every\n * record written before the field existed still parses.\n */\n acceptedAt: z.string().min(1).optional(),\n acceptedCommitSha: z.string().min(1).optional(),\n});\nexport type PlaybookRunWriteRecord = z.infer<typeof RunWriteRecordSchema>;\n\n/** One file's change, as the board renders it. */\nexport interface PlaybookRunFileDiff {\n readonly path: string;\n readonly existedBefore: boolean;\n /** The file on disk no longer holds the bytes the run wrote — the same test `revert` applies. */\n readonly diverged: boolean;\n /** Unified diff of the run's own change. EMPTY when the run rewrote a file with identical bytes. */\n readonly diff: string;\n}\n\n/** What one run changed — a pure read over the register. */\nexport interface PlaybookRunDiff {\n readonly runId: string;\n readonly playbookRef: string;\n readonly at: string;\n readonly files: readonly PlaybookRunFileDiff[];\n}\n\nexport interface PlaybookRunRevertOutcome {\n readonly runId: string;\n readonly reverted: readonly string[];\n /** Files whose CURRENT bytes differ from what the run wrote — refused without `force` so a human edit is never silently destroyed. */\n readonly refusedDiverged: readonly string[];\n /**\n * Files whose current bytes are a LATER recorded run's landing (#1614). Refused even under `force`:\n * restoring this run's pre-image would destroy that run's work, which a person asking to undo THIS run\n * did not ask for. Revert the later run first.\n */\n readonly refusedLaterRun: readonly { readonly path: string; readonly runId: string }[];\n}\n\n/** Why a run's written file no longer holds its bytes: a later recorded run landed there, or something else changed it. */\nexport enum PlaybookRunFileSuccession {\n /** A later recorded run landed this path; the file holds its bytes, or a still later change on top of them. */\n LATER_RUN = 'later_run',\n /** No later recorded run wrote this path: a person or a tool outside the runs changed it. */\n EDITED_OUTSIDE_RUNS = 'edited_outside_runs',\n}\n\nexport class PlaybookRunWriteRecordNotFoundError extends Error {\n public constructor(runId: string) {\n super(`No write record exists for run \"${runId}\".`);\n }\n}\n\n/**\n * The per-run WRITE REGISTER: which files each playbook run wrote, with pre-images, so any run can be\n * reverted in one call while mechanisms are being exercised.\n *\n * ## A runtime convenience, not a second truth\n *\n * Records live in the gitignored companion state directory. Deleting them all costs exactly the\n * convenience — git still holds every accepted state, and `git diff` still shows every un-accepted write.\n * Nothing reads these records to make a decision; the ONLY consumers are the list/revert doors below,\n * both operated by a human testing the mechanism. (`.claude/rules/one-source-of-truth.md`: cache, not\n * ledger — losing it costs time, never truth.)\n *\n * ## Revert protects the human's later edits\n *\n * Revert restores a file's pre-image (or deletes a file the run created) ONLY when the file still holds\n * the exact bytes the run wrote. A file that has moved on — a human edited it after the run — is refused\n * and reported, because destroying a person's edit to undo a machine's is the wrong trade. `force`\n * overrides per explicit request.\n *\n * This register is also the natural future home of per-file run locking (issue #48): the mechanism that\n * knows which files a run touches is the one that can hold locks between concurrent CLIs.\n */\n@injectable()\nexport class PlaybookRunWriteRegisterCompanionService {\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n /**\n * Notified after every mutation of the register (a `record` or a `revert`).\n *\n * The seam exists for the creation-plane eligibility cache: a run landing files is exactly the\n * event that changes playbook eligibility, and the projection service subscribes here rather\n * than being injected INTO this service (which would cycle — it already depends on this one).\n * Listeners are fire-and-forget and must not throw; a cache invalidation failing must never\n * fail the write it observes.\n */\n private readonly mutationListeners: Array<() => void> = [];\n\n public registerMutationListener(listener: () => void): void {\n this.mutationListeners.push(listener);\n }\n\n private notifyMutation(): void {\n for (const listener of this.mutationListeners) {\n try { listener(); } catch { /* a listener must never fail the write it observes */ }\n }\n }\n\n public constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(COMPANION_SERVICE_TYPES.CompanionContext) private readonly companionContext: CompanionContext,\n ) {\n this.logDebug = this.logger.debugByType('PlaybookRunWriteRegister');\n }\n\n public async record(record: PlaybookRunWriteRecord): Promise<void> {\n const parsed = RunWriteRecordSchema.parse(record);\n const registerDirectory = this.resolveRegisterDirectory();\n await mkdir(registerDirectory, { recursive: true });\n await writeFile(this.resolveRecordPath(parsed.runId), `${JSON.stringify(parsed, null, 2)}\\n`, 'utf8');\n this.logDebug('Recorded run writes', { runId: parsed.runId, files: parsed.files.length });\n this.notifyMutation();\n }\n\n /** Newest first. A record that no longer parses is skipped (a cache never fails its reader). */\n public async list(): Promise<readonly PlaybookRunWriteRecord[]> {\n const registerDirectory = this.resolveRegisterDirectory();\n const entries = await readdir(registerDirectory).catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') return [] as string[];\n throw error;\n });\n const records: PlaybookRunWriteRecord[] = [];\n for (const entry of entries.filter((name) => name.endsWith('.json'))) {\n try {\n const raw = await readFile(path.join(registerDirectory, entry), 'utf8');\n records.push(RunWriteRecordSchema.parse(JSON.parse(raw)));\n } catch {\n this.logDebug('Skipping unreadable run-write record', { entry });\n }\n }\n return records.sort((left, right) => right.at.localeCompare(left.at));\n }\n\n /**\n * WHAT a run changed, per file — the board's answer to \"should I commit this?\" (#1274).\n *\n * The board dispatches writes into the working tree and, until this existed, could only list the\n * PATHS. That undercuts the doctrine printed at the top of every one of its screens — *acceptance\n * is your own git commit* — because it hands over the commit decision with no way to inspect the\n * change.\n *\n * ## Why the diff comes from the REGISTER and not from git\n *\n * `git diff` answers a different question: what is UNCOMMITTED at a path. That equals the run's\n * change only while nothing else has touched the path since, so a second run, a human edit, or an\n * unrelated generation silently widens it. The register holds the exact bytes before\n * (`previousContent`) and the exact bytes the run wrote (`writtenContent`), so this diff is\n * attributed to the RUN and cannot drift.\n *\n * ## `diverged` is the honest half\n *\n * A file may have moved on since the run wrote it, and this read must not pretend otherwise — the\n * diff still describes what the RUN did, but it is no longer what is on disk. The test is exactly\n * the one `revert` uses to decide whether it may restore a file, deliberately: two different\n * answers to \"has this moved on?\" on one register is how a board comes to offer a revert it cannot\n * perform, or withhold one it could.\n *\n * A pure READ — nothing is locked, written or reverted.\n */\n public async markAccepted(runId: string, commitSha: string, at: string): Promise<void> {\n const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') throw new PlaybookRunWriteRecordNotFoundError(runId);\n throw error;\n });\n await this.record({ ...RunWriteRecordSchema.parse(JSON.parse(raw)), acceptedAt: at, acceptedCommitSha: commitSha });\n }\n\n public async describeRunDiff(runId: string): Promise<PlaybookRunDiff> {\n const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') throw new PlaybookRunWriteRecordNotFoundError(runId);\n throw error;\n });\n const record = RunWriteRecordSchema.parse(JSON.parse(raw));\n\n const files = await Promise.all(record.files.map(async (file) => {\n const absolutePath = path.resolve(this.companionContext.saasRoot, file.path);\n const current = await readFile(absolutePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') return undefined;\n throw error;\n });\n const createdFileAlreadyAbsent = !file.existedBefore && current === undefined;\n return {\n path: file.path,\n existedBefore: file.existedBefore,\n diverged: !createdFileAlreadyAbsent && current !== file.writtenContent,\n /* A created file has no pre-image, so every line is an addition. */\n diff: renderUnifiedDiff(file.previousContent ?? '', file.writtenContent),\n };\n }));\n\n return { runId: record.runId, playbookRef: record.playbookRef, at: record.at, files };\n }\n\n public async revert(runId: string, options: { readonly force?: boolean } = {}): Promise<PlaybookRunRevertOutcome> {\n const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') throw new PlaybookRunWriteRecordNotFoundError(runId);\n throw error;\n });\n const record = RunWriteRecordSchema.parse(JSON.parse(raw));\n\n const reverted: string[] = [];\n const refusedDiverged: string[] = [];\n const refusedLaterRun: { path: string; runId: string }[] = [];\n const laterRecords = (await this.list()).filter((candidate) => candidate.runId !== record.runId && candidate.at > record.at);\n for (const file of record.files) {\n const absolutePath = path.resolve(this.companionContext.saasRoot, file.path);\n const current = await readFile(absolutePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') return undefined;\n throw error;\n });\n // Absence is a later change when restoring would recreate an overwritten file.\n // A created file already absent is settled: removing it again changes nothing.\n const createdFileAlreadyAbsent = !file.existedBefore && current === undefined;\n const laterWriter = laterRecords.find((later) => later.files.some((laterFile) => laterFile.path === file.path && laterFile.writtenContent === current));\n if (laterWriter) {\n refusedLaterRun.push({ path: file.path, runId: laterWriter.runId });\n continue;\n }\n if (options.force !== true && !createdFileAlreadyAbsent && current !== file.writtenContent) {\n refusedDiverged.push(file.path);\n continue;\n }\n if (file.existedBefore && file.previousContent !== undefined) {\n await writeFile(absolutePath, file.previousContent, 'utf8');\n } else {\n await unlink(absolutePath).catch((error: NodeJS.ErrnoException) => {\n if (error?.code !== 'ENOENT') throw error;\n });\n }\n reverted.push(file.path);\n }\n\n // Keep ONLY unsettled paths after a partial outcome. Rechecking already restored files\n // against generated bytes manufactured conflicts; forcing that retry could overwrite\n // edits made after the first undo. The remaining pre-images retain their original meaning.\n const unsettled = new Set([...refusedDiverged, ...refusedLaterRun.map((entry) => entry.path)]);\n if (unsettled.size === 0) {\n await rm(this.resolveRecordPath(runId), { force: true });\n } else if (reverted.length > 0) {\n await this.record({ ...record, files: record.files.filter((file) => unsettled.has(file.path)) });\n }\n this.logDebug('Reverted run writes', { runId, reverted: reverted.length, refused: refusedDiverged.length, refusedLaterRun: refusedLaterRun.length });\n this.notifyMutation();\n return { runId, reverted, refusedDiverged, refusedLaterRun };\n }\n\n /**\n * Why each of a run's files no longer holds what the run wrote (#1614): a LATER recorded run wrote the\n * same path, or nothing recorded did. Acceptance reads this so a run whose work was refined by a later\n * run is not reported the same way as one a person edited over.\n */\n public async describeSuccession(runId: string): Promise<ReadonlyMap<string, PlaybookRunFileSuccession>> {\n const records = await this.list();\n const record = records.find((candidate) => candidate.runId === runId);\n if (!record) throw new PlaybookRunWriteRecordNotFoundError(runId);\n const succession = new Map<string, PlaybookRunFileSuccession>();\n for (const file of record.files) {\n const laterRun = records.some((later) => later.runId !== runId && later.at > record.at && later.files.some((laterFile) => laterFile.path === file.path));\n succession.set(file.path, laterRun ? PlaybookRunFileSuccession.LATER_RUN : PlaybookRunFileSuccession.EDITED_OUTSIDE_RUNS);\n }\n return succession;\n }\n\n private resolveRegisterDirectory(): string {\n return path.resolve(this.companionContext.saasRoot, '.wildo-saas/state/meta-workflows/run-writes');\n }\n\n private resolveRecordPath(runId: string): string {\n // The runId doubles as a file name; refuse anything path-shaped.\n if (!/^[a-zA-Z0-9._-]+$/.test(runId)) throw new Error(`Run id \"${runId}\" is not a valid record name.`);\n return path.join(this.resolveRegisterDirectory(), `${runId}.json`);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"playbook-run-write-register.companion.service.js","sourceRoot":"","sources":["../../../../../src/meta-workflows/services/playbook-run-write-register.companion.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,0CAA0C,EAI1C,gCAAgC,GACjC,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B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, stat, unlink, writeFile } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { inject, injectable } from 'inversify';\nimport { z } from 'zod';\n\nimport {\n ApplicationSpecificationLandingConcurrency,\n type PlaybookFamilyChange,\n type PlaybookJudgedGapCriterion,\n type PlaybookLandingHistory,\n writeSpecificationFileAtomically,\n} from '@wildo-ai/application-creation-runtime';\nimport type { LoggerService } from '@wildo-ai/saas-backend-lib';\nimport { SAAS_SERVICE_TYPES } from '@wildo-ai/saas-backend-lib';\n\nimport { COMPANION_SERVICE_TYPES } from '../../core/inject/models/service-types';\nimport type { CompanionContext } from '../../core/context/companion-context';\nimport { renderUnifiedDiff } from '../utils/unified-diff.companion.utils';\n\n/** One file a run wrote, with everything a revert needs. */\nconst RunWriteFileSchema = z.strictObject({\n /** App-root-relative path of the written file. */\n path: z.string().min(1),\n existedBefore: z.boolean(),\n /** The file's bytes before the run, when one existed. */\n previousContent: z.string().optional(),\n /** The exact bytes the run wrote — revert refuses when the file has moved on from these (unless forced). */\n writtenContent: z.string().min(1),\n /**\n * What the landing found against the bytes the run READ (#1614): unchanged since, merged over another\n * writer's entries, or not compared. Absent on records from before it existed, and on files a run\n * derives rather than lands (wiring, diagrams, decision records).\n */\n concurrency: z.enum(ApplicationSpecificationLandingConcurrency).optional(),\n});\n\nconst RunWriteRecordSchema = z.strictObject({\n /** The actor execution's id — the run's one identity (#1358). */\n runId: z.string().min(1),\n playbookRef: z.string().min(1),\n /**\n * The trace session the run recorded under, when its request carried one. RECORDED here because the\n * run id no longer encodes it (#1358): a reader that wants the run's evidence joins on this field.\n */\n traceSessionId: z.string().min(1).optional(),\n at: z.string().min(1),\n /**\n * When the run STARTED — before it read anything it derives from (review F7, 2026-10-01). `at` is when its\n * writes were recorded, which is later; a run admitted beside a writer of a family it reads lands after\n * that writer, so judging it by `at` would call its output current although it was derived from the old\n * input. Optional: a record from before it existed is judged by `at`.\n */\n startedAt: z.string().min(1).optional(),\n /**\n * The catalog VERSION of the playbook that ran (#2158). A landing made by a version other than the one the\n * catalog holds now is a REFRESH, so a changed method re-derives unattended. Optional: older records carry\n * none and are not judged out of date.\n */\n playbookVersion: z.string().min(1).optional(),\n /**\n * Per family the run landed, the aspects it MEASURABLY changed (`measureChangedAspects`, #2146); `null` when the\n * change could not be confined to aspects, which counts as a change of the whole family. A record without this\n * field predates measurement, and only then does the writer's declaration decide.\n */\n aspectsChanged: z.record(z.string(), z.array(z.string().min(1)).nullable()).optional(),\n /** Aspect keys the brief-adequacy gate added to this run's brief: read by it, beyond what it declares. */\n readAspectsAdded: z.array(z.string().min(1)).optional(),\n files: z.array(RunWriteFileSchema).min(1),\n /**\n * Stamped when the run's writes were ACCEPTED through the workbench (#1454, Step 7) — a cache of\n * what `git log` already knows, so a row can say \"accepted\" without asking git. Optional, so every\n * record written before the field existed still parses.\n */\n acceptedAt: z.string().min(1).optional(),\n acceptedCommitSha: z.string().min(1).optional(),\n /**\n * The criteria the advisory judge rated GAP, stamped after the run when its overall verdict was GAP\n * (#2142). The judge answers AFTER the writes are recorded, so this arrives by a second write\n * (`markJudgedGap`). Read back as `PlaybookLandingHistory.lastLandingJudgedGapByPlaybook`, so an\n * unattended round reports a rejected-and-unchanged playbook as STUCK rather than as finished.\n * Optional: a record from before it existed, an unjudged run and a non-GAP verdict all carry none.\n */\n judgedGapCriteria: z.array(z.strictObject({ criterionRef: z.string().min(1), rationale: z.string().min(1).optional() })).min(1).optional(),\n});\nexport type PlaybookRunWriteRecord = z.infer<typeof RunWriteRecordSchema>;\n\n/** What {@link PlaybookRunWriteRegisterCompanionService.deriveLandingHistory} reads off the records, once per register change. */\ninterface RunLandingSummary {\n readonly lastLandedAtByPlaybook: ReadonlyMap<string, number>;\n /** Per playbook, the GAP criteria of its LATEST landing — only when that landing was judged GAP. */\n readonly lastLandingJudgedGapByPlaybook: ReadonlyMap<string, readonly PlaybookJudgedGapCriterion[]>;\n readonly latestByPath: ReadonlyMap<string, { readonly at: number; readonly playbookRef: string; readonly writtenContent: string }>;\n /** Per path, each writer's latest landing that changed it — see `PlaybookLandingHistory.landingsByFamily`. */\n readonly latestByPathAndWriter: ReadonlyMap<string, ReadonlyMap<string, number>>;\n /** Per playbook, the version its latest landing was recorded under (#2158). */\n readonly lastLandedVersionByPlaybook: ReadonlyMap<string, string>;\n /** Per path, the latest revert that put it back, and whose run it undid (#2157). */\n readonly latestRevertByPath: ReadonlyMap<string, { readonly at: number; readonly playbookRef: string }>;\n /** Per playbook, the aspects the brief-adequacy gate added to its latest run's brief. */\n readonly addedReadAspectsByPlaybook: ReadonlyMap<string, readonly string[]>;\n /** Per path, per writer, the measured `aspectsChanged` of that writer's latest landing there (undefined: not measured). */\n readonly latestAspectsByPathAndWriter: ReadonlyMap<string, ReadonlyMap<string, Readonly<Record<string, readonly string[] | null>> | undefined>>;\n /** Per path, the latest outside edit hidden between two landings (review F1). */\n readonly latestHiddenOutsideEditByPath: ReadonlyMap<string, number>;\n}\n\n/** How long after a revert's marker instant its own file write may still carry a later mtime. */\nconst REVERT_WRITE_SLACK_SECONDS = 2;\n\n/**\n * A REVERT, kept after its run's record is gone (#2157): which files it put back, and when. Without it, a revert\n * left the family holding an OLDER run's bytes, so its change was dated at that older landing, and a reader that\n * landed between the reverted write and the revert read CURRENT although it was derived from content that no\n * longer exists. Kept under `reverts/`, which `list()` never reads as a run.\n */\nconst RunRevertMarkerSchema = z.strictObject({\n runId: z.string().min(1),\n playbookRef: z.string().min(1),\n at: z.string().min(1),\n paths: z.array(z.string().min(1)).min(1),\n /**\n * The revert was FORCED over files edited since the run (`wildo creation revert --force`) and did discard such\n * an edit (#2231): set only when a file that would otherwise have been refused was reverted, never for a `--force`\n * that changed nothing a plain revert would not. Read by the intervention ledger; absent on an ordinary revert and on every marker\n * written before the field.\n */\n forced: z.literal(true).optional(),\n /**\n * What the reverted run WROTE, when it ran (#2231): its instant and each file's written bytes' sha256. A full\n * revert deletes the run's write record, and with it the only footprint that let the intervention ledger\n * attribute a commit of those files made before the revert. Kept here so the run still owns what it wrote.\n * Absent on markers written before the field.\n */\n runAt: z.string().min(1).optional(),\n writtenFiles: z.array(z.strictObject({ path: z.string().min(1), sha256: z.string().min(1) })).optional(),\n});\n\n/** One revert, as its marker records it (#2157, #2231). `markerId` is the marker's file name, one per revert. */\nexport interface PlaybookRunRevertMarker {\n readonly markerId: string;\n readonly runId: string;\n readonly playbookRef: string;\n readonly at: string;\n readonly paths: readonly string[];\n readonly forced: boolean;\n /** The reverted run's footprint — when it ran and what it wrote — when the marker carries it. */\n readonly runFootprint?: { readonly runAt: string; readonly writtenFiles: readonly { readonly path: string; readonly sha256: string }[] };\n}\n\n/** One file's change, as the board renders it. */\nexport interface PlaybookRunFileDiff {\n readonly path: string;\n readonly existedBefore: boolean;\n /** The file on disk no longer holds the bytes the run wrote — the same test `revert` applies. */\n readonly diverged: boolean;\n /** Unified diff of the run's own change. EMPTY when the run rewrote a file with identical bytes. */\n readonly diff: string;\n}\n\n/** What one run changed — a pure read over the register. */\nexport interface PlaybookRunDiff {\n readonly runId: string;\n readonly playbookRef: string;\n readonly at: string;\n readonly files: readonly PlaybookRunFileDiff[];\n}\n\nexport interface PlaybookRunRevertOutcome {\n readonly runId: string;\n readonly reverted: readonly string[];\n /** Files whose CURRENT bytes differ from what the run wrote — refused without `force` so a human edit is never silently destroyed. */\n readonly refusedDiverged: readonly string[];\n /**\n * Files whose current bytes are a LATER recorded run's landing (#1614). Refused even under `force`:\n * restoring this run's pre-image would destroy that run's work, which a person asking to undo THIS run\n * did not ask for. Revert the later run first.\n */\n readonly refusedLaterRun: readonly { readonly path: string; readonly runId: string }[];\n}\n\n/** Why a run's written file no longer holds its bytes: a later recorded run landed there, or something else changed it. */\nexport enum PlaybookRunFileSuccession {\n /** A later recorded run landed this path; the file holds its bytes, or a still later change on top of them. */\n LATER_RUN = 'later_run',\n /** No later recorded run wrote this path: a person or a tool outside the runs changed it. */\n EDITED_OUTSIDE_RUNS = 'edited_outside_runs',\n}\n\nexport class PlaybookRunWriteRecordNotFoundError extends Error {\n public constructor(runId: string) {\n super(`No write record exists for run \"${runId}\".`);\n }\n}\n\n/**\n * The per-run WRITE REGISTER: which files each playbook run wrote, with pre-images, so any run can be\n * reverted in one call while mechanisms are being exercised.\n *\n * ## A runtime convenience, not a second truth\n *\n * Records live in the gitignored companion state directory. Deleting them all costs exactly the\n * convenience — git still holds every accepted state, and `git diff` still shows every un-accepted write.\n * (`.claude/rules/one-source-of-truth.md`: cache, not ledger — losing it costs time, never truth.)\n *\n * ONE decision reads them, and it is a decision to NOT SPEND (2026-10-01): {@link deriveLandingHistory}\n * tells the eligibility board when each playbook last landed, so an unattended selection stops re-running\n * a playbook whose inputs have not moved (`PlaybookEligibility.rerun`). Deleting the records makes every\n * playbook read as a first run again (once the companion re-reads the register: the summary is kept until\n * the next record, revert or restart) — a re-run, never a lost fact — which is the one kind of refusal\n * Rule 5 lets runtime state make. Everything else here serves the list/revert doors a human operates.\n *\n * ## Revert protects the human's later edits\n *\n * Revert restores a file's pre-image (or deletes a file the run created) ONLY when the file still holds\n * the exact bytes the run wrote. A file that has moved on — a human edited it after the run — is refused\n * and reported, because destroying a person's edit to undo a machine's is the wrong trade. `force`\n * overrides per explicit request.\n *\n * This register is also the natural future home of per-file run locking (issue #48): the mechanism that\n * knows which files a run touches is the one that can hold locks between concurrent CLIs.\n */\n@injectable()\nexport class PlaybookRunWriteRegisterCompanionService {\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n /**\n * Notified after every mutation of the register (a `record` or a `revert`).\n *\n * The seam exists for the creation-plane eligibility cache: a run landing files is exactly the\n * event that changes playbook eligibility, and the projection service subscribes here rather\n * than being injected INTO this service (which would cycle — it already depends on this one).\n * Listeners are fire-and-forget and must not throw; a cache invalidation failing must never\n * fail the write it observes.\n */\n private readonly mutationListeners: Array<() => void> = [];\n\n public registerMutationListener(listener: () => void): void {\n this.mutationListeners.push(listener);\n }\n\n private notifyMutation(): void {\n this.landingSummary = undefined;\n for (const listener of this.mutationListeners) {\n try { listener(); } catch { /* a listener must never fail the write it observes */ }\n }\n }\n\n public constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(COMPANION_SERVICE_TYPES.CompanionContext) private readonly companionContext: CompanionContext,\n ) {\n this.logDebug = this.logger.debugByType('PlaybookRunWriteRegister');\n }\n\n /** The record-derived half of {@link deriveLandingHistory}, kept until the register next changes. */\n private landingSummary: Promise<RunLandingSummary> | undefined;\n\n /**\n * When each playbook last landed, and when each family's file last changed — the host's record of its\n * own runs that `PlaybookEligibility.rerun` reads (2026-10-01).\n *\n * Why the register and not git: during the definition phase nothing is committed (on\n * app-creation-test-004 every family after the vision was a working edit), and a commit time is when a\n * change was ACCEPTED, not when it was derived. The register holds the instant each run landed.\n *\n * A family's change is the latest run that wrote its file — unless a REVERT came after it (`revertOf`, read from\n * the markers under `reverts/`, #2157), or the file no longer holds the bytes that run wrote, which is the same\n * test `revert` uses (`diverged`): then somebody changed it OUTSIDE the runs, dated by the file's mtime. Outside\n * edits are also reported on their own (`lastOutsideEditByFamily`), including one hidden BETWEEN two landings, so\n * no later landing can mask them. A family no run ever wrote is left out, and the runtime falls back to git.\n *\n * On the board's hot path, so the parse of every record is memoised until the register changes; what is\n * read per call is only the handful of family files given here.\n *\n * @param familyFiles family → its file, app-root-relative, for the families that have content.\n */\n public async deriveLandingHistory(familyFiles: ReadonlyMap<string, string>): Promise<PlaybookLandingHistory | undefined> {\n this.landingSummary ??= this.summarizeLandings();\n /*\n * An unreadable register is NO history — `undefined`, so every verdict is UNTRACKED and offered as before\n * this existed — never an empty one, which would label every playbook a first run (review F11). Asked\n * again on the next call.\n */\n const summary = await this.landingSummary.catch(() => {\n this.landingSummary = undefined;\n return undefined;\n });\n if (summary === undefined) return undefined;\n const lastChangeByFamily = new Map<string, PlaybookFamilyChange>();\n const landingsByFamily = new Map<string, ReadonlyMap<string, number>>();\n const landedAspectsByFamily = new Map<string, ReadonlyMap<string, readonly string[] | null>>();\n const lastOutsideEditByFamily = new Map<string, number>();\n const noteOutsideEdit = (family: string, at: number): void => {\n if (at > (lastOutsideEditByFamily.get(family) ?? 0)) lastOutsideEditByFamily.set(family, at);\n };\n for (const [family, appRelativePath] of familyFiles) {\n const writers = summary.latestByPathAndWriter.get(appRelativePath);\n if (writers !== undefined) landingsByFamily.set(family, writers);\n // What each writer's latest landing measurably changed in THIS family, when it was measured (#2146).\n const measured = new Map<string, readonly string[] | null>();\n for (const [writer, changed] of summary.latestAspectsByPathAndWriter.get(appRelativePath) ?? []) {\n // A measured record names every family it landed; `null` there is a whole-family change (review R1).\n if (changed !== undefined && Object.hasOwn(changed, family)) measured.set(writer, changed[family] ?? null);\n }\n if (measured.size > 0) landedAspectsByFamily.set(family, measured);\n // An edit hidden BETWEEN two landings: a later run found bytes the earlier run did not write (review F1).\n const hidden = summary.latestHiddenOutsideEditByPath.get(appRelativePath);\n if (hidden !== undefined) noteOutsideEdit(family, hidden);\n const landing = summary.latestByPath.get(appRelativePath);\n const absolutePath = path.join(this.companionContext.saasRoot, appRelativePath);\n // A revert after the latest landing is the family's latest change, attributed to the run it undid (#2157).\n const revert = summary.latestRevertByPath.get(appRelativePath);\n if (revert !== undefined && (landing === undefined || revert.at > landing.at)) {\n lastChangeByFamily.set(family, { at: revert.at, revertOf: revert.playbookRef });\n // A file touched after the revert wrote it was edited outside the runs since (review F2). The revert's own\n // write precedes its marker, so its mtime is never later than the marker's instant plus a moment.\n const modifiedAt = await stat(absolutePath).then((entry) => entry.mtimeMs / 1000).catch(() => undefined);\n if (modifiedAt !== undefined && modifiedAt > revert.at + REVERT_WRITE_SLACK_SECONDS) noteOutsideEdit(family, modifiedAt);\n continue;\n }\n if (landing === undefined) continue;\n const current = await readFile(absolutePath, 'utf8').catch(() => undefined);\n if (current === undefined || current === landing.writtenContent) {\n lastChangeByFamily.set(family, { at: landing.at, byPlaybookRef: landing.playbookRef });\n continue;\n }\n const modifiedAt = await stat(absolutePath).then((entry) => entry.mtimeMs / 1000).catch(() => landing.at);\n lastChangeByFamily.set(family, { at: Math.max(landing.at, modifiedAt) });\n noteOutsideEdit(family, Math.max(landing.at, modifiedAt));\n }\n return {\n lastLandedAtByPlaybook: summary.lastLandedAtByPlaybook,\n lastChangeByFamily,\n landingsByFamily,\n lastLandingJudgedGapByPlaybook: summary.lastLandingJudgedGapByPlaybook,\n ...(summary.lastLandedVersionByPlaybook.size > 0 ? { lastLandedVersionByPlaybook: summary.lastLandedVersionByPlaybook } : {}),\n ...(lastOutsideEditByFamily.size > 0 ? { lastOutsideEditByFamily } : {}),\n ...(landedAspectsByFamily.size > 0 ? { landedAspectsByFamily } : {}),\n ...(summary.addedReadAspectsByPlaybook.size > 0 ? { addedReadAspectsByPlaybook: summary.addedReadAspectsByPlaybook } : {}),\n };\n }\n\n private async summarizeLandings(): Promise<RunLandingSummary> {\n const lastLandedAtByPlaybook = new Map<string, number>();\n const lastLandingJudgedGapByPlaybook = new Map<string, readonly PlaybookJudgedGapCriterion[]>();\n const latestByPath = new Map<string, { readonly at: number; readonly playbookRef: string; readonly writtenContent: string }>();\n const latestByPathAndWriter = new Map<string, Map<string, number>>();\n const lastLandedVersionByPlaybook = new Map<string, string>();\n const addedReadAspectsByPlaybook = new Map<string, readonly string[]>();\n const latestAspectsByPathAndWriter = new Map<string, Map<string, Readonly<Record<string, readonly string[]>> | undefined>>();\n // Every landing of each path, oldest first, to find an edit made between two of them (review F1).\n const landingsOfPath = new Map<string, { readonly at: number; readonly existedBefore: boolean; readonly previousContent?: string; readonly writtenContent: string }[]>();\n /*\n * `list()` is newest first, so the first sighting of a playbook or a path is its latest. Seconds keep\n * their fraction: two landings in one second must still order (review F7).\n *\n * A playbook is judged by when it STARTED (it derived from what it read then); a family changed when a\n * run's writes LANDED. A file rewritten with the bytes it already held is no change (review F4): measured\n * on app-creation-test-004, value-proposition's 06:15 run rewrote the market snapshot byte for byte, and\n * counting it would have made every reader of the snapshot a refresh with nothing changed.\n */\n for (const record of await this.list()) {\n const at = Date.parse(record.at) / 1000;\n if (Number.isNaN(at)) continue;\n const startedAt = record.startedAt !== undefined ? Date.parse(record.startedAt) / 1000 : Number.NaN;\n if (!lastLandedAtByPlaybook.has(record.playbookRef)) {\n lastLandedAtByPlaybook.set(record.playbookRef, Number.isNaN(startedAt) ? at : startedAt);\n // The LATEST landing's verdict only: a later landing the judge did not reject supersedes an earlier GAP.\n if (record.judgedGapCriteria !== undefined) lastLandingJudgedGapByPlaybook.set(record.playbookRef, record.judgedGapCriteria);\n if (record.playbookVersion !== undefined) lastLandedVersionByPlaybook.set(record.playbookRef, record.playbookVersion);\n if (record.readAspectsAdded !== undefined && record.readAspectsAdded.length > 0) addedReadAspectsByPlaybook.set(record.playbookRef, record.readAspectsAdded);\n }\n for (const file of record.files) {\n landingsOfPath.set(file.path, [{\n at: Number.isNaN(startedAt) ? at : startedAt,\n existedBefore: file.existedBefore,\n ...(file.previousContent !== undefined ? { previousContent: file.previousContent } : {}),\n writtenContent: file.writtenContent,\n }, ...(landingsOfPath.get(file.path) ?? [])]);\n if (file.existedBefore && file.previousContent === file.writtenContent) continue;\n const writerAspects = latestAspectsByPathAndWriter.get(file.path) ?? new Map();\n if (!writerAspects.has(record.playbookRef)) writerAspects.set(record.playbookRef, record.aspectsChanged);\n latestAspectsByPathAndWriter.set(file.path, writerAspects);\n if (!latestByPath.has(file.path)) latestByPath.set(file.path, { at, playbookRef: record.playbookRef, writtenContent: file.writtenContent });\n const writers = latestByPathAndWriter.get(file.path) ?? new Map<string, number>();\n if (!writers.has(record.playbookRef)) writers.set(record.playbookRef, at);\n latestByPathAndWriter.set(file.path, writers);\n }\n }\n const latestRevertByPath = new Map<string, { readonly at: number; readonly playbookRef: string }>();\n const markers = await readdir(this.resolveRevertDirectory()).catch(() => [] as string[]);\n for (const entry of markers.filter((name) => name.endsWith('.json'))) {\n const parsed = await readFile(path.join(this.resolveRevertDirectory(), entry), 'utf8')\n .then((raw) => RunRevertMarkerSchema.safeParse(JSON.parse(raw)))\n .catch(() => undefined);\n if (parsed?.success !== true) continue;\n const at = Date.parse(parsed.data.at) / 1000;\n if (Number.isNaN(at)) continue;\n for (const revertedPath of parsed.data.paths) {\n const known = latestRevertByPath.get(revertedPath);\n if (known === undefined || at > known.at) latestRevertByPath.set(revertedPath, { at, playbookRef: parsed.data.playbookRef });\n }\n }\n /*\n * An edit hidden between two landings: a run's pre-image is not what the run before it wrote — or the file was\n * gone although that run had written it. Dated at the later run's start, the latest moment it can have happened,\n * so a reader that landed in between is reopened (the safe direction).\n */\n const latestHiddenOutsideEditByPath = new Map<string, number>();\n for (const [filePath, landings] of landingsOfPath) {\n for (let index = 1; index < landings.length; index += 1) {\n const earlier = landings[index - 1]!;\n const later = landings[index]!;\n const editedBetween = later.existedBefore ? later.previousContent !== undefined && later.previousContent !== earlier.writtenContent : true;\n if (editedBetween) latestHiddenOutsideEditByPath.set(filePath, Math.max(latestHiddenOutsideEditByPath.get(filePath) ?? 0, later.at));\n }\n }\n return {\n lastLandedAtByPlaybook, lastLandingJudgedGapByPlaybook, latestByPath, latestByPathAndWriter, lastLandedVersionByPlaybook,\n latestRevertByPath, addedReadAspectsByPlaybook, latestAspectsByPathAndWriter, latestHiddenOutsideEditByPath,\n };\n }\n\n public async record(record: PlaybookRunWriteRecord): Promise<void> {\n const parsed = RunWriteRecordSchema.parse(record);\n const registerDirectory = this.resolveRegisterDirectory();\n await mkdir(registerDirectory, { recursive: true });\n await writeFile(this.resolveRecordPath(parsed.runId), `${JSON.stringify(parsed, null, 2)}\\n`, 'utf8');\n this.logDebug('Recorded run writes', { runId: parsed.runId, files: parsed.files.length });\n this.notifyMutation();\n }\n\n /** Newest first. A record that no longer parses is skipped (a cache never fails its reader). */\n public async list(): Promise<readonly PlaybookRunWriteRecord[]> {\n const registerDirectory = this.resolveRegisterDirectory();\n const entries = await readdir(registerDirectory).catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') return [] as string[];\n throw error;\n });\n const records: PlaybookRunWriteRecord[] = [];\n for (const entry of entries.filter((name) => name.endsWith('.json'))) {\n try {\n const raw = await readFile(path.join(registerDirectory, entry), 'utf8');\n records.push(RunWriteRecordSchema.parse(JSON.parse(raw)));\n } catch {\n this.logDebug('Skipping unreadable run-write record', { entry });\n }\n }\n return records.sort((left, right) => right.at.localeCompare(left.at));\n }\n\n /**\n * WHAT a run changed, per file — the board's answer to \"should I commit this?\" (#1274).\n *\n * The board dispatches writes into the working tree and, until this existed, could only list the\n * PATHS. That undercuts the doctrine printed at the top of every one of its screens — *acceptance\n * is your own git commit* — because it hands over the commit decision with no way to inspect the\n * change.\n *\n * ## Why the diff comes from the REGISTER and not from git\n *\n * `git diff` answers a different question: what is UNCOMMITTED at a path. That equals the run's\n * change only while nothing else has touched the path since, so a second run, a human edit, or an\n * unrelated generation silently widens it. The register holds the exact bytes before\n * (`previousContent`) and the exact bytes the run wrote (`writtenContent`), so this diff is\n * attributed to the RUN and cannot drift.\n *\n * ## `diverged` is the honest half\n *\n * A file may have moved on since the run wrote it, and this read must not pretend otherwise — the\n * diff still describes what the RUN did, but it is no longer what is on disk. The test is exactly\n * the one `revert` uses to decide whether it may restore a file, deliberately: two different\n * answers to \"has this moved on?\" on one register is how a board comes to offer a revert it cannot\n * perform, or withhold one it could.\n *\n * A pure READ — nothing is locked, written or reverted.\n */\n public async markAccepted(runId: string, commitSha: string, at: string): Promise<void> {\n const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') throw new PlaybookRunWriteRecordNotFoundError(runId);\n throw error;\n });\n await this.record({ ...RunWriteRecordSchema.parse(JSON.parse(raw)), acceptedAt: at, acceptedCommitSha: commitSha });\n }\n\n /**\n * Stamp the criteria the judge rated GAP onto a recorded run (#2142). Same read-modify-record shape as\n * `markAccepted`; `record` notifies, so the memoised landing summary is re-derived.\n */\n public async markJudgedGap(runId: string, criteria: readonly PlaybookJudgedGapCriterion[]): Promise<void> {\n if (criteria.length === 0) return;\n const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') throw new PlaybookRunWriteRecordNotFoundError(runId);\n throw error;\n });\n await this.record({ ...RunWriteRecordSchema.parse(JSON.parse(raw)), judgedGapCriteria: criteria.map((criterion) => ({ ...criterion })) });\n }\n\n public async describeRunDiff(runId: string): Promise<PlaybookRunDiff> {\n const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') throw new PlaybookRunWriteRecordNotFoundError(runId);\n throw error;\n });\n const record = RunWriteRecordSchema.parse(JSON.parse(raw));\n\n const files = await Promise.all(record.files.map(async (file) => {\n const absolutePath = path.resolve(this.companionContext.saasRoot, file.path);\n const current = await readFile(absolutePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') return undefined;\n throw error;\n });\n const createdFileAlreadyAbsent = !file.existedBefore && current === undefined;\n return {\n path: file.path,\n existedBefore: file.existedBefore,\n diverged: !createdFileAlreadyAbsent && current !== file.writtenContent,\n /* A created file has no pre-image, so every line is an addition. */\n diff: renderUnifiedDiff(file.previousContent ?? '', file.writtenContent),\n };\n }));\n\n return { runId: record.runId, playbookRef: record.playbookRef, at: record.at, files };\n }\n\n public async revert(runId: string, options: { readonly force?: boolean } = {}): Promise<PlaybookRunRevertOutcome> {\n const raw = await readFile(this.resolveRecordPath(runId), 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') throw new PlaybookRunWriteRecordNotFoundError(runId);\n throw error;\n });\n const record = RunWriteRecordSchema.parse(JSON.parse(raw));\n\n const reverted: string[] = [];\n const refusedDiverged: string[] = [];\n const refusedLaterRun: { path: string; runId: string }[] = [];\n let overwroteEdits = false;\n const laterRecords = (await this.list()).filter((candidate) => candidate.runId !== record.runId && candidate.at > record.at);\n for (const file of record.files) {\n const absolutePath = path.resolve(this.companionContext.saasRoot, file.path);\n const current = await readFile(absolutePath, 'utf8').catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') return undefined;\n throw error;\n });\n // Absence is a later change when restoring would recreate an overwritten file.\n // A created file already absent is settled: removing it again changes nothing.\n const createdFileAlreadyAbsent = !file.existedBefore && current === undefined;\n const laterWriter = laterRecords.find((later) => later.files.some((laterFile) => laterFile.path === file.path && laterFile.writtenContent === current));\n if (laterWriter) {\n refusedLaterRun.push({ path: file.path, runId: laterWriter.runId });\n continue;\n }\n const diverged = !createdFileAlreadyAbsent && current !== file.writtenContent;\n if (options.force !== true && diverged) {\n refusedDiverged.push(file.path);\n continue;\n }\n // Forced AND it mattered: this file held an edit made since the run, which the revert now discards.\n if (diverged) overwroteEdits = true;\n if (file.existedBefore && file.previousContent !== undefined) {\n // Atomically: a revert rewrites specification files the companion is reading (#2250).\n await writeSpecificationFileAtomically(absolutePath, file.previousContent);\n } else {\n await unlink(absolutePath).catch((error: NodeJS.ErrnoException) => {\n if (error?.code !== 'ENOENT') throw error;\n });\n }\n reverted.push(file.path);\n }\n\n // Keep ONLY unsettled paths after a partial outcome. Rechecking already restored files\n // against generated bytes manufactured conflicts; forcing that retry could overwrite\n // edits made after the first undo. The remaining pre-images retain their original meaning.\n const unsettled = new Set([...refusedDiverged, ...refusedLaterRun.map((entry) => entry.path)]);\n if (unsettled.size === 0) {\n await rm(this.resolveRecordPath(runId), { force: true });\n } else if (reverted.length > 0) {\n await this.record({ ...record, files: record.files.filter((file) => unsettled.has(file.path)) });\n }\n if (reverted.length > 0) {\n // Best-effort: losing the marker costs only the dating of this revert, never the revert itself.\n const marker = RunRevertMarkerSchema.parse({\n runId,\n playbookRef: record.playbookRef,\n at: new Date().toISOString(),\n paths: reverted,\n ...(overwroteEdits ? { forced: true } : {}),\n runAt: record.at,\n writtenFiles: record.files.map((file) => ({ path: file.path, sha256: createHash('sha256').update(file.writtenContent).digest('hex') })),\n });\n await mkdir(this.resolveRevertDirectory(), { recursive: true })\n // One file per revert, never per run: a partial revert followed by a forced one must keep both dates (review F3).\n .then(() => writeFile(path.join(this.resolveRevertDirectory(), `${runId}-${Date.now()}.json`), `${JSON.stringify(marker, null, 2)}\\n`, 'utf8'))\n .catch((error: unknown) => this.logDebug('Could not record the revert marker', { runId, error: String(error) }));\n }\n this.logDebug('Reverted run writes', { runId, reverted: reverted.length, refused: refusedDiverged.length, refusedLaterRun: refusedLaterRun.length });\n this.notifyMutation();\n return { runId, reverted, refusedDiverged, refusedLaterRun };\n }\n\n /**\n * Every revert marker, oldest first (#2231): what the intervention ledger counts as a person's revert. A marker\n * that no longer parses is skipped, as `list` skips a record — the register is a cache, never a reader's failure.\n */\n public async listReverts(): Promise<readonly PlaybookRunRevertMarker[]> {\n const directory = this.resolveRevertDirectory();\n const entries = await readdir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error?.code === 'ENOENT') return [] as string[];\n throw error;\n });\n const markers: PlaybookRunRevertMarker[] = [];\n for (const entry of entries.filter((name) => name.endsWith('.json'))) {\n try {\n const marker = RunRevertMarkerSchema.parse(JSON.parse(await readFile(path.join(directory, entry), 'utf8')));\n markers.push({\n markerId: entry.replace(/\\.json$/, ''),\n runId: marker.runId,\n playbookRef: marker.playbookRef,\n at: marker.at,\n paths: marker.paths,\n forced: marker.forced === true,\n ...(marker.runAt && marker.writtenFiles ? { runFootprint: { runAt: marker.runAt, writtenFiles: marker.writtenFiles } } : {}),\n });\n } catch {\n this.logDebug('Skipping unreadable revert marker', { entry });\n }\n }\n return markers.sort((left, right) => left.at.localeCompare(right.at));\n }\n\n /**\n * Why each of a run's files no longer holds what the run wrote (#1614): a LATER recorded run wrote the\n * same path, or nothing recorded did. Acceptance reads this so a run whose work was refined by a later\n * run is not reported the same way as one a person edited over.\n */\n public async describeSuccession(runId: string): Promise<ReadonlyMap<string, PlaybookRunFileSuccession>> {\n const records = await this.list();\n const record = records.find((candidate) => candidate.runId === runId);\n if (!record) throw new PlaybookRunWriteRecordNotFoundError(runId);\n const succession = new Map<string, PlaybookRunFileSuccession>();\n for (const file of record.files) {\n const laterRun = records.some((later) => later.runId !== runId && later.at > record.at && later.files.some((laterFile) => laterFile.path === file.path));\n succession.set(file.path, laterRun ? PlaybookRunFileSuccession.LATER_RUN : PlaybookRunFileSuccession.EDITED_OUTSIDE_RUNS);\n }\n return succession;\n }\n\n private resolveRegisterDirectory(): string {\n return path.resolve(this.companionContext.saasRoot, '.wildo-saas/state/meta-workflows/run-writes');\n }\n\n private resolveRevertDirectory(): string {\n return path.join(this.resolveRegisterDirectory(), 'reverts');\n }\n\n private resolveRecordPath(runId: string): string {\n // The runId doubles as a file name; refuse anything path-shaped.\n if (!/^[a-zA-Z0-9._-]+$/.test(runId)) throw new Error(`Run id \"${runId}\" is not a valid record name.`);\n return path.join(this.resolveRegisterDirectory(), `${runId}.json`);\n }\n}\n"]}
|