@wildo-ai/dev-companion 1.1.12 → 1.1.13

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.
Files changed (88) hide show
  1. package/dist/esm/.tsbuildinfo +1 -1
  2. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
  3. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +8 -6
  4. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
  5. package/dist/esm/companion-api/controllers/companion.controller.d.ts +6 -0
  6. package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
  7. package/dist/esm/companion-api/controllers/companion.controller.js +13 -1
  8. package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
  9. package/dist/esm/core/introspection/resources/creation-home-projection.companion.d.ts.map +1 -1
  10. package/dist/esm/core/introspection/resources/creation-home-projection.companion.js +7 -0
  11. package/dist/esm/core/introspection/resources/creation-home-projection.companion.js.map +1 -1
  12. package/dist/esm/core/introspection/resources/launch-blockers.companion.d.ts +5 -1
  13. package/dist/esm/core/introspection/resources/launch-blockers.companion.d.ts.map +1 -1
  14. package/dist/esm/core/introspection/resources/launch-blockers.companion.js +37 -4
  15. package/dist/esm/core/introspection/resources/launch-blockers.companion.js.map +1 -1
  16. package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts +14 -0
  17. package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts.map +1 -1
  18. package/dist/esm/core/introspection/services/companion-introspection.companion.service.js +48 -0
  19. package/dist/esm/core/introspection/services/companion-introspection.companion.service.js.map +1 -1
  20. package/dist/esm/core/introspection/services/introspection-dependency-tree.companion.d.ts +128 -0
  21. package/dist/esm/core/introspection/services/introspection-dependency-tree.companion.d.ts.map +1 -0
  22. package/dist/esm/core/introspection/services/introspection-dependency-tree.companion.js +180 -0
  23. package/dist/esm/core/introspection/services/introspection-dependency-tree.companion.js.map +1 -0
  24. package/dist/esm/core/introspection/services/introspection-worker-pool.companion.d.ts +9 -0
  25. package/dist/esm/core/introspection/services/introspection-worker-pool.companion.d.ts.map +1 -1
  26. package/dist/esm/core/introspection/services/introspection-worker-pool.companion.js +25 -3
  27. package/dist/esm/core/introspection/services/introspection-worker-pool.companion.js.map +1 -1
  28. package/dist/esm/core/runtime/restart-drain.companion.d.ts +107 -0
  29. package/dist/esm/core/runtime/restart-drain.companion.d.ts.map +1 -0
  30. package/dist/esm/core/runtime/restart-drain.companion.js +237 -0
  31. package/dist/esm/core/runtime/restart-drain.companion.js.map +1 -0
  32. package/dist/esm/executions/services/companion-executions.companion.service.d.ts +18 -1
  33. package/dist/esm/executions/services/companion-executions.companion.service.d.ts.map +1 -1
  34. package/dist/esm/executions/services/companion-executions.companion.service.js +34 -8
  35. package/dist/esm/executions/services/companion-executions.companion.service.js.map +1 -1
  36. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +40 -0
  37. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -1
  38. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +13 -0
  39. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -1
  40. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts +40 -0
  41. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts.map +1 -1
  42. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js +40 -0
  43. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js.map +1 -1
  44. package/dist/esm/i18n/system_enums/application-creation.en.d.ts +5 -0
  45. package/dist/esm/i18n/system_enums/application-creation.en.d.ts.map +1 -1
  46. package/dist/esm/i18n/system_enums/application-creation.en.js +6 -0
  47. package/dist/esm/i18n/system_enums/application-creation.en.js.map +1 -1
  48. package/dist/esm/i18n/system_enums/application-creation.fr.d.ts +5 -0
  49. package/dist/esm/i18n/system_enums/application-creation.fr.d.ts.map +1 -1
  50. package/dist/esm/i18n/system_enums/application-creation.fr.js +5 -0
  51. package/dist/esm/i18n/system_enums/application-creation.fr.js.map +1 -1
  52. package/dist/esm/i18n/system_enums/workbench-build.en.d.ts +2 -0
  53. package/dist/esm/i18n/system_enums/workbench-build.en.d.ts.map +1 -1
  54. package/dist/esm/i18n/system_enums/workbench-build.en.js +2 -0
  55. package/dist/esm/i18n/system_enums/workbench-build.en.js.map +1 -1
  56. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts +5 -1
  57. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts.map +1 -1
  58. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js +5 -1
  59. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js.map +1 -1
  60. package/dist/esm/meta-workflows/models/playbook-run-record.models.d.ts +12 -0
  61. package/dist/esm/meta-workflows/models/playbook-run-record.models.d.ts.map +1 -1
  62. package/dist/esm/meta-workflows/models/playbook-run-record.models.js +9 -0
  63. package/dist/esm/meta-workflows/models/playbook-run-record.models.js.map +1 -1
  64. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +80 -4
  65. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
  66. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +235 -42
  67. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
  68. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts +56 -3
  69. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts.map +1 -1
  70. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js +182 -33
  71. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js.map +1 -1
  72. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts +58 -0
  73. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts.map +1 -1
  74. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js +116 -2
  75. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
  76. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts +12 -0
  77. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts.map +1 -1
  78. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js +31 -7
  79. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js.map +1 -1
  80. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts +2 -2
  81. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts.map +1 -1
  82. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js +10 -8
  83. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js.map +1 -1
  84. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +67 -2
  85. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
  86. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +243 -48
  87. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
  88. package/package.json +17 -17
