@wildo-ai/dev-companion 1.1.15 → 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 +165 -5
- 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 +239 -8
- 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 +2 -1
- 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 +2 -1
- 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/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 +20 -0
- 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 +27 -12
- 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 +155 -3
- 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 +791 -151
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
- 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/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/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/system_enums/workbench-build.en.d.ts +1 -1
- package/dist/esm/i18n/system_enums/workbench-build.en.js +1 -1
- package/dist/esm/i18n/system_enums/workbench-build.en.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 +12 -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 +99 -1
- 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 +67 -20
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +344 -76
- 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.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js +9 -0
- 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 +38 -2
- 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 +176 -22
- 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/creation-run-report.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js +9 -1
- 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 +64 -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 +139 -14
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concurrent-coding-runs.models.js","sourceRoot":"","sources":["../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YAAY,GAAG,KAAK,CAAC,cAAc;aACtC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;aACvC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;QACtG,IAAI,YAAY,KAAK,SAAS;YAAE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * Several coding runs in ONE worktree at once (#1528) — the pure half: what they hold, what each one\n * records about the others, and how a failure that may be another run's doing is kept from retiring a\n * task.\n *\n * The decision this serves, in Paul's words (2026-09-24): concurrent agents editing the same tree\n * reconcile fine in practice, so the lane does not PREVENT interference — no file separation, no\n * disjoint scopes, no worktree per agent — it DETECTS it and REPAIRS it. Measured on the first\n * end-to-end run's plan: 94 tasks in six waves, wave 2 holding 45 independent tasks, run single-file.\n *\n * What is still exclusive, and why each is the only thing that is:\n * - ONE run per build task at a time: two agents building the same task are a bug, not a collision.\n * That is the engine's exclusive subject, keyed on the task instead of the worktree.\n * - A SINGLE-FLIGHT run and concurrent runs never overlap, in either direction. A single-flight run\n * was promised the tree to itself; and the single-flight door is the one a running agent can reach\n * from its own shell, so refusing it while any run is in flight keeps the P-35 recursion cap\n * EXPLICIT now that the global lock no longer provides it as a side effect.\n * - A git COMMIT takes the workspace lock briefly, because git's own index lock does not tolerate\n * two writers.\n */\nimport { isAbsolute, relative, sep } from 'node:path';\n\nimport { isWritingAcpToolKind, writtenLocationsOfAcpSessionUpdate } from '@wildo-ai/external-connectors-models';\nimport { CodingRunFailureAttribution } from '@wildo-ai/platform-core-shared';\n\nimport { APPLICATION_CODING_WORKTREE_SUBJECT } from '../../meta-workflows/models/application-coding-agent.actors-system.definitions';\nimport { ApplicationCodingTaskDisposition } from './coding-agent-dispatch.models';\n\n/** How a coding run shares the application's working tree. */\nexport enum CodingRunConcurrency {\n /** The lane as it always was: the run holds the worktree subject and the workspace lock for its whole life. */\n SINGLE_FLIGHT = 'single-flight',\n /** One of several runs in one wave: holds only its own task, and takes the workspace lock only to commit. */\n CONCURRENT = 'concurrent',\n}\n\n/** The prefix of a concurrent run's exclusive subject; the task ref follows it. */\nexport const APPLICATION_CODING_TASK_SUBJECT_PREFIX = 'build-task:';\n\n/** What a run holds exclusively: the whole worktree when single-flight, only its own task when concurrent. */\nexport function applicationCodingExclusiveSubject(mode: CodingRunConcurrency, taskRef: string): string {\n return mode === CodingRunConcurrency.CONCURRENT ? `${APPLICATION_CODING_TASK_SUBJECT_PREFIX}${taskRef}` : APPLICATION_CODING_WORKTREE_SUBJECT;\n}\n\n/** True when a live execution's subject says it is a concurrent run. */\nexport function isConcurrentRunSubject(exclusiveSubject: string | undefined): boolean {\n return typeof exclusiveSubject === 'string' && exclusiveSubject.startsWith(APPLICATION_CODING_TASK_SUBJECT_PREFIX);\n}\n\n/** One run's time in the tree, as this process saw it. `changedPaths` is known once it settled. */\nexport interface CodingRunWindow {\n readonly taskId: string;\n readonly taskRef: string;\n readonly startedAtMs: number;\n readonly endedAtMs?: number;\n readonly changedPaths?: readonly string[];\n}\n\n/** What a run records about the runs that shared the tree with it — the observability half of the repair layer. */\nexport interface CodingRunConcurrencyRecord {\n /** Build tasks whose runs were in the tree at some point during this one. */\n readonly overlappingTaskRefs: readonly string[];\n /** Paths this run changed that an overlapping run is known to have changed too: where a collision would be. */\n readonly contendedPaths: readonly string[];\n /**\n * Whether any overlapping run may have written to the tree (#2389 review F5): one still running, one that ended\n * without reporting its paths (a park), or one that settled having changed something. `false` only when every\n * overlapping run settled and changed NOTHING — runs the coding agent's usage limit refused, typically — and then\n * no sibling can have turned a shared check red. Absent on a record written before this field: read as `true`.\n */\n readonly overlappingRunsMayHaveWritten?: boolean;\n}\n\n/**\n * Which runs overlapped `self`, and which of its changed paths they touched too. Pure over the windows\n * this process holds. A sibling still running has no `changedPaths` yet, so a contention with it is\n * recorded by whichever of the two settles LATER — every pair is reported once, by one side.\n */\nexport function describeRunConcurrency(\n windows: readonly CodingRunWindow[],\n self: { readonly taskId: string; readonly startedAtMs: number; readonly endedAtMs: number },\n selfChangedPaths: readonly string[],\n): CodingRunConcurrencyRecord {\n const overlapping = windows.filter((window) => window.taskId !== self.taskId\n && window.startedAtMs < self.endedAtMs\n && (window.endedAtMs === undefined || window.endedAtMs > self.startedAtMs));\n const siblingPaths = new Set(overlapping.flatMap((window) => window.changedPaths ?? []));\n return {\n overlappingTaskRefs: [...new Set(overlapping.map((window) => window.taskRef))].sort(),\n contendedPaths: [...new Set(selfChangedPaths.filter((path) => siblingPaths.has(path)))].sort(),\n overlappingRunsMayHaveWritten: overlapping.some((window) => window.changedPaths === undefined || window.changedPaths.length > 0),\n };\n}\n\n/**\n * Whether a failed run may have failed for a SIBLING's writes (#2389) — the `interferenceSuspected` flag,\n * derived once. Overlap in time is the precondition, never the verdict: the flag also buys a forgiveness\n * from the attempt budget ({@link selectBudgetCountingFailures}), so it must name only failures the tree\n * could have caused.\n *\n * - A HOST failure never: the turn was taken away (a provider limit, a killed process, an operator's\n * cancel) or the run could not be recorded. Measured on app-creation-test-005: four tasks failed on the\n * coding agent's session limit, changed nothing, contended nothing, and every attempt read\n * `interferenceSuspected: true` because another run was in the tree — and past the host bound each one\n * drew an interference forgiveness, so the label hid two failures the budget should have seen.\n * - A failed CHECK, whenever an overlapping run may have written: a sibling's write to any file can turn a\n * shared check red (a typecheck spans the package), and a sibling still running has not reported its paths,\n * so its overlap alone is the signal. Narrowing it to `contendedPaths` would miss exactly that case. Siblings\n * that all settled having changed nothing cannot have caused it (#2389 review F5), so they do not count.\n * - The agent failing at its own work: only when a path it changed was changed by a sibling too — the one\n * way a sibling can have reached the turn itself. A run that changed nothing contended nothing.\n */\nexport function deriveInterferenceSuspected(input: {\n readonly disposition: ApplicationCodingTaskDisposition;\n readonly failureAttribution: CodingRunFailureAttribution | null;\n readonly concurrency: CodingRunConcurrencyRecord | null;\n}): boolean {\n if (input.concurrency === null || input.concurrency.overlappingTaskRefs.length === 0) return false;\n if (input.failureAttribution !== CodingRunFailureAttribution.TASK) return false;\n switch (input.disposition) {\n case ApplicationCodingTaskDisposition.VERIFICATION_FAILED:\n return input.concurrency.overlappingRunsMayHaveWritten !== false;\n case ApplicationCodingTaskDisposition.AGENT_EXECUTION_FAILED:\n return input.concurrency.contendedPaths.length > 0;\n case ApplicationCodingTaskDisposition.WORKING_RESULT_RECORDED:\n case ApplicationCodingTaskDisposition.AWAITING_OPERATOR_INPUT:\n case ApplicationCodingTaskDisposition.INTERRUPTED_REQUIRES_REVIEW:\n case ApplicationCodingTaskDisposition.CHANGE_SET_CAPTURE_FAILED:\n case ApplicationCodingTaskDisposition.TRACEABILITY_FAILED:\n // It changed nothing, so it contended nothing: a sibling cannot have caused a run to write no file.\n case ApplicationCodingTaskDisposition.OVERRIDE_NOT_REPAIRED:\n return false;\n }\n}\n\n/**\n * Whether a run FAILED ITS CHECKS beside siblings, so the failure may be theirs and only a re-check ALONE can say (#3204).\n * Pure: the wave's end re-checks exactly these runs, and the selector holds their task until it has.\n *\n * Two shapes, and the second is why this is not {@link deriveInterferenceSuspected}:\n * - a check FAILED while an overlapping run may have written (`interferenceSuspected`);\n * - a check could not be ASKED at all (the run is HOST-attributed: every failed check threw, `verificationCouldNotAsk`)\n * while other runs shared the tree. A sibling's half-written file fails a package's compile, its compiled output goes\n * stale, and the registry check refuses to read it (\"dist is older than its sources ... last compile FAILED\"). That is\n * the environment's, so the budget forgives it as a host failure; it is also the siblings', so only a check run alone\n * can tell whether this run's work passes. Measured on reference run 42621319676: every such failure of two schema\n * tasks was HOST-attributed, none was re-checked, and both spent their budget in nine minutes.\n *\n * A run alone (no overlap) is never one: a red check there is the run's, or the host's, and running it again alone is\n * exactly what the next dispatch does.\n */\nexport function failedVerificationBesideSiblings(run: {\n readonly disposition?: unknown;\n readonly interferenceSuspected?: unknown;\n readonly failureAttribution?: unknown;\n readonly concurrency?: { readonly overlappingTaskRefs?: readonly unknown[] } | null;\n}): boolean {\n if (run.disposition !== ApplicationCodingTaskDisposition.VERIFICATION_FAILED) return false;\n if (run.interferenceSuspected === true) return true;\n return run.failureAttribution === CodingRunFailureAttribution.HOST && (run.concurrency?.overlappingTaskRefs?.length ?? 0) > 0;\n}\n\n/** How long a settled run's window is kept for others to compare against — longer than any single run. */\nexport const CODING_RUN_WINDOW_RETENTION_MS = 6 * 60 * 60 * 1000;\n\n/**\n * Failed runs whose failure MAY have been another run's doing, forgiven before they count against the\n * task's attempt budget. Two, so a task that genuinely cannot pass still retires, after at most two\n * extra attempts. The first two are the ones forgiven, because interference is likeliest while the\n * wave is widest.\n */\nexport const MAXIMUM_INTERFERENCE_RETRIES = 2;\n\n/**\n * Failed runs the HOST caused — the run could not be recorded, or the turn was taken away (#1581) —\n * forgiven before they count against the task's attempt budget. Bounded like interference: a host\n * condition that fails every attempt is a task that cannot run here, and an unbounded forgiveness would\n * re-dispatch it, and pay for each turn, forever. The coding agent's usage limit is outside this bound:\n * such a run is never counted, because the build pauses until the reset (#2388).\n */\nexport const MAXIMUM_HOST_FAILURE_EXCLUSIONS = 2;\n\n/**\n * Failed runs the NETWORK took (`networkFailureKind`, #3236) forgiven before they count, on a bound of their own.\n *\n * Its own, because the generic host bound of two is spent by the first two minutes of a flaky network: on\n * app-creation-test-007 a 35-minute DNS loss failed six runs across two tasks. Bounded nonetheless (review F5): the\n * connectivity hold makes every re-dispatch wait for a probe that SUCCEEDED, so an unbounded forgiveness would only be\n * safe if the probe and the agent always agreed, and they need not (a proxy, a cloud endpoint, a classifier wrong about\n * one message). Past the bound, a network-taken run falls through to the host bound and then counts, so a task that\n * fails \"on the network\" every time still retires.\n */\nexport const MAXIMUM_NETWORK_FAILURE_EXCLUSIONS = 4;\n\n/**\n * The failed runs that COUNT against a task's attempt budget. Pure. A run the coding agent's account\n * usage limit took is never counted and spends no forgiveness (#2388): the build wave pauses until the\n * limit's reset, so nothing re-dispatches into it and no bound is needed. Nor is a run the NETWORK took\n * (`networkFailureKind`, #3236) up to {@link MAXIMUM_NETWORK_FAILURE_EXCLUSIONS}, on a bound of its own:\n * a connectivity hold keeps every later admission waiting until the agent's API answers a probe, so a\n * network that is down spends nothing, and the bound stops a network that answers probes and drops\n * every turn from re-dispatching a task forever. Nor, ever, is a run that failed only because its checks could not\n * be ASKED (`verificationUnanswered`, `failedOnlyForUnansweredVerification`, run 43961156770): no check judged the\n * work, so it is never the task's failure. It spends no forgiveness either. Two holds bound the spend instead: a cause\n * met on two distinct tasks holds every admission (`VerificationHostCause.REPEATED_HOST_FAILURE`), and a task meeting\n * it on {@link MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS} runs in a row is withheld on its own\n * ({@link deriveUnansweredVerificationWithholding}). Until then a host bound of two applied, and on reference run 43961156770 a dead compile watcher retired ten\n * tasks `attempts_exhausted` after five unanswered checks each. Two other kinds of failure may\n * not be the task's, and each is forgiven up to its own bound, oldest first:\n * - a run that shared the tree when it failed is suspected of interference, up to\n * {@link MAXIMUM_INTERFERENCE_RETRIES};\n * - a run whose failure the host caused, up to {@link MAXIMUM_HOST_FAILURE_EXCLUSIONS}.\n * A run that is both uses ONE forgiveness: the host's while a host slot is free, else an interference\n * slot. Either way it is forgiven once, never twice.\n */\nexport function selectBudgetCountingFailures<T extends {\n readonly settledAt?: string;\n readonly interferenceSuspected: boolean;\n readonly hostAttributed?: boolean;\n readonly usageLimited?: boolean;\n readonly networkTaken?: boolean;\n readonly verificationUnanswered?: boolean;\n}>(runs: readonly T[]): T[] {\n const oldestFirst = [...runs].filter((run) => run.usageLimited !== true && run.verificationUnanswered !== true)\n .sort((left, right) => (left.settledAt ?? '').localeCompare(right.settledAt ?? ''));\n let forgivenInterference = 0;\n let forgivenHost = 0;\n let forgivenNetwork = 0;\n const counting = oldestFirst.filter((run) => {\n if (run.networkTaken === true && forgivenNetwork < MAXIMUM_NETWORK_FAILURE_EXCLUSIONS) {\n forgivenNetwork += 1;\n return false;\n }\n if (run.hostAttributed === true && forgivenHost < MAXIMUM_HOST_FAILURE_EXCLUSIONS) {\n forgivenHost += 1;\n return false;\n }\n if (run.interferenceSuspected && forgivenInterference < MAXIMUM_INTERFERENCE_RETRIES) {\n forgivenInterference += 1;\n return false;\n }\n return true;\n });\n // Callers read newest first, as the budget lookup always returned them.\n return counting.reverse();\n}\n\n/**\n * How many CONSECUTIVE runs of one task may fail only because their checks could not be asked before the task is withheld\n * (run 43961156770). Such runs never count against the attempt budget ({@link selectBudgetCountingFailures}), and a cause\n * met on two distinct tasks holds every admission; this bounds the cause only ONE task meets. Its own edit can be it (a\n * load-time error the CLI's runner reports as \"could not ask\"), and so can the last task left of a broken build: without a\n * bound it would be re-dispatched, and paid for, forever. Two, as the cross-task hold opens on two.\n */\nexport const MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS = 2;\n\n/** One settled run of a task, as {@link deriveUnansweredVerificationWithholding} reads it. */\nexport interface UnansweredVerificationRunReading {\n readonly taskId: string;\n readonly settledAtMs: number;\n /** `failedOnlyForUnansweredVerification`: every check it failed on could not be asked, and no re-check saw one fail. */\n readonly verificationUnanswered: boolean;\n /** The checks it failed on (none carried from before it), each with what it said. */\n readonly failedChecks: ReadonlyArray<{ readonly checkRef: string; readonly message: string }>;\n}\n\n/**\n * Whether ONE task is withheld because its latest runs could not have their checks asked (run 43961156770), and on which\n * run. Pure. Withheld while all hold:\n * - its newest {@link MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS} or more runs (newest first, re-armed ones already\n * left out by the caller) are unanswered;\n * - the newest settled less than `reaskAfterMs` ago: past it, one run asks the host again, as the cross-task hold re-asks;\n * - `hostAnsweredSince` says the host has not answered since that run: a check it failed on ran to a verdict for some\n * run, or the compiled model it named caught up.\n * Never counted, so never `attempts_exhausted`: a re-arm for the environment releases it like any failed run.\n */\nexport function deriveUnansweredVerificationWithholding<T extends UnansweredVerificationRunReading>(\n runsNewestFirst: readonly T[],\n input: { readonly nowMs: number; readonly reaskAfterMs: number; readonly hostAnsweredSince: (latest: T) => boolean },\n): { readonly latest: T; readonly consecutive: number } | undefined {\n let consecutive = 0;\n while (consecutive < runsNewestFirst.length && runsNewestFirst[consecutive]!.verificationUnanswered) consecutive += 1;\n const latest = runsNewestFirst[0];\n if (latest === undefined || consecutive < MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS) return undefined;\n if (input.nowMs - latest.settledAtMs >= input.reaskAfterMs) return undefined;\n if (input.hostAnsweredSince(latest)) return undefined;\n return { latest, consecutive };\n}\n\n/**\n * The file locations ONE live session event claims as written (#3205 outcome 4), by the engine's one rule\n * (`writtenLocationsOfAcpSessionUpdate`), which the session runner applies when it gathers `reportedFileLocations`. Kept\n * here as the event-shaped door the companion receives, so a run's claims can be kept on disk as they happen.\n */\nexport function writtenLocationsOfSessionEvent(event: { readonly kind: string; readonly payload: unknown }, toolCallKinds: Map<string, string>): string[] {\n return writtenLocationsOfAcpSessionUpdate(event.kind, event.payload, toolCallKinds);\n}\n\n/** The subset of a coding agent's permission decision that names what it touched. */\nexport interface CodingRunPermissionDecisionEvidence {\n readonly allowed: boolean;\n /** The ACP tool kind asked about; only a WRITING kind's locations are a claim (#1805). */\n readonly toolKind?: string;\n readonly locations: readonly string[];\n}\n\n/**\n * The application-relative paths a concurrent run has EVIDENCE of writing itself: the file locations\n * its agent reported on its own tool calls, and the locations of the edits it was ALLOWED to make.\n *\n * Why a concurrent run needs this and a single-flight run does not. A run's change set is a\n * before/after capture of the whole tree, so in a wave every sibling's files appear in it too, and\n * nothing in a capture can tell them apart. Measured on the first live wave (2026-09-24, four real\n * agents each adding a module and an export line): the first run to settle committed ALL FOUR modules\n * under its own name — \"the writes of coding run task-3\" listing alpha, beta, delta and gamma — and\n * the other three accepts were refused as already committed. The tree ended right and the history\n * said the wrong thing; and a sibling that later FAILED would have had its half-written file\n * committed under the first finisher's name, which is exactly what a failed run must not get.\n *\n * So a concurrent run's own accept commits only what it claims — the files its agent's WRITING tool calls\n * reported (#1805: a read or a search claims nothing). A path nobody claims — an agent that wrote through\n * its shell, which declares no location — is not lost: when the runs sharing the tree have settled, what\n * they left is committed naming every run whose writes it may carry, as ONE writer-unknown change unless the\n * records establish its writer (#3218). And when no other writer can have written it — no other recorded run\n * carries it and nothing without a record is beside the run — the run's own accept takes it (#3215).\n *\n * `candidateRoots` are the configured application root and its physical realpath, because an agent\n * reports CANONICAL paths (`/private/var/…` for a root configured as `/var/…`). Pure.\n */\nexport function collectRunClaimedPaths(input: {\n readonly candidateRoots: readonly string[];\n readonly reportedFileLocations?: readonly string[];\n readonly permissionDecisions?: readonly CodingRunPermissionDecisionEvidence[];\n}): string[] {\n const absolute = [\n ...(input.reportedFileLocations ?? []),\n // Allowed to WRITE, not merely to read: a permission asked for a read or a search claims nothing (#1805 review F3).\n ...(input.permissionDecisions ?? []).filter((decision) => decision.allowed && isWritingAcpToolKind(decision.toolKind)).flatMap((decision) => decision.locations),\n ];\n const claimed = new Set<string>();\n for (const location of absolute) {\n if (!isAbsolute(location)) continue;\n const relativePath = input.candidateRoots\n .map((root) => relative(root, location))\n .find((candidate) => candidate.length > 0 && !candidate.startsWith('..') && !isAbsolute(candidate));\n if (relativePath !== undefined) claimed.add(relativePath.split(sep).join('/'));\n }\n return [...claimed].sort();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"concurrent-coding-runs.models.js","sourceRoot":"","sources":["../../../../src/claude-cli/models/concurrent-coding-runs.models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAA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,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;QACtG,IAAI,YAAY,KAAK,SAAS;YAAE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * Several coding runs in ONE worktree at once (#1528) — the pure half: what they hold, what each one\n * records about the others, and how a failure that may be another run's doing is kept from retiring a\n * task.\n *\n * The decision this serves, in Paul's words (2026-09-24): concurrent agents editing the same tree\n * reconcile fine in practice, so the lane does not PREVENT interference — no file separation, no\n * disjoint scopes, no worktree per agent — it DETECTS it and REPAIRS it. Measured on the first\n * end-to-end run's plan: 94 tasks in six waves, wave 2 holding 45 independent tasks, run single-file.\n *\n * What is still exclusive, and why each is the only thing that is:\n * - ONE run per build task at a time: two agents building the same task are a bug, not a collision.\n * That is the engine's exclusive subject, keyed on the task instead of the worktree.\n * - A SINGLE-FLIGHT run and concurrent runs never overlap, in either direction. A single-flight run\n * was promised the tree to itself; and the single-flight door is the one a running agent can reach\n * from its own shell, so refusing it while any run is in flight keeps the P-35 recursion cap\n * EXPLICIT now that the global lock no longer provides it as a side effect.\n * - A git COMMIT takes the workspace lock briefly, because git's own index lock does not tolerate\n * two writers.\n */\nimport { isAbsolute, relative, sep } from 'node:path';\n\nimport { isWritingAcpToolKind, writtenLocationsOfAcpSessionUpdate } from '@wildo-ai/external-connectors-models';\nimport { CodingRunFailureAttribution } from '@wildo-ai/platform-core-shared';\n\nimport { APPLICATION_CODING_WORKTREE_SUBJECT } from '../../meta-workflows/models/application-coding-agent.actors-system.definitions';\nimport { ApplicationCodingTaskDisposition } from './coding-agent-dispatch.models';\n\n/** How a coding run shares the application's working tree. */\nexport enum CodingRunConcurrency {\n /** The lane as it always was: the run holds the worktree subject and the workspace lock for its whole life. */\n SINGLE_FLIGHT = 'single-flight',\n /** One of several runs in one wave: holds only its own task, and takes the workspace lock only to commit. */\n CONCURRENT = 'concurrent',\n}\n\n/** The prefix of a concurrent run's exclusive subject; the task ref follows it. */\nexport const APPLICATION_CODING_TASK_SUBJECT_PREFIX = 'build-task:';\n\n/** What a run holds exclusively: the whole worktree when single-flight, only its own task when concurrent. */\nexport function applicationCodingExclusiveSubject(mode: CodingRunConcurrency, taskRef: string): string {\n return mode === CodingRunConcurrency.CONCURRENT ? `${APPLICATION_CODING_TASK_SUBJECT_PREFIX}${taskRef}` : APPLICATION_CODING_WORKTREE_SUBJECT;\n}\n\n/** True when a live execution's subject says it is a concurrent run. */\nexport function isConcurrentRunSubject(exclusiveSubject: string | undefined): boolean {\n return typeof exclusiveSubject === 'string' && exclusiveSubject.startsWith(APPLICATION_CODING_TASK_SUBJECT_PREFIX);\n}\n\n/** One run's time in the tree, as this process saw it. `changedPaths` is known once it settled. */\nexport interface CodingRunWindow {\n readonly taskId: string;\n readonly taskRef: string;\n readonly startedAtMs: number;\n readonly endedAtMs?: number;\n readonly changedPaths?: readonly string[];\n}\n\n/** What a run records about the runs that shared the tree with it — the observability half of the repair layer. */\nexport interface CodingRunConcurrencyRecord {\n /** Build tasks whose runs were in the tree at some point during this one. */\n readonly overlappingTaskRefs: readonly string[];\n /** Paths this run changed that an overlapping run is known to have changed too: where a collision would be. */\n readonly contendedPaths: readonly string[];\n /**\n * Whether any overlapping run may have written to the tree (#2389 review F5): one still running, one that ended\n * without reporting its paths (a park), or one that settled having changed something. `false` only when every\n * overlapping run settled and changed NOTHING — runs the coding agent's usage limit refused, typically — and then\n * no sibling can have turned a shared check red. Absent on a record written before this field: read as `true`.\n */\n readonly overlappingRunsMayHaveWritten?: boolean;\n}\n\n/**\n * Which runs overlapped `self`, and which of its changed paths they touched too. Pure over the windows\n * this process holds. A sibling still running has no `changedPaths` yet, so a contention with it is\n * recorded by whichever of the two settles LATER — every pair is reported once, by one side.\n */\nexport function describeRunConcurrency(\n windows: readonly CodingRunWindow[],\n self: { readonly taskId: string; readonly startedAtMs: number; readonly endedAtMs: number },\n selfChangedPaths: readonly string[],\n): CodingRunConcurrencyRecord {\n const overlapping = windows.filter((window) => window.taskId !== self.taskId\n && window.startedAtMs < self.endedAtMs\n && (window.endedAtMs === undefined || window.endedAtMs > self.startedAtMs));\n const siblingPaths = new Set(overlapping.flatMap((window) => window.changedPaths ?? []));\n return {\n overlappingTaskRefs: [...new Set(overlapping.map((window) => window.taskRef))].sort(),\n contendedPaths: [...new Set(selfChangedPaths.filter((path) => siblingPaths.has(path)))].sort(),\n overlappingRunsMayHaveWritten: overlapping.some((window) => window.changedPaths === undefined || window.changedPaths.length > 0),\n };\n}\n\n/**\n * Whether a failed run may have failed for a SIBLING's writes (#2389) — the `interferenceSuspected` flag,\n * derived once. Overlap in time is the precondition, never the verdict: the flag also buys a forgiveness\n * from the attempt budget ({@link selectBudgetCountingFailures}), so it must name only failures the tree\n * could have caused.\n *\n * - A HOST failure never: the turn was taken away (a provider limit, a killed process, an operator's\n * cancel) or the run could not be recorded. Measured on app-creation-test-005: four tasks failed on the\n * coding agent's session limit, changed nothing, contended nothing, and every attempt read\n * `interferenceSuspected: true` because another run was in the tree — and past the host bound each one\n * drew an interference forgiveness, so the label hid two failures the budget should have seen.\n * - A failed CHECK, whenever an overlapping run may have written: a sibling's write to any file can turn a\n * shared check red (a typecheck spans the package), and a sibling still running has not reported its paths,\n * so its overlap alone is the signal. Narrowing it to `contendedPaths` would miss exactly that case. Siblings\n * that all settled having changed nothing cannot have caused it (#2389 review F5), so they do not count.\n * - The agent failing at its own work: only when a path it changed was changed by a sibling too — the one\n * way a sibling can have reached the turn itself. A run that changed nothing contended nothing.\n */\nexport function deriveInterferenceSuspected(input: {\n readonly disposition: ApplicationCodingTaskDisposition;\n readonly failureAttribution: CodingRunFailureAttribution | null;\n readonly concurrency: CodingRunConcurrencyRecord | null;\n}): boolean {\n if (input.concurrency === null || input.concurrency.overlappingTaskRefs.length === 0) return false;\n if (input.failureAttribution !== CodingRunFailureAttribution.TASK) return false;\n switch (input.disposition) {\n case ApplicationCodingTaskDisposition.VERIFICATION_FAILED:\n return input.concurrency.overlappingRunsMayHaveWritten !== false;\n case ApplicationCodingTaskDisposition.AGENT_EXECUTION_FAILED:\n return input.concurrency.contendedPaths.length > 0;\n case ApplicationCodingTaskDisposition.WORKING_RESULT_RECORDED:\n case ApplicationCodingTaskDisposition.AWAITING_OPERATOR_INPUT:\n case ApplicationCodingTaskDisposition.INTERRUPTED_REQUIRES_REVIEW:\n case ApplicationCodingTaskDisposition.CHANGE_SET_CAPTURE_FAILED:\n case ApplicationCodingTaskDisposition.TRACEABILITY_FAILED:\n // It changed nothing, so it contended nothing: a sibling cannot have caused a run to write no file.\n case ApplicationCodingTaskDisposition.OVERRIDE_NOT_REPAIRED:\n return false;\n }\n}\n\n/**\n * Whether a run FAILED ITS CHECKS beside siblings, so the failure may be theirs and only a re-check ALONE can say (#3204).\n * Pure: these runs are re-checked alone, once no live run writes what their checks read or at the wave's end (#3998), and\n * the selector holds their task until that re-check is recorded.\n *\n * Two shapes, and the second is why this is not {@link deriveInterferenceSuspected}:\n * - a check FAILED while an overlapping run may have written (`interferenceSuspected`);\n * - a check could not be ASKED at all (the run is HOST-attributed: every failed check threw, `verificationCouldNotAsk`)\n * while other runs shared the tree. A sibling's half-written file fails a package's compile, its compiled output goes\n * stale, and the registry check refuses to read it (\"dist is older than its sources ... last compile FAILED\"). That is\n * the environment's, so the budget forgives it as a host failure; it is also the siblings', so only a check run alone\n * can tell whether this run's work passes. Measured on reference run 42621319676: every such failure of two schema\n * tasks was HOST-attributed, none was re-checked, and both spent their budget in nine minutes.\n *\n * A run alone (no overlap) is never one: a red check there is the run's, or the host's, and running it again alone is\n * exactly what the next dispatch does.\n */\nexport function failedVerificationBesideSiblings(run: {\n readonly disposition?: unknown;\n readonly interferenceSuspected?: unknown;\n readonly failureAttribution?: unknown;\n readonly concurrency?: { readonly overlappingTaskRefs?: readonly unknown[] } | null;\n}): boolean {\n if (run.disposition !== ApplicationCodingTaskDisposition.VERIFICATION_FAILED) return false;\n if (run.interferenceSuspected === true) return true;\n return run.failureAttribution === CodingRunFailureAttribution.HOST && (run.concurrency?.overlappingTaskRefs?.length ?? 0) > 0;\n}\n\n/** How long a settled run's window is kept for others to compare against — longer than any single run. */\nexport const CODING_RUN_WINDOW_RETENTION_MS = 6 * 60 * 60 * 1000;\n\n/**\n * Failed runs whose failure MAY have been another run's doing, forgiven before they count against the\n * task's attempt budget. Two, so a task that genuinely cannot pass still retires, after at most two\n * extra attempts. The first two are the ones forgiven, because interference is likeliest while the\n * wave is widest.\n */\nexport const MAXIMUM_INTERFERENCE_RETRIES = 2;\n\n/**\n * Failed runs the HOST caused — the run could not be recorded, or the turn was taken away (#1581) —\n * forgiven before they count against the task's attempt budget. Bounded like interference: a host\n * condition that fails every attempt is a task that cannot run here, and an unbounded forgiveness would\n * re-dispatch it, and pay for each turn, forever. The coding agent's usage limit is outside this bound:\n * such a run is never counted, because the build pauses until the reset (#2388).\n */\nexport const MAXIMUM_HOST_FAILURE_EXCLUSIONS = 2;\n\n/**\n * Failed runs the NETWORK took (`networkFailureKind`, #3236) forgiven before they count, on a bound of their own.\n *\n * Its own, because the generic host bound of two is spent by the first two minutes of a flaky network: on\n * app-creation-test-007 a 35-minute DNS loss failed six runs across two tasks. Bounded nonetheless (review F5): the\n * connectivity hold makes every re-dispatch wait for a probe that SUCCEEDED, so an unbounded forgiveness would only be\n * safe if the probe and the agent always agreed, and they need not (a proxy, a cloud endpoint, a classifier wrong about\n * one message). Past the bound, a network-taken run falls through to the host bound and then counts, so a task that\n * fails \"on the network\" every time still retires.\n */\nexport const MAXIMUM_NETWORK_FAILURE_EXCLUSIONS = 4;\n\n/**\n * The failed runs that COUNT against a task's attempt budget. Pure. A run the coding agent's account\n * usage limit took is never counted and spends no forgiveness (#2388): the build wave pauses until the\n * limit's reset, so nothing re-dispatches into it and no bound is needed. Nor is a run the NETWORK took\n * (`networkFailureKind`, #3236) up to {@link MAXIMUM_NETWORK_FAILURE_EXCLUSIONS}, on a bound of its own:\n * a connectivity hold keeps every later admission waiting until the agent's API answers a probe, so a\n * network that is down spends nothing, and the bound stops a network that answers probes and drops\n * every turn from re-dispatching a task forever. Nor, ever, is a run that failed only because its checks could not\n * be ASKED (`verificationUnanswered`, `failedOnlyForUnansweredVerification`, run 43961156770): no check judged the\n * work, so it is never the task's failure. It spends no forgiveness either. Two holds bound the spend instead: a cause\n * met on two distinct tasks holds every admission (`VerificationHostCause.REPEATED_HOST_FAILURE`), and a task meeting\n * it on {@link MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS} runs in a row is withheld on its own\n * ({@link deriveUnansweredVerificationWithholding}). Until then a host bound of two applied, and on reference run 43961156770 a dead compile watcher retired ten\n * tasks `attempts_exhausted` after five unanswered checks each. Two other kinds of failure may\n * not be the task's, and each is forgiven up to its own bound, oldest first:\n * - a run that shared the tree when it failed is suspected of interference, up to\n * {@link MAXIMUM_INTERFERENCE_RETRIES};\n * - a run whose failure the host caused, up to {@link MAXIMUM_HOST_FAILURE_EXCLUSIONS}.\n * A run that is both uses ONE forgiveness: the host's while a host slot is free, else an interference\n * slot. Either way it is forgiven once, never twice.\n */\nexport function selectBudgetCountingFailures<T extends {\n readonly settledAt?: string;\n readonly interferenceSuspected: boolean;\n readonly hostAttributed?: boolean;\n readonly usageLimited?: boolean;\n readonly networkTaken?: boolean;\n readonly verificationUnanswered?: boolean;\n}>(runs: readonly T[]): T[] {\n const oldestFirst = [...runs].filter((run) => run.usageLimited !== true && run.verificationUnanswered !== true)\n .sort((left, right) => (left.settledAt ?? '').localeCompare(right.settledAt ?? ''));\n let forgivenInterference = 0;\n let forgivenHost = 0;\n let forgivenNetwork = 0;\n const counting = oldestFirst.filter((run) => {\n if (run.networkTaken === true && forgivenNetwork < MAXIMUM_NETWORK_FAILURE_EXCLUSIONS) {\n forgivenNetwork += 1;\n return false;\n }\n if (run.hostAttributed === true && forgivenHost < MAXIMUM_HOST_FAILURE_EXCLUSIONS) {\n forgivenHost += 1;\n return false;\n }\n if (run.interferenceSuspected && forgivenInterference < MAXIMUM_INTERFERENCE_RETRIES) {\n forgivenInterference += 1;\n return false;\n }\n return true;\n });\n // Callers read newest first, as the budget lookup always returned them.\n return counting.reverse();\n}\n\n/**\n * How many CONSECUTIVE runs of one task may fail only because their checks could not be asked before the task is withheld\n * (run 43961156770). Such runs never count against the attempt budget ({@link selectBudgetCountingFailures}), and a cause\n * met on two distinct tasks holds every admission; this bounds the cause only ONE task meets. Its own edit can be it (a\n * load-time error the CLI's runner reports as \"could not ask\"), and so can the last task left of a broken build: without a\n * bound it would be re-dispatched, and paid for, forever. Two, as the cross-task hold opens on two.\n */\nexport const MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS = 2;\n\n/** One settled run of a task, as {@link deriveUnansweredVerificationWithholding} reads it. */\nexport interface UnansweredVerificationRunReading {\n readonly taskId: string;\n readonly settledAtMs: number;\n /** `failedOnlyForUnansweredVerification`: every check it failed on could not be asked, and no re-check saw one fail. */\n readonly verificationUnanswered: boolean;\n /** The checks it failed on (none carried from before it), each with what it said. */\n readonly failedChecks: ReadonlyArray<{ readonly checkRef: string; readonly message: string }>;\n}\n\n/**\n * Whether ONE task is withheld because its latest runs could not have their checks asked (run 43961156770), and on which\n * run. Pure. Withheld while all hold:\n * - its newest {@link MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS} or more runs (newest first, re-armed ones already\n * left out by the caller) are unanswered;\n * - the newest settled less than `reaskAfterMs` ago: past it, one run asks the host again, as the cross-task hold re-asks;\n * - `hostAnsweredSince` says the host has not answered since that run: a check it failed on ran to a verdict for some\n * run, or the compiled model it named caught up.\n * Never counted, so never `attempts_exhausted`: a re-arm for the environment releases it like any failed run.\n */\nexport function deriveUnansweredVerificationWithholding<T extends UnansweredVerificationRunReading>(\n runsNewestFirst: readonly T[],\n input: { readonly nowMs: number; readonly reaskAfterMs: number; readonly hostAnsweredSince: (latest: T) => boolean },\n): { readonly latest: T; readonly consecutive: number } | undefined {\n let consecutive = 0;\n while (consecutive < runsNewestFirst.length && runsNewestFirst[consecutive]!.verificationUnanswered) consecutive += 1;\n const latest = runsNewestFirst[0];\n if (latest === undefined || consecutive < MAXIMUM_CONSECUTIVE_UNANSWERED_VERIFICATION_RUNS) return undefined;\n if (input.nowMs - latest.settledAtMs >= input.reaskAfterMs) return undefined;\n if (input.hostAnsweredSince(latest)) return undefined;\n return { latest, consecutive };\n}\n\n/**\n * The file locations ONE live session event claims as written (#3205 outcome 4), by the engine's one rule\n * (`writtenLocationsOfAcpSessionUpdate`), which the session runner applies when it gathers `reportedFileLocations`. Kept\n * here as the event-shaped door the companion receives, so a run's claims can be kept on disk as they happen.\n */\nexport function writtenLocationsOfSessionEvent(event: { readonly kind: string; readonly payload: unknown }, toolCallKinds: Map<string, string>): string[] {\n return writtenLocationsOfAcpSessionUpdate(event.kind, event.payload, toolCallKinds);\n}\n\n/** The subset of a coding agent's permission decision that names what it touched. */\nexport interface CodingRunPermissionDecisionEvidence {\n readonly allowed: boolean;\n /** The ACP tool kind asked about; only a WRITING kind's locations are a claim (#1805). */\n readonly toolKind?: string;\n readonly locations: readonly string[];\n}\n\n/**\n * The application-relative paths a concurrent run has EVIDENCE of writing itself: the file locations\n * its agent reported on its own tool calls, and the locations of the edits it was ALLOWED to make.\n *\n * Why a concurrent run needs this and a single-flight run does not. A run's change set is a\n * before/after capture of the whole tree, so in a wave every sibling's files appear in it too, and\n * nothing in a capture can tell them apart. Measured on the first live wave (2026-09-24, four real\n * agents each adding a module and an export line): the first run to settle committed ALL FOUR modules\n * under its own name — \"the writes of coding run task-3\" listing alpha, beta, delta and gamma — and\n * the other three accepts were refused as already committed. The tree ended right and the history\n * said the wrong thing; and a sibling that later FAILED would have had its half-written file\n * committed under the first finisher's name, which is exactly what a failed run must not get.\n *\n * So a concurrent run's own accept commits only what it claims — the files its agent's WRITING tool calls\n * reported (#1805: a read or a search claims nothing). A path nobody claims — an agent that wrote through\n * its shell, which declares no location — is not lost: when the runs sharing the tree have settled, what\n * they left is committed naming every run whose writes it may carry, as ONE writer-unknown change unless the\n * records establish its writer (#3218). And when no other writer can have written it — no other recorded run\n * carries it and nothing without a record is beside the run — the run's own accept takes it (#3215).\n *\n * `candidateRoots` are the configured application root and its physical realpath, because an agent\n * reports CANONICAL paths (`/private/var/…` for a root configured as `/var/…`). Pure.\n */\nexport function collectRunClaimedPaths(input: {\n readonly candidateRoots: readonly string[];\n readonly reportedFileLocations?: readonly string[];\n readonly permissionDecisions?: readonly CodingRunPermissionDecisionEvidence[];\n}): string[] {\n const absolute = [\n ...(input.reportedFileLocations ?? []),\n // Allowed to WRITE, not merely to read: a permission asked for a read or a search claims nothing (#1805 review F3).\n ...(input.permissionDecisions ?? []).filter((decision) => decision.allowed && isWritingAcpToolKind(decision.toolKind)).flatMap((decision) => decision.locations),\n ];\n const claimed = new Set<string>();\n for (const location of absolute) {\n if (!isAbsolute(location)) continue;\n const relativePath = input.candidateRoots\n .map((root) => relative(root, location))\n .find((candidate) => candidate.length > 0 && !candidate.startsWith('..') && !isAbsolute(candidate));\n if (relativePath !== undefined) claimed.add(relativePath.split(sep).join('/'));\n }\n return [...claimed].sort();\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ApplicationCodingTaskVerificationPlan, type GitWorktreeSnapshot } from './coding-agent-dispatch.models';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a failed run's isolated re-check may run while other coding runs are still live (#3998).
|
|
4
|
+
*
|
|
5
|
+
* A run that failed its checks beside siblings is re-checked ALONE (#3220), because the failure may be a sibling's
|
|
6
|
+
* half-written file rather than the run's own work. Until #3998 "alone" meant "once every run of the wave has settled",
|
|
7
|
+
* so a task waited for the slowest run of its wave whatever that run wrote: on reference run 43961156770 that left the
|
|
8
|
+
* build with nothing running and 27 tasks ready for 13.4 minutes, 44.6 minutes in all.
|
|
9
|
+
*
|
|
10
|
+
* The interference the re-check rules out comes only from runs that write what the re-run checks READ. So a re-check
|
|
11
|
+
* may run beside a live run when that run is not expected to write a package the checks read, and its verdict is kept
|
|
12
|
+
* only when nothing under those packages changed while the checks ran. This module answers both questions; it reads
|
|
13
|
+
* nothing but the application's own package manifests and the two worktree snapshots it is given.
|
|
14
|
+
*/
|
|
15
|
+
/** An application's workspace packages and what each depends on, read from their own `package.json` files. */
|
|
16
|
+
export interface ApplicationWorkspacePackageGraph {
|
|
17
|
+
/** Application-relative package directories, no trailing slash (`shared-lib`, `workers/my-node-worker`). */
|
|
18
|
+
readonly packageDirectories: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
* Per package directory, the directories of the workspace packages it depends on. A package naming a `workspace:`
|
|
21
|
+
* dependency that no discovered package carries is absent here: its read closure cannot be known, so a check reading
|
|
22
|
+
* it reads the whole application. A `file:` or `link:` dependency outside the application (the framework's own packages
|
|
23
|
+
* in framework development) is no package of it, and no coding run writes it.
|
|
24
|
+
*/
|
|
25
|
+
readonly dependsOn: ReadonlyMap<string, readonly string[]>;
|
|
26
|
+
}
|
|
27
|
+
/** What a set of verification checks reads: a closure of workspace packages, or the whole application. */
|
|
28
|
+
export type VerificationReadScope = {
|
|
29
|
+
readonly wholeApplication: true;
|
|
30
|
+
} | {
|
|
31
|
+
readonly wholeApplication: false;
|
|
32
|
+
readonly packageDirectories: ReadonlySet<string>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Read the application's workspace packages from the tree (#3998): every directory at the application root, or one level
|
|
36
|
+
* below a root directory that is not itself a package (`workers/*`, `minions/*`, `providers/*`), holding a `package.json`.
|
|
37
|
+
* Derived from what exists rather than from a list, so a package a composition scenario adds is a package here the day it
|
|
38
|
+
* exists. `undefined` when the root cannot be listed: every check then reads the whole application.
|
|
39
|
+
*/
|
|
40
|
+
export declare function readApplicationWorkspacePackageGraph(saasRoot: string): ApplicationWorkspacePackageGraph | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* What these checks read (#3998): the union of each one's root package and every workspace package that root depends on,
|
|
43
|
+
* transitively. The whole application when any check's root is whole, unknown, absent from the graph, or depends on a
|
|
44
|
+
* workspace package that could not be resolved. Files outside every package (the root manifests, `wildo.saas.config.ts`,
|
|
45
|
+
* `infrastructure/`) are read by every check: see {@link isPathReadBy}.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveVerificationReadScope(plans: readonly Pick<ApplicationCodingTaskVerificationPlan, 'kind' | 'path'>[], graph: ApplicationWorkspacePackageGraph | undefined): VerificationReadScope;
|
|
48
|
+
/**
|
|
49
|
+
* Whether a write at this path (a file or a prefix) can change what the checks read (#3998). A path inside a package of
|
|
50
|
+
* the read closure can; a path inside another package cannot; a path inside NO package can, because nothing says which
|
|
51
|
+
* checks read it (a root manifest, the application's config, a top-level directory that holds packages).
|
|
52
|
+
*/
|
|
53
|
+
export declare function isPathReadBy(path: string, scope: VerificationReadScope, graph: ApplicationWorkspacePackageGraph | undefined): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether a live run that may write these paths could interfere with the checks (#3998). `undefined` (what the run
|
|
56
|
+
* writes is not known) and an empty list (a run with no stated scope) both interfere: unknown means it may.
|
|
57
|
+
*/
|
|
58
|
+
export declare function writeScopeMayReachReadScope(writes: readonly string[] | undefined, scope: VerificationReadScope, graph: ApplicationWorkspacePackageGraph | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether anything the checks read changed between two worktree snapshots (#3998): HEAD moved, or a dirty or untracked
|
|
61
|
+
* file the checks read appeared, disappeared or changed its content. What decides whether a re-check that ran beside
|
|
62
|
+
* live runs is kept: the prediction of what each run writes said nothing would be written there, and this says whether
|
|
63
|
+
* anything was, by any writer, a shell command included, among the paths a snapshot lists. A snapshot lists tracked and
|
|
64
|
+
* untracked files, never gitignored ones, so compiled output (`dist/`) is not compared: its sources are. HEAD is compared
|
|
65
|
+
* repository-wide, so any commit during the checks counts as a change (the conservative direction).
|
|
66
|
+
*/
|
|
67
|
+
export declare function readScopeChangedBetween(before: Pick<GitWorktreeSnapshot, 'headSha' | 'files'>, after: Pick<GitWorktreeSnapshot, 'headSha' | 'files'>, scope: VerificationReadScope, graph: ApplicationWorkspacePackageGraph | undefined): boolean;
|
|
68
|
+
//# sourceMappingURL=isolated-recheck-interference.models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated-recheck-interference.models.d.ts","sourceRoot":"","sources":["../../../../src/claude-cli/models/isolated-recheck-interference.models.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,qCAAqC,EAAE,KAAK,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAExI;;;;;;;;;;;;GAYG;AAEH,8GAA8G;AAC9G,MAAM,WAAW,gCAAgC;IAC/C,4GAA4G;IAC5G,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;CAC5D;AAED,0GAA0G;AAC1G,MAAM,MAAM,qBAAqB,GAC7B;IAAE,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAA;CAAE,GACnC;IAAE,QAAQ,CAAC,gBAAgB,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC;AAsB3F;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,MAAM,GAAG,gCAAgC,GAAG,SAAS,CA6CnH;AAiCD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,SAAS,IAAI,CAAC,qCAAqC,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,EAC9E,KAAK,EAAE,gCAAgC,GAAG,SAAS,GAClD,qBAAqB,CAmBvB;AAgBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,gCAAgC,GAAG,SAAS,GAAG,OAAO,CAKrI;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EACrC,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,gCAAgC,GAAG,SAAS,GAClD,OAAO,CAGT;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,OAAO,CAAC,EACtD,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,OAAO,CAAC,EACrD,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,gCAAgC,GAAG,SAAS,GAClD,OAAO,CAUT"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { VerificationKind } from './coding-agent-dispatch.models.js';
|
|
4
|
+
const WHOLE_APPLICATION = { wholeApplication: true };
|
|
5
|
+
/** Directory entries that are never a package of the application: installs, git, and dotted (tool or runtime) trees. */
|
|
6
|
+
function isCandidatePackageEntry(name) {
|
|
7
|
+
return name !== 'node_modules' && !name.startsWith('.');
|
|
8
|
+
}
|
|
9
|
+
function readManifest(path) {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
12
|
+
return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed : undefined;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
|
|
19
|
+
/** The specifier that names a package of the same workspace, which must therefore resolve to a discovered package. */
|
|
20
|
+
const WORKSPACE_SPECIFIER = /^workspace:/u;
|
|
21
|
+
/**
|
|
22
|
+
* Read the application's workspace packages from the tree (#3998): every directory at the application root, or one level
|
|
23
|
+
* below a root directory that is not itself a package (`workers/*`, `minions/*`, `providers/*`), holding a `package.json`.
|
|
24
|
+
* Derived from what exists rather than from a list, so a package a composition scenario adds is a package here the day it
|
|
25
|
+
* exists. `undefined` when the root cannot be listed: every check then reads the whole application.
|
|
26
|
+
*/
|
|
27
|
+
export function readApplicationWorkspacePackageGraph(saasRoot) {
|
|
28
|
+
let rootEntries;
|
|
29
|
+
try {
|
|
30
|
+
rootEntries = readdirSync(saasRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isCandidatePackageEntry(entry.name)).map((entry) => entry.name);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const manifests = new Map();
|
|
36
|
+
for (const entry of rootEntries) {
|
|
37
|
+
const manifest = existsSync(join(saasRoot, entry, 'package.json')) ? readManifest(join(saasRoot, entry, 'package.json')) : undefined;
|
|
38
|
+
if (manifest !== undefined) {
|
|
39
|
+
manifests.set(entry, manifest);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
let children;
|
|
43
|
+
try {
|
|
44
|
+
children = readdirSync(join(saasRoot, entry), { withFileTypes: true }).filter((child) => child.isDirectory() && isCandidatePackageEntry(child.name)).map((child) => child.name);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
for (const child of children) {
|
|
50
|
+
const nested = readManifest(join(saasRoot, entry, child, 'package.json'));
|
|
51
|
+
if (nested !== undefined)
|
|
52
|
+
manifests.set(`${entry}/${child}`, nested);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const directoryByName = new Map();
|
|
56
|
+
for (const [directory, manifest] of manifests) {
|
|
57
|
+
if (typeof manifest.name === 'string')
|
|
58
|
+
directoryByName.set(manifest.name, directory);
|
|
59
|
+
}
|
|
60
|
+
const dependsOn = new Map();
|
|
61
|
+
for (const [directory, manifest] of manifests) {
|
|
62
|
+
const dependencies = [];
|
|
63
|
+
let resolved = true;
|
|
64
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
65
|
+
const declared = manifest[field];
|
|
66
|
+
if (typeof declared !== 'object' || declared === null)
|
|
67
|
+
continue;
|
|
68
|
+
for (const [name, specifier] of Object.entries(declared)) {
|
|
69
|
+
const dependencyDirectory = directoryByName.get(name);
|
|
70
|
+
if (dependencyDirectory !== undefined)
|
|
71
|
+
dependencies.push(dependencyDirectory);
|
|
72
|
+
else if (typeof specifier === 'string' && WORKSPACE_SPECIFIER.test(specifier))
|
|
73
|
+
resolved = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (resolved)
|
|
77
|
+
dependsOn.set(directory, [...new Set(dependencies)]);
|
|
78
|
+
}
|
|
79
|
+
return { packageDirectories: [...manifests.keys()], dependsOn };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The workspace package each check reads FROM, before its dependency closure (#3998). Exhaustive over
|
|
83
|
+
* {@link VerificationKind}, so a kind added tomorrow does not compile until it says what it reads.
|
|
84
|
+
*
|
|
85
|
+
* - A check with a `path` reads that package (a typecheck, a package build, a design-system check of the frontend).
|
|
86
|
+
* - A check of the application's assembled backend (the resources registry built offline, the schema-plan drift, the FK
|
|
87
|
+
* sweep through the backend's introspection) reads `backend-api`: each of them imports its compiled modules registry,
|
|
88
|
+
* at the path those checks themselves name (`backend-api/dist/modules-registry.backend.js`).
|
|
89
|
+
* - The settings-rail sweep reads `frontend`; the specification evaluation reads `specifications`.
|
|
90
|
+
* - Everything else reads the WHOLE application: a test path can import anything, and the module layout, the config,
|
|
91
|
+
* a running backend, a browser and the website's demo facts are about every package at once.
|
|
92
|
+
*/
|
|
93
|
+
const READ_ROOT_BY_KIND = {
|
|
94
|
+
[VerificationKind.TYPECHECK]: 'PATH',
|
|
95
|
+
[VerificationKind.PACKAGE_BUILD]: 'PATH',
|
|
96
|
+
[VerificationKind.DESIGN_SYSTEM_CONTRAST]: 'PATH',
|
|
97
|
+
[VerificationKind.DESIGN_SYSTEM_CONTRACT]: 'PATH',
|
|
98
|
+
[VerificationKind.DESIGN_SYSTEM_BRAND]: 'PATH',
|
|
99
|
+
[VerificationKind.RESOURCES_REGISTRY_INIT]: 'backend-api',
|
|
100
|
+
[VerificationKind.SCHEMA_PLAN_DRIFT]: 'backend-api',
|
|
101
|
+
[VerificationKind.FRONTEND_FK_RESOLUTION]: 'backend-api',
|
|
102
|
+
[VerificationKind.SETTINGS_PLACEMENT_CONTENT]: 'frontend',
|
|
103
|
+
[VerificationKind.SPECIFICATION_EXPORTS]: 'specifications',
|
|
104
|
+
[VerificationKind.VITEST_PATH]: 'WHOLE',
|
|
105
|
+
[VerificationKind.MODULE_LAYOUT]: 'WHOLE',
|
|
106
|
+
[VerificationKind.CONFIG_VALIDATE]: 'WHOLE',
|
|
107
|
+
[VerificationKind.BACKEND_READY]: 'WHOLE',
|
|
108
|
+
[VerificationKind.BROWSER_SMOKE]: 'WHOLE',
|
|
109
|
+
[VerificationKind.WEBSITE_DEMO_FACTS]: 'WHOLE',
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* What these checks read (#3998): the union of each one's root package and every workspace package that root depends on,
|
|
113
|
+
* transitively. The whole application when any check's root is whole, unknown, absent from the graph, or depends on a
|
|
114
|
+
* workspace package that could not be resolved. Files outside every package (the root manifests, `wildo.saas.config.ts`,
|
|
115
|
+
* `infrastructure/`) are read by every check: see {@link isPathReadBy}.
|
|
116
|
+
*/
|
|
117
|
+
export function resolveVerificationReadScope(plans, graph) {
|
|
118
|
+
if (graph === undefined || plans.length === 0)
|
|
119
|
+
return WHOLE_APPLICATION;
|
|
120
|
+
const closure = new Set();
|
|
121
|
+
const pending = [];
|
|
122
|
+
for (const plan of plans) {
|
|
123
|
+
const declared = READ_ROOT_BY_KIND[plan.kind];
|
|
124
|
+
const root = declared === 'PATH' ? plan.path : declared === 'WHOLE' ? null : declared;
|
|
125
|
+
if (root === undefined || root === null || root === '' || !graph.packageDirectories.includes(root))
|
|
126
|
+
return WHOLE_APPLICATION;
|
|
127
|
+
pending.push(root);
|
|
128
|
+
}
|
|
129
|
+
while (pending.length > 0) {
|
|
130
|
+
const directory = pending.pop();
|
|
131
|
+
if (closure.has(directory))
|
|
132
|
+
continue;
|
|
133
|
+
const dependencies = graph.dependsOn.get(directory);
|
|
134
|
+
if (dependencies === undefined)
|
|
135
|
+
return WHOLE_APPLICATION;
|
|
136
|
+
closure.add(directory);
|
|
137
|
+
pending.push(...dependencies);
|
|
138
|
+
}
|
|
139
|
+
return { wholeApplication: false, packageDirectories: closure };
|
|
140
|
+
}
|
|
141
|
+
/** An application-relative path or prefix, without a leading `./` or `/`. */
|
|
142
|
+
function normalizeApplicationPath(path) {
|
|
143
|
+
return path.replace(/\\/gu, '/').replace(/^(?:\.\/|\/)+/u, '');
|
|
144
|
+
}
|
|
145
|
+
/** The package directory a path lies in (the longest match), or `undefined` when it lies in none. */
|
|
146
|
+
function packageContaining(path, graph) {
|
|
147
|
+
let best;
|
|
148
|
+
for (const directory of graph.packageDirectories) {
|
|
149
|
+
if ((path === directory || path.startsWith(`${directory}/`)) && (best === undefined || directory.length > best.length))
|
|
150
|
+
best = directory;
|
|
151
|
+
}
|
|
152
|
+
return best;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Whether a write at this path (a file or a prefix) can change what the checks read (#3998). A path inside a package of
|
|
156
|
+
* the read closure can; a path inside another package cannot; a path inside NO package can, because nothing says which
|
|
157
|
+
* checks read it (a root manifest, the application's config, a top-level directory that holds packages).
|
|
158
|
+
*/
|
|
159
|
+
export function isPathReadBy(path, scope, graph) {
|
|
160
|
+
if (scope.wholeApplication || graph === undefined)
|
|
161
|
+
return true;
|
|
162
|
+
const normalized = normalizeApplicationPath(path);
|
|
163
|
+
const owner = normalized === '' ? undefined : packageContaining(normalized, graph);
|
|
164
|
+
return owner === undefined || scope.packageDirectories.has(owner);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Whether a live run that may write these paths could interfere with the checks (#3998). `undefined` (what the run
|
|
168
|
+
* writes is not known) and an empty list (a run with no stated scope) both interfere: unknown means it may.
|
|
169
|
+
*/
|
|
170
|
+
export function writeScopeMayReachReadScope(writes, scope, graph) {
|
|
171
|
+
if (writes === undefined || writes.length === 0)
|
|
172
|
+
return true;
|
|
173
|
+
return writes.some((path) => isPathReadBy(path, scope, graph));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Whether anything the checks read changed between two worktree snapshots (#3998): HEAD moved, or a dirty or untracked
|
|
177
|
+
* file the checks read appeared, disappeared or changed its content. What decides whether a re-check that ran beside
|
|
178
|
+
* live runs is kept: the prediction of what each run writes said nothing would be written there, and this says whether
|
|
179
|
+
* anything was, by any writer, a shell command included, among the paths a snapshot lists. A snapshot lists tracked and
|
|
180
|
+
* untracked files, never gitignored ones, so compiled output (`dist/`) is not compared: its sources are. HEAD is compared
|
|
181
|
+
* repository-wide, so any commit during the checks counts as a change (the conservative direction).
|
|
182
|
+
*/
|
|
183
|
+
export function readScopeChangedBetween(before, after, scope, graph) {
|
|
184
|
+
if (before.headSha !== after.headSha)
|
|
185
|
+
return true;
|
|
186
|
+
for (const path of new Set([...Object.keys(before.files), ...Object.keys(after.files)])) {
|
|
187
|
+
if (!isPathReadBy(path, scope, graph))
|
|
188
|
+
continue;
|
|
189
|
+
const earlier = before.files[path];
|
|
190
|
+
const later = after.files[path];
|
|
191
|
+
if (earlier === undefined || later === undefined)
|
|
192
|
+
return true;
|
|
193
|
+
if (earlier.changeKind !== later.changeKind || earlier.fingerprint !== later.fingerprint || earlier.sizeBytes !== later.sizeBytes)
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=isolated-recheck-interference.models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated-recheck-interference.models.js","sourceRoot":"","sources":["../../../../src/claude-cli/models/isolated-recheck-interference.models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAwE,MAAM,gCAAgC,CAAC;AAkCxI,MAAM,iBAAiB,GAA0B,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;AAE5E,wHAAwH;AACxH,SAAS,uBAAuB,CAAC,IAAY;IAC3C,OAAO,IAAI,KAAK,cAAc,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAY,CAAC;QACjE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAiC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjI,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,iBAAiB,GAAG,CAAC,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,sBAAsB,CAAU,CAAC;AACnH,sHAAsH;AACtH,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAAC,QAAgB;IACnE,IAAI,W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AC;IAC7D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAsD,EACtD,KAAqD,EACrD,KAA4B,EAC5B,KAAmD;IAEnD,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAClD,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACxF,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC;YAAE,SAAS;QAChD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QAC9D,IAAI,OAAO,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK,CAAC,WAAW,IAAI,OAAO,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;IACjJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { VerificationKind, type ApplicationCodingTaskVerificationPlan, type GitWorktreeSnapshot } from './coding-agent-dispatch.models';\n\n/**\n * Whether a failed run's isolated re-check may run while other coding runs are still live (#3998).\n *\n * A run that failed its checks beside siblings is re-checked ALONE (#3220), because the failure may be a sibling's\n * half-written file rather than the run's own work. Until #3998 \"alone\" meant \"once every run of the wave has settled\",\n * so a task waited for the slowest run of its wave whatever that run wrote: on reference run 43961156770 that left the\n * build with nothing running and 27 tasks ready for 13.4 minutes, 44.6 minutes in all.\n *\n * The interference the re-check rules out comes only from runs that write what the re-run checks READ. So a re-check\n * may run beside a live run when that run is not expected to write a package the checks read, and its verdict is kept\n * only when nothing under those packages changed while the checks ran. This module answers both questions; it reads\n * nothing but the application's own package manifests and the two worktree snapshots it is given.\n */\n\n/** An application's workspace packages and what each depends on, read from their own `package.json` files. */\nexport interface ApplicationWorkspacePackageGraph {\n /** Application-relative package directories, no trailing slash (`shared-lib`, `workers/my-node-worker`). */\n readonly packageDirectories: readonly string[];\n /**\n * Per package directory, the directories of the workspace packages it depends on. A package naming a `workspace:`\n * dependency that no discovered package carries is absent here: its read closure cannot be known, so a check reading\n * it reads the whole application. A `file:` or `link:` dependency outside the application (the framework's own packages\n * in framework development) is no package of it, and no coding run writes it.\n */\n readonly dependsOn: ReadonlyMap<string, readonly string[]>;\n}\n\n/** What a set of verification checks reads: a closure of workspace packages, or the whole application. */\nexport type VerificationReadScope =\n | { readonly wholeApplication: true }\n | { readonly wholeApplication: false; readonly packageDirectories: ReadonlySet<string> };\n\nconst WHOLE_APPLICATION: VerificationReadScope = { wholeApplication: true };\n\n/** Directory entries that are never a package of the application: installs, git, and dotted (tool or runtime) trees. */\nfunction isCandidatePackageEntry(name: string): boolean {\n return name !== 'node_modules' && !name.startsWith('.');\n}\n\nfunction readManifest(path: string): Record<string, unknown> | undefined {\n try {\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as unknown;\n return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed as Record<string, unknown> : undefined;\n } catch {\n return undefined;\n }\n}\n\nconst DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] as const;\n/** The specifier that names a package of the same workspace, which must therefore resolve to a discovered package. */\nconst WORKSPACE_SPECIFIER = /^workspace:/u;\n\n/**\n * Read the application's workspace packages from the tree (#3998): every directory at the application root, or one level\n * below a root directory that is not itself a package (`workers/*`, `minions/*`, `providers/*`), holding a `package.json`.\n * Derived from what exists rather than from a list, so a package a composition scenario adds is a package here the day it\n * exists. `undefined` when the root cannot be listed: every check then reads the whole application.\n */\nexport function readApplicationWorkspacePackageGraph(saasRoot: string): ApplicationWorkspacePackageGraph | undefined {\n let rootEntries: string[];\n try {\n rootEntries = readdirSync(saasRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isCandidatePackageEntry(entry.name)).map((entry) => entry.name);\n } catch {\n return undefined;\n }\n const manifests = new Map<string, Record<string, unknown>>();\n for (const entry of rootEntries) {\n const manifest = existsSync(join(saasRoot, entry, 'package.json')) ? readManifest(join(saasRoot, entry, 'package.json')) : undefined;\n if (manifest !== undefined) {\n manifests.set(entry, manifest);\n continue;\n }\n let children: string[];\n try {\n children = readdirSync(join(saasRoot, entry), { withFileTypes: true }).filter((child) => child.isDirectory() && isCandidatePackageEntry(child.name)).map((child) => child.name);\n } catch {\n continue;\n }\n for (const child of children) {\n const nested = readManifest(join(saasRoot, entry, child, 'package.json'));\n if (nested !== undefined) manifests.set(`${entry}/${child}`, nested);\n }\n }\n const directoryByName = new Map<string, string>();\n for (const [directory, manifest] of manifests) {\n if (typeof manifest.name === 'string') directoryByName.set(manifest.name, directory);\n }\n const dependsOn = new Map<string, readonly string[]>();\n for (const [directory, manifest] of manifests) {\n const dependencies: string[] = [];\n let resolved = true;\n for (const field of DEPENDENCY_FIELDS) {\n const declared = manifest[field];\n if (typeof declared !== 'object' || declared === null) continue;\n for (const [name, specifier] of Object.entries(declared as Record<string, unknown>)) {\n const dependencyDirectory = directoryByName.get(name);\n if (dependencyDirectory !== undefined) dependencies.push(dependencyDirectory);\n else if (typeof specifier === 'string' && WORKSPACE_SPECIFIER.test(specifier)) resolved = false;\n }\n }\n if (resolved) dependsOn.set(directory, [...new Set(dependencies)]);\n }\n return { packageDirectories: [...manifests.keys()], dependsOn };\n}\n\n/**\n * The workspace package each check reads FROM, before its dependency closure (#3998). Exhaustive over\n * {@link VerificationKind}, so a kind added tomorrow does not compile until it says what it reads.\n *\n * - A check with a `path` reads that package (a typecheck, a package build, a design-system check of the frontend).\n * - A check of the application's assembled backend (the resources registry built offline, the schema-plan drift, the FK\n * sweep through the backend's introspection) reads `backend-api`: each of them imports its compiled modules registry,\n * at the path those checks themselves name (`backend-api/dist/modules-registry.backend.js`).\n * - The settings-rail sweep reads `frontend`; the specification evaluation reads `specifications`.\n * - Everything else reads the WHOLE application: a test path can import anything, and the module layout, the config,\n * a running backend, a browser and the website's demo facts are about every package at once.\n */\nconst READ_ROOT_BY_KIND: Readonly<Record<VerificationKind, 'PATH' | 'WHOLE' | string>> = {\n [VerificationKind.TYPECHECK]: 'PATH',\n [VerificationKind.PACKAGE_BUILD]: 'PATH',\n [VerificationKind.DESIGN_SYSTEM_CONTRAST]: 'PATH',\n [VerificationKind.DESIGN_SYSTEM_CONTRACT]: 'PATH',\n [VerificationKind.DESIGN_SYSTEM_BRAND]: 'PATH',\n [VerificationKind.RESOURCES_REGISTRY_INIT]: 'backend-api',\n [VerificationKind.SCHEMA_PLAN_DRIFT]: 'backend-api',\n [VerificationKind.FRONTEND_FK_RESOLUTION]: 'backend-api',\n [VerificationKind.SETTINGS_PLACEMENT_CONTENT]: 'frontend',\n [VerificationKind.SPECIFICATION_EXPORTS]: 'specifications',\n [VerificationKind.VITEST_PATH]: 'WHOLE',\n [VerificationKind.MODULE_LAYOUT]: 'WHOLE',\n [VerificationKind.CONFIG_VALIDATE]: 'WHOLE',\n [VerificationKind.BACKEND_READY]: 'WHOLE',\n [VerificationKind.BROWSER_SMOKE]: 'WHOLE',\n [VerificationKind.WEBSITE_DEMO_FACTS]: 'WHOLE',\n};\n\n/**\n * What these checks read (#3998): the union of each one's root package and every workspace package that root depends on,\n * transitively. The whole application when any check's root is whole, unknown, absent from the graph, or depends on a\n * workspace package that could not be resolved. Files outside every package (the root manifests, `wildo.saas.config.ts`,\n * `infrastructure/`) are read by every check: see {@link isPathReadBy}.\n */\nexport function resolveVerificationReadScope(\n plans: readonly Pick<ApplicationCodingTaskVerificationPlan, 'kind' | 'path'>[],\n graph: ApplicationWorkspacePackageGraph | undefined,\n): VerificationReadScope {\n if (graph === undefined || plans.length === 0) return WHOLE_APPLICATION;\n const closure = new Set<string>();\n const pending: string[] = [];\n for (const plan of plans) {\n const declared = READ_ROOT_BY_KIND[plan.kind] as string | undefined;\n const root = declared === 'PATH' ? plan.path : declared === 'WHOLE' ? null : declared;\n if (root === undefined || root === null || root === '' || !graph.packageDirectories.includes(root)) return WHOLE_APPLICATION;\n pending.push(root);\n }\n while (pending.length > 0) {\n const directory = pending.pop()!;\n if (closure.has(directory)) continue;\n const dependencies = graph.dependsOn.get(directory);\n if (dependencies === undefined) return WHOLE_APPLICATION;\n closure.add(directory);\n pending.push(...dependencies);\n }\n return { wholeApplication: false, packageDirectories: closure };\n}\n\n/** An application-relative path or prefix, without a leading `./` or `/`. */\nfunction normalizeApplicationPath(path: string): string {\n return path.replace(/\\\\/gu, '/').replace(/^(?:\\.\\/|\\/)+/u, '');\n}\n\n/** The package directory a path lies in (the longest match), or `undefined` when it lies in none. */\nfunction packageContaining(path: string, graph: ApplicationWorkspacePackageGraph): string | undefined {\n let best: string | undefined;\n for (const directory of graph.packageDirectories) {\n if ((path === directory || path.startsWith(`${directory}/`)) && (best === undefined || directory.length > best.length)) best = directory;\n }\n return best;\n}\n\n/**\n * Whether a write at this path (a file or a prefix) can change what the checks read (#3998). A path inside a package of\n * the read closure can; a path inside another package cannot; a path inside NO package can, because nothing says which\n * checks read it (a root manifest, the application's config, a top-level directory that holds packages).\n */\nexport function isPathReadBy(path: string, scope: VerificationReadScope, graph: ApplicationWorkspacePackageGraph | undefined): boolean {\n if (scope.wholeApplication || graph === undefined) return true;\n const normalized = normalizeApplicationPath(path);\n const owner = normalized === '' ? undefined : packageContaining(normalized, graph);\n return owner === undefined || scope.packageDirectories.has(owner);\n}\n\n/**\n * Whether a live run that may write these paths could interfere with the checks (#3998). `undefined` (what the run\n * writes is not known) and an empty list (a run with no stated scope) both interfere: unknown means it may.\n */\nexport function writeScopeMayReachReadScope(\n writes: readonly string[] | undefined,\n scope: VerificationReadScope,\n graph: ApplicationWorkspacePackageGraph | undefined,\n): boolean {\n if (writes === undefined || writes.length === 0) return true;\n return writes.some((path) => isPathReadBy(path, scope, graph));\n}\n\n/**\n * Whether anything the checks read changed between two worktree snapshots (#3998): HEAD moved, or a dirty or untracked\n * file the checks read appeared, disappeared or changed its content. What decides whether a re-check that ran beside\n * live runs is kept: the prediction of what each run writes said nothing would be written there, and this says whether\n * anything was, by any writer, a shell command included, among the paths a snapshot lists. A snapshot lists tracked and\n * untracked files, never gitignored ones, so compiled output (`dist/`) is not compared: its sources are. HEAD is compared\n * repository-wide, so any commit during the checks counts as a change (the conservative direction).\n */\nexport function readScopeChangedBetween(\n before: Pick<GitWorktreeSnapshot, 'headSha' | 'files'>,\n after: Pick<GitWorktreeSnapshot, 'headSha' | 'files'>,\n scope: VerificationReadScope,\n graph: ApplicationWorkspacePackageGraph | undefined,\n): boolean {\n if (before.headSha !== after.headSha) return true;\n for (const path of new Set([...Object.keys(before.files), ...Object.keys(after.files)])) {\n if (!isPathReadBy(path, scope, graph)) continue;\n const earlier = before.files[path];\n const later = after.files[path];\n if (earlier === undefined || later === undefined) return true;\n if (earlier.changeKind !== later.changeKind || earlier.fingerprint !== later.fingerprint || earlier.sizeBytes !== later.sizeBytes) return true;\n }\n return false;\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;CA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