@wildo-ai/dev-companion 1.1.14 → 1.1.16
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 +233 -6
- 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 +316 -13
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
- package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts +48 -2
- package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts.map +1 -1
- package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js +41 -3
- package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js.map +1 -1
- package/dist/esm/claude-cli/models/isolated-recheck-interference.models.d.ts +68 -0
- package/dist/esm/claude-cli/models/isolated-recheck-interference.models.d.ts.map +1 -0
- package/dist/esm/claude-cli/models/isolated-recheck-interference.models.js +198 -0
- package/dist/esm/claude-cli/models/isolated-recheck-interference.models.js.map +1 -0
- package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts +6 -0
- package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts.map +1 -1
- package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.js.map +1 -1
- package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts +19 -5
- package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts.map +1 -1
- package/dist/esm/claude-cli/models/verification-tool-availability.models.js +17 -5
- package/dist/esm/claude-cli/models/verification-tool-availability.models.js.map +1 -1
- package/dist/esm/claude-cli/models/workspace-path-claims.models.d.ts +138 -0
- package/dist/esm/claude-cli/models/workspace-path-claims.models.d.ts.map +1 -0
- package/dist/esm/claude-cli/models/workspace-path-claims.models.js +204 -0
- package/dist/esm/claude-cli/models/workspace-path-claims.models.js.map +1 -0
- package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts +36 -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 +71 -16
- 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 +234 -9
- 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 +1073 -182
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
- package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts +14 -0
- package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts.map +1 -1
- package/dist/esm/claude-cli/services/research-evidence-store.companion.js +35 -0
- package/dist/esm/claude-cli/services/research-evidence-store.companion.js.map +1 -1
- package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts +36 -0
- package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts.map +1 -0
- package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js +134 -0
- package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js.map +1 -0
- package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.js +7 -1
- package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
- package/dist/esm/core/introspection/resources/creation-home-projection.companion.js +1 -1
- package/dist/esm/core/introspection/resources/creation-home-projection.companion.js.map +1 -1
- package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts +3 -2
- package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/services/translation-placement.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/subprocess/app-shell-placement-content.behavior.d.ts +13 -0
- package/dist/esm/core/introspection/subprocess/app-shell-placement-content.behavior.d.ts.map +1 -1
- package/dist/esm/core/introspection/subprocess/app-shell-placement-content.behavior.js +98 -16
- package/dist/esm/core/introspection/subprocess/app-shell-placement-content.behavior.js.map +1 -1
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.d.ts.map +1 -1
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js +24 -14
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js.map +1 -1
- package/dist/esm/core/introspection/workspace-element-index.companion.d.ts +42 -0
- package/dist/esm/core/introspection/workspace-element-index.companion.d.ts.map +1 -1
- package/dist/esm/core/introspection/workspace-element-index.companion.js +42 -0
- package/dist/esm/core/introspection/workspace-element-index.companion.js.map +1 -1
- package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +53 -0
- package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -1
- package/dist/esm/core/runtime/dev-compile-quiet.companion.js +119 -2
- package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -1
- 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 +13 -1
- package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
- package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts +2 -2
- package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts.map +1 -1
- package/dist/esm/core/runtime/utils/companion-platform-config.companion.js +6 -6
- package/dist/esm/core/runtime/utils/companion-platform-config.companion.js.map +1 -1
- package/dist/esm/email/services/email-template.companion.service.d.ts +5 -0
- package/dist/esm/email/services/email-template.companion.service.d.ts.map +1 -1
- package/dist/esm/email/services/email-template.companion.service.js +44 -11
- package/dist/esm/email/services/email-template.companion.service.js.map +1 -1
- package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts +26 -2
- package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts.map +1 -1
- package/dist/esm/email/utils/email-template-fs-discovery.utils.js +41 -2
- package/dist/esm/email/utils/email-template-fs-discovery.utils.js.map +1 -1
- package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts +19 -0
- package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts.map +1 -0
- package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js +171 -0
- package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js.map +1 -0
- package/dist/esm/email/utils/module-email-root.companion.utils.d.ts +75 -0
- package/dist/esm/email/utils/module-email-root.companion.utils.d.ts.map +1 -0
- package/dist/esm/email/utils/module-email-root.companion.utils.js +162 -0
- package/dist/esm/email/utils/module-email-root.companion.utils.js.map +1 -0
- package/dist/esm/expert-personas/services/expert-persona.companion.service.d.ts +21 -1
- package/dist/esm/expert-personas/services/expert-persona.companion.service.d.ts.map +1 -1
- package/dist/esm/expert-personas/services/expert-persona.companion.service.js +35 -3
- package/dist/esm/expert-personas/services/expert-persona.companion.service.js.map +1 -1
- package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.d.ts +62 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.d.ts.map +1 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.js +62 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.js.map +1 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.d.ts +62 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.d.ts.map +1 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.js +62 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.js.map +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts.map +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchAspects.en.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchAspects.en.js +4 -0
- package/dist/esm/i18n/resources/workbenchAspects.en.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +35 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +12 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts +536 -531
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts.map +1 -1
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js +536 -531
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js.map +1 -1
- package/dist/esm/i18n/system_enums/workbench-build.en.d.ts +3 -3
- package/dist/esm/i18n/system_enums/workbench-build.en.js +3 -3
- package/dist/esm/i18n/system_enums/workbench-build.en.js.map +1 -1
- package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.d.ts.map +1 -1
- package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js +7 -3
- package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/models/carried-verification-failure.models.d.ts +23 -0
- package/dist/esm/meta-workflows/models/carried-verification-failure.models.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/carried-verification-failure.models.js +14 -0
- package/dist/esm/meta-workflows/models/carried-verification-failure.models.js.map +1 -1
- package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts +21 -1
- package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js +117 -3
- package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.d.ts +5 -0
- package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.js +22 -1
- package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +98 -24
- 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 +439 -93
- 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 +21 -8
- 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 +74 -12
- 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 +47 -1
- 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 +98 -9
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts +39 -3
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js +224 -48
- package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.d.ts +45 -0
- package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.js +74 -0
- package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts +12 -0
- package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js +30 -1
- package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js.map +1 -1
- 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 +21 -2
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +71 -5
- 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 +219 -17
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts +55 -1
- package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js +157 -10
- package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js.map +1 -1
- package/dist/esm/meta-workflows/services/website-demo-facts.models.d.ts +19 -1
- package/dist/esm/meta-workflows/services/website-demo-facts.models.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/website-demo-facts.models.js +7 -5
- package/dist/esm/meta-workflows/services/website-demo-facts.models.js.map +1 -1
- package/dist/esm/module-layout/module-layout-convention.companion.d.ts +158 -0
- package/dist/esm/module-layout/module-layout-convention.companion.d.ts.map +1 -0
- package/dist/esm/module-layout/module-layout-convention.companion.js +272 -0
- package/dist/esm/module-layout/module-layout-convention.companion.js.map +1 -0
- package/dist/esm/module-layout/module-layout-inspection.companion.d.ts +42 -0
- package/dist/esm/module-layout/module-layout-inspection.companion.d.ts.map +1 -0
- package/dist/esm/module-layout/module-layout-inspection.companion.js +290 -0
- package/dist/esm/module-layout/module-layout-inspection.companion.js.map +1 -0
- package/dist/esm/module-layout/module-source-files.companion.d.ts +3 -0
- package/dist/esm/module-layout/module-source-files.companion.d.ts.map +1 -0
- package/dist/esm/module-layout/module-source-files.companion.js +45 -0
- package/dist/esm/module-layout/module-source-files.companion.js.map +1 -0
- package/dist/esm/technical-doc/services/technical-documentation-pilot.companion.service.d.ts +2 -0
- package/dist/esm/technical-doc/services/technical-documentation-pilot.companion.service.d.ts.map +1 -1
- package/dist/esm/technical-doc/services/technical-documentation-pilot.companion.service.js +3 -1
- package/dist/esm/technical-doc/services/technical-documentation-pilot.companion.service.js.map +1 -1
- package/package.json +17 -17
|
@@ -17,11 +17,17 @@ export declare enum VerificationHostCause {
|
|
|
17
17
|
*/
|
|
18
18
|
COMMAND_LACKS_VERB = "command-lacks-verb",
|
|
19
19
|
/**
|
|
20
|
-
* The same check could not be asked, with the same host message, on two DISTINCT tasks
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* The same check could not be asked, with the same host message, on two DISTINCT tasks (#3432): whatever the cause, it
|
|
21
|
+
* is the host's and it repeats, so a third task would meet it too. Mostly no free probe exists, so the hold is re-asked:
|
|
22
|
+
* an admission after {@link VerificationToolUnavailableHold.reaskAfter} is let through, and the same failure holds again
|
|
23
|
+
* at once. A compiled model behind its sources is the exception: its compile record is a free probe (below). A cause only
|
|
24
|
+
* ONE task meets is bounded per task instead (`MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS`).
|
|
25
|
+
*
|
|
26
|
+
* Every run counts, alone or beside siblings, and so does a wave's isolated re-check (run 43961156770). Only runs alone
|
|
27
|
+
* counted until then, on the reasoning that beside siblings the cause may be a sibling's half-written file (#3204); at a
|
|
28
|
+
* parallelism of ten no run was alone, the hold never opened, and a dead compile watcher cost 89 runs. A hold opened on
|
|
29
|
+
* a sibling's transient cause ends as soon as any run, or the wave's re-check, ASKS the check, and one on a compiled
|
|
30
|
+
* model behind its sources ({@link VerificationToolUnavailableHold.stalePackage}) as soon as that package compiles.
|
|
25
31
|
*/
|
|
26
32
|
REPEATED_HOST_FAILURE = "repeated-host-failure"
|
|
27
33
|
}
|
|
@@ -98,6 +104,14 @@ export interface VerificationToolUnavailableHold {
|
|
|
98
104
|
readonly metOnTaskRefs?: readonly string[];
|
|
99
105
|
/** {@link VerificationHostCause.REPEATED_HOST_FAILURE}: from this instant the next admission re-asks the host. */
|
|
100
106
|
readonly reaskAfter?: string;
|
|
107
|
+
/**
|
|
108
|
+
* {@link VerificationHostCause.REPEATED_HOST_FAILURE} whose check could not be asked because this application package's
|
|
109
|
+
* compiled model is behind its sources (`shared-lib`, run 43961156770). Its probe is free: a read of the hold asks the
|
|
110
|
+
* package's compile record (at most once per poll interval), and the hold ends as soon as the package reads compiled
|
|
111
|
+
* current, before `reaskAfter`. Once per successful compile: a reading the CLI still refuses releases one admission, not
|
|
112
|
+
* every read.
|
|
113
|
+
*/
|
|
114
|
+
readonly stalePackage?: string;
|
|
101
115
|
}
|
|
102
116
|
/**
|
|
103
117
|
* The cause in one sentence, with its remedy (#3432): the subject of the Home line, the build wave's guidance and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification-tool-availability.models.d.ts","sourceRoot":"","sources":["../../../../src/claude-cli/models/verification-tool-availability.models.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,oBAAY,qBAAqB;IAC/B;;;OAGG;IACH,cAAc,mBAAmB;IACjC;;;;;OAKG;IACH,kBAAkB,uBAAuB;IACzC
|
|
1
|
+
{"version":3,"file":"verification-tool-availability.models.d.ts","sourceRoot":"","sources":["../../../../src/claude-cli/models/verification-tool-availability.models.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,oBAAY,qBAAqB;IAC/B;;;OAGG;IACH,cAAc,mBAAmB;IACjC;;;;;OAKG;IACH,kBAAkB,uBAAuB;IACzC;;;;;;;;;;;;OAYG;IACH,qBAAqB,0BAA0B;CAChD;AAED,2JAA2J;AAC3J,eAAO,MAAM,kCAAkC,QAAiB,CAAC;AAEjE;;;;;;;;;GASG;AACH,qBAAa,gCAAiC,SAAQ,KAAK;IACzD,gGAAgG;IAChG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wFAAwF;IACxF,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC,cAAc,GAAG,qBAAqB,CAAC,kBAAkB,CAAC;IACpG,kIAAkI;IAClI,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE;QAAE,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE;CAOxG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAEzK;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAChD,OAAO,EAAE;IAAE,QAAQ,CAAC,OAA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,0CAA0C,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,+BAA+B,GAAG,MAAM,CAWzH"}
|
|
@@ -20,11 +20,17 @@ export var VerificationHostCause;
|
|
|
20
20
|
*/
|
|
21
21
|
VerificationHostCause["COMMAND_LACKS_VERB"] = "command-lacks-verb";
|
|
22
22
|
/**
|
|
23
|
-
* The same check could not be asked, with the same host message, on two DISTINCT tasks
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
23
|
+
* The same check could not be asked, with the same host message, on two DISTINCT tasks (#3432): whatever the cause, it
|
|
24
|
+
* is the host's and it repeats, so a third task would meet it too. Mostly no free probe exists, so the hold is re-asked:
|
|
25
|
+
* an admission after {@link VerificationToolUnavailableHold.reaskAfter} is let through, and the same failure holds again
|
|
26
|
+
* at once. A compiled model behind its sources is the exception: its compile record is a free probe (below). A cause only
|
|
27
|
+
* ONE task meets is bounded per task instead (`MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS`).
|
|
28
|
+
*
|
|
29
|
+
* Every run counts, alone or beside siblings, and so does a wave's isolated re-check (run 43961156770). Only runs alone
|
|
30
|
+
* counted until then, on the reasoning that beside siblings the cause may be a sibling's half-written file (#3204); at a
|
|
31
|
+
* parallelism of ten no run was alone, the hold never opened, and a dead compile watcher cost 89 runs. A hold opened on
|
|
32
|
+
* a sibling's transient cause ends as soon as any run, or the wave's re-check, ASKS the check, and one on a compiled
|
|
33
|
+
* model behind its sources ({@link VerificationToolUnavailableHold.stalePackage}) as soon as that package compiles.
|
|
28
34
|
*/
|
|
29
35
|
VerificationHostCause["REPEATED_HOST_FAILURE"] = "repeated-host-failure";
|
|
30
36
|
})(VerificationHostCause || (VerificationHostCause = {}));
|
|
@@ -95,6 +101,12 @@ export function describeVerificationHostCause(held) {
|
|
|
95
101
|
return `The installed \`${held.command ?? 'wildo'}\` does not know \`${(held.verbProbeArgs ?? []).filter((arg) => arg !== '--help').join(' ')}\`, `
|
|
96
102
|
+ `so ${held.checkRef} cannot run for any task. Update it to the companion's version: the hold ends as soon as it answers the verb.`;
|
|
97
103
|
case VerificationHostCause.REPEATED_HOST_FAILURE:
|
|
104
|
+
if (held.stalePackage !== undefined) {
|
|
105
|
+
return `${held.checkRef} could not be asked, the same way, on ${(held.metOnTaskRefs ?? [held.taskRef]).join(' and ')}: `
|
|
106
|
+
+ `${held.stalePackage}'s compiled output is behind its sources, so the check reads a model nobody edited. ${held.message} `
|
|
107
|
+
+ `The build waits for ${held.stalePackage} to compile (a stopped compile watcher must be running again; a failed compile `
|
|
108
|
+
+ `must be fixed): the hold ends as soon as it is compiled current, and the build asks again from ${held.reaskAfter ?? 'the next admission'} at the latest.`;
|
|
109
|
+
}
|
|
98
110
|
return `${held.checkRef} could not be asked, the same way, on ${(held.metOnTaskRefs ?? [held.taskRef]).join(' and ')}: ${held.message} `
|
|
99
111
|
+ `Repair what the message names; the build asks again from ${held.reaskAfter ?? 'the next admission'}.`;
|
|
100
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification-tool-availability.models.js","sourceRoot":"","sources":["../../../../src/claude-cli/models/verification-tool-availability.models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAN,IAAY,qBAqBX;AArBD,WAAY,qBAAqB;IAC/B;;;OAGG;IACH,0DAAiC,CAAA;IACjC;;;;;OAKG;IACH,kEAAyC,CAAA;IACzC;;;;;;OAMG;IACH,wEAA+C,CAAA;AACjD,CAAC,EArBW,qBAAqB,KAArB,qBAAqB,QAqBhC;AAED,2JAA2J;AAC3J,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEjE;;;;;;;;;GASG;AACH,MAAM,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AAI,CAAC,QAAQ,2BAA2B;cAC7I,aAAa,IAAI,CAAC,OAAO,OAAO,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,OAAO,2BAA2B;cAC3F,wIAAwI;cACxI,wCAAwC;cACxC,mFAAmF,IAAI,CAAC,OAAO,uCAAuC,CAAC;IAC7I,CAAC;IACD,OAAO,eAAe,OAAO,qBAAqB,6BAA6B,CAAC,IAAI,CAAC,wBAAwB;UACzG,WAAW,IAAI,CAAC,OAAO,OAAO,IAAI,CAAC,UAAU,KAAK;UAClD,sFAAsF,IAAI,CAAC,OAAO,uCAAuC,CAAC;AAChJ,CAAC","sourcesContent":["import { accessSync, constants as fsConstants } from 'node:fs';\nimport { delimiter, join } from 'node:path';\n\n/**\n * WHY a verification check cannot be asked for a reason the HOST owns that will not clear between two runs (#3423,\n * #3432). Each cause has its own release, which a reader can trigger, because an unattended drive stops on the Home line\n * before any admission happens.\n */\nexport enum VerificationHostCause {\n /**\n * The check's command cannot be executed: absent from the PATH the check spawns with (#3423). Opened on the first run,\n * since its probe is free: a PATH lookup, made by every read of the hold.\n */\n COMMAND_ABSENT = 'command-absent',\n /**\n * The command runs and does not know the verb the check asks: an installed `wildo` older than the companion answers\n * `config check-resources` with \"Unknown command\" (#3432). A PATH lookup would find it and release at once, so its probe\n * asks the command for the verb (`--help`), in the background of a read and at once before an admission. Opened on the\n * first run, like an absent command: the probe costs a CLI start, never a coding turn.\n */\n COMMAND_LACKS_VERB = 'command-lacks-verb',\n /**\n * The same check could not be asked, with the same host message, on two DISTINCT tasks each run alone (#3432): whatever\n * the cause, it is the host's and it repeats, so a third task would meet it too. No free probe exists, so the hold is\n * re-asked: an admission after {@link VerificationToolUnavailableHold.reaskAfter} is let through, and the same failure\n * holds again at once. Only runs ALONE count: a check that cannot be asked beside siblings may be a sibling's half-written\n * file (#3204), which the wave's isolated re-check settles, never a cause of the host's.\n */\n REPEATED_HOST_FAILURE = 'repeated-host-failure',\n}\n\n/** How long a {@link VerificationHostCause.REPEATED_HOST_FAILURE} hold refuses before one admission re-asks the host, as the account-refusal hold does. */\nexport const VERIFICATION_HOST_FAILURE_REASK_MS = 30 * 60 * 1000;\n\n/**\n * A verification check could not be ASKED because the command it runs could not be executed (#3423): the\n * executable is absent from the PATH the check spawns with — or, since #3432, is there and lacks the verb the check\n * asks ({@link VerificationHostCause.COMMAND_LACKS_VERB}).\n *\n * Distinct from every other \"could not ask\" (a compiled model behind its sources, an absent backend dist, a runner\n * that crashed): those can clear on their own between two runs, and the per-task host forgiveness absorbs them. An\n * absent executable cannot, and it fails every task's check the same way. Measured on reference run 42202387917:\n * `spawn wildo ENOENT` failed nine tasks' `check:resources-registry-init`, 39 attempts in 17 minutes, about $100.\n */\nexport class VerificationToolUnavailableError extends Error {\n /** The command the check spawns, as it was named: looked up on PATH to know when it is back. */\n readonly command: string;\n /** Which of the command's two failures this is: absent, or present without the verb. */\n readonly hostCause: VerificationHostCause.COMMAND_ABSENT | VerificationHostCause.COMMAND_LACKS_VERB;\n /** {@link VerificationHostCause.COMMAND_LACKS_VERB} only: the arguments that ask the command for the verb, ending in `--help`. */\n readonly verbProbeArgs?: readonly string[];\n\n constructor(command: string, message: string, lacksVerb?: { readonly verbProbeArgs: readonly string[] }) {\n super(message);\n this.name = 'VerificationToolUnavailableError';\n this.command = command;\n this.hostCause = lacksVerb ? VerificationHostCause.COMMAND_LACKS_VERB : VerificationHostCause.COMMAND_ABSENT;\n if (lacksVerb) this.verbProbeArgs = lacksVerb.verbProbeArgs;\n }\n}\n\n/**\n * Does the command's answer to a verb probe say it KNOWS the verb (#3432)? Exit 0 and no \"Unknown command\": an older\n * `wildo` exits 1 with `Unknown command: \"config\"`. A CLI that printed general help for a verb it does not know would\n * release the hold wrongly, and the next run would hold again at once: one run, never a lockout.\n */\nexport function verbProbeKnowsTheVerb(outcome: { readonly success: boolean; readonly message: string; readonly stdoutTail: string; readonly stderrTail: string }): boolean {\n return outcome.success && !/Unknown command/iu.test(`${outcome.message}\\n${outcome.stdoutTail}\\n${outcome.stderrTail}`);\n}\n\n/**\n * A host check failure's message with what differs between two runs of the same cause taken out (#3432): numbers\n * (durations, pids, counts, ports) and whitespace. Two tasks meeting one cause print the same message but for those.\n */\nexport function normalizeHostCheckFailureMessage(message: string): string {\n return message.replace(/\\d+/gu, '#').replace(/\\s+/gu, ' ').trim().slice(0, 400);\n}\n\n/**\n * Throw a {@link VerificationToolUnavailableError} when a check's outcome says its command could not be executed.\n * One function for every check that spawns a CLI, so the classification cannot drift between them.\n *\n * `absent` matches the spawn error in the outcome's message: `ENOENT` by default (Node's \"spawn x ENOENT\").\n */\nexport function refuseWhenVerificationToolIsAbsent(\n outcome: { readonly success: boolean; readonly message: string },\n input: { readonly command: string; readonly checking: string; readonly absent?: RegExp },\n): void {\n if (outcome.success || !(input.absent ?? /\\bENOENT\\b/).test(outcome.message)) return;\n throw new VerificationToolUnavailableError(\n input.command,\n `Cannot ${input.checking}: the \\`${input.command}\\` CLI could not be executed (${outcome.message}).`,\n );\n}\n\n/**\n * What holds coding admissions while a verification check cannot be asked for a host cause that will not clear on its\n * own (#3423, #3432): which cause, which command (when the cause is one), which check met it, the check's own message,\n * and the run that met it.\n */\nexport interface VerificationToolUnavailableHold {\n readonly hostCause: VerificationHostCause;\n /** The command the check spawns, for the two command causes; absent for a repeated failure, which may spawn none. */\n readonly command?: string;\n /** {@link VerificationHostCause.COMMAND_LACKS_VERB}: the arguments that ask the command for the verb. */\n readonly verbProbeArgs?: readonly string[];\n readonly checkRef: string;\n readonly message: string;\n readonly taskRef: string;\n readonly runTaskId: string;\n readonly observedAt: string;\n /** {@link VerificationHostCause.REPEATED_HOST_FAILURE}: every task the cause was met on, `taskRef` among them. */\n readonly metOnTaskRefs?: readonly string[];\n /** {@link VerificationHostCause.REPEATED_HOST_FAILURE}: from this instant the next admission re-asks the host. */\n readonly reaskAfter?: string;\n}\n\n/**\n * The cause in one sentence, with its remedy (#3432): the subject of the Home line, the build wave's guidance and the\n * drive's stop all say this, so the three cannot disagree about what holds the build or how it ends.\n */\nexport function describeVerificationHostCause(held: VerificationToolUnavailableHold): string {\n switch (held.hostCause) {\n case VerificationHostCause.COMMAND_ABSENT:\n return `\\`${held.command ?? 'a command'}\\` is not on the companion's PATH, so ${held.checkRef} cannot run for any task. `\n + 'Install it in a directory on that PATH, or restart the companion with one: the hold ends as soon as it is found.';\n case VerificationHostCause.COMMAND_LACKS_VERB:\n return `The installed \\`${held.command ?? 'wildo'}\\` does not know \\`${(held.verbProbeArgs ?? []).filter((arg) => arg !== '--help').join(' ')}\\`, `\n + `so ${held.checkRef} cannot run for any task. Update it to the companion's version: the hold ends as soon as it answers the verb.`;\n case VerificationHostCause.REPEATED_HOST_FAILURE:\n return `${held.checkRef} could not be asked, the same way, on ${(held.metOnTaskRefs ?? [held.taskRef]).join(' and ')}: ${held.message} `\n + `Repair what the message names; the build asks again from ${held.reaskAfter ?? 'the next admission'}.`;\n }\n}\n\n/**\n * The first executable `command` on `pathValue`, as a spawn by bare name finds it (with the Windows command suffixes),\n * or `null`. The probe that ends the hold: free, and asked of the same PATH the verification subprocess receives.\n *\n * A command written as a path (`./bin/wildo`, `/usr/local/bin/wildo`) is not searched on PATH, as a spawn does not\n * search it: it is checked where it is. What the lookup cannot see: an executable that is found but still fails to spawn\n * with ENOENT (a script whose interpreter is missing). Then the hold ends at every lookup and each run meets it again,\n * which is the per-task forgiveness this hold replaces, never worse.\n */\nexport function resolveExecutableOnPath(\n command: string,\n pathValue: string | undefined = process.env.PATH,\n platform: NodeJS.Platform = process.platform,\n pathExtensions: string | undefined = process.env.PATHEXT,\n): string | null {\n const suffixes = platform === 'win32' ? (pathExtensions ?? '.EXE;.CMD;.BAT').split(';') : [''];\n if (command.includes('/') || (platform === 'win32' && command.includes('\\\\'))) {\n for (const suffix of suffixes) {\n try {\n accessSync(`${command}${suffix}`, fsConstants.X_OK);\n return `${command}${suffix}`;\n } catch {\n // Not executable with this suffix.\n }\n }\n return null;\n }\n for (const directory of (pathValue ?? '').split(platform === 'win32' ? ';' : delimiter).filter(Boolean)) {\n for (const suffix of suffixes) {\n const candidate = join(directory, `${command}${suffix}`);\n try {\n accessSync(candidate, fsConstants.X_OK);\n return candidate;\n } catch {\n // Not in this directory.\n }\n }\n }\n return null;\n}\n\n/**\n * The refusal an admission answers while the hold stands and the command is still absent. Names the cause, the\n * remedy, and the door past a lookup that is wrong: a re-arm for the environment of the task whose run MET the hold,\n * which has a failed run to re-arm (the task being admitted usually has none, and its re-arm would be refused).\n */\nexport function describeVerificationToolUnavailableRefusal(taskRef: string, held: VerificationToolUnavailableHold): string {\n if (held.hostCause === VerificationHostCause.COMMAND_ABSENT) {\n return `Coding task ${taskRef} was not started: \\`${held.command}\\` is not on the companion's PATH, so ${held.checkRef} cannot run for any task `\n + `(found by ${held.taskRef} at ${held.observedAt}: ${held.message}). No attempt was spent. `\n + `Install it into a directory already on the companion's PATH, or restart the companion with a PATH that holds it, then dispatch again: `\n + 'the next admission looks it up first. '\n + `If it is on PATH and this lookup is wrong, end the hold with: wildo build rearm ${held.taskRef} --reason environment --note \"<why>\".`;\n }\n return `Coding task ${taskRef} was not started: ${describeVerificationHostCause(held)} No attempt was spent `\n + `(met by ${held.taskRef} at ${held.observedAt}). `\n + `If the cause is gone and this does not clear, end the hold with: wildo build rearm ${held.taskRef} --reason environment --note \"<why>\".`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"verification-tool-availability.models.js","sourceRoot":"","sources":["../../../../src/claude-cli/models/verification-tool-availability.models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAN,IAAY,qBA2BX;AA3BD,WAAY,qBAAqB;IAC/B;;;OAGG;IACH,0DAAiC,CAAA;IACjC;;;;;OAKG;IACH,kEAAyC,CAAA;IACzC;;;;;;;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AM,CAAC,OAAO,CAAC,EAAE,CAAC;QACxG,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;YAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC,CAAC;YACzD,IAAI,CAAC;gBACH,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxC,OAAO,SAAS,CAAC;YACnB,CAAC;YAAC,MAAM,CAAC;gBACP,yBAAyB;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0CAA0C,CAAC,OAAe,EAAE,IAAqC;IAC/G,IAAI,IAAI,CAAC,SAAS,KAAK,qBAAqB,CAAC,cAAc,EAAE,CAAC;QAC5D,OAAO,eAAe,OAAO,uBAAuB,IAAI,CAAC,OAAO,yCAAyC,IAAI,CAAC,QAAQ,2BAA2B;cAC7I,aAAa,IAAI,CAAC,OAAO,OAAO,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,OAAO,2BAA2B;cAC3F,wIAAwI;cACxI,wCAAwC;cACxC,mFAAmF,IAAI,CAAC,OAAO,uCAAuC,CAAC;IAC7I,CAAC;IACD,OAAO,eAAe,OAAO,qBAAqB,6BAA6B,CAAC,IAAI,CAAC,wBAAwB;UACzG,WAAW,IAAI,CAAC,OAAO,OAAO,IAAI,CAAC,UAAU,KAAK;UAClD,sFAAsF,IAAI,CAAC,OAAO,uCAAuC,CAAC;AAChJ,CAAC","sourcesContent":["import { accessSync, constants as fsConstants } from 'node:fs';\nimport { delimiter, join } from 'node:path';\n\n/**\n * WHY a verification check cannot be asked for a reason the HOST owns that will not clear between two runs (#3423,\n * #3432). Each cause has its own release, which a reader can trigger, because an unattended drive stops on the Home line\n * before any admission happens.\n */\nexport enum VerificationHostCause {\n /**\n * The check's command cannot be executed: absent from the PATH the check spawns with (#3423). Opened on the first run,\n * since its probe is free: a PATH lookup, made by every read of the hold.\n */\n COMMAND_ABSENT = 'command-absent',\n /**\n * The command runs and does not know the verb the check asks: an installed `wildo` older than the companion answers\n * `config check-resources` with \"Unknown command\" (#3432). A PATH lookup would find it and release at once, so its probe\n * asks the command for the verb (`--help`), in the background of a read and at once before an admission. Opened on the\n * first run, like an absent command: the probe costs a CLI start, never a coding turn.\n */\n COMMAND_LACKS_VERB = 'command-lacks-verb',\n /**\n * The same check could not be asked, with the same host message, on two DISTINCT tasks (#3432): whatever the cause, it\n * is the host's and it repeats, so a third task would meet it too. Mostly no free probe exists, so the hold is re-asked:\n * an admission after {@link VerificationToolUnavailableHold.reaskAfter} is let through, and the same failure holds again\n * at once. A compiled model behind its sources is the exception: its compile record is a free probe (below). A cause only\n * ONE task meets is bounded per task instead (`MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS`).\n *\n * Every run counts, alone or beside siblings, and so does a wave's isolated re-check (run 43961156770). Only runs alone\n * counted until then, on the reasoning that beside siblings the cause may be a sibling's half-written file (#3204); at a\n * parallelism of ten no run was alone, the hold never opened, and a dead compile watcher cost 89 runs. A hold opened on\n * a sibling's transient cause ends as soon as any run, or the wave's re-check, ASKS the check, and one on a compiled\n * model behind its sources ({@link VerificationToolUnavailableHold.stalePackage}) as soon as that package compiles.\n */\n REPEATED_HOST_FAILURE = 'repeated-host-failure',\n}\n\n/** How long a {@link VerificationHostCause.REPEATED_HOST_FAILURE} hold refuses before one admission re-asks the host, as the account-refusal hold does. */\nexport const VERIFICATION_HOST_FAILURE_REASK_MS = 30 * 60 * 1000;\n\n/**\n * A verification check could not be ASKED because the command it runs could not be executed (#3423): the\n * executable is absent from the PATH the check spawns with — or, since #3432, is there and lacks the verb the check\n * asks ({@link VerificationHostCause.COMMAND_LACKS_VERB}).\n *\n * Distinct from every other \"could not ask\" (a compiled model behind its sources, an absent backend dist, a runner\n * that crashed): those can clear on their own between two runs, and the per-task host forgiveness absorbs them. An\n * absent executable cannot, and it fails every task's check the same way. Measured on reference run 42202387917:\n * `spawn wildo ENOENT` failed nine tasks' `check:resources-registry-init`, 39 attempts in 17 minutes, about $100.\n */\nexport class VerificationToolUnavailableError extends Error {\n /** The command the check spawns, as it was named: looked up on PATH to know when it is back. */\n readonly command: string;\n /** Which of the command's two failures this is: absent, or present without the verb. */\n readonly hostCause: VerificationHostCause.COMMAND_ABSENT | VerificationHostCause.COMMAND_LACKS_VERB;\n /** {@link VerificationHostCause.COMMAND_LACKS_VERB} only: the arguments that ask the command for the verb, ending in `--help`. */\n readonly verbProbeArgs?: readonly string[];\n\n constructor(command: string, message: string, lacksVerb?: { readonly verbProbeArgs: readonly string[] }) {\n super(message);\n this.name = 'VerificationToolUnavailableError';\n this.command = command;\n this.hostCause = lacksVerb ? VerificationHostCause.COMMAND_LACKS_VERB : VerificationHostCause.COMMAND_ABSENT;\n if (lacksVerb) this.verbProbeArgs = lacksVerb.verbProbeArgs;\n }\n}\n\n/**\n * Does the command's answer to a verb probe say it KNOWS the verb (#3432)? Exit 0 and no \"Unknown command\": an older\n * `wildo` exits 1 with `Unknown command: \"config\"`. A CLI that printed general help for a verb it does not know would\n * release the hold wrongly, and the next run would hold again at once: one run, never a lockout.\n */\nexport function verbProbeKnowsTheVerb(outcome: { readonly success: boolean; readonly message: string; readonly stdoutTail: string; readonly stderrTail: string }): boolean {\n return outcome.success && !/Unknown command/iu.test(`${outcome.message}\\n${outcome.stdoutTail}\\n${outcome.stderrTail}`);\n}\n\n/**\n * A host check failure's message with what differs between two runs of the same cause taken out (#3432): numbers\n * (durations, pids, counts, ports) and whitespace. Two tasks meeting one cause print the same message but for those.\n */\nexport function normalizeHostCheckFailureMessage(message: string): string {\n return message.replace(/\\d+/gu, '#').replace(/\\s+/gu, ' ').trim().slice(0, 400);\n}\n\n/**\n * Throw a {@link VerificationToolUnavailableError} when a check's outcome says its command could not be executed.\n * One function for every check that spawns a CLI, so the classification cannot drift between them.\n *\n * `absent` matches the spawn error in the outcome's message: `ENOENT` by default (Node's \"spawn x ENOENT\").\n */\nexport function refuseWhenVerificationToolIsAbsent(\n outcome: { readonly success: boolean; readonly message: string },\n input: { readonly command: string; readonly checking: string; readonly absent?: RegExp },\n): void {\n if (outcome.success || !(input.absent ?? /\\bENOENT\\b/).test(outcome.message)) return;\n throw new VerificationToolUnavailableError(\n input.command,\n `Cannot ${input.checking}: the \\`${input.command}\\` CLI could not be executed (${outcome.message}).`,\n );\n}\n\n/**\n * What holds coding admissions while a verification check cannot be asked for a host cause that will not clear on its\n * own (#3423, #3432): which cause, which command (when the cause is one), which check met it, the check's own message,\n * and the run that met it.\n */\nexport interface VerificationToolUnavailableHold {\n readonly hostCause: VerificationHostCause;\n /** The command the check spawns, for the two command causes; absent for a repeated failure, which may spawn none. */\n readonly command?: string;\n /** {@link VerificationHostCause.COMMAND_LACKS_VERB}: the arguments that ask the command for the verb. */\n readonly verbProbeArgs?: readonly string[];\n readonly checkRef: string;\n readonly message: string;\n readonly taskRef: string;\n readonly runTaskId: string;\n readonly observedAt: string;\n /** {@link VerificationHostCause.REPEATED_HOST_FAILURE}: every task the cause was met on, `taskRef` among them. */\n readonly metOnTaskRefs?: readonly string[];\n /** {@link VerificationHostCause.REPEATED_HOST_FAILURE}: from this instant the next admission re-asks the host. */\n readonly reaskAfter?: string;\n /**\n * {@link VerificationHostCause.REPEATED_HOST_FAILURE} whose check could not be asked because this application package's\n * compiled model is behind its sources (`shared-lib`, run 43961156770). Its probe is free: a read of the hold asks the\n * package's compile record (at most once per poll interval), and the hold ends as soon as the package reads compiled\n * current, before `reaskAfter`. Once per successful compile: a reading the CLI still refuses releases one admission, not\n * every read.\n */\n readonly stalePackage?: string;\n}\n\n/**\n * The cause in one sentence, with its remedy (#3432): the subject of the Home line, the build wave's guidance and the\n * drive's stop all say this, so the three cannot disagree about what holds the build or how it ends.\n */\nexport function describeVerificationHostCause(held: VerificationToolUnavailableHold): string {\n switch (held.hostCause) {\n case VerificationHostCause.COMMAND_ABSENT:\n return `\\`${held.command ?? 'a command'}\\` is not on the companion's PATH, so ${held.checkRef} cannot run for any task. `\n + 'Install it in a directory on that PATH, or restart the companion with one: the hold ends as soon as it is found.';\n case VerificationHostCause.COMMAND_LACKS_VERB:\n return `The installed \\`${held.command ?? 'wildo'}\\` does not know \\`${(held.verbProbeArgs ?? []).filter((arg) => arg !== '--help').join(' ')}\\`, `\n + `so ${held.checkRef} cannot run for any task. Update it to the companion's version: the hold ends as soon as it answers the verb.`;\n case VerificationHostCause.REPEATED_HOST_FAILURE:\n if (held.stalePackage !== undefined) {\n return `${held.checkRef} could not be asked, the same way, on ${(held.metOnTaskRefs ?? [held.taskRef]).join(' and ')}: `\n + `${held.stalePackage}'s compiled output is behind its sources, so the check reads a model nobody edited. ${held.message} `\n + `The build waits for ${held.stalePackage} to compile (a stopped compile watcher must be running again; a failed compile `\n + `must be fixed): the hold ends as soon as it is compiled current, and the build asks again from ${held.reaskAfter ?? 'the next admission'} at the latest.`;\n }\n return `${held.checkRef} could not be asked, the same way, on ${(held.metOnTaskRefs ?? [held.taskRef]).join(' and ')}: ${held.message} `\n + `Repair what the message names; the build asks again from ${held.reaskAfter ?? 'the next admission'}.`;\n }\n}\n\n/**\n * The first executable `command` on `pathValue`, as a spawn by bare name finds it (with the Windows command suffixes),\n * or `null`. The probe that ends the hold: free, and asked of the same PATH the verification subprocess receives.\n *\n * A command written as a path (`./bin/wildo`, `/usr/local/bin/wildo`) is not searched on PATH, as a spawn does not\n * search it: it is checked where it is. What the lookup cannot see: an executable that is found but still fails to spawn\n * with ENOENT (a script whose interpreter is missing). Then the hold ends at every lookup and each run meets it again,\n * which is the per-task forgiveness this hold replaces, never worse.\n */\nexport function resolveExecutableOnPath(\n command: string,\n pathValue: string | undefined = process.env.PATH,\n platform: NodeJS.Platform = process.platform,\n pathExtensions: string | undefined = process.env.PATHEXT,\n): string | null {\n const suffixes = platform === 'win32' ? (pathExtensions ?? '.EXE;.CMD;.BAT').split(';') : [''];\n if (command.includes('/') || (platform === 'win32' && command.includes('\\\\'))) {\n for (const suffix of suffixes) {\n try {\n accessSync(`${command}${suffix}`, fsConstants.X_OK);\n return `${command}${suffix}`;\n } catch {\n // Not executable with this suffix.\n }\n }\n return null;\n }\n for (const directory of (pathValue ?? '').split(platform === 'win32' ? ';' : delimiter).filter(Boolean)) {\n for (const suffix of suffixes) {\n const candidate = join(directory, `${command}${suffix}`);\n try {\n accessSync(candidate, fsConstants.X_OK);\n return candidate;\n } catch {\n // Not in this directory.\n }\n }\n }\n return null;\n}\n\n/**\n * The refusal an admission answers while the hold stands and the command is still absent. Names the cause, the\n * remedy, and the door past a lookup that is wrong: a re-arm for the environment of the task whose run MET the hold,\n * which has a failed run to re-arm (the task being admitted usually has none, and its re-arm would be refused).\n */\nexport function describeVerificationToolUnavailableRefusal(taskRef: string, held: VerificationToolUnavailableHold): string {\n if (held.hostCause === VerificationHostCause.COMMAND_ABSENT) {\n return `Coding task ${taskRef} was not started: \\`${held.command}\\` is not on the companion's PATH, so ${held.checkRef} cannot run for any task `\n + `(found by ${held.taskRef} at ${held.observedAt}: ${held.message}). No attempt was spent. `\n + `Install it into a directory already on the companion's PATH, or restart the companion with a PATH that holds it, then dispatch again: `\n + 'the next admission looks it up first. '\n + `If it is on PATH and this lookup is wrong, end the hold with: wildo build rearm ${held.taskRef} --reason environment --note \"<why>\".`;\n }\n return `Coding task ${taskRef} was not started: ${describeVerificationHostCause(held)} No attempt was spent `\n + `(met by ${held.taskRef} at ${held.observedAt}). `\n + `If the cause is gone and this does not clear, end the hold with: wildo build rearm ${held.taskRef} --reason environment --note \"<why>\".`;\n}\n"]}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { type ApplicationWorkspacePackageGraph, type VerificationReadScope } from './isolated-recheck-interference.models';
|
|
2
|
+
/**
|
|
3
|
+
* PATH-SCOPED holds on the application's working tree (#4020): what lets a concurrent coding run be ADMITTED while a
|
|
4
|
+
* long holder of the whole-tree workspace-mutation lock works on paths its declared scope does not meet.
|
|
5
|
+
*
|
|
6
|
+
* ## What was too wide
|
|
7
|
+
*
|
|
8
|
+
* The workspace-mutation lock (`withDedicatedFileLock` on `.wildo-saas/state/workspace-mutation.lock`) is held for
|
|
9
|
+
* minutes by a generation step (its whole window) and by an isolated re-check (its checks). A concurrent coding run took
|
|
10
|
+
* the same lock before its baseline, to commit pending playbook runs, whether or not one was pending, so it waited for
|
|
11
|
+
* every such holder. Measured on reference run 44052185141 (2026-11-17): dispatch-wait p95 76.5 s, 218 minutes summed;
|
|
12
|
+
* the logo step alone (13:22:25-13:28:19) kept 8 prepared runs waiting 155-375 s.
|
|
13
|
+
*
|
|
14
|
+
* ## What changed, and what did not
|
|
15
|
+
*
|
|
16
|
+
* The holders keep the lock exactly as before: no commit, no re-check, no single-flight run and no second step enters a
|
|
17
|
+
* step's window, and no commit enters a re-check. What changed is the ADMISSION only. A holder that knows which paths it
|
|
18
|
+
* writes or reads opens a CLAIM naming them, inside the lock it holds; a concurrent run with nothing to commit before its
|
|
19
|
+
* baseline then waits for the claims its declared mutation scope meets, not for the lock. A holder that opens no claim (a
|
|
20
|
+
* step declaring nothing, a single-flight run, a commit, a CLI writer in another process) is waited for exactly as before.
|
|
21
|
+
*
|
|
22
|
+
* A run admitted this way joins the holder's window the way a wave's run already joins a step the wave runs inline
|
|
23
|
+
* (#1805 review N2): the step reads its window as SHARED and claims only what lies under its own directories (#2240), and
|
|
24
|
+
* its closing checkpoint commits the tree as it stands (#3204). A step whose writes have not all been traced claims
|
|
25
|
+
* nothing, so it is waited for as before. The run's scope is a prediction (#1268 lets a run write anywhere);
|
|
26
|
+
* interference between writers sharing the tree is detected and repaired, not prevented (#1528).
|
|
27
|
+
*
|
|
28
|
+
* ## The three kinds
|
|
29
|
+
*
|
|
30
|
+
* - {@link WorkspacePathClaimKind.STEP_WRITE}: what a generation step may write, for its window: its write scope plus
|
|
31
|
+
* every side write traced for it (`GENERATION_STEP_CLAIM_BASIS`); a step not traced claims nothing.
|
|
32
|
+
* - {@link WorkspacePathClaimKind.RECHECK_READ}: an isolated re-check's read scope while its checks run; the whole
|
|
33
|
+
* application at a wave's end. A run whose scope may reach it waits, so the re-check still runs "alone against what it
|
|
34
|
+
* reads" (#3220, #3998).
|
|
35
|
+
* - {@link WorkspacePathClaimKind.ADMISSION_WRITE}: a concurrent coding run from the first instant of its admission
|
|
36
|
+
* (opened before any wait) until it is a registered live run, so a re-check opening meanwhile sees it.
|
|
37
|
+
*
|
|
38
|
+
* ## In-process, on purpose
|
|
39
|
+
*
|
|
40
|
+
* Every claim holder and every waiter lives in the companion process. STEP_WRITE and RECHECK_READ claims are opened and
|
|
41
|
+
* released INSIDE the file lock their holder holds, so "one of them is open" means "this process holds the lock in a
|
|
42
|
+
* section whose paths are named". The cross-process half of exclusion (a CLI writer, another companion) is still the file
|
|
43
|
+
* lock. JavaScript runs one task at a time, so a claim CHECKED and OPENED with no `await` between the two is atomic
|
|
44
|
+
* against every other holder; callers keep it that way.
|
|
45
|
+
*/
|
|
46
|
+
export declare enum WorkspacePathClaimKind {
|
|
47
|
+
/** A generation step writing its own directories. */
|
|
48
|
+
STEP_WRITE = "STEP_WRITE",
|
|
49
|
+
/** An isolated re-check reading a closure of workspace packages, or the whole application. */
|
|
50
|
+
RECHECK_READ = "RECHECK_READ",
|
|
51
|
+
/** A concurrent coding run being admitted, until it is registered as a live run. */
|
|
52
|
+
ADMISSION_WRITE = "ADMISSION_WRITE"
|
|
53
|
+
}
|
|
54
|
+
interface WorkspacePathClaimBase {
|
|
55
|
+
/** Unique per open claim. */
|
|
56
|
+
readonly id: string;
|
|
57
|
+
/** The task or run the claim belongs to, for a refusal or a wait to name. */
|
|
58
|
+
readonly ownerTaskId: string;
|
|
59
|
+
readonly ownerTaskRef: string;
|
|
60
|
+
}
|
|
61
|
+
export type WorkspacePathClaim = (WorkspacePathClaimBase & {
|
|
62
|
+
readonly kind: WorkspacePathClaimKind.STEP_WRITE | WorkspacePathClaimKind.ADMISSION_WRITE;
|
|
63
|
+
/** Application-root-relative path prefixes it may write. */
|
|
64
|
+
readonly writePrefixes: readonly string[];
|
|
65
|
+
}) | (WorkspacePathClaimBase & {
|
|
66
|
+
readonly kind: WorkspacePathClaimKind.RECHECK_READ;
|
|
67
|
+
readonly readScope: VerificationReadScope;
|
|
68
|
+
/** The package graph the read scope was resolved against; absent, every path is read. */
|
|
69
|
+
readonly graph: ApplicationWorkspacePackageGraph | undefined;
|
|
70
|
+
});
|
|
71
|
+
/** What a claim is compared with: an open claim's shape, without its identity. */
|
|
72
|
+
export type WorkspacePathClaimRequest = WorkspacePathClaim extends infer Claim ? Claim extends WorkspacePathClaim ? Omit<Claim, 'id'> : never : never;
|
|
73
|
+
/**
|
|
74
|
+
* The roots a generation step claims for its window (#4020), normalized, or `undefined` when it claims nothing: an empty
|
|
75
|
+
* claim, or one naming the root itself. Directories (with their trailing slash) and exact files alike: the overlap test
|
|
76
|
+
* reads both as string prefixes. The claim must cover every write, side effects included (the logo step's brand
|
|
77
|
+
* propagation into the frontend, the website and the documentation, for one); the generation-step service declares it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function generationStepWorkspaceClaimRoots(ownedPathPrefixes: readonly string[]): readonly string[] | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Whether two sets of write prefixes may name a common path. Raw string prefixes in BOTH directions, so `frontend/src`
|
|
82
|
+
* meets `frontend/src-old/` and `frontend/` meets `frontend/src/x.ts`: over-reporting an overlap costs a wait, missing one
|
|
83
|
+
* lets two writers into one file, so the comparison errs toward overlap. An empty set is UNKNOWN and meets everything.
|
|
84
|
+
*/
|
|
85
|
+
export declare function writePrefixesOverlap(left: readonly string[], right: readonly string[]): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Whether two claims may not be held at once (#4020). Symmetric. Two writers conflict when their prefixes overlap; a
|
|
88
|
+
* writer and a reader when the writer may write something the reader's checks read ({@link writeScopeMayReachReadScope},
|
|
89
|
+
* the rule the early re-check already applies to live runs, #3998); two readers never do, since neither changes the tree.
|
|
90
|
+
*
|
|
91
|
+
* Two ADMISSIONS never conflict: concurrent coding runs share the tree by decision (#1528), overlapping scopes included,
|
|
92
|
+
* and interference between them is detected and repaired rather than prevented. An admission claim exists only so the
|
|
93
|
+
* holders that DO exclude a run (a step's directories, a re-check's read scope) can see a run that is not live yet.
|
|
94
|
+
*/
|
|
95
|
+
export declare function workspacePathClaimsConflict(left: WorkspacePathClaimRequest, right: WorkspacePathClaimRequest): boolean;
|
|
96
|
+
/** Whether a path a commit would carry lies under one of these write roots. */
|
|
97
|
+
export declare function isUnderWriteRoots(path: string, roots: readonly string[]): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The open claims of one companion process, and a way to wait for them to change (#4020). Pure bookkeeping: it decides
|
|
100
|
+
* nothing about what a holder may do; the dispatch service asks it, under the rules above.
|
|
101
|
+
*/
|
|
102
|
+
export declare class WorkspacePathClaims {
|
|
103
|
+
private readonly open;
|
|
104
|
+
private sequence;
|
|
105
|
+
private changed;
|
|
106
|
+
/** Every open claim, in opening order. */
|
|
107
|
+
list(): readonly WorkspacePathClaim[];
|
|
108
|
+
/** The open claims that conflict with `request`, excluding any owned by `exceptOwnerTaskId`. */
|
|
109
|
+
conflicting(request: WorkspacePathClaimRequest, exceptOwnerTaskId?: string): readonly WorkspacePathClaim[];
|
|
110
|
+
/**
|
|
111
|
+
* Open a claim, returning its release. The release is idempotent, so a `finally` and an earlier explicit release may
|
|
112
|
+
* both call it. Never checks for conflicts itself: the caller checks with {@link conflicting} and opens with no `await`
|
|
113
|
+
* in between, which is what makes the pair atomic.
|
|
114
|
+
*/
|
|
115
|
+
acquire(request: WorkspacePathClaimRequest): () => void;
|
|
116
|
+
/**
|
|
117
|
+
* The roots of every open STEP_WRITE claim, except the steps named: what a commit made WITHOUT the lock (a person's
|
|
118
|
+
* build checkpoint) must not carry while the step is still writing there.
|
|
119
|
+
*/
|
|
120
|
+
openStepWriteRoots(exceptOwnerTaskIds?: Iterable<string>): readonly string[];
|
|
121
|
+
/** Resolves the next time a claim is opened or released. */
|
|
122
|
+
nextChange(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Wait until `blocking()` answers an empty list, re-asking it at every change and at least every `pollMs`, and at most
|
|
125
|
+
* `timeoutMs` in all. Answers the claims still blocking when the bound is reached, or an empty list. The poll is a
|
|
126
|
+
* backstop for a predicate that also reads state outside this registry (a live-run set); the change signal is what
|
|
127
|
+
* normally wakes it.
|
|
128
|
+
*/
|
|
129
|
+
waitUntilClear(blocking: () => readonly WorkspacePathClaim[], options: {
|
|
130
|
+
readonly timeoutMs: number;
|
|
131
|
+
readonly pollMs?: number;
|
|
132
|
+
}): Promise<readonly WorkspacePathClaim[]>;
|
|
133
|
+
private signalChange;
|
|
134
|
+
}
|
|
135
|
+
/** One line naming who holds the claims a waiter met, for a refusal or a log. */
|
|
136
|
+
export declare function describeWorkspacePathClaims(claims: readonly WorkspacePathClaim[]): string;
|
|
137
|
+
export {};
|
|
138
|
+
//# sourceMappingURL=workspace-path-claims.models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-path-claims.models.d.ts","sourceRoot":"","sources":["../../../../src/claude-cli/models/workspace-path-claims.models.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC3B,MAAM,wCAAwC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,oBAAY,sBAAsB;IAChC,qDAAqD;IACrD,UAAU,eAAe;IACzB,8FAA8F;IAC9F,YAAY,iBAAiB;IAC7B,oFAAoF;IACpF,eAAe,oBAAoB;CACpC;AAED,UAAU,sBAAsB;IAC9B,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,MA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8D;IAE7E,0CAA0C;IACnC,IAAI,IAAI,SAAS,kBAAkB,EAAE;IAI5C,gGAAgG;IACzF,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,kBAAkB,EAAE;IAIjH;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,IAAI;IAU9D;;;OAGG;IACI,kBAAkB,CAAC,kBAAkB,GAAE,QAAQ,CAAC,MAAM,CAAM,GAAG,SAAS,MAAM,EAAE;IAOvF,4DAA4D;IACrD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IASlC;;;;;OAKG;IACU,cAAc,CACzB,QAAQ,EAAE,MAAM,SAAS,kBAAkB,EAAE,EAC7C,OAAO,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC;IAgBzC,OAAO,CAAC,YAAY;CAKrB;AAED,iFAAiF;AACjF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,GAAG,MAAM,CAWzF"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { writeScopeMayReachReadScope, } from './isolated-recheck-interference.models.js';
|
|
2
|
+
/**
|
|
3
|
+
* PATH-SCOPED holds on the application's working tree (#4020): what lets a concurrent coding run be ADMITTED while a
|
|
4
|
+
* long holder of the whole-tree workspace-mutation lock works on paths its declared scope does not meet.
|
|
5
|
+
*
|
|
6
|
+
* ## What was too wide
|
|
7
|
+
*
|
|
8
|
+
* The workspace-mutation lock (`withDedicatedFileLock` on `.wildo-saas/state/workspace-mutation.lock`) is held for
|
|
9
|
+
* minutes by a generation step (its whole window) and by an isolated re-check (its checks). A concurrent coding run took
|
|
10
|
+
* the same lock before its baseline, to commit pending playbook runs, whether or not one was pending, so it waited for
|
|
11
|
+
* every such holder. Measured on reference run 44052185141 (2026-11-17): dispatch-wait p95 76.5 s, 218 minutes summed;
|
|
12
|
+
* the logo step alone (13:22:25-13:28:19) kept 8 prepared runs waiting 155-375 s.
|
|
13
|
+
*
|
|
14
|
+
* ## What changed, and what did not
|
|
15
|
+
*
|
|
16
|
+
* The holders keep the lock exactly as before: no commit, no re-check, no single-flight run and no second step enters a
|
|
17
|
+
* step's window, and no commit enters a re-check. What changed is the ADMISSION only. A holder that knows which paths it
|
|
18
|
+
* writes or reads opens a CLAIM naming them, inside the lock it holds; a concurrent run with nothing to commit before its
|
|
19
|
+
* baseline then waits for the claims its declared mutation scope meets, not for the lock. A holder that opens no claim (a
|
|
20
|
+
* step declaring nothing, a single-flight run, a commit, a CLI writer in another process) is waited for exactly as before.
|
|
21
|
+
*
|
|
22
|
+
* A run admitted this way joins the holder's window the way a wave's run already joins a step the wave runs inline
|
|
23
|
+
* (#1805 review N2): the step reads its window as SHARED and claims only what lies under its own directories (#2240), and
|
|
24
|
+
* its closing checkpoint commits the tree as it stands (#3204). A step whose writes have not all been traced claims
|
|
25
|
+
* nothing, so it is waited for as before. The run's scope is a prediction (#1268 lets a run write anywhere);
|
|
26
|
+
* interference between writers sharing the tree is detected and repaired, not prevented (#1528).
|
|
27
|
+
*
|
|
28
|
+
* ## The three kinds
|
|
29
|
+
*
|
|
30
|
+
* - {@link WorkspacePathClaimKind.STEP_WRITE}: what a generation step may write, for its window: its write scope plus
|
|
31
|
+
* every side write traced for it (`GENERATION_STEP_CLAIM_BASIS`); a step not traced claims nothing.
|
|
32
|
+
* - {@link WorkspacePathClaimKind.RECHECK_READ}: an isolated re-check's read scope while its checks run; the whole
|
|
33
|
+
* application at a wave's end. A run whose scope may reach it waits, so the re-check still runs "alone against what it
|
|
34
|
+
* reads" (#3220, #3998).
|
|
35
|
+
* - {@link WorkspacePathClaimKind.ADMISSION_WRITE}: a concurrent coding run from the first instant of its admission
|
|
36
|
+
* (opened before any wait) until it is a registered live run, so a re-check opening meanwhile sees it.
|
|
37
|
+
*
|
|
38
|
+
* ## In-process, on purpose
|
|
39
|
+
*
|
|
40
|
+
* Every claim holder and every waiter lives in the companion process. STEP_WRITE and RECHECK_READ claims are opened and
|
|
41
|
+
* released INSIDE the file lock their holder holds, so "one of them is open" means "this process holds the lock in a
|
|
42
|
+
* section whose paths are named". The cross-process half of exclusion (a CLI writer, another companion) is still the file
|
|
43
|
+
* lock. JavaScript runs one task at a time, so a claim CHECKED and OPENED with no `await` between the two is atomic
|
|
44
|
+
* against every other holder; callers keep it that way.
|
|
45
|
+
*/
|
|
46
|
+
export var WorkspacePathClaimKind;
|
|
47
|
+
(function (WorkspacePathClaimKind) {
|
|
48
|
+
/** A generation step writing its own directories. */
|
|
49
|
+
WorkspacePathClaimKind["STEP_WRITE"] = "STEP_WRITE";
|
|
50
|
+
/** An isolated re-check reading a closure of workspace packages, or the whole application. */
|
|
51
|
+
WorkspacePathClaimKind["RECHECK_READ"] = "RECHECK_READ";
|
|
52
|
+
/** A concurrent coding run being admitted, until it is registered as a live run. */
|
|
53
|
+
WorkspacePathClaimKind["ADMISSION_WRITE"] = "ADMISSION_WRITE";
|
|
54
|
+
})(WorkspacePathClaimKind || (WorkspacePathClaimKind = {}));
|
|
55
|
+
/** An application-relative path or prefix, without a leading `./` or `/`. */
|
|
56
|
+
function normalizePrefix(prefix) {
|
|
57
|
+
return prefix.replace(/\\/gu, '/').replace(/^(?:\.\/|\/)+/u, '');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The roots a generation step claims for its window (#4020), normalized, or `undefined` when it claims nothing: an empty
|
|
61
|
+
* claim, or one naming the root itself. Directories (with their trailing slash) and exact files alike: the overlap test
|
|
62
|
+
* reads both as string prefixes. The claim must cover every write, side effects included (the logo step's brand
|
|
63
|
+
* propagation into the frontend, the website and the documentation, for one); the generation-step service declares it.
|
|
64
|
+
*/
|
|
65
|
+
export function generationStepWorkspaceClaimRoots(ownedPathPrefixes) {
|
|
66
|
+
const roots = ownedPathPrefixes.map(normalizePrefix);
|
|
67
|
+
if (roots.length === 0 || roots.some((root) => root === '' || root === '/'))
|
|
68
|
+
return undefined;
|
|
69
|
+
return [...new Set(roots)].sort();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether two sets of write prefixes may name a common path. Raw string prefixes in BOTH directions, so `frontend/src`
|
|
73
|
+
* meets `frontend/src-old/` and `frontend/` meets `frontend/src/x.ts`: over-reporting an overlap costs a wait, missing one
|
|
74
|
+
* lets two writers into one file, so the comparison errs toward overlap. An empty set is UNKNOWN and meets everything.
|
|
75
|
+
*/
|
|
76
|
+
export function writePrefixesOverlap(left, right) {
|
|
77
|
+
if (left.length === 0 || right.length === 0)
|
|
78
|
+
return true;
|
|
79
|
+
const a = left.map(normalizePrefix);
|
|
80
|
+
const b = right.map(normalizePrefix);
|
|
81
|
+
return a.some((x) => b.some((y) => x === '' || y === '' || x.startsWith(y) || y.startsWith(x)));
|
|
82
|
+
}
|
|
83
|
+
function isWriteClaim(claim) {
|
|
84
|
+
return claim.kind === WorkspacePathClaimKind.STEP_WRITE || claim.kind === WorkspacePathClaimKind.ADMISSION_WRITE;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Whether two claims may not be held at once (#4020). Symmetric. Two writers conflict when their prefixes overlap; a
|
|
88
|
+
* writer and a reader when the writer may write something the reader's checks read ({@link writeScopeMayReachReadScope},
|
|
89
|
+
* the rule the early re-check already applies to live runs, #3998); two readers never do, since neither changes the tree.
|
|
90
|
+
*
|
|
91
|
+
* Two ADMISSIONS never conflict: concurrent coding runs share the tree by decision (#1528), overlapping scopes included,
|
|
92
|
+
* and interference between them is detected and repaired rather than prevented. An admission claim exists only so the
|
|
93
|
+
* holders that DO exclude a run (a step's directories, a re-check's read scope) can see a run that is not live yet.
|
|
94
|
+
*/
|
|
95
|
+
export function workspacePathClaimsConflict(left, right) {
|
|
96
|
+
if (left.kind === WorkspacePathClaimKind.ADMISSION_WRITE && right.kind === WorkspacePathClaimKind.ADMISSION_WRITE)
|
|
97
|
+
return false;
|
|
98
|
+
if (isWriteClaim(left) && isWriteClaim(right))
|
|
99
|
+
return writePrefixesOverlap(left.writePrefixes, right.writePrefixes);
|
|
100
|
+
if (isWriteClaim(left) && right.kind === WorkspacePathClaimKind.RECHECK_READ)
|
|
101
|
+
return writeScopeMayReachReadScope(left.writePrefixes, right.readScope, right.graph);
|
|
102
|
+
if (left.kind === WorkspacePathClaimKind.RECHECK_READ && isWriteClaim(right))
|
|
103
|
+
return writeScopeMayReachReadScope(right.writePrefixes, left.readScope, left.graph);
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
/** Whether a path a commit would carry lies under one of these write roots. */
|
|
107
|
+
export function isUnderWriteRoots(path, roots) {
|
|
108
|
+
const normalized = normalizePrefix(path);
|
|
109
|
+
return roots.map(normalizePrefix).some((root) => root !== '' && normalized.startsWith(root));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The open claims of one companion process, and a way to wait for them to change (#4020). Pure bookkeeping: it decides
|
|
113
|
+
* nothing about what a holder may do; the dispatch service asks it, under the rules above.
|
|
114
|
+
*/
|
|
115
|
+
export class WorkspacePathClaims {
|
|
116
|
+
open = new Map();
|
|
117
|
+
sequence = 0;
|
|
118
|
+
changed;
|
|
119
|
+
/** Every open claim, in opening order. */
|
|
120
|
+
list() {
|
|
121
|
+
return [...this.open.values()];
|
|
122
|
+
}
|
|
123
|
+
/** The open claims that conflict with `request`, excluding any owned by `exceptOwnerTaskId`. */
|
|
124
|
+
conflicting(request, exceptOwnerTaskId) {
|
|
125
|
+
return this.list().filter((claim) => claim.ownerTaskId !== exceptOwnerTaskId && workspacePathClaimsConflict(claim, request));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Open a claim, returning its release. The release is idempotent, so a `finally` and an earlier explicit release may
|
|
129
|
+
* both call it. Never checks for conflicts itself: the caller checks with {@link conflicting} and opens with no `await`
|
|
130
|
+
* in between, which is what makes the pair atomic.
|
|
131
|
+
*/
|
|
132
|
+
acquire(request) {
|
|
133
|
+
this.sequence += 1;
|
|
134
|
+
const id = `${request.kind}:${request.ownerTaskId}:${this.sequence}`;
|
|
135
|
+
this.open.set(id, { ...request, id });
|
|
136
|
+
this.signalChange();
|
|
137
|
+
return () => {
|
|
138
|
+
if (this.open.delete(id))
|
|
139
|
+
this.signalChange();
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The roots of every open STEP_WRITE claim, except the steps named: what a commit made WITHOUT the lock (a person's
|
|
144
|
+
* build checkpoint) must not carry while the step is still writing there.
|
|
145
|
+
*/
|
|
146
|
+
openStepWriteRoots(exceptOwnerTaskIds = []) {
|
|
147
|
+
const except = new Set(exceptOwnerTaskIds);
|
|
148
|
+
return [...new Set(this.list()
|
|
149
|
+
.filter((claim) => claim.kind === WorkspacePathClaimKind.STEP_WRITE && !except.has(claim.ownerTaskId))
|
|
150
|
+
.flatMap((claim) => (claim.kind === WorkspacePathClaimKind.STEP_WRITE ? claim.writePrefixes : [])))].sort();
|
|
151
|
+
}
|
|
152
|
+
/** Resolves the next time a claim is opened or released. */
|
|
153
|
+
nextChange() {
|
|
154
|
+
this.changed ??= (() => {
|
|
155
|
+
let resolve;
|
|
156
|
+
const promise = new Promise((done) => { resolve = done; });
|
|
157
|
+
return { promise, resolve };
|
|
158
|
+
})();
|
|
159
|
+
return this.changed.promise;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Wait until `blocking()` answers an empty list, re-asking it at every change and at least every `pollMs`, and at most
|
|
163
|
+
* `timeoutMs` in all. Answers the claims still blocking when the bound is reached, or an empty list. The poll is a
|
|
164
|
+
* backstop for a predicate that also reads state outside this registry (a live-run set); the change signal is what
|
|
165
|
+
* normally wakes it.
|
|
166
|
+
*/
|
|
167
|
+
async waitUntilClear(blocking, options) {
|
|
168
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
169
|
+
for (;;) {
|
|
170
|
+
const now = blocking();
|
|
171
|
+
if (now.length === 0)
|
|
172
|
+
return now;
|
|
173
|
+
const remaining = deadline - Date.now();
|
|
174
|
+
if (remaining <= 0)
|
|
175
|
+
return now;
|
|
176
|
+
let timer;
|
|
177
|
+
await Promise.race([
|
|
178
|
+
this.nextChange(),
|
|
179
|
+
new Promise((resolve) => { timer = setTimeout(resolve, Math.min(remaining, options.pollMs ?? 5_000)); timer.unref?.(); }),
|
|
180
|
+
]);
|
|
181
|
+
if (timer !== undefined)
|
|
182
|
+
clearTimeout(timer);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
signalChange() {
|
|
186
|
+
const changed = this.changed;
|
|
187
|
+
this.changed = undefined;
|
|
188
|
+
changed?.resolve();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/** One line naming who holds the claims a waiter met, for a refusal or a log. */
|
|
192
|
+
export function describeWorkspacePathClaims(claims) {
|
|
193
|
+
return claims.map((claim) => {
|
|
194
|
+
switch (claim.kind) {
|
|
195
|
+
case WorkspacePathClaimKind.STEP_WRITE:
|
|
196
|
+
return `generation step ${claim.ownerTaskRef} writing ${claim.writePrefixes.join(', ')}`;
|
|
197
|
+
case WorkspacePathClaimKind.ADMISSION_WRITE:
|
|
198
|
+
return `coding run ${claim.ownerTaskRef} being admitted to write ${claim.writePrefixes.join(', ')}`;
|
|
199
|
+
case WorkspacePathClaimKind.RECHECK_READ:
|
|
200
|
+
return `isolated re-check of ${claim.ownerTaskRef} reading ${claim.readScope.wholeApplication ? 'the whole application' : [...claim.readScope.packageDirectories].sort().join(', ')}`;
|
|
201
|
+
}
|
|
202
|
+
}).join('; ');
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=workspace-path-claims.models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-path-claims.models.js","sourceRoot":"","sources":["../../../../src/claude-cli/models/workspace-path-claims.models.ts"],"names":[],"mappings":"AAAA,OAAO,EACL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AAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1L,CAAC;IACH,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC","sourcesContent":["import {\n writeScopeMayReachReadScope,\n type ApplicationWorkspacePackageGraph,\n type VerificationReadScope,\n} from './isolated-recheck-interference.models';\n\n/**\n * PATH-SCOPED holds on the application's working tree (#4020): what lets a concurrent coding run be ADMITTED while a\n * long holder of the whole-tree workspace-mutation lock works on paths its declared scope does not meet.\n *\n * ## What was too wide\n *\n * The workspace-mutation lock (`withDedicatedFileLock` on `.wildo-saas/state/workspace-mutation.lock`) is held for\n * minutes by a generation step (its whole window) and by an isolated re-check (its checks). A concurrent coding run took\n * the same lock before its baseline, to commit pending playbook runs, whether or not one was pending, so it waited for\n * every such holder. Measured on reference run 44052185141 (2026-11-17): dispatch-wait p95 76.5 s, 218 minutes summed;\n * the logo step alone (13:22:25-13:28:19) kept 8 prepared runs waiting 155-375 s.\n *\n * ## What changed, and what did not\n *\n * The holders keep the lock exactly as before: no commit, no re-check, no single-flight run and no second step enters a\n * step's window, and no commit enters a re-check. What changed is the ADMISSION only. A holder that knows which paths it\n * writes or reads opens a CLAIM naming them, inside the lock it holds; a concurrent run with nothing to commit before its\n * baseline then waits for the claims its declared mutation scope meets, not for the lock. A holder that opens no claim (a\n * step declaring nothing, a single-flight run, a commit, a CLI writer in another process) is waited for exactly as before.\n *\n * A run admitted this way joins the holder's window the way a wave's run already joins a step the wave runs inline\n * (#1805 review N2): the step reads its window as SHARED and claims only what lies under its own directories (#2240), and\n * its closing checkpoint commits the tree as it stands (#3204). A step whose writes have not all been traced claims\n * nothing, so it is waited for as before. The run's scope is a prediction (#1268 lets a run write anywhere);\n * interference between writers sharing the tree is detected and repaired, not prevented (#1528).\n *\n * ## The three kinds\n *\n * - {@link WorkspacePathClaimKind.STEP_WRITE}: what a generation step may write, for its window: its write scope plus\n * every side write traced for it (`GENERATION_STEP_CLAIM_BASIS`); a step not traced claims nothing.\n * - {@link WorkspacePathClaimKind.RECHECK_READ}: an isolated re-check's read scope while its checks run; the whole\n * application at a wave's end. A run whose scope may reach it waits, so the re-check still runs \"alone against what it\n * reads\" (#3220, #3998).\n * - {@link WorkspacePathClaimKind.ADMISSION_WRITE}: a concurrent coding run from the first instant of its admission\n * (opened before any wait) until it is a registered live run, so a re-check opening meanwhile sees it.\n *\n * ## In-process, on purpose\n *\n * Every claim holder and every waiter lives in the companion process. STEP_WRITE and RECHECK_READ claims are opened and\n * released INSIDE the file lock their holder holds, so \"one of them is open\" means \"this process holds the lock in a\n * section whose paths are named\". The cross-process half of exclusion (a CLI writer, another companion) is still the file\n * lock. JavaScript runs one task at a time, so a claim CHECKED and OPENED with no `await` between the two is atomic\n * against every other holder; callers keep it that way.\n */\nexport enum WorkspacePathClaimKind {\n /** A generation step writing its own directories. */\n STEP_WRITE = 'STEP_WRITE',\n /** An isolated re-check reading a closure of workspace packages, or the whole application. */\n RECHECK_READ = 'RECHECK_READ',\n /** A concurrent coding run being admitted, until it is registered as a live run. */\n ADMISSION_WRITE = 'ADMISSION_WRITE',\n}\n\ninterface WorkspacePathClaimBase {\n /** Unique per open claim. */\n readonly id: string;\n /** The task or run the claim belongs to, for a refusal or a wait to name. */\n readonly ownerTaskId: string;\n readonly ownerTaskRef: string;\n}\n\nexport type WorkspacePathClaim =\n | (WorkspacePathClaimBase & {\n readonly kind: WorkspacePathClaimKind.STEP_WRITE | WorkspacePathClaimKind.ADMISSION_WRITE;\n /** Application-root-relative path prefixes it may write. */\n readonly writePrefixes: readonly string[];\n })\n | (WorkspacePathClaimBase & {\n readonly kind: WorkspacePathClaimKind.RECHECK_READ;\n readonly readScope: VerificationReadScope;\n /** The package graph the read scope was resolved against; absent, every path is read. */\n readonly graph: ApplicationWorkspacePackageGraph | undefined;\n });\n\n/** What a claim is compared with: an open claim's shape, without its identity. */\nexport type WorkspacePathClaimRequest = WorkspacePathClaim extends infer Claim ? Claim extends WorkspacePathClaim ? Omit<Claim, 'id'> : never : never;\n\n/** An application-relative path or prefix, without a leading `./` or `/`. */\nfunction normalizePrefix(prefix: string): string {\n return prefix.replace(/\\\\/gu, '/').replace(/^(?:\\.\\/|\\/)+/u, '');\n}\n\n/**\n * The roots a generation step claims for its window (#4020), normalized, or `undefined` when it claims nothing: an empty\n * claim, or one naming the root itself. Directories (with their trailing slash) and exact files alike: the overlap test\n * reads both as string prefixes. The claim must cover every write, side effects included (the logo step's brand\n * propagation into the frontend, the website and the documentation, for one); the generation-step service declares it.\n */\nexport function generationStepWorkspaceClaimRoots(ownedPathPrefixes: readonly string[]): readonly string[] | undefined {\n const roots = ownedPathPrefixes.map(normalizePrefix);\n if (roots.length === 0 || roots.some((root) => root === '' || root === '/')) return undefined;\n return [...new Set(roots)].sort();\n}\n\n/**\n * Whether two sets of write prefixes may name a common path. Raw string prefixes in BOTH directions, so `frontend/src`\n * meets `frontend/src-old/` and `frontend/` meets `frontend/src/x.ts`: over-reporting an overlap costs a wait, missing one\n * lets two writers into one file, so the comparison errs toward overlap. An empty set is UNKNOWN and meets everything.\n */\nexport function writePrefixesOverlap(left: readonly string[], right: readonly string[]): boolean {\n if (left.length === 0 || right.length === 0) return true;\n const a = left.map(normalizePrefix);\n const b = right.map(normalizePrefix);\n return a.some((x) => b.some((y) => x === '' || y === '' || x.startsWith(y) || y.startsWith(x)));\n}\n\nfunction isWriteClaim(claim: WorkspacePathClaimRequest): claim is Extract<WorkspacePathClaimRequest, { readonly writePrefixes: readonly string[] }> {\n return claim.kind === WorkspacePathClaimKind.STEP_WRITE || claim.kind === WorkspacePathClaimKind.ADMISSION_WRITE;\n}\n\n/**\n * Whether two claims may not be held at once (#4020). Symmetric. Two writers conflict when their prefixes overlap; a\n * writer and a reader when the writer may write something the reader's checks read ({@link writeScopeMayReachReadScope},\n * the rule the early re-check already applies to live runs, #3998); two readers never do, since neither changes the tree.\n *\n * Two ADMISSIONS never conflict: concurrent coding runs share the tree by decision (#1528), overlapping scopes included,\n * and interference between them is detected and repaired rather than prevented. An admission claim exists only so the\n * holders that DO exclude a run (a step's directories, a re-check's read scope) can see a run that is not live yet.\n */\nexport function workspacePathClaimsConflict(left: WorkspacePathClaimRequest, right: WorkspacePathClaimRequest): boolean {\n if (left.kind === WorkspacePathClaimKind.ADMISSION_WRITE && right.kind === WorkspacePathClaimKind.ADMISSION_WRITE) return false;\n if (isWriteClaim(left) && isWriteClaim(right)) return writePrefixesOverlap(left.writePrefixes, right.writePrefixes);\n if (isWriteClaim(left) && right.kind === WorkspacePathClaimKind.RECHECK_READ) return writeScopeMayReachReadScope(left.writePrefixes, right.readScope, right.graph);\n if (left.kind === WorkspacePathClaimKind.RECHECK_READ && isWriteClaim(right)) return writeScopeMayReachReadScope(right.writePrefixes, left.readScope, left.graph);\n return false;\n}\n\n/** Whether a path a commit would carry lies under one of these write roots. */\nexport function isUnderWriteRoots(path: string, roots: readonly string[]): boolean {\n const normalized = normalizePrefix(path);\n return roots.map(normalizePrefix).some((root) => root !== '' && normalized.startsWith(root));\n}\n\n/**\n * The open claims of one companion process, and a way to wait for them to change (#4020). Pure bookkeeping: it decides\n * nothing about what a holder may do; the dispatch service asks it, under the rules above.\n */\nexport class WorkspacePathClaims {\n private readonly open = new Map<string, WorkspacePathClaim>();\n private sequence = 0;\n private changed: { promise: Promise<void>; resolve: () => void } | undefined;\n\n /** Every open claim, in opening order. */\n public list(): readonly WorkspacePathClaim[] {\n return [...this.open.values()];\n }\n\n /** The open claims that conflict with `request`, excluding any owned by `exceptOwnerTaskId`. */\n public conflicting(request: WorkspacePathClaimRequest, exceptOwnerTaskId?: string): readonly WorkspacePathClaim[] {\n return this.list().filter((claim) => claim.ownerTaskId !== exceptOwnerTaskId && workspacePathClaimsConflict(claim, request));\n }\n\n /**\n * Open a claim, returning its release. The release is idempotent, so a `finally` and an earlier explicit release may\n * both call it. Never checks for conflicts itself: the caller checks with {@link conflicting} and opens with no `await`\n * in between, which is what makes the pair atomic.\n */\n public acquire(request: WorkspacePathClaimRequest): () => void {\n this.sequence += 1;\n const id = `${request.kind}:${request.ownerTaskId}:${this.sequence}`;\n this.open.set(id, { ...request, id } as WorkspacePathClaim);\n this.signalChange();\n return () => {\n if (this.open.delete(id)) this.signalChange();\n };\n }\n\n /**\n * The roots of every open STEP_WRITE claim, except the steps named: what a commit made WITHOUT the lock (a person's\n * build checkpoint) must not carry while the step is still writing there.\n */\n public openStepWriteRoots(exceptOwnerTaskIds: Iterable<string> = []): readonly string[] {\n const except = new Set(exceptOwnerTaskIds);\n return [...new Set(this.list()\n .filter((claim) => claim.kind === WorkspacePathClaimKind.STEP_WRITE && !except.has(claim.ownerTaskId))\n .flatMap((claim) => (claim.kind === WorkspacePathClaimKind.STEP_WRITE ? claim.writePrefixes : [])))].sort();\n }\n\n /** Resolves the next time a claim is opened or released. */\n public nextChange(): Promise<void> {\n this.changed ??= (() => {\n let resolve!: () => void;\n const promise = new Promise<void>((done) => { resolve = done; });\n return { promise, resolve };\n })();\n return this.changed.promise;\n }\n\n /**\n * Wait until `blocking()` answers an empty list, re-asking it at every change and at least every `pollMs`, and at most\n * `timeoutMs` in all. Answers the claims still blocking when the bound is reached, or an empty list. The poll is a\n * backstop for a predicate that also reads state outside this registry (a live-run set); the change signal is what\n * normally wakes it.\n */\n public async waitUntilClear(\n blocking: () => readonly WorkspacePathClaim[],\n options: { readonly timeoutMs: number; readonly pollMs?: number },\n ): Promise<readonly WorkspacePathClaim[]> {\n const deadline = Date.now() + options.timeoutMs;\n for (;;) {\n const now = blocking();\n if (now.length === 0) return now;\n const remaining = deadline - Date.now();\n if (remaining <= 0) return now;\n let timer: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([\n this.nextChange(),\n new Promise<void>((resolve) => { timer = setTimeout(resolve, Math.min(remaining, options.pollMs ?? 5_000)); timer.unref?.(); }),\n ]);\n if (timer !== undefined) clearTimeout(timer);\n }\n }\n\n private signalChange(): void {\n const changed = this.changed;\n this.changed = undefined;\n changed?.resolve();\n }\n}\n\n/** One line naming who holds the claims a waiter met, for a refusal or a log. */\nexport function describeWorkspacePathClaims(claims: readonly WorkspacePathClaim[]): string {\n return claims.map((claim) => {\n switch (claim.kind) {\n case WorkspacePathClaimKind.STEP_WRITE:\n return `generation step ${claim.ownerTaskRef} writing ${claim.writePrefixes.join(', ')}`;\n case WorkspacePathClaimKind.ADMISSION_WRITE:\n return `coding run ${claim.ownerTaskRef} being admitted to write ${claim.writePrefixes.join(', ')}`;\n case WorkspacePathClaimKind.RECHECK_READ:\n return `isolated re-check of ${claim.ownerTaskRef} reading ${claim.readScope.wholeApplication ? 'the whole application' : [...claim.readScope.packageDirectories].sort().join(', ')}`;\n }\n }).join('; ');\n}\n"]}
|