@@ -32,6 +32,7 @@ import * as path from 'node:path';
32
32
  import { join } from 'node:path';
33
33
  import { loadDraftFamilyValues } from '../../core/context/draft-family-values.companion.js';
34
34
  import { InFlightWorkHeartbeat } from '../../core/runtime/in-flight-work-heartbeat.companion.js';
35
+ import { companionRestartDrain } from '../../core/runtime/restart-drain.companion.js';
35
36
  import { getFrameworkKnowledgePlaybook, listFrameworkKnowledgePlaybooks, listFrameworkKnowledgeSkillSummaries, readCompiledResearchInformedContent, readFrameworkKnowledgeSkillBody } from '@wildo-ai/framework-knowledge';
36
37
  import { MetaWorkflow_EvaluationTreatmentDefinitionSchema, MetaWorkflow_EvaluationVerdict, MetaWorkflow_Executor, MetaWorkflow_ClarificationAction, } from '@wildo-ai/saas-models/meta-workflows';
37
38
  import { APPLICATION_SPECIFICATION_SEMANTIC_SCHEMA_BINDINGS, composeElicitationSection, dispatchOutcomeStepRef, BUILD_DECOMPOSE_INPUT_FAMILIES, STANDARD_APPLICATION_SPECIFICATION_SEMANTIC_AUTHORITY, evaluatePlaybookCatalogEligibility, buildApplicationCoherenceReport, collectHeldDraftUndeclaredFactCitations, composeAssuranceDocumentBlueprintBrief, composeAssuranceDocumentFactObligationsBrief, renderAssuranceDocumentClaimGuardsForJudge, composeAssuranceEvidenceBrief, composeAuthoredDocumentFactsBrief, composeAssuranceProgramAuthorityBrief, composeApplicationRoleGraphBrief, deriveOneFamilyFreshness, resolveStepOutputSchema, runPlaybookChoreography, countCheckpointedRounds, describeStaleOutput, describePlaybookRerun, measureChangedAspects, PlaybookLaneBoundaryDecision, collectPlaybookLaneBoundaries, isJudgeVerdictStepRef, buildPlaybookReviewGuide, evaluatePlaybookEligibility, applicationLineRefusalOf, getFamilyPackageRelativePath, resolvePlaybookOutputLandingTarget, getLandableArtifactFamilies, isPlaybookGenerationSuspension, renderApplicationCoherenceReport, renderDeclaredInputFamily, composeDeclaredInputWithheldAspects, composeMarketFitScoresSection, composeRiskSignalsSection, widenDeclaredInputAspects, ARTIFACT_PRESENT_WITHOUT_VALUE, collectConvenedExpertRoles, committedCharterRoleRefs, partitionUnstaffedExpertRoles, rederivableExpertRoleRefs, renderPlaybookReviewGuide, runPlaybookGeneration, readPlaybookOutputLandingBaselines, PlaybookOutputLandingConflictError, PlaybookOutputLandingHeldError, SpecificationWriteRefusedError, writeSpecificationFileAtomicallySync, DEFAULT_MAXIMUM_CLARIFICATION_ROUNDS, accumulateClarificationRequests, validateClarificationAnswers, composeClarificationAnswersSection, runPlaybookJudge, runPlaybookLoop, PlaybookGenerationPurpose, composeBillingCommercialModelBrief, composeOperatingJurisdictionCoverageBrief, composeOperatingJurisdictionsSection, composeCreatorStatedFactsSection, projectPlaybookElicitationAsDecision, answersNoLongerOffered, materializeElicitationOptions, readAnswersForPlaybookQuestions, readNonAnswersForPlaybookQuestions, resolveElicitationAnswers, resolveElicitationNonAnswers, buildCreatorInputLatestReadAnswerByPlaybook, resolveApplicationLineScope, collectFamiliesDeactivatedByDecisions, isFamilyNotApplicable, describeApplicationActiveSet, narrowRefinementRound, refinementDependencyMaps, LANDED_SPECIFICATION_CONSTANT_PREFIX, findReadersDatedByWaitingInterviews, selectInterviewsWaitingOnThePerson, readInterviewDepthFromState, PlaybookRerunKind, } from '@wildo-ai/application-creation-runtime';
