@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
package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ import type { CompanionContext } from '../../context/companion-context';
|
|
|
5
5
|
export interface IntrospectionSourceStateObservation {
|
|
6
6
|
/**
|
|
7
7
|
* The comparable value. Two observations with the same token describe the same source tree; a
|
|
8
|
-
* different token means SOMETHING moved
|
|
8
|
+
* different token means SOMETHING moved. Which derivations that voids is decided per derivation from
|
|
9
|
+
* {@link components} — only those whose inputs moved (#2245); one whose inputs are unknown compares
|
|
10
|
+
* on this whole token.
|
|
9
11
|
*/
|
|
10
12
|
token: string;
|
|
11
13
|
/**
|
|
@@ -22,6 +24,21 @@ export interface IntrospectionSourceStateObservation {
|
|
|
22
24
|
observedEntryCount: number;
|
|
23
25
|
/** The instant the sweep STARTED, which is the instant the token describes. */
|
|
24
26
|
startedAt: number;
|
|
27
|
+
/**
|
|
28
|
+
* The same reading, broken down so a caller can tell WHICH tree moved (#2245). Present only when
|
|
29
|
+
* {@link bounded}: an unbounded sweep says nothing reliable about any part of the tree.
|
|
30
|
+
*
|
|
31
|
+
* `shared` covers what every derivation reads — the application root's own manifests and every
|
|
32
|
+
* `@wildo-ai/*` framework root. `byApplicationRoot` holds one token per application package root
|
|
33
|
+
* (keyed by its absolute path), so a write inside `technical-doc` moves that root's token and no
|
|
34
|
+
* other. {@link token} still moves whenever any component does.
|
|
35
|
+
*/
|
|
36
|
+
components?: IntrospectionSourceStateComponents;
|
|
37
|
+
}
|
|
38
|
+
/** {@link IntrospectionSourceStateObservation.components}. */
|
|
39
|
+
export interface IntrospectionSourceStateComponents {
|
|
40
|
+
readonly shared: string;
|
|
41
|
+
readonly byApplicationRoot: ReadonlyMap<string, string>;
|
|
25
42
|
}
|
|
26
43
|
/**
|
|
27
44
|
* Observes the state of every source tree an introspection derivation can read, as one comparable
|
|
@@ -110,27 +127,8 @@ export declare class IntrospectionSourceStateObserver {
|
|
|
110
127
|
* correct, while genuinely concurrent callers share one walk, which is what the coalescing is for.
|
|
111
128
|
*/
|
|
112
129
|
observe(requestedAt?: number): Promise<IntrospectionSourceStateObservation>;
|
|
113
|
-
private runObservation;
|
|
114
130
|
/**
|
|
115
|
-
*
|
|
116
|
-
* differently.
|
|
117
|
-
*
|
|
118
|
-
* An APPLICATION root is a package the operator edits: its `src` moves first and its `dist` moves
|
|
119
|
-
* second, and only the second changes what a derivation imports —
|
|
120
|
-
* `resolvePackageCompanionEntryPath` resolves the package's `exports['./companion']`, which is
|
|
121
|
-
* `./dist/esm/companion-exports.js` on every application package. A FRAMEWORK root is the injected
|
|
122
|
-
* `@wildo-ai/*` copy in the application's own store: dist-only bytes, hard-linked at supervised
|
|
123
|
-
* (re)start, carrying no runtime-signal files of its own.
|
|
124
|
-
*
|
|
125
|
-
* Exposed so the watcher and the sweep observe one population rather than two enumerations that
|
|
126
|
-
* agree only until one side gains an entry.
|
|
127
|
-
*/
|
|
128
|
-
resolveObservedRootPopulations(): Promise<{
|
|
129
|
-
readonly applicationRoots: readonly string[];
|
|
130
|
-
readonly frameworkRoots: readonly string[];
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* Every tree whose bytes can reach a derivation, de-duplicated by resolved real path.
|
|
131
|
+
* Sweep every tree whose bytes can reach a derivation, de-duplicated by resolved real path.
|
|
134
132
|
*
|
|
135
133
|
* Two families, and the second is the one a reader would not think of:
|
|
136
134
|
*
|
|
@@ -148,8 +146,29 @@ export declare class IntrospectionSourceStateObserver {
|
|
|
148
146
|
* family 1, and descending it would pull in `.wildo-saas` (the companion's own dist plus the
|
|
149
147
|
* runtime-signal files that churn on a heartbeat, which would make every token unique and every
|
|
150
148
|
* cache read a miss).
|
|
149
|
+
*
|
|
150
|
+
* Each application root is accumulated into its OWN component, so a caller can tell which package
|
|
151
|
+
* moved (#2245); the framework roots and the root manifests form the shared component.
|
|
151
152
|
*/
|
|
152
|
-
private
|
|
153
|
+
private runObservation;
|
|
154
|
+
/**
|
|
155
|
+
* The two ROOT populations a derivation reads from, kept apart because a watcher treats them
|
|
156
|
+
* differently.
|
|
157
|
+
*
|
|
158
|
+
* An APPLICATION root is a package the operator edits: its `src` moves first and its `dist` moves
|
|
159
|
+
* second, and only the second changes what a derivation imports —
|
|
160
|
+
* `resolvePackageCompanionEntryPath` resolves the package's `exports['./companion']`, which is
|
|
161
|
+
* `./dist/esm/companion-exports.js` on every application package. A FRAMEWORK root is the injected
|
|
162
|
+
* `@wildo-ai/*` copy in the application's own store: dist-only bytes, hard-linked at supervised
|
|
163
|
+
* (re)start, carrying no runtime-signal files of its own.
|
|
164
|
+
*
|
|
165
|
+
* Exposed so the watcher and the sweep observe one population rather than two enumerations that
|
|
166
|
+
* agree only until one side gains an entry.
|
|
167
|
+
*/
|
|
168
|
+
resolveObservedRootPopulations(): Promise<{
|
|
169
|
+
readonly applicationRoots: readonly string[];
|
|
170
|
+
readonly frameworkRoots: readonly string[];
|
|
171
|
+
}>;
|
|
153
172
|
/**
|
|
154
173
|
* Fold the application root's own top-level FILES in, without descending it.
|
|
155
174
|
*
|
package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"introspection-source-state.companion.service.d.ts","sourceRoot":"","sources":["../../../../../../src/core/introspection/services/introspection-source-state.companion.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAsCxE;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAClD
|
|
1
|
+
{"version":3,"file":"introspection-source-state.companion.service.d.ts","sourceRoot":"","sources":["../../../../../../src/core/introspection/services/introspection-source-state.companion.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAsCxE;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAClD;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,4FAA4F;IAC5F,UAAU,EAAE,MAAM,CAAC;IACnB,mFAAmF;IACnF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,2FAA2F;IAC3F,kBAAkB,EAAE,MAAM,CAAC;IAC3B,+EAA+E;IAC/E,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,kCAAkC,CAAC;CACjD;AAED,8DAA8D;AAC9D,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzD;AA4BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,qBAAa,gCAAgC;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA0H;IAC3J,OAAO,CAAC,mBAAmB,CAAK;IAChC,OAAO,CAAC,QAAQ,CAAiG;gBAG/G,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,eAAe,GAAG,eAAe,GAAG,mBAAmB,GAAG,wBAAwB,CAAC;IAK3I;;;;;;;;;OASG;IACU,OAAO,CAAC,WAAW,GAAE,MAAmB,GAAG,OAAO,CAAC,mCAAmC,CAAC;IAuBpG;;;;;;;;;;;;;;;;;;;;;;OAsBG;YACW,cAAc;IAoC5B;;;;;;;;;;;;;OAaG;IACU,8BAA8B,IAAI,OAAO,CAAC;QACrD,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;QAC7C,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;KAC5C,CAAC;IA8BF;;;;;;;;;;;;OAYG;YACW,+BAA+B;IAwB7C;;;;;;;;;OASG;YACW,IAAI;IA4BlB;;;;;;OAMG;YACW,cAAc;CA4D7B;AAED;;;;;;;GAOG;AACH,wBAAgB,0CAA0C,CACxD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,eAAe,GAAG,mBAAmB,GAAG,wBAAwB,CAAC,GACtH,SAAS,MAAM,EAAE,CAYnB"}
|
package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js
CHANGED
|
@@ -33,6 +33,12 @@ const SKIPPED_DIRECTORY_NAMES = new Set(['node_modules', '.git']);
|
|
|
33
33
|
* moving when the source does.
|
|
34
34
|
*/
|
|
35
35
|
const MAXIMUM_OBSERVED_ENTRIES = 250_000;
|
|
36
|
+
function emptyAccumulator() {
|
|
37
|
+
return { fileCount: 0, directoryCount: 0, maximumMtimeMs: 0 };
|
|
38
|
+
}
|
|
39
|
+
function describeAccumulator(accumulator) {
|
|
40
|
+
return `files:${accumulator.fileCount}|dirs:${accumulator.directoryCount}|mtime:${accumulator.maximumMtimeMs}`;
|
|
41
|
+
}
|
|
36
42
|
/**
|
|
37
43
|
* Observes the state of every source tree an introspection derivation can read, as one comparable
|
|
38
44
|
* token.
|
|
@@ -141,28 +147,59 @@ export class IntrospectionSourceStateObserver {
|
|
|
141
147
|
this.inFlight = { startedAt, observation };
|
|
142
148
|
return observation;
|
|
143
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Sweep every tree whose bytes can reach a derivation, de-duplicated by resolved real path.
|
|
152
|
+
*
|
|
153
|
+
* Two families, and the second is the one a reader would not think of:
|
|
154
|
+
*
|
|
155
|
+
* 1. The APPLICATION package roots — every declared service, every resolved library, and the
|
|
156
|
+
* specifications package. Whole roots rather than `src/` alone, because
|
|
157
|
+
* `resolvePackageCompanionEntryPath` prefers a package's built `./companion` export when it
|
|
158
|
+
* exists, so the child commonly imports `dist/`, not source. Sweeping both means neither
|
|
159
|
+
* resolution mode has a blind spot.
|
|
160
|
+
* 2. The FRAMEWORK packages, reached by reading each of those roots' (and the companion home's)
|
|
161
|
+
* `node_modules/@wildo-ai` scope directory and resolving each link to its real path. Reading
|
|
162
|
+
* the scope directory rather than listing package names keeps this from becoming a second
|
|
163
|
+
* enumeration of the engine's package set that could drift from the real one.
|
|
164
|
+
*
|
|
165
|
+
* The application root itself is NOT walked recursively — its interesting children are already in
|
|
166
|
+
* family 1, and descending it would pull in `.wildo-saas` (the companion's own dist plus the
|
|
167
|
+
* runtime-signal files that churn on a heartbeat, which would make every token unique and every
|
|
168
|
+
* cache read a miss).
|
|
169
|
+
*
|
|
170
|
+
* Each application root is accumulated into its OWN component, so a caller can tell which package
|
|
171
|
+
* moved (#2245); the framework roots and the root manifests form the shared component.
|
|
172
|
+
*/
|
|
144
173
|
async runObservation(startedAt) {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
await this.
|
|
174
|
+
const { applicationRoots, frameworkRoots } = await this.resolveObservedRootPopulations();
|
|
175
|
+
// Each application root is observed on its own; the framework roots, and the application root's
|
|
176
|
+
// manifests, share one component because every derivation reads them (#2245). A root that is both
|
|
177
|
+
// is counted once, as an application root.
|
|
178
|
+
const byApplicationRoot = new Map(applicationRoots.map((root) => [root, emptyAccumulator()]));
|
|
179
|
+
const shared = emptyAccumulator();
|
|
180
|
+
const sharedFrameworkRoots = [...new Set(frameworkRoots)].filter((root) => !byApplicationRoot.has(root));
|
|
181
|
+
const totals = { entryCount: 0, exceededCeiling: false };
|
|
182
|
+
await this.observeApplicationRootManifests(shared, totals);
|
|
183
|
+
await this.walk([
|
|
184
|
+
...[...byApplicationRoot.entries()].map(([root, accumulator]) => ({ directory: root, accumulator })),
|
|
185
|
+
...sharedFrameworkRoots.map((root) => ({ directory: root, accumulator: shared })),
|
|
186
|
+
], totals);
|
|
154
187
|
this.observationSequence += 1;
|
|
155
|
-
const bounded = !
|
|
188
|
+
const bounded = !totals.exceededCeiling;
|
|
189
|
+
const observedRootCount = byApplicationRoot.size + sharedFrameworkRoots.length;
|
|
190
|
+
const sharedToken = `roots:${observedRootCount}|${describeAccumulator(shared)}`;
|
|
191
|
+
const rootTokens = new Map([...byApplicationRoot.entries()].map(([root, accumulator]) => [root, describeAccumulator(accumulator)]));
|
|
156
192
|
const token = bounded
|
|
157
|
-
?
|
|
193
|
+
? [sharedToken, ...[...rootTokens.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([root, rootToken]) => `${root}=${rootToken}`)].join('||')
|
|
158
194
|
: `unbounded:${this.observationSequence}`;
|
|
159
195
|
return {
|
|
160
196
|
token,
|
|
161
197
|
bounded,
|
|
162
198
|
durationMs: Date.now() - startedAt,
|
|
163
|
-
observedRootCount
|
|
164
|
-
observedEntryCount:
|
|
199
|
+
observedRootCount,
|
|
200
|
+
observedEntryCount: totals.entryCount,
|
|
165
201
|
startedAt,
|
|
202
|
+
...(bounded ? { components: { shared: sharedToken, byApplicationRoot: rootTokens } } : {}),
|
|
166
203
|
};
|
|
167
204
|
}
|
|
168
205
|
/**
|
|
@@ -208,30 +245,6 @@ export class IntrospectionSourceStateObserver {
|
|
|
208
245
|
}
|
|
209
246
|
return { applicationRoots: [...applicationRoots], frameworkRoots: [...frameworkRoots] };
|
|
210
247
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Every tree whose bytes can reach a derivation, de-duplicated by resolved real path.
|
|
213
|
-
*
|
|
214
|
-
* Two families, and the second is the one a reader would not think of:
|
|
215
|
-
*
|
|
216
|
-
* 1. The APPLICATION package roots — every declared service, every resolved library, and the
|
|
217
|
-
* specifications package. Whole roots rather than `src/` alone, because
|
|
218
|
-
* `resolvePackageCompanionEntryPath` prefers a package's built `./companion` export when it
|
|
219
|
-
* exists, so the child commonly imports `dist/`, not source. Sweeping both means neither
|
|
220
|
-
* resolution mode has a blind spot.
|
|
221
|
-
* 2. The FRAMEWORK packages, reached by reading each of those roots' (and the companion home's)
|
|
222
|
-
* `node_modules/@wildo-ai` scope directory and resolving each link to its real path. Reading
|
|
223
|
-
* the scope directory rather than listing package names keeps this from becoming a second
|
|
224
|
-
* enumeration of the engine's package set that could drift from the real one.
|
|
225
|
-
*
|
|
226
|
-
* The application root itself is NOT walked recursively — its interesting children are already in
|
|
227
|
-
* family 1, and descending it would pull in `.wildo-saas` (the companion's own dist plus the
|
|
228
|
-
* runtime-signal files that churn on a heartbeat, which would make every token unique and every
|
|
229
|
-
* cache read a miss).
|
|
230
|
-
*/
|
|
231
|
-
async resolveObservedRoots() {
|
|
232
|
-
const { applicationRoots, frameworkRoots } = await this.resolveObservedRootPopulations();
|
|
233
|
-
return [...new Set([...applicationRoots, ...frameworkRoots])];
|
|
234
|
-
}
|
|
235
248
|
/**
|
|
236
249
|
* Fold the application root's own top-level FILES in, without descending it.
|
|
237
250
|
*
|
|
@@ -245,7 +258,7 @@ export class IntrospectionSourceStateObserver {
|
|
|
245
258
|
* dist and the runtime-signal files that are rewritten on a heartbeat, which would make every
|
|
246
259
|
* token unique and every cache read a miss.
|
|
247
260
|
*/
|
|
248
|
-
async observeApplicationRootManifests(accumulator) {
|
|
261
|
+
async observeApplicationRootManifests(accumulator, totals) {
|
|
249
262
|
let entries;
|
|
250
263
|
try {
|
|
251
264
|
entries = await fsPromises.readdir(this.companionContext.saasRoot, { withFileTypes: true });
|
|
@@ -257,6 +270,7 @@ export class IntrospectionSourceStateObserver {
|
|
|
257
270
|
if (!entry.isFile())
|
|
258
271
|
return;
|
|
259
272
|
accumulator.fileCount += 1;
|
|
273
|
+
totals.entryCount += 1;
|
|
260
274
|
try {
|
|
261
275
|
const entryStats = await fsPromises.stat(join(this.companionContext.saasRoot, entry.name));
|
|
262
276
|
if (entryStats.mtimeMs > accumulator.maximumMtimeMs) {
|
|
@@ -279,22 +293,22 @@ export class IntrospectionSourceStateObserver {
|
|
|
279
293
|
* is the quantity the concurrency limit is actually about, and terminates on the only condition
|
|
280
294
|
* that means finished: nothing queued and nothing running.
|
|
281
295
|
*/
|
|
282
|
-
async walk(roots,
|
|
296
|
+
async walk(roots, totals) {
|
|
283
297
|
const pending = [...roots];
|
|
284
298
|
let inFlightDirectories = 0;
|
|
285
299
|
return new Promise((resolveWalk) => {
|
|
286
300
|
const pump = () => {
|
|
287
|
-
while (!
|
|
301
|
+
while (!totals.exceededCeiling
|
|
288
302
|
&& inFlightDirectories < DIRECTORY_WALK_CONCURRENCY
|
|
289
303
|
&& pending.length > 0) {
|
|
290
|
-
const
|
|
304
|
+
const next = pending.pop();
|
|
291
305
|
inFlightDirectories += 1;
|
|
292
|
-
void this.visitDirectory(
|
|
306
|
+
void this.visitDirectory(next, totals, pending).then(() => {
|
|
293
307
|
inFlightDirectories -= 1;
|
|
294
308
|
pump();
|
|
295
309
|
});
|
|
296
310
|
}
|
|
297
|
-
if (inFlightDirectories === 0 && (pending.length === 0 ||
|
|
311
|
+
if (inFlightDirectories === 0 && (pending.length === 0 || totals.exceededCeiling)) {
|
|
298
312
|
resolveWalk();
|
|
299
313
|
}
|
|
300
314
|
};
|
|
@@ -308,7 +322,7 @@ export class IntrospectionSourceStateObserver {
|
|
|
308
322
|
* nothing and is not an error — when it appears later it is a new directory, which moves the
|
|
309
323
|
* counts and invalidates every cached derivation.
|
|
310
324
|
*/
|
|
311
|
-
async visitDirectory(directory, accumulator, pending) {
|
|
325
|
+
async visitDirectory({ directory, accumulator }, totals, pending) {
|
|
312
326
|
let entries;
|
|
313
327
|
try {
|
|
314
328
|
entries = await fsPromises.readdir(directory, { withFileTypes: true });
|
|
@@ -317,6 +331,7 @@ export class IntrospectionSourceStateObserver {
|
|
|
317
331
|
return;
|
|
318
332
|
}
|
|
319
333
|
accumulator.directoryCount += 1;
|
|
334
|
+
totals.entryCount += 1;
|
|
320
335
|
try {
|
|
321
336
|
const directoryStats = await fsPromises.stat(directory);
|
|
322
337
|
if (directoryStats.mtimeMs > accumulator.maximumMtimeMs) {
|
|
@@ -332,7 +347,7 @@ export class IntrospectionSourceStateObserver {
|
|
|
332
347
|
continue;
|
|
333
348
|
const entryPath = join(directory, entry.name);
|
|
334
349
|
if (entry.isDirectory()) {
|
|
335
|
-
pending.push(entryPath);
|
|
350
|
+
pending.push({ directory: entryPath, accumulator });
|
|
336
351
|
continue;
|
|
337
352
|
}
|
|
338
353
|
if (!entry.isFile()) {
|
|
@@ -340,8 +355,10 @@ export class IntrospectionSourceStateObserver {
|
|
|
340
355
|
// back out into a dependency graph. Retargeting one rewrites its directory entry, which
|
|
341
356
|
// moves the parent directory's mtime, so the change is still observed.
|
|
342
357
|
accumulator.fileCount += 1;
|
|
358
|
+
totals.entryCount += 1;
|
|
343
359
|
continue;
|
|
344
360
|
}
|
|
361
|
+
totals.entryCount += 1;
|
|
345
362
|
fileStats.push(fsPromises.stat(entryPath).then((entryStats) => {
|
|
346
363
|
accumulator.fileCount += 1;
|
|
347
364
|
if (entryStats.mtimeMs > accumulator.maximumMtimeMs) {
|
|
@@ -352,8 +369,8 @@ export class IntrospectionSourceStateObserver {
|
|
|
352
369
|
}));
|
|
353
370
|
}
|
|
354
371
|
await Promise.all(fileStats);
|
|
355
|
-
if (
|
|
356
|
-
|
|
372
|
+
if (totals.entryCount > MAXIMUM_OBSERVED_ENTRIES) {
|
|
373
|
+
totals.exceededCeiling = true;
|
|
357
374
|
}
|
|
358
375
|
}
|
|
359
376
|
}
|
package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"introspection-source-state.companion.service.js","sourceRoot":"","sources":["../../../../../../src/core/introspection/services/introspection-source-state.companion.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG1C;;;;;;;;;;;GAWG;AACH,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE;;;;;;;;;GASG;AACH,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAkCzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,MAAM,OAAO,gCAAgC;IAC1B,gBAAgB,CAA0H;IACnJ,mBAAmB,GAAG,CAAC,CAAC;IACxB,QAAQ,GAA4F,IAAI,CAAC;IAEjH,YACE,gBAAyI;QAEzI,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CAAC,OAAO,CAAC,cAAsB,IAAI,CAAC,GAAG,EAAE;QACnD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,SAAS,IAAI,WAAW,EAAE,CAAC;YACzD,OAAO,OAAO,CAAC,WAAW,CAAC;QAC7B,CAAC;QAED,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,yFAAyF;YACzF,0DAA0D;YAC1D,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,EAA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AED;;;;;;;GAOG;AACH,MAAM,UAAU,0CAA0C,CACxD,gBAAuH;IAEvH,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3C,KAAK,MAAM,iBAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,CAAC;QAC9E,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,KAAK,MAAM,eAAe,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAChF,gBAAgB,CAAC,GAAG,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,gBAAgB,CAAC,sBAAsB,EAAE,CAAC;QAC5C,gBAAgB,CAAC,GAAG,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,CAAC,GAAG,gBAAgB,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport type { CompanionContext } from '../../context/companion-context';\n\n/**\n * How many directories are walked concurrently.\n *\n * Measured on `examples/wonder-crm` (23,758 files + 2,706 directories across the three application\n * package roots and the 19 distinct `@wildo-ai/*` roots they resolve to): 350 ms at concurrency 1,\n * **125 ms at 16**, 142 ms at 64, 134 ms at 128. The curve is flat past 16, so 16 is the point where\n * the walk stops being latency-bound without turning into an open-ended file-descriptor burst.\n *\n * The walk is deliberately ASYNC rather than the ~30 % faster synchronous form. A synchronous sweep\n * measured 175 ms on the same tree, but it holds the event loop for that whole time — and this runs\n * inside a long-lived HTTP server that is also serving the workbench.\n */\nconst DIRECTORY_WALK_CONCURRENCY = 16;\n\n/**\n * Directory names never descended into.\n *\n * `node_modules` is skipped during the walk and reached only through the explicit `@wildo-ai/*`\n * roots below: descending into it from an application package would sweep the app's entire\n * dependency graph (hundreds of thousands of files) to learn nothing the resolved engine roots do\n * not already say.\n */\nconst SKIPPED_DIRECTORY_NAMES = new Set(['node_modules', '.git']);\n\n/**\n * A ceiling on how much this observer will walk before it gives up on caching.\n *\n * Chosen ~10x above the measured 26k-entry dogfood application, so it can only be reached by a\n * pathological root (a `dist` holding a build cache, an application that vendored something large).\n * Crossing it does not disable the walk half-way and report a plausible number — it returns\n * `bounded: false`, which the caller MUST read as \"do not cache this derivation\". Failing toward\n * re-deriving is the only safe direction here: an under-observed token is a cache key that stops\n * moving when the source does.\n */\nconst MAXIMUM_OBSERVED_ENTRIES = 250_000;\n\n/**\n * What a completed sweep learned about the source that feeds an introspection derivation.\n */\nexport interface IntrospectionSourceStateObservation {\n /**\n * The comparable value. Two observations with the same token describe the same source tree; a\n * different token means SOMETHING moved and every cached derivation is void.\n */\n token: string;\n /**\n * `false` when the sweep hit {@link MAXIMUM_OBSERVED_ENTRIES}. The token is then deliberately\n * unique per observation, so a caller that ignores this flag still re-derives rather than serving\n * a stale answer.\n */\n bounded: boolean;\n /** Wall-clock cost of the sweep, for the debug line that explains a cache hit's latency. */\n durationMs: number;\n /** Number of roots actually walked (a root that does not exist yet is not one). */\n observedRootCount: number;\n /** Files plus directories visited. Reported so an operator can see why a sweep is slow. */\n observedEntryCount: number;\n /** The instant the sweep STARTED, which is the instant the token describes. */\n startedAt: number;\n}\n\ninterface SweepAccumulator {\n fileCount: number;\n directoryCount: number;\n maximumMtimeMs: number;\n exceededCeiling: boolean;\n}\n\n/**\n * Observes the state of every source tree an introspection derivation can read, as one comparable\n * token.\n *\n * ## Why a token rather than a watcher\n *\n * The companion's file watcher (`IntrospectionSourceWatcherCompanionService`) is best-effort —\n * `fs.watch` can go deaf with no error — so it only says WHEN to look; this observer says WHETHER\n * anything moved. A sweep answers that on demand, costs ~125 ms against the largest dogfood\n * application, and cannot miss an event because it does not observe events at all — it observes the\n * tree. (This paragraph said \"the companion has no file watcher\" until 2026-09-24; the watcher was\n * added on top of the observer, not instead of it.)\n *\n * ## Why mtimes rather than content\n *\n * `.claude/rules/application-creation-directive.md` forbids digests, of any kind, for any purpose,\n * and `.claude/rules/one-source-of-truth.md` Rule 0 refuses anything that is not branchable on git.\n * A content hash compared against a stored one is exactly the second-source-of-truth shape both\n * rules exist to keep out. An mtime observation stores nothing about the application: it is a\n * reading taken now, compared against a reading taken earlier in the same process, and deleting it\n * costs a re-derivation and nothing else.\n *\n * ## What the token is made of, and what each part catches\n *\n * | Component | Catches |\n * |---|---|\n * | maximum file/directory mtime | a file written in place (the ordinary edit, and every `tsc` emit) |\n * | file count | a file added or deleted |\n * | directory count | a directory added or deleted |\n * | directory mtimes, in the maximum | a RENAME, which preserves the file's own mtime and would otherwise be invisible while the file count stayed equal |\n *\n * Directory mtimes are the non-obvious member and they are load-bearing: without them,\n * `mv a.ts b.ts` moves neither the count nor any file mtime, and the cache would keep answering\n * from the pre-rename derivation for as long as nothing else in the tree moved.\n *\n * The one mutation this cannot see is an mtime pushed BACKWARD in place on a file that is not the\n * newest in the tree (`touch -t 200001010000 <file>` on an already-old file). Nothing in a dev loop\n * does that; a real editor, `tsc`, `git checkout` and pnpm's hard-link relink all move an mtime\n * forward or move a directory. Recorded rather than papered over, because a reader who assumes the\n * token is total would be assuming something false.\n *\n * ## Which trees, and why the engine ones are in there\n *\n * An application resolving `@wildo-ai/*` through `file:` links — every dogfood app does — changes\n * its derivation when the engine is rebuilt, with no application file touched. The engine bytes the\n * child actually imports are the ones pnpm hard-linked into the app's store, NOT the ones in\n * `engine/<package>/dist`, and the two are reconciled at supervised (re)start rather than continuously. So\n * the framework signal has to be the injected snapshot itself. `.wildo-runtime-signals/dev-compile-status.json`\n * was considered and rejected for exactly this: it is a LEADING indicator, moving when the engine\n * compiles and therefore possibly before the bytes this process would import have changed — which\n * would let a derivation be cached against a token that has already advanced past it, and never\n * re-derived when the injection finally lands.\n *\n * For an application consuming published `@wildo-ai/*` tarballs the same roots are simply immutable\n * between installs, so the sweep costs a little and proves the same thing.\n *\n * ## What it costs, and one narrowing that was measured and REJECTED\n *\n * 176–225 ms against `examples/wonder-crm` (23 roots, 27,050 entries), versus a 3.1–4.2 s cold\n * import of that application's specifications package alone. So a cache hit is ~15x cheaper than\n * the cheapest possible miss.\n *\n * Skipping `*.d.ts` and `*.map` would roughly halve it — they are **55 %** of the swept files\n * (8,830 maps + 4,417 declarations of 24,243) and neither can change a runtime derivation. It was\n * rejected anyway: the saving is ~90 ms nobody can perceive, and it would buy that with an\n * assumption about what a future behavior may read. No behavior under `introspection/subprocess/`\n * imports `node:fs` at all today — every one of them is a pure function of the imported module\n * graph — but that is a fact about today, and the direction to be wrong in here is toward\n * re-deriving. Recorded so the next reader does not re-derive the numbers before reaching the same\n * conclusion.\n */\nexport class IntrospectionSourceStateObserver {\n private readonly companionContext: Pick<CompanionContext, 'saasRoot' | 'companionHome' | 'servicesByKey' | 'resolvedLibraries' | 'resolvedSpecifications'>;\n private observationSequence = 0;\n private inFlight: { startedAt: number; observation: Promise<IntrospectionSourceStateObservation> } | null = null;\n\n constructor(\n companionContext: Pick<CompanionContext, 'saasRoot' | 'companionHome' | 'servicesByKey' | 'resolvedLibraries' | 'resolvedSpecifications'>,\n ) {\n this.companionContext = companionContext;\n }\n\n /**\n * Take a reading of the source trees, reusing an in-flight one ONLY when that reading started at\n * or after the caller's own arrival.\n *\n * The condition is the whole point of the coalescing. A sweep takes ~125 ms; a request arriving\n * 100 ms into someone else's sweep and adopting its token would be answered from a picture of the\n * world taken 100 ms before it asked — a window in which the operator could have saved a file. So\n * a late arrival waits for the running sweep to finish and takes a fresh one, which is slower and\n * correct, while genuinely concurrent callers share one walk, which is what the coalescing is for.\n */\n public async observe(requestedAt: number = Date.now()): Promise<IntrospectionSourceStateObservation> {\n const current = this.inFlight;\n if (current !== null && current.startedAt >= requestedAt) {\n return current.observation;\n }\n\n if (current !== null) {\n // Let the running sweep finish before starting another; two concurrent walks of the same\n // trees would only contend for the same file descriptors.\n await current.observation.catch(() => undefined);\n return this.observe(requestedAt);\n }\n\n const startedAt = Date.now();\n const observation = this.runObservation(startedAt).finally(() => {\n if (this.inFlight?.startedAt === startedAt) {\n this.inFlight = null;\n }\n });\n this.inFlight = { startedAt, observation };\n return observation;\n }\n\n private async runObservation(startedAt: number): Promise<IntrospectionSourceStateObservation> {\n const roots = await this.resolveObservedRoots();\n const accumulator: SweepAccumulator = {\n fileCount: 0,\n directoryCount: 0,\n maximumMtimeMs: 0,\n exceededCeiling: false,\n };\n\n await this.observeApplicationRootManifests(accumulator);\n await this.walk(roots, accumulator);\n\n this.observationSequence += 1;\n const bounded = !accumulator.exceededCeiling;\n const token = bounded\n ? `roots:${roots.length}|files:${accumulator.fileCount}|dirs:${accumulator.directoryCount}|mtime:${accumulator.maximumMtimeMs}`\n : `unbounded:${this.observationSequence}`;\n\n return {\n token,\n bounded,\n durationMs: Date.now() - startedAt,\n observedRootCount: roots.length,\n observedEntryCount: accumulator.fileCount + accumulator.directoryCount,\n startedAt,\n };\n }\n\n /**\n * The two ROOT populations a derivation reads from, kept apart because a watcher treats them\n * differently.\n *\n * An APPLICATION root is a package the operator edits: its `src` moves first and its `dist` moves\n * second, and only the second changes what a derivation imports —\n * `resolvePackageCompanionEntryPath` resolves the package's `exports['./companion']`, which is\n * `./dist/esm/companion-exports.js` on every application package. A FRAMEWORK root is the injected\n * `@wildo-ai/*` copy in the application's own store: dist-only bytes, hard-linked at supervised\n * (re)start, carrying no runtime-signal files of its own.\n *\n * Exposed so the watcher and the sweep observe one population rather than two enumerations that\n * agree only until one side gains an entry.\n */\n public async resolveObservedRootPopulations(): Promise<{\n readonly applicationRoots: readonly string[];\n readonly frameworkRoots: readonly string[];\n }> {\n const applicationRoots = resolveIntrospectedApplicationPackageRoots(this.companionContext);\n\n const frameworkScopeOwners = [\n ...applicationRoots,\n this.companionContext.saasRoot,\n this.companionContext.companionHome,\n ];\n const frameworkRoots = new Set<string>();\n for (const owner of frameworkScopeOwners) {\n const scopeDirectory = join(owner, 'node_modules', '@wildo-ai');\n let scopeEntries: string[];\n try {\n scopeEntries = await fsPromises.readdir(scopeDirectory);\n } catch {\n continue;\n }\n for (const scopeEntry of scopeEntries) {\n try {\n frameworkRoots.add(await fsPromises.realpath(join(scopeDirectory, scopeEntry)));\n } catch {\n // A dangling link contributes nothing to observe; its disappearance shows up as a\n // directory-mtime change on the scope directory's owner instead.\n }\n }\n }\n\n return { applicationRoots: [...applicationRoots], frameworkRoots: [...frameworkRoots] };\n }\n\n /**\n * Every tree whose bytes can reach a derivation, de-duplicated by resolved real path.\n *\n * Two families, and the second is the one a reader would not think of:\n *\n * 1. The APPLICATION package roots — every declared service, every resolved library, and the\n * specifications package. Whole roots rather than `src/` alone, because\n * `resolvePackageCompanionEntryPath` prefers a package's built `./companion` export when it\n * exists, so the child commonly imports `dist/`, not source. Sweeping both means neither\n * resolution mode has a blind spot.\n * 2. The FRAMEWORK packages, reached by reading each of those roots' (and the companion home's)\n * `node_modules/@wildo-ai` scope directory and resolving each link to its real path. Reading\n * the scope directory rather than listing package names keeps this from becoming a second\n * enumeration of the engine's package set that could drift from the real one.\n *\n * The application root itself is NOT walked recursively — its interesting children are already in\n * family 1, and descending it would pull in `.wildo-saas` (the companion's own dist plus the\n * runtime-signal files that churn on a heartbeat, which would make every token unique and every\n * cache read a miss).\n */\n private async resolveObservedRoots(): Promise<string[]> {\n const { applicationRoots, frameworkRoots } = await this.resolveObservedRootPopulations();\n return [...new Set([...applicationRoots, ...frameworkRoots])];\n }\n\n /**\n * Fold the application root's own top-level FILES in, without descending it.\n *\n * These are `pnpm-lock.yaml`, `package.json` and `wildo.saas.config.ts` — the manifests that\n * decide which third-party bytes the child imports. Without them there is a narrow but real hole:\n * an install that moves a non-`@wildo-ai` dependency changes a derivation while touching nothing\n * inside a package root, because the walk enters `node_modules` only through the resolved\n * `@wildo-ai` scope. The lockfile moves on every such install, so one shallow read closes it.\n *\n * The root is NOT descended, because doing so would pull in `.wildo-saas` — the companion's own\n * dist and the runtime-signal files that are rewritten on a heartbeat, which would make every\n * token unique and every cache read a miss.\n */\n private async observeApplicationRootManifests(accumulator: SweepAccumulator): Promise<void> {\n let entries;\n try {\n entries = await fsPromises.readdir(this.companionContext.saasRoot, { withFileTypes: true });\n } catch {\n return;\n }\n\n await Promise.all(entries.map(async (entry) => {\n if (!entry.isFile()) return;\n accumulator.fileCount += 1;\n try {\n const entryStats = await fsPromises.stat(join(this.companionContext.saasRoot, entry.name));\n if (entryStats.mtimeMs > accumulator.maximumMtimeMs) {\n accumulator.maximumMtimeMs = entryStats.mtimeMs;\n }\n } catch {\n // Counted above; a file that vanished between readdir and stat is itself a change, and the\n // count will differ on the next observation.\n }\n }));\n }\n\n /**\n * Breadth-of-tree walk with a fixed directory concurrency.\n *\n * A worker-pool built over the ROOT list was written first and was wrong: it sizes its pool from\n * the number of roots, so a single-root application would walk its whole tree one directory at a\n * time, and a worker that finds the queue momentarily empty cannot tell \"finished\" from \"another\n * worker is about to push children\". The pump below sizes on IN-FLIGHT directories instead, which\n * is the quantity the concurrency limit is actually about, and terminates on the only condition\n * that means finished: nothing queued and nothing running.\n */\n private async walk(roots: readonly string[], accumulator: SweepAccumulator): Promise<void> {\n const pending: string[] = [...roots];\n let inFlightDirectories = 0;\n\n return new Promise<void>((resolveWalk) => {\n const pump = (): void => {\n while (\n !accumulator.exceededCeiling\n && inFlightDirectories < DIRECTORY_WALK_CONCURRENCY\n && pending.length > 0\n ) {\n const directory = pending.pop() as string;\n inFlightDirectories += 1;\n void this.visitDirectory(directory, accumulator, pending).then(() => {\n inFlightDirectories -= 1;\n pump();\n });\n }\n\n if (inFlightDirectories === 0 && (pending.length === 0 || accumulator.exceededCeiling)) {\n resolveWalk();\n }\n };\n\n pump();\n });\n }\n\n /**\n * Read one directory: count it, fold its own mtime in, stat its files, and queue its children.\n *\n * Never rejects. A directory that cannot be read (an unbuilt `dist`, a permission) contributes\n * nothing and is not an error — when it appears later it is a new directory, which moves the\n * counts and invalidates every cached derivation.\n */\n private async visitDirectory(\n directory: string,\n accumulator: SweepAccumulator,\n pending: string[],\n ): Promise<void> {\n let entries;\n try {\n entries = await fsPromises.readdir(directory, { withFileTypes: true });\n } catch {\n return;\n }\n\n accumulator.directoryCount += 1;\n try {\n const directoryStats = await fsPromises.stat(directory);\n if (directoryStats.mtimeMs > accumulator.maximumMtimeMs) {\n accumulator.maximumMtimeMs = directoryStats.mtimeMs;\n }\n } catch {\n // Counted above regardless: the directory demonstrably exists, we just read it.\n }\n\n const fileStats: Promise<void>[] = [];\n for (const entry of entries) {\n if (SKIPPED_DIRECTORY_NAMES.has(entry.name)) continue;\n const entryPath = join(directory, entry.name);\n if (entry.isDirectory()) {\n pending.push(entryPath);\n continue;\n }\n if (!entry.isFile()) {\n // A symlink is counted but never followed — following one inside a package tree can walk\n // back out into a dependency graph. Retargeting one rewrites its directory entry, which\n // moves the parent directory's mtime, so the change is still observed.\n accumulator.fileCount += 1;\n continue;\n }\n fileStats.push(\n fsPromises.stat(entryPath).then(\n (entryStats) => {\n accumulator.fileCount += 1;\n if (entryStats.mtimeMs > accumulator.maximumMtimeMs) {\n accumulator.maximumMtimeMs = entryStats.mtimeMs;\n }\n },\n () => {\n accumulator.fileCount += 1;\n },\n ),\n );\n }\n await Promise.all(fileStats);\n\n if (accumulator.fileCount + accumulator.directoryCount > MAXIMUM_OBSERVED_ENTRIES) {\n accumulator.exceededCeiling = true;\n }\n }\n}\n\n/**\n * Every APPLICATION package an introspection derivation can import: each declared service, each\n * resolved library, and the specifications package.\n *\n * ONE enumeration, shared by this observer and by the creation-plane projection's input signature\n * (#1310, seventh review G1), because both answer the same question — \"which built trees can move an\n * introspection result?\" — and two lists of one population agree only until one gains an entry.\n */\nexport function resolveIntrospectedApplicationPackageRoots(\n companionContext: Pick<CompanionContext, 'saasRoot' | 'servicesByKey' | 'resolvedLibraries' | 'resolvedSpecifications'>,\n): readonly string[] {\n const applicationRoots = new Set<string>();\n for (const serviceDefinition of Object.values(companionContext.servicesByKey)) {\n applicationRoots.add(resolve(companionContext.saasRoot, serviceDefinition.path));\n }\n for (const resolvedLibrary of Object.values(companionContext.resolvedLibraries)) {\n applicationRoots.add(resolvedLibrary.packageRoot);\n }\n if (companionContext.resolvedSpecifications) {\n applicationRoots.add(companionContext.resolvedSpecifications.packageRoot);\n }\n return [...applicationRoots];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"introspection-source-state.companion.service.js","sourceRoot":"","sources":["../../../../../../src/core/introspection/services/introspection-source-state.companion.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG1C;;;;;;;;;;;GAWG;AACH,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE;;;;;;;;;GASG;AACH,MAAM,wBAAwB,GAAG,OAAO,CAAC;AA+DzC,SAAS,gBAAgB;IACvB,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,mBAAmB,CAAC,WAA6B;IACxD,OAAO,SAAS,WAAW,CAAC,SAAS,SAAS,WAAW,CAAC,cAAc,UAAU,WAAW,CAAC,cAAc,EAAE,CAAC;AACjH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,MAAM,OAAO,gCAAgC;IAC1B,gBAAgB,CAA0H;IACnJ,mBAAmB,GAAG,CAAC,CAAC;IACxB,QAAQ,GAA4F,IAAI,CAAC;IAEjH,YACE,gBAAyI;QAEzI,IAAI,CAAC,gBAAgB,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C,gBAAgB,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,CAAC,GAAG,gBAAgB,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport type { CompanionContext } from '../../context/companion-context';\n\n/**\n * How many directories are walked concurrently.\n *\n * Measured on `examples/wonder-crm` (23,758 files + 2,706 directories across the three application\n * package roots and the 19 distinct `@wildo-ai/*` roots they resolve to): 350 ms at concurrency 1,\n * **125 ms at 16**, 142 ms at 64, 134 ms at 128. The curve is flat past 16, so 16 is the point where\n * the walk stops being latency-bound without turning into an open-ended file-descriptor burst.\n *\n * The walk is deliberately ASYNC rather than the ~30 % faster synchronous form. A synchronous sweep\n * measured 175 ms on the same tree, but it holds the event loop for that whole time — and this runs\n * inside a long-lived HTTP server that is also serving the workbench.\n */\nconst DIRECTORY_WALK_CONCURRENCY = 16;\n\n/**\n * Directory names never descended into.\n *\n * `node_modules` is skipped during the walk and reached only through the explicit `@wildo-ai/*`\n * roots below: descending into it from an application package would sweep the app's entire\n * dependency graph (hundreds of thousands of files) to learn nothing the resolved engine roots do\n * not already say.\n */\nconst SKIPPED_DIRECTORY_NAMES = new Set(['node_modules', '.git']);\n\n/**\n * A ceiling on how much this observer will walk before it gives up on caching.\n *\n * Chosen ~10x above the measured 26k-entry dogfood application, so it can only be reached by a\n * pathological root (a `dist` holding a build cache, an application that vendored something large).\n * Crossing it does not disable the walk half-way and report a plausible number — it returns\n * `bounded: false`, which the caller MUST read as \"do not cache this derivation\". Failing toward\n * re-deriving is the only safe direction here: an under-observed token is a cache key that stops\n * moving when the source does.\n */\nconst MAXIMUM_OBSERVED_ENTRIES = 250_000;\n\n/**\n * What a completed sweep learned about the source that feeds an introspection derivation.\n */\nexport interface IntrospectionSourceStateObservation {\n /**\n * The comparable value. Two observations with the same token describe the same source tree; a\n * different token means SOMETHING moved. Which derivations that voids is decided per derivation from\n * {@link components} — only those whose inputs moved (#2245); one whose inputs are unknown compares\n * on this whole token.\n */\n token: string;\n /**\n * `false` when the sweep hit {@link MAXIMUM_OBSERVED_ENTRIES}. The token is then deliberately\n * unique per observation, so a caller that ignores this flag still re-derives rather than serving\n * a stale answer.\n */\n bounded: boolean;\n /** Wall-clock cost of the sweep, for the debug line that explains a cache hit's latency. */\n durationMs: number;\n /** Number of roots actually walked (a root that does not exist yet is not one). */\n observedRootCount: number;\n /** Files plus directories visited. Reported so an operator can see why a sweep is slow. */\n observedEntryCount: number;\n /** The instant the sweep STARTED, which is the instant the token describes. */\n startedAt: number;\n /**\n * The same reading, broken down so a caller can tell WHICH tree moved (#2245). Present only when\n * {@link bounded}: an unbounded sweep says nothing reliable about any part of the tree.\n *\n * `shared` covers what every derivation reads — the application root's own manifests and every\n * `@wildo-ai/*` framework root. `byApplicationRoot` holds one token per application package root\n * (keyed by its absolute path), so a write inside `technical-doc` moves that root's token and no\n * other. {@link token} still moves whenever any component does.\n */\n components?: IntrospectionSourceStateComponents;\n}\n\n/** {@link IntrospectionSourceStateObservation.components}. */\nexport interface IntrospectionSourceStateComponents {\n readonly shared: string;\n readonly byApplicationRoot: ReadonlyMap<string, string>;\n}\n\ninterface SweepAccumulator {\n fileCount: number;\n directoryCount: number;\n maximumMtimeMs: number;\n}\n\n/** A directory still to visit, and the component its entries count towards. */\ninterface PendingDirectory {\n readonly directory: string;\n readonly accumulator: SweepAccumulator;\n}\n\n/** The whole sweep's running total, so the ceiling bounds the walk rather than any one root. */\ninterface SweepTotals {\n entryCount: number;\n exceededCeiling: boolean;\n}\n\nfunction emptyAccumulator(): SweepAccumulator {\n return { fileCount: 0, directoryCount: 0, maximumMtimeMs: 0 };\n}\n\nfunction describeAccumulator(accumulator: SweepAccumulator): string {\n return `files:${accumulator.fileCount}|dirs:${accumulator.directoryCount}|mtime:${accumulator.maximumMtimeMs}`;\n}\n\n/**\n * Observes the state of every source tree an introspection derivation can read, as one comparable\n * token.\n *\n * ## Why a token rather than a watcher\n *\n * The companion's file watcher (`IntrospectionSourceWatcherCompanionService`) is best-effort —\n * `fs.watch` can go deaf with no error — so it only says WHEN to look; this observer says WHETHER\n * anything moved. A sweep answers that on demand, costs ~125 ms against the largest dogfood\n * application, and cannot miss an event because it does not observe events at all — it observes the\n * tree. (This paragraph said \"the companion has no file watcher\" until 2026-09-24; the watcher was\n * added on top of the observer, not instead of it.)\n *\n * ## Why mtimes rather than content\n *\n * `.claude/rules/application-creation-directive.md` forbids digests, of any kind, for any purpose,\n * and `.claude/rules/one-source-of-truth.md` Rule 0 refuses anything that is not branchable on git.\n * A content hash compared against a stored one is exactly the second-source-of-truth shape both\n * rules exist to keep out. An mtime observation stores nothing about the application: it is a\n * reading taken now, compared against a reading taken earlier in the same process, and deleting it\n * costs a re-derivation and nothing else.\n *\n * ## What the token is made of, and what each part catches\n *\n * | Component | Catches |\n * |---|---|\n * | maximum file/directory mtime | a file written in place (the ordinary edit, and every `tsc` emit) |\n * | file count | a file added or deleted |\n * | directory count | a directory added or deleted |\n * | directory mtimes, in the maximum | a RENAME, which preserves the file's own mtime and would otherwise be invisible while the file count stayed equal |\n *\n * Directory mtimes are the non-obvious member and they are load-bearing: without them,\n * `mv a.ts b.ts` moves neither the count nor any file mtime, and the cache would keep answering\n * from the pre-rename derivation for as long as nothing else in the tree moved.\n *\n * The one mutation this cannot see is an mtime pushed BACKWARD in place on a file that is not the\n * newest in the tree (`touch -t 200001010000 <file>` on an already-old file). Nothing in a dev loop\n * does that; a real editor, `tsc`, `git checkout` and pnpm's hard-link relink all move an mtime\n * forward or move a directory. Recorded rather than papered over, because a reader who assumes the\n * token is total would be assuming something false.\n *\n * ## Which trees, and why the engine ones are in there\n *\n * An application resolving `@wildo-ai/*` through `file:` links — every dogfood app does — changes\n * its derivation when the engine is rebuilt, with no application file touched. The engine bytes the\n * child actually imports are the ones pnpm hard-linked into the app's store, NOT the ones in\n * `engine/<package>/dist`, and the two are reconciled at supervised (re)start rather than continuously. So\n * the framework signal has to be the injected snapshot itself. `.wildo-runtime-signals/dev-compile-status.json`\n * was considered and rejected for exactly this: it is a LEADING indicator, moving when the engine\n * compiles and therefore possibly before the bytes this process would import have changed — which\n * would let a derivation be cached against a token that has already advanced past it, and never\n * re-derived when the injection finally lands.\n *\n * For an application consuming published `@wildo-ai/*` tarballs the same roots are simply immutable\n * between installs, so the sweep costs a little and proves the same thing.\n *\n * ## What it costs, and one narrowing that was measured and REJECTED\n *\n * 176–225 ms against `examples/wonder-crm` (23 roots, 27,050 entries), versus a 3.1–4.2 s cold\n * import of that application's specifications package alone. So a cache hit is ~15x cheaper than\n * the cheapest possible miss.\n *\n * Skipping `*.d.ts` and `*.map` would roughly halve it — they are **55 %** of the swept files\n * (8,830 maps + 4,417 declarations of 24,243) and neither can change a runtime derivation. It was\n * rejected anyway: the saving is ~90 ms nobody can perceive, and it would buy that with an\n * assumption about what a future behavior may read. No behavior under `introspection/subprocess/`\n * imports `node:fs` at all today — every one of them is a pure function of the imported module\n * graph — but that is a fact about today, and the direction to be wrong in here is toward\n * re-deriving. Recorded so the next reader does not re-derive the numbers before reaching the same\n * conclusion.\n */\nexport class IntrospectionSourceStateObserver {\n private readonly companionContext: Pick<CompanionContext, 'saasRoot' | 'companionHome' | 'servicesByKey' | 'resolvedLibraries' | 'resolvedSpecifications'>;\n private observationSequence = 0;\n private inFlight: { startedAt: number; observation: Promise<IntrospectionSourceStateObservation> } | null = null;\n\n constructor(\n companionContext: Pick<CompanionContext, 'saasRoot' | 'companionHome' | 'servicesByKey' | 'resolvedLibraries' | 'resolvedSpecifications'>,\n ) {\n this.companionContext = companionContext;\n }\n\n /**\n * Take a reading of the source trees, reusing an in-flight one ONLY when that reading started at\n * or after the caller's own arrival.\n *\n * The condition is the whole point of the coalescing. A sweep takes ~125 ms; a request arriving\n * 100 ms into someone else's sweep and adopting its token would be answered from a picture of the\n * world taken 100 ms before it asked — a window in which the operator could have saved a file. So\n * a late arrival waits for the running sweep to finish and takes a fresh one, which is slower and\n * correct, while genuinely concurrent callers share one walk, which is what the coalescing is for.\n */\n public async observe(requestedAt: number = Date.now()): Promise<IntrospectionSourceStateObservation> {\n const current = this.inFlight;\n if (current !== null && current.startedAt >= requestedAt) {\n return current.observation;\n }\n\n if (current !== null) {\n // Let the running sweep finish before starting another; two concurrent walks of the same\n // trees would only contend for the same file descriptors.\n await current.observation.catch(() => undefined);\n return this.observe(requestedAt);\n }\n\n const startedAt = Date.now();\n const observation = this.runObservation(startedAt).finally(() => {\n if (this.inFlight?.startedAt === startedAt) {\n this.inFlight = null;\n }\n });\n this.inFlight = { startedAt, observation };\n return observation;\n }\n\n /**\n * Sweep every tree whose bytes can reach a derivation, de-duplicated by resolved real path.\n *\n * Two families, and the second is the one a reader would not think of:\n *\n * 1. The APPLICATION package roots — every declared service, every resolved library, and the\n * specifications package. Whole roots rather than `src/` alone, because\n * `resolvePackageCompanionEntryPath` prefers a package's built `./companion` export when it\n * exists, so the child commonly imports `dist/`, not source. Sweeping both means neither\n * resolution mode has a blind spot.\n * 2. The FRAMEWORK packages, reached by reading each of those roots' (and the companion home's)\n * `node_modules/@wildo-ai` scope directory and resolving each link to its real path. Reading\n * the scope directory rather than listing package names keeps this from becoming a second\n * enumeration of the engine's package set that could drift from the real one.\n *\n * The application root itself is NOT walked recursively — its interesting children are already in\n * family 1, and descending it would pull in `.wildo-saas` (the companion's own dist plus the\n * runtime-signal files that churn on a heartbeat, which would make every token unique and every\n * cache read a miss).\n *\n * Each application root is accumulated into its OWN component, so a caller can tell which package\n * moved (#2245); the framework roots and the root manifests form the shared component.\n */\n private async runObservation(startedAt: number): Promise<IntrospectionSourceStateObservation> {\n const { applicationRoots, frameworkRoots } = await this.resolveObservedRootPopulations();\n // Each application root is observed on its own; the framework roots, and the application root's\n // manifests, share one component because every derivation reads them (#2245). A root that is both\n // is counted once, as an application root.\n const byApplicationRoot = new Map(applicationRoots.map((root) => [root, emptyAccumulator()] as const));\n const shared = emptyAccumulator();\n const sharedFrameworkRoots = [...new Set(frameworkRoots)].filter((root) => !byApplicationRoot.has(root));\n const totals: SweepTotals = { entryCount: 0, exceededCeiling: false };\n\n await this.observeApplicationRootManifests(shared, totals);\n await this.walk([\n ...[...byApplicationRoot.entries()].map(([root, accumulator]) => ({ directory: root, accumulator })),\n ...sharedFrameworkRoots.map((root) => ({ directory: root, accumulator: shared })),\n ], totals);\n\n this.observationSequence += 1;\n const bounded = !totals.exceededCeiling;\n const observedRootCount = byApplicationRoot.size + sharedFrameworkRoots.length;\n const sharedToken = `roots:${observedRootCount}|${describeAccumulator(shared)}`;\n const rootTokens = new Map([...byApplicationRoot.entries()].map(([root, accumulator]) => [root, describeAccumulator(accumulator)] as const));\n const token = bounded\n ? [sharedToken, ...[...rootTokens.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([root, rootToken]) => `${root}=${rootToken}`)].join('||')\n : `unbounded:${this.observationSequence}`;\n\n return {\n token,\n bounded,\n durationMs: Date.now() - startedAt,\n observedRootCount,\n observedEntryCount: totals.entryCount,\n startedAt,\n ...(bounded ? { components: { shared: sharedToken, byApplicationRoot: rootTokens } } : {}),\n };\n }\n\n /**\n * The two ROOT populations a derivation reads from, kept apart because a watcher treats them\n * differently.\n *\n * An APPLICATION root is a package the operator edits: its `src` moves first and its `dist` moves\n * second, and only the second changes what a derivation imports —\n * `resolvePackageCompanionEntryPath` resolves the package's `exports['./companion']`, which is\n * `./dist/esm/companion-exports.js` on every application package. A FRAMEWORK root is the injected\n * `@wildo-ai/*` copy in the application's own store: dist-only bytes, hard-linked at supervised\n * (re)start, carrying no runtime-signal files of its own.\n *\n * Exposed so the watcher and the sweep observe one population rather than two enumerations that\n * agree only until one side gains an entry.\n */\n public async resolveObservedRootPopulations(): Promise<{\n readonly applicationRoots: readonly string[];\n readonly frameworkRoots: readonly string[];\n }> {\n const applicationRoots = resolveIntrospectedApplicationPackageRoots(this.companionContext);\n\n const frameworkScopeOwners = [\n ...applicationRoots,\n this.companionContext.saasRoot,\n this.companionContext.companionHome,\n ];\n const frameworkRoots = new Set<string>();\n for (const owner of frameworkScopeOwners) {\n const scopeDirectory = join(owner, 'node_modules', '@wildo-ai');\n let scopeEntries: string[];\n try {\n scopeEntries = await fsPromises.readdir(scopeDirectory);\n } catch {\n continue;\n }\n for (const scopeEntry of scopeEntries) {\n try {\n frameworkRoots.add(await fsPromises.realpath(join(scopeDirectory, scopeEntry)));\n } catch {\n // A dangling link contributes nothing to observe; its disappearance shows up as a\n // directory-mtime change on the scope directory's owner instead.\n }\n }\n }\n\n return { applicationRoots: [...applicationRoots], frameworkRoots: [...frameworkRoots] };\n }\n\n /**\n * Fold the application root's own top-level FILES in, without descending it.\n *\n * These are `pnpm-lock.yaml`, `package.json` and `wildo.saas.config.ts` — the manifests that\n * decide which third-party bytes the child imports. Without them there is a narrow but real hole:\n * an install that moves a non-`@wildo-ai` dependency changes a derivation while touching nothing\n * inside a package root, because the walk enters `node_modules` only through the resolved\n * `@wildo-ai` scope. The lockfile moves on every such install, so one shallow read closes it.\n *\n * The root is NOT descended, because doing so would pull in `.wildo-saas` — the companion's own\n * dist and the runtime-signal files that are rewritten on a heartbeat, which would make every\n * token unique and every cache read a miss.\n */\n private async observeApplicationRootManifests(accumulator: SweepAccumulator, totals: SweepTotals): Promise<void> {\n let entries;\n try {\n entries = await fsPromises.readdir(this.companionContext.saasRoot, { withFileTypes: true });\n } catch {\n return;\n }\n\n await Promise.all(entries.map(async (entry) => {\n if (!entry.isFile()) return;\n accumulator.fileCount += 1;\n totals.entryCount += 1;\n try {\n const entryStats = await fsPromises.stat(join(this.companionContext.saasRoot, entry.name));\n if (entryStats.mtimeMs > accumulator.maximumMtimeMs) {\n accumulator.maximumMtimeMs = entryStats.mtimeMs;\n }\n } catch {\n // Counted above; a file that vanished between readdir and stat is itself a change, and the\n // count will differ on the next observation.\n }\n }));\n }\n\n /**\n * Breadth-of-tree walk with a fixed directory concurrency.\n *\n * A worker-pool built over the ROOT list was written first and was wrong: it sizes its pool from\n * the number of roots, so a single-root application would walk its whole tree one directory at a\n * time, and a worker that finds the queue momentarily empty cannot tell \"finished\" from \"another\n * worker is about to push children\". The pump below sizes on IN-FLIGHT directories instead, which\n * is the quantity the concurrency limit is actually about, and terminates on the only condition\n * that means finished: nothing queued and nothing running.\n */\n private async walk(roots: readonly PendingDirectory[], totals: SweepTotals): Promise<void> {\n const pending: PendingDirectory[] = [...roots];\n let inFlightDirectories = 0;\n\n return new Promise<void>((resolveWalk) => {\n const pump = (): void => {\n while (\n !totals.exceededCeiling\n && inFlightDirectories < DIRECTORY_WALK_CONCURRENCY\n && pending.length > 0\n ) {\n const next = pending.pop() as PendingDirectory;\n inFlightDirectories += 1;\n void this.visitDirectory(next, totals, pending).then(() => {\n inFlightDirectories -= 1;\n pump();\n });\n }\n\n if (inFlightDirectories === 0 && (pending.length === 0 || totals.exceededCeiling)) {\n resolveWalk();\n }\n };\n\n pump();\n });\n }\n\n /**\n * Read one directory: count it, fold its own mtime in, stat its files, and queue its children.\n *\n * Never rejects. A directory that cannot be read (an unbuilt `dist`, a permission) contributes\n * nothing and is not an error — when it appears later it is a new directory, which moves the\n * counts and invalidates every cached derivation.\n */\n private async visitDirectory(\n { directory, accumulator }: PendingDirectory,\n totals: SweepTotals,\n pending: PendingDirectory[],\n ): Promise<void> {\n let entries;\n try {\n entries = await fsPromises.readdir(directory, { withFileTypes: true });\n } catch {\n return;\n }\n\n accumulator.directoryCount += 1;\n totals.entryCount += 1;\n try {\n const directoryStats = await fsPromises.stat(directory);\n if (directoryStats.mtimeMs > accumulator.maximumMtimeMs) {\n accumulator.maximumMtimeMs = directoryStats.mtimeMs;\n }\n } catch {\n // Counted above regardless: the directory demonstrably exists, we just read it.\n }\n\n const fileStats: Promise<void>[] = [];\n for (const entry of entries) {\n if (SKIPPED_DIRECTORY_NAMES.has(entry.name)) continue;\n const entryPath = join(directory, entry.name);\n if (entry.isDirectory()) {\n pending.push({ directory: entryPath, accumulator });\n continue;\n }\n if (!entry.isFile()) {\n // A symlink is counted but never followed — following one inside a package tree can walk\n // back out into a dependency graph. Retargeting one rewrites its directory entry, which\n // moves the parent directory's mtime, so the change is still observed.\n accumulator.fileCount += 1;\n totals.entryCount += 1;\n continue;\n }\n totals.entryCount += 1;\n fileStats.push(\n fsPromises.stat(entryPath).then(\n (entryStats) => {\n accumulator.fileCount += 1;\n if (entryStats.mtimeMs > accumulator.maximumMtimeMs) {\n accumulator.maximumMtimeMs = entryStats.mtimeMs;\n }\n },\n () => {\n accumulator.fileCount += 1;\n },\n ),\n );\n }\n await Promise.all(fileStats);\n\n if (totals.entryCount > MAXIMUM_OBSERVED_ENTRIES) {\n totals.exceededCeiling = true;\n }\n }\n}\n\n/**\n * Every APPLICATION package an introspection derivation can import: each declared service, each\n * resolved library, and the specifications package.\n *\n * ONE enumeration, shared by this observer and by the creation-plane projection's input signature\n * (#1310, seventh review G1), because both answer the same question — \"which built trees can move an\n * introspection result?\" — and two lists of one population agree only until one gains an entry.\n */\nexport function resolveIntrospectedApplicationPackageRoots(\n companionContext: Pick<CompanionContext, 'saasRoot' | 'servicesByKey' | 'resolvedLibraries' | 'resolvedSpecifications'>,\n): readonly string[] {\n const applicationRoots = new Set<string>();\n for (const serviceDefinition of Object.values(companionContext.servicesByKey)) {\n applicationRoots.add(resolve(companionContext.saasRoot, serviceDefinition.path));\n }\n for (const resolvedLibrary of Object.values(companionContext.resolvedLibraries)) {\n applicationRoots.add(resolvedLibrary.packageRoot);\n }\n if (companionContext.resolvedSpecifications) {\n applicationRoots.add(companionContext.resolvedSpecifications.packageRoot);\n }\n return [...applicationRoots];\n}\n"]}
|
|
@@ -49,7 +49,13 @@ export declare function renderMarketBrief(market: MarketSnapshot): string;
|
|
|
49
49
|
export declare function renderBrandBrief(brand: BrandSnapshot): string;
|
|
50
50
|
/** Render REQUIREMENTS: what the product actually does (the floor for honest claims). */
|
|
51
51
|
export declare function renderRequirementsBrief(requirements: RequirementsSnapshot): string;
|
|
52
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Render BUSINESS_MODEL: the offer posture (premium demands different codes than accessible).
|
|
54
|
+
*
|
|
55
|
+
* Says WHERE the tiers came from (`resolvePricingTiersStatus`), because a reader grounded on the brief
|
|
56
|
+
* otherwise treats a proposal as the creator's decision and an undecided sketch as "no pricing" — the
|
|
57
|
+
* two readings the `pricingTiers` status exists to prevent. Model-facing prose, not display text.
|
|
58
|
+
*/
|
|
53
59
|
export declare function renderBusinessModelBrief(businessModel: BusinessModelLiteSnapshot): string;
|
|
54
60
|
/** Render ACCEPTED_DECISIONS: the shipped brand assets new work must cohere with. */
|
|
55
61
|
export declare function renderAcceptedDecisionsBrief(assets: BrandAssetConfig[]): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expert-persona-brief.renderer.d.ts","sourceRoot":"","sources":["../../../../../../src/core/introspection/subprocess/expert-persona-brief.renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,
|
|
1
|
+
{"version":3,"file":"expert-persona-brief.renderer.d.ts","sourceRoot":"","sources":["../../../../../../src/core/introspection/subprocess/expert-persona-brief.renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAGtB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAE9B,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,+BAA+B,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,kFAAkF;AAClF,MAAM,WAAW,yBAAyB;IACxC,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,CAAC;IACjD,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,CAAC;IACjD,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC;IAC/C,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC,EAAE,oBAAoB,CAAC;IAC7D,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC,EAAE,yBAAyB,CAAC;IACpE,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAClE;AAYD,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAoBhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAmDhE;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAa7D;AAED,yFAAyF;AACzF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,oBAAoB,GAAG,MAAM,CAWlF;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,yBAAyB,GAAG,MAAM,CAYzF;AAED,qFAAqF;AACrF,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAO/E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC,CAejD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExpertShapingInputKind, } from '@wildo-ai/saas-specifications';
|
|
1
|
+
import { ExpertShapingInputKind, PricingTiersStatus, resolvePricingTiersStatus, } from '@wildo-ai/saas-specifications';
|
|
2
2
|
const NONE = '_(none)_';
|
|
3
3
|
function lines(...parts) {
|
|
4
4
|
return parts.filter((part) => typeof part === 'string' && part.length > 0).join('\n');
|
|
@@ -62,10 +62,19 @@ export function renderRequirementsBrief(requirements) {
|
|
|
62
62
|
const nonFunctional = requirements.nonFunctional.map((requirement) => `[${requirement.kind}] ${requirement.statement}${requirement.metric ? ` (${requirement.metric})` : ''}`);
|
|
63
63
|
return lines('### Requirements (what the product actually does)', '**Functional:**', bullets(functional), '**Non-functional:**', bullets(nonFunctional));
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Render BUSINESS_MODEL: the offer posture (premium demands different codes than accessible).
|
|
67
|
+
*
|
|
68
|
+
* Says WHERE the tiers came from (`resolvePricingTiersStatus`), because a reader grounded on the brief
|
|
69
|
+
* otherwise treats a proposal as the creator's decision and an undecided sketch as "no pricing" — the
|
|
70
|
+
* two readings the `pricingTiers` status exists to prevent. Model-facing prose, not display text.
|
|
71
|
+
*/
|
|
66
72
|
export function renderBusinessModelBrief(businessModel) {
|
|
67
|
-
const plans = businessModel.plans.map((plan) => `- **${plan.name}**${plan.pricePoint ? ` — ${plan.pricePoint}${plan.billingPeriod ? `/${plan.billingPeriod}` : ''}` : ''}${plan.targetSummary ? ` · for: ${plan.targetSummary}` : ''}${plan.includes ? ` · includes: ${plan.includes}` : ''}`);
|
|
68
|
-
|
|
73
|
+
const plans = businessModel.plans.map((plan) => `- **${plan.name}**${plan.pricePoint ? ` — ${plan.pricePoint}${plan.billingPeriod ? `/${plan.billingPeriod}` : ''}` : ''}${plan.targetSummary ? ` · for: ${plan.targetSummary}` : ''}${plan.includes ? ` · includes: ${plan.includes}` : ''}${plan.proposalBasis ? ` · proposed because: ${plan.proposalBasis}` : ''}`);
|
|
74
|
+
const tiers = resolvePricingTiersStatus(businessModel);
|
|
75
|
+
return lines('### Business model', businessModel.revenueModel ? `**Revenue model:** ${businessModel.revenueModel}` : undefined, tiers === PricingTiersStatus.PROPOSED ? "**Plans (proposed at the creator's request, not named by the creator):**" : '**Plans:**', tiers === PricingTiersStatus.UNDECIDED
|
|
76
|
+
? '_Not decided yet — the creator has not chosen the tiers. Assume none; the revenue model above still applies._'
|
|
77
|
+
: plans.length > 0 ? plans.join('\n') : NONE);
|
|
69
78
|
}
|
|
70
79
|
/** Render ACCEPTED_DECISIONS: the shipped brand assets new work must cohere with. */
|
|
71
80
|
export function renderAcceptedDecisionsBrief(assets) {
|