@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
|
@@ -32,7 +32,12 @@ export async function readPerUnitLabels(filePath) {
|
|
|
32
32
|
throw err;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The file content for one unit in one locale, refused when a value carries a control character —
|
|
37
|
+
* everything {@link writePerUnitLabels} does except the write. Split out so a run can stage the
|
|
38
|
+
* content in a `StagedLabelFileWriter` and move it into place with the rest of the run (#2213).
|
|
39
|
+
*/
|
|
40
|
+
export function renderPerUnitLabels(args) {
|
|
36
41
|
// The last door before disk (#1109). The completion loop already refuses and re-requests a
|
|
37
42
|
// value carrying a control character, so a value arriving here is one no generation path
|
|
38
43
|
// produced — a corrupt prior file being carried forward, or a caller that bypassed the loop.
|
|
@@ -43,12 +48,15 @@ export async function writePerUnitLabels(args) {
|
|
|
43
48
|
throw new Error(`Refusing to write ${args.filePath}: ${corrupt.length} label value(s) carry a control character (${corrupt.slice(0, 5).join(', ')}${corrupt.length > 5 ? ', …' : ''}). A control byte in a label reaches the UI, the logs and every export of the label tree; regenerate the unit.`);
|
|
44
49
|
}
|
|
45
50
|
const nested = buildNestedLabelsFromFlatEntries(args.flatEntries);
|
|
46
|
-
|
|
51
|
+
return formatNestedLabelsTsFile({
|
|
47
52
|
localeCode: args.localeCode,
|
|
48
53
|
localeDisplayName: args.localeDisplayName,
|
|
49
54
|
isPrimaryLocale: args.isPrimaryLocale,
|
|
50
55
|
labels: nested,
|
|
51
56
|
});
|
|
57
|
+
}
|
|
58
|
+
export async function writePerUnitLabels(args) {
|
|
59
|
+
const content = renderPerUnitLabels(args);
|
|
52
60
|
await fs.mkdir(path.dirname(args.filePath), { recursive: true });
|
|
53
61
|
await writeFileAtomic(args.filePath, content);
|
|
54
62
|
return content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"per-unit-file.utils.js","sourceRoot":"","sources":["../../../../../src/i18n-labelling/utils/per-unit-file.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AASxF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAuB;IACxF,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,IAAI,UAAU,KAAK,CAAC,CAAC;AACxG,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACtD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,yBAAyB,CAAC,G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,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,MAAM,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport {\n buildNestedLabelsFromFlatEntries,\n flattenNestedStringLabels,\n formatNestedLabelsTsFile,\n parseNestedLabelsTsSource,\n} from './label-file-source.utils';\nimport { writeFileAtomic } from '../../core/utils/atomic-write.utils';\nimport { labelValueCarriesControlCharacter } from './structured-chunk-completion.utils';\nimport type { LabellingUnit } from '../models/labelling-unit.models';\n\nexport interface PerUnitFilePathArgs {\n i18nRoot: string;\n unit: Pick<LabellingUnit, 'filePathHint'>;\n localeCode: string;\n}\n\n/**\n * Resolve the on-disk path for a unit's per-locale labels file.\n * Layout (under `<backendRoot>/src/engine/i18n/`):\n * - `components/<slug>.<locale>.ts`\n * - `resources/<slug>.<locale>.ts`\n * - `themes/<slug>.<locale>.ts`\n * - `milestones/<slug>.<locale>.ts`\n * - `billing/<slug>.<locale>.ts`\n *\n * These per-unit files are the runtime source of truth — there is no\n * monolithic `labels.<locale>.ts`. The backend's engine i18n barrel\n * walks this tree at module load via\n * {@link scanCustomLabelsDirectory} from `@wildo-ai/saas-backend-lib`.\n */\nexport function resolvePerUnitFilePath({ i18nRoot, unit, localeCode }: PerUnitFilePathArgs): string {\n return path.resolve(i18nRoot, unit.filePathHint.bucket, `${unit.filePathHint.slug}.${localeCode}.ts`);\n}\n\nexport async function readPerUnitLabels(filePath: string): Promise<Record<string, string>> {\n try {\n const raw = await fs.readFile(filePath, 'utf-8');\n const parsed = parseNestedLabelsTsSource(raw);\n return flattenNestedStringLabels(parsed.labels);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') return {};\n throw err;\n }\n}\n\n/**\n * The file content for one unit in one locale, refused when a value carries a control character —\n * everything {@link writePerUnitLabels} does except the write. Split out so a run can stage the\n * content in a `StagedLabelFileWriter` and move it into place with the rest of the run (#2213).\n */\nexport function renderPerUnitLabels(args: {\n filePath: string;\n localeCode: string;\n localeDisplayName: string;\n isPrimaryLocale: boolean;\n flatEntries: Record<string, string>;\n}): string {\n // The last door before disk (#1109). The completion loop already refuses and re-requests a\n // value carrying a control character, so a value arriving here is one no generation path\n // produced — a corrupt prior file being carried forward, or a caller that bypassed the loop.\n // A bundle is loaded by the backend and served to every client, so refusing the unit is\n // cheaper than any reader finding the byte.\n const corrupt = Object.entries(args.flatEntries).filter(([, value]) => labelValueCarriesControlCharacter(value)).map(([key]) => key);\n if (corrupt.length > 0) {\n throw new Error(\n `Refusing to write ${args.filePath}: ${corrupt.length} label value(s) carry a control character (${corrupt.slice(0, 5).join(', ')}${corrupt.length > 5 ? ', …' : ''}). A control byte in a label reaches the UI, the logs and every export of the label tree; regenerate the unit.`,\n );\n }\n const nested = buildNestedLabelsFromFlatEntries(args.flatEntries);\n return formatNestedLabelsTsFile({\n localeCode: args.localeCode,\n localeDisplayName: args.localeDisplayName,\n isPrimaryLocale: args.isPrimaryLocale,\n labels: nested,\n });\n}\n\nexport async function writePerUnitLabels(args: {\n filePath: string;\n localeCode: string;\n localeDisplayName: string;\n isPrimaryLocale: boolean;\n flatEntries: Record<string, string>;\n}): Promise<string> {\n const content = renderPerUnitLabels(args);\n await fs.mkdir(path.dirname(args.filePath), { recursive: true });\n await writeFileAtomic(args.filePath, content);\n return content;\n}\n"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a labelling run stages its generated files: `<saasRoot>/.wildo-saas/state/label-staging/`.
|
|
3
|
+
*
|
|
4
|
+
* Under `.wildo-saas/state`, which every application gitignores (the skeleton's `gitignore` and both
|
|
5
|
+
* dogfood applications), and which nothing watches: the backend's `tsc-watch` watches its own package,
|
|
6
|
+
* and the introspection observer never descends `.wildo-saas`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const LABEL_STAGING_RELATIVE_ROOT: string;
|
|
9
|
+
/**
|
|
10
|
+
* Stages a labelling run's generated files on disk and moves them into the application in ONE burst
|
|
11
|
+
* when the run ends (#2213).
|
|
12
|
+
*
|
|
13
|
+
* ## Why
|
|
14
|
+
*
|
|
15
|
+
* Label files live inside the application's backend source (`<backend>/src/engine/i18n/**`, and each
|
|
16
|
+
* email template's `labels.<locale>.ts`). Every file written there wakes two watchers that each do a
|
|
17
|
+
* whole application's worth of work: the backend's `tsc-watch` recompiles and RESTARTS the server, and
|
|
18
|
+
* the companion's introspection watcher sees the emitted `dist` move and recompiles every derivation
|
|
19
|
+
* that can read the backend (#2245). Measured on `app-creation-test-004` (2026-10-01) over 2h20 of one
|
|
20
|
+
* `i18n-labels` step: 215 backend boots, 41 recompile passes, 300 introspection subprocesses.
|
|
21
|
+
*
|
|
22
|
+
* Staged files reach the application only at the end of the run, all at once, so a whole run costs one
|
|
23
|
+
* restart and one recompile pass. They are renamed into place, which is atomic per file and lands every
|
|
24
|
+
* file inside one watcher settle window.
|
|
25
|
+
*
|
|
26
|
+
* ## Why on disk rather than in memory
|
|
27
|
+
*
|
|
28
|
+
* The first version (efb3a30a8d) held files in memory and wrote a burst every five minutes, because a
|
|
29
|
+
* companion that stopped mid-run would lose everything held. On disk, nothing is lost: a run that dies
|
|
30
|
+
* leaves its staging directory behind, and the next run adopts it ({@link adoptAbandonedLabelStaging})
|
|
31
|
+
* before doing any work. So the run can wait until its end, which is what makes it one restart.
|
|
32
|
+
*
|
|
33
|
+
* ## Why recording a unit before its file lands is safe
|
|
34
|
+
*
|
|
35
|
+
* The run records a unit in the lock (`fresh`, with the SHA of what it produced) before the file
|
|
36
|
+
* reaches its place. Every freshness check compares that SHA with the file ON DISK in its place, so a
|
|
37
|
+
* staged file that never lands reads as drifted and is redone; and translate refuses to translate from
|
|
38
|
+
* a primary file that does not match the labellize record, so a run overlapping another's staging can
|
|
39
|
+
* never record a wrong fresh.
|
|
40
|
+
*
|
|
41
|
+
* A file that cannot be moved into place is reported back to the run, which turns that unit's result
|
|
42
|
+
* into a FAILED row. It stays staged, and a later run adopts it.
|
|
43
|
+
*
|
|
44
|
+
* ## What is NOT staged
|
|
45
|
+
*
|
|
46
|
+
* A target outside the application root is written at once (staging mirrors paths relative to the
|
|
47
|
+
* root, so it has nowhere to put it). The labellize adoption prune, which reads its own file back, and
|
|
48
|
+
* the framework-base seeders, which already write as one burst before the unit pool, write directly.
|
|
49
|
+
*/
|
|
50
|
+
export declare class StagedLabelFileWriter {
|
|
51
|
+
private readonly saasRoot;
|
|
52
|
+
private readonly runDirectory;
|
|
53
|
+
/** Staged files by their target path. */
|
|
54
|
+
private readonly staged;
|
|
55
|
+
private closed;
|
|
56
|
+
private constructor();
|
|
57
|
+
/** Open a run's staging directory and mark it as owned by this process. */
|
|
58
|
+
static open(saasRoot: string): Promise<StagedLabelFileWriter>;
|
|
59
|
+
/**
|
|
60
|
+
* Stage `content` for `targetPath`. Throws when it cannot be written, so the caller records the unit
|
|
61
|
+
* FAILED before anything is recorded in the lock.
|
|
62
|
+
*/
|
|
63
|
+
stage(targetPath: string, content: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Move every staged file into place, as one burst, and return every file that could not be moved, by
|
|
66
|
+
* target path. Idempotent. The run calls it before it reports, however the run ended.
|
|
67
|
+
*/
|
|
68
|
+
close(): Promise<ReadonlyMap<string, string>>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Move into place the files a dead or finished run left staged (#2213).
|
|
72
|
+
*
|
|
73
|
+
* A run directory is adopted when its marker says the run closed, or its process is gone; a live run's
|
|
74
|
+
* directory is never touched. A staged file is moved only if the file in its place is not NEWER — a
|
|
75
|
+
* file written in place since (a person's edit, another run) is not overwritten, and the staged one is
|
|
76
|
+
* discarded. Its lock record then disagrees with the disk, so the unit is redone. Never throws: a
|
|
77
|
+
* staging root it cannot read adopts nothing.
|
|
78
|
+
*/
|
|
79
|
+
export declare function adoptAbandonedLabelStaging(saasRoot: string): Promise<{
|
|
80
|
+
readonly adopted: readonly string[];
|
|
81
|
+
readonly discarded: readonly string[];
|
|
82
|
+
}>;
|
|
83
|
+
/** A run's results with every unit whose file could not be put in place turned into a FAILED row. */
|
|
84
|
+
export declare function withUnwrittenFilesFailed<T extends {
|
|
85
|
+
filePath: string;
|
|
86
|
+
status: string;
|
|
87
|
+
error?: string;
|
|
88
|
+
}>(results: readonly T[], failures: ReadonlyMap<string, string>, failedStatus: T['status']): T[];
|
|
89
|
+
//# sourceMappingURL=staged-label-file-writer.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staged-label-file-writer.utils.d.ts","sourceRoot":"","sources":["../../../../../src/i18n-labelling/utils/staged-label-file-writer.utils.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,QAAqD,CAAC;AAY9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,qBAAqB;IAM9B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO;IAKP,2EAA2E;WACvD,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAO1E;;;OAGG;IACU,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYtE;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAY3D;AAED;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CA6B1J;AAED,qGAAqG;AACrG,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACrG,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,GACxB,CAAC,EAAE,CAML"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import * as fs from 'node:fs/promises';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { writeFileAtomic } from '../../core/utils/atomic-write.utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* Where a labelling run stages its generated files: `<saasRoot>/.wildo-saas/state/label-staging/`.
|
|
7
|
+
*
|
|
8
|
+
* Under `.wildo-saas/state`, which every application gitignores (the skeleton's `gitignore` and both
|
|
9
|
+
* dogfood applications), and which nothing watches: the backend's `tsc-watch` watches its own package,
|
|
10
|
+
* and the introspection observer never descends `.wildo-saas`.
|
|
11
|
+
*/
|
|
12
|
+
export const LABEL_STAGING_RELATIVE_ROOT = path.join('.wildo-saas', 'state', 'label-staging');
|
|
13
|
+
/** The marker each run's staging directory carries, so another run can tell a live run from a dead one. */
|
|
14
|
+
const RUN_MARKER_FILE_NAME = 'run.json';
|
|
15
|
+
/**
|
|
16
|
+
* Stages a labelling run's generated files on disk and moves them into the application in ONE burst
|
|
17
|
+
* when the run ends (#2213).
|
|
18
|
+
*
|
|
19
|
+
* ## Why
|
|
20
|
+
*
|
|
21
|
+
* Label files live inside the application's backend source (`<backend>/src/engine/i18n/**`, and each
|
|
22
|
+
* email template's `labels.<locale>.ts`). Every file written there wakes two watchers that each do a
|
|
23
|
+
* whole application's worth of work: the backend's `tsc-watch` recompiles and RESTARTS the server, and
|
|
24
|
+
* the companion's introspection watcher sees the emitted `dist` move and recompiles every derivation
|
|
25
|
+
* that can read the backend (#2245). Measured on `app-creation-test-004` (2026-10-01) over 2h20 of one
|
|
26
|
+
* `i18n-labels` step: 215 backend boots, 41 recompile passes, 300 introspection subprocesses.
|
|
27
|
+
*
|
|
28
|
+
* Staged files reach the application only at the end of the run, all at once, so a whole run costs one
|
|
29
|
+
* restart and one recompile pass. They are renamed into place, which is atomic per file and lands every
|
|
30
|
+
* file inside one watcher settle window.
|
|
31
|
+
*
|
|
32
|
+
* ## Why on disk rather than in memory
|
|
33
|
+
*
|
|
34
|
+
* The first version (efb3a30a8d) held files in memory and wrote a burst every five minutes, because a
|
|
35
|
+
* companion that stopped mid-run would lose everything held. On disk, nothing is lost: a run that dies
|
|
36
|
+
* leaves its staging directory behind, and the next run adopts it ({@link adoptAbandonedLabelStaging})
|
|
37
|
+
* before doing any work. So the run can wait until its end, which is what makes it one restart.
|
|
38
|
+
*
|
|
39
|
+
* ## Why recording a unit before its file lands is safe
|
|
40
|
+
*
|
|
41
|
+
* The run records a unit in the lock (`fresh`, with the SHA of what it produced) before the file
|
|
42
|
+
* reaches its place. Every freshness check compares that SHA with the file ON DISK in its place, so a
|
|
43
|
+
* staged file that never lands reads as drifted and is redone; and translate refuses to translate from
|
|
44
|
+
* a primary file that does not match the labellize record, so a run overlapping another's staging can
|
|
45
|
+
* never record a wrong fresh.
|
|
46
|
+
*
|
|
47
|
+
* A file that cannot be moved into place is reported back to the run, which turns that unit's result
|
|
48
|
+
* into a FAILED row. It stays staged, and a later run adopts it.
|
|
49
|
+
*
|
|
50
|
+
* ## What is NOT staged
|
|
51
|
+
*
|
|
52
|
+
* A target outside the application root is written at once (staging mirrors paths relative to the
|
|
53
|
+
* root, so it has nowhere to put it). The labellize adoption prune, which reads its own file back, and
|
|
54
|
+
* the framework-base seeders, which already write as one burst before the unit pool, write directly.
|
|
55
|
+
*/
|
|
56
|
+
export class StagedLabelFileWriter {
|
|
57
|
+
saasRoot;
|
|
58
|
+
runDirectory;
|
|
59
|
+
/** Staged files by their target path. */
|
|
60
|
+
staged = new Map();
|
|
61
|
+
closed = false;
|
|
62
|
+
constructor(saasRoot, runDirectory) {
|
|
63
|
+
this.saasRoot = saasRoot;
|
|
64
|
+
this.runDirectory = runDirectory;
|
|
65
|
+
}
|
|
66
|
+
/** Open a run's staging directory and mark it as owned by this process. */
|
|
67
|
+
static async open(saasRoot) {
|
|
68
|
+
const runDirectory = path.join(saasRoot, LABEL_STAGING_RELATIVE_ROOT, `${new Date().toISOString().replace(/[:.]/g, '-')}-${process.pid}-${randomUUID().slice(0, 8)}`);
|
|
69
|
+
await fs.mkdir(runDirectory, { recursive: true });
|
|
70
|
+
await writeMarker(runDirectory, { pid: process.pid, startedAt: new Date().toISOString() });
|
|
71
|
+
return new StagedLabelFileWriter(saasRoot, runDirectory);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Stage `content` for `targetPath`. Throws when it cannot be written, so the caller records the unit
|
|
75
|
+
* FAILED before anything is recorded in the lock.
|
|
76
|
+
*/
|
|
77
|
+
async stage(targetPath, content) {
|
|
78
|
+
if (this.closed)
|
|
79
|
+
throw new Error(`Cannot stage ${targetPath}: this labelling run's staging is closed`);
|
|
80
|
+
const relative = path.relative(this.saasRoot, targetPath);
|
|
81
|
+
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
82
|
+
await writeLabelFile(targetPath, content);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const stagedPath = path.join(this.runDirectory, relative);
|
|
86
|
+
await writeLabelFile(stagedPath, content);
|
|
87
|
+
this.staged.set(targetPath, stagedPath);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Move every staged file into place, as one burst, and return every file that could not be moved, by
|
|
91
|
+
* target path. Idempotent. The run calls it before it reports, however the run ended.
|
|
92
|
+
*/
|
|
93
|
+
async close() {
|
|
94
|
+
if (this.closed)
|
|
95
|
+
return new Map();
|
|
96
|
+
this.closed = true;
|
|
97
|
+
const failures = await promoteStagedFiles([...this.staged.entries()]);
|
|
98
|
+
if (failures.size === 0) {
|
|
99
|
+
await fs.rm(this.runDirectory, { recursive: true, force: true });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// What could not be moved stays staged, and the marker says the run is over so another run may adopt it.
|
|
103
|
+
await writeMarker(this.runDirectory, { pid: process.pid, startedAt: new Date().toISOString(), closed: true });
|
|
104
|
+
}
|
|
105
|
+
return failures;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Move into place the files a dead or finished run left staged (#2213).
|
|
110
|
+
*
|
|
111
|
+
* A run directory is adopted when its marker says the run closed, or its process is gone; a live run's
|
|
112
|
+
* directory is never touched. A staged file is moved only if the file in its place is not NEWER — a
|
|
113
|
+
* file written in place since (a person's edit, another run) is not overwritten, and the staged one is
|
|
114
|
+
* discarded. Its lock record then disagrees with the disk, so the unit is redone. Never throws: a
|
|
115
|
+
* staging root it cannot read adopts nothing.
|
|
116
|
+
*/
|
|
117
|
+
export async function adoptAbandonedLabelStaging(saasRoot) {
|
|
118
|
+
const stagingRoot = path.join(saasRoot, LABEL_STAGING_RELATIVE_ROOT);
|
|
119
|
+
const adopted = [];
|
|
120
|
+
const discarded = [];
|
|
121
|
+
let runs;
|
|
122
|
+
try {
|
|
123
|
+
runs = await fs.readdir(stagingRoot);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return { adopted, discarded };
|
|
127
|
+
}
|
|
128
|
+
for (const run of runs) {
|
|
129
|
+
const runDirectory = path.join(stagingRoot, run);
|
|
130
|
+
const marker = await readMarker(runDirectory);
|
|
131
|
+
if (marker !== null && !marker.closed && isProcessAlive(marker.pid))
|
|
132
|
+
continue;
|
|
133
|
+
const moves = [];
|
|
134
|
+
for (const stagedPath of await listFiles(runDirectory)) {
|
|
135
|
+
if (path.basename(stagedPath) === RUN_MARKER_FILE_NAME && path.dirname(stagedPath) === runDirectory)
|
|
136
|
+
continue;
|
|
137
|
+
const targetPath = path.join(saasRoot, path.relative(runDirectory, stagedPath));
|
|
138
|
+
if (await isNewer(targetPath, stagedPath)) {
|
|
139
|
+
discarded.push(targetPath);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
moves.push([targetPath, stagedPath]);
|
|
143
|
+
}
|
|
144
|
+
const failures = await promoteStagedFiles(moves);
|
|
145
|
+
for (const [targetPath] of moves)
|
|
146
|
+
if (!failures.has(targetPath))
|
|
147
|
+
adopted.push(targetPath);
|
|
148
|
+
if (failures.size === 0)
|
|
149
|
+
await fs.rm(runDirectory, { recursive: true, force: true });
|
|
150
|
+
}
|
|
151
|
+
return { adopted, discarded };
|
|
152
|
+
}
|
|
153
|
+
/** A run's results with every unit whose file could not be put in place turned into a FAILED row. */
|
|
154
|
+
export function withUnwrittenFilesFailed(results, failures, failedStatus) {
|
|
155
|
+
if (failures.size === 0)
|
|
156
|
+
return [...results];
|
|
157
|
+
return results.map((result) => {
|
|
158
|
+
const failure = failures.get(result.filePath);
|
|
159
|
+
return failure === undefined ? result : { ...result, status: failedStatus, error: `Generated, but could not write ${result.filePath}: ${failure}` };
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/** Rename every staged file into place, together. Returns the failures by target path; a failed file stays staged. */
|
|
163
|
+
async function promoteStagedFiles(moves) {
|
|
164
|
+
const failures = new Map();
|
|
165
|
+
await Promise.all(moves.map(async ([targetPath, stagedPath]) => {
|
|
166
|
+
try {
|
|
167
|
+
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
|
168
|
+
await fs.rename(stagedPath, targetPath);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
failures.set(targetPath, error instanceof Error ? error.message : String(error));
|
|
172
|
+
}
|
|
173
|
+
}));
|
|
174
|
+
return failures;
|
|
175
|
+
}
|
|
176
|
+
async function writeLabelFile(filePath, content) {
|
|
177
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
178
|
+
await writeFileAtomic(filePath, content);
|
|
179
|
+
}
|
|
180
|
+
async function writeMarker(runDirectory, marker) {
|
|
181
|
+
await writeFileAtomic(path.join(runDirectory, RUN_MARKER_FILE_NAME), `${JSON.stringify(marker)}\n`);
|
|
182
|
+
}
|
|
183
|
+
async function readMarker(runDirectory) {
|
|
184
|
+
try {
|
|
185
|
+
const parsed = JSON.parse(await fs.readFile(path.join(runDirectory, RUN_MARKER_FILE_NAME), 'utf8'));
|
|
186
|
+
return typeof parsed.pid === 'number' ? parsed : null;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** `kill(pid, 0)` signals nothing; it throws ESRCH when no such process exists (EPERM means it exists). */
|
|
193
|
+
function isProcessAlive(pid) {
|
|
194
|
+
try {
|
|
195
|
+
process.kill(pid, 0);
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
return error?.code === 'EPERM';
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async function isNewer(targetPath, stagedPath) {
|
|
203
|
+
try {
|
|
204
|
+
const [target, staged] = await Promise.all([fs.stat(targetPath), fs.stat(stagedPath)]);
|
|
205
|
+
return target.mtimeMs > staged.mtimeMs;
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function listFiles(directory) {
|
|
212
|
+
const files = [];
|
|
213
|
+
let entries;
|
|
214
|
+
try {
|
|
215
|
+
entries = await fs.readdir(directory, { withFileTypes: true });
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return files;
|
|
219
|
+
}
|
|
220
|
+
for (const entry of entries) {
|
|
221
|
+
const entryPath = path.join(directory, entry.name);
|
|
222
|
+
if (entry.isDirectory())
|
|
223
|
+
files.push(...await listFiles(entryPath));
|
|
224
|
+
else if (entry.isFile())
|
|
225
|
+
files.push(entryPath);
|
|
226
|
+
}
|
|
227
|
+
return files;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=staged-label-file-writer.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staged-label-file-writer.utils.js","sourceRoot":"","sources":["../../../../../src/i18n-labelling/utils/staged-label-file-writer.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;AAE9F,2GAA2G;AAC3G,MAAM,oBAAoB,GAAG,UAAU,CAAC;AASxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,OAAO,qBAAqB;IAMb;IACA;IANnB,yCAAyC;IACxB,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,MAAM,GAAG,KAAK,CAAC;IAEvB,YACmB,QAAgB,EAChB,YAAoB;QADpB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,iBAAY,GAAZ,YAAY,CAAQ;IACpC,CAAC;IAEJ,2EAA2E;IACpE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAgB;QACvC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,2BAA2B,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI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GAAG,MAAM,CAAC,OAAO,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,SAAiB;IACxC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC;IACZ,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,KAAK,CAAC,WAAW,EAAE;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;aAC9D,IAAI,KAAK,CAAC,MAAM,EAAE;YAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { writeFileAtomic } from '../../core/utils/atomic-write.utils';\n\n/**\n * Where a labelling run stages its generated files: `<saasRoot>/.wildo-saas/state/label-staging/`.\n *\n * Under `.wildo-saas/state`, which every application gitignores (the skeleton's `gitignore` and both\n * dogfood applications), and which nothing watches: the backend's `tsc-watch` watches its own package,\n * and the introspection observer never descends `.wildo-saas`.\n */\nexport const LABEL_STAGING_RELATIVE_ROOT = path.join('.wildo-saas', 'state', 'label-staging');\n\n/** The marker each run's staging directory carries, so another run can tell a live run from a dead one. */\nconst RUN_MARKER_FILE_NAME = 'run.json';\n\ninterface StagingRunMarker {\n readonly pid: number;\n readonly startedAt: string;\n /** Set when the run finished promoting: anything still here is a file it could not move. */\n readonly closed?: boolean;\n}\n\n/**\n * Stages a labelling run's generated files on disk and moves them into the application in ONE burst\n * when the run ends (#2213).\n *\n * ## Why\n *\n * Label files live inside the application's backend source (`<backend>/src/engine/i18n/**`, and each\n * email template's `labels.<locale>.ts`). Every file written there wakes two watchers that each do a\n * whole application's worth of work: the backend's `tsc-watch` recompiles and RESTARTS the server, and\n * the companion's introspection watcher sees the emitted `dist` move and recompiles every derivation\n * that can read the backend (#2245). Measured on `app-creation-test-004` (2026-10-01) over 2h20 of one\n * `i18n-labels` step: 215 backend boots, 41 recompile passes, 300 introspection subprocesses.\n *\n * Staged files reach the application only at the end of the run, all at once, so a whole run costs one\n * restart and one recompile pass. They are renamed into place, which is atomic per file and lands every\n * file inside one watcher settle window.\n *\n * ## Why on disk rather than in memory\n *\n * The first version (efb3a30a8d) held files in memory and wrote a burst every five minutes, because a\n * companion that stopped mid-run would lose everything held. On disk, nothing is lost: a run that dies\n * leaves its staging directory behind, and the next run adopts it ({@link adoptAbandonedLabelStaging})\n * before doing any work. So the run can wait until its end, which is what makes it one restart.\n *\n * ## Why recording a unit before its file lands is safe\n *\n * The run records a unit in the lock (`fresh`, with the SHA of what it produced) before the file\n * reaches its place. Every freshness check compares that SHA with the file ON DISK in its place, so a\n * staged file that never lands reads as drifted and is redone; and translate refuses to translate from\n * a primary file that does not match the labellize record, so a run overlapping another's staging can\n * never record a wrong fresh.\n *\n * A file that cannot be moved into place is reported back to the run, which turns that unit's result\n * into a FAILED row. It stays staged, and a later run adopts it.\n *\n * ## What is NOT staged\n *\n * A target outside the application root is written at once (staging mirrors paths relative to the\n * root, so it has nowhere to put it). The labellize adoption prune, which reads its own file back, and\n * the framework-base seeders, which already write as one burst before the unit pool, write directly.\n */\nexport class StagedLabelFileWriter {\n /** Staged files by their target path. */\n private readonly staged = new Map<string, string>();\n private closed = false;\n\n private constructor(\n private readonly saasRoot: string,\n private readonly runDirectory: string,\n ) {}\n\n /** Open a run's staging directory and mark it as owned by this process. */\n public static async open(saasRoot: string): Promise<StagedLabelFileWriter> {\n const runDirectory = path.join(saasRoot, LABEL_STAGING_RELATIVE_ROOT, `${new Date().toISOString().replace(/[:.]/g, '-')}-${process.pid}-${randomUUID().slice(0, 8)}`);\n await fs.mkdir(runDirectory, { recursive: true });\n await writeMarker(runDirectory, { pid: process.pid, startedAt: new Date().toISOString() });\n return new StagedLabelFileWriter(saasRoot, runDirectory);\n }\n\n /**\n * Stage `content` for `targetPath`. Throws when it cannot be written, so the caller records the unit\n * FAILED before anything is recorded in the lock.\n */\n public async stage(targetPath: string, content: string): Promise<void> {\n if (this.closed) throw new Error(`Cannot stage ${targetPath}: this labelling run's staging is closed`);\n const relative = path.relative(this.saasRoot, targetPath);\n if (relative.startsWith('..') || path.isAbsolute(relative)) {\n await writeLabelFile(targetPath, content);\n return;\n }\n const stagedPath = path.join(this.runDirectory, relative);\n await writeLabelFile(stagedPath, content);\n this.staged.set(targetPath, stagedPath);\n }\n\n /**\n * Move every staged file into place, as one burst, and return every file that could not be moved, by\n * target path. Idempotent. The run calls it before it reports, however the run ended.\n */\n public async close(): Promise<ReadonlyMap<string, string>> {\n if (this.closed) return new Map();\n this.closed = true;\n const failures = await promoteStagedFiles([...this.staged.entries()]);\n if (failures.size === 0) {\n await fs.rm(this.runDirectory, { recursive: true, force: true });\n } else {\n // What could not be moved stays staged, and the marker says the run is over so another run may adopt it.\n await writeMarker(this.runDirectory, { pid: process.pid, startedAt: new Date().toISOString(), closed: true });\n }\n return failures;\n }\n}\n\n/**\n * Move into place the files a dead or finished run left staged (#2213).\n *\n * A run directory is adopted when its marker says the run closed, or its process is gone; a live run's\n * directory is never touched. A staged file is moved only if the file in its place is not NEWER — a\n * file written in place since (a person's edit, another run) is not overwritten, and the staged one is\n * discarded. Its lock record then disagrees with the disk, so the unit is redone. Never throws: a\n * staging root it cannot read adopts nothing.\n */\nexport async function adoptAbandonedLabelStaging(saasRoot: string): Promise<{ readonly adopted: readonly string[]; readonly discarded: readonly string[] }> {\n const stagingRoot = path.join(saasRoot, LABEL_STAGING_RELATIVE_ROOT);\n const adopted: string[] = [];\n const discarded: string[] = [];\n let runs: string[];\n try {\n runs = await fs.readdir(stagingRoot);\n } catch {\n return { adopted, discarded };\n }\n for (const run of runs) {\n const runDirectory = path.join(stagingRoot, run);\n const marker = await readMarker(runDirectory);\n if (marker !== null && !marker.closed && isProcessAlive(marker.pid)) continue;\n const moves: Array<[string, string]> = [];\n for (const stagedPath of await listFiles(runDirectory)) {\n if (path.basename(stagedPath) === RUN_MARKER_FILE_NAME && path.dirname(stagedPath) === runDirectory) continue;\n const targetPath = path.join(saasRoot, path.relative(runDirectory, stagedPath));\n if (await isNewer(targetPath, stagedPath)) {\n discarded.push(targetPath);\n continue;\n }\n moves.push([targetPath, stagedPath]);\n }\n const failures = await promoteStagedFiles(moves);\n for (const [targetPath] of moves) if (!failures.has(targetPath)) adopted.push(targetPath);\n if (failures.size === 0) await fs.rm(runDirectory, { recursive: true, force: true });\n }\n return { adopted, discarded };\n}\n\n/** A run's results with every unit whose file could not be put in place turned into a FAILED row. */\nexport function withUnwrittenFilesFailed<T extends { filePath: string; status: string; error?: string }>(\n results: readonly T[],\n failures: ReadonlyMap<string, string>,\n failedStatus: T['status'],\n): T[] {\n if (failures.size === 0) return [...results];\n return results.map((result) => {\n const failure = failures.get(result.filePath);\n return failure === undefined ? result : { ...result, status: failedStatus, error: `Generated, but could not write ${result.filePath}: ${failure}` };\n });\n}\n\n/** Rename every staged file into place, together. Returns the failures by target path; a failed file stays staged. */\nasync function promoteStagedFiles(moves: ReadonlyArray<readonly [targetPath: string, stagedPath: string]>): Promise<ReadonlyMap<string, string>> {\n const failures = new Map<string, string>();\n await Promise.all(moves.map(async ([targetPath, stagedPath]) => {\n try {\n await fs.mkdir(path.dirname(targetPath), { recursive: true });\n await fs.rename(stagedPath, targetPath);\n } catch (error: unknown) {\n failures.set(targetPath, error instanceof Error ? error.message : String(error));\n }\n }));\n return failures;\n}\n\nasync function writeLabelFile(filePath: string, content: string): Promise<void> {\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await writeFileAtomic(filePath, content);\n}\n\nasync function writeMarker(runDirectory: string, marker: StagingRunMarker): Promise<void> {\n await writeFileAtomic(path.join(runDirectory, RUN_MARKER_FILE_NAME), `${JSON.stringify(marker)}\\n`);\n}\n\nasync function readMarker(runDirectory: string): Promise<StagingRunMarker | null> {\n try {\n const parsed = JSON.parse(await fs.readFile(path.join(runDirectory, RUN_MARKER_FILE_NAME), 'utf8')) as Partial<StagingRunMarker>;\n return typeof parsed.pid === 'number' ? parsed as StagingRunMarker : null;\n } catch {\n return null;\n }\n}\n\n/** `kill(pid, 0)` signals nothing; it throws ESRCH when no such process exists (EPERM means it exists). */\nfunction isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error: unknown) {\n return (error as NodeJS.ErrnoException)?.code === 'EPERM';\n }\n}\n\nasync function isNewer(targetPath: string, stagedPath: string): Promise<boolean> {\n try {\n const [target, staged] = await Promise.all([fs.stat(targetPath), fs.stat(stagedPath)]);\n return target.mtimeMs > staged.mtimeMs;\n } catch {\n return false;\n }\n}\n\nasync function listFiles(directory: string): Promise<string[]> {\n const files: string[] = [];\n let entries;\n try {\n entries = await fs.readdir(directory, { withFileTypes: true });\n } catch {\n return files;\n }\n for (const entry of entries) {\n const entryPath = path.join(directory, entry.name);\n if (entry.isDirectory()) files.push(...await listFiles(entryPath));\n else if (entry.isFile()) files.push(entryPath);\n }\n return files;\n}\n"]}
|
|
@@ -22,8 +22,74 @@ export declare enum BuildTaskRearmReason {
|
|
|
22
22
|
/** A defect outside the task made its product impossible to produce, and has been fixed. */
|
|
23
23
|
BLOCKING_DEFECT_FIXED = "blocking-defect-fixed",
|
|
24
24
|
/** Neither of the above: an operator judged the work should run again. The note says why. */
|
|
25
|
-
OPERATOR_JUDGEMENT = "operator-judgement"
|
|
25
|
+
OPERATOR_JUDGEMENT = "operator-judgement",
|
|
26
|
+
/**
|
|
27
|
+
* Set by the BUILD WAVE, never by a person (#2210): the run completed while other runs edited the same
|
|
28
|
+
* tree, and its declared product is missing from a file one of them also changed, so the loss is
|
|
29
|
+
* theirs rather than the task's. The wave re-arms the task and re-runs it alone, a bounded number of
|
|
30
|
+
* times ({@link MAXIMUM_INTERFERENCE_REARMS}). The run also carries a {@link BuildTaskInterference}.
|
|
31
|
+
*
|
|
32
|
+
* Like every re-arm it also releases the task's FAILED runs not yet re-armed, so the attempt budget starts
|
|
33
|
+
* afresh. Deliberate: the task did complete, so its earlier failures say nothing about whether the work can
|
|
34
|
+
* be done, and the interference bound still stops a task that keeps losing its product.
|
|
35
|
+
*/
|
|
36
|
+
INTERFERED_BY_CONCURRENT_RUN = "interfered-by-concurrent-run"
|
|
26
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* The reasons a PERSON may give (`POST /build/tasks/:taskRef/rearm`, `wildo build rearm`). The wave's own
|
|
40
|
+
* reason is left out: it asserts a measurement (a sibling changed the product's file during the run) that
|
|
41
|
+
* only the wave makes, and an operator choosing it would record a detection that never happened.
|
|
42
|
+
*/
|
|
43
|
+
export declare const OPERATOR_BUILD_TASK_REARM_REASONS: readonly [BuildTaskRearmReason.PROBE_CORRECTED, BuildTaskRearmReason.BLOCKING_DEFECT_FIXED, BuildTaskRearmReason.OPERATOR_JUDGEMENT];
|
|
44
|
+
/**
|
|
45
|
+
* Running a task the landing probe calls LANDED, on purpose (#2217) — `wildo build run <task> --despite-landed`.
|
|
46
|
+
*
|
|
47
|
+
* A re-arm releases a task whose run COMPLETED without landing. It cannot help a task that reads landed with no
|
|
48
|
+
* run of its own: the product was found before anything ran — written by a sibling task, by hand, or (#2216) by
|
|
49
|
+
* a probe that read a comment as the product. Until this existed such a landing was permanent: `run` refused
|
|
50
|
+
* "already landed" and `rearm` refused "nothing to re-arm".
|
|
51
|
+
*
|
|
52
|
+
* The landing stays DERIVED — nothing here writes a status, and nothing stops the probe answering "landed" again
|
|
53
|
+
* after the run. What the operator gets is one dispatch past the refusal, and what the record gets is why: the
|
|
54
|
+
* override rides the run's own row, beside the conversation it came from, and the build record shows it on that
|
|
55
|
+
* attempt. Same reasons a person may give a re-arm, for the same reason: the question a later reader asks is
|
|
56
|
+
* the same one.
|
|
57
|
+
*/
|
|
58
|
+
export interface BuildTaskLandedOverride {
|
|
59
|
+
readonly reason: (typeof OPERATOR_BUILD_TASK_REARM_REASONS)[number];
|
|
60
|
+
/** Why the landing is believed wrong, in a sentence. Required: an override with no stated reason is a bypass. */
|
|
61
|
+
readonly note: string;
|
|
62
|
+
}
|
|
63
|
+
/** The landed override a run row's input carries, or `undefined` when the run was an ordinary dispatch. */
|
|
64
|
+
export declare function readBuildTaskLandedOverride(input: unknown): BuildTaskLandedOverride | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* How many times one task's runs may be re-armed for interference before the wave stops re-running it
|
|
67
|
+
* (#2210). A bound of its own, not the attempt budget's: that one (`MAXIMUM_INTERFERENCE_RETRIES`) forgives
|
|
68
|
+
* FAILED runs, and these runs succeeded. Two, the same number, for the same reason: interference cannot
|
|
69
|
+
* retire a task, and a task that keeps losing its product still stops costing a turn. The re-run is
|
|
70
|
+
* single-flight, so a second detection already means something other than a sibling is at work.
|
|
71
|
+
*/
|
|
72
|
+
export declare const MAXIMUM_INTERFERENCE_REARMS = 2;
|
|
73
|
+
/**
|
|
74
|
+
* What the wave found about a COMPLETED run whose product is missing (#2210): which runs shared the tree
|
|
75
|
+
* with it, and which of the files its task's landing probes read they changed too. Suspected, like
|
|
76
|
+
* `interferenceSuspected` on a failed run: the wave sees that a sibling wrote the file in the run's
|
|
77
|
+
* window, not which line it replaced.
|
|
78
|
+
*/
|
|
79
|
+
export interface BuildTaskInterference {
|
|
80
|
+
readonly overlappingTaskRefs: readonly string[];
|
|
81
|
+
/** The task's own probe paths that an overlapping run also changed. Never empty: no shared file, no interference. */
|
|
82
|
+
readonly contendedProductPaths: readonly string[];
|
|
83
|
+
readonly detectedAt: string;
|
|
84
|
+
/** Whether the wave re-armed the task for it, or the bound ({@link MAXIMUM_INTERFERENCE_REARMS}) was already spent. */
|
|
85
|
+
readonly requeued: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** The memory key the interference is recorded under, beside the re-arm. */
|
|
88
|
+
export declare const BUILD_TASK_INTERFERENCE_MEMORY_KEY = "application-creation.build-task-interference";
|
|
89
|
+
/** The interference recorded on a run's memory, or `undefined` when none was detected. */
|
|
90
|
+
export declare function readBuildTaskInterference(memory: unknown): BuildTaskInterference | undefined;
|
|
91
|
+
/** The run's memory with the interference appended to its long-term store; see {@link withBuildTaskRearm}. */
|
|
92
|
+
export declare function withBuildTaskInterference(memory: Actors_Memory_Context | undefined, interference: BuildTaskInterference): Actors_Memory_Context;
|
|
27
93
|
/** The memory key a re-arm is recorded under — namespaced, because task memory is shared by every consumer of the task plane. */
|
|
28
94
|
export declare const BUILD_TASK_REARM_MEMORY_KEY = "application-creation.build-task-rearm";
|
|
29
95
|
export interface BuildTaskRearm {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-task-rearm.models.d.ts","sourceRoot":"","sources":["../../../../../src/meta-workflows/models/build-task-rearm.models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAuB,MAAM,uBAAuB,CAAC;AAExF,qGAAqG;AACrG,oBAAY,oBAAoB;IAC9B,2EAA2E;IAC3E,eAAe,oBAAoB;IACnC,4FAA4F;IAC5F,qBAAqB,0BAA0B;IAC/C,6FAA6F;IAC7F,kBAAkB,uBAAuB;
|
|
1
|
+
{"version":3,"file":"build-task-rearm.models.d.ts","sourceRoot":"","sources":["../../../../../src/meta-workflows/models/build-task-rearm.models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAuB,MAAM,uBAAuB,CAAC;AAExF,qGAAqG;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,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAUD,wFAAwF;AACxF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAK9E;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,qBAAqB,CAI1H;AAED,8GAA8G;AAC9G,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAyB,IAAI,yBAAyB;CACvD"}
|
|
@@ -7,7 +7,71 @@ export var BuildTaskRearmReason;
|
|
|
7
7
|
BuildTaskRearmReason["BLOCKING_DEFECT_FIXED"] = "blocking-defect-fixed";
|
|
8
8
|
/** Neither of the above: an operator judged the work should run again. The note says why. */
|
|
9
9
|
BuildTaskRearmReason["OPERATOR_JUDGEMENT"] = "operator-judgement";
|
|
10
|
+
/**
|
|
11
|
+
* Set by the BUILD WAVE, never by a person (#2210): the run completed while other runs edited the same
|
|
12
|
+
* tree, and its declared product is missing from a file one of them also changed, so the loss is
|
|
13
|
+
* theirs rather than the task's. The wave re-arms the task and re-runs it alone, a bounded number of
|
|
14
|
+
* times ({@link MAXIMUM_INTERFERENCE_REARMS}). The run also carries a {@link BuildTaskInterference}.
|
|
15
|
+
*
|
|
16
|
+
* Like every re-arm it also releases the task's FAILED runs not yet re-armed, so the attempt budget starts
|
|
17
|
+
* afresh. Deliberate: the task did complete, so its earlier failures say nothing about whether the work can
|
|
18
|
+
* be done, and the interference bound still stops a task that keeps losing its product.
|
|
19
|
+
*/
|
|
20
|
+
BuildTaskRearmReason["INTERFERED_BY_CONCURRENT_RUN"] = "interfered-by-concurrent-run";
|
|
10
21
|
})(BuildTaskRearmReason || (BuildTaskRearmReason = {}));
|
|
22
|
+
/**
|
|
23
|
+
* The reasons a PERSON may give (`POST /build/tasks/:taskRef/rearm`, `wildo build rearm`). The wave's own
|
|
24
|
+
* reason is left out: it asserts a measurement (a sibling changed the product's file during the run) that
|
|
25
|
+
* only the wave makes, and an operator choosing it would record a detection that never happened.
|
|
26
|
+
*/
|
|
27
|
+
export const OPERATOR_BUILD_TASK_REARM_REASONS = [
|
|
28
|
+
BuildTaskRearmReason.PROBE_CORRECTED,
|
|
29
|
+
BuildTaskRearmReason.BLOCKING_DEFECT_FIXED,
|
|
30
|
+
BuildTaskRearmReason.OPERATOR_JUDGEMENT,
|
|
31
|
+
];
|
|
32
|
+
/** The landed override a run row's input carries, or `undefined` when the run was an ordinary dispatch. */
|
|
33
|
+
export function readBuildTaskLandedOverride(input) {
|
|
34
|
+
const value = input?.landedOverride;
|
|
35
|
+
if (typeof value !== 'object' || value === null)
|
|
36
|
+
return undefined;
|
|
37
|
+
const candidate = value;
|
|
38
|
+
return OPERATOR_BUILD_TASK_REARM_REASONS.includes(candidate.reason) && typeof candidate.note === 'string'
|
|
39
|
+
? { reason: candidate.reason, note: candidate.note }
|
|
40
|
+
: undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* How many times one task's runs may be re-armed for interference before the wave stops re-running it
|
|
44
|
+
* (#2210). A bound of its own, not the attempt budget's: that one (`MAXIMUM_INTERFERENCE_RETRIES`) forgives
|
|
45
|
+
* FAILED runs, and these runs succeeded. Two, the same number, for the same reason: interference cannot
|
|
46
|
+
* retire a task, and a task that keeps losing its product still stops costing a turn. The re-run is
|
|
47
|
+
* single-flight, so a second detection already means something other than a sibling is at work.
|
|
48
|
+
*/
|
|
49
|
+
export const MAXIMUM_INTERFERENCE_REARMS = 2;
|
|
50
|
+
/** The memory key the interference is recorded under, beside the re-arm. */
|
|
51
|
+
export const BUILD_TASK_INTERFERENCE_MEMORY_KEY = 'application-creation.build-task-interference';
|
|
52
|
+
function isInterferenceValue(value) {
|
|
53
|
+
if (typeof value !== 'object' || value === null)
|
|
54
|
+
return false;
|
|
55
|
+
const candidate = value;
|
|
56
|
+
return Array.isArray(candidate.overlappingTaskRefs)
|
|
57
|
+
&& Array.isArray(candidate.contendedProductPaths)
|
|
58
|
+
&& typeof candidate.detectedAt === 'string'
|
|
59
|
+
&& typeof candidate.requeued === 'boolean';
|
|
60
|
+
}
|
|
61
|
+
/** The interference recorded on a run's memory, or `undefined` when none was detected. */
|
|
62
|
+
export function readBuildTaskInterference(memory) {
|
|
63
|
+
const entries = memory?.longTerm?.entries;
|
|
64
|
+
if (!Array.isArray(entries))
|
|
65
|
+
return undefined;
|
|
66
|
+
const entry = entries.find((candidate) => candidate?.key === BUILD_TASK_INTERFERENCE_MEMORY_KEY && isInterferenceValue(candidate.value));
|
|
67
|
+
return entry?.value;
|
|
68
|
+
}
|
|
69
|
+
/** The run's memory with the interference appended to its long-term store; see {@link withBuildTaskRearm}. */
|
|
70
|
+
export function withBuildTaskInterference(memory, interference) {
|
|
71
|
+
const base = memory ?? { shortTerm: EMPTY_STORE, longTerm: EMPTY_STORE, working: EMPTY_STORE };
|
|
72
|
+
const entry = { key: BUILD_TASK_INTERFERENCE_MEMORY_KEY, value: interference, type: 'json', timestamp: interference.detectedAt };
|
|
73
|
+
return { ...base, longTerm: { ...base.longTerm, entries: [...base.longTerm.entries, entry] } };
|
|
74
|
+
}
|
|
11
75
|
/** The memory key a re-arm is recorded under — namespaced, because task memory is shared by every consumer of the task plane. */
|
|
12
76
|
export const BUILD_TASK_REARM_MEMORY_KEY = 'application-creation.build-task-rearm';
|
|
13
77
|
function isRearmValue(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-task-rearm.models.js","sourceRoot":"","sources":["../../../../../src/meta-workflows/models/build-task-rearm.models.ts"],"names":[],"mappings":"AAkBA,qGAAqG;AACrG,MAAM,CAAN,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC9B,2EAA2E;IAC3E,2DAAmC,CAAA;IACnC,4FAA4F;IA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AA2B,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAChI,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;AACjG,CAAC;AAED,8GAA8G;AAC9G,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnB,IAAI,GAAG,qBAAqB,CAAC;CACvD","sourcesContent":["/**\n * RE-ARMING a build task — the door the \"completed but not landed\" guard was missing (#1535).\n *\n * The build dispatcher refuses to re-run a task whose coding run COMPLETED without landing, because\n * re-offering it was a measured money leak: a task whose product is never satisfied is ready again the\n * instant it finishes (#606). That refusal is right, and it was a one-way door. Once the reason the task\n * did not land is FIXED — the landing check was corrected, or a framework defect that made the product\n * impossible was repaired — nothing put the task back, so it stayed skipped for the life of the\n * application. The only way round it was flipping the completed row to `cancelled` by hand, which\n * rewrites what happened and records no reason.\n *\n * A re-arm keeps the run's history intact and adds one fact to it, on the run itself: this completed\n * run no longer counts, and here is why. It is written into the task's long-term MEMORY, the task's\n * consolidated record, rather than into a second store, and the guard skips a run that carries it.\n * Re-arming several times leaves several entries, so a task re-armed three times reads as exactly that.\n */\nimport type { Actors_Memory_Context, Actors_Memory_Entry } from '@wildo-ai/saas-models';\n\n/** WHY a build task was put back in the queue — the one question a later reader of a re-arm asks. */\nexport enum BuildTaskRearmReason {\n /** The landing check was wrong about this task, and has been corrected. */\n PROBE_CORRECTED = 'probe-corrected',\n /** A defect outside the task made its product impossible to produce, and has been fixed. */\n BLOCKING_DEFECT_FIXED = 'blocking-defect-fixed',\n /** Neither of the above: an operator judged the work should run again. The note says why. */\n OPERATOR_JUDGEMENT = 'operator-judgement',\n}\n\n/** The memory key a re-arm is recorded under — namespaced, because task memory is shared by every consumer of the task plane. */\nexport const BUILD_TASK_REARM_MEMORY_KEY = 'application-creation.build-task-rearm';\n\nexport interface BuildTaskRearm {\n readonly reason: BuildTaskRearmReason;\n /** What was fixed, in a sentence — the part a reason code cannot carry. */\n readonly note: string;\n readonly rearmedAt: string;\n}\n\nfunction isRearmValue(value: unknown): value is BuildTaskRearm {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Record<string, unknown>;\n return Object.values(BuildTaskRearmReason).includes(candidate.reason as BuildTaskRearmReason)\n && typeof candidate.note === 'string'\n && typeof candidate.rearmedAt === 'string';\n}\n\n/** The re-arm recorded on a task's memory, or `undefined` when the run still counts. */\nexport function readBuildTaskRearm(memory: unknown): BuildTaskRearm | undefined {\n const entries = (memory as Partial<Actors_Memory_Context> | undefined)?.longTerm?.entries;\n if (!Array.isArray(entries)) return undefined;\n const entry = entries.find((candidate) => candidate?.key === BUILD_TASK_REARM_MEMORY_KEY && isRearmValue(candidate.value));\n return entry?.value as BuildTaskRearm | undefined;\n}\n\nconst EMPTY_STORE = { entries: [] };\n\n/**\n * The task's memory with a re-arm appended to its long-term store; every other store is kept as it was.\n * A row written before tasks carried memory has none, and gets the empty stores the schema defaults to.\n */\nexport function withBuildTaskRearm(memory: Actors_Memory_Context | undefined, rearm: BuildTaskRearm): Actors_Memory_Context {\n const base: Actors_Memory_Context = memory ?? { shortTerm: EMPTY_STORE, longTerm: EMPTY_STORE, working: EMPTY_STORE };\n const entry: Actors_Memory_Entry = { key: BUILD_TASK_REARM_MEMORY_KEY, value: rearm, type: 'json', timestamp: rearm.rearmedAt };\n return { ...base, longTerm: { ...base.longTerm, entries: [...base.longTerm.entries, entry] } };\n}\n\n/** Refused re-arm: the task holds no completed run that still counts, so the request would change nothing. */\nexport class NothingToRearmError extends Error {\n public override readonly name = 'NothingToRearmError';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"build-task-rearm.models.js","sourceRoot":"","sources":["../../../../../src/meta-workflows/models/build-task-rearm.models.ts"],"names":[],"m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CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;AACjG,CAAC;AAED,8GAA8G;AAC9G,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnB,IAAI,GAAG,qBAAqB,CAAC;CACvD","sourcesContent":["/**\n * RE-ARMING a build task — the door the \"completed but not landed\" guard was missing (#1535).\n *\n * The build dispatcher refuses to re-run a task whose coding run COMPLETED without landing, because\n * re-offering it was a measured money leak: a task whose product is never satisfied is ready again the\n * instant it finishes (#606). That refusal is right, and it was a one-way door. Once the reason the task\n * did not land is FIXED — the landing check was corrected, or a framework defect that made the product\n * impossible was repaired — nothing put the task back, so it stayed skipped for the life of the\n * application. The only way round it was flipping the completed row to `cancelled` by hand, which\n * rewrites what happened and records no reason.\n *\n * A re-arm keeps the run's history intact and adds one fact to it, on the run itself: this completed\n * run no longer counts, and here is why. It is written into the task's long-term MEMORY, the task's\n * consolidated record, rather than into a second store, and the guard skips a run that carries it.\n * Re-arming several times leaves several entries, so a task re-armed three times reads as exactly that.\n */\nimport type { Actors_Memory_Context, Actors_Memory_Entry } from '@wildo-ai/saas-models';\n\n/** WHY a build task was put back in the queue — the one question a later reader of a re-arm asks. */\nexport enum BuildTaskRearmReason {\n /** The landing check was wrong about this task, and has been corrected. */\n PROBE_CORRECTED = 'probe-corrected',\n /** A defect outside the task made its product impossible to produce, and has been fixed. */\n BLOCKING_DEFECT_FIXED = 'blocking-defect-fixed',\n /** Neither of the above: an operator judged the work should run again. The note says why. */\n OPERATOR_JUDGEMENT = 'operator-judgement',\n /**\n * Set by the BUILD WAVE, never by a person (#2210): the run completed while other runs edited the same\n * tree, and its declared product is missing from a file one of them also changed, so the loss is\n * theirs rather than the task's. The wave re-arms the task and re-runs it alone, a bounded number of\n * times ({@link MAXIMUM_INTERFERENCE_REARMS}). The run also carries a {@link BuildTaskInterference}.\n *\n * Like every re-arm it also releases the task's FAILED runs not yet re-armed, so the attempt budget starts\n * afresh. Deliberate: the task did complete, so its earlier failures say nothing about whether the work can\n * be done, and the interference bound still stops a task that keeps losing its product.\n */\n INTERFERED_BY_CONCURRENT_RUN = 'interfered-by-concurrent-run',\n}\n\n/**\n * The reasons a PERSON may give (`POST /build/tasks/:taskRef/rearm`, `wildo build rearm`). The wave's own\n * reason is left out: it asserts a measurement (a sibling changed the product's file during the run) that\n * only the wave makes, and an operator choosing it would record a detection that never happened.\n */\nexport const OPERATOR_BUILD_TASK_REARM_REASONS = [\n BuildTaskRearmReason.PROBE_CORRECTED,\n BuildTaskRearmReason.BLOCKING_DEFECT_FIXED,\n BuildTaskRearmReason.OPERATOR_JUDGEMENT,\n] as const satisfies readonly BuildTaskRearmReason[];\n\n/**\n * Running a task the landing probe calls LANDED, on purpose (#2217) — `wildo build run <task> --despite-landed`.\n *\n * A re-arm releases a task whose run COMPLETED without landing. It cannot help a task that reads landed with no\n * run of its own: the product was found before anything ran — written by a sibling task, by hand, or (#2216) by\n * a probe that read a comment as the product. Until this existed such a landing was permanent: `run` refused\n * \"already landed\" and `rearm` refused \"nothing to re-arm\".\n *\n * The landing stays DERIVED — nothing here writes a status, and nothing stops the probe answering \"landed\" again\n * after the run. What the operator gets is one dispatch past the refusal, and what the record gets is why: the\n * override rides the run's own row, beside the conversation it came from, and the build record shows it on that\n * attempt. Same reasons a person may give a re-arm, for the same reason: the question a later reader asks is\n * the same one.\n */\nexport interface BuildTaskLandedOverride {\n readonly reason: (typeof OPERATOR_BUILD_TASK_REARM_REASONS)[number];\n /** Why the landing is believed wrong, in a sentence. Required: an override with no stated reason is a bypass. */\n readonly note: string;\n}\n\n/** The landed override a run row's input carries, or `undefined` when the run was an ordinary dispatch. */\nexport function readBuildTaskLandedOverride(input: unknown): BuildTaskLandedOverride | undefined {\n const value = (input as { landedOverride?: unknown } | undefined)?.landedOverride;\n if (typeof value !== 'object' || value === null) return undefined;\n const candidate = value as Record<string, unknown>;\n return (OPERATOR_BUILD_TASK_REARM_REASONS as readonly unknown[]).includes(candidate.reason) && typeof candidate.note === 'string'\n ? { reason: candidate.reason as BuildTaskLandedOverride['reason'], note: candidate.note }\n : undefined;\n}\n\n/**\n * How many times one task's runs may be re-armed for interference before the wave stops re-running it\n * (#2210). A bound of its own, not the attempt budget's: that one (`MAXIMUM_INTERFERENCE_RETRIES`) forgives\n * FAILED runs, and these runs succeeded. Two, the same number, for the same reason: interference cannot\n * retire a task, and a task that keeps losing its product still stops costing a turn. The re-run is\n * single-flight, so a second detection already means something other than a sibling is at work.\n */\nexport const MAXIMUM_INTERFERENCE_REARMS = 2;\n\n/**\n * What the wave found about a COMPLETED run whose product is missing (#2210): which runs shared the tree\n * with it, and which of the files its task's landing probes read they changed too. Suspected, like\n * `interferenceSuspected` on a failed run: the wave sees that a sibling wrote the file in the run's\n * window, not which line it replaced.\n */\nexport interface BuildTaskInterference {\n readonly overlappingTaskRefs: readonly string[];\n /** The task's own probe paths that an overlapping run also changed. Never empty: no shared file, no interference. */\n readonly contendedProductPaths: readonly string[];\n readonly detectedAt: string;\n /** Whether the wave re-armed the task for it, or the bound ({@link MAXIMUM_INTERFERENCE_REARMS}) was already spent. */\n readonly requeued: boolean;\n}\n\n/** The memory key the interference is recorded under, beside the re-arm. */\nexport const BUILD_TASK_INTERFERENCE_MEMORY_KEY = 'application-creation.build-task-interference';\n\nfunction isInterferenceValue(value: unknown): value is BuildTaskInterference {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Record<string, unknown>;\n return Array.isArray(candidate.overlappingTaskRefs)\n && Array.isArray(candidate.contendedProductPaths)\n && typeof candidate.detectedAt === 'string'\n && typeof candidate.requeued === 'boolean';\n}\n\n/** The interference recorded on a run's memory, or `undefined` when none was detected. */\nexport function readBuildTaskInterference(memory: unknown): BuildTaskInterference | undefined {\n const entries = (memory as Partial<Actors_Memory_Context> | undefined)?.longTerm?.entries;\n if (!Array.isArray(entries)) return undefined;\n const entry = entries.find((candidate) => candidate?.key === BUILD_TASK_INTERFERENCE_MEMORY_KEY && isInterferenceValue(candidate.value));\n return entry?.value as BuildTaskInterference | undefined;\n}\n\n/** The run's memory with the interference appended to its long-term store; see {@link withBuildTaskRearm}. */\nexport function withBuildTaskInterference(memory: Actors_Memory_Context | undefined, interference: BuildTaskInterference): Actors_Memory_Context {\n const base: Actors_Memory_Context = memory ?? { shortTerm: EMPTY_STORE, longTerm: EMPTY_STORE, working: EMPTY_STORE };\n const entry: Actors_Memory_Entry = { key: BUILD_TASK_INTERFERENCE_MEMORY_KEY, value: interference, type: 'json', timestamp: interference.detectedAt };\n return { ...base, longTerm: { ...base.longTerm, entries: [...base.longTerm.entries, entry] } };\n}\n\n/** The memory key a re-arm is recorded under — namespaced, because task memory is shared by every consumer of the task plane. */\nexport const BUILD_TASK_REARM_MEMORY_KEY = 'application-creation.build-task-rearm';\n\nexport interface BuildTaskRearm {\n readonly reason: BuildTaskRearmReason;\n /** What was fixed, in a sentence — the part a reason code cannot carry. */\n readonly note: string;\n readonly rearmedAt: string;\n}\n\nfunction isRearmValue(value: unknown): value is BuildTaskRearm {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as Record<string, unknown>;\n return Object.values(BuildTaskRearmReason).includes(candidate.reason as BuildTaskRearmReason)\n && typeof candidate.note === 'string'\n && typeof candidate.rearmedAt === 'string';\n}\n\n/** The re-arm recorded on a task's memory, or `undefined` when the run still counts. */\nexport function readBuildTaskRearm(memory: unknown): BuildTaskRearm | undefined {\n const entries = (memory as Partial<Actors_Memory_Context> | undefined)?.longTerm?.entries;\n if (!Array.isArray(entries)) return undefined;\n const entry = entries.find((candidate) => candidate?.key === BUILD_TASK_REARM_MEMORY_KEY && isRearmValue(candidate.value));\n return entry?.value as BuildTaskRearm | undefined;\n}\n\nconst EMPTY_STORE = { entries: [] };\n\n/**\n * The task's memory with a re-arm appended to its long-term store; every other store is kept as it was.\n * A row written before tasks carried memory has none, and gets the empty stores the schema defaults to.\n */\nexport function withBuildTaskRearm(memory: Actors_Memory_Context | undefined, rearm: BuildTaskRearm): Actors_Memory_Context {\n const base: Actors_Memory_Context = memory ?? { shortTerm: EMPTY_STORE, longTerm: EMPTY_STORE, working: EMPTY_STORE };\n const entry: Actors_Memory_Entry = { key: BUILD_TASK_REARM_MEMORY_KEY, value: rearm, type: 'json', timestamp: rearm.rearmedAt };\n return { ...base, longTerm: { ...base.longTerm, entries: [...base.longTerm.entries, entry] } };\n}\n\n/** Refused re-arm: the task holds no completed run that still counts, so the request would change nothing. */\nexport class NothingToRearmError extends Error {\n public override readonly name = 'NothingToRearmError';\n}\n"]}
|