@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
|
@@ -37,10 +37,11 @@ export declare function getCompanionEnabledLocaleCodes(config: (AppPrimaryLangua
|
|
|
37
37
|
* are skipped rather than thrown on — `enabledLanguages` is a list, and one unknown entry must not
|
|
38
38
|
* stop the languages that are valid.
|
|
39
39
|
*
|
|
40
|
-
* One reader for
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* One reader for the consumers that must agree: the i18n generation step (which locales to translate
|
|
41
|
+
* into), the capability composition (whether the website needs a second locale, and which) and the
|
|
42
|
+
* coherence report (which of the market's languages the application does not serve). The
|
|
43
|
+
* foundation does not read it: it composes the locales the composition DECIDED (`decision.locales`),
|
|
44
|
+
* which can include a market language the configuration does not serve yet.
|
|
44
45
|
*/
|
|
45
46
|
export declare function getCompanionServedLanguages(config: AppPrimaryLanguageConfigShape | null | undefined): AvailableLanguage[];
|
|
46
47
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primary-language.companion.utils.d.ts","sourceRoot":"","sources":["../../../../../src/core/config/primary-language.companion.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,KAAK,6BAA6B,GAAG;IACnC,cAAc,CAAC,EAAE;QACf,SAAS,CAAC,EAAE;YACV,eAAe,CAAC,EAAE,OAAO,CAAC;YAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;YAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;SAC5B,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,6BAA6B,GAAG,IAAI,GAAG,SAAS,GACvD,iBAAiB,CAOnB;AAED,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,6BAA6B,GAAG,IAAI,GAAG,SAAS,GACvD,iBAAiB,CAOnB;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,CAAC,6BAA6B,GAAG;IAAE,cAAc,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE;YAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/H,SAAS,MAAM,EAAE,CAKnB;AAED
|
|
1
|
+
{"version":3,"file":"primary-language.companion.utils.d.ts","sourceRoot":"","sources":["../../../../../src/core/config/primary-language.companion.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,KAAK,6BAA6B,GAAG;IACnC,cAAc,CAAC,EAAE;QACf,SAAS,CAAC,EAAE;YACV,eAAe,CAAC,EAAE,OAAO,CAAC;YAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;YAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;SAC5B,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,6BAA6B,GAAG,IAAI,GAAG,SAAS,GACvD,iBAAiB,CAOnB;AAED,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,6BAA6B,GAAG,IAAI,GAAG,SAAS,GACvD,iBAAiB,CAOnB;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,CAAC,6BAA6B,GAAG;IAAE,cAAc,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE;YAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/H,SAAS,MAAM,EAAE,CAKnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,6BAA6B,GAAG,IAAI,GAAG,SAAS,GAAG,iBAAiB,EAAE,CAOzH"}
|
|
@@ -41,10 +41,11 @@ export function getCompanionEnabledLocaleCodes(config) {
|
|
|
41
41
|
* are skipped rather than thrown on — `enabledLanguages` is a list, and one unknown entry must not
|
|
42
42
|
* stop the languages that are valid.
|
|
43
43
|
*
|
|
44
|
-
* One reader for
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
44
|
+
* One reader for the consumers that must agree: the i18n generation step (which locales to translate
|
|
45
|
+
* into), the capability composition (whether the website needs a second locale, and which) and the
|
|
46
|
+
* coherence report (which of the market's languages the application does not serve). The
|
|
47
|
+
* foundation does not read it: it composes the locales the composition DECIDED (`decision.locales`),
|
|
48
|
+
* which can include a market language the configuration does not serve yet.
|
|
48
49
|
*/
|
|
49
50
|
export function getCompanionServedLanguages(config) {
|
|
50
51
|
const primary = getCompanionConfiguredPrimaryLanguage(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primary-language.companion.utils.js","sourceRoot":"","sources":["../../../../../src/core/config/primary-language.companion.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAYxE;;;;;;;GAOG;AACH,MAAM,UAAU,qCAAqC,CACnD,MAAwD;IAExD,MAAM,UAAU,GAAG,MAAM,EAAE,cAAc,EAA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AAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAoB,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzH,OAAO,CAAC,GAAG,IAAI,GAAG,CAAS,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"primary-language.companion.utils.js","sourceRoot":"","sources":["../../../../../src/core/config/primary-language.companion.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAYxE;;;;;;;GAOG;AACH,MAAM,UAAU,qCAAqC,CACnD,MAAwD;IAExD,MAAM,UAAU,GAAG,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,CAAC;IACtE,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,UAA+B,CAAC,EAAE,CAAC;QAC5G,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,UAAU,CAAC,uFAAuF,CAAC,CAAC;IAC9J,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC;IACrF,OAAO,KAAK,IAAI,iBAAiB,CAAC,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,sCAAsC,CACpD,MAAwD;IAExD,MAAM,UAAU,GAAG,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,gBAAgB,CAAC;IACvE,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,UAA+B,CAAC,EAAE,CAAC;QAC5G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AAC,EAAE,CAAC;IACP,OAAO,CAAC,GAAG,IAAI,GAAG,CAAoB,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { AvailableLanguage } from '@wildo-ai/presets-components-models';\n\ntype AppPrimaryLanguageConfigShape = {\n appPreferences?: {\n languages?: {\n defaultLanguage?: unknown;\n fallbackLanguage?: unknown;\n enabledLanguages?: unknown;\n };\n };\n};\n\n/**\n * Resolve the companion's configured primary locale from backend config.\n *\n * Keep this runtime-local helper aligned with\n * `getConfiguredPrimaryLanguage()` in `@wildo-ai/saas-backend-lib`; the\n * companion test/runtime path can execute against the built backend package,\n * while the config object remains the single source of truth.\n */\nexport function getCompanionConfiguredPrimaryLanguage(\n config: AppPrimaryLanguageConfigShape | null | undefined,\n): AvailableLanguage {\n const configured = config?.appPreferences?.languages?.defaultLanguage;\n if (configured !== undefined && !Object.values(AvailableLanguage).includes(configured as AvailableLanguage)) {\n throw new Error(`Invalid app primary language \"${String(configured)}\". Configure appPreferences.languages.defaultLanguage with a valid AvailableLanguage.`);\n }\n const found = Object.values(AvailableLanguage).find((value) => value === configured);\n return found ?? AvailableLanguage.EN;\n}\n\nexport function getCompanionConfiguredFallbackLanguage(\n config: AppPrimaryLanguageConfigShape | null | undefined,\n): AvailableLanguage {\n const configured = config?.appPreferences?.languages?.fallbackLanguage;\n if (configured !== undefined && !Object.values(AvailableLanguage).includes(configured as AvailableLanguage)) {\n throw new Error(`Invalid app fallback language \"${String(configured)}\". Configure appPreferences.languages.fallbackLanguage with a valid AvailableLanguage.`);\n }\n const found = Object.values(AvailableLanguage).find((value) => value === configured);\n return found ?? getCompanionConfiguredPrimaryLanguage(config);\n}\n\n/**\n * The locales an application SERVES: its primary locale plus whatever `appPreferences.languages.enabledLanguages`\n * declares, primary first. One answer for every companion step that writes per-locale files — the label\n * seeding, the email canon seeding and the generation steps — because two answers would let the seeded\n * set and the generated set disagree.\n */\nexport function getCompanionEnabledLocaleCodes(\n config: (AppPrimaryLanguageConfigShape & { appPreferences?: { languages?: { enabledLanguages?: unknown } } }) | null | undefined,\n): readonly string[] {\n const primary = String(getCompanionConfiguredPrimaryLanguage(config));\n const declared = config?.appPreferences?.languages?.enabledLanguages;\n const enabled = Array.isArray(declared) ? declared.filter((locale): locale is string => typeof locale === 'string') : [];\n return [...new Set<string>([primary, ...enabled])];\n}\n\n/**\n * Every language the application serves, PRIMARY FIRST: the configured default, then each enabled\n * language the `AvailableLanguage` vocabulary carries, without repeats. Values outside the vocabulary\n * are skipped rather than thrown on — `enabledLanguages` is a list, and one unknown entry must not\n * stop the languages that are valid.\n *\n * One reader for the consumers that must agree: the i18n generation step (which locales to translate\n * into), the capability composition (whether the website needs a second locale, and which) and the\n * coherence report (which of the market's languages the application does not serve). The\n * foundation does not read it: it composes the locales the composition DECIDED (`decision.locales`),\n * which can include a market language the configuration does not serve yet.\n */\nexport function getCompanionServedLanguages(config: AppPrimaryLanguageConfigShape | null | undefined): AvailableLanguage[] {\n const primary = getCompanionConfiguredPrimaryLanguage(config);\n const declared = config?.appPreferences?.languages?.enabledLanguages;\n const enabled = Array.isArray(declared)\n ? declared.filter((locale): locale is AvailableLanguage => Object.values(AvailableLanguage).includes(locale as AvailableLanguage))\n : [];\n return [...new Set<AvailableLanguage>([primary, ...enabled])];\n}\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { CompanionContext } from "./companion-context";
|
|
2
|
+
/**
|
|
3
|
+
* Lets the long-lived companion see a new build of the application's OWN packages without a restart (#2125).
|
|
4
|
+
*
|
|
5
|
+
* ## The pin this removes
|
|
6
|
+
*
|
|
7
|
+
* The companion reads application packages (`@my-app/shared-lib`, the frontend's `./resource-ui-behaviors`, the
|
|
8
|
+
* backend's `./companion`) as their COMPILED `dist`, imported by Node — directly, or through jiti, which hands an ESM
|
|
9
|
+
* `.js` file to Node's native `import()`. Node's ESM registry keys a module by URL, is process-global, and never
|
|
10
|
+
* forgets a URL. So the first evaluation of each of those modules was the only one the companion ever saw: a coding
|
|
11
|
+
* run that added an enum to `shared-lib` left it `undefined` for every later specifications load, and every playbook
|
|
12
|
+
* run failed with `Cannot read properties of undefined (reading 'X')` until the companion restarted (2026-09-16).
|
|
13
|
+
*
|
|
14
|
+
* ## How
|
|
15
|
+
*
|
|
16
|
+
* An in-thread resolve hook adds `?wildo-application-generation=g<N>` to the URL of every module inside an
|
|
17
|
+
* application package. `N` advances when one of those packages' compiled trees changes, so the next import resolves
|
|
18
|
+
* to new URLs and Node evaluates the application-package subgraph again. Framework packages (anything under
|
|
19
|
+
* `node_modules`) are never tagged, so zod's patched prototypes, the decorator registries and every other framework
|
|
20
|
+
* singleton stay single.
|
|
21
|
+
*
|
|
22
|
+
* One evaluation sees ONE generation, by two rules. A module imported by an already-tagged module inherits its
|
|
23
|
+
* parent's generation rather than the current one, so a lazy `import()` inside a held module — the companion entries
|
|
24
|
+
* of shared-lib, the backend and the frontend all have one — stays in the generation it was loaded in. And a
|
|
25
|
+
* specifications evaluation, whose authored source makes many separate native imports through jiti, HOLDS the
|
|
26
|
+
* generation ({@link holdApplicationModuleGeneration}): an advance computed by a concurrent loader is published only
|
|
27
|
+
* when no evaluation is in flight. Without the hold, measured by review, five imports in one evaluation split across
|
|
28
|
+
* two generations, i.e. two instances of shared-lib in one specifications object.
|
|
29
|
+
*
|
|
30
|
+
* ## What is NOT tagged, deliberately
|
|
31
|
+
*
|
|
32
|
+
* - **The specifications package.** The specifications loader evaluates its authored SOURCE (a fresh read in
|
|
33
|
+
* platform-config-lib), so its compiled `dist` is never imported in-process except by the boot-time charter loader.
|
|
34
|
+
* It is also the package whose build moves most often — every landed family — so signing it would cost a fresh
|
|
35
|
+
* copy of every OTHER package on every edit.
|
|
36
|
+
* - **CommonJS.** Node's `require` ignores a URL query, so a CJS application package is not re-instanced. Every
|
|
37
|
+
* package `wildo init` scaffolds is `"type": "module"`.
|
|
38
|
+
*
|
|
39
|
+
* ## Rejected: evaluating the sibling packages from SOURCE
|
|
40
|
+
*
|
|
41
|
+
* That is what the specifications package itself does, and it was tried first for the siblings. It does not
|
|
42
|
+
* generalise: a frontend's TSX imports `./View.js` meaning `./View.tsx`, which is bundler resolution and fails in Node
|
|
43
|
+
* (measured on Wonder Todos), and it would make the companion depend on every application's source being
|
|
44
|
+
* Node-runnable. The compiled `dist` is what the backend already runs, so it always loads.
|
|
45
|
+
*
|
|
46
|
+
* ## The cost, stated
|
|
47
|
+
*
|
|
48
|
+
* Node never releases a module record, so each generation leaves its predecessor's modules in memory for the life of
|
|
49
|
+
* the process: one copy of the application's compiled sibling packages (shared-lib, the frontend library, the backend
|
|
50
|
+
* companion graph) per rebuild of one of them that a load then observes, cleared by any restart. Review measured
|
|
51
|
+
* about 2 MB retained per generation for Wonder Todos' shared-lib and frontend library with linking failing, so a
|
|
52
|
+
* full evaluation retains more; that figure is not measured. It is the trade against a companion that is silently
|
|
53
|
+
* wrong until restarted.
|
|
54
|
+
*/
|
|
55
|
+
/** The query parameter carrying the generation. Named so a stack trace shows why a module URL has a query. */
|
|
56
|
+
export declare const APPLICATION_MODULE_GENERATION_PARAMETER = "wildo-application-generation";
|
|
57
|
+
/**
|
|
58
|
+
* The longest a hold may keep a newer generation unpublished. Longer than any specifications evaluation measured
|
|
59
|
+
* (2026-10-01: 1.2-2.9 s warm, 11 s cold on a created application, up to 37 s cold on Wonder Todos), so it never cuts a
|
|
60
|
+
* real evaluation short. What it bounds is the two ways a hold could otherwise freeze the generation: an evaluation
|
|
61
|
+
* that never settles, and evaluations overlapping back to back so the hold count never returns to zero. An evaluation
|
|
62
|
+
* that outlives it may see two generations, which is the behaviour without holds — degraded, never stuck.
|
|
63
|
+
*/
|
|
64
|
+
export declare const APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS = 120000;
|
|
65
|
+
type GenerationContext = Pick<CompanionContext, "saasRoot" | "servicesByKey" | "resolvedLibraries" | "resolvedSpecifications">;
|
|
66
|
+
/**
|
|
67
|
+
* Bring the generation up to date with the application's compiled packages, installing the hook on first use, and
|
|
68
|
+
* return the generation a load starting now will see (`null`: nothing is tagged).
|
|
69
|
+
*
|
|
70
|
+
* Call it immediately before any in-process load that reaches an application package. It never throws: a generation
|
|
71
|
+
* improves a load and is never a precondition of one, so a failure to read the packages leaves the published
|
|
72
|
+
* generation as it was and the load proceeds exactly as it did before generations existed.
|
|
73
|
+
*/
|
|
74
|
+
export declare function advanceApplicationModuleGeneration(companionContext: GenerationContext, nowMs?: number): string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Run `evaluate` with the published generation frozen, so every native import it makes lands in one generation.
|
|
77
|
+
*
|
|
78
|
+
* For an evaluation that reaches application packages through SEVERAL separate imports (the specifications source,
|
|
79
|
+
* through jiti) rather than through one entry whose subgraph inherits its tag. Holds nest and overlap; the newest
|
|
80
|
+
* pending generation is published when the last one releases, or once it has waited
|
|
81
|
+
* {@link APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS}, so no hold can freeze the generation for good.
|
|
82
|
+
*/
|
|
83
|
+
export declare function holdApplicationModuleGeneration<T>(evaluate: () => Promise<T>): Promise<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Whether a resolved module URL belongs to an application package and should carry a generation.
|
|
86
|
+
*
|
|
87
|
+
* Exported so the decision can be pinned without installing a process-wide hook in a test. A URL is tagged only when
|
|
88
|
+
* it lies under a registered application package root AND not inside a `node_modules` below it: a package's own
|
|
89
|
+
* dependencies are third-party or framework code, and re-instancing those per generation is exactly the duplicate
|
|
90
|
+
* the design avoids. Both sides come from `pathToFileURL`, so percent-encoding agrees; a path whose letter case
|
|
91
|
+
* differs from the registered root (possible on a case-insensitive Windows volume) is not tagged, which costs
|
|
92
|
+
* freshness and never correctness.
|
|
93
|
+
*/
|
|
94
|
+
export declare function isApplicationModuleUrl(url: string, packageUrlPrefixes?: ReadonlySet<string>): boolean;
|
|
95
|
+
/** Return `url` carrying `generation`, replacing any generation it already carries. */
|
|
96
|
+
export declare function withApplicationModuleGeneration(url: string, generation: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* The generation a resolved application module receives: its importer's, when the importer is itself a tagged
|
|
99
|
+
* application module, and the published one otherwise. Exported so the inheritance rule can be pinned.
|
|
100
|
+
*/
|
|
101
|
+
export declare function generationForImport(parentUrl: string | undefined, published: string | null): string | null;
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=application-module-generations.companion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-module-generations.companion.d.ts","sourceRoot":"","sources":["../../../../../src/core/context/application-module-generations.companion.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,8GAA8G;AAC9G,eAAO,MAAM,uCAAuC,iCAAiC,CAAC;AAYtF;;;;;;GAMG;AACH,eAAO,MAAM,2CAA2C,SAAU,CAAC;AA8BnE,KAAK,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,eAAe,GAAG,mBAAmB,GAAG,wBAAwB,CAAC,CAAC;AAE/H;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,GAAE,MAA0B,GAAG,MAAM,GAAG,IAAI,CAuCxI;AAED;;;;;;;GAOG;AACH,wBAAsB,+BAA+B,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ/F;AAUD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,kBAAkB,GAAE,WAAW,CAAC,MAAM,CAA4B,GAAG,OAAO,CAO/H;AAED,uFAAuF;AACvF,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAIvF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAM1G"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { registerHooks } from "node:module";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { performance } from "node:perf_hooks";
|
|
6
|
+
import { resolveIntrospectedApplicationPackageRoots } from "../introspection/services/introspection-source-state.companion.service.js";
|
|
7
|
+
import { signDerivedInputs } from "../utils/derived-input-signature.companion.utils.js";
|
|
8
|
+
/**
|
|
9
|
+
* Lets the long-lived companion see a new build of the application's OWN packages without a restart (#2125).
|
|
10
|
+
*
|
|
11
|
+
* ## The pin this removes
|
|
12
|
+
*
|
|
13
|
+
* The companion reads application packages (`@my-app/shared-lib`, the frontend's `./resource-ui-behaviors`, the
|
|
14
|
+
* backend's `./companion`) as their COMPILED `dist`, imported by Node — directly, or through jiti, which hands an ESM
|
|
15
|
+
* `.js` file to Node's native `import()`. Node's ESM registry keys a module by URL, is process-global, and never
|
|
16
|
+
* forgets a URL. So the first evaluation of each of those modules was the only one the companion ever saw: a coding
|
|
17
|
+
* run that added an enum to `shared-lib` left it `undefined` for every later specifications load, and every playbook
|
|
18
|
+
* run failed with `Cannot read properties of undefined (reading 'X')` until the companion restarted (2026-09-16).
|
|
19
|
+
*
|
|
20
|
+
* ## How
|
|
21
|
+
*
|
|
22
|
+
* An in-thread resolve hook adds `?wildo-application-generation=g<N>` to the URL of every module inside an
|
|
23
|
+
* application package. `N` advances when one of those packages' compiled trees changes, so the next import resolves
|
|
24
|
+
* to new URLs and Node evaluates the application-package subgraph again. Framework packages (anything under
|
|
25
|
+
* `node_modules`) are never tagged, so zod's patched prototypes, the decorator registries and every other framework
|
|
26
|
+
* singleton stay single.
|
|
27
|
+
*
|
|
28
|
+
* One evaluation sees ONE generation, by two rules. A module imported by an already-tagged module inherits its
|
|
29
|
+
* parent's generation rather than the current one, so a lazy `import()` inside a held module — the companion entries
|
|
30
|
+
* of shared-lib, the backend and the frontend all have one — stays in the generation it was loaded in. And a
|
|
31
|
+
* specifications evaluation, whose authored source makes many separate native imports through jiti, HOLDS the
|
|
32
|
+
* generation ({@link holdApplicationModuleGeneration}): an advance computed by a concurrent loader is published only
|
|
33
|
+
* when no evaluation is in flight. Without the hold, measured by review, five imports in one evaluation split across
|
|
34
|
+
* two generations, i.e. two instances of shared-lib in one specifications object.
|
|
35
|
+
*
|
|
36
|
+
* ## What is NOT tagged, deliberately
|
|
37
|
+
*
|
|
38
|
+
* - **The specifications package.** The specifications loader evaluates its authored SOURCE (a fresh read in
|
|
39
|
+
* platform-config-lib), so its compiled `dist` is never imported in-process except by the boot-time charter loader.
|
|
40
|
+
* It is also the package whose build moves most often — every landed family — so signing it would cost a fresh
|
|
41
|
+
* copy of every OTHER package on every edit.
|
|
42
|
+
* - **CommonJS.** Node's `require` ignores a URL query, so a CJS application package is not re-instanced. Every
|
|
43
|
+
* package `wildo init` scaffolds is `"type": "module"`.
|
|
44
|
+
*
|
|
45
|
+
* ## Rejected: evaluating the sibling packages from SOURCE
|
|
46
|
+
*
|
|
47
|
+
* That is what the specifications package itself does, and it was tried first for the siblings. It does not
|
|
48
|
+
* generalise: a frontend's TSX imports `./View.js` meaning `./View.tsx`, which is bundler resolution and fails in Node
|
|
49
|
+
* (measured on Wonder Todos), and it would make the companion depend on every application's source being
|
|
50
|
+
* Node-runnable. The compiled `dist` is what the backend already runs, so it always loads.
|
|
51
|
+
*
|
|
52
|
+
* ## The cost, stated
|
|
53
|
+
*
|
|
54
|
+
* Node never releases a module record, so each generation leaves its predecessor's modules in memory for the life of
|
|
55
|
+
* the process: one copy of the application's compiled sibling packages (shared-lib, the frontend library, the backend
|
|
56
|
+
* companion graph) per rebuild of one of them that a load then observes, cleared by any restart. Review measured
|
|
57
|
+
* about 2 MB retained per generation for Wonder Todos' shared-lib and frontend library with linking failing, so a
|
|
58
|
+
* full evaluation retains more; that figure is not measured. It is the trade against a companion that is silently
|
|
59
|
+
* wrong until restarted.
|
|
60
|
+
*/
|
|
61
|
+
/** The query parameter carrying the generation. Named so a stack trace shows why a module URL has a query. */
|
|
62
|
+
export const APPLICATION_MODULE_GENERATION_PARAMETER = "wildo-application-generation";
|
|
63
|
+
/**
|
|
64
|
+
* How long one signature reading answers later advances, the creation-plane projection's window and for the same
|
|
65
|
+
* reason: a board refresh or a dispatch loads application packages several times in a burst, and each full reading
|
|
66
|
+
* walks every compiled sibling tree. Measured on Wonder Todos (2026-10-01, Node-loadable files only): a fresh reading
|
|
67
|
+
* 43-52 ms warm and 289 ms cold, against ~0.4 ms inside the window; walking the same trees with their `.d.ts` and
|
|
68
|
+
* `.map` files cost 70-116 ms for three of the five packages. A build emitted inside the window is seen by the first
|
|
69
|
+
* load once the window has elapsed. Measured on a MONOTONIC clock, so a wall-clock correction cannot freeze it.
|
|
70
|
+
*/
|
|
71
|
+
const SIGNATURE_REUSE_MS = 500;
|
|
72
|
+
/**
|
|
73
|
+
* The longest a hold may keep a newer generation unpublished. Longer than any specifications evaluation measured
|
|
74
|
+
* (2026-10-01: 1.2-2.9 s warm, 11 s cold on a created application, up to 37 s cold on Wonder Todos), so it never cuts a
|
|
75
|
+
* real evaluation short. What it bounds is the two ways a hold could otherwise freeze the generation: an evaluation
|
|
76
|
+
* that never settles, and evaluations overlapping back to back so the hold count never returns to zero. An evaluation
|
|
77
|
+
* that outlives it may see two generations, which is the behaviour without holds — degraded, never stuck.
|
|
78
|
+
*/
|
|
79
|
+
export const APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS = 120_000;
|
|
80
|
+
/** The files Node imports from a compiled tree. Declarations and source maps are never loaded. */
|
|
81
|
+
const NODE_LOADED_FILE_PATTERN = /\.(?:m?js|cjs|json)$/u;
|
|
82
|
+
/** `file:` URL prefixes (each ending in `/`) of the application packages whose modules are tagged. */
|
|
83
|
+
const taggedPackageUrlPrefixes = new Set();
|
|
84
|
+
let generationCounter = 0;
|
|
85
|
+
/** The generation every untagged import receives. `null` until a first signature was read. */
|
|
86
|
+
let publishedGeneration = null;
|
|
87
|
+
/**
|
|
88
|
+
* A generation computed while an evaluation held the published one, applied when the last hold releases or once it has
|
|
89
|
+
* waited {@link APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS}, whichever comes first.
|
|
90
|
+
*/
|
|
91
|
+
let pendingGeneration = null;
|
|
92
|
+
let holds = 0;
|
|
93
|
+
let hooksInstalled = false;
|
|
94
|
+
/**
|
|
95
|
+
* Each package's last compiled-tree signature. Per PACKAGE, not per caller: two callers enumerating different sets of
|
|
96
|
+
* packages compare each package against its own last reading, so they never advance the generation by differing from
|
|
97
|
+
* each other, and a rebuild is noticed by whichever caller reads that package next. The generation stays one counter,
|
|
98
|
+
* because the hook is one.
|
|
99
|
+
*/
|
|
100
|
+
const lastSignatureByPackageRoot = new Map();
|
|
101
|
+
/** When each set of packages was last read, for the reuse window only: it decides cost, never whether to advance. */
|
|
102
|
+
const lastReadingAtMsByRootSet = new Map();
|
|
103
|
+
/**
|
|
104
|
+
* Bring the generation up to date with the application's compiled packages, installing the hook on first use, and
|
|
105
|
+
* return the generation a load starting now will see (`null`: nothing is tagged).
|
|
106
|
+
*
|
|
107
|
+
* Call it immediately before any in-process load that reaches an application package. It never throws: a generation
|
|
108
|
+
* improves a load and is never a precondition of one, so a failure to read the packages leaves the published
|
|
109
|
+
* generation as it was and the load proceeds exactly as it did before generations existed.
|
|
110
|
+
*/
|
|
111
|
+
export function advanceApplicationModuleGeneration(companionContext, nowMs = performance.now()) {
|
|
112
|
+
try {
|
|
113
|
+
const packageRoots = resolveTaggablePackageRoots(companionContext);
|
|
114
|
+
for (const packageRoot of packageRoots)
|
|
115
|
+
taggedPackageUrlPrefixes.add(`${pathToFileURL(packageRoot).href}/`);
|
|
116
|
+
installGenerationHook();
|
|
117
|
+
publishPendingGeneration({ nowMs });
|
|
118
|
+
const rootSet = packageRoots.join("\n");
|
|
119
|
+
const lastReadingAtMs = lastReadingAtMsByRootSet.get(rootSet);
|
|
120
|
+
if (lastReadingAtMs !== undefined && nowMs - lastReadingAtMs < SIGNATURE_REUSE_MS)
|
|
121
|
+
return publishedGeneration;
|
|
122
|
+
lastReadingAtMsByRootSet.set(rootSet, nowMs);
|
|
123
|
+
let rebuilt = publishedGeneration === null && pendingGeneration === null;
|
|
124
|
+
for (const packageRoot of packageRoots) {
|
|
125
|
+
const signature = signCompiledPackageTrees(packageRoot) ?? "unbuilt";
|
|
126
|
+
const previous = lastSignatureByPackageRoot.get(packageRoot);
|
|
127
|
+
/*
|
|
128
|
+
* A package read for the first time does not advance: it was not tagged before this call registered it, so its
|
|
129
|
+
* next import resolves to a URL carrying the current generation, which no earlier evaluation used.
|
|
130
|
+
*/
|
|
131
|
+
if (previous !== undefined && previous !== signature)
|
|
132
|
+
rebuilt = true;
|
|
133
|
+
lastSignatureByPackageRoot.set(packageRoot, signature);
|
|
134
|
+
}
|
|
135
|
+
if (!rebuilt)
|
|
136
|
+
return publishedGeneration;
|
|
137
|
+
generationCounter += 1;
|
|
138
|
+
const next = `g${generationCounter}`;
|
|
139
|
+
if (holds > 0) {
|
|
140
|
+
// The wait is measured from the FIRST deferred generation, so a stream of newer ones cannot extend it.
|
|
141
|
+
pendingGeneration = { generation: next, sinceMs: pendingGeneration?.sinceMs ?? nowMs };
|
|
142
|
+
publishPendingGeneration({ nowMs });
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
publishedGeneration = next;
|
|
146
|
+
pendingGeneration = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// Deliberately silent: see the JSDoc. The previous generation stays published.
|
|
151
|
+
}
|
|
152
|
+
return publishedGeneration;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Run `evaluate` with the published generation frozen, so every native import it makes lands in one generation.
|
|
156
|
+
*
|
|
157
|
+
* For an evaluation that reaches application packages through SEVERAL separate imports (the specifications source,
|
|
158
|
+
* through jiti) rather than through one entry whose subgraph inherits its tag. Holds nest and overlap; the newest
|
|
159
|
+
* pending generation is published when the last one releases, or once it has waited
|
|
160
|
+
* {@link APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS}, so no hold can freeze the generation for good.
|
|
161
|
+
*/
|
|
162
|
+
export async function holdApplicationModuleGeneration(evaluate) {
|
|
163
|
+
holds += 1;
|
|
164
|
+
try {
|
|
165
|
+
return await evaluate();
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
holds -= 1;
|
|
169
|
+
publishPendingGeneration({ nowMs: performance.now() });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** Publish the pending generation when no hold remains, or when it has waited past the hold limit. */
|
|
173
|
+
function publishPendingGeneration(input) {
|
|
174
|
+
if (pendingGeneration === null)
|
|
175
|
+
return;
|
|
176
|
+
if (holds > 0 && input.nowMs - pendingGeneration.sinceMs < APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS)
|
|
177
|
+
return;
|
|
178
|
+
publishedGeneration = pendingGeneration.generation;
|
|
179
|
+
pendingGeneration = null;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Whether a resolved module URL belongs to an application package and should carry a generation.
|
|
183
|
+
*
|
|
184
|
+
* Exported so the decision can be pinned without installing a process-wide hook in a test. A URL is tagged only when
|
|
185
|
+
* it lies under a registered application package root AND not inside a `node_modules` below it: a package's own
|
|
186
|
+
* dependencies are third-party or framework code, and re-instancing those per generation is exactly the duplicate
|
|
187
|
+
* the design avoids. Both sides come from `pathToFileURL`, so percent-encoding agrees; a path whose letter case
|
|
188
|
+
* differs from the registered root (possible on a case-insensitive Windows volume) is not tagged, which costs
|
|
189
|
+
* freshness and never correctness.
|
|
190
|
+
*/
|
|
191
|
+
export function isApplicationModuleUrl(url, packageUrlPrefixes = taggedPackageUrlPrefixes) {
|
|
192
|
+
if (!url.startsWith("file:"))
|
|
193
|
+
return false;
|
|
194
|
+
const withoutQuery = url.split("?", 1)[0];
|
|
195
|
+
for (const prefix of packageUrlPrefixes) {
|
|
196
|
+
if (withoutQuery.startsWith(prefix) && !withoutQuery.slice(prefix.length).split("/").includes("node_modules"))
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
/** Return `url` carrying `generation`, replacing any generation it already carries. */
|
|
202
|
+
export function withApplicationModuleGeneration(url, generation) {
|
|
203
|
+
const tagged = new URL(url);
|
|
204
|
+
tagged.searchParams.set(APPLICATION_MODULE_GENERATION_PARAMETER, generation);
|
|
205
|
+
return tagged.href;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The generation a resolved application module receives: its importer's, when the importer is itself a tagged
|
|
209
|
+
* application module, and the published one otherwise. Exported so the inheritance rule can be pinned.
|
|
210
|
+
*/
|
|
211
|
+
export function generationForImport(parentUrl, published) {
|
|
212
|
+
if (parentUrl !== undefined && parentUrl.startsWith("file:") && isApplicationModuleUrl(parentUrl)) {
|
|
213
|
+
const inherited = new URL(parentUrl).searchParams.get(APPLICATION_MODULE_GENERATION_PARAMETER);
|
|
214
|
+
if (inherited !== null)
|
|
215
|
+
return inherited;
|
|
216
|
+
}
|
|
217
|
+
return published;
|
|
218
|
+
}
|
|
219
|
+
function installGenerationHook() {
|
|
220
|
+
if (hooksInstalled)
|
|
221
|
+
return;
|
|
222
|
+
hooksInstalled = true;
|
|
223
|
+
/*
|
|
224
|
+
* `registerHooks` (in-thread, synchronous) rather than `module.register` (a loader thread): the generation must
|
|
225
|
+
* change the moment `advanceApplicationModuleGeneration` returns, and a loader thread would need the value sent
|
|
226
|
+
* across a port. It composes with the static-asset no-op registered through `module.register`: `nextResolve`
|
|
227
|
+
* continues into that chain, whose pattern accepts a trailing query, so a tagged module that imports a stylesheet
|
|
228
|
+
* still gets the empty module (verified with both installed).
|
|
229
|
+
*/
|
|
230
|
+
registerHooks({
|
|
231
|
+
resolve(specifier, context, nextResolve) {
|
|
232
|
+
const resolved = nextResolve(specifier, context);
|
|
233
|
+
if (!isApplicationModuleUrl(resolved.url))
|
|
234
|
+
return resolved;
|
|
235
|
+
const generation = generationForImport(context.parentURL, publishedGeneration);
|
|
236
|
+
return generation === null ? resolved : { ...resolved, url: withApplicationModuleGeneration(resolved.url, generation) };
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The application's packages that are imported natively in-process, by real path.
|
|
242
|
+
*
|
|
243
|
+
* Reads only the fields the context carries: a partial context built for a single loader enumerates what it can.
|
|
244
|
+
* Excluded: the specifications package (see the module JSDoc) and the application root itself — a service declared at
|
|
245
|
+
* `path: "."` would make the root a "package" whose subtree holds the companion under `.wildo-saas/`, and tagging the
|
|
246
|
+
* companion's own modules would give it a second instance of itself.
|
|
247
|
+
*/
|
|
248
|
+
function resolveTaggablePackageRoots(companionContext) {
|
|
249
|
+
const hasApplicationRoot = typeof companionContext.saasRoot === "string" && companionContext.saasRoot.length > 0;
|
|
250
|
+
const applicationRoot = hasApplicationRoot ? safeRealpath(resolve(companionContext.saasRoot)) : null;
|
|
251
|
+
const enumerable = {
|
|
252
|
+
saasRoot: hasApplicationRoot ? companionContext.saasRoot : "",
|
|
253
|
+
servicesByKey: hasApplicationRoot ? (companionContext.servicesByKey ?? {}) : {},
|
|
254
|
+
resolvedLibraries: companionContext.resolvedLibraries ?? {},
|
|
255
|
+
// The specifications package is left out by not naming it: see the module JSDoc.
|
|
256
|
+
resolvedSpecifications: null,
|
|
257
|
+
};
|
|
258
|
+
const roots = new Set();
|
|
259
|
+
for (const packageRoot of resolveIntrospectedApplicationPackageRoots(enumerable)) {
|
|
260
|
+
const realRoot = safeRealpath(packageRoot);
|
|
261
|
+
if (realRoot === null || realRoot === applicationRoot)
|
|
262
|
+
continue;
|
|
263
|
+
roots.add(realRoot);
|
|
264
|
+
}
|
|
265
|
+
return [...roots].sort();
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Sign what Node can import from one package: the directory of every COMPILED target its `exports` declare (an
|
|
269
|
+
* `import` or `default` path, never a `source` one), counting only Node-loadable files. Every target, not only
|
|
270
|
+
* `./companion`, because the frontend's `./resource-ui-behaviors` and a library's root are what specifications import.
|
|
271
|
+
* Authored source is not signed: Node never loads it, so an edit not yet compiled must not cost a generation.
|
|
272
|
+
*/
|
|
273
|
+
function signCompiledPackageTrees(packageRoot) {
|
|
274
|
+
let manifest;
|
|
275
|
+
try {
|
|
276
|
+
manifest = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
const targets = new Set();
|
|
282
|
+
const collect = (value, condition) => {
|
|
283
|
+
if (typeof value === "string") {
|
|
284
|
+
// `./dist/x.js` and `dist/x.js` are the same target; an absolute or escaping path is not this package's build.
|
|
285
|
+
const relativeTarget = value.startsWith("./") ? value.slice(2) : value;
|
|
286
|
+
if (condition !== "source" && condition !== "types" && relativeTarget.length > 0 && !relativeTarget.startsWith("/") && !relativeTarget.startsWith("..")) {
|
|
287
|
+
targets.add(dirname(resolve(packageRoot, relativeTarget)));
|
|
288
|
+
}
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (value !== null && typeof value === "object") {
|
|
292
|
+
for (const [key, nested] of Object.entries(value))
|
|
293
|
+
collect(nested, key.startsWith(".") ? condition : key);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
collect(manifest.exports);
|
|
297
|
+
collect(manifest.module);
|
|
298
|
+
collect(manifest.main);
|
|
299
|
+
if (targets.size === 0)
|
|
300
|
+
return null;
|
|
301
|
+
return signDerivedInputs([...targets].sort(), [resolve(packageRoot, "package.json")], {
|
|
302
|
+
includeFile: (fileName) => NODE_LOADED_FILE_PATTERN.test(fileName),
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
function safeRealpath(path) {
|
|
306
|
+
try {
|
|
307
|
+
return realpathSync(path);
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=application-module-generations.companion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-module-generations.companion.js","sourceRoot":"","sources":["../../../../../src/core/context/application-module-generations.companion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,0CAA0C,EAAE,MAAM,wEAAwE,CAAC;AACpI,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAGrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,8GAA8G;AAC9G,MAAM,CAAC,MAAM,uCAAuC,GAAG,8BAA8B,CAAC;AAEtF;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2CAA2C,GAAG,OAAO,CAAC;AAEnE,kGAAkG;AAClG,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAEzD,sGAAsG;AACtG,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAU,CAAC;AAEnD,IAAI,iBAAiB,GAAG,CAAC,CAAC;AAC1B,8FAA8F;AAC9F,IAAI,mBAAmB,GAAkB,IAAI,CAAC;AAC9C;;;G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AAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO;QACT,CAAC;QACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAChD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC;gBAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACvI,CAAC;IACH,CAAC,CAAC;IACF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,iBAAiB,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,EAAE;QACpF,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC;KACnE,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { readFileSync, realpathSync } from \"node:fs\";\nimport { registerHooks } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { performance } from \"node:perf_hooks\";\n\nimport { resolveIntrospectedApplicationPackageRoots } from \"../introspection/services/introspection-source-state.companion.service\";\nimport { signDerivedInputs } from \"../utils/derived-input-signature.companion.utils\";\nimport type { CompanionContext } from \"./companion-context\";\n\n/**\n * Lets the long-lived companion see a new build of the application's OWN packages without a restart (#2125).\n *\n * ## The pin this removes\n *\n * The companion reads application packages (`@my-app/shared-lib`, the frontend's `./resource-ui-behaviors`, the\n * backend's `./companion`) as their COMPILED `dist`, imported by Node — directly, or through jiti, which hands an ESM\n * `.js` file to Node's native `import()`. Node's ESM registry keys a module by URL, is process-global, and never\n * forgets a URL. So the first evaluation of each of those modules was the only one the companion ever saw: a coding\n * run that added an enum to `shared-lib` left it `undefined` for every later specifications load, and every playbook\n * run failed with `Cannot read properties of undefined (reading 'X')` until the companion restarted (2026-09-16).\n *\n * ## How\n *\n * An in-thread resolve hook adds `?wildo-application-generation=g<N>` to the URL of every module inside an\n * application package. `N` advances when one of those packages' compiled trees changes, so the next import resolves\n * to new URLs and Node evaluates the application-package subgraph again. Framework packages (anything under\n * `node_modules`) are never tagged, so zod's patched prototypes, the decorator registries and every other framework\n * singleton stay single.\n *\n * One evaluation sees ONE generation, by two rules. A module imported by an already-tagged module inherits its\n * parent's generation rather than the current one, so a lazy `import()` inside a held module — the companion entries\n * of shared-lib, the backend and the frontend all have one — stays in the generation it was loaded in. And a\n * specifications evaluation, whose authored source makes many separate native imports through jiti, HOLDS the\n * generation ({@link holdApplicationModuleGeneration}): an advance computed by a concurrent loader is published only\n * when no evaluation is in flight. Without the hold, measured by review, five imports in one evaluation split across\n * two generations, i.e. two instances of shared-lib in one specifications object.\n *\n * ## What is NOT tagged, deliberately\n *\n * - **The specifications package.** The specifications loader evaluates its authored SOURCE (a fresh read in\n * platform-config-lib), so its compiled `dist` is never imported in-process except by the boot-time charter loader.\n * It is also the package whose build moves most often — every landed family — so signing it would cost a fresh\n * copy of every OTHER package on every edit.\n * - **CommonJS.** Node's `require` ignores a URL query, so a CJS application package is not re-instanced. Every\n * package `wildo init` scaffolds is `\"type\": \"module\"`.\n *\n * ## Rejected: evaluating the sibling packages from SOURCE\n *\n * That is what the specifications package itself does, and it was tried first for the siblings. It does not\n * generalise: a frontend's TSX imports `./View.js` meaning `./View.tsx`, which is bundler resolution and fails in Node\n * (measured on Wonder Todos), and it would make the companion depend on every application's source being\n * Node-runnable. The compiled `dist` is what the backend already runs, so it always loads.\n *\n * ## The cost, stated\n *\n * Node never releases a module record, so each generation leaves its predecessor's modules in memory for the life of\n * the process: one copy of the application's compiled sibling packages (shared-lib, the frontend library, the backend\n * companion graph) per rebuild of one of them that a load then observes, cleared by any restart. Review measured\n * about 2 MB retained per generation for Wonder Todos' shared-lib and frontend library with linking failing, so a\n * full evaluation retains more; that figure is not measured. It is the trade against a companion that is silently\n * wrong until restarted.\n */\n\n/** The query parameter carrying the generation. Named so a stack trace shows why a module URL has a query. */\nexport const APPLICATION_MODULE_GENERATION_PARAMETER = \"wildo-application-generation\";\n\n/**\n * How long one signature reading answers later advances, the creation-plane projection's window and for the same\n * reason: a board refresh or a dispatch loads application packages several times in a burst, and each full reading\n * walks every compiled sibling tree. Measured on Wonder Todos (2026-10-01, Node-loadable files only): a fresh reading\n * 43-52 ms warm and 289 ms cold, against ~0.4 ms inside the window; walking the same trees with their `.d.ts` and\n * `.map` files cost 70-116 ms for three of the five packages. A build emitted inside the window is seen by the first\n * load once the window has elapsed. Measured on a MONOTONIC clock, so a wall-clock correction cannot freeze it.\n */\nconst SIGNATURE_REUSE_MS = 500;\n\n/**\n * The longest a hold may keep a newer generation unpublished. Longer than any specifications evaluation measured\n * (2026-10-01: 1.2-2.9 s warm, 11 s cold on a created application, up to 37 s cold on Wonder Todos), so it never cuts a\n * real evaluation short. What it bounds is the two ways a hold could otherwise freeze the generation: an evaluation\n * that never settles, and evaluations overlapping back to back so the hold count never returns to zero. An evaluation\n * that outlives it may see two generations, which is the behaviour without holds — degraded, never stuck.\n */\nexport const APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS = 120_000;\n\n/** The files Node imports from a compiled tree. Declarations and source maps are never loaded. */\nconst NODE_LOADED_FILE_PATTERN = /\\.(?:m?js|cjs|json)$/u;\n\n/** `file:` URL prefixes (each ending in `/`) of the application packages whose modules are tagged. */\nconst taggedPackageUrlPrefixes = new Set<string>();\n\nlet generationCounter = 0;\n/** The generation every untagged import receives. `null` until a first signature was read. */\nlet publishedGeneration: string | null = null;\n/**\n * A generation computed while an evaluation held the published one, applied when the last hold releases or once it has\n * waited {@link APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS}, whichever comes first.\n */\nlet pendingGeneration: { readonly generation: string; readonly sinceMs: number } | null = null;\nlet holds = 0;\nlet hooksInstalled = false;\n\n/**\n * Each package's last compiled-tree signature. Per PACKAGE, not per caller: two callers enumerating different sets of\n * packages compare each package against its own last reading, so they never advance the generation by differing from\n * each other, and a rebuild is noticed by whichever caller reads that package next. The generation stays one counter,\n * because the hook is one.\n */\nconst lastSignatureByPackageRoot = new Map<string, string>();\n\n/** When each set of packages was last read, for the reuse window only: it decides cost, never whether to advance. */\nconst lastReadingAtMsByRootSet = new Map<string, number>();\n\ntype GenerationContext = Pick<CompanionContext, \"saasRoot\" | \"servicesByKey\" | \"resolvedLibraries\" | \"resolvedSpecifications\">;\n\n/**\n * Bring the generation up to date with the application's compiled packages, installing the hook on first use, and\n * return the generation a load starting now will see (`null`: nothing is tagged).\n *\n * Call it immediately before any in-process load that reaches an application package. It never throws: a generation\n * improves a load and is never a precondition of one, so a failure to read the packages leaves the published\n * generation as it was and the load proceeds exactly as it did before generations existed.\n */\nexport function advanceApplicationModuleGeneration(companionContext: GenerationContext, nowMs: number = performance.now()): string | null {\n try {\n const packageRoots = resolveTaggablePackageRoots(companionContext);\n for (const packageRoot of packageRoots) taggedPackageUrlPrefixes.add(`${pathToFileURL(packageRoot).href}/`);\n installGenerationHook();\n\n publishPendingGeneration({ nowMs });\n\n const rootSet = packageRoots.join(\"\\n\");\n const lastReadingAtMs = lastReadingAtMsByRootSet.get(rootSet);\n if (lastReadingAtMs !== undefined && nowMs - lastReadingAtMs < SIGNATURE_REUSE_MS) return publishedGeneration;\n lastReadingAtMsByRootSet.set(rootSet, nowMs);\n\n let rebuilt = publishedGeneration === null && pendingGeneration === null;\n for (const packageRoot of packageRoots) {\n const signature = signCompiledPackageTrees(packageRoot) ?? \"unbuilt\";\n const previous = lastSignatureByPackageRoot.get(packageRoot);\n /*\n * A package read for the first time does not advance: it was not tagged before this call registered it, so its\n * next import resolves to a URL carrying the current generation, which no earlier evaluation used.\n */\n if (previous !== undefined && previous !== signature) rebuilt = true;\n lastSignatureByPackageRoot.set(packageRoot, signature);\n }\n if (!rebuilt) return publishedGeneration;\n generationCounter += 1;\n const next = `g${generationCounter}`;\n if (holds > 0) {\n // The wait is measured from the FIRST deferred generation, so a stream of newer ones cannot extend it.\n pendingGeneration = { generation: next, sinceMs: pendingGeneration?.sinceMs ?? nowMs };\n publishPendingGeneration({ nowMs });\n } else {\n publishedGeneration = next;\n pendingGeneration = null;\n }\n } catch {\n // Deliberately silent: see the JSDoc. The previous generation stays published.\n }\n return publishedGeneration;\n}\n\n/**\n * Run `evaluate` with the published generation frozen, so every native import it makes lands in one generation.\n *\n * For an evaluation that reaches application packages through SEVERAL separate imports (the specifications source,\n * through jiti) rather than through one entry whose subgraph inherits its tag. Holds nest and overlap; the newest\n * pending generation is published when the last one releases, or once it has waited\n * {@link APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS}, so no hold can freeze the generation for good.\n */\nexport async function holdApplicationModuleGeneration<T>(evaluate: () => Promise<T>): Promise<T> {\n holds += 1;\n try {\n return await evaluate();\n } finally {\n holds -= 1;\n publishPendingGeneration({ nowMs: performance.now() });\n }\n}\n\n/** Publish the pending generation when no hold remains, or when it has waited past the hold limit. */\nfunction publishPendingGeneration(input: { readonly nowMs: number }): void {\n if (pendingGeneration === null) return;\n if (holds > 0 && input.nowMs - pendingGeneration.sinceMs < APPLICATION_MODULE_GENERATION_HOLD_LIMIT_MS) return;\n publishedGeneration = pendingGeneration.generation;\n pendingGeneration = null;\n}\n\n/**\n * Whether a resolved module URL belongs to an application package and should carry a generation.\n *\n * Exported so the decision can be pinned without installing a process-wide hook in a test. A URL is tagged only when\n * it lies under a registered application package root AND not inside a `node_modules` below it: a package's own\n * dependencies are third-party or framework code, and re-instancing those per generation is exactly the duplicate\n * the design avoids. Both sides come from `pathToFileURL`, so percent-encoding agrees; a path whose letter case\n * differs from the registered root (possible on a case-insensitive Windows volume) is not tagged, which costs\n * freshness and never correctness.\n */\nexport function isApplicationModuleUrl(url: string, packageUrlPrefixes: ReadonlySet<string> = taggedPackageUrlPrefixes): boolean {\n if (!url.startsWith(\"file:\")) return false;\n const withoutQuery = url.split(\"?\", 1)[0]!;\n for (const prefix of packageUrlPrefixes) {\n if (withoutQuery.startsWith(prefix) && !withoutQuery.slice(prefix.length).split(\"/\").includes(\"node_modules\")) return true;\n }\n return false;\n}\n\n/** Return `url` carrying `generation`, replacing any generation it already carries. */\nexport function withApplicationModuleGeneration(url: string, generation: string): string {\n const tagged = new URL(url);\n tagged.searchParams.set(APPLICATION_MODULE_GENERATION_PARAMETER, generation);\n return tagged.href;\n}\n\n/**\n * The generation a resolved application module receives: its importer's, when the importer is itself a tagged\n * application module, and the published one otherwise. Exported so the inheritance rule can be pinned.\n */\nexport function generationForImport(parentUrl: string | undefined, published: string | null): string | null {\n if (parentUrl !== undefined && parentUrl.startsWith(\"file:\") && isApplicationModuleUrl(parentUrl)) {\n const inherited = new URL(parentUrl).searchParams.get(APPLICATION_MODULE_GENERATION_PARAMETER);\n if (inherited !== null) return inherited;\n }\n return published;\n}\n\nfunction installGenerationHook(): void {\n if (hooksInstalled) return;\n hooksInstalled = true;\n /*\n * `registerHooks` (in-thread, synchronous) rather than `module.register` (a loader thread): the generation must\n * change the moment `advanceApplicationModuleGeneration` returns, and a loader thread would need the value sent\n * across a port. It composes with the static-asset no-op registered through `module.register`: `nextResolve`\n * continues into that chain, whose pattern accepts a trailing query, so a tagged module that imports a stylesheet\n * still gets the empty module (verified with both installed).\n */\n registerHooks({\n resolve(specifier, context, nextResolve) {\n const resolved = nextResolve(specifier, context);\n if (!isApplicationModuleUrl(resolved.url)) return resolved;\n const generation = generationForImport(context.parentURL, publishedGeneration);\n return generation === null ? resolved : { ...resolved, url: withApplicationModuleGeneration(resolved.url, generation) };\n },\n });\n}\n\n/**\n * The application's packages that are imported natively in-process, by real path.\n *\n * Reads only the fields the context carries: a partial context built for a single loader enumerates what it can.\n * Excluded: the specifications package (see the module JSDoc) and the application root itself — a service declared at\n * `path: \".\"` would make the root a \"package\" whose subtree holds the companion under `.wildo-saas/`, and tagging the\n * companion's own modules would give it a second instance of itself.\n */\nfunction resolveTaggablePackageRoots(companionContext: GenerationContext): string[] {\n const hasApplicationRoot = typeof companionContext.saasRoot === \"string\" && companionContext.saasRoot.length > 0;\n const applicationRoot = hasApplicationRoot ? safeRealpath(resolve(companionContext.saasRoot)) : null;\n const enumerable = {\n saasRoot: hasApplicationRoot ? companionContext.saasRoot : \"\",\n servicesByKey: hasApplicationRoot ? (companionContext.servicesByKey ?? {}) : {},\n resolvedLibraries: companionContext.resolvedLibraries ?? {},\n // The specifications package is left out by not naming it: see the module JSDoc.\n resolvedSpecifications: null,\n };\n const roots = new Set<string>();\n for (const packageRoot of resolveIntrospectedApplicationPackageRoots(enumerable)) {\n const realRoot = safeRealpath(packageRoot);\n if (realRoot === null || realRoot === applicationRoot) continue;\n roots.add(realRoot);\n }\n return [...roots].sort();\n}\n\n/**\n * Sign what Node can import from one package: the directory of every COMPILED target its `exports` declare (an\n * `import` or `default` path, never a `source` one), counting only Node-loadable files. Every target, not only\n * `./companion`, because the frontend's `./resource-ui-behaviors` and a library's root are what specifications import.\n * Authored source is not signed: Node never loads it, so an edit not yet compiled must not cost a generation.\n */\nfunction signCompiledPackageTrees(packageRoot: string): string | null {\n let manifest: { exports?: unknown; main?: unknown; module?: unknown };\n try {\n manifest = JSON.parse(readFileSync(resolve(packageRoot, \"package.json\"), \"utf8\")) as typeof manifest;\n } catch {\n return null;\n }\n const targets = new Set<string>();\n const collect = (value: unknown, condition?: string): void => {\n if (typeof value === \"string\") {\n // `./dist/x.js` and `dist/x.js` are the same target; an absolute or escaping path is not this package's build.\n const relativeTarget = value.startsWith(\"./\") ? value.slice(2) : value;\n if (condition !== \"source\" && condition !== \"types\" && relativeTarget.length > 0 && !relativeTarget.startsWith(\"/\") && !relativeTarget.startsWith(\"..\")) {\n targets.add(dirname(resolve(packageRoot, relativeTarget)));\n }\n return;\n }\n if (value !== null && typeof value === \"object\") {\n for (const [key, nested] of Object.entries(value as Record<string, unknown>)) collect(nested, key.startsWith(\".\") ? condition : key);\n }\n };\n collect(manifest.exports);\n collect(manifest.module);\n collect(manifest.main);\n if (targets.size === 0) return null;\n return signDerivedInputs([...targets].sort(), [resolve(packageRoot, \"package.json\")], {\n includeFile: (fileName) => NODE_LOADED_FILE_PATTERN.test(fileName),\n });\n}\n\nfunction safeRealpath(path: string): string | null {\n try {\n return realpathSync(path);\n } catch {\n return null;\n }\n}\n"]}
|
|
@@ -28,18 +28,17 @@ export declare function loadLibraryRootModuleExports(companionContext: Companion
|
|
|
28
28
|
* `tsconfig.json` are normalized and supplied to the loader; without them the
|
|
29
29
|
* authored source cannot resolve its own internal specifiers.
|
|
30
30
|
*
|
|
31
|
-
* **
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* `
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `framework-source`
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* `dist
|
|
41
|
-
*
|
|
42
|
-
* must resolve the way the LOADER does, not the way the resolver defaults.
|
|
31
|
+
* **The evaluated entry is the AUTHORED `src/companion-exports.ts`, in every
|
|
32
|
+
* application.** `freshModuleCache: true` makes `loadPackageCompanionExport`
|
|
33
|
+
* prefer authored source, because jiti re-reads only what it transpiles: the
|
|
34
|
+
* compiled `dist/esm/companion-exports.js` is imported natively by Node and
|
|
35
|
+
* pinned in its process-global ESM registry for the process lifetime. Until
|
|
36
|
+
* 2026-10-01 the entry followed the INFERRED module resolution instead —
|
|
37
|
+
* `framework-source` (source) inside the framework workspace, `package` (dist)
|
|
38
|
+
* outside it — so this surface was fresh on the dogfood applications and frozen
|
|
39
|
+
* at startup on every application created with the published CLI. The resolver
|
|
40
|
+
* called with NO options still answers `dist`; anything reasoning about this
|
|
41
|
+
* surface's freshness must resolve the way the LOADER does.
|
|
43
42
|
*
|
|
44
43
|
* **Authored, not accepted, is the correct surface here.** Consumers are i18n
|
|
45
44
|
* label-key collection and cross-registry assertions, which must track what the
|
|
@@ -51,13 +50,14 @@ export declare function loadSpecificationsCompanionExports(companionContext: Com
|
|
|
51
50
|
/**
|
|
52
51
|
* A cheap fingerprint of the module tree {@link loadSpecificationsCompanionExports} actually evaluates.
|
|
53
52
|
*
|
|
54
|
-
* **It signs every tree the resolver could land on,
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* one extra re-evaluation
|
|
53
|
+
* **It signs every tree the resolver could land on, a superset of the one evaluated.** For the
|
|
54
|
+
* specifications loader that tree is authored `src/` whenever it exists (a fresh read prefers source),
|
|
55
|
+
* and resolving under `framework-source` lands on exactly that file, so `src/` is always signed. The
|
|
56
|
+
* union is kept because the creation-plane projection signs OTHER packages with this function, whose
|
|
57
|
+
* evaluated tree still follows the inferred module resolution — which `platform-config-lib` keeps
|
|
58
|
+
* private. Its cost is that a rebuild of the tree NOT evaluated also invalidates: for specifications,
|
|
59
|
+
* every tsc emit into `dist` after a source edit costs one extra re-evaluation. Never a stale answer,
|
|
60
|
+
* which is the direction this must err in.
|
|
61
61
|
*
|
|
62
62
|
* Why a signature instead of a TTL: `freshModuleCache: true` exists so a family landed while the
|
|
63
63
|
* companion runs is visible without a restart (#170), and a TTL trades exactly that away for up to its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion-package-loaders.companion.d.ts","sourceRoot":"","sources":["../../../../../src/core/context/companion-package-loaders.companion.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"companion-package-loaders.companion.d.ts","sourceRoot":"","sources":["../../../../../src/core/context/companion-package-loaders.companion.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,6BAA6B,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,GAAG,8BAA8B,CAYpI;AAED,wBAAgB,kCAAkC,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,8BAA8B,CAQrH;AAED,wBAAsB,2BAA2B,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAI3I;AAED,wBAAsB,iCAAiC,CACrD,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,GAAE,MAAiB,GAC3B,OAAO,CAAC,6BAA6B,CAAC,CAQxC;AAED,wBAAsB,4BAA4B,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,GAAE,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