@wildo-ai/dev-companion 1.1.12 → 1.1.14
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/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +21 -0
- 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 +37 -4
- 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.map +1 -1
- package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js +9 -2
- 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 +66 -0
- 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 +191 -13
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
- package/dist/esm/claude-cli/services/git-change-set.companion.service.d.ts +6 -2
- package/dist/esm/claude-cli/services/git-change-set.companion.service.d.ts.map +1 -1
- package/dist/esm/claude-cli/services/git-change-set.companion.service.js +16 -39
- package/dist/esm/claude-cli/services/git-change-set.companion.service.js.map +1 -1
- package/dist/esm/code-compliance-check/check-raw-feature-id-literals.companion.js +31 -2
- package/dist/esm/code-compliance-check/check-raw-feature-id-literals.companion.js.map +1 -1
- package/dist/esm/companion-api/companion-api.schemas.d.ts +2 -0
- package/dist/esm/companion-api/companion-api.schemas.d.ts.map +1 -1
- package/dist/esm/companion-api/companion-api.schemas.js +8 -0
- package/dist/esm/companion-api/companion-api.schemas.js.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.d.ts +13 -0
- package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.js +39 -13
- package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
- package/dist/esm/companion-api/controllers/long-held-request.companion.d.ts +17 -0
- package/dist/esm/companion-api/controllers/long-held-request.companion.d.ts.map +1 -0
- package/dist/esm/companion-api/controllers/long-held-request.companion.js +33 -0
- package/dist/esm/companion-api/controllers/long-held-request.companion.js.map +1 -0
- package/dist/esm/core/introspection/resources/creation-home-projection.companion.d.ts +9 -0
- 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 +19 -0
- package/dist/esm/core/introspection/resources/creation-home-projection.companion.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 +7 -1
- 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 +5 -1
- package/dist/esm/core/introspection/resources/launch-blockers.companion.d.ts.map +1 -1
- package/dist/esm/core/introspection/resources/launch-blockers.companion.js +37 -4
- package/dist/esm/core/introspection/resources/launch-blockers.companion.js.map +1 -1
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts +14 -0
- 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 +48 -0
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/services/introspection-dependency-tree.companion.d.ts +128 -0
- package/dist/esm/core/introspection/services/introspection-dependency-tree.companion.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-dependency-tree.companion.js +180 -0
- package/dist/esm/core/introspection/services/introspection-dependency-tree.companion.js.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts +8 -20
- 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 +37 -142
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/services/introspection-source-walk.worker.d.ts +64 -0
- package/dist/esm/core/introspection/services/introspection-source-walk.worker.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-walk.worker.js +304 -0
- package/dist/esm/core/introspection/services/introspection-source-walk.worker.js.map +1 -0
- package/dist/esm/core/introspection/services/introspection-worker-pool.companion.d.ts +9 -0
- package/dist/esm/core/introspection/services/introspection-worker-pool.companion.d.ts.map +1 -1
- package/dist/esm/core/introspection/services/introspection-worker-pool.companion.js +25 -3
- package/dist/esm/core/introspection/services/introspection-worker-pool.companion.js.map +1 -1
- package/dist/esm/core/runtime/companion-language-model-route.d.ts +16 -1
- package/dist/esm/core/runtime/companion-language-model-route.d.ts.map +1 -1
- package/dist/esm/core/runtime/companion-language-model-route.js +23 -1
- package/dist/esm/core/runtime/companion-language-model-route.js.map +1 -1
- package/dist/esm/core/runtime/restart-drain.companion.d.ts +107 -0
- package/dist/esm/core/runtime/restart-drain.companion.d.ts.map +1 -0
- package/dist/esm/core/runtime/restart-drain.companion.js +237 -0
- package/dist/esm/core/runtime/restart-drain.companion.js.map +1 -0
- 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 +3 -2
- package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
- package/dist/esm/core/utils/git-read-broker.companion.d.ts +62 -0
- package/dist/esm/core/utils/git-read-broker.companion.d.ts.map +1 -0
- package/dist/esm/core/utils/git-read-broker.companion.js +282 -0
- package/dist/esm/core/utils/git-read-broker.companion.js.map +1 -0
- package/dist/esm/core/utils/local-write-recording.companion.d.ts +8 -1
- package/dist/esm/core/utils/local-write-recording.companion.d.ts.map +1 -1
- package/dist/esm/core/utils/local-write-recording.companion.js +7 -23
- package/dist/esm/core/utils/local-write-recording.companion.js.map +1 -1
- package/dist/esm/executions/services/companion-executions.companion.service.d.ts +18 -1
- package/dist/esm/executions/services/companion-executions.companion.service.d.ts.map +1 -1
- package/dist/esm/executions/services/companion-executions.companion.service.js +34 -8
- package/dist/esm/executions/services/companion-executions.companion.service.js.map +1 -1
- package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.d.ts +29 -0
- package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.d.ts.map +1 -0
- package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.js +29 -0
- package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.en.js.map +1 -0
- package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.d.ts +29 -0
- package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.d.ts.map +1 -0
- package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.js +29 -0
- package/dist/esm/i18n/components/HIGH_LEVEL_VIEWS_CHART_DASHBOARD_LAYOUT_EDITOR.fr.js.map +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.d.ts +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.js +2 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.en.js.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.d.ts +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.js +2 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_APPROVAL.fr.js.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.d.ts +5 -2
- package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.js +5 -2
- package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.en.js.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.d.ts +5 -2
- package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.js +5 -2
- package/dist/esm/i18n/components/LOW_LEVEL_AI_CONVERSATION_THREAD.fr.js.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.d.ts +41 -0
- package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.d.ts.map +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.js +41 -0
- package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.en.js.map +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.d.ts +41 -0
- package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.d.ts.map +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.js +41 -0
- package/dist/esm/i18n/components/LOW_LEVEL_APPROVAL_SEAL.fr.js.map +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.d.ts +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.js +2 -1
- package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.en.js.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.d.ts +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.js +2 -1
- package/dist/esm/i18n/components/LOW_LEVEL_CONTENT_SECTION_CONTAINER.fr.js.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.d.ts +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.js +2 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.en.js.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.d.ts +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.js +2 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD_STRING.fr.js.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.d.ts +1 -0
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.js +2 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.en.js.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.d.ts +1 -0
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.js +2 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_MFA_CHALLENGE.fr.js.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.d.ts +2 -0
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.js +3 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.en.js.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.d.ts +2 -0
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.js +3 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_TERMS.fr.js.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.d.ts +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.js +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.en.js.map +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.d.ts +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.js +1 -1
- package/dist/esm/i18n/components/PUBLIC_LAYOUTS_USER_AUTH.fr.js.map +1 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.d.ts +2 -0
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.js +3 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.en.js.map +1 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.d.ts +3 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.js +4 -2
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_FILTERS.fr.js.map +1 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.d.ts +17 -0
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.js +18 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.en.js.map +1 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.d.ts +17 -0
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.js +18 -1
- package/dist/esm/i18n/components/RESOURCES_LAYOUTS_LIST.fr.js.map +1 -1
- package/dist/esm/i18n/composite_views/app.creation-conversation.fr.d.ts +206 -195
- package/dist/esm/i18n/composite_views/app.creation-conversation.fr.d.ts.map +1 -1
- package/dist/esm/i18n/composite_views/app.creation-conversation.fr.js +206 -195
- package/dist/esm/i18n/composite_views/app.creation-conversation.fr.js.map +1 -1
- package/dist/esm/i18n/composite_views/app.creation-dossier.fr.d.ts +10 -0
- package/dist/esm/i18n/composite_views/app.creation-dossier.fr.d.ts.map +1 -1
- package/dist/esm/i18n/composite_views/app.creation-dossier.fr.js +12 -2
- package/dist/esm/i18n/composite_views/app.creation-dossier.fr.js.map +1 -1
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.d.ts +70 -0
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.d.ts.map +1 -1
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.js +70 -0
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.fr.js.map +1 -1
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.d.ts +12 -2
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.d.ts.map +1 -1
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.js +12 -2
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.fr.js.map +1 -1
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.d.ts +10 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.d.ts.map +1 -1
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.js +10 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.fr.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.d.ts +25 -20
- package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.js +25 -20
- package/dist/esm/i18n/resources/workbenchBuildDispatchPlan.fr.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.d.ts +32 -32
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.js +32 -32
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.fr.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.d.ts +65 -65
- package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.js +65 -65
- package/dist/esm/i18n/resources/workbenchBuildTaskRecords.fr.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchDossierEntries.fr.d.ts +20 -0
- package/dist/esm/i18n/resources/workbenchDossierEntries.fr.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchDossierEntries.fr.js +20 -0
- package/dist/esm/i18n/resources/workbenchDossierEntries.fr.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.d.ts +12 -0
- package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.js +13 -1
- package/dist/esm/i18n/resources/workbenchGovernanceQuestions.fr.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +40 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +13 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts +40 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js +40 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/application-creation.en.d.ts +5 -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 +6 -0
- package/dist/esm/i18n/system_enums/application-creation.en.js.map +1 -1
- package/dist/esm/i18n/system_enums/application-creation.fr.d.ts +175 -170
- package/dist/esm/i18n/system_enums/application-creation.fr.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/application-creation.fr.js +175 -170
- package/dist/esm/i18n/system_enums/application-creation.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/flows-actors.fr.d.ts +22 -22
- package/dist/esm/i18n/system_enums/flows-actors.fr.js +22 -22
- package/dist/esm/i18n/system_enums/flows-actors.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/run-records.fr.d.ts +21 -21
- package/dist/esm/i18n/system_enums/run-records.fr.js +21 -21
- package/dist/esm/i18n/system_enums/run-records.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-build.en.d.ts +3 -0
- package/dist/esm/i18n/system_enums/workbench-build.en.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-build.en.js +3 -0
- package/dist/esm/i18n/system_enums/workbench-build.en.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-build.fr.d.ts +37 -33
- package/dist/esm/i18n/system_enums/workbench-build.fr.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-build.fr.js +37 -33
- package/dist/esm/i18n/system_enums/workbench-build.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-creation-home.en.d.ts +1 -0
- package/dist/esm/i18n/system_enums/workbench-creation-home.en.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-creation-home.en.js +1 -0
- package/dist/esm/i18n/system_enums/workbench-creation-home.en.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-creation-home.fr.d.ts +18 -17
- package/dist/esm/i18n/system_enums/workbench-creation-home.fr.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-creation-home.fr.js +18 -17
- package/dist/esm/i18n/system_enums/workbench-creation-home.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-dossier.fr.d.ts +7 -5
- package/dist/esm/i18n/system_enums/workbench-dossier.fr.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-dossier.fr.js +8 -6
- package/dist/esm/i18n/system_enums/workbench-dossier.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-secrets.fr.d.ts +12 -12
- package/dist/esm/i18n/system_enums/workbench-secrets.fr.js +12 -12
- package/dist/esm/i18n/system_enums/workbench-secrets.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.d.ts +1 -0
- package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.d.ts.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.js +2 -1
- package/dist/esm/i18n/system_enums/workbench-specification-artifact.fr.js.map +1 -1
- package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.d.ts.map +1 -1
- package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.js +3 -4
- package/dist/esm/i18n-labelling/services/labelling-planner.companion.service.js.map +1 -1
- package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.d.ts +11 -0
- package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.d.ts.map +1 -1
- package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.js +21 -0
- package/dist/esm/i18n-labelling/utils/declared-refusal-codes.utils.js.map +1 -1
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts +5 -1
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js +5 -1
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js.map +1 -1
- package/dist/esm/meta-workflows/models/playbook-run-record.models.d.ts +12 -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 +9 -0
- package/dist/esm/meta-workflows/models/playbook-run-record.models.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +200 -20
- 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 +1107 -230
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts +158 -16
- package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js +381 -46
- package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts +58 -0
- 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 +116 -2
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.d.ts +3 -3
- package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.js +3 -3
- package/dist/esm/meta-workflows/services/application-build-landing-projection.companion.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-task-closure.companion.d.ts +9 -0
- package/dist/esm/meta-workflows/services/application-build-task-closure.companion.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-task-closure.companion.js +19 -0
- package/dist/esm/meta-workflows/services/application-build-task-closure.companion.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts +12 -0
- 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 +31 -7
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.js +4 -5
- package/dist/esm/meta-workflows/services/creation-intervention-ledger.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts +2 -2
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js +10 -8
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js.map +1 -1
- 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 +6 -3
- package/dist/esm/meta-workflows/services/foundation-executor.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.js +3 -5
- package/dist/esm/meta-workflows/services/playbook-run-write-register-window.companion.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +68 -3
- 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 +281 -69
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
- package/package.json +18 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspection-source-walk.worker.js","sourceRoot":"","sources":["../../../../../src/core/introspection/services/introspection-source-walk.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;GAOG;AACH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,8BAA8B,GAAG,iBAAiB,CAAC;AACzD,MAAM,8BAA8B,GAAG,wBAAwB,CAAC;AA4ChE,oDAAoD;AACpD,MAAM,WAAW;IACP,SAAS,CAAS;IACT,OAAO,GAAsB,EAAE,CAAC;IAEjD,YAAY,OAAe;QACzB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,GAAG,CAAI,SAA2B;QAC7C,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,4FAA4F;YAC5F,sEAAsE;YACtE,MAAM,IAAI,OAAO,CAAO,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC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BAA4B;IACnC,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAChC,MAAM,IAAI,gCAAgC,CAAC,gCAAgC,GAAG,iBAAiB,CAAC,CAAC;AACnG,CAAC","sourcesContent":["import { existsSync, promises as fsPromises } from 'node:fs';\nimport { basename, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isMainThread, parentPort, Worker, workerData } from 'node:worker_threads';\nimport { describeCaughtError } from '@wildo-ai/saas-models/public-runtime';\n\n/**\n * The source-state sweep's directory walk, run on a WORKER THREAD (companion event-loop stalls, #3204).\n *\n * `IntrospectionSourceStateObserver` decides WHICH roots to walk (the change feed, the held walks) and turns the result\n * into a token; this module only walks. It used to walk on the companion's main thread, and during a build that was the\n * largest single cost there: every observation re-walks the application's package roots (about 14,000 entries on the\n * reference application), because the build moves them constantly, and the per-file `stat` calls, their promises and\n * their `Stats` objects are main-thread work even though the reads themselves run on libuv's pool. A 90 s CPU profile of\n * the reference run's companion (2026-11-14) put 11.6 s of the main thread inside the sweep's `stat` calls and 15 s in\n * the sweep overall, while every workbench request waited behind it. On a worker the same walk costs the main thread one\n * message each way.\n *\n * The walk is the same code either way: {@link walkSourceRoots} is what the worker runs and what the companion runs in\n * process when no worker can be had (a test harness, a failed start, a worker that died), so the two cannot disagree\n * about what a token means.\n *\n * This module imports NOTHING but Node built-ins, deliberately: from source (the companion under test, or run from its\n * `.ts`) the worker is started on this file directly and Node strips its types, which resolves no extensionless\n * relative import and no package. Its concurrency bounds therefore arrive with each request rather than by import, and\n * nothing here may use non-erasable TypeScript (an `enum`, a parameter property).\n */\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 the observer resolves: 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 * The compiler's private output, never descended into when it sits in a package's `.wildo-runtime-signals` (#3452).\n *\n * A compile writes here first and publishes into `dist` once the emit is final, and nothing a derivation imports resolves\n * here: every package's `exports` name `dist`, and no link in any dogfood application points into staging (measured\n * 2026-11-08 over `examples/`). So a staging write cannot change a derivation, and the publication that can moves `dist`\n * and the accepted-generation manifest beside it, which are still walked. It was about 40 % of what a sweep stat'ed\n * (5,440 of Wonder Todos' 13,484 `backend-api` files). The change source ignores the same subtree.\n */\nconst COMPILE_STAGING_DIRECTORY_NAME = 'compile-staging';\nconst RUNTIME_SIGNALS_DIRECTORY_NAME = '.wildo-runtime-signals';\n\n/** What one root's walk learned: the components of its token. */\nexport interface SourceWalkAccumulator {\n fileCount: number;\n directoryCount: number;\n maximumMtimeMs: number;\n}\n\n/** One walk: the roots, and the bounds the observer owns. */\nexport interface SourceWalkRequest {\n readonly roots: readonly string[];\n /** Entries the observation already counted (manifests, held roots), so the ceiling bounds the whole sweep. */\n readonly entryCountBefore: number;\n /** Past this the walk stops and reports `exceededCeiling`; see the observer's `MAXIMUM_OBSERVED_ENTRIES`. */\n readonly maximumEntries: number;\n /** `DIRECTORY_WALK_CONCURRENCY`, passed rather than imported (see the module comment). */\n readonly directoryConcurrency: number;\n /** `FILE_STAT_CONCURRENCY`, passed rather than imported (see the module comment). */\n readonly fileStatConcurrency: number;\n}\n\n/** {@link walkSourceRoots}'s answer: one accumulator per requested root, in request order. */\nexport interface SourceWalkResult {\n readonly accumulators: readonly SourceWalkAccumulator[];\n readonly entryCount: number;\n readonly exceededCeiling: boolean;\n}\n\n/** A directory still to visit, and the component its entries count towards. */\ninterface PendingDirectory {\n readonly directory: string;\n readonly accumulator: SourceWalkAccumulator;\n}\n\n/** The whole walk's running total, so the ceiling bounds the walk rather than any one root. */\ninterface WalkTotals {\n entryCount: number;\n exceededCeiling: boolean;\n readonly maximumEntries: number;\n /** Shared by every directory of the walk, so the bound is on the walk and not per directory. */\n readonly statPermits: StatPermits;\n}\n\n/** A counting semaphore for the file-stat bound. */\nclass StatPermits {\n private available: number;\n private readonly waiting: Array<() => void> = [];\n\n constructor(permits: number) {\n this.available = permits;\n }\n\n public async run<T>(operation: () => Promise<T>): Promise<T> {\n if (this.available > 0) {\n this.available -= 1;\n } else {\n // A released permit is handed straight to the next waiter, so `available` never rises while\n // anyone is waiting and no waiter can be overtaken by a later caller.\n await new Promise<void>((resolveWait) => this.waiting.push(resolveWait));\n }\n try {\n return await operation();\n } finally {\n const next = this.waiting.shift();\n if (next) next();\n else this.available += 1;\n }\n }\n}\n\n/**\n * Walk the roots and return one accumulator per root. Never rejects for a root that cannot be read: it contributes\n * nothing, and when it appears later it is a new directory, which moves the counts.\n */\nexport async function walkSourceRoots(request: SourceWalkRequest): Promise<SourceWalkResult> {\n const accumulators = request.roots.map((): SourceWalkAccumulator => ({ fileCount: 0, directoryCount: 0, maximumMtimeMs: 0 }));\n const totals: WalkTotals = {\n entryCount: request.entryCountBefore,\n exceededCeiling: false,\n maximumEntries: request.maximumEntries,\n statPermits: new StatPermits(request.fileStatConcurrency),\n };\n await walk(request.roots.map((directory, index) => ({ directory, accumulator: accumulators[index]! })), totals, request.directoryConcurrency);\n return { accumulators, entryCount: totals.entryCount, exceededCeiling: totals.exceededCeiling };\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 */\nasync function walk(roots: readonly PendingDirectory[], totals: WalkTotals, directoryConcurrency: number): Promise<void> {\n const pending: PendingDirectory[] = [...roots];\n let inFlightDirectories = 0;\n\n return new Promise<void>((resolveWalk) => {\n const pump = (): void => {\n while (!totals.exceededCeiling && inFlightDirectories < directoryConcurrency && pending.length > 0) {\n const next = pending.pop() as PendingDirectory;\n inFlightDirectories += 1;\n void 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 */\nasync function visitDirectory({ directory, accumulator }: PendingDirectory, totals: WalkTotals, pending: PendingDirectory[]): 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 const insideRuntimeSignals = basename(directory) === RUNTIME_SIGNALS_DIRECTORY_NAME;\n for (const entry of entries) {\n if (SKIPPED_DIRECTORY_NAMES.has(entry.name)) continue;\n if (insideRuntimeSignals && entry.name === COMPILE_STAGING_DIRECTORY_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 totals.statPermits.run(() => 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 > totals.maximumEntries) {\n totals.exceededCeiling = true;\n }\n}\n\n/** Marks a thread started by {@link SourceWalkWorker}, so importing this module elsewhere starts nothing. */\nconst SOURCE_WALK_WORKER_KIND = 'wildo.introspection-source-walk';\n\ninterface SourceWalkWorkerMessage {\n readonly id: number;\n readonly result?: SourceWalkResult;\n readonly error?: string;\n}\n\n// The worker side: answer each request with the same function the companion would run in process.\nif (!isMainThread && parentPort !== null && (workerData as { kind?: unknown } | undefined)?.kind === SOURCE_WALK_WORKER_KIND) {\n const port = parentPort;\n port.on('message', (message: { readonly id: number; readonly request: SourceWalkRequest }) => {\n walkSourceRoots(message.request).then(\n (result) => port.postMessage({ id: message.id, result } satisfies SourceWalkWorkerMessage),\n (error: unknown) => port.postMessage({ id: message.id, error: describeCaughtError(error) } satisfies SourceWalkWorkerMessage),\n );\n });\n}\n\n/**\n * The companion's side: one long-lived worker thread, started on first use and shared by every observer (two sweep the\n * same roots). Unreferenced, so it never keeps the process alive.\n *\n * Fails toward the in-process walk, never toward a wrong token: a worker that cannot start, errors or exits fails its\n * pending walks with a {@link SourceWalkWorkerUnavailableError}, the caller walks in process, and the next walk starts\n * a fresh worker. After {@link MAXIMUM_WORKER_FAILURES} consecutive failures it stops trying for the life of the process,\n * so a worker that can never start costs one failed start per walk at most a few times, not on every observation.\n */\nexport class SourceWalkWorker {\n private worker: Worker | undefined;\n private nextId = 1;\n private consecutiveFailures = 0;\n private readonly pending = new Map<number, { resolve: (result: SourceWalkResult) => void; reject: (error: Error) => void }>();\n // A plain field, not a parameter property: this file runs under type stripping, which refuses non-erasable syntax.\n private readonly options: { readonly entryPath?: string };\n\n public constructor(options: { readonly entryPath?: string } = {}) {\n this.options = options;\n }\n\n /** The walk, on the worker; rejects with {@link SourceWalkWorkerUnavailableError} when no worker can do it. */\n public walk(request: SourceWalkRequest): Promise<SourceWalkResult> {\n const worker = this.ensureWorker();\n if (worker === undefined) return Promise.reject(new SourceWalkWorkerUnavailableError('no source-walk worker is available'));\n const id = this.nextId;\n this.nextId += 1;\n return new Promise<SourceWalkResult>((resolve, reject) => {\n this.pending.set(id, { resolve, reject });\n // Referenced only while a walk is pending, so a running walk is never cut short by the process idling out.\n if (this.pending.size === 1) worker.ref();\n worker.postMessage({ id, request });\n });\n }\n\n /** Whether the worker has been given up on for this process. For tests and logs. */\n public get disabled(): boolean {\n return this.consecutiveFailures >= MAXIMUM_WORKER_FAILURES;\n }\n\n /** Stop the worker (tests). A walk it was doing fails as unavailable, so its caller walks in process. */\n public async close(): Promise<void> {\n const worker = this.worker;\n if (worker === undefined) return;\n this.failPending(worker, 'the source-walk worker was closed');\n await worker.terminate();\n }\n\n private ensureWorker(): Worker | undefined {\n if (this.worker !== undefined) return this.worker;\n if (this.disabled) return undefined;\n let worker: Worker;\n try {\n worker = new Worker(this.options.entryPath ?? resolveSourceWalkWorkerEntry(), { workerData: { kind: SOURCE_WALK_WORKER_KIND } });\n } catch {\n this.consecutiveFailures += 1;\n return undefined;\n }\n worker.unref();\n worker.on('message', (message: SourceWalkWorkerMessage) => {\n const waiter = this.pending.get(message.id);\n if (waiter === undefined) return;\n this.pending.delete(message.id);\n if (this.pending.size === 0) worker.unref();\n if (message.result !== undefined) {\n this.consecutiveFailures = 0;\n waiter.resolve(message.result);\n } else {\n waiter.reject(new SourceWalkWorkerUnavailableError(message.error ?? 'the source-walk worker answered nothing'));\n }\n });\n const fail = (reason: string): void => {\n if (this.worker !== worker) return;\n this.consecutiveFailures += 1;\n this.failPending(worker, reason);\n // A failure that is not an exit (an error, an unreadable answer) leaves the thread running: stop the one it forgot.\n void worker.terminate().catch(() => undefined);\n };\n worker.on('error', (error: Error) => fail(`the source-walk worker failed: ${error.message}`));\n worker.on('exit', (code: number) => fail(`the source-walk worker exited (code ${code})`));\n // An answer that cannot be deserialized would otherwise leave its walk pending for good.\n worker.on('messageerror', (error: Error) => fail(`the source-walk worker's answer could not be read: ${error.message}`));\n this.worker = worker;\n return worker;\n }\n\n /** Forget the worker and fail every walk it was doing as unavailable, so each is walked in process. */\n private failPending(worker: Worker, reason: string): void {\n if (this.worker !== worker) return;\n this.worker = undefined;\n const waiters = [...this.pending.values()];\n this.pending.clear();\n for (const waiter of waiters) waiter.reject(new SourceWalkWorkerUnavailableError(reason));\n }\n}\n\n/** A walk the worker could not do; the caller walks in process instead. */\nexport class SourceWalkWorkerUnavailableError extends Error {\n public override readonly name = 'SourceWalkWorkerUnavailableError';\n}\n\n/** Consecutive worker failures after which the companion walks in process for the rest of its life. */\nexport const MAXIMUM_WORKER_FAILURES = 3;\n\n/** This module's own file: the compiled `.js` in a build, the `.ts` when the companion runs from source. */\nfunction resolveSourceWalkWorkerEntry(): string {\n const own = fileURLToPath(import.meta.url);\n if (existsSync(own)) return own;\n throw new SourceWalkWorkerUnavailableError(`the source-walk worker entry ${own} does not exist`);\n}\n"]}
|
|
@@ -88,6 +88,15 @@ export declare class IntrospectionWorkerPool {
|
|
|
88
88
|
* relies on each worker exiting by itself when the companion exits, because its IPC channel closes.
|
|
89
89
|
*/
|
|
90
90
|
shutdown(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Retire every worker started before `instantMs` (#3703): an idle one now, a busy one as soon as its request settles.
|
|
93
|
+
*
|
|
94
|
+
* For a dependency tree that moved under the pool. A worker started before a `pnpm install` re-created the
|
|
95
|
+
* application's `node_modules` holds modules read from the old tree, and Node keeps a failed import failed for the
|
|
96
|
+
* life of the process, so a derivation that failed there would fail there again. The caller asks this once the tree
|
|
97
|
+
* has settled, so its retry, and every later request, runs in a process started after it.
|
|
98
|
+
*/
|
|
99
|
+
retireWorkersStartedBefore(instantMs: number, reason: string): void;
|
|
91
100
|
private acquire;
|
|
92
101
|
private spawn;
|
|
93
102
|
private onMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"introspection-worker-pool.companion.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/services/introspection-worker-pool.companion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,OAAO,EAIL,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACvC,KAAK,4BAA4B,EAElC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAGrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,8BAA8B;IAC7C,+FAA+F;IAC/F,QAAQ,CAAC,WAAW,EAAE,MAAM,YAAY,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qGAAqG;IACrG,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAC5E;
|
|
1
|
+
{"version":3,"file":"introspection-worker-pool.companion.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/services/introspection-worker-pool.companion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,OAAO,EAIL,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACvC,KAAK,4BAA4B,EAElC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAGrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,8BAA8B;IAC7C,+FAA+F;IAC/F,QAA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H3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,YAAY,CAAK;gBAEW,OAAO,EAAE,8BAA8B;IAE3E,+DAA+D;IAC/D,IAAW,eAAe,IAAI,MAAM,CAEnC;IAED;;;;;OAKG;IACU,GAAG,CACd,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,kCAAkC,EAC3C,KAAK,CAAC,EAAE,wBAAwB,GAC/B,OAAO,CAAC,0BAA0B,CAAC;IA2DtC;;;OAGG;IACI,QAAQ,IAAI,IAAI;IAIvB;;;;;;;OAOG;IACI,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;YAQ5D,OAAO;IA4CrB,OAAO,CAAC,KAAK;IAgCb,OAAO,CAAC,SAAS;IAsDjB,OAAO,CAAC,OAAO;IAoBf,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,MAAM;CAiCf"}
|
|
@@ -95,6 +95,24 @@ export class IntrospectionWorkerPool {
|
|
|
95
95
|
for (const worker of [...this.workers])
|
|
96
96
|
this.retire(worker, 'pool shut down');
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Retire every worker started before `instantMs` (#3703): an idle one now, a busy one as soon as its request settles.
|
|
100
|
+
*
|
|
101
|
+
* For a dependency tree that moved under the pool. A worker started before a `pnpm install` re-created the
|
|
102
|
+
* application's `node_modules` holds modules read from the old tree, and Node keeps a failed import failed for the
|
|
103
|
+
* life of the process, so a derivation that failed there would fail there again. The caller asks this once the tree
|
|
104
|
+
* has settled, so its retry, and every later request, runs in a process started after it.
|
|
105
|
+
*/
|
|
106
|
+
retireWorkersStartedBefore(instantMs, reason) {
|
|
107
|
+
for (const worker of [...this.workers]) {
|
|
108
|
+
if (worker.startedAtMs >= instantMs)
|
|
109
|
+
continue;
|
|
110
|
+
if (worker.busy)
|
|
111
|
+
worker.retireAfterRequest = true;
|
|
112
|
+
else
|
|
113
|
+
this.retire(worker, reason);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
98
116
|
async acquire(sourceStateToken, reuse) {
|
|
99
117
|
const claim = (worker) => {
|
|
100
118
|
if (worker.idleTimer)
|
|
@@ -103,7 +121,7 @@ export class IntrospectionWorkerPool {
|
|
|
103
121
|
worker.busy = true;
|
|
104
122
|
return worker;
|
|
105
123
|
};
|
|
106
|
-
const idle = this.workers.find((worker) => !worker.busy && !worker.retiring && worker.sourceStateToken === sourceStateToken);
|
|
124
|
+
const idle = this.workers.find((worker) => !worker.busy && !worker.retiring && !worker.retireAfterRequest && worker.sourceStateToken === sourceStateToken);
|
|
107
125
|
if (idle)
|
|
108
126
|
return claim(idle);
|
|
109
127
|
/*
|
|
@@ -114,7 +132,7 @@ export class IntrospectionWorkerPool {
|
|
|
114
132
|
* requests never take one worker.
|
|
115
133
|
*/
|
|
116
134
|
if (reuse?.sharedToken !== undefined) {
|
|
117
|
-
for (const worker of this.workers.filter((candidate) => !candidate.busy && !candidate.retiring && candidate.sharedToken === reuse.sharedToken && !candidate.loadedUnknown)) {
|
|
135
|
+
for (const worker of this.workers.filter((candidate) => !candidate.busy && !candidate.retiring && candidate.sharedToken === reuse.sharedToken && !candidate.loadedUnknown && !candidate.retireAfterRequest)) {
|
|
118
136
|
/*
|
|
119
137
|
* Asked again, because the list is a snapshot and this loop awaits between candidates: another request may have
|
|
120
138
|
* claimed (or retired) a worker the snapshot still names. Claiming it anyway put two requests on one worker, and the
|
|
@@ -153,6 +171,7 @@ export class IntrospectionWorkerPool {
|
|
|
153
171
|
spawned.catch(() => undefined);
|
|
154
172
|
const worker = {
|
|
155
173
|
id, child, sourceStateToken, sharedToken, loaded: new Map(), loadedUnknown: false, spawned, pending: null, busy: true, idleTimer: null, served: 0, retiring: false,
|
|
174
|
+
startedAtMs: Date.now(), retireAfterRequest: false,
|
|
156
175
|
};
|
|
157
176
|
this.workers.push(worker);
|
|
158
177
|
const capture = (stream) => (chunk) => {
|
|
@@ -224,7 +243,10 @@ export class IntrospectionWorkerPool {
|
|
|
224
243
|
stderr: pending.stderr,
|
|
225
244
|
...(readSet === undefined ? {} : { readSet }),
|
|
226
245
|
});
|
|
227
|
-
if (
|
|
246
|
+
if (worker.retireAfterRequest) {
|
|
247
|
+
this.retire(worker, 'started before the dependency tree moved');
|
|
248
|
+
}
|
|
249
|
+
else if (!worker.retiring) {
|
|
228
250
|
worker.idleTimer = setTimeout(() => this.retire(worker, 'idle'), this.options.idleMs);
|
|
229
251
|
worker.idleTimer.unref?.();
|
|
230
252
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"introspection-worker-pool.companion.js","sourceRoot":"","sources":["../../../../../src/core/introspection/services/introspection-worker-pool.companion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAClG,OAAO,EACL,2CAA2C,EAC3C,0CAA0C,EAC1C,8BAA8B,GAK/B,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AA8C1F,oGAAoG;AACpG,MAAM,kCAAkC,GAAG,EAAE,GAAG,IAAI,CAAC;AAErD,0FAA0F;AAC1F,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAElC,uEAAuE;AACvE,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAAS,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AA6DtF,MAAM,OAAO,uBAAuB;IAIE;IAHnB,OAAO,GAAmB,EAAE,CAAC;IACtC,YAAY,GAAG,CAAC,CAAC;IAEzB,YAAoC,OAAuC;QAAvC,YAAO,GAAP,OAAO,CAAgC;IAAG,CAAC;IAE/E,+DAA+D;IAC/D,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,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C,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;QACD,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC;gBACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC,EAAE,mBAAmB,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;CACF;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC;AAC/D,CAAC;AAED,SAAS,cAAc,CAAC,OAAuB;IAC7C,MAAM,KAAK,GAAG;QACZ,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport { randomUUID } from 'node:crypto';\n\nimport { CompanionIntrospectionResultSchema } from '../../../companion-api/companion-api.schemas';\nimport {\n COMPANION_INTROSPECTION_WORKER_REQUEST_KIND,\n INTROSPECTION_PARENT_TERMINATED_ERROR_NAME,\n recordIntrospectionPayloadText,\n type CompanionIntrospectionChildRequest,\n type CompanionIntrospectionErrorDetails,\n type CompanionIntrospectionResult,\n type CompanionIntrospectionWorkerRequest,\n} from '../models/companion-introspection.models';\nimport type { IntrospectionReadEntry } from '../subprocess/derivation-read-tracking';\nimport { parseIntrospectionReadSet } from './introspection-derivation-read-set.companion';\n\n/**\n * Re-use one introspection child for every derivation asked of the SAME source state (#3208).\n *\n * ## Why\n *\n * A derivation runs in a child process that imports the companion's handler graph, the engine and the\n * application before it does any work. Measured on app-creation-test-007 (15 resources, 96 landed build\n * tasks): each derivation cost 47-120 s of wall time, of which the behavior itself took 0.2-9.7 s, so\n * about 90 % of every recompile pass was children starting. A pass recompiles every derivation whose\n * inputs moved, and in a build wave nearly every task moves `specifications` or `shared-lib`, which every\n * derivation reads: thirty-odd child boots per pass, each ~1.2 GB and ~13 s of CPU, four at a time,\n * beside the coding agents. That was the host load the companion's event loop starved under.\n *\n * ## What is shared, and why that is safe\n *\n * A worker is bound to the SOURCE-STATE TOKEN the derivation state observed before compiling. Every\n * derivation compiled against that token is asked of a worker bound to it, so the application's modules\n * are imported once per state instead of once per question. A worker asked for a different token is\n * never reused: it is retired, and a fresh one imports the new state. That keeps the old guarantee — an\n * answer is computed from the tree the token names — while sharing the one thing that was pure overhead.\n *\n * Behaviors share a process, which a one-shot child never did. Two guards cover that:\n * - requests reach a worker one at a time, so no two behaviors interleave on one module state;\n * - a request that FAILS in a worker that already served another is asked once more of a fresh one-shot\n * child, and a success there is logged as a behavior that is not safe to share a process with. A real\n * failure (an unbuilt package, a refused input) fails again and is reported as before.\n *\n * ## What it costs\n *\n * At most {@link IntrospectionWorkerPoolOptions.maximumWorkers} live children, the same bound the\n * concurrency queue already put on running ones; an idle worker exits after\n * {@link IntrospectionWorkerPoolOptions.idleMs} so a quiet companion holds none.\n */\nexport interface IntrospectionWorkerPoolOptions {\n /** Start one worker child (argv, cwd and env are the caller's; `stdio` must include `ipc`). */\n readonly spawnWorker: () => ChildProcess;\n readonly maximumWorkers: number;\n /** An idle worker exits after this long. */\n readonly idleMs: number;\n /** One request may take this long before its worker is killed and the request fails as a timeout. */\n readonly requestTimeoutMs: number;\n readonly log: (message: string, context?: Record<string, unknown>) => void;\n}\n\n/** The longest stdout/stderr kept per request, so a chatty worker cannot grow the parent's heap. */\nconst MAXIMUM_CAPTURED_OUTPUT_CHARACTERS = 64 * 1024;\n\n/** How long a retired worker has to exit after its channel closes before it is killed. */\nconst RETIREMENT_GRACE_MS = 1_000;\n\n/** Signals that mean someone other than this pool stopped a worker. */\nconst EXTERNAL_TERMINATION_SIGNALS = new Set<string>(['SIGTERM', 'SIGINT', 'SIGHUP']);\n\ninterface PendingRequest {\n readonly requestId: string;\n readonly settle: (outcome: IntrospectionWorkerOutcome) => void;\n readonly timeout: NodeJS.Timeout;\n stdout: string;\n stderr: string;\n}\n\ninterface PooledWorker {\n readonly id: number;\n readonly child: ChildProcess;\n /** The token of the tree the worker last served: the one it was started for, or one it was kept for (#3452). */\n sourceStateToken: string;\n /** The shared component (framework roots, root manifests) it was started under; it is never kept across a change of it. */\n readonly sharedToken: string | undefined;\n /**\n * Every application file a request of this worker read, at its FIRST reading: the module code the worker holds for\n * the rest of its life (#3452). A worker is kept for a new token only while none of these moved.\n */\n readonly loaded: Map<string, IntrospectionReadEntry>;\n /** A request answered with no read set: what the worker holds is unknown, so it is never kept for another token. */\n loadedUnknown: boolean;\n readonly spawned: Promise<void>;\n pending: PendingRequest | null;\n /**\n * Taken by `acquire` synchronously and released when the request settles. `pending` alone is not\n * enough: it is set only once the worker has spawned, so two requests arriving together would both see\n * a fresh worker as free.\n */\n busy: boolean;\n idleTimer: NodeJS.Timeout | null;\n /** Requests this worker has answered; a failure after the first is retried in isolation. */\n served: number;\n retiring: boolean;\n}\n\n/** What one request through the pool came to. */\nexport type IntrospectionWorkerOutcome =\n | {\n readonly kind: 'result';\n readonly result: CompanionIntrospectionResult;\n readonly workerServedBefore: number;\n readonly stdout: string;\n readonly stderr: string;\n /** The files a successful request read (#3207); absent when the worker could not say. */\n readonly readSet?: readonly IntrospectionReadEntry[];\n }\n | { readonly kind: 'failure'; readonly error: CompanionIntrospectionErrorDetails; readonly workerServedBefore: number; readonly stdout: string; readonly stderr: string };\n\n/**\n * What lets an idle worker bound to another token serve a request (#3452): the shared component the request was\n * observed under, and a check that every file the worker loaded still reads as it did (the derivation state's read-set\n * checker, so one `stat` per path serves both).\n */\nexport interface IntrospectionWorkerReuse {\n readonly sharedToken: string | undefined;\n readonly stillMatches: (entries: readonly IntrospectionReadEntry[], observationToken: string) => Promise<boolean>;\n}\n\nexport class IntrospectionWorkerPool {\n private readonly workers: PooledWorker[] = [];\n private nextWorkerId = 1;\n\n public constructor(private readonly options: IntrospectionWorkerPoolOptions) {}\n\n /** Live workers, busy or idle. A diagnostic and a test pin. */\n public get liveWorkerCount(): number {\n return this.workers.length;\n }\n\n /**\n * Ask one derivation of a worker bound to `sourceStateToken`, starting one if none is idle.\n *\n * The caller bounds how many requests run at once (the service's concurrency queue), so there is always\n * an idle worker of this token or room for a new one once idle workers of other tokens are retired.\n */\n public async run(\n sourceStateToken: string,\n request: CompanionIntrospectionChildRequest,\n reuse?: IntrospectionWorkerReuse,\n ): Promise<IntrospectionWorkerOutcome> {\n const worker = await this.acquire(sourceStateToken, reuse);\n try {\n await worker.spawned;\n } catch (error) {\n this.retire(worker, 'spawn failed');\n const spawnError = error instanceof Error ? error : new Error(String(error));\n return { kind: 'failure', error: { message: spawnError.message, name: spawnError.name, stack: spawnError.stack }, workerServedBefore: 0, stdout: '', stderr: '' };\n }\n return new Promise<IntrospectionWorkerOutcome>((resolveOutcome) => {\n const requestId = randomUUID();\n const servedBefore = worker.served;\n let settled = false;\n if (worker.pending !== null) {\n /*\n * Never overwrite a pending request: the one replaced could then settle only through a slot that no longer names\n * it. `acquire` guarantees a worker holds one request at a time; should that ever fail again, both requests fail\n * here and the worker is retired, which is a visible failure the caller retries instead of a promise nobody settles.\n */\n this.failPending(worker, { message: 'Introspection worker was handed a second request while it held one.', name: 'CompanionIntrospectionWorkerProtocolError' });\n this.retire(worker, 'handed a second request', { kill: true });\n resolveOutcome({ kind: 'failure', error: { message: 'Introspection worker was handed a second request while it held one.', name: 'CompanionIntrospectionWorkerProtocolError' }, workerServedBefore: servedBefore, stdout: '', stderr: '' });\n return;\n }\n const pending: PendingRequest = {\n requestId,\n stdout: '',\n stderr: '',\n // Settles THIS request, not whatever the worker holds now: the deadline is the one guarantee a request has.\n timeout: setTimeout(() => {\n pending.settle({\n kind: 'failure',\n error: { message: `Companion introspection timed out after ${this.options.requestTimeoutMs}ms.`, name: 'CompanionIntrospectionTimeoutError' },\n workerServedBefore: 0,\n stdout: pending.stdout,\n stderr: pending.stderr,\n });\n this.retire(worker, 'request timed out', { kill: true });\n }, this.options.requestTimeoutMs),\n settle: (outcome) => {\n if (settled) return;\n settled = true;\n clearTimeout(pending.timeout);\n if (worker.pending === pending) worker.pending = null;\n worker.busy = false;\n resolveOutcome({ ...outcome, workerServedBefore: servedBefore });\n },\n };\n worker.pending = pending;\n const envelope: CompanionIntrospectionWorkerRequest = { kind: COMPANION_INTROSPECTION_WORKER_REQUEST_KIND, requestId, request };\n try {\n worker.child.send?.(envelope);\n } catch (error) {\n this.failPending(worker, { message: `Could not send the request to the introspection worker: ${String(error)}`, name: 'CompanionIntrospectionWorkerSendError' });\n this.retire(worker, 'send failed');\n }\n });\n }\n\n /**\n * Retire every worker. For a caller that wants them gone now (a test, a profiling run); a running companion\n * relies on each worker exiting by itself when the companion exits, because its IPC channel closes.\n */\n public shutdown(): void {\n for (const worker of [...this.workers]) this.retire(worker, 'pool shut down');\n }\n\n private async acquire(sourceStateToken: string, reuse: IntrospectionWorkerReuse | undefined): Promise<PooledWorker> {\n const claim = (worker: PooledWorker): PooledWorker => {\n if (worker.idleTimer) clearTimeout(worker.idleTimer);\n worker.idleTimer = null;\n worker.busy = true;\n return worker;\n };\n const idle = this.workers.find((worker) => !worker.busy && !worker.retiring && worker.sourceStateToken === sourceStateToken);\n if (idle) return claim(idle);\n /*\n * An idle worker of ANOTHER token is kept when nothing it holds moved (#3452): the same shared component, and every\n * file its requests loaded reading as it did. The token covers the whole tree, so any edit anywhere used to retire\n * every idle worker — measured on the reference runs, 246 of 313 workers retired as \"source state moved\" and 158\n * served one request, each paying a cold compile (median 9.5 s against 0.1 s warm). Claimed before the check, so two\n * requests never take one worker.\n */\n if (reuse?.sharedToken !== undefined) {\n for (const worker of this.workers.filter((candidate) => !candidate.busy && !candidate.retiring && candidate.sharedToken === reuse.sharedToken && !candidate.loadedUnknown)) {\n /*\n * Asked again, because the list is a snapshot and this loop awaits between candidates: another request may have\n * claimed (or retired) a worker the snapshot still names. Claiming it anyway put two requests on one worker, and the\n * second overwrote the first's pending slot, so the first never settled (reference run 42468505853: worker 167,\n * claimed twice within 200 ms, left `labelling-resource-specifications` in flight for good and froze the build).\n */\n if (worker.busy || worker.retiring) continue;\n claim(worker);\n if (await reuse.stillMatches([...worker.loaded.values()], sourceStateToken)) {\n this.options.log('Introspection worker kept for a moved tree it never read', { workerId: worker.id, sourceStateToken: abbreviate(sourceStateToken), loadedFiles: worker.loaded.size });\n worker.sourceStateToken = sourceStateToken;\n return worker;\n }\n worker.busy = false;\n this.retire(worker, 'a file it loaded moved');\n }\n }\n // No idle worker can serve this state: every idle one is of another and holds something that moved, so it is\n // retired at once, which also makes room. A busy worker is never taken; the caller's concurrency bound guarantees\n // room once the idle ones are gone.\n for (const worker of [...this.workers]) {\n if (!worker.busy) this.retire(worker, 'source state moved');\n }\n return this.spawn(sourceStateToken, reuse?.sharedToken);\n }\n\n private spawn(sourceStateToken: string, sharedToken: string | undefined): PooledWorker {\n const child = this.options.spawnWorker();\n const id = this.nextWorkerId++;\n const spawned = new Promise<void>((resolveSpawn, rejectSpawn) => {\n child.once('spawn', () => resolveSpawn());\n child.once('error', (error) => rejectSpawn(error));\n });\n // A spawn failure is reported through `run`; this keeps it from also being an unhandled rejection.\n spawned.catch(() => undefined);\n const worker: PooledWorker = {\n id, child, sourceStateToken, sharedToken, loaded: new Map(), loadedUnknown: false, spawned, pending: null, busy: true, idleTimer: null, served: 0, retiring: false,\n };\n this.workers.push(worker);\n\n const capture = (stream: 'stdout' | 'stderr') => (chunk: Buffer | string) => {\n const pending = worker.pending;\n if (!pending) return;\n pending[stream] = (pending[stream] + chunk.toString()).slice(-MAXIMUM_CAPTURED_OUTPUT_CHARACTERS);\n };\n child.stdout?.on('data', capture('stdout'));\n child.stderr?.on('data', capture('stderr'));\n child.on('message', (message: unknown) => this.onMessage(worker, message));\n child.on('error', (error) => {\n this.failPending(worker, { message: error.message, name: error.name, stack: error.stack });\n this.retire(worker, 'worker error');\n });\n child.on('close', (code, signal) => this.onClose(worker, code, signal));\n this.options.log('Introspection worker started', { workerId: id, sourceStateToken: abbreviate(sourceStateToken), liveWorkers: this.workers.length });\n return worker;\n }\n\n private onMessage(worker: PooledWorker, message: unknown): void {\n const pending = worker.pending;\n const requestId = message !== null && typeof message === 'object' ? (message as { requestId?: unknown }).requestId : undefined;\n if (!pending || requestId !== pending.requestId) {\n // An answer nobody is waiting for means the worker and this pool disagree about what it is doing.\n this.failPending(worker, { message: 'Introspection worker answered a request it was not asked.', name: 'CompanionIntrospectionWorkerProtocolError' });\n this.retire(worker, 'protocol mismatch');\n return;\n }\n // A success's data arrives as text (#3452): parsed once here, and the text kept beside the value for the change check.\n const dataJson = (message as { dataJson?: unknown }).dataJson;\n let rawResult = (message as { result?: unknown }).result;\n let data: unknown;\n if (typeof dataJson === 'string' && rawResult !== null && typeof rawResult === 'object') {\n try {\n data = JSON.parse(dataJson);\n } catch {\n this.failPending(worker, { message: 'Introspection worker returned unreadable result data.', name: 'CompanionIntrospectionWorkerProtocolError' });\n this.retire(worker, 'invalid result');\n return;\n }\n rawResult = { ...(rawResult as Record<string, unknown>), data };\n }\n const parsed = CompanionIntrospectionResultSchema.safeParse(rawResult);\n if (!parsed.success) {\n this.failPending(worker, { message: `Introspection worker returned an invalid result: ${parsed.error.message}`, name: 'CompanionIntrospectionWorkerProtocolError' });\n this.retire(worker, 'invalid result');\n return;\n }\n worker.served += 1;\n if (typeof dataJson === 'string' && parsed.data.success) recordIntrospectionPayloadText(parsed.data.data, dataJson);\n const readSet = parseIntrospectionReadSet((message as { readSet?: unknown }).readSet);\n // What the worker now holds: each file at its first reading, which is the code it keeps (#3452). That is every file\n // the request LOADED, which a behavior ignoring the families reports beside its narrower `readSet` (review F4).\n const rawLoaded = (message as { loadedReadSet?: unknown }).loadedReadSet;\n const loaded = rawLoaded === undefined ? readSet : parseIntrospectionReadSet(rawLoaded);\n if (loaded === undefined) worker.loadedUnknown = true;\n else for (const entry of loaded) if (!worker.loaded.has(entry.path)) worker.loaded.set(entry.path, entry);\n pending.settle({\n kind: 'result',\n result: parsed.data as CompanionIntrospectionResult,\n workerServedBefore: 0,\n stdout: pending.stdout,\n stderr: pending.stderr,\n ...(readSet === undefined ? {} : { readSet }),\n });\n if (!worker.retiring) {\n worker.idleTimer = setTimeout(() => this.retire(worker, 'idle'), this.options.idleMs);\n worker.idleTimer.unref?.();\n }\n }\n\n private onClose(worker: PooledWorker, code: number | null, signal: NodeJS.Signals | null): void {\n const index = this.workers.indexOf(worker);\n if (index !== -1) this.workers.splice(index, 1);\n if (worker.idleTimer) clearTimeout(worker.idleTimer);\n if (!worker.pending) return;\n // Nobody here asked this worker to stop while it held a request, so a termination signal came from\n // outside: the companion itself is stopping (see `wasTerminatedFromOutside` for the one-shot twin).\n const external = !worker.retiring && signal !== null && EXTERNAL_TERMINATION_SIGNALS.has(signal);\n const output = describeOutput(worker.pending);\n this.failPending(worker, external\n ? {\n message: `Companion introspection was terminated by ${signal} that this service did not send — the companion process itself is stopping, so the derivation was cut short rather than failing. Re-run it once the companion is ready.`,\n name: INTROSPECTION_PARENT_TERMINATED_ERROR_NAME,\n }\n : {\n message: `Companion introspection worker exited before answering (code=${code ?? 'null'}, signal=${signal ?? 'null'})${output ? ` — ${output}` : ''}.`,\n name: 'CompanionIntrospectionSubprocessExitError',\n });\n }\n\n private failPending(worker: PooledWorker, error: CompanionIntrospectionErrorDetails): void {\n const pending = worker.pending;\n if (!pending) return;\n pending.settle({ kind: 'failure', error, workerServedBefore: 0, stdout: pending.stdout, stderr: pending.stderr });\n }\n\n private retire(worker: PooledWorker, reason: string, options: { readonly kill?: boolean } = {}): void {\n if (worker.retiring) return;\n worker.retiring = true;\n if (worker.idleTimer) clearTimeout(worker.idleTimer);\n worker.idleTimer = null;\n const index = this.workers.indexOf(worker);\n if (index !== -1) this.workers.splice(index, 1);\n this.options.log('Introspection worker retired', { workerId: worker.id, reason, served: worker.served, liveWorkers: this.workers.length });\n // Closing the channel is the worker's signal to exit (it exits 0 on `disconnect`). A hung worker —\n // one retired over a timeout — cannot run that handler, so it is signalled at once; either way one\n // that is still there after the grace period is killed.\n try {\n if (worker.child.connected) worker.child.disconnect?.();\n } catch {\n // Already disconnected.\n }\n if (options.kill === true) {\n try {\n worker.child.kill('SIGTERM');\n } catch {\n // Already gone.\n }\n }\n const kill = setTimeout(() => {\n try {\n worker.child.kill('SIGKILL');\n } catch {\n // Already gone.\n }\n }, RETIREMENT_GRACE_MS);\n kill.unref?.();\n worker.child.once('close', () => clearTimeout(kill));\n }\n}\n\nfunction abbreviate(token: string): string {\n return token.length <= 16 ? token : `${token.slice(0, 16)}…`;\n}\n\nfunction describeOutput(pending: PendingRequest): string {\n const parts = [\n ...(pending.stdout.trim() ? [`stdout: ${pending.stdout.trim()}`] : []),\n ...(pending.stderr.trim() ? [`stderr: ${pending.stderr.trim()}`] : []),\n ];\n return parts.join(' | ');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"introspection-worker-pool.companion.js","sourceRoot":"","sources":["../../../../../src/core/introspection/services/introspection-worker-pool.companion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,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:crypto';\n\nimport { CompanionIntrospectionResultSchema } from '../../../companion-api/companion-api.schemas';\nimport {\n COMPANION_INTROSPECTION_WORKER_REQUEST_KIND,\n INTROSPECTION_PARENT_TERMINATED_ERROR_NAME,\n recordIntrospectionPayloadText,\n type CompanionIntrospectionChildRequest,\n type CompanionIntrospectionErrorDetails,\n type CompanionIntrospectionResult,\n type CompanionIntrospectionWorkerRequest,\n} from '../models/companion-introspection.models';\nimport type { IntrospectionReadEntry } from '../subprocess/derivation-read-tracking';\nimport { parseIntrospectionReadSet } from './introspection-derivation-read-set.companion';\n\n/**\n * Re-use one introspection child for every derivation asked of the SAME source state (#3208).\n *\n * ## Why\n *\n * A derivation runs in a child process that imports the companion's handler graph, the engine and the\n * application before it does any work. Measured on app-creation-test-007 (15 resources, 96 landed build\n * tasks): each derivation cost 47-120 s of wall time, of which the behavior itself took 0.2-9.7 s, so\n * about 90 % of every recompile pass was children starting. A pass recompiles every derivation whose\n * inputs moved, and in a build wave nearly every task moves `specifications` or `shared-lib`, which every\n * derivation reads: thirty-odd child boots per pass, each ~1.2 GB and ~13 s of CPU, four at a time,\n * beside the coding agents. That was the host load the companion's event loop starved under.\n *\n * ## What is shared, and why that is safe\n *\n * A worker is bound to the SOURCE-STATE TOKEN the derivation state observed before compiling. Every\n * derivation compiled against that token is asked of a worker bound to it, so the application's modules\n * are imported once per state instead of once per question. A worker asked for a different token is\n * never reused: it is retired, and a fresh one imports the new state. That keeps the old guarantee — an\n * answer is computed from the tree the token names — while sharing the one thing that was pure overhead.\n *\n * Behaviors share a process, which a one-shot child never did. Two guards cover that:\n * - requests reach a worker one at a time, so no two behaviors interleave on one module state;\n * - a request that FAILS in a worker that already served another is asked once more of a fresh one-shot\n * child, and a success there is logged as a behavior that is not safe to share a process with. A real\n * failure (an unbuilt package, a refused input) fails again and is reported as before.\n *\n * ## What it costs\n *\n * At most {@link IntrospectionWorkerPoolOptions.maximumWorkers} live children, the same bound the\n * concurrency queue already put on running ones; an idle worker exits after\n * {@link IntrospectionWorkerPoolOptions.idleMs} so a quiet companion holds none.\n */\nexport interface IntrospectionWorkerPoolOptions {\n /** Start one worker child (argv, cwd and env are the caller's; `stdio` must include `ipc`). */\n readonly spawnWorker: () => ChildProcess;\n readonly maximumWorkers: number;\n /** An idle worker exits after this long. */\n readonly idleMs: number;\n /** One request may take this long before its worker is killed and the request fails as a timeout. */\n readonly requestTimeoutMs: number;\n readonly log: (message: string, context?: Record<string, unknown>) => void;\n}\n\n/** The longest stdout/stderr kept per request, so a chatty worker cannot grow the parent's heap. */\nconst MAXIMUM_CAPTURED_OUTPUT_CHARACTERS = 64 * 1024;\n\n/** How long a retired worker has to exit after its channel closes before it is killed. */\nconst RETIREMENT_GRACE_MS = 1_000;\n\n/** Signals that mean someone other than this pool stopped a worker. */\nconst EXTERNAL_TERMINATION_SIGNALS = new Set<string>(['SIGTERM', 'SIGINT', 'SIGHUP']);\n\ninterface PendingRequest {\n readonly requestId: string;\n readonly settle: (outcome: IntrospectionWorkerOutcome) => void;\n readonly timeout: NodeJS.Timeout;\n stdout: string;\n stderr: string;\n}\n\ninterface PooledWorker {\n readonly id: number;\n readonly child: ChildProcess;\n /** The token of the tree the worker last served: the one it was started for, or one it was kept for (#3452). */\n sourceStateToken: string;\n /** The shared component (framework roots, root manifests) it was started under; it is never kept across a change of it. */\n readonly sharedToken: string | undefined;\n /**\n * Every application file a request of this worker read, at its FIRST reading: the module code the worker holds for\n * the rest of its life (#3452). A worker is kept for a new token only while none of these moved.\n */\n readonly loaded: Map<string, IntrospectionReadEntry>;\n /** A request answered with no read set: what the worker holds is unknown, so it is never kept for another token. */\n loadedUnknown: boolean;\n readonly spawned: Promise<void>;\n pending: PendingRequest | null;\n /**\n * Taken by `acquire` synchronously and released when the request settles. `pending` alone is not\n * enough: it is set only once the worker has spawned, so two requests arriving together would both see\n * a fresh worker as free.\n */\n busy: boolean;\n idleTimer: NodeJS.Timeout | null;\n /** Requests this worker has answered; a failure after the first is retried in isolation. */\n served: number;\n retiring: boolean;\n /** When the pool started this worker: what {@link IntrospectionWorkerPool.retireWorkersStartedBefore} compares. */\n readonly startedAtMs: number;\n /** Set on a busy worker that must not serve again: it is retired as soon as its request settles (#3703). */\n retireAfterRequest: boolean;\n}\n\n/** What one request through the pool came to. */\nexport type IntrospectionWorkerOutcome =\n | {\n readonly kind: 'result';\n readonly result: CompanionIntrospectionResult;\n readonly workerServedBefore: number;\n readonly stdout: string;\n readonly stderr: string;\n /** The files a successful request read (#3207); absent when the worker could not say. */\n readonly readSet?: readonly IntrospectionReadEntry[];\n }\n | { readonly kind: 'failure'; readonly error: CompanionIntrospectionErrorDetails; readonly workerServedBefore: number; readonly stdout: string; readonly stderr: string };\n\n/**\n * What lets an idle worker bound to another token serve a request (#3452): the shared component the request was\n * observed under, and a check that every file the worker loaded still reads as it did (the derivation state's read-set\n * checker, so one `stat` per path serves both).\n */\nexport interface IntrospectionWorkerReuse {\n readonly sharedToken: string | undefined;\n readonly stillMatches: (entries: readonly IntrospectionReadEntry[], observationToken: string) => Promise<boolean>;\n}\n\nexport class IntrospectionWorkerPool {\n private readonly workers: PooledWorker[] = [];\n private nextWorkerId = 1;\n\n public constructor(private readonly options: IntrospectionWorkerPoolOptions) {}\n\n /** Live workers, busy or idle. A diagnostic and a test pin. */\n public get liveWorkerCount(): number {\n return this.workers.length;\n }\n\n /**\n * Ask one derivation of a worker bound to `sourceStateToken`, starting one if none is idle.\n *\n * The caller bounds how many requests run at once (the service's concurrency queue), so there is always\n * an idle worker of this token or room for a new one once idle workers of other tokens are retired.\n */\n public async run(\n sourceStateToken: string,\n request: CompanionIntrospectionChildRequest,\n reuse?: IntrospectionWorkerReuse,\n ): Promise<IntrospectionWorkerOutcome> {\n const worker = await this.acquire(sourceStateToken, reuse);\n try {\n await worker.spawned;\n } catch (error) {\n this.retire(worker, 'spawn failed');\n const spawnError = error instanceof Error ? error : new Error(String(error));\n return { kind: 'failure', error: { message: spawnError.message, name: spawnError.name, stack: spawnError.stack }, workerServedBefore: 0, stdout: '', stderr: '' };\n }\n return new Promise<IntrospectionWorkerOutcome>((resolveOutcome) => {\n const requestId = randomUUID();\n const servedBefore = worker.served;\n let settled = false;\n if (worker.pending !== null) {\n /*\n * Never overwrite a pending request: the one replaced could then settle only through a slot that no longer names\n * it. `acquire` guarantees a worker holds one request at a time; should that ever fail again, both requests fail\n * here and the worker is retired, which is a visible failure the caller retries instead of a promise nobody settles.\n */\n this.failPending(worker, { message: 'Introspection worker was handed a second request while it held one.', name: 'CompanionIntrospectionWorkerProtocolError' });\n this.retire(worker, 'handed a second request', { kill: true });\n resolveOutcome({ kind: 'failure', error: { message: 'Introspection worker was handed a second request while it held one.', name: 'CompanionIntrospectionWorkerProtocolError' }, workerServedBefore: servedBefore, stdout: '', stderr: '' });\n return;\n }\n const pending: PendingRequest = {\n requestId,\n stdout: '',\n stderr: '',\n // Settles THIS request, not whatever the worker holds now: the deadline is the one guarantee a request has.\n timeout: setTimeout(() => {\n pending.settle({\n kind: 'failure',\n error: { message: `Companion introspection timed out after ${this.options.requestTimeoutMs}ms.`, name: 'CompanionIntrospectionTimeoutError' },\n workerServedBefore: 0,\n stdout: pending.stdout,\n stderr: pending.stderr,\n });\n this.retire(worker, 'request timed out', { kill: true });\n }, this.options.requestTimeoutMs),\n settle: (outcome) => {\n if (settled) return;\n settled = true;\n clearTimeout(pending.timeout);\n if (worker.pending === pending) worker.pending = null;\n worker.busy = false;\n resolveOutcome({ ...outcome, workerServedBefore: servedBefore });\n },\n };\n worker.pending = pending;\n const envelope: CompanionIntrospectionWorkerRequest = { kind: COMPANION_INTROSPECTION_WORKER_REQUEST_KIND, requestId, request };\n try {\n worker.child.send?.(envelope);\n } catch (error) {\n this.failPending(worker, { message: `Could not send the request to the introspection worker: ${String(error)}`, name: 'CompanionIntrospectionWorkerSendError' });\n this.retire(worker, 'send failed');\n }\n });\n }\n\n /**\n * Retire every worker. For a caller that wants them gone now (a test, a profiling run); a running companion\n * relies on each worker exiting by itself when the companion exits, because its IPC channel closes.\n */\n public shutdown(): void {\n for (const worker of [...this.workers]) this.retire(worker, 'pool shut down');\n }\n\n /**\n * Retire every worker started before `instantMs` (#3703): an idle one now, a busy one as soon as its request settles.\n *\n * For a dependency tree that moved under the pool. A worker started before a `pnpm install` re-created the\n * application's `node_modules` holds modules read from the old tree, and Node keeps a failed import failed for the\n * life of the process, so a derivation that failed there would fail there again. The caller asks this once the tree\n * has settled, so its retry, and every later request, runs in a process started after it.\n */\n public retireWorkersStartedBefore(instantMs: number, reason: string): void {\n for (const worker of [...this.workers]) {\n if (worker.startedAtMs >= instantMs) continue;\n if (worker.busy) worker.retireAfterRequest = true;\n else this.retire(worker, reason);\n }\n }\n\n private async acquire(sourceStateToken: string, reuse: IntrospectionWorkerReuse | undefined): Promise<PooledWorker> {\n const claim = (worker: PooledWorker): PooledWorker => {\n if (worker.idleTimer) clearTimeout(worker.idleTimer);\n worker.idleTimer = null;\n worker.busy = true;\n return worker;\n };\n const idle = this.workers.find((worker) => !worker.busy && !worker.retiring && !worker.retireAfterRequest && worker.sourceStateToken === sourceStateToken);\n if (idle) return claim(idle);\n /*\n * An idle worker of ANOTHER token is kept when nothing it holds moved (#3452): the same shared component, and every\n * file its requests loaded reading as it did. The token covers the whole tree, so any edit anywhere used to retire\n * every idle worker — measured on the reference runs, 246 of 313 workers retired as \"source state moved\" and 158\n * served one request, each paying a cold compile (median 9.5 s against 0.1 s warm). Claimed before the check, so two\n * requests never take one worker.\n */\n if (reuse?.sharedToken !== undefined) {\n for (const worker of this.workers.filter((candidate) => !candidate.busy && !candidate.retiring && candidate.sharedToken === reuse.sharedToken && !candidate.loadedUnknown && !candidate.retireAfterRequest)) {\n /*\n * Asked again, because the list is a snapshot and this loop awaits between candidates: another request may have\n * claimed (or retired) a worker the snapshot still names. Claiming it anyway put two requests on one worker, and the\n * second overwrote the first's pending slot, so the first never settled (reference run 42468505853: worker 167,\n * claimed twice within 200 ms, left `labelling-resource-specifications` in flight for good and froze the build).\n */\n if (worker.busy || worker.retiring) continue;\n claim(worker);\n if (await reuse.stillMatches([...worker.loaded.values()], sourceStateToken)) {\n this.options.log('Introspection worker kept for a moved tree it never read', { workerId: worker.id, sourceStateToken: abbreviate(sourceStateToken), loadedFiles: worker.loaded.size });\n worker.sourceStateToken = sourceStateToken;\n return worker;\n }\n worker.busy = false;\n this.retire(worker, 'a file it loaded moved');\n }\n }\n // No idle worker can serve this state: every idle one is of another and holds something that moved, so it is\n // retired at once, which also makes room. A busy worker is never taken; the caller's concurrency bound guarantees\n // room once the idle ones are gone.\n for (const worker of [...this.workers]) {\n if (!worker.busy) this.retire(worker, 'source state moved');\n }\n return this.spawn(sourceStateToken, reuse?.sharedToken);\n }\n\n private spawn(sourceStateToken: string, sharedToken: string | undefined): PooledWorker {\n const child = this.options.spawnWorker();\n const id = this.nextWorkerId++;\n const spawned = new Promise<void>((resolveSpawn, rejectSpawn) => {\n child.once('spawn', () => resolveSpawn());\n child.once('error', (error) => rejectSpawn(error));\n });\n // A spawn failure is reported through `run`; this keeps it from also being an unhandled rejection.\n spawned.catch(() => undefined);\n const worker: PooledWorker = {\n id, child, sourceStateToken, sharedToken, loaded: new Map(), loadedUnknown: false, spawned, pending: null, busy: true, idleTimer: null, served: 0, retiring: false,\n startedAtMs: Date.now(), retireAfterRequest: false,\n };\n this.workers.push(worker);\n\n const capture = (stream: 'stdout' | 'stderr') => (chunk: Buffer | string) => {\n const pending = worker.pending;\n if (!pending) return;\n pending[stream] = (pending[stream] + chunk.toString()).slice(-MAXIMUM_CAPTURED_OUTPUT_CHARACTERS);\n };\n child.stdout?.on('data', capture('stdout'));\n child.stderr?.on('data', capture('stderr'));\n child.on('message', (message: unknown) => this.onMessage(worker, message));\n child.on('error', (error) => {\n this.failPending(worker, { message: error.message, name: error.name, stack: error.stack });\n this.retire(worker, 'worker error');\n });\n child.on('close', (code, signal) => this.onClose(worker, code, signal));\n this.options.log('Introspection worker started', { workerId: id, sourceStateToken: abbreviate(sourceStateToken), liveWorkers: this.workers.length });\n return worker;\n }\n\n private onMessage(worker: PooledWorker, message: unknown): void {\n const pending = worker.pending;\n const requestId = message !== null && typeof message === 'object' ? (message as { requestId?: unknown }).requestId : undefined;\n if (!pending || requestId !== pending.requestId) {\n // An answer nobody is waiting for means the worker and this pool disagree about what it is doing.\n this.failPending(worker, { message: 'Introspection worker answered a request it was not asked.', name: 'CompanionIntrospectionWorkerProtocolError' });\n this.retire(worker, 'protocol mismatch');\n return;\n }\n // A success's data arrives as text (#3452): parsed once here, and the text kept beside the value for the change check.\n const dataJson = (message as { dataJson?: unknown }).dataJson;\n let rawResult = (message as { result?: unknown }).result;\n let data: unknown;\n if (typeof dataJson === 'string' && rawResult !== null && typeof rawResult === 'object') {\n try {\n data = JSON.parse(dataJson);\n } catch {\n this.failPending(worker, { message: 'Introspection worker returned unreadable result data.', name: 'CompanionIntrospectionWorkerProtocolError' });\n this.retire(worker, 'invalid result');\n return;\n }\n rawResult = { ...(rawResult as Record<string, unknown>), data };\n }\n const parsed = CompanionIntrospectionResultSchema.safeParse(rawResult);\n if (!parsed.success) {\n this.failPending(worker, { message: `Introspection worker returned an invalid result: ${parsed.error.message}`, name: 'CompanionIntrospectionWorkerProtocolError' });\n this.retire(worker, 'invalid result');\n return;\n }\n worker.served += 1;\n if (typeof dataJson === 'string' && parsed.data.success) recordIntrospectionPayloadText(parsed.data.data, dataJson);\n const readSet = parseIntrospectionReadSet((message as { readSet?: unknown }).readSet);\n // What the worker now holds: each file at its first reading, which is the code it keeps (#3452). That is every file\n // the request LOADED, which a behavior ignoring the families reports beside its narrower `readSet` (review F4).\n const rawLoaded = (message as { loadedReadSet?: unknown }).loadedReadSet;\n const loaded = rawLoaded === undefined ? readSet : parseIntrospectionReadSet(rawLoaded);\n if (loaded === undefined) worker.loadedUnknown = true;\n else for (const entry of loaded) if (!worker.loaded.has(entry.path)) worker.loaded.set(entry.path, entry);\n pending.settle({\n kind: 'result',\n result: parsed.data as CompanionIntrospectionResult,\n workerServedBefore: 0,\n stdout: pending.stdout,\n stderr: pending.stderr,\n ...(readSet === undefined ? {} : { readSet }),\n });\n if (worker.retireAfterRequest) {\n this.retire(worker, 'started before the dependency tree moved');\n } else if (!worker.retiring) {\n worker.idleTimer = setTimeout(() => this.retire(worker, 'idle'), this.options.idleMs);\n worker.idleTimer.unref?.();\n }\n }\n\n private onClose(worker: PooledWorker, code: number | null, signal: NodeJS.Signals | null): void {\n const index = this.workers.indexOf(worker);\n if (index !== -1) this.workers.splice(index, 1);\n if (worker.idleTimer) clearTimeout(worker.idleTimer);\n if (!worker.pending) return;\n // Nobody here asked this worker to stop while it held a request, so a termination signal came from\n // outside: the companion itself is stopping (see `wasTerminatedFromOutside` for the one-shot twin).\n const external = !worker.retiring && signal !== null && EXTERNAL_TERMINATION_SIGNALS.has(signal);\n const output = describeOutput(worker.pending);\n this.failPending(worker, external\n ? {\n message: `Companion introspection was terminated by ${signal} that this service did not send — the companion process itself is stopping, so the derivation was cut short rather than failing. Re-run it once the companion is ready.`,\n name: INTROSPECTION_PARENT_TERMINATED_ERROR_NAME,\n }\n : {\n message: `Companion introspection worker exited before answering (code=${code ?? 'null'}, signal=${signal ?? 'null'})${output ? ` — ${output}` : ''}.`,\n name: 'CompanionIntrospectionSubprocessExitError',\n });\n }\n\n private failPending(worker: PooledWorker, error: CompanionIntrospectionErrorDetails): void {\n const pending = worker.pending;\n if (!pending) return;\n pending.settle({ kind: 'failure', error, workerServedBefore: 0, stdout: pending.stdout, stderr: pending.stderr });\n }\n\n private retire(worker: PooledWorker, reason: string, options: { readonly kill?: boolean } = {}): void {\n if (worker.retiring) return;\n worker.retiring = true;\n if (worker.idleTimer) clearTimeout(worker.idleTimer);\n worker.idleTimer = null;\n const index = this.workers.indexOf(worker);\n if (index !== -1) this.workers.splice(index, 1);\n this.options.log('Introspection worker retired', { workerId: worker.id, reason, served: worker.served, liveWorkers: this.workers.length });\n // Closing the channel is the worker's signal to exit (it exits 0 on `disconnect`). A hung worker —\n // one retired over a timeout — cannot run that handler, so it is signalled at once; either way one\n // that is still there after the grace period is killed.\n try {\n if (worker.child.connected) worker.child.disconnect?.();\n } catch {\n // Already disconnected.\n }\n if (options.kill === true) {\n try {\n worker.child.kill('SIGTERM');\n } catch {\n // Already gone.\n }\n }\n const kill = setTimeout(() => {\n try {\n worker.child.kill('SIGKILL');\n } catch {\n // Already gone.\n }\n }, RETIREMENT_GRACE_MS);\n kill.unref?.();\n worker.child.once('close', () => clearTimeout(kill));\n }\n}\n\nfunction abbreviate(token: string): string {\n return token.length <= 16 ? token : `${token.slice(0, 16)}…`;\n}\n\nfunction describeOutput(pending: PendingRequest): string {\n const parts = [\n ...(pending.stdout.trim() ? [`stdout: ${pending.stdout.trim()}`] : []),\n ...(pending.stderr.trim() ? [`stderr: ${pending.stderr.trim()}`] : []),\n ];\n return parts.join(' | ');\n}\n"]}
|
|
@@ -19,7 +19,22 @@ export declare enum CompanionLanguageModelTransport {
|
|
|
19
19
|
}
|
|
20
20
|
/** The model the companion's routed calls run on: Opus 5.5, the model its coding and research lane already uses. */
|
|
21
21
|
export declare const COMPANION_LANGUAGE_MODEL_ROUTE_MODEL = LLM_Model.CLAUDE_OPUS_5_5;
|
|
22
|
+
/**
|
|
23
|
+
* Where this process says "a routed language-model call is running", app-root-relative. Beaten while any session of
|
|
24
|
+
* the route is open and removed when none is, so the dev supervisor holds a restart that would kill it (the label and
|
|
25
|
+
* translate runs hold no lock and are no playbook run, so nothing else said so).
|
|
26
|
+
*
|
|
27
|
+
* A COPY of `LANGUAGE_MODEL_RUN_HEARTBEAT_RELATIVE_PATH` in
|
|
28
|
+
* `scripts/dev-orchestrator/runtime-supervisor-lifecycle.mjs`, pinned equal by
|
|
29
|
+
* `scripts/__tests__/runtime-supervisor-workspace-mutation-hold.test.mjs`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const LANGUAGE_MODEL_RUN_HEARTBEAT_RELATIVE_PATH = ".wildo-saas/state/language-model-run.heartbeat";
|
|
32
|
+
/**
|
|
33
|
+
* The route's `onSessionsInFlightChange` for a companion rooted at `saasRoot`: the heartbeat file exists exactly while
|
|
34
|
+
* a routed session is open.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createLanguageModelRunHeartbeatReporter(saasRoot: string, reportFailure: (message: string, error: unknown) => void): (sessionsInFlight: number) => void;
|
|
22
37
|
export declare function resolveCompanionLanguageModelTransport(environment?: NodeJS.ProcessEnv): CompanionLanguageModelTransport;
|
|
23
38
|
/** The route the companion installs, or undefined when its calls stay on the API keys. */
|
|
24
|
-
export declare function resolveCompanionLanguageModelRoute(environment?: NodeJS.ProcessEnv): LanguageModelAgentClientProtocolRoute | undefined;
|
|
39
|
+
export declare function resolveCompanionLanguageModelRoute(environment?: NodeJS.ProcessEnv, onSessionsInFlightChange?: (sessionsInFlight: number) => void): LanguageModelAgentClientProtocolRoute | undefined;
|
|
25
40
|
//# sourceMappingURL=companion-language-model-route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion-language-model-route.d.ts","sourceRoot":"","sources":["../../../../src/core/runtime/companion-language-model-route.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"companion-language-model-route.d.ts","sourceRoot":"","sources":["../../../../src/core/runtime/companion-language-model-route.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AAKxF;;;;;;;;;;GAUG;AACH,oBAAY,+BAA+B;IACzC,qFAAqF;IACrF,qBAAqB,QAAQ;IAC7B,gDAAgD;IAChD,GAAG,QAAQ;CACZ;AAED,oHAAoH;AACpH,eAAO,MAAM,oCAAoC,4BAA4B,CAAC;AAkB9E;;;;;;;;GAQG;AACH,eAAO,MAAM,0CAA0C,mDAAmD,CAAC;AAK3G;;;GAGG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,GACvD,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,CAGpC;AAED,wBAAgB,sCAAsC,CAAC,WAAW,GAAE,MAAM,CAAC,UAAwB,GAAG,+BAA+B,CAMpI;AAED,0FAA0F;AAC1F,wBAAgB,kCAAkC,CAChD,WAAW,GAAE,MAAM,CAAC,UAAwB,EAC5C,wBAAwB,CAAC,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,GAC5D,qCAAqC,GAAG,SAAS,CAiBnD"}
|
|
@@ -2,6 +2,7 @@ import { tmpdir } from 'node:os';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { LLM_Model } from '@wildo-ai/external-connectors-models';
|
|
4
4
|
import { APPLICATION_CODING_AGENT_BINDINGS } from '../../meta-workflows/models/application-coding-agent.actors-system.definitions.js';
|
|
5
|
+
import { InFlightWorkHeartbeat } from './in-flight-work-heartbeat.companion.js';
|
|
5
6
|
/**
|
|
6
7
|
* Where the companion's language-model calls run (#3472): Claude Code over ACP, on Opus 5.5, by default.
|
|
7
8
|
*
|
|
@@ -36,6 +37,26 @@ const DEFAULT_MAXIMUM_CONCURRENT_SESSIONS = 4;
|
|
|
36
37
|
const CALL_TIMEOUT_MS = 60 * 60 * 1000;
|
|
37
38
|
/** Refused submissions before a call reports its last refusal to the lane's own correction loop. */
|
|
38
39
|
const MAXIMUM_SUBMISSIONS = 6;
|
|
40
|
+
/**
|
|
41
|
+
* Where this process says "a routed language-model call is running", app-root-relative. Beaten while any session of
|
|
42
|
+
* the route is open and removed when none is, so the dev supervisor holds a restart that would kill it (the label and
|
|
43
|
+
* translate runs hold no lock and are no playbook run, so nothing else said so).
|
|
44
|
+
*
|
|
45
|
+
* A COPY of `LANGUAGE_MODEL_RUN_HEARTBEAT_RELATIVE_PATH` in
|
|
46
|
+
* `scripts/dev-orchestrator/runtime-supervisor-lifecycle.mjs`, pinned equal by
|
|
47
|
+
* `scripts/__tests__/runtime-supervisor-workspace-mutation-hold.test.mjs`.
|
|
48
|
+
*/
|
|
49
|
+
export const LANGUAGE_MODEL_RUN_HEARTBEAT_RELATIVE_PATH = '.wildo-saas/state/language-model-run.heartbeat';
|
|
50
|
+
/** How often that file's mtime is refreshed; the supervisor judges it stale at three times this (`AGENT_RUN_HEARTBEAT_STALE_MS`). */
|
|
51
|
+
const LANGUAGE_MODEL_RUN_HEARTBEAT_INTERVAL_MS = 5_000;
|
|
52
|
+
/**
|
|
53
|
+
* The route's `onSessionsInFlightChange` for a companion rooted at `saasRoot`: the heartbeat file exists exactly while
|
|
54
|
+
* a routed session is open.
|
|
55
|
+
*/
|
|
56
|
+
export function createLanguageModelRunHeartbeatReporter(saasRoot, reportFailure) {
|
|
57
|
+
const heartbeat = new InFlightWorkHeartbeat(join(saasRoot, LANGUAGE_MODEL_RUN_HEARTBEAT_RELATIVE_PATH), LANGUAGE_MODEL_RUN_HEARTBEAT_INTERVAL_MS, reportFailure);
|
|
58
|
+
return (sessionsInFlight) => heartbeat.sync(sessionsInFlight > 0);
|
|
59
|
+
}
|
|
39
60
|
export function resolveCompanionLanguageModelTransport(environment = process.env) {
|
|
40
61
|
const declared = environment.WILDO_LANGUAGE_MODEL_TRANSPORT?.trim().toLowerCase();
|
|
41
62
|
if (declared === undefined || declared === '')
|
|
@@ -47,7 +68,7 @@ export function resolveCompanionLanguageModelTransport(environment = process.env
|
|
|
47
68
|
throw new Error(`WILDO_LANGUAGE_MODEL_TRANSPORT="${declared}" is neither "acp" nor "api".`);
|
|
48
69
|
}
|
|
49
70
|
/** The route the companion installs, or undefined when its calls stay on the API keys. */
|
|
50
|
-
export function resolveCompanionLanguageModelRoute(environment = process.env) {
|
|
71
|
+
export function resolveCompanionLanguageModelRoute(environment = process.env, onSessionsInFlightChange) {
|
|
51
72
|
if (resolveCompanionLanguageModelTransport(environment) === CompanionLanguageModelTransport.API)
|
|
52
73
|
return undefined;
|
|
53
74
|
const sessions = Number.parseInt(environment.WILDO_LANGUAGE_MODEL_SESSIONS ?? '', 10);
|
|
@@ -64,6 +85,7 @@ export function resolveCompanionLanguageModelRoute(environment = process.env) {
|
|
|
64
85
|
maximumConcurrentSessions: Number.isInteger(sessions) && sessions > 0 ? sessions : DEFAULT_MAXIMUM_CONCURRENT_SESSIONS,
|
|
65
86
|
callTimeoutMs: CALL_TIMEOUT_MS,
|
|
66
87
|
maximumSubmissions: MAXIMUM_SUBMISSIONS,
|
|
88
|
+
...(onSessionsInFlightChange ? { onSessionsInFlightChange } : {}),
|
|
67
89
|
};
|
|
68
90
|
}
|
|
69
91
|
//# sourceMappingURL=companion-language-model-route.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion-language-model-route.js","sourceRoot":"","sources":["../../../../src/core/runtime/companion-language-model-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,iCAAiC,EAAE,MAAM,gFAAgF,CAAC;
|
|
1
|
+
{"version":3,"file":"companion-language-model-route.js","sourceRoot":"","sources":["../../../../src/core/runtime/companion-language-model-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,iCAAiC,EAAE,MAAM,gFAAgF,CAAC;AACnI,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E;;;;;;;;;;GAUG;AACH,MAAM,CA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C,GAAG,CAAC;IACjG,IAAI,QAAQ,KAAK,+BAA+B,CAAC,qBAAqB;QAAE,OAAO,+BAA+B,CAAC,qBAAqB,CAAC;IACrI,MAAM,IAAI,KAAK,CAAC,mCAAmC,QAAQ,+BAA+B,CAAC,CAAC;AAC9F,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,kCAAkC,CAChD,cAAiC,OAAO,CAAC,GAAG,EAC5C,wBAA6D;IAE7D,IAAI,sCAAsC,CAAC,WAAW,CAAC,KAAK,+BAA+B,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAClH,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,6BAA6B,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IACtF,MAAM,OAAO,GAAG,iCAAiC,CAAC,SAAS,CAAC;IAC5D,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,qGAAqG,CAAC,CAAC;IAClJ,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,WAAW;QACnC,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;QAChD,KAAK,EAAE,oCAAoC;QAC3C,kBAAkB,EAAE,oBAAoB;QACxC,2GAA2G;QAC3G,gBAAgB,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,+BAA+B,CAAC;QACjE,yBAAyB,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,mCAAmC;QACtH,aAAa,EAAE,eAAe;QAC9B,kBAAkB,EAAE,mBAAmB;QACvC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["import { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport { LLM_Model } from '@wildo-ai/external-connectors-models';\nimport type { LanguageModelAgentClientProtocolRoute } from '@wildo-ai/saas-backend-lib';\n\nimport { APPLICATION_CODING_AGENT_BINDINGS } from '../../meta-workflows/models/application-coding-agent.actors-system.definitions';\nimport { InFlightWorkHeartbeat } from './in-flight-work-heartbeat.companion';\n\n/**\n * Where the companion's language-model calls run (#3472): Claude Code over ACP, on Opus 5.5, by default.\n *\n * Decided by Paul, 2026-11-08, after the creation lane's cost on a metered Anthropic API key exploded: one reference\n * run made 177 calls for 7.3 M input and 1.9 M output tokens, all on the API, because the lane had been switched to\n * Claude through its API key rather than through the developer's own coding agent. The companion's text and structured\n * calls — every playbook generator, judge, panel and selector, labelling, e-mail templates — now run on the developer's\n * Claude Code login. Image generation stays on OpenAI's API (no ACP agent generates images).\n *\n * `WILDO_LANGUAGE_MODEL_TRANSPORT=api` keeps every call on the API keys, for a machine with no Claude Code login.\n */\nexport enum CompanionLanguageModelTransport {\n /** The developer's own coding agent, over the Agent Client Protocol. The default. */\n AGENT_CLIENT_PROTOCOL = 'acp',\n /** The providers' API keys, as before #3472. */\n API = 'api',\n}\n\n/** The model the companion's routed calls run on: Opus 5.5, the model its coding and research lane already uses. */\nexport const COMPANION_LANGUAGE_MODEL_ROUTE_MODEL = LLM_Model.CLAUDE_OPUS_5_5;\n\n/**\n * Agents on these providers are routed. Both, so a text call left on OpenAI does not keep spending its API key: the\n * route moves the transport and the model, never the prompt or the schema.\n */\nconst ROUTED_PROVIDER_REFS = ['anthropic', 'openai'] as const;\n\n/**\n * Concurrent sessions. Each one is an adapter process plus a Claude Code process; the lane runs up to three lanes,\n * and a deliberation fans out three candidates and a panel, so four keeps the lane moving without exhausting memory.\n */\nconst DEFAULT_MAXIMUM_CONCURRENT_SESSIONS = 4;\n/** One call, all its turns: the structured-generation total deadline the API path uses (#3204). */\nconst CALL_TIMEOUT_MS = 60 * 60 * 1000;\n/** Refused submissions before a call reports its last refusal to the lane's own correction loop. */\nconst MAXIMUM_SUBMISSIONS = 6;\n\n/**\n * Where this process says \"a routed language-model call is running\", app-root-relative. Beaten while any session of\n * the route is open and removed when none is, so the dev supervisor holds a restart that would kill it (the label and\n * translate runs hold no lock and are no playbook run, so nothing else said so).\n *\n * A COPY of `LANGUAGE_MODEL_RUN_HEARTBEAT_RELATIVE_PATH` in\n * `scripts/dev-orchestrator/runtime-supervisor-lifecycle.mjs`, pinned equal by\n * `scripts/__tests__/runtime-supervisor-workspace-mutation-hold.test.mjs`.\n */\nexport const LANGUAGE_MODEL_RUN_HEARTBEAT_RELATIVE_PATH = '.wildo-saas/state/language-model-run.heartbeat';\n\n/** How often that file's mtime is refreshed; the supervisor judges it stale at three times this (`AGENT_RUN_HEARTBEAT_STALE_MS`). */\nconst LANGUAGE_MODEL_RUN_HEARTBEAT_INTERVAL_MS = 5_000;\n\n/**\n * The route's `onSessionsInFlightChange` for a companion rooted at `saasRoot`: the heartbeat file exists exactly while\n * a routed session is open.\n */\nexport function createLanguageModelRunHeartbeatReporter(\n saasRoot: string,\n reportFailure: (message: string, error: unknown) => void,\n): (sessionsInFlight: number) => void {\n const heartbeat = new InFlightWorkHeartbeat(join(saasRoot, LANGUAGE_MODEL_RUN_HEARTBEAT_RELATIVE_PATH), LANGUAGE_MODEL_RUN_HEARTBEAT_INTERVAL_MS, reportFailure);\n return (sessionsInFlight) => heartbeat.sync(sessionsInFlight > 0);\n}\n\nexport function resolveCompanionLanguageModelTransport(environment: NodeJS.ProcessEnv = process.env): CompanionLanguageModelTransport {\n const declared = environment.WILDO_LANGUAGE_MODEL_TRANSPORT?.trim().toLowerCase();\n if (declared === undefined || declared === '') return CompanionLanguageModelTransport.AGENT_CLIENT_PROTOCOL;\n if (declared === CompanionLanguageModelTransport.API) return CompanionLanguageModelTransport.API;\n if (declared === CompanionLanguageModelTransport.AGENT_CLIENT_PROTOCOL) return CompanionLanguageModelTransport.AGENT_CLIENT_PROTOCOL;\n throw new Error(`WILDO_LANGUAGE_MODEL_TRANSPORT=\"${declared}\" is neither \"acp\" nor \"api\".`);\n}\n\n/** The route the companion installs, or undefined when its calls stay on the API keys. */\nexport function resolveCompanionLanguageModelRoute(\n environment: NodeJS.ProcessEnv = process.env,\n onSessionsInFlightChange?: (sessionsInFlight: number) => void,\n): LanguageModelAgentClientProtocolRoute | undefined {\n if (resolveCompanionLanguageModelTransport(environment) === CompanionLanguageModelTransport.API) return undefined;\n const sessions = Number.parseInt(environment.WILDO_LANGUAGE_MODEL_SESSIONS ?? '', 10);\n const binding = APPLICATION_CODING_AGENT_BINDINGS.anthropic;\n if (binding === undefined) throw new Error('The companion declares no anthropic coding-agent binding to route its language-model calls through.');\n return {\n acpProviderRef: binding.providerRef,\n executionProfileRef: binding.executionProfileRef,\n model: COMPANION_LANGUAGE_MODEL_ROUTE_MODEL,\n routedProviderRefs: ROUTED_PROVIDER_REFS,\n // Outside every application workspace, so a session can never read or write the application it writes FOR.\n scratchDirectory: join(tmpdir(), 'wildo-language-model-sessions'),\n maximumConcurrentSessions: Number.isInteger(sessions) && sessions > 0 ? sessions : DEFAULT_MAXIMUM_CONCURRENT_SESSIONS,\n callTimeoutMs: CALL_TIMEOUT_MS,\n maximumSubmissions: MAXIMUM_SUBMISSIONS,\n ...(onSessionsInFlightChange ? { onSessionsInFlightChange } : {}),\n };\n}\n"]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drain before a held restart (#3204; #265's first candidate shape, never built until now).
|
|
3
|
+
*
|
|
4
|
+
* `wildo local dev` runs the companion under `runtime-supervisor.mjs`, which HOLDS a restart (a dependency install, an
|
|
5
|
+
* engine rebuild) while work is in flight, because the restart kills the companion's process tree. During an unattended
|
|
6
|
+
* build a playbook run is always in flight, so the hold only ever ended at its ceiling (`HOLD_EXCEEDED`, 65 min), which
|
|
7
|
+
* then killed the wave's live coding runs: reference run 43237839187 lost nine at 15:43. Nothing told the companion a
|
|
8
|
+
* restart was waiting, so it kept starting work.
|
|
9
|
+
*
|
|
10
|
+
* Now the supervisor publishes the held restart in its observation, and this module answers three things for the rest of
|
|
11
|
+
* the companion:
|
|
12
|
+
* - {@link CompanionRestartDrain.isRestartHeld}: the build wave stops filling (`ApplicationBuildWaveStop.RESTART_PENDING`);
|
|
13
|
+
* - {@link CompanionRestartDrain.awaitRestartWindow}: the creation loop and every choreography wait at the TOP of each
|
|
14
|
+
* round, before reading the tree or asking a model, until the restart comes (the process ends) or the hold is withdrawn;
|
|
15
|
+
* - when nothing is BUSY, the companion writes its drained marker, `{ pid, at }`, every few seconds. The supervisor's
|
|
16
|
+
* `decideRestartHold` reads it as `DRAINED` and restarts at once.
|
|
17
|
+
*
|
|
18
|
+
* ## What counts as busy (review F1 of the first draft, which counted leaves only)
|
|
19
|
+
*
|
|
20
|
+
* EVERY run is counted for its whole life ({@link CompanionRestartDrain.whileWorking}, at the same entry points that beat
|
|
21
|
+
* the playbook-run heartbeat, settle included): a composite does work of its own between children (merging, a checkpoint,
|
|
22
|
+
* a tree read, the selector's model call), and a run's record is written after its work returns. A run stops being busy
|
|
23
|
+
* only while it is PAUSED: parked at the restart window, or waiting on the children its round dispatched
|
|
24
|
+
* ({@link CompanionRestartDrain.whilePaused}), each of which is counted itself. Busy is runs minus pauses; drained is none
|
|
25
|
+
* busy. A nested lane, which runs inside its parent's round rather than as a run of its own, is counted by the runtime
|
|
26
|
+
* through the same port. Agents (coding, research) keep their own heartbeats, which the supervisor checks first.
|
|
27
|
+
*
|
|
28
|
+
* The marker is deleted the moment anything becomes busy again, so a stale "drained" can never cover work that started
|
|
29
|
+
* after it (review F4).
|
|
30
|
+
*/
|
|
31
|
+
/** A COPY of `COMPANION_DRAINED_FOR_RESTART_RELATIVE_PATH` in `scripts/dev-orchestrator/runtime-supervisor-lifecycle.mjs`. */
|
|
32
|
+
export declare const COMPANION_DRAINED_FOR_RESTART_RELATIVE_PATH = ".wildo-saas/runtime-signals/wildo-dev-companion.drained-for-restart.json";
|
|
33
|
+
/** How often a parked loop re-reads the hold and the companion rewrites its drained marker. Under the supervisor's 30 s freshness. */
|
|
34
|
+
export declare const RESTART_DRAIN_POLL_MS = 5000;
|
|
35
|
+
/**
|
|
36
|
+
* The longest a round waits at the restart window (review F3): the supervisor's own ceiling (`CODING_RUN_HARD_MAX_MS`
|
|
37
|
+
* 60 min + 5 min margin), past which it restarts anyway. A hold still published after it is a supervisor fault, and the
|
|
38
|
+
* round goes on rather than parking the creation for ever.
|
|
39
|
+
*/
|
|
40
|
+
export declare const RESTART_WINDOW_CEILING_MS: number;
|
|
41
|
+
/** A restart the running supervisor holds for this process. */
|
|
42
|
+
export interface HeldCompanionRestart {
|
|
43
|
+
readonly since: string;
|
|
44
|
+
readonly reason: string | null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The restart the supervisor running THIS process holds, or `undefined`. Counted only when the observation names this
|
|
48
|
+
* process as its child and its producer is alive, as `requestCompanionRestart` reads the same file: a record left by a
|
|
49
|
+
* supervisor that has exited, or describing another companion, must never park this one.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readHeldCompanionRestart(saasRoot: string, options?: {
|
|
52
|
+
readonly processId?: number;
|
|
53
|
+
readonly isProcessAlive?: (pid: number) => boolean;
|
|
54
|
+
}): HeldCompanionRestart | undefined;
|
|
55
|
+
/** See the module comment. One per process ({@link companionRestartDrain}); constructed directly by tests. */
|
|
56
|
+
export declare class CompanionRestartDrain {
|
|
57
|
+
private readonly options;
|
|
58
|
+
private workInFlight;
|
|
59
|
+
private paused;
|
|
60
|
+
private saasRoot;
|
|
61
|
+
private ticker;
|
|
62
|
+
private cached;
|
|
63
|
+
constructor(options?: {
|
|
64
|
+
readonly now?: () => number;
|
|
65
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
66
|
+
readonly processId?: number;
|
|
67
|
+
readonly isProcessAlive?: (pid: number) => boolean;
|
|
68
|
+
/** Tests drive {@link tick} themselves. */
|
|
69
|
+
readonly withoutTicker?: boolean;
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* The restart held for this process right now, or `undefined`; read at most every {@link OBSERVATION_CACHE_MS}. A hold
|
|
73
|
+
* published for longer than {@link RESTART_WINDOW_CEILING_MS} is a supervisor fault and is NOT held here (second review
|
|
74
|
+
* H2): one predicate for every reader, so a wave does not stop filling for ever after the window let its loop go on.
|
|
75
|
+
*/
|
|
76
|
+
heldRestart(saasRoot: string): HeldCompanionRestart | undefined;
|
|
77
|
+
/** What the supervisor publishes, ceiling not applied. */
|
|
78
|
+
private publishedRestart;
|
|
79
|
+
isRestartHeld(saasRoot: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Count work as in flight from NOW until the returned release is called (idempotent): for a run whose life spans a
|
|
82
|
+
* detached chain, counted before its first await so no marker is written between its start and its count (review L1).
|
|
83
|
+
*/
|
|
84
|
+
begin(saasRoot: string): () => void;
|
|
85
|
+
/** Run work counted as in flight for its whole life: busy, unless it is paused. */
|
|
86
|
+
whileWorking<T>(saasRoot: string, work: () => Promise<T>): Promise<T>;
|
|
87
|
+
/** Run `work` while the counted run calling it is PAUSED: it waits on children that are counted themselves. */
|
|
88
|
+
whilePaused<T>(work: () => Promise<T>): Promise<T>;
|
|
89
|
+
/**
|
|
90
|
+
* Wait at a round boundary while a restart is held: return at once when none is, and otherwise only once the hold is
|
|
91
|
+
* withdrawn. Normally it never returns: the supervisor reads the drained marker and restarts the process.
|
|
92
|
+
*/
|
|
93
|
+
awaitRestartWindow(saasRoot: string, onParked?: (held: HeldCompanionRestart) => void, onCeiling?: (held: HeldCompanionRestart) => void): Promise<void>;
|
|
94
|
+
/** Write the drained marker when a restart is held and nothing is busy. Called by the ticker and when a round parks. */
|
|
95
|
+
tick(): void;
|
|
96
|
+
/** How many counted runs are busy (in flight and not paused). For tests and logs. */
|
|
97
|
+
busy(): number;
|
|
98
|
+
/** Apply a change to the counts, deleting the drained marker the moment something becomes busy (review F4). */
|
|
99
|
+
private changeCounts;
|
|
100
|
+
private pastCeiling;
|
|
101
|
+
private attach;
|
|
102
|
+
private now;
|
|
103
|
+
private sleep;
|
|
104
|
+
}
|
|
105
|
+
/** The process's drain: one supervisor watches one companion process. */
|
|
106
|
+
export declare const companionRestartDrain: CompanionRestartDrain;
|
|
107
|
+
//# sourceMappingURL=restart-drain.companion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restart-drain.companion.d.ts","sourceRoot":"","sources":["../../../../src/core/runtime/restart-drain.companion.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,8HAA8H;AAC9H,eAAO,MAAM,2CAA2C,6EAA6E,CAAC;AAKtI,sIAAsI;AACtI,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAK3C;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,QAAc,CAAC;AAErD,+DAA+D;AAC/D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAWD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CAAO,GAChG,oBAAoB,GAAG,SAAS,CAclC;AAED,8GAA8G;AAC9G,qBAAa,qBAAqB;IAOb,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN3C,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,MAAM,CAA6C;IAC3D,OAAO,CAAC,MAAM,CAA6F;gBAEvE,OAAO,GAAE;QAC3C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;QAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KA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