@@ -78,6 +79,9 @@ import { awaitModelProviderRecovery, isEnvironmentalPlaybookFailure, readPlayboo
78
79
  import { findOverlappingRootRuns, projectLastPlaybookLoop, projectPlaybookRunRecords, readPlaybookRunMeasurement, summarizePlaybookLoopResult, summarizePlaybookRunResult } from '../models/playbook-run-record.models.js';
79
80
  // The playbook a build WAVE runs as (#2208): any CODING_AGENT-tier playbook runs a wave, and this is the one the build console starts.
80
81
  import { BUILD_WAVE_PLAYBOOK_REF, PLAYBOOK_SPEND_NOT_OBSERVED, mergePlaybookSpend } from '@wildo-ai/application-creation-runtime';
82
+ // The maturity reading, derived live for the drive's requirements standing (#3701), from the inputs its executor lands.
83
+ import { deriveApplicationMaturity } from '@wildo-ai/application-creation-runtime';
84
+ import { listRequirementOpenItems } from '@wildo-ai/saas-specifications/application-creation';
81
85
  import { PlaybookSpendMeterCompanionService } from './playbook-spend-meter.companion.service.js';
82
86
  import { DossierCompanionService } from './dossier.companion.service.js';
83
87
  import { proposeInterviewAnswers } from './interview-answer-proposal.companion.js';
@@ -2124,6 +2128,11 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2124
2128
  readArtifactState: () => this.traceRunPhase(input.session, 'choreography-artifact-state', () => this.readArtifactState()),
2125
2129
  // A quick interview's skipped questions are assumed rather than waited on (#2129), for every lane of the tree.
2126
2130
  assumeInterviewAnswers: (request) => this.assumeInterviewAnswers(request),
2131
+ // A round waits at its top while the dev supervisor holds a restart, so the restart kills nothing (#3204); waiting on
2132
+ // its children it is paused, and a nested lane is counted as a run of its own.
2133
+ awaitRestartWindow: () => this.awaitRestartWindow(),
2134
+ whilePaused: (work) => companionRestartDrain.whilePaused(work),
2135
+ whileWorking: (work) => this.whileDrainCounted(work),
2127
2136
  // Before the first tree read: a composite whose children its line runs none of stops here (#1639).
2128
2137
  readApplicationLineScope: () => this.traceRunPhase(input.session, 'application-line-scope', () => this.readApplicationLineScope()),
2129
2138
  // Every selection and child dispatch is measured, so the row records spend per iteration and per child (#1507).
@@ -2159,7 +2168,13 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2159
2168
  * re-dispatched until the iteration ceiling (reference run 42120979649).
2160
2169
  */
2161
2170
  readProviderAccountRefusal: readPlaybookFailureProviderAccountRefusal,
2162
- runChild: async (playbookRef, objective, stepResults, dispatchingCompositeRef) => {
2171
+ /*
2172
+ * One RUN for the restart drain (#3204 second review H1): the parent is PAUSED while its round's children run, so each
2173
+ * child is counted here, whole: its prelude, a research agent's screening and evidence records, a step output's model
2174
+ * call, and the compile wait after it. A child that IS a playbook run pauses this count while `runPlaybook` counts
2175
+ * itself (`runChoreographyChild`), so it is counted once.
2176
+ */
2177
+ runChild: (playbookRef, objective, stepResults, dispatchingCompositeRef) => this.whileDrainCounted(async () => {
2163
2178
  const parentElicitationSection = withInstancePurposeSection(await this.composeDispatchingElicitationSection({
2164
2179
  dispatchingCompositeRef,
2165
2180
  ownRef: input.playbook.ref,
@@ -2230,7 +2245,7 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2230
2245
  },
2231
2246
  }).catch((error) => this.logDebug('Could not wait for the application packages to publish', { afterChild: playbookRef, error: describeCaughtError(error) }));
2232
2247
  }
2233
- },
2248
+ }),
2234
2249
  select: {
2235
2250
  /*
2236
2251
  * The DISPATCHING composite's round, not the root's (#1577): its declared inputs and its interview.
@@ -2582,7 +2597,8 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2582
2597
  });
2583
2598
  return { stepResults: new Map([[stepOutput.ref, value]]) };
2584
2599
  }
2585
- const run = await this.runPlaybook({
2600
+ // `runPlaybook` counts itself for the restart drain, so the child's own count (`runChild`) pauses meanwhile (#3204).
2601
+ const run = await this.whileDrainPaused(() => this.runPlaybook({
2586
2602
  playbookRef: input.playbookRef,
2587
2603
  /*
2588
2604
  * The objective is the choreography SELECTOR's words for this child, never the creator's. It was
@@ -2604,7 +2620,7 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2604
2620
  ...(input.parentElicitationSection ? { parentElicitationSection: input.parentElicitationSection } : {}),
2605
2621
  ...(input.dryRun === true ? { dryRun: true } : {}),
2606
2622
  ...(input.session ? { session: input.session } : {}),
2607
- });
2623
+ }));
2608
2624
  /*
2609
2625
  * Narrowed on `landedValues`, not on `landed`. A nested CHOREOGRAPHY result also carries `landed`,
2610
2626
  * so the obvious discriminator admits a union member that has no values to hand back — caught by
@@ -4384,6 +4400,10 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
4384
4400
  readArtifactState: () => this.readArtifactState(),
4385
4401
  // A quick interview's skipped questions are assumed rather than waited on (#2129).
4386
4402
  assumeInterviewAnswers: (request) => this.assumeInterviewAnswers(request),
4403
+ // An iteration waits at its top while the dev supervisor holds a restart, so the restart kills nothing (#3204); waiting
4404
+ // on its lanes, which are runs counted themselves, it is paused.
4405
+ awaitRestartWindow: () => this.awaitRestartWindow(),
4406
+ whilePaused: (work) => companionRestartDrain.whilePaused(work),
4387
4407
  // Lanes of one iteration call this CONCURRENTLY. Safe because admitted lanes are output-disjoint
4388
4408
  // by construction and the write register records per run — where "output" is a lane's TRANSITIVE
4389
4409
  // write scope (`resolvePlaybookWriteScope`), so a composite lane is judged by what its children
@@ -5126,10 +5146,45 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
5126
5146
  const byValue = typeof error === 'object' && error !== null ? this.runMeasurements.get(error) : undefined;
5127
5147
  return byValue ?? (runId !== undefined ? this.failedRunMeasurements.get(runId) : undefined);
5128
5148
  }
5129
- /** The run options for ONE run: the shared readings, plus a failure record that can find this run's spend by id. */
5149
+ /**
5150
+ * Build-plan runs whose read of the tasks already built FAILED (#3449, R10), by run id, with why: the re-decompose ran
5151
+ * unheld. Written onto the run's own row by {@link playbookRunOptionsFor} however the run ends, then forgotten.
5152
+ *
5153
+ * Created on first use rather than as a field initialiser: test harnesses build this service without running field
5154
+ * initialisers (the executions service lazily creates its maps for the same reason), and a field-initialised Map is
5155
+ * absent there, so the first `get` threw. A real companion constructs it normally either way.
5156
+ */
5157
+ builtTasksUnreadByRun;
5158
+ builtTasksUnreadRuns() {
5159
+ return (this.builtTasksUnreadByRun ??= new Map());
5160
+ }
5161
+ /**
5162
+ * The run options for ONE run: the shared readings, plus a failure record that can find this run's spend by id, and the
5163
+ * marker of a re-decompose that could not read the tasks already built (`builtTasksUnread`), on every ending.
5164
+ */
5130
5165
  playbookRunOptionsFor(runIdOf) {
5166
+ const takeBuiltTasksUnread = () => {
5167
+ const runId = runIdOf();
5168
+ const reason = runId === undefined ? undefined : this.builtTasksUnreadRuns().get(runId);
5169
+ if (runId !== undefined)
5170
+ this.builtTasksUnreadRuns().delete(runId);
5171
+ return reason === undefined ? undefined : { builtTasksUnread: reason };
5172
+ };
5173
+ const shared = this.playbookRunOptions;
5131
5174
  return {
5132
- ...this.playbookRunOptions,
5175
+ ...shared,
5176
+ suspendOn: (result) => {
5177
+ const request = shared.suspendOn?.(result) ?? null;
5178
+ if (request === null)
5179
+ return null;
5180
+ const marker = takeBuiltTasksUnread();
5181
+ return marker === undefined ? request : { ...request, taskOutput: { ...request.taskOutput, ...marker } };
5182
+ },
5183
+ concludeAs: (result) => {
5184
+ const conclusion = shared.concludeAs?.(result) ?? null;
5185
+ const marker = takeBuiltTasksUnread();
5186
+ return conclusion === null || marker === undefined ? conclusion : { ...conclusion, taskOutput: { ...conclusion.taskOutput, ...marker } };
5187
+ },
5133
5188
  recordBesideFailure: (error) => {
5134
5189
  const runId = runIdOf();
5135
5190
  const measurement = this.measurementOfFailure(error, runId);
@@ -5137,11 +5192,37 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
5137
5192
  ?? (runId !== undefined ? this.failedRunOverlaps.get(runId) : undefined);
5138
5193
  if (runId !== undefined)
5139
5194
  this.failedRunOverlaps.delete(runId);
5140
- const beside = { ...(measurement ? { measurement } : {}), ...(overlappedRuns && overlappedRuns.length > 0 ? { overlappedRuns } : {}) };
5195
+ const beside = { ...(measurement ? { measurement } : {}), ...(overlappedRuns && overlappedRuns.length > 0 ? { overlappedRuns } : {}), ...takeBuiltTasksUnread() };
5141
5196
  return Object.keys(beside).length > 0 ? beside : null;
5142
5197
  },
5143
5198
  };
5144
5199
  }
5200
+ /**
5201
+ * The tasks already built, for a run producing the build plan (#3449), or `undefined` when there is nothing to keep or
5202
+ * they could not be read. When they could not be read and a plan exists, the re-decompose runs UNHELD (R10): it is not
5203
+ * stopped, because a plan that cannot be read is often what the re-decompose repairs, but it says so, as a warning
5204
+ * naming the run and as `builtTasksUnread` on the run's row. Until R10 this was a debug line, so a re-decompose that
5205
+ * rewrote built work left nothing to find.
5206
+ */
5207
+ async readBuiltTasksForBuildPlanRun(input) {
5208
+ let reason;
5209
+ try {
5210
+ const evidence = await this.buildDispatch.resolveLandedTaskEvidence();
5211
+ if (evidence !== undefined)
5212
+ return evidence.landedTasks;
5213
+ // Absent is two things: no plan yet (nothing to keep), or a plan that exists and did not read.
5214
+ if (!(await this.buildDispatch.hasAuthoredBuildPlan()))
5215
+ return undefined;
5216
+ reason = 'the build plan exists but could not be read (its module failed or it does not satisfy its schema)';
5217
+ }
5218
+ catch (error) {
5219
+ reason = describeCaughtError(error);
5220
+ }
5221
+ this.builtTasksUnreadRuns().set(input.runId, reason);
5222
+ this.logger.warn(`${input.playbookRef} (run ${input.runId}) could not read the build tasks already built, so this re-decompose is NOT held to keep `
5223
+ + `their refs, targets and products: ${reason}. Recorded on the run's row as builtTasksUnread.`, { playbookRef: input.playbookRef, runId: input.runId });
5224
+ return undefined;
5225
+ }
5145
5226
  playbookRunOptions = createPlaybookRunOptions(this.suspensionRequests, this.runMeasurements, this.runOverlaps);
5146
5227
  /**
5147
5228
  * Every choreography that ENDED without concluding and left its progress on its execution row —
@@ -5309,6 +5390,14 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
5309
5390
  if (derivable.length === 0) {
5310
5391
  return { heldTaskRefs, ran: false, detail: 'Every stale charter was edited by a person and is never derived again: update it by hand and commit it.' };
5311
5392
  }
5393
+ /*
5394
+ * Not while the dev supervisor holds a restart (#3204 review F5): it is a new run, which the restart would wait on or
5395
+ * kill. The hold stays, so the next round, in the restarted companion, meets it and derives the charters then.
5396
+ */
5397
+ const saasRoot = this.companionContext?.saasRoot;
5398
+ if (saasRoot !== undefined && companionRestartDrain.isRestartHeld(saasRoot)) {
5399
+ return { heldTaskRefs, ran: false, detail: `${EXPERT_STAFFING_PLAYBOOK_REF} not run: the dev supervisor is holding a restart; the next round runs it.` };
5400
+ }
5312
5401
  try {
5313
5402
  await this.runPlaybook({
5314
5403
  playbookRef: EXPERT_STAFFING_PLAYBOOK_REF,
@@ -5445,7 +5534,43 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
5445
5534
  */
5446
5535
  priorLeg) {
5447
5536
  // Counted here as well as at every entry, so a caller added later is covered while it executes.
5448
- return this.whileInFlight(() => this.executePlaybookRunCounted(input, priorLeg));
5537
+ // Not drain-counted HERE: every path into it is counted once, at its entry, for the run's whole life (#3204).
5538
+ return this.whileInFlight(() => this.executePlaybookRunCounted(input, priorLeg), { drainCounted: false });
5539
+ }
5540
+ /**
5541
+ * Count `work` as one RUN for the restart drain (#3204): busy for its whole life unless paused (parked at the restart
5542
+ * window, or waiting on children counted themselves). Without an application root there is no supervisor to drain for.
5543
+ */
5544
+ whileDrainCounted(work) {
5545
+ const saasRoot = this.companionContext?.saasRoot;
5546
+ return saasRoot === undefined ? work() : companionRestartDrain.whileWorking(saasRoot, work);
5547
+ }
5548
+ /** {@link whileDrainCounted}'s pause: the counted run calling it waits on work that counts itself. */
5549
+ whileDrainPaused(work) {
5550
+ return this.companionContext?.saasRoot === undefined ? work() : companionRestartDrain.whilePaused(work);
5551
+ }
5552
+ /** {@link whileDrainCounted} for a run whose life spans a detached chain: counted until the release is called. */
5553
+ beginDrainCounted() {
5554
+ const saasRoot = this.companionContext?.saasRoot;
5555
+ return saasRoot === undefined ? () => undefined : companionRestartDrain.begin(saasRoot);
5556
+ }
5557
+ /**
5558
+ * The restart window the creation loop and every choreography wait at before dispatching (#3204): returns at once
5559
+ * unless the dev supervisor is holding a restart, and otherwise parks this round until the restart comes. Said once per
5560
+ * park in the log, since a parked round is otherwise silent.
5561
+ */
5562
+ async awaitRestartWindow() {
5563
+ // No application root, no supervisor to wait for: a harness, or a companion not started from one.
5564
+ const saasRoot = this.companionContext?.saasRoot;
5565
+ if (saasRoot === undefined)
5566
+ return;
5567
+ return companionRestartDrain.awaitRestartWindow(saasRoot, (held) => {
5568
+ this.logger.info('A restart is held by the dev supervisor: this round waits at its boundary and starts nothing, so the restart '
5569
+ + 'finds nothing running; the run continues after the restart', { reason: held.reason, heldSince: held.since });
5570
+ }, (held) => {
5571
+ this.logger.warn('A restart has been held past the supervisor\'s own ceiling and is still published: the round goes on rather '
5572
+ + 'than waiting for ever', { reason: held.reason, heldSince: held.since });
5573
+ });
5449
5574
  }
5450
5575
  async executePlaybookRunCounted(input, priorLeg) {
5451
5576
  const startedAtMs = Date.now();
@@ -6025,18 +6150,8 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
6025
6150
  * for an application — the measurement moves, and the next requirement lowers it again.
6026
6151
  */
6027
6152
  if (input.playbookRef === APPLICATION_MATURITY_PLAYBOOK_REF) {
6028
- const decidedFamilyValues = {};
6029
- for (const [family, value] of artifactState.artifactsByFamily) {
6030
- if (value === undefined || value === null || value === FILE_PRESENT_WITHOUT_VALUE)
6031
- continue;
6032
- decidedFamilyValues[family] = value;
6033
- }
6034
- /*
6035
- * The landing probe's own sets, read from the build dispatch rather than recomputed here: what
6036
- * LANDED is a question the landing pass answers over the WORKING tree (#3204), and a second
6037
- * implementation of that question is how two surfaces come to disagree about whether a task is done.
6038
- */
6039
- const evidence = await this.buildDispatch.resolveLandedTaskEvidence();
6153
+ // One composition of the reading's inputs, shared with the drive's requirements standing (#3701).
6154
+ const maturityInputs = await this.composeApplicationMaturityInputs(artifactState);
6040
6155
  return this.landDeterministicExecutorRun({
6041
6156
  ...deterministicLanding,
6042
6157
  // A reading of the build's landed tasks, which are application code and no family: dated by the code (#3237 review H1).
@@ -6046,12 +6161,7 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
6046
6161
  execute: (noteWrite) => this.applicationMaturityExecutor.execute({
6047
6162
  onWillWrite: (paths) => { for (const written of this.toApplicationRelativeSpecificationPaths(paths))
6048
6163
  noteWrite(written); },
6049
- inputs: {
6050
- decidedFamilyValues,
6051
- ...(evidence === undefined ? {} : { landedTaskRefs: evidence.landedTaskRefs, provenTaskRefs: evidence.provenTaskRefs }),
6052
- // What a coding run reported still unmet caps its requirement below VERIFIED, naming the follow-up (#2580).
6053
- ...(evidence?.openReportedGaps === undefined ? {} : { openReportedGaps: evidence.openReportedGaps }),
6054
- },
6164
+ inputs: maturityInputs,
6055
6165
  ...(input.dryRun === true ? { dryRun: true } : {}),
6056
6166
  }),
6057
6167
  });
@@ -6103,15 +6213,10 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
6103
6213
  * The build tasks already built (#3449), read once for a run producing the build plan: the brief names them so the
6104
6214
  * model keeps them, and the normalizer refuses an answer that drops or renames one, or changes its target or what it
6105
6215
  * produces (#3204). ONE read for both, so the two cannot disagree about what was built. Unreadable is absent, never
6106
- * empty: "not read" is not "nothing landed".
6216
+ * empty: "not read" is not "nothing landed", and it is loud (R10, `readBuiltTasksForBuildPlanRun`).
6107
6217
  */
6108
6218
  const producesBuildPlan = (playbook.outputs ?? []).some((output) => output.family === ApplicationSpecificationFamily.BUILD_PLAN);
6109
- const landedBuildTasks = producesBuildPlan
6110
- ? (await this.buildDispatch.resolveLandedTaskEvidence().catch((error) => {
6111
- this.logDebug('The landed build tasks could not be read; the re-decompose is not held to them', { error: describeCaughtError(error) });
6112
- return undefined;
6113
- }))?.landedTasks
6114
- : undefined;
6219
+ const landedBuildTasks = producesBuildPlan ? await this.readBuiltTasksForBuildPlanRun(input) : undefined;
6115
6220
  const landedBuildTasksSection = landedBuildTasks === undefined || landedBuildTasks.length === 0 ? '' : [
6116
6221
  '# Build tasks already built (keep every one, under its ref, with its target and products)',
6117
6222
  'These tasks of the current build plan are built and committed. Your plan keeps each of them, under the same ref (author',
@@ -7523,6 +7628,79 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
7523
7628
  * no `engineCapabilities` key at all is read the same way: the blind brief and no refusal, which errs
7524
7629
  * toward refusing less rather than refusing on a capability set nobody declared.
7525
7630
  */
7631
+ /**
7632
+ * The maturity reading's inputs (#1496), composed ONCE for its two readers: the `bottom_up.maturity-reading` executor,
7633
+ * which lands the reading, and {@link readRequirementsStanding}, which the unattended drive reads before it may call the
7634
+ * goal reached (#3701). Two compositions would be two answers to "where does the application stand".
7635
+ *
7636
+ * - the landed family VALUES (a family present only as a file contributes nothing);
7637
+ * - the landing probe's own sets, read from the build dispatch rather than recomputed here: what LANDED is a question
7638
+ * the landing pass answers over the WORKING tree (#3204), and a second implementation of that question is how two
7639
+ * surfaces come to disagree about whether a task is done;
7640
+ * - the gaps coding runs reported and that are still open, which cap their requirement below VERIFIED (#2580);
7641
+ * - the CONFIGURATION a requirement's declared substance is measured against (#3702): the engine capabilities the
7642
+ * application enables and the languages it serves. Absent when either cannot be read, which the reading reports as
7643
+ * such on every requirement that declares a need, rather than as met.
7644
+ */
7645
+ async composeApplicationMaturityInputs(artifactState) {
7646
+ const decidedFamilyValues = {};
7647
+ for (const [family, value] of artifactState.artifactsByFamily) {
7648
+ if (value === undefined || value === null || value === FILE_PRESENT_WITHOUT_VALUE)
7649
+ continue;
7650
+ decidedFamilyValues[family] = value;
7651
+ }
7652
+ const evidence = await this.buildDispatch.resolveLandedTaskEvidence();
7653
+ const applicationConfiguration = this.readMaturityConfigurationFacts();
7654
+ return {
7655
+ decidedFamilyValues,
7656
+ ...(evidence === undefined ? {} : { landedTaskRefs: evidence.landedTaskRefs, provenTaskRefs: evidence.provenTaskRefs }),
7657
+ ...(evidence?.openReportedGaps === undefined ? {} : { openReportedGaps: evidence.openReportedGaps }),
7658
+ ...(applicationConfiguration === undefined ? {} : { applicationConfiguration }),
7659
+ };
7660
+ }
7661
+ /**
7662
+ * What the application's configuration turns on (#3702), for the maturity reading: the enabled engine capabilities
7663
+ * (`wildo.saas.config.ts`; none declared is none enabled) and the languages served, through the one reader the i18n
7664
+ * step and the capability composition share. `undefined` when the configuration could not be read: an unknown, never
7665
+ * an empty configuration.
7666
+ */
7667
+ readMaturityConfigurationFacts() {
7668
+ if (this.companionContext?.saasConfig === undefined)
7669
+ return undefined;
7670
+ let config;
7671
+ try {
7672
+ config = this.appConfigService?.config;
7673
+ }
7674
+ catch {
7675
+ return undefined;
7676
+ }
7677
+ if (config === undefined || config === null)
7678
+ return undefined;
7679
+ return {
7680
+ enabledEngineCapabilities: this.readEnabledEngineCapabilities() ?? [],
7681
+ servedLanguages: getCompanionServedLanguages(config),
7682
+ };
7683
+ }
7684
+ /**
7685
+ * Where the application stands against its own requirements NOW, for the unattended drive (#3701): the maturity reading
7686
+ * derived live from the same inputs the reading's executor lands, and every item still open on it. Derived rather than
7687
+ * read from the landed reading, which is only as current as the last time the reading's playbook ran: the reference run
7688
+ * stopped minutes after its last landing, and a stop rule must not judge the creation by a photograph.
7689
+ */
7690
+ async readRequirementsStanding() {
7691
+ const reading = deriveApplicationMaturity(await this.composeApplicationMaturityInputs(await this.readArtifactState()));
7692
+ return {
7693
+ measuredAt: new Date().toISOString(),
7694
+ stage: reading.stage,
7695
+ requirementCount: reading.requirements.length,
7696
+ openItems: listRequirementOpenItems(reading).map((item) => ({
7697
+ requirementRef: item.requirementRef,
7698
+ kind: item.kind,
7699
+ detail: item.detail,
7700
+ closedByTaskRef: item.closedByTaskRef ?? null,
7701
+ })),
7702
+ };
7703
+ }
7526
7704
  readEnabledEngineCapabilities() {
7527
7705
  const declared = this.companionContext.saasConfig?.engineCapabilities;
7528
7706
  if (declared === undefined)
@@ -8623,11 +8801,16 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
8623
8801
  * executes even if nobody remembers to wrap it. Nested counts are harmless: the file beats while the
8624
8802
  * count is above zero.
8625
8803
  */
8626
- async whileInFlight(work) {
8804
+ async whileInFlight(work, options = {}) {
8627
8805
  this.playbookExecutionsInFlight = (this.playbookExecutionsInFlight ?? 0) + 1;
8628
8806
  this.syncPlaybookRunHeartbeat();
8629
8807
  try {
8630
- return await work();
8808
+ /*
8809
+ * One RUN for the restart drain too (#3204), at the same entry points and for the same whole life, settle included.
8810
+ * The inner `executePlaybookRun` wrap passes `drainCounted: false`: counted twice, one paused run would still read
8811
+ * busy, and a held restart would never drain.
8812
+ */
8813
+ return await (options.drainCounted === false ? work() : this.whileDrainCounted(work));
8631
8814
  }
8632
8815
  finally {
8633
8816
  this.playbookExecutionsInFlight = Math.max(0, (this.playbookExecutionsInFlight ?? 1) - 1);
@@ -8907,24 +9090,36 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
8907
9090
  * run that silently never happened — and the work is completed detached against the opened ids.
8908
9091
  * Until 2026-09-20 this minted its own id and handed it in; a submission and its row now share one.
8909
9092
  */
9093
+ // Counted for the restart drain from BEFORE the open (#3204 second review L1): no drained marker between the start and the chain.
9094
+ const releaseOpeningCount = this.beginDrainCounted();
8910
9095
  const opened = await this.actorsSystem.openActorExecution(this.buildActorExecutionRequest(input))
8911
9096
  .catch(async (error) => {
9097
+ releaseOpeningCount();
8912
9098
  const subject = this.resolveExclusiveSubject(input);
8913
9099
  throw subject === undefined ? error : await this.nameTheRunHoldingTheSubject(error, MetaWorkflowsExclusiveSubject.COMPOSITE, subject, input.session);
8914
9100
  });
8915
9101
  const runId = opened.executionId;
8916
- // Registered BEFORE the run is started, so a caller that polls immediately cannot see a gap in
8917
- // which its own submission is reported nowhere.
8918
- this.runningDetachedRuns.set(runId, {
8919
- runId,
8920
- playbookRef: input.playbookRef,
8921
- ...(input.instanceKey ? { instanceKey: input.instanceKey } : {}),
8922
- startedAt,
8923
- ...(input.session ? { traceSessionId: input.session.sessionId } : {}),
8924
- ...(input.conversationId ? { conversationId: input.conversationId } : {}),
8925
- });
8926
- this.syncPlaybookRunHeartbeat();
8927
- void this.actorsSystem
9102
+ try {
9103
+ // Registered BEFORE the run is started, so a caller that polls immediately cannot see a gap in
9104
+ // which its own submission is reported nowhere.
9105
+ this.runningDetachedRuns.set(runId, {
9106
+ runId,
9107
+ playbookRef: input.playbookRef,
9108
+ ...(input.instanceKey ? { instanceKey: input.instanceKey } : {}),
9109
+ startedAt,
9110
+ ...(input.session ? { traceSessionId: input.session.sessionId } : {}),
9111
+ ...(input.conversationId ? { conversationId: input.conversationId } : {}),
9112
+ });
9113
+ this.syncPlaybookRunHeartbeat();
9114
+ }
9115
+ catch (error) {
9116
+ // Never leak the opening count (second review L4): a leaked count would keep the companion from ever draining.
9117
+ releaseOpeningCount();
9118
+ throw error;
9119
+ }
9120
+ // One RUN for the restart drain (#3204) from start to settle: the record and the chain's next round come after the work.
9121
+ // The chain's count starts before `work` is called, so releasing the opening count inside it leaves no gap.
9122
+ void this.whileDrainCounted(() => (releaseOpeningCount(), this.actorsSystem)
8928
9123
  .completeActorExecution(opened, async () => {
8929
9124
  // Where the build stood BEFORE the round, so its end can tell a round that moved from one that did not.
8930
9125
  // Only where a relaunch could read it (#1639): a dry run or a posture that never relaunches pays nothing here.
@@ -8993,7 +9188,7 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
8993
9188
  ...(input.session ? { traceSessionId: input.session.sessionId } : {}),
8994
9189
  ...(input.conversationId ? { conversationId: input.conversationId } : {}),
8995
9190
  });
8996
- });
9191
+ }));
8997
9192
  return {
8998
9193
  accepted: false,
8999
9194
  async: true,