refactor(mcp): make analysis states unrepresentable (#468)
* refactor(config): parse capability settings into exact states * refactor(runtime): encode replay and process outcomes exactly * refactor: make analysis states unrepresentable * refactor(mcp): register canonical schemas with SDK * fix: preserve capability and catalog invariants * fix(build): remove stale compiled modules * fix(replay): update real verifier policy dependency * fix(package): verify the complete MCP catalog * fix(test): supply complete replay reload policy * refactor(contracts): centralize output schema lookup * refactor(mcp): delegate protocol boundaries to SDK * fix(browser): approve real source capture * fix(mcp): preserve catalog guidance
This commit is contained in:
@@ -186,8 +186,10 @@ const systemHost: ProcessOwnershipHost = {
|
||||
const environment: Record<string, string> = {};
|
||||
for (const match of stdout.matchAll(
|
||||
/(?:^|\s)([A-Za-z_][A-Za-z0-9_]*)=([^\s]*)/gu,
|
||||
))
|
||||
environment[match[1]!] = match[2] ?? "";
|
||||
)) {
|
||||
const name = match[1];
|
||||
if (name !== undefined) environment[name] = match[2] ?? "";
|
||||
}
|
||||
return environment;
|
||||
},
|
||||
signalGroup(processGroupId, signal) {
|
||||
|
||||
@@ -34,8 +34,7 @@ export class ProviderStartupDeadline {
|
||||
readonly #externalSignal: AbortSignal | undefined;
|
||||
readonly #onExternalAbort: () => void;
|
||||
#timer: NodeJS.Timeout | undefined;
|
||||
#timedOut = false;
|
||||
#cancelled = false;
|
||||
#interruption: "cancelled" | "timeout" | undefined;
|
||||
|
||||
constructor(
|
||||
readonly timeoutMs: number,
|
||||
@@ -48,13 +47,13 @@ export class ProviderStartupDeadline {
|
||||
this.#onExternalAbort = () => {
|
||||
if (this.#controller.signal.aborted) return;
|
||||
if (Date.now() >= this.#deadlineAt) {
|
||||
this.#timedOut = true;
|
||||
this.#interruption = "timeout";
|
||||
this.#abort(
|
||||
new DOMException("Provider startup deadline elapsed", "TimeoutError"),
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.#cancelled = true;
|
||||
this.#interruption = "cancelled";
|
||||
this.#abort(signal?.reason);
|
||||
};
|
||||
if (signal?.aborted === true) {
|
||||
@@ -64,7 +63,7 @@ export class ProviderStartupDeadline {
|
||||
signal?.addEventListener("abort", this.#onExternalAbort, { once: true });
|
||||
this.#timer = setTimeout(() => {
|
||||
if (this.#controller.signal.aborted) return;
|
||||
this.#timedOut = true;
|
||||
this.#interruption = "timeout";
|
||||
this.#abort(
|
||||
new DOMException("Provider startup deadline elapsed", "TimeoutError"),
|
||||
);
|
||||
@@ -76,15 +75,11 @@ export class ProviderStartupDeadline {
|
||||
return this.#controller.signal;
|
||||
}
|
||||
|
||||
/** True only when the external caller signal initiated cancellation. */
|
||||
get cancelled(): boolean {
|
||||
return this.#cancelled;
|
||||
}
|
||||
|
||||
/** True when the absolute startup deadline has elapsed. */
|
||||
get timedOut(): boolean {
|
||||
/** First control path that interrupted startup, if any. */
|
||||
get interruption(): "cancelled" | "timeout" | undefined {
|
||||
return (
|
||||
this.#timedOut || (!this.#cancelled && Date.now() >= this.#deadlineAt)
|
||||
this.#interruption ??
|
||||
(Date.now() >= this.#deadlineAt ? "timeout" : undefined)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,19 @@ export interface SpawnedOwnedProviderProcess {
|
||||
}
|
||||
|
||||
/** Process handle returned by a provider-specific launcher. */
|
||||
export interface ProviderProcessLaunch {
|
||||
readonly process: ChildProcess;
|
||||
readonly ownsProcessLifetime: boolean;
|
||||
readonly ownership?: OwnedProcessGroup;
|
||||
readonly cleanup?: () => Promise<ProcessCleanupResult>;
|
||||
}
|
||||
export type ProviderProcessLaunch =
|
||||
| {
|
||||
readonly process: ChildProcess;
|
||||
readonly ownsProcessLifetime: false;
|
||||
readonly ownership?: never;
|
||||
readonly cleanup?: never;
|
||||
}
|
||||
| {
|
||||
readonly process: ChildProcess;
|
||||
readonly ownsProcessLifetime: true;
|
||||
readonly ownership?: OwnedProcessGroup;
|
||||
readonly cleanup?: () => Promise<ProcessCleanupResult>;
|
||||
};
|
||||
|
||||
/** Detached diagnostics captured for one supervised provider process. */
|
||||
export interface ProviderProcessSnapshot {
|
||||
|
||||
Reference in New Issue
Block a user