@principles/pd-cli 2.9.1 → 2.11.0
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/commands/candidate.d.ts.map +1 -1
- package/dist/commands/candidate.js +16 -5
- package/dist/commands/candidate.js.map +1 -1
- package/dist/commands/codex-setup.d.ts.map +1 -1
- package/dist/commands/codex-setup.js +17 -1
- package/dist/commands/codex-setup.js.map +1 -1
- package/dist/commands/codex-worker.d.ts.map +1 -1
- package/dist/commands/codex-worker.js +8 -4
- package/dist/commands/codex-worker.js.map +1 -1
- package/dist/commands/consent-sweep-revoked.d.ts +20 -0
- package/dist/commands/consent-sweep-revoked.d.ts.map +1 -0
- package/dist/commands/consent-sweep-revoked.js +85 -0
- package/dist/commands/consent-sweep-revoked.js.map +1 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +9 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/diagnose.d.ts.map +1 -1
- package/dist/commands/diagnose.js +12 -6
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/openclaw-worker.d.ts +11 -0
- package/dist/commands/openclaw-worker.d.ts.map +1 -0
- package/dist/commands/openclaw-worker.js +199 -0
- package/dist/commands/openclaw-worker.js.map +1 -0
- package/dist/commands/pain-explicit.d.ts.map +1 -1
- package/dist/commands/pain-explicit.js +1 -0
- package/dist/commands/pain-explicit.js.map +1 -1
- package/dist/commands/pain-recall.d.ts +2 -2
- package/dist/commands/pain-recall.d.ts.map +1 -1
- package/dist/commands/pain-recall.js +7 -1
- package/dist/commands/pain-recall.js.map +1 -1
- package/dist/commands/pain-record.d.ts.map +1 -1
- package/dist/commands/pain-record.js +4 -1
- package/dist/commands/pain-record.js.map +1 -1
- package/dist/commands/pain-retry.d.ts.map +1 -1
- package/dist/commands/pain-retry.js +30 -6
- package/dist/commands/pain-retry.js.map +1 -1
- package/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-enqueue-successors.js +2 -1
- package/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
- package/dist/commands/runtime-internalization-run-once.d.ts +1 -0
- package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-run-once.js +32 -8
- package/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-wake-once.js +2 -1
- package/dist/commands/runtime-internalization-wake-once.js.map +1 -1
- package/dist/commands/service-handover.d.ts +12 -0
- package/dist/commands/service-handover.d.ts.map +1 -0
- package/dist/commands/service-handover.js +117 -0
- package/dist/commands/service-handover.js.map +1 -0
- package/dist/commands/service-lifecycle.d.ts +31 -0
- package/dist/commands/service-lifecycle.d.ts.map +1 -0
- package/dist/commands/service-lifecycle.js +207 -0
- package/dist/commands/service-lifecycle.js.map +1 -0
- package/dist/commands/service-run-once.d.ts +102 -0
- package/dist/commands/service-run-once.d.ts.map +1 -0
- package/dist/commands/service-run-once.js +558 -0
- package/dist/commands/service-run-once.js.map +1 -0
- package/dist/commands/workbuddy-setup.d.ts.map +1 -1
- package/dist/commands/workbuddy-setup.js +22 -2
- package/dist/commands/workbuddy-setup.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +180 -1
- package/dist/program.js.map +1 -1
- package/dist/services/admission-write-gate.d.ts +3 -1
- package/dist/services/admission-write-gate.d.ts.map +1 -1
- package/dist/services/admission-write-gate.js +1 -0
- package/dist/services/admission-write-gate.js.map +1 -1
- package/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
- package/dist/services/pain-flood-simulation-runner.js +4 -0
- package/dist/services/pain-flood-simulation-runner.js.map +1 -1
- package/dist/services/service-host/coordinator-common.d.ts +49 -0
- package/dist/services/service-host/coordinator-common.d.ts.map +1 -0
- package/dist/services/service-host/coordinator-common.js +158 -0
- package/dist/services/service-host/coordinator-common.js.map +1 -0
- package/dist/services/service-host/handover-claims.d.ts +14 -0
- package/dist/services/service-host/handover-claims.d.ts.map +1 -0
- package/dist/services/service-host/handover-claims.js +50 -0
- package/dist/services/service-host/handover-claims.js.map +1 -0
- package/dist/services/service-host/index.d.ts +31 -0
- package/dist/services/service-host/index.d.ts.map +1 -0
- package/dist/services/service-host/index.js +33 -0
- package/dist/services/service-host/index.js.map +1 -0
- package/dist/services/service-host/install-identity.d.ts +99 -0
- package/dist/services/service-host/install-identity.d.ts.map +1 -0
- package/dist/services/service-host/install-identity.js +176 -0
- package/dist/services/service-host/install-identity.js.map +1 -0
- package/dist/services/service-host/locking/service-run-lock.d.ts +255 -0
- package/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -0
- package/dist/services/service-host/locking/service-run-lock.js +739 -0
- package/dist/services/service-host/locking/service-run-lock.js.map +1 -0
- package/dist/services/service-host/managed-run.d.ts +75 -0
- package/dist/services/service-host/managed-run.d.ts.map +1 -0
- package/dist/services/service-host/managed-run.js +550 -0
- package/dist/services/service-host/managed-run.js.map +1 -0
- package/dist/services/service-host/owner-projection.d.ts +47 -0
- package/dist/services/service-host/owner-projection.d.ts.map +1 -0
- package/dist/services/service-host/owner-projection.js +121 -0
- package/dist/services/service-host/owner-projection.js.map +1 -0
- package/dist/services/service-host/progress-evidence.d.ts +38 -0
- package/dist/services/service-host/progress-evidence.d.ts.map +1 -0
- package/dist/services/service-host/progress-evidence.js +155 -0
- package/dist/services/service-host/progress-evidence.js.map +1 -0
- package/dist/services/service-host/run-once.d.ts +96 -0
- package/dist/services/service-host/run-once.d.ts.map +1 -0
- package/dist/services/service-host/run-once.js +308 -0
- package/dist/services/service-host/run-once.js.map +1 -0
- package/dist/services/service-host/scheduler/contract.d.ts +184 -0
- package/dist/services/service-host/scheduler/contract.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/contract.js +86 -0
- package/dist/services/service-host/scheduler/contract.js.map +1 -0
- package/dist/services/service-host/scheduler/index.d.ts +76 -0
- package/dist/services/service-host/scheduler/index.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/index.js +128 -0
- package/dist/services/service-host/scheduler/index.js.map +1 -0
- package/dist/services/service-host/scheduler/linux.d.ts +27 -0
- package/dist/services/service-host/scheduler/linux.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/linux.js +1010 -0
- package/dist/services/service-host/scheduler/linux.js.map +1 -0
- package/dist/services/service-host/scheduler/macos.d.ts +13 -0
- package/dist/services/service-host/scheduler/macos.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/macos.js +819 -0
- package/dist/services/service-host/scheduler/macos.js.map +1 -0
- package/dist/services/service-host/scheduler/runtime-io.d.ts +13 -0
- package/dist/services/service-host/scheduler/runtime-io.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/runtime-io.js +141 -0
- package/dist/services/service-host/scheduler/runtime-io.js.map +1 -0
- package/dist/services/service-host/scheduler/service-status.d.ts +99 -0
- package/dist/services/service-host/scheduler/service-status.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/service-status.js +202 -0
- package/dist/services/service-host/scheduler/service-status.js.map +1 -0
- package/dist/services/service-host/scheduler/windows.d.ts +40 -0
- package/dist/services/service-host/scheduler/windows.d.ts.map +1 -0
- package/dist/services/service-host/scheduler/windows.js +688 -0
- package/dist/services/service-host/scheduler/windows.js.map +1 -0
- package/dist/services/service-host/shadow-progress-store.d.ts +43 -0
- package/dist/services/service-host/shadow-progress-store.d.ts.map +1 -0
- package/dist/services/service-host/shadow-progress-store.js +156 -0
- package/dist/services/service-host/shadow-progress-store.js.map +1 -0
- package/dist/services/service-host/shadow-run.d.ts +87 -0
- package/dist/services/service-host/shadow-run.d.ts.map +1 -0
- package/dist/services/service-host/shadow-run.js +549 -0
- package/dist/services/service-host/shadow-run.js.map +1 -0
- package/dist/services/service-host/status/service-run-status.d.ts +227 -0
- package/dist/services/service-host/status/service-run-status.d.ts.map +1 -0
- package/dist/services/service-host/status/service-run-status.js +187 -0
- package/dist/services/service-host/status/service-run-status.js.map +1 -0
- package/dist/services/service-host/worker-adapter-codex.d.ts +2 -0
- package/dist/services/service-host/worker-adapter-codex.d.ts.map +1 -0
- package/dist/services/service-host/worker-adapter-codex.js +76 -0
- package/dist/services/service-host/worker-adapter-codex.js.map +1 -0
- package/dist/services/service-host/worker-adapter-openclaw.d.ts +2 -0
- package/dist/services/service-host/worker-adapter-openclaw.d.ts.map +1 -0
- package/dist/services/service-host/worker-adapter-openclaw.js +49 -0
- package/dist/services/service-host/worker-adapter-openclaw.js.map +1 -0
- package/dist/services/service-host/worker-adapter-workbuddy.d.ts +2 -0
- package/dist/services/service-host/worker-adapter-workbuddy.d.ts.map +1 -0
- package/dist/services/service-host/worker-adapter-workbuddy.js +36 -0
- package/dist/services/service-host/worker-adapter-workbuddy.js.map +1 -0
- package/dist/services/service-host/worker-adapter.d.ts +187 -0
- package/dist/services/service-host/worker-adapter.d.ts.map +1 -0
- package/dist/services/service-host/worker-adapter.js +609 -0
- package/dist/services/service-host/worker-adapter.js.map +1 -0
- package/dist/services/service-host/worker-env.d.ts +84 -0
- package/dist/services/service-host/worker-env.d.ts.map +1 -0
- package/dist/services/service-host/worker-env.js +195 -0
- package/dist/services/service-host/worker-env.js.map +1 -0
- package/dist/services/service-host/worker-process.d.ts +75 -0
- package/dist/services/service-host/worker-process.d.ts.map +1 -0
- package/dist/services/service-host/worker-process.js +225 -0
- package/dist/services/service-host/worker-process.js.map +1 -0
- package/dist/services/service-host/workspace-discovery.d.ts +71 -0
- package/dist/services/service-host/workspace-discovery.d.ts.map +1 -0
- package/dist/services/service-host/workspace-discovery.js +288 -0
- package/dist/services/service-host/workspace-discovery.js.map +1 -0
- package/dist/services/service-host/workspace-dispatch.d.ts +61 -0
- package/dist/services/service-host/workspace-dispatch.d.ts.map +1 -0
- package/dist/services/service-host/workspace-dispatch.js +105 -0
- package/dist/services/service-host/workspace-dispatch.js.map +1 -0
- package/dist/services/service-host/workspace-handover.d.ts +190 -0
- package/dist/services/service-host/workspace-handover.d.ts.map +1 -0
- package/dist/services/service-host/workspace-handover.js +1393 -0
- package/dist/services/service-host/workspace-handover.js.map +1 -0
- package/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
- package/dist/services/synthetic-baseline-runner.js +4 -0
- package/dist/services/synthetic-baseline-runner.js.map +1 -1
- package/package.json +10 -9
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type HostClaimOptions, type HostWorkspaceClaim, type InstallManifest, type McpBindingHost } from '@principles/install-layout';
|
|
2
|
+
import { type OwnerProjection } from './owner-projection.js';
|
|
3
|
+
/**
|
|
4
|
+
* Discovery verdicts (Phase 1 admission boundary). `discovered` is the
|
|
5
|
+
* low-severity default: a location an authorized source SAW that carries no
|
|
6
|
+
* registered fact (manifest entry / validated binding / declaration) or PD
|
|
7
|
+
* governance state yet — e.g. a host default tree that exists on disk without
|
|
8
|
+
* PD setup. Registered facts that fail on-disk validation escalate:
|
|
9
|
+
* `unavailable` (registered dir gone), `degraded` (registered dir exists but
|
|
10
|
+
* the `.pd` state dir is missing), `conflicting` (cross-host containment
|
|
11
|
+
* violation), `invalid` (identity/validation could not be established).
|
|
12
|
+
*/
|
|
13
|
+
export declare const WORKSPACE_DISCOVERY_VERDICTS: readonly ['authorized', 'degraded', 'unavailable', 'conflicting', 'invalid', 'discovered'];
|
|
14
|
+
export type WorkspaceDiscoveryVerdict = (typeof WORKSPACE_DISCOVERY_VERDICTS)[number];
|
|
15
|
+
export interface DiscoveryProbes {
|
|
16
|
+
/** `dir` / `missing` / `other` (exists but not a directory). */
|
|
17
|
+
statDir(dir: string): 'dir' | 'missing' | 'other';
|
|
18
|
+
/** Realpath identity, or undefined when unresolvable. */
|
|
19
|
+
realpath(target: string): string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare function defaultDiscoveryProbes(): DiscoveryProbes;
|
|
22
|
+
/** Per-workspace discovery evidence for one source entry. */
|
|
23
|
+
export interface WorkspaceSourceRef {
|
|
24
|
+
readonly source: 'manifest' | 'claim';
|
|
25
|
+
/** For claims: the claiming host. */
|
|
26
|
+
readonly host?: McpBindingHost;
|
|
27
|
+
/** For claims: how the claim was established (SPEC §9.1 source B). */
|
|
28
|
+
readonly via?: HostWorkspaceClaim['via'];
|
|
29
|
+
/** The exact path the source listed (evidence; may differ lexically from canonicalDir). */
|
|
30
|
+
readonly path: string;
|
|
31
|
+
}
|
|
32
|
+
export interface WorkspaceDiscoveryEntry {
|
|
33
|
+
/** Canonical (realpath-preferred) absolute dir — the dedupe identity. */
|
|
34
|
+
readonly canonicalDir: string;
|
|
35
|
+
readonly verdict: WorkspaceDiscoveryVerdict;
|
|
36
|
+
/** Hosts that claim this exact workspace (multi-host sharing is allowed, §9.1.5). */
|
|
37
|
+
readonly hosts: readonly McpBindingHost[];
|
|
38
|
+
/** Every authorized-source listing that produced this entry. */
|
|
39
|
+
readonly sources: readonly WorkspaceSourceRef[];
|
|
40
|
+
/** Read-only owner projection from `backgroundExecutions` (§8.4). */
|
|
41
|
+
readonly owner: OwnerProjection;
|
|
42
|
+
/** On-disk facts. */
|
|
43
|
+
readonly checks: {
|
|
44
|
+
readonly directory: 'present' | 'missing' | 'not_a_directory' | 'unchecked';
|
|
45
|
+
readonly stateDir: 'present' | 'missing' | 'unchecked';
|
|
46
|
+
/** Realpath identity resolved (false = lexical form used). */
|
|
47
|
+
readonly realpathResolved: boolean;
|
|
48
|
+
};
|
|
49
|
+
/** Structured reason when the verdict is not `authorized` (rc-9). */
|
|
50
|
+
readonly reason?: string;
|
|
51
|
+
/** Operator next action when the verdict is not `authorized`. */
|
|
52
|
+
readonly nextAction?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface WorkspaceDiscoveryResult {
|
|
55
|
+
readonly workspaces: readonly WorkspaceDiscoveryEntry[];
|
|
56
|
+
readonly discoveredTotal: number;
|
|
57
|
+
readonly counts: Readonly<Record<WorkspaceDiscoveryVerdict, number>>;
|
|
58
|
+
}
|
|
59
|
+
export interface DiscoverWorkspacesInput {
|
|
60
|
+
/** The parsed install manifest (source A). Must be a VALID parse — callers never hand over an error. */
|
|
61
|
+
manifest: InstallManifest;
|
|
62
|
+
/** Validated per-host claims (source B), as produced by `collectHostWorkspaceClaims`. */
|
|
63
|
+
claims: readonly HostWorkspaceClaim[];
|
|
64
|
+
/** Host-root context the claims were collected with (reused for foreign-owner checks). */
|
|
65
|
+
claimOptions: HostClaimOptions;
|
|
66
|
+
probes?: DiscoveryProbes;
|
|
67
|
+
}
|
|
68
|
+
/** Bounded, control-character-free string for reasons/status output (rc-8). */
|
|
69
|
+
export declare function bounded(value: string, max: number): string;
|
|
70
|
+
export declare function discoverWorkspaces(input: DiscoverWorkspacesInput): WorkspaceDiscoveryResult;
|
|
71
|
+
//# sourceMappingURL=workspace-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-discovery.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/workspace-discovery.ts"],"names":[],"mappings":"AAoBA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAgC,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE3F;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,YACvC,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,CACJ,CAAC;AACX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtF,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC;IAClD,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC9C;AAED,wBAAgB,sBAAsB,IAAI,eAAe,CAmBxD;AAED,6DAA6D;AAC7D,MAAM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AC,CAAC;CACtE;AAED,MAAM,WAAW,uBAAuB;IACtC,wGAAwG;IACxG,QAAQ,EAAE,eAAe,CAAC;IAC1B,yFAAyF;IACzF,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACtC,0FAA0F;IAC1F,YAAY,EAAE,gBAAgB,CAAC;IAC/B,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAuCD,+EAA+E;AAC/E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAG1D;AAqKD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,wBAAwB,CAqD3F"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace discovery (SPEC-PD-SERVICE-HOST-001 §9.1, TD §5.1).
|
|
3
|
+
*
|
|
4
|
+
* Two authorized discovery sources, nothing else:
|
|
5
|
+
* A. the canonical install manifest (`workspaces[]` + per-Workspace
|
|
6
|
+
* `backgroundExecutions` ownership records);
|
|
7
|
+
* B. validated per-host binding claims (`collectHostWorkspaceClaims` —
|
|
8
|
+
* `default` / `host_declaration` / `payload_binding`).
|
|
9
|
+
*
|
|
10
|
+
* The claim collector is the existing fail-closed authority: only a FULLY
|
|
11
|
+
* validated binding forms a claim, and an unreadable/invalid binding yields
|
|
12
|
+
* NO claim (the launcher's refuse-to-start rule). Discovery never re-implements
|
|
13
|
+
* that validation and never widens it; it groups, cross-checks and reports.
|
|
14
|
+
*
|
|
15
|
+
* No cwd inference, no arbitrary directory scanning, no env-var-derived
|
|
16
|
+
* workspaces, no free-text MCP parameters — those are explicitly forbidden
|
|
17
|
+
* (SPEC §9.1, Phase 1 admission boundary).
|
|
18
|
+
*/
|
|
19
|
+
import * as fs from 'node:fs';
|
|
20
|
+
import * as path from 'node:path';
|
|
21
|
+
import { MCP_BINDING_HOSTS, findForeignWorkspaceOwner, } from '@principles/install-layout';
|
|
22
|
+
import { projectWorkspaceOwnerAliases } from './owner-projection.js';
|
|
23
|
+
/**
|
|
24
|
+
* Discovery verdicts (Phase 1 admission boundary). `discovered` is the
|
|
25
|
+
* low-severity default: a location an authorized source SAW that carries no
|
|
26
|
+
* registered fact (manifest entry / validated binding / declaration) or PD
|
|
27
|
+
* governance state yet — e.g. a host default tree that exists on disk without
|
|
28
|
+
* PD setup. Registered facts that fail on-disk validation escalate:
|
|
29
|
+
* `unavailable` (registered dir gone), `degraded` (registered dir exists but
|
|
30
|
+
* the `.pd` state dir is missing), `conflicting` (cross-host containment
|
|
31
|
+
* violation), `invalid` (identity/validation could not be established).
|
|
32
|
+
*/
|
|
33
|
+
export const WORKSPACE_DISCOVERY_VERDICTS = [
|
|
34
|
+
'authorized',
|
|
35
|
+
'degraded',
|
|
36
|
+
'unavailable',
|
|
37
|
+
'conflicting',
|
|
38
|
+
'invalid',
|
|
39
|
+
'discovered',
|
|
40
|
+
];
|
|
41
|
+
export function defaultDiscoveryProbes() {
|
|
42
|
+
return {
|
|
43
|
+
statDir(dir) {
|
|
44
|
+
try {
|
|
45
|
+
const stats = fs.statSync(dir);
|
|
46
|
+
if (stats.isDirectory())
|
|
47
|
+
return 'dir';
|
|
48
|
+
return 'other';
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return 'missing';
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
realpath(target) {
|
|
55
|
+
try {
|
|
56
|
+
return fs.realpathSync.native(target);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Workspace identity for dedupe and same-ownership comparison (§9.1.6):
|
|
66
|
+
* realpath when resolvable (junction/symlink aliases collapse onto the same
|
|
67
|
+
* real directory), else the resolved lexical form; Windows compares
|
|
68
|
+
* case-insensitively (the launcher's `samePath` rule).
|
|
69
|
+
*/
|
|
70
|
+
function identityForm(value, platform, realpath) {
|
|
71
|
+
const resolved = path.resolve(value);
|
|
72
|
+
const real = realpath(resolved) ?? resolved;
|
|
73
|
+
return platform === 'win32' ? real.toLowerCase() : real;
|
|
74
|
+
}
|
|
75
|
+
/** Bounded, control-character-free string for reasons/status output (rc-8). */
|
|
76
|
+
export function bounded(value, max) {
|
|
77
|
+
const clean = value.replace(/[^\x20-\x7E]+/g, ' ');
|
|
78
|
+
return clean.length > max ? `${clean.slice(0, max - 1)}…` : clean;
|
|
79
|
+
}
|
|
80
|
+
function validateGroupInner(group, paths, ctx) {
|
|
81
|
+
const { platform, probes, manifest, claimOptions } = ctx;
|
|
82
|
+
const { canonicalDir, manifestForms } = paths;
|
|
83
|
+
// The owner projection looks up EVERY manifest alias of this real dir —
|
|
84
|
+
// ownership records are keyed to the parser's workspaces[] strings, and a
|
|
85
|
+
// record filed under a second alias must not be missed (P1-6).
|
|
86
|
+
const owner = projectWorkspaceOwnerAliases(manifest, manifestForms, platform);
|
|
87
|
+
const hasRegisteredFact = group.manifestForms.length > 0
|
|
88
|
+
|| group.sources.some((ref) => ref.source === 'claim' && (ref.via === 'payload_binding' || ref.via === 'host_declaration'));
|
|
89
|
+
// ── On-disk facts ──
|
|
90
|
+
const directoryProbe = probes.statDir(canonicalDir);
|
|
91
|
+
const directory = directoryProbe === 'dir' ? 'present' : directoryProbe === 'missing' ? 'missing' : 'not_a_directory';
|
|
92
|
+
let stateDir = 'unchecked';
|
|
93
|
+
let verdict;
|
|
94
|
+
let reason;
|
|
95
|
+
let nextAction;
|
|
96
|
+
if (directory !== 'present') {
|
|
97
|
+
// §9.1.6: a missing/mis-typed path never infers a replacement directory.
|
|
98
|
+
if (hasRegisteredFact) {
|
|
99
|
+
verdict = 'unavailable';
|
|
100
|
+
reason = directory === 'missing'
|
|
101
|
+
? 'workspace_directory_missing'
|
|
102
|
+
: 'workspace_path_not_a_directory';
|
|
103
|
+
nextAction = 'Re-register the workspace (installer / host setup) or remove the stale registration; do not point PD at a replacement directory by hand.';
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
verdict = 'discovered';
|
|
107
|
+
reason = directory === 'missing'
|
|
108
|
+
? 'default_location_not_created_yet'
|
|
109
|
+
: 'default_location_not_a_directory';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const stateProbe = probes.statDir(path.join(canonicalDir, '.pd'));
|
|
114
|
+
if (stateProbe === 'dir') {
|
|
115
|
+
stateDir = 'present';
|
|
116
|
+
verdict = 'authorized';
|
|
117
|
+
}
|
|
118
|
+
else if (hasRegisteredFact) {
|
|
119
|
+
stateDir = 'missing';
|
|
120
|
+
verdict = 'degraded';
|
|
121
|
+
reason = 'workspace_state_dir_missing';
|
|
122
|
+
nextAction = 'Re-run the host setup for this workspace so PD governance state (.pd/) is created.';
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
stateDir = 'missing';
|
|
126
|
+
verdict = 'discovered';
|
|
127
|
+
reason = 'pd_state_dir_not_initialized';
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// ── Cross-host ownership check (reuses findForeignWorkspaceOwner semantics) ──
|
|
131
|
+
// `findForeignWorkspaceOwner(host, dir)` answers "does an authorized source
|
|
132
|
+
// claim `dir` for a host OTHER than `host`" — by SAME identity (legitimate
|
|
133
|
+
// multi-host sharing, §9.1.5) or by CONTAINMENT (this dir nesting inside
|
|
134
|
+
// another host's owned tree — the PRI-1247 misbinding shape). Judging it
|
|
135
|
+
// from the perspective of EVERY MCP binding host (the union of all hosts)
|
|
136
|
+
// is wrong (P1-5): a same-host parent/child pair — OpenClaw's payload
|
|
137
|
+
// binding `<root>/team` nested inside its own default `<root>` — shows up
|
|
138
|
+
// as foreign containment from a second host's perspective even though
|
|
139
|
+
// OpenClaw owns both. Judge from the perspectives of THIS workspace's own
|
|
140
|
+
// claiming hosts instead; a containment hit then proves the containing
|
|
141
|
+
// tree belongs to a host the workspace does NOT claim — a real foreign
|
|
142
|
+
// owner. A manifest-only workspace (no claiming hosts) keeps the
|
|
143
|
+
// conservative all-hosts union: an orphan must not skip the foreign scan.
|
|
144
|
+
const hosts = new Set(group.claimingHosts);
|
|
145
|
+
const containmentViolations = [];
|
|
146
|
+
const perspectives = group.claimingHosts.size > 0 ? [...group.claimingHosts] : [...MCP_BINDING_HOSTS];
|
|
147
|
+
for (const host of perspectives) {
|
|
148
|
+
const verdictForHost = findForeignWorkspaceOwner(host, canonicalDir, claimOptions);
|
|
149
|
+
for (const claim of verdictForHost.claims) {
|
|
150
|
+
const same = identityForm(claim.workspaceDir, platform, probes.realpath)
|
|
151
|
+
=== identityForm(canonicalDir, platform, probes.realpath);
|
|
152
|
+
if (same) {
|
|
153
|
+
hosts.add(claim.host);
|
|
154
|
+
}
|
|
155
|
+
else if (!group.claimingHosts.has(claim.host)) {
|
|
156
|
+
containmentViolations.push(`${claim.host}:${claim.via}:${bounded(claim.workspaceDir, 160)}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (owner.source === 'conflicting') {
|
|
161
|
+
// Two aliases of ONE real workspace carry disagreeing owner records —
|
|
162
|
+
// an explicit invalid state, never a silently-picked alias (P1-6).
|
|
163
|
+
return {
|
|
164
|
+
canonicalDir,
|
|
165
|
+
verdict: 'conflicting',
|
|
166
|
+
hosts: [...hosts].sort(),
|
|
167
|
+
sources: group.sources,
|
|
168
|
+
owner,
|
|
169
|
+
checks: {
|
|
170
|
+
directory,
|
|
171
|
+
stateDir,
|
|
172
|
+
realpathResolved: probes.realpath(canonicalDir) !== undefined,
|
|
173
|
+
},
|
|
174
|
+
reason: `workspace_owner_alias_conflict:${bounded(owner.conflictDetail ?? 'conflict', 240)}`,
|
|
175
|
+
nextAction: 'The workspace is listed under several path aliases whose backgroundExecutions records disagree. Reconcile install.json so the workspace has one owner record; PD will not serve it until then.',
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (containmentViolations.length > 0) {
|
|
179
|
+
// Containment violations outrank everything else — a workspace inside
|
|
180
|
+
// another host's owned tree must never be treated as executable (fail-closed).
|
|
181
|
+
return {
|
|
182
|
+
canonicalDir,
|
|
183
|
+
verdict: 'conflicting',
|
|
184
|
+
hosts: [...hosts].sort(),
|
|
185
|
+
sources: group.sources,
|
|
186
|
+
owner,
|
|
187
|
+
checks: {
|
|
188
|
+
directory,
|
|
189
|
+
stateDir,
|
|
190
|
+
realpathResolved: probes.realpath(canonicalDir) !== undefined,
|
|
191
|
+
},
|
|
192
|
+
reason: `workspace_containment_conflict:${bounded(containmentViolations.join('|'), 240)}`,
|
|
193
|
+
nextAction: 'The workspace path sits inside another host\'s owned tree (PRI-1247 misbinding). Fix the binding/declaration; the workspace will not be served until then.',
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const realpathResolved = probes.realpath(canonicalDir) !== undefined;
|
|
197
|
+
const base = {
|
|
198
|
+
canonicalDir,
|
|
199
|
+
hosts: [...hosts].sort(),
|
|
200
|
+
sources: group.sources,
|
|
201
|
+
owner,
|
|
202
|
+
checks: { directory, stateDir, realpathResolved },
|
|
203
|
+
};
|
|
204
|
+
if (verdict === 'authorized')
|
|
205
|
+
return { ...base, verdict };
|
|
206
|
+
return { ...base, verdict, ...(reason !== undefined ? { reason } : {}), ...(nextAction !== undefined ? { nextAction } : {}) };
|
|
207
|
+
}
|
|
208
|
+
function validateGroup(group, ctx) {
|
|
209
|
+
// Display identity prefers the realpath form (§9.1.6); every manifest alias
|
|
210
|
+
// stays in sources and ALL of them drive the owner-record lookup.
|
|
211
|
+
const ownerLookupDirs = group.manifestForms.length > 0 ? group.manifestForms : [group.canonicalDir];
|
|
212
|
+
const paths = { canonicalDir: group.canonicalDir, manifestForms: ownerLookupDirs };
|
|
213
|
+
try {
|
|
214
|
+
return validateGroupInner(group, paths, ctx);
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
// One workspace's validation must never block the others (FR-07).
|
|
218
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
219
|
+
return {
|
|
220
|
+
canonicalDir: paths.canonicalDir,
|
|
221
|
+
verdict: 'invalid',
|
|
222
|
+
hosts: [...group.claimingHosts].sort(),
|
|
223
|
+
sources: group.sources,
|
|
224
|
+
owner: projectWorkspaceOwnerAliases(ctx.manifest, ownerLookupDirs, ctx.platform),
|
|
225
|
+
checks: {
|
|
226
|
+
directory: 'unchecked',
|
|
227
|
+
stateDir: 'unchecked',
|
|
228
|
+
realpathResolved: false,
|
|
229
|
+
},
|
|
230
|
+
reason: `discovery_validation_error:${bounded(message, 200)}`,
|
|
231
|
+
nextAction: 'Re-run `pd service run-once --dry-run` after repairing the workspace path; other workspaces were still processed.',
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
export function discoverWorkspaces(input) {
|
|
236
|
+
const { platform } = input.claimOptions;
|
|
237
|
+
const probes = input.probes === undefined ? defaultDiscoveryProbes() : input.probes;
|
|
238
|
+
// ── Group every authorized-source listing by realpath identity ──────────
|
|
239
|
+
const groups = new Map();
|
|
240
|
+
const groupOf = (canonical) => {
|
|
241
|
+
const key = identityForm(canonical, platform, probes.realpath);
|
|
242
|
+
let entry = groups.get(key);
|
|
243
|
+
if (entry === undefined) {
|
|
244
|
+
const resolved = path.resolve(canonical);
|
|
245
|
+
const real = probes.realpath(resolved);
|
|
246
|
+
entry = {
|
|
247
|
+
canonicalDir: real ?? resolved,
|
|
248
|
+
manifestForms: [],
|
|
249
|
+
sources: [],
|
|
250
|
+
claimingHosts: new Set(),
|
|
251
|
+
};
|
|
252
|
+
groups.set(key, entry);
|
|
253
|
+
}
|
|
254
|
+
return entry;
|
|
255
|
+
};
|
|
256
|
+
// Source B first: claims carry host attribution.
|
|
257
|
+
for (const claim of input.claims) {
|
|
258
|
+
const entry = groupOf(claim.workspaceDir);
|
|
259
|
+
entry.claimingHosts.add(claim.host);
|
|
260
|
+
entry.sources.push({ source: 'claim', host: claim.host, via: claim.via, path: claim.workspaceDir });
|
|
261
|
+
}
|
|
262
|
+
// Source A: every manifest alias of this real dir is kept — owner records
|
|
263
|
+
// are keyed by the parser's workspaces[] strings and may live under any
|
|
264
|
+
// alias (P1-6). Order is preserved for deterministic reporting.
|
|
265
|
+
for (const listed of input.manifest.workspaces ?? []) {
|
|
266
|
+
const entry = groupOf(listed);
|
|
267
|
+
if (!entry.manifestForms.includes(listed))
|
|
268
|
+
entry.manifestForms.push(listed);
|
|
269
|
+
entry.sources.push({ source: 'manifest', path: listed });
|
|
270
|
+
}
|
|
271
|
+
// ── Validate each unique workspace independently (FR-07 isolation) ──────
|
|
272
|
+
const entries = [];
|
|
273
|
+
for (const group of groups.values()) {
|
|
274
|
+
entries.push(validateGroup(group, { platform, probes, manifest: input.manifest, claimOptions: input.claimOptions }));
|
|
275
|
+
}
|
|
276
|
+
const counts = {
|
|
277
|
+
authorized: 0,
|
|
278
|
+
degraded: 0,
|
|
279
|
+
unavailable: 0,
|
|
280
|
+
conflicting: 0,
|
|
281
|
+
invalid: 0,
|
|
282
|
+
discovered: 0,
|
|
283
|
+
};
|
|
284
|
+
for (const entry of entries)
|
|
285
|
+
counts[entry.verdict] += 1;
|
|
286
|
+
return { workspaces: entries, discoveredTotal: entries.length, counts };
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=workspace-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-discovery.js","sourceRoot":"","sources":["../../../src/services/service-host/workspace-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,iBAAiB,EACjB,yBAAyB,GAK1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,4BAA4B,EAAwB,MAAM,uBAAuB,CAAC;AAE3F;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC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IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QACrD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5E,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,2EAA2E;IAC3E,MAAM,OAAO,GAA8B,EAAE,CAAC;IAC9C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;QACpC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACvH,CAAC;IACD,MAAM,MAAM,GAA8C;QACxD,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;QACX,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,CAAC;KACd,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,OAAO;QAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AdapterCycleResult, WorkerAdapter, WorkerHostKind, WorkspaceDescriptor, resolveActiveReleaseCliEntry } from './worker-adapter.js';
|
|
2
|
+
import type { ActiveReleaseFacts, ShadowExecutionRecord } from './status/service-run-status.js';
|
|
3
|
+
import type { InstallIdentity } from './install-identity.js';
|
|
4
|
+
import type { WorkerProcessOptions, WorkerProcessResult } from './worker-process.js';
|
|
5
|
+
export type AdapterDispatchOutcome = {
|
|
6
|
+
readonly kind: 'unsupported';
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'budget_exhausted';
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'executed';
|
|
11
|
+
readonly result: AdapterCycleResult;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'adapter_threw';
|
|
14
|
+
readonly sanitizedMessage: string;
|
|
15
|
+
};
|
|
16
|
+
export interface AdapterDispatchEntry {
|
|
17
|
+
readonly hostKind: WorkerHostKind;
|
|
18
|
+
readonly outcome: AdapterDispatchOutcome;
|
|
19
|
+
}
|
|
20
|
+
export interface DispatchWorkspaceAdaptersArgs {
|
|
21
|
+
readonly workspaceDir: string;
|
|
22
|
+
readonly descriptor: WorkspaceDescriptor;
|
|
23
|
+
/** Bound host kinds to try, in order (all bound adapters — no filter — in managed mode). */
|
|
24
|
+
readonly hostKinds: readonly WorkerHostKind[];
|
|
25
|
+
/** Whole-workspace budget in ms (serial adapters share it). */
|
|
26
|
+
readonly timeoutMs: number;
|
|
27
|
+
/**
|
|
28
|
+
* Adapters by host kind. PARTIAL on purpose (PRI-1282 Phase 4): the shadow
|
|
29
|
+
* coordinator supplies only the codex|workbuddy pair while managed mode
|
|
30
|
+
* supplies all three — a dispatched kind without a registered adapter is a
|
|
31
|
+
* truthful `unsupported` entry, never a crash.
|
|
32
|
+
*/
|
|
33
|
+
readonly adapters: Readonly<Partial<Record<WorkerHostKind, WorkerAdapter>>>;
|
|
34
|
+
readonly activeRelease: ActiveReleaseFacts;
|
|
35
|
+
readonly identity: InstallIdentity;
|
|
36
|
+
readonly inheritedEnv: Readonly<Record<string, string | undefined>>;
|
|
37
|
+
readonly signal?: AbortSignal;
|
|
38
|
+
readonly probes?: {
|
|
39
|
+
readonly spawnWorkerProcess?: (options: WorkerProcessOptions) => Promise<WorkerProcessResult>;
|
|
40
|
+
readonly resolveCliEntry?: typeof resolveActiveReleaseCliEntry;
|
|
41
|
+
readonly now?: () => Date;
|
|
42
|
+
};
|
|
43
|
+
/** Caller's abort predicate, checked before every dispatch. */
|
|
44
|
+
readonly isAborted: () => boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface WorkspaceDispatchResult {
|
|
47
|
+
/** Monotonic deadline that governed this workspace (evidence). */
|
|
48
|
+
readonly deadlineAtMs: number;
|
|
49
|
+
readonly entries: readonly AdapterDispatchEntry[];
|
|
50
|
+
}
|
|
51
|
+
export declare function dispatchWorkspaceAdapters(args: DispatchWorkspaceAdaptersArgs): Promise<WorkspaceDispatchResult>;
|
|
52
|
+
/** Map an adapter cycle outcome to the shared workspace-state vocabulary. */
|
|
53
|
+
export declare function workspaceStateFor(outcome: AdapterCycleResult['cycleOutcome']): ShadowExecutionRecord['workspaceState'];
|
|
54
|
+
/**
|
|
55
|
+
* Carry-forward rule (task §6 + F7 review fix): EVIDENCED task progress
|
|
56
|
+
* wins for ANY outcome; otherwise a cycle_completed run's cycle-evidence
|
|
57
|
+
* timestamp applies; otherwise the previous value is preserved. Never the
|
|
58
|
+
* completion time of an empty/failed cycle.
|
|
59
|
+
*/
|
|
60
|
+
export declare function carriedProgress(result: AdapterCycleResult, previous: string | undefined): Pick<ShadowExecutionRecord, 'lastProgressAt' | 'lastProgressSource'>;
|
|
61
|
+
//# sourceMappingURL=workspace-dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-dispatch.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/workspace-dispatch.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACpB,4BAA4B,EAAC,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC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AC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAC9F,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,4BAA4B,CAAC;QAC/D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;KAC3B,CAAC;IACF,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,kEAAkE;IAClE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACnD;AAED,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA8CrH;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,CAAC,cAAc,CAAC,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAgBtH;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,GAAG,oBAAoB,CAAC,CAgBtE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared per-workspace Worker Adapter dispatch — the ONE implementation of
|
|
3
|
+
* the bounded adapter loop used by BOTH the Phase 2 shadow coordinator and
|
|
4
|
+
* the Phase 3 managed run (PRI-1281). Extracted from shadow-run so the
|
|
5
|
+
* deadline / abort / admission sequencing cannot drift between modes:
|
|
6
|
+
*
|
|
7
|
+
* - one MONOTONIC per-workspace budget shared by serially bound adapters;
|
|
8
|
+
* - an abort check before EVERY dispatch (an interrupt stops the queue, not
|
|
9
|
+
* just the in-flight worker);
|
|
10
|
+
* - a not-supported adapter is not an error (other hosts may still run);
|
|
11
|
+
* - an adapter throw is isolated to this workspace (FR-07).
|
|
12
|
+
*/
|
|
13
|
+
import { randomUUID } from 'node:crypto';
|
|
14
|
+
import { sanitizeWorkerText } from './worker-adapter.js';
|
|
15
|
+
export async function dispatchWorkspaceAdapters(args) {
|
|
16
|
+
const deadlineAtMs = performance.now() + args.timeoutMs;
|
|
17
|
+
const entries = [];
|
|
18
|
+
for (const hostKind of args.hostKinds) {
|
|
19
|
+
if (args.isAborted())
|
|
20
|
+
break;
|
|
21
|
+
const adapter = args.adapters[hostKind];
|
|
22
|
+
if (adapter === undefined) {
|
|
23
|
+
entries.push({ hostKind, outcome: { kind: 'unsupported' } });
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const support = adapter.supports(args.descriptor);
|
|
27
|
+
if (!support.supported) {
|
|
28
|
+
entries.push({ hostKind, outcome: { kind: 'unsupported' } });
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const remainingMs = deadlineAtMs - performance.now();
|
|
32
|
+
if (remainingMs <= 0) {
|
|
33
|
+
// Budget exhausted by an earlier adapter on this workspace — record the
|
|
34
|
+
// timeout truthfully instead of starting another Worker.
|
|
35
|
+
entries.push({ hostKind, outcome: { kind: 'budget_exhausted' } });
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const result = await adapter.executeOnce({
|
|
40
|
+
workspaceDir: args.workspaceDir,
|
|
41
|
+
activeRelease: args.activeRelease,
|
|
42
|
+
invocationId: randomUUID(),
|
|
43
|
+
timeoutMs: remainingMs,
|
|
44
|
+
deadlineAtMs,
|
|
45
|
+
...(args.signal !== undefined ? { signal: args.signal } : {}),
|
|
46
|
+
identity: args.identity,
|
|
47
|
+
inheritedEnv: args.inheritedEnv,
|
|
48
|
+
probes: {
|
|
49
|
+
...(args.probes?.spawnWorkerProcess !== undefined ? { spawnWorkerProcess: args.probes.spawnWorkerProcess } : {}),
|
|
50
|
+
...(args.probes?.resolveCliEntry !== undefined ? { resolveCliEntry: args.probes.resolveCliEntry } : {}),
|
|
51
|
+
...(args.probes?.now !== undefined ? { now: args.probes.now } : {}),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
entries.push({ hostKind, outcome: { kind: 'executed', result } });
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
// An adapter must never take down the whole run (FR-07).
|
|
58
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
59
|
+
entries.push({ hostKind, outcome: { kind: 'adapter_threw', sanitizedMessage: sanitizeWorkerText(message, 160) } });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return { deadlineAtMs, entries };
|
|
63
|
+
}
|
|
64
|
+
/** Map an adapter cycle outcome to the shared workspace-state vocabulary. */
|
|
65
|
+
export function workspaceStateFor(outcome) {
|
|
66
|
+
switch (outcome) {
|
|
67
|
+
case 'cycle_completed':
|
|
68
|
+
case 'cycle_completed_without_business_progress':
|
|
69
|
+
return 'completed';
|
|
70
|
+
case 'paused':
|
|
71
|
+
return 'paused';
|
|
72
|
+
case 'degraded':
|
|
73
|
+
return 'degraded';
|
|
74
|
+
case 'failed':
|
|
75
|
+
case 'timeout':
|
|
76
|
+
case 'cancelled':
|
|
77
|
+
return 'failed';
|
|
78
|
+
default:
|
|
79
|
+
return 'unavailable';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Carry-forward rule (task §6 + F7 review fix): EVIDENCED task progress
|
|
84
|
+
* wins for ANY outcome; otherwise a cycle_completed run's cycle-evidence
|
|
85
|
+
* timestamp applies; otherwise the previous value is preserved. Never the
|
|
86
|
+
* completion time of an empty/failed cycle.
|
|
87
|
+
*/
|
|
88
|
+
export function carriedProgress(result, previous) {
|
|
89
|
+
if (result.businessProgress.taskStateChanged && result.lastProgressAt !== null) {
|
|
90
|
+
return { lastProgressAt: result.lastProgressAt, lastProgressSource: 'task_state_change' };
|
|
91
|
+
}
|
|
92
|
+
// P2-02 (final-remediation review): a non-null lastProgressAt is real
|
|
93
|
+
// evidenced progress for ANY outcome — a paused/degraded cycle that
|
|
94
|
+
// persisted catch-up/downstream work keeps its timestamp too.
|
|
95
|
+
if (result.cycleOutcome === 'cycle_completed' || result.lastProgressAt !== null) {
|
|
96
|
+
return {
|
|
97
|
+
lastProgressAt: result.lastProgressAt ?? previous ?? null,
|
|
98
|
+
lastProgressSource: result.lastProgressAt !== null ? 'cycle_evidence' : previous !== undefined ? 'previous_run' : null,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// No business progress this cycle (empty cycle, pause, failure, kill):
|
|
102
|
+
// keep the last known truthful value — never the cycle completion time.
|
|
103
|
+
return { lastProgressAt: previous ?? null, lastProgressSource: previous !== undefined ? 'previous_run' : null };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=workspace-dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-dispatch.js","sourceRoot":"","sources":["../../../src/services/service-host/workspace-dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAiDzD,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,IAAmC;IACjF,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;IACxD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,SAAS,EAAE;YAAE,MAAM;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B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