@dailephd/my-centcom 0.1.0 → 0.3.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/README.md +10 -5
- package/apps/daemon/dist/artifacts/returnSnapshots.d.ts +12 -0
- package/apps/daemon/dist/artifacts/returnSnapshots.js +41 -0
- package/apps/daemon/dist/bootstrap/app.d.ts +21 -0
- package/apps/daemon/dist/bootstrap/app.js +27 -0
- package/apps/daemon/dist/bootstrap/installLayout.d.ts +81 -0
- package/apps/daemon/dist/bootstrap/installLayout.js +164 -0
- package/apps/daemon/dist/bootstrap/main.d.ts +14 -0
- package/apps/daemon/dist/bootstrap/main.js +141 -0
- package/apps/daemon/dist/bootstrap/operatorConsole.d.ts +75 -0
- package/apps/daemon/dist/bootstrap/operatorConsole.js +293 -0
- package/apps/daemon/dist/bootstrap/privateDataRoot.d.ts +38 -0
- package/apps/daemon/dist/bootstrap/privateDataRoot.js +204 -0
- package/apps/daemon/dist/bootstrap/secureMain.d.ts +118 -0
- package/apps/daemon/dist/bootstrap/secureMain.js +403 -0
- package/apps/daemon/dist/bootstrap/setup.d.ts +93 -0
- package/apps/daemon/dist/bootstrap/setup.js +738 -0
- package/apps/daemon/dist/context/changeProposal.d.ts +97 -0
- package/apps/daemon/dist/context/changeProposal.js +259 -0
- package/apps/daemon/dist/context/gitEvidence.d.ts +88 -0
- package/apps/daemon/dist/context/gitEvidence.js +332 -0
- package/apps/daemon/dist/context/gitObservation.d.ts +30 -0
- package/apps/daemon/dist/context/gitObservation.js +113 -0
- package/apps/daemon/dist/context/projectReadIssuer.d.ts +68 -0
- package/apps/daemon/dist/context/projectReadIssuer.js +158 -0
- package/apps/daemon/dist/context/projectReadService.d.ts +153 -0
- package/apps/daemon/dist/context/projectReadService.js +652 -0
- package/apps/daemon/dist/context/projectViewService.d.ts +85 -0
- package/apps/daemon/dist/context/projectViewService.js +332 -0
- package/apps/daemon/dist/context/proposalRecorder.d.ts +11 -0
- package/apps/daemon/dist/context/proposalRecorder.js +19 -0
- package/apps/daemon/dist/plugins/drivers/codexMcpConfig.d.ts +40 -0
- package/apps/daemon/dist/plugins/drivers/codexMcpConfig.js +73 -0
- package/apps/daemon/dist/plugins/drivers/codexModelCompatibility.d.ts +49 -0
- package/apps/daemon/dist/plugins/drivers/codexModelCompatibility.js +70 -0
- package/apps/daemon/dist/plugins/drivers/fakePluginDriver.d.ts +16 -0
- package/apps/daemon/dist/plugins/drivers/fakePluginDriver.js +115 -0
- package/apps/daemon/dist/plugins/drivers/finiteCliDriver.d.ts +153 -0
- package/apps/daemon/dist/plugins/drivers/finiteCliDriver.js +505 -0
- package/apps/daemon/dist/plugins/registry/operationCatalog.d.ts +23 -0
- package/apps/daemon/dist/plugins/registry/operationCatalog.js +41 -0
- package/apps/daemon/dist/plugins/registry/registryOperationCatalog.d.ts +14 -0
- package/apps/daemon/dist/plugins/registry/registryOperationCatalog.js +29 -0
- package/apps/daemon/dist/plugins/registry/verifiedCapabilityRegistry.d.ts +151 -0
- package/apps/daemon/dist/plugins/registry/verifiedCapabilityRegistry.js +579 -0
- package/apps/daemon/dist/projects/codingAuthority.d.ts +102 -0
- package/apps/daemon/dist/projects/codingAuthority.js +244 -0
- package/apps/daemon/dist/projects/fixtureAuthorization.d.ts +54 -0
- package/apps/daemon/dist/projects/fixtureAuthorization.js +172 -0
- package/apps/daemon/dist/projects/pairedAuthority.d.ts +158 -0
- package/apps/daemon/dist/projects/pairedAuthority.js +273 -0
- package/apps/daemon/dist/projects/trustedCliConsent.d.ts +47 -0
- package/apps/daemon/dist/projects/trustedCliConsent.js +84 -0
- package/apps/daemon/dist/runs/changeApplier.d.ts +59 -0
- package/apps/daemon/dist/runs/changeApplier.js +319 -0
- package/apps/daemon/dist/runs/codingWorkflowService.d.ts +283 -0
- package/apps/daemon/dist/runs/codingWorkflowService.js +785 -0
- package/apps/daemon/dist/runs/durableIntentCoordinator.d.ts +72 -0
- package/apps/daemon/dist/runs/durableIntentCoordinator.js +160 -0
- package/apps/daemon/dist/runs/inMemoryCoordinator.d.ts +55 -0
- package/apps/daemon/dist/runs/inMemoryCoordinator.js +375 -0
- package/apps/daemon/dist/runs/runExecutor.d.ts +154 -0
- package/apps/daemon/dist/runs/runExecutor.js +295 -0
- package/apps/daemon/dist/runs/workflowService.d.ts +185 -0
- package/apps/daemon/dist/runs/workflowService.js +300 -0
- package/apps/daemon/dist/runtime/boundedProcessHost.d.ts +111 -0
- package/apps/daemon/dist/runtime/boundedProcessHost.js +752 -0
- package/apps/daemon/dist/runtime/evidenceRedaction.d.ts +30 -0
- package/apps/daemon/dist/runtime/evidenceRedaction.js +79 -0
- package/apps/daemon/dist/runtime/executionDiagnostics.d.ts +134 -0
- package/apps/daemon/dist/runtime/executionDiagnostics.js +213 -0
- package/apps/daemon/dist/runtime/modelExecutionPolicy.d.ts +22 -0
- package/apps/daemon/dist/runtime/modelExecutionPolicy.js +19 -0
- package/apps/daemon/dist/runtime/mxcExecution.d.ts +12 -0
- package/apps/daemon/dist/runtime/mxcExecution.js +163 -0
- package/apps/daemon/dist/runtime/mxcIntegrity.d.ts +24 -0
- package/apps/daemon/dist/runtime/mxcIntegrity.js +81 -0
- package/apps/daemon/dist/runtime/mxcWorker.d.ts +2 -0
- package/apps/daemon/dist/runtime/mxcWorker.js +45 -0
- package/apps/daemon/dist/runtime/provisionedExecution.d.ts +150 -0
- package/apps/daemon/dist/runtime/provisionedExecution.js +653 -0
- package/apps/daemon/dist/runtime/testExecution.d.ts +76 -0
- package/apps/daemon/dist/runtime/testExecution.js +106 -0
- package/apps/daemon/dist/runtime/testProfiles.d.ts +10 -0
- package/apps/daemon/dist/runtime/testProfiles.js +4 -0
- package/apps/daemon/dist/runtime/trustedAgentStaging.d.ts +89 -0
- package/apps/daemon/dist/runtime/trustedAgentStaging.js +262 -0
- package/apps/daemon/dist/runtime/trustedCaBundle.d.ts +77 -0
- package/apps/daemon/dist/runtime/trustedCaBundle.js +125 -0
- package/apps/daemon/dist/runtime/windows/windowsJobSupervisor.d.ts +166 -0
- package/apps/daemon/dist/runtime/windows/windowsJobSupervisor.js +521 -0
- package/apps/daemon/dist/storage/diagnosticLog.d.ts +63 -0
- package/apps/daemon/dist/storage/diagnosticLog.js +136 -0
- package/apps/daemon/dist/storage/executionTelemetry.d.ts +63 -0
- package/apps/daemon/dist/storage/executionTelemetry.js +247 -0
- package/apps/daemon/dist/storage/protectedSecrets.d.ts +39 -0
- package/apps/daemon/dist/storage/protectedSecrets.js +106 -0
- package/apps/daemon/dist/storage/sqliteLedger.d.ts +786 -0
- package/apps/daemon/dist/storage/sqliteLedger.js +1303 -0
- package/apps/daemon/dist/transports/http/dispatch.d.ts +43 -0
- package/apps/daemon/dist/transports/http/dispatch.js +405 -0
- package/apps/daemon/dist/transports/http/secureRoutes.d.ts +40 -0
- package/apps/daemon/dist/transports/http/secureRoutes.js +332 -0
- package/apps/daemon/dist/transports/http/workflowRoutes.d.ts +41 -0
- package/apps/daemon/dist/transports/http/workflowRoutes.js +473 -0
- package/apps/daemon/dist/transports/mcp/localProjectReadServer.d.ts +182 -0
- package/apps/daemon/dist/transports/mcp/localProjectReadServer.js +221 -0
- package/apps/daemon/dist/transports/native/nativeHost.d.ts +24 -0
- package/apps/daemon/dist/transports/native/nativeHost.js +344 -0
- package/apps/daemon/package.json +24 -0
- package/apps/daemon/src/runtime/benign/referenceEcho.mjs +27 -0
- package/apps/daemon/src/runtime/windows/buildSupervisor.mjs +87 -0
- package/apps/daemon/src/runtime/windows/supervisorMain.cs +676 -0
- package/apps/extension/manifest.secure.json +25 -0
- package/apps/extension/scripts/build.mjs +173 -0
- package/apps/extension/src/background/secureWorker.ts +1595 -0
- package/apps/extension/src/background/serviceWorker.ts +892 -0
- package/apps/extension/src/content/captureSelection.ts +64 -0
- package/apps/extension/src/content/secureInsert.ts +207 -0
- package/apps/extension/src/probe/index.html +41 -0
- package/apps/extension/src/probe/main.ts +201 -0
- package/apps/extension/src/sidepanel/index.html +203 -0
- package/apps/extension/src/sidepanel/main.ts +903 -0
- package/package.json +19 -3
- package/packages/contracts/dist/artifacts.d.ts +66 -0
- package/packages/contracts/dist/artifacts.js +64 -0
- package/packages/contracts/dist/automation.d.ts +540 -0
- package/packages/contracts/dist/automation.js +191 -0
- package/packages/contracts/dist/browser.d.ts +251 -0
- package/packages/contracts/dist/browser.js +131 -0
- package/packages/contracts/dist/context.d.ts +71 -0
- package/packages/contracts/dist/context.js +73 -0
- package/packages/contracts/dist/diagnostics.d.ts +99 -0
- package/packages/contracts/dist/diagnostics.js +284 -0
- package/packages/contracts/dist/effects.d.ts +42 -0
- package/packages/contracts/dist/effects.js +42 -0
- package/packages/contracts/dist/errors.d.ts +75 -0
- package/packages/contracts/dist/errors.js +70 -0
- package/packages/contracts/dist/events.d.ts +50 -0
- package/packages/contracts/dist/events.js +34 -0
- package/packages/contracts/dist/executionDiagnostics.d.ts +212 -0
- package/packages/contracts/dist/executionDiagnostics.js +101 -0
- package/packages/contracts/dist/identity.d.ts +54 -0
- package/packages/contracts/dist/identity.js +40 -0
- package/packages/contracts/dist/index.d.ts +20 -0
- package/packages/contracts/dist/index.js +20 -0
- package/packages/contracts/dist/invocation.d.ts +90 -0
- package/packages/contracts/dist/invocation.js +77 -0
- package/packages/contracts/dist/lifecycle.d.ts +130 -0
- package/packages/contracts/dist/lifecycle.js +135 -0
- package/packages/contracts/dist/plugin.d.ts +214 -0
- package/packages/contracts/dist/plugin.js +117 -0
- package/packages/contracts/dist/projectRead.d.ts +205 -0
- package/packages/contracts/dist/projectRead.js +162 -0
- package/packages/contracts/dist/secure.d.ts +128 -0
- package/packages/contracts/dist/secure.js +99 -0
- package/packages/contracts/package.json +32 -0
- package/packages/contracts/src/artifacts.ts +83 -0
- package/packages/contracts/src/automation.ts +238 -0
- package/packages/contracts/src/browser.ts +164 -0
- package/packages/contracts/src/context.ts +91 -0
- package/packages/contracts/src/diagnostics.ts +318 -0
- package/packages/contracts/src/effects.ts +49 -0
- package/packages/contracts/src/errors.ts +83 -0
- package/packages/contracts/src/events.ts +46 -0
- package/packages/contracts/src/executionDiagnostics.ts +116 -0
- package/packages/contracts/src/identity.ts +68 -0
- package/packages/contracts/src/index.ts +20 -0
- package/packages/contracts/src/invocation.ts +96 -0
- package/packages/contracts/src/lifecycle.ts +169 -0
- package/packages/contracts/src/plugin.ts +174 -0
- package/packages/contracts/src/projectRead.ts +179 -0
- package/packages/contracts/src/secure.ts +136 -0
- package/provenance.json +179 -9
- package/source.zip +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C06 evidence redaction (SW-068). Everything that reaches the execution-evidence store passes through here FIRST; nothing raw is ever stored.
|
|
3
|
+
*
|
|
4
|
+
* Rules (all deterministic, all tested with deliberately embedded secrets):
|
|
5
|
+
* - credentials: Bearer/Basic tokens, Authorization/Cookie header values, JWTs, sk-/ghp_/xox*-style keys, key=value pairs whose key names a secret, URL userinfo, query strings;
|
|
6
|
+
* - any opaque run of 32+ token characters (hex, base64, base64url) -> [MASKED];
|
|
7
|
+
* - personal data: e-mail addresses, the user name inside Windows profile paths;
|
|
8
|
+
* - private content: lines of the approved PROMPT (12+ characters) are replaced wherever they re-appear, and the TEXT of structured model output (agent_message, command
|
|
9
|
+
* output, deltas) is never stored - only its length (the output itself lives in the immutable return snapshot);
|
|
10
|
+
* - every stored line is bounded (EVIDENCE_LIMITS.maxLineChars); cutting is reported as truncated.
|
|
11
|
+
*/
|
|
12
|
+
export declare function redactText(raw: string, o?: {
|
|
13
|
+
promptLines?: readonly string[];
|
|
14
|
+
max?: number;
|
|
15
|
+
}): {
|
|
16
|
+
text: string;
|
|
17
|
+
truncated: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Summarizes ONE stdout line. A JSON frame keeps its structure and diagnostics but never its content; anything else is redacted text. */
|
|
20
|
+
export declare function summarizeStdoutLine(line: string, o?: {
|
|
21
|
+
promptLines?: readonly string[];
|
|
22
|
+
}): {
|
|
23
|
+
text: string;
|
|
24
|
+
truncated: boolean;
|
|
25
|
+
parsedJson: boolean;
|
|
26
|
+
jsonInvalid: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** The non-empty lines (12+ chars) of an approved prompt, for echo masking. Bounded. */
|
|
29
|
+
export declare function promptLinesOf(prompt: string): string[];
|
|
30
|
+
//# sourceMappingURL=evidenceRedaction.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C06 evidence redaction (SW-068). Everything that reaches the execution-evidence store passes through here FIRST; nothing raw is ever stored.
|
|
3
|
+
*
|
|
4
|
+
* Rules (all deterministic, all tested with deliberately embedded secrets):
|
|
5
|
+
* - credentials: Bearer/Basic tokens, Authorization/Cookie header values, JWTs, sk-/ghp_/xox*-style keys, key=value pairs whose key names a secret, URL userinfo, query strings;
|
|
6
|
+
* - any opaque run of 32+ token characters (hex, base64, base64url) -> [MASKED];
|
|
7
|
+
* - personal data: e-mail addresses, the user name inside Windows profile paths;
|
|
8
|
+
* - private content: lines of the approved PROMPT (12+ characters) are replaced wherever they re-appear, and the TEXT of structured model output (agent_message, command
|
|
9
|
+
* output, deltas) is never stored - only its length (the output itself lives in the immutable return snapshot);
|
|
10
|
+
* - every stored line is bounded (EVIDENCE_LIMITS.maxLineChars); cutting is reported as truncated.
|
|
11
|
+
*/
|
|
12
|
+
import { EVIDENCE_LIMITS } from '../../../../packages/contracts/dist/index.js';
|
|
13
|
+
const OPAQUE = /[A-Za-z0-9+/_=-]{32,}/g;
|
|
14
|
+
const SECRET_KEY = /((?:api[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|auth(?:orization)?|token|secret|password|passwd|cookie|session(?:[_-]?id)?|bearer)["']?\s*[:=]\s*["']?)([^\s"',;&]+)/gi;
|
|
15
|
+
/** Output-bearing JSON keys: their string values are model/tool OUTPUT, never diagnostics. */
|
|
16
|
+
const CONTENT_KEYS = new Set(['text', 'content', 'output', 'aggregated_output', 'delta', 'stdout', 'stderr', 'diff', 'patch', 'command', 'arguments', 'input', 'prompt', 'reasoning']);
|
|
17
|
+
/** Keys whose value IS the diagnostic message and so is kept (redacted). */
|
|
18
|
+
const MESSAGE_KEYS = new Set(['message', 'error', 'detail', 'reason', 'status', 'code', 'type', 'kind', 'name', 'phase']);
|
|
19
|
+
export function redactText(raw, o = {}) {
|
|
20
|
+
const max = o.max ?? EVIDENCE_LIMITS.maxLineChars;
|
|
21
|
+
let t = Array.from(String(raw)).map((ch) => { const c = ch.charCodeAt(0); return c < 32 && c !== 9 || c === 127 ? ' ' : ch; }).join('');
|
|
22
|
+
for (const line of o.promptLines ?? [])
|
|
23
|
+
if (line.length >= 12)
|
|
24
|
+
t = t.split(line).join('[PROMPT_TEXT]');
|
|
25
|
+
t = t
|
|
26
|
+
.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi, '$1 [MASKED]')
|
|
27
|
+
.replace(/\b(Authorization|Proxy-Authorization|Cookie|Set-Cookie|X-Api-Key)\s*:\s*(?:(?:Bearer|Basic|Token)\s+)?[^\s,;]+/gi, '$1: [MASKED]')
|
|
28
|
+
.replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]*/g, '[MASKED_JWT]')
|
|
29
|
+
.replace(/\b(?:sk|pk|rk|ghp|gho|ghu|ghs|xox[abprs]|AKIA)[-_A-Za-z0-9]{12,}/g, '[MASKED_KEY]')
|
|
30
|
+
.replace(SECRET_KEY, (_m, k) => `${k}[MASKED]`)
|
|
31
|
+
.replace(/(\b[a-z][a-z0-9+.-]*:\/\/)[^\s/@]+@/gi, '$1[USERINFO]@')
|
|
32
|
+
.replace(/(\bhttps?:\/\/[^\s?"']+)\?[^\s"']*/gi, '$1?[QUERY]')
|
|
33
|
+
.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g, '[EMAIL]')
|
|
34
|
+
.replace(/([A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s"']+/gi, '$1[USER]')
|
|
35
|
+
.replace(OPAQUE, '[MASKED]')
|
|
36
|
+
.replace(/\s+/g, ' ')
|
|
37
|
+
.trim();
|
|
38
|
+
return t.length > max ? { text: t.slice(0, max), truncated: true } : { text: t, truncated: false };
|
|
39
|
+
}
|
|
40
|
+
/** Summarizes ONE stdout line. A JSON frame keeps its structure and diagnostics but never its content; anything else is redacted text. */
|
|
41
|
+
export function summarizeStdoutLine(line, o = {}) {
|
|
42
|
+
const trimmed = line.trim();
|
|
43
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
44
|
+
try {
|
|
45
|
+
const v = JSON.parse(trimmed);
|
|
46
|
+
const walk = (x, key, depth) => {
|
|
47
|
+
if (typeof x === 'string') {
|
|
48
|
+
if (CONTENT_KEYS.has(key) && !MESSAGE_KEYS.has(key))
|
|
49
|
+
return `[OMITTED ${x.length} chars]`;
|
|
50
|
+
return redactText(x, { ...o, max: 300 }).text;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(x))
|
|
53
|
+
return depth > 4 ? '[DEEP]' : x.slice(0, 8).map((y) => walk(y, key, depth + 1));
|
|
54
|
+
if (x !== null && typeof x === 'object') {
|
|
55
|
+
if (depth > 4)
|
|
56
|
+
return '[DEEP]';
|
|
57
|
+
const out = {};
|
|
58
|
+
for (const [k, y] of Object.entries(x).slice(0, 16))
|
|
59
|
+
out[k] = walk(y, k, depth + 1);
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
return x;
|
|
63
|
+
};
|
|
64
|
+
const r = redactText(JSON.stringify(walk(v, '', 0)), { ...o, max: EVIDENCE_LIMITS.maxLineChars });
|
|
65
|
+
return { text: r.text, truncated: r.truncated, parsedJson: true, jsonInvalid: false };
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
const r = redactText(trimmed, o);
|
|
69
|
+
return { text: r.text, truncated: r.truncated, parsedJson: false, jsonInvalid: true };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const r = redactText(trimmed, o);
|
|
73
|
+
return { text: r.text, truncated: r.truncated, parsedJson: false, jsonInvalid: false };
|
|
74
|
+
}
|
|
75
|
+
/** The non-empty lines (12+ chars) of an approved prompt, for echo masking. Bounded. */
|
|
76
|
+
export function promptLinesOf(prompt) {
|
|
77
|
+
return prompt.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length >= 12).slice(0, 64);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=evidenceRedaction.js.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { ExecutionClassification, ExecutionFailureCategory, TaskVerdict } from '../../../../packages/contracts/dist/index.js';
|
|
2
|
+
import type { ExecutionEvidenceEventRow } from '../storage/sqliteLedger.js';
|
|
3
|
+
/**
|
|
4
|
+
* C06 generic execution failure classifier (SW-068). It sees ONLY redacted evidence rows plus the process host's own facts; it never sees raw output, so the same
|
|
5
|
+
* code classifies Codex, a future Claude driver and any custom CLI. Provider adapters contribute extra TEXT RULES through PROVIDER_RULES; the category set, the
|
|
6
|
+
* precedence and the honesty rules below are the contract and do not change per provider:
|
|
7
|
+
* 1. Host/supervisor facts (timeout, cancel, spawn failure, tree not confirmed, input not delivered) are OBSERVED_HOST_FACT.
|
|
8
|
+
* 2. An error message in a structured event or on stderr that matches a rule is OBSERVED_ERROR_TEXT and names the cause (causeDetermined = true).
|
|
9
|
+
* 3. Circumstantial patterns (a reconnect loop with no stated reason) are INFERRED and never claim a determined cause.
|
|
10
|
+
* 4. A non-zero exit with nothing explanatory is PROCESS_EXIT_FAILURE with basis NOT_DETERMINED: the exit code is a fact, the reason is unknown.
|
|
11
|
+
*/
|
|
12
|
+
export interface TextRule {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly category: ExecutionFailureCategory;
|
|
15
|
+
readonly test: RegExp;
|
|
16
|
+
readonly basis?: 'OBSERVED_ERROR_TEXT' | 'INFERRED';
|
|
17
|
+
}
|
|
18
|
+
/** Generic rules, in precedence order (an explicit limit or credential statement beats a transport symptom). */
|
|
19
|
+
export declare const GENERIC_TEXT_RULES: readonly TextRule[];
|
|
20
|
+
/** Provider adapters add rules that are specific to one CLI's wording. Add a Claude or custom CLI by adding a key; nothing else in the architecture changes. */
|
|
21
|
+
export declare const PROVIDER_RULES: Readonly<Record<string, readonly TextRule[]>>;
|
|
22
|
+
export interface ClassifierInput {
|
|
23
|
+
outputProfile: string | null;
|
|
24
|
+
/** Final run lifecycle state as committed (FAILED, UNKNOWN, CANCELLED, COMPLETED), or undefined when the run was never finished (daemon died). */
|
|
25
|
+
lifecycleState: string | undefined;
|
|
26
|
+
/** Facts from the process host. NOT_LAUNCHED carries the driver/host code; FINISHED carries the observed process facts; NONE = nothing was observed. */
|
|
27
|
+
observed: {
|
|
28
|
+
kind: 'NONE';
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'NOT_LAUNCHED';
|
|
31
|
+
code: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'FINISHED';
|
|
34
|
+
processOutcome: string;
|
|
35
|
+
processLaunched: boolean;
|
|
36
|
+
exitCode: number | null;
|
|
37
|
+
treeTerminated: boolean | null;
|
|
38
|
+
childTokenVerified: boolean;
|
|
39
|
+
stdinStatus: string | null;
|
|
40
|
+
hasFinalMessage: boolean;
|
|
41
|
+
unparsedLines: number;
|
|
42
|
+
};
|
|
43
|
+
events: readonly ExecutionEvidenceEventRow[];
|
|
44
|
+
lastStage: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function classifyExecution(i: ClassifierInput): ExecutionClassification;
|
|
47
|
+
/**
|
|
48
|
+
* SW-071 TASK VERDICT. Provider wording for TOOL activity lives here, next to PROVIDER_RULES, and nowhere else. It reads only the redacted evidence rows, so it works for any
|
|
49
|
+
* run (live, exported or recovered). A profile with no entry reports tool = NOT_OBSERVED, never a guessed success.
|
|
50
|
+
* - refusal : the CLI states it refused/rejected the tool request (for Codex: a router error "Rejected(...) blocked by policy", or a command item with status "declined");
|
|
51
|
+
* - completed: a finished command item whose status is "completed" and whose exit code is 0 (the command output text itself is never stored);
|
|
52
|
+
* - failed : a finished command item that ran and failed (non-zero exit or status "failed").
|
|
53
|
+
* Process, model, tool and answer stay separate; none is derived from another except that repositoryInspection needs a completed tool call AND a correct answer.
|
|
54
|
+
*/
|
|
55
|
+
export interface ToolRules {
|
|
56
|
+
/** Matches a stderr/stdout evidence line that reports a refused or rejected tool request. */
|
|
57
|
+
readonly refusal: readonly RegExp[];
|
|
58
|
+
/** Matches a line that reports a tool request that was permitted but failed to run (not a policy refusal). */
|
|
59
|
+
readonly toolError: RegExp;
|
|
60
|
+
/** Matches an evidence line that is a FINISHED command/tool item (status and exit code are read from the same line). */
|
|
61
|
+
readonly finishedItem: RegExp;
|
|
62
|
+
/** Matches an evidence line that is a STARTED command/tool item (counted as requested when nothing finished it). */
|
|
63
|
+
readonly startedItem: RegExp;
|
|
64
|
+
}
|
|
65
|
+
export declare const PROVIDER_TOOL_RULES: Readonly<Record<string, ToolRules>>;
|
|
66
|
+
export interface VerdictInput {
|
|
67
|
+
outputProfile: string | null;
|
|
68
|
+
classification: ExecutionClassification | null;
|
|
69
|
+
observed: ClassifierInput['observed'];
|
|
70
|
+
events: readonly ExecutionEvidenceEventRow[];
|
|
71
|
+
/** Task-answer correctness judged INDEPENDENTLY by the caller against ground truth it computed itself. Omit when it was not (or could not be) checked. */
|
|
72
|
+
answerCorrect?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* SW-074: the INDEPENDENT verification of the project-read MCP audit (assessProjectReadAudit; hash-chain recomputed, reads matched to ground truth the model never saw). When present, MCP tool
|
|
75
|
+
* outcomes are counted from it, never from model-visible text, and repository inspection is PROVEN only when its verdict is TOOL_PROVEN. A correct answer alone proves nothing.
|
|
76
|
+
*/
|
|
77
|
+
mcp?: {
|
|
78
|
+
allowedReads: number;
|
|
79
|
+
refusals: number;
|
|
80
|
+
verdict: string;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export declare function assessTaskVerdict(i: VerdictInput): TaskVerdict;
|
|
84
|
+
/**
|
|
85
|
+
* SW-072 CODEX 0.167.0 UNMATCHED-COMMAND POLICY MODEL (provider knowledge; lives here with the other Codex wording).
|
|
86
|
+
*
|
|
87
|
+
* This mirrors, and is pinned against, `render_decision_for_unmatched_command_for_platform` in codex-rs/core/src/exec_policy.rs at tag rust-v0.167.0: a command that no exec-policy rule
|
|
88
|
+
* matches is decided by this function. Conditions that held in the SW-070 run (each independently evidenced, see the SW-072 report): Windows host; Windows sandbox level DISABLED (no
|
|
89
|
+
* `windows.sandbox` setting -> the sandbox log said "selection: disabled"); a managed permission profile with RESTRICTED filesystem access (`--sandbox read-only`); approval policy NEVER
|
|
90
|
+
* (`codex exec` forces it for headless runs). Together they return FORBIDDEN, and the router reports "`<cmd>` rejected: blocked by policy" (a dangerous-command match would have printed
|
|
91
|
+
* its own reason instead). This is the SOURCE-LEVEL explanation; it is a model, not a runtime trace, and it must be re-verified against the source when the pinned Codex build changes.
|
|
92
|
+
*/
|
|
93
|
+
export type CodexWindowsSandboxLevel = 'disabled' | 'unelevated' | 'elevated';
|
|
94
|
+
export type CodexApprovalPolicy = 'never' | 'on-request' | 'unless-trusted' | 'granular';
|
|
95
|
+
export type CodexFilesystemKind = 'restricted' | 'unrestricted' | 'external';
|
|
96
|
+
export type CodexUnmatchedDecision = 'allow' | 'prompt' | 'forbidden';
|
|
97
|
+
export interface CodexUnmatchedInput {
|
|
98
|
+
windowsHost: boolean;
|
|
99
|
+
sandboxLevel: CodexWindowsSandboxLevel;
|
|
100
|
+
profileManaged: boolean;
|
|
101
|
+
filesystem: CodexFilesystemKind;
|
|
102
|
+
approval: CodexApprovalPolicy;
|
|
103
|
+
/** True when Codex's own dangerous-command screening matched the command. */
|
|
104
|
+
dangerousCommand: boolean;
|
|
105
|
+
/** True when the model asked to run outside the sandbox (sandbox_permissions override). */
|
|
106
|
+
requestsSandboxOverride?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export declare function codexUnmatchedCommandDecision(i: CodexUnmatchedInput): CodexUnmatchedDecision;
|
|
109
|
+
/** What `codex exec <argv>` resolves to for the policy inputs above, from the reviewed argv alone (no config files exist in the isolated home; see SW-072). */
|
|
110
|
+
export declare function codexExecEffectivePolicy(argv: readonly string[]): {
|
|
111
|
+
approval: CodexApprovalPolicy;
|
|
112
|
+
sandboxLevel: CodexWindowsSandboxLevel;
|
|
113
|
+
profileManaged: boolean;
|
|
114
|
+
filesystem: CodexFilesystemKind;
|
|
115
|
+
};
|
|
116
|
+
/** Predicted decision for an ordinary, non-dangerous, rule-unmatched command (such as a PowerShell Get-Content) under a reviewed argv on Windows. */
|
|
117
|
+
export declare const predictCodexUnmatchedCommand: (argv: readonly string[]) => CodexUnmatchedDecision;
|
|
118
|
+
/**
|
|
119
|
+
* SW-073 NESTED-SANDBOX STARTABILITY. Codex 0.167.0's legacy ("unelevated") Windows sandbox builds its inner token with
|
|
120
|
+
* CreateRestrictedToken(DISABLE_MAX_PRIVILEGE | LUA_TOKEN | WRITE_RESTRICTED, restricting SIDs {capability SID, logon SID, Everyone}) from the CURRENT process token.
|
|
121
|
+
* Windows rejects WRITE_RESTRICTED when that base token is already restricted (IsTokenRestricted = TRUE) with ERROR_INVALID_PARAMETER (87), for every SID set (proved by the SW-073
|
|
122
|
+
* stage probe, tests/fixtures/sw073NestedSandboxProbe.cs, under the real supervisor identity and on controlled token shapes). Hence a Codex process whose token carries restricting SIDs
|
|
123
|
+
* (the my-centcom RESTRICTED_LOW_INTEGRITY identity) cannot start the unelevated sandbox: structural, not a configuration or ACL problem. `elevated` is a different mechanism (sandbox
|
|
124
|
+
* accounts created by an administrator-run setup) and is not modelled as startable here.
|
|
125
|
+
*/
|
|
126
|
+
export declare function codexInnerSandboxCanStart(i: {
|
|
127
|
+
sandboxLevel: CodexWindowsSandboxLevel;
|
|
128
|
+
outerTokenRestricted: boolean;
|
|
129
|
+
outerCanWriteUserProfile?: boolean;
|
|
130
|
+
}): {
|
|
131
|
+
canStart: boolean;
|
|
132
|
+
reason: string;
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=executionDiagnostics.d.ts.map
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
const CODE = (n) => `(?:http|status|code|error)\\W{0,4}(?:${n})\\b`;
|
|
2
|
+
/** Generic rules, in precedence order (an explicit limit or credential statement beats a transport symptom). */
|
|
3
|
+
export const GENERIC_TEXT_RULES = Object.freeze([
|
|
4
|
+
{ id: 'text:rate-or-usage-limit', category: 'RATE_OR_USAGE_LIMIT', test: new RegExp(`rate.?limit|usage limit|quota|too many requests|credits? (?:are )?(?:exhausted|required)|${CODE('429')}`, 'i') },
|
|
5
|
+
{ id: 'text:authentication', category: 'AUTHENTICATION_FAILURE', test: new RegExp(`not logged in|invalid (?:api )?key|token (?:is )?(?:expired|invalid|revoked)|(?:log|sign) ?in (?:again|required)|authentication (?:failed|required|error)|refresh token|${CODE('401')}|unauthori[sz]ed`, 'i') },
|
|
6
|
+
{ id: 'text:authorization', category: 'AUTHORIZATION_FAILURE', test: new RegExp(`forbidden|not entitled|plan does not include|not (?:allowed|permitted) to use|${CODE('403')}`, 'i') },
|
|
7
|
+
{ id: 'text:sandbox', category: 'SANDBOX_FAILURE', test: /sandbox (?:setup|helper|failed|error|unavailable|refused|startup)|failed to (?:start|create|set up) (?:the )?sandbox|command[- ]runner|CreateRestrictedToken|restricted token/i },
|
|
8
|
+
{ id: 'text:tls-certificate', category: 'NETWORK_OR_TLS_FAILURE', test: /certificate|\btls\b|\bssl\b|handshake|untrusted root|unable to get local issuer|self[- ]signed/i },
|
|
9
|
+
{ id: 'text:network', category: 'NETWORK_OR_TLS_FAILURE', test: /ECONNREFUSED|ECONNRESET|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|dns|could not resolve|connection (?:refused|reset|closed|timed out)|timed out connecting|network error|error sending request|unreachable|stream disconnected|os error 100(?:60|61|54)/i },
|
|
10
|
+
{ id: 'text:provider-rejection', category: 'PROVIDER_REJECTION', test: new RegExp(`invalid_request|model .{0,40}(?:not found|unsupported|not supported|unavailable)|unsupported (?:model|parameter|region)|overloaded|server error|bad gateway|service unavailable|${CODE('400|404|409|422|5\\d\\d')}`, 'i') },
|
|
11
|
+
{ id: 'text:reconnect-loop', category: 'NETWORK_OR_TLS_FAILURE', test: /reconnecting|retrying|retry(?:ing)? \d+\/\d+/i, basis: 'INFERRED' },
|
|
12
|
+
]);
|
|
13
|
+
/** Provider adapters add rules that are specific to one CLI's wording. Add a Claude or custom CLI by adding a key; nothing else in the architecture changes. */
|
|
14
|
+
export const PROVIDER_RULES = Object.freeze({
|
|
15
|
+
'codex-exec-jsonl-v1': Object.freeze([
|
|
16
|
+
{ id: 'codex:windows-sandbox', category: 'SANDBOX_FAILURE', test: /windows sandbox|codex-windows-sandbox|sandbox selection/i },
|
|
17
|
+
{ id: 'codex:tls-validation', category: 'NETWORK_OR_TLS_FAILURE', test: /tls handshake or certificate validation failed|certificate validation failed/i },
|
|
18
|
+
{ id: 'codex:responses-ws', category: 'NETWORK_OR_TLS_FAILURE', test: /responses websocket|websocket (?:failed|handshake)/i },
|
|
19
|
+
]),
|
|
20
|
+
});
|
|
21
|
+
const SPAWN_EXE_INVALID = /not a valid win32|bad image|cannot find the file|ENOENT|EXECUTABLE_(?:CHANGED|MISMATCH)|digest/i;
|
|
22
|
+
const make = (c, basis, determined, rule, seq, stage, detail) => ({ category: c, basis, causeDetermined: determined, rule, evidenceSeq: seq.slice(0, 8), lastConfirmedStage: stage, providerDetail: detail === null ? null : detail.slice(0, 300) });
|
|
23
|
+
export function classifyExecution(i) {
|
|
24
|
+
const stage = /^[A-Z][A-Z0-9_]{1,40}$/.test(i.lastStage) ? i.lastStage : 'UNKNOWN_STAGE';
|
|
25
|
+
const rules = [...(i.outputProfile && PROVIDER_RULES[i.outputProfile] ? PROVIDER_RULES[i.outputProfile] : []), ...GENERIC_TEXT_RULES];
|
|
26
|
+
const textEvents = i.events.filter((e) => e.kind === 'STDERR' || e.kind === 'STDOUT' || e.kind === 'PARSER');
|
|
27
|
+
const findText = (only) => {
|
|
28
|
+
for (const r of rules) {
|
|
29
|
+
if (only && !only(r))
|
|
30
|
+
continue;
|
|
31
|
+
const ev = textEvents.find((e) => r.test.test(e.data));
|
|
32
|
+
if (ev)
|
|
33
|
+
return { rule: r, ev };
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
};
|
|
37
|
+
const o = i.observed;
|
|
38
|
+
if (i.lifecycleState === 'CANCELLED')
|
|
39
|
+
return make('CANCELLED', 'OBSERVED_HOST_FACT', true, 'host:cancelled', [], stage, null);
|
|
40
|
+
if (o.kind === 'NOT_LAUNCHED') {
|
|
41
|
+
const exe = /EXECUTABLE_CHANGED|EXECUTABLE_MISMATCH|PREPARE_EXECUTABLE|SCRIPT_UNPINNED|CODE_INPUT|CA_BUNDLE|ENV_INVALID/.test(o.code);
|
|
42
|
+
return make(exe ? 'EXECUTABLE_INVALID' : 'PROCESS_START_FAILURE', 'OBSERVED_HOST_FACT', true, `host:not-launched:${o.code}`.slice(0, 64), [], stage, o.code.slice(0, 60));
|
|
43
|
+
}
|
|
44
|
+
if (o.kind === 'NONE') {
|
|
45
|
+
// Never finished and nothing observed: the daemon (or host) died while the process may still have existed.
|
|
46
|
+
if (i.lifecycleState === 'UNKNOWN' || i.lifecycleState === undefined || i.lifecycleState === 'STARTING' || i.lifecycleState === 'RUNNING')
|
|
47
|
+
return make('UNKNOWN_OUTCOME', 'OBSERVED_HOST_FACT', false, 'host:no-terminal-evidence', [], stage, null);
|
|
48
|
+
return make('UNCLASSIFIED_FAILURE', 'NOT_DETERMINED', false, 'none:no-observation', [], stage, null);
|
|
49
|
+
}
|
|
50
|
+
// FINISHED
|
|
51
|
+
if (o.processOutcome === 'TIMEOUT')
|
|
52
|
+
return make('TIMEOUT', 'OBSERVED_HOST_FACT', true, 'host:timeout', [], stage, null);
|
|
53
|
+
if (o.processOutcome === 'CANCELLED')
|
|
54
|
+
return make('CANCELLED', 'OBSERVED_HOST_FACT', true, 'host:cancelled', [], stage, null);
|
|
55
|
+
if (o.processOutcome === 'SPAWN_FAILED' || !o.processLaunched) {
|
|
56
|
+
const bad = textEvents.find((e) => SPAWN_EXE_INVALID.test(e.data)) ?? i.events.find((e) => e.kind === 'LIFECYCLE' && SPAWN_EXE_INVALID.test(e.data));
|
|
57
|
+
return bad ? make('EXECUTABLE_INVALID', 'OBSERVED_ERROR_TEXT', true, 'text:spawn-executable-invalid', [bad.seq], stage, bad.data)
|
|
58
|
+
: make('PROCESS_START_FAILURE', 'OBSERVED_HOST_FACT', true, 'host:spawn-failed', [], stage, null);
|
|
59
|
+
}
|
|
60
|
+
if (o.processOutcome === 'SUPERVISION_FAILED' || i.lifecycleState === 'UNKNOWN' || o.treeTerminated !== true || !o.childTokenVerified) {
|
|
61
|
+
return make('UNKNOWN_OUTCOME', 'OBSERVED_HOST_FACT', false, 'host:supervision-not-confirmed', [], stage, null);
|
|
62
|
+
}
|
|
63
|
+
if (o.processOutcome === 'OUTPUT_LIMIT_EXCEEDED')
|
|
64
|
+
return make('EVENT_PROTOCOL_ERROR', 'OBSERVED_HOST_FACT', true, 'host:output-limit', [], stage, null);
|
|
65
|
+
if (o.exitCode === 0) {
|
|
66
|
+
if (o.stdinStatus !== null && o.stdinStatus !== 'NOT_REQUESTED' && o.stdinStatus !== 'DELIVERED_EOF')
|
|
67
|
+
return make('PROCESS_START_FAILURE', 'OBSERVED_HOST_FACT', true, `host:stdin-${o.stdinStatus.toLowerCase()}`.slice(0, 64), [], stage, null);
|
|
68
|
+
if (!o.hasFinalMessage) {
|
|
69
|
+
const bad = textEvents.find((e) => e.kind === 'PARSER');
|
|
70
|
+
return make('EVENT_PROTOCOL_ERROR', 'OBSERVED_HOST_FACT', true, 'host:exit-0-without-final-message', bad ? [bad.seq] : [], stage, bad ? bad.data : null);
|
|
71
|
+
}
|
|
72
|
+
return make(null, 'OBSERVED_HOST_FACT', true, 'ok:exit-0-with-final-message', [], stage, null);
|
|
73
|
+
}
|
|
74
|
+
// Non-zero exit (or a signal): look for an explanation in what the CLI itself reported.
|
|
75
|
+
const hit = findText();
|
|
76
|
+
if (hit) {
|
|
77
|
+
const inferred = hit.rule.basis === 'INFERRED';
|
|
78
|
+
return make(hit.rule.category, inferred ? 'INFERRED' : 'OBSERVED_ERROR_TEXT', !inferred, hit.rule.id, [hit.ev.seq], stage, hit.ev.data);
|
|
79
|
+
}
|
|
80
|
+
if (o.stdinStatus !== null && o.stdinStatus !== 'NOT_REQUESTED' && o.stdinStatus !== 'DELIVERED_EOF')
|
|
81
|
+
return make('PROCESS_START_FAILURE', 'OBSERVED_HOST_FACT', true, `host:stdin-${o.stdinStatus.toLowerCase()}`.slice(0, 64), [], stage, null);
|
|
82
|
+
const bad = textEvents.find((e) => e.kind === 'PARSER');
|
|
83
|
+
if (bad && !o.hasFinalMessage && o.unparsedLines > 0)
|
|
84
|
+
return make('EVENT_PROTOCOL_ERROR', 'OBSERVED_ERROR_TEXT', false, 'parser:invalid-events', [bad.seq], stage, bad.data);
|
|
85
|
+
// A known exit code without a known reason is an observed FACT but NOT a diagnosis.
|
|
86
|
+
return make('PROCESS_EXIT_FAILURE', 'NOT_DETERMINED', false, 'host:nonzero-exit-no-reason', [], stage, `exit=${o.exitCode}`);
|
|
87
|
+
}
|
|
88
|
+
export const PROVIDER_TOOL_RULES = Object.freeze({
|
|
89
|
+
'codex-exec-jsonl-v1': Object.freeze({
|
|
90
|
+
refusal: Object.freeze([/createprocess\s*\{\s*message:\s*rejected/i, /rejected:\s*(?:blocked by policy|policy forbids)/i, /approval required by policy/i]),
|
|
91
|
+
toolError: /exec_command failed/i,
|
|
92
|
+
finishedItem: /"type":"item\.completed".*"type":"command_execution"|"type":"command_execution".*"type":"item\.completed"/,
|
|
93
|
+
startedItem: /"type":"item\.started".*"type":"command_execution"|"type":"command_execution".*"type":"item\.started"/,
|
|
94
|
+
}),
|
|
95
|
+
});
|
|
96
|
+
export function assessTaskVerdict(i) {
|
|
97
|
+
const o = i.observed;
|
|
98
|
+
const processDim = i.classification === null || o.kind === 'NONE' || o.kind === 'NOT_LAUNCHED' || i.classification.category === 'UNKNOWN_OUTCOME' ? 'NOT_OBSERVED'
|
|
99
|
+
: i.classification.category === null ? 'SUCCEEDED' : 'FAILED';
|
|
100
|
+
const modelDim = o.kind !== 'FINISHED' ? 'NOT_OBSERVED' : o.hasFinalMessage ? 'COMPLETED' : 'NO_FINAL_MESSAGE';
|
|
101
|
+
const rules = i.outputProfile ? PROVIDER_TOOL_RULES[i.outputProfile] : undefined;
|
|
102
|
+
const counts = { requested: 0, completed: 0, refused: 0, failed: 0 };
|
|
103
|
+
const seq = [];
|
|
104
|
+
const note = (n) => { if (seq.length < 8)
|
|
105
|
+
seq.push(n); };
|
|
106
|
+
if (rules) {
|
|
107
|
+
let started = 0;
|
|
108
|
+
for (const e of i.events) {
|
|
109
|
+
if (e.kind === 'STDERR' || e.kind === 'STDOUT' || e.kind === 'PARSER') {
|
|
110
|
+
if (rules.refusal.some((r) => r.test(e.data))) {
|
|
111
|
+
counts.refused += 1;
|
|
112
|
+
note(e.seq);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (rules.toolError.test(e.data)) {
|
|
116
|
+
counts.failed += 1;
|
|
117
|
+
note(e.seq);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (e.kind !== 'STDOUT')
|
|
122
|
+
continue;
|
|
123
|
+
if (rules.startedItem.test(e.data)) {
|
|
124
|
+
started += 1;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (!rules.finishedItem.test(e.data))
|
|
128
|
+
continue;
|
|
129
|
+
const status = /"status":"([a-z_]+)"/.exec(e.data)?.[1] ?? null;
|
|
130
|
+
const exit = /"exit_code":(-?\d+)/.exec(e.data)?.[1];
|
|
131
|
+
if (status === 'declined' || status === 'rejected') {
|
|
132
|
+
counts.refused += 1;
|
|
133
|
+
note(e.seq);
|
|
134
|
+
}
|
|
135
|
+
else if (status === 'completed' && (exit === undefined || exit === '0')) {
|
|
136
|
+
counts.completed += 1;
|
|
137
|
+
note(e.seq);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
counts.failed += 1;
|
|
141
|
+
note(e.seq);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
counts.requested = Math.max(started, counts.completed + counts.refused + counts.failed);
|
|
145
|
+
}
|
|
146
|
+
if (i.mcp) {
|
|
147
|
+
counts.completed += i.mcp.allowedReads;
|
|
148
|
+
counts.refused += i.mcp.refusals;
|
|
149
|
+
counts.requested = Math.max(counts.requested, counts.completed + counts.refused + counts.failed);
|
|
150
|
+
}
|
|
151
|
+
const toolDim = !rules && !i.mcp ? 'NOT_OBSERVED'
|
|
152
|
+
: counts.requested === 0 ? (o.kind === 'FINISHED' ? 'NOT_REQUESTED' : 'NOT_OBSERVED')
|
|
153
|
+
: counts.completed > 0 && counts.refused === 0 && counts.failed === 0 ? 'SUCCEEDED'
|
|
154
|
+
: counts.completed > 0 ? 'PARTIAL'
|
|
155
|
+
: counts.refused > 0 ? 'REFUSED' : counts.failed > 0 ? 'FAILED' : 'NOT_OBSERVED';
|
|
156
|
+
const answer = i.answerCorrect === undefined ? 'NOT_CHECKED' : i.answerCorrect ? 'CORRECT' : 'INCORRECT';
|
|
157
|
+
const inspection = counts.completed > 0 && answer === 'CORRECT' && (!i.mcp || i.mcp.verdict === 'TOOL_PROVEN') ? 'PROVEN' : counts.completed === 0 && counts.refused > 0 ? 'REFUSED' : 'NOT_PROVEN';
|
|
158
|
+
return { process: processDim, model: modelDim, tool: toolDim, answer, repositoryInspection: inspection, toolCounts: counts, toolEvidenceSeq: seq };
|
|
159
|
+
}
|
|
160
|
+
export function codexUnmatchedCommandDecision(i) {
|
|
161
|
+
// "managed filesystem restrictions are only a policy shape when no platform sandbox backend exists to enforce them" (upstream comment); kept conservative.
|
|
162
|
+
const restrictionsWithoutBackend = i.windowsHost && i.sandboxLevel === 'disabled' && i.profileManaged && i.filesystem === 'restricted';
|
|
163
|
+
if (i.dangerousCommand || restrictionsWithoutBackend)
|
|
164
|
+
return i.approval === 'never' ? 'forbidden' : 'prompt';
|
|
165
|
+
switch (i.approval) {
|
|
166
|
+
case 'never': return 'allow'; // relies on the sandbox for protection
|
|
167
|
+
case 'unless-trusted': return 'prompt';
|
|
168
|
+
case 'on-request':
|
|
169
|
+
case 'granular':
|
|
170
|
+
return i.filesystem === 'restricted' ? (i.requestsSandboxOverride ? 'prompt' : 'allow') : 'allow';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/** What `codex exec <argv>` resolves to for the policy inputs above, from the reviewed argv alone (no config files exist in the isolated home; see SW-072). */
|
|
174
|
+
export function codexExecEffectivePolicy(argv) {
|
|
175
|
+
const flag = (name) => { const i = argv.indexOf(name); return i >= 0 ? argv[i + 1] : undefined; };
|
|
176
|
+
let sandboxLevel = 'disabled';
|
|
177
|
+
for (let k = 0; k < argv.length - 1; k += 1) {
|
|
178
|
+
if (argv[k] !== '-c')
|
|
179
|
+
continue;
|
|
180
|
+
const m = /^windows\.sandbox\s*=\s*"?(unelevated|elevated|disabled)"?$/.exec(argv[k + 1]);
|
|
181
|
+
if (m)
|
|
182
|
+
sandboxLevel = m[1];
|
|
183
|
+
}
|
|
184
|
+
const mode = flag('--sandbox') ?? flag('-s');
|
|
185
|
+
const filesystem = mode === 'danger-full-access' ? 'unrestricted' : 'restricted'; // read-only and workspace-write (the default) are restricted
|
|
186
|
+
return { approval: 'never', sandboxLevel, profileManaged: mode !== 'danger-full-access', filesystem };
|
|
187
|
+
}
|
|
188
|
+
/** Predicted decision for an ordinary, non-dangerous, rule-unmatched command (such as a PowerShell Get-Content) under a reviewed argv on Windows. */
|
|
189
|
+
export const predictCodexUnmatchedCommand = (argv) => codexUnmatchedCommandDecision({ windowsHost: true, dangerousCommand: false, ...codexExecEffectivePolicy(argv) });
|
|
190
|
+
/**
|
|
191
|
+
* SW-073 NESTED-SANDBOX STARTABILITY. Codex 0.167.0's legacy ("unelevated") Windows sandbox builds its inner token with
|
|
192
|
+
* CreateRestrictedToken(DISABLE_MAX_PRIVILEGE | LUA_TOKEN | WRITE_RESTRICTED, restricting SIDs {capability SID, logon SID, Everyone}) from the CURRENT process token.
|
|
193
|
+
* Windows rejects WRITE_RESTRICTED when that base token is already restricted (IsTokenRestricted = TRUE) with ERROR_INVALID_PARAMETER (87), for every SID set (proved by the SW-073
|
|
194
|
+
* stage probe, tests/fixtures/sw073NestedSandboxProbe.cs, under the real supervisor identity and on controlled token shapes). Hence a Codex process whose token carries restricting SIDs
|
|
195
|
+
* (the my-centcom RESTRICTED_LOW_INTEGRITY identity) cannot start the unelevated sandbox: structural, not a configuration or ACL problem. `elevated` is a different mechanism (sandbox
|
|
196
|
+
* accounts created by an administrator-run setup) and is not modelled as startable here.
|
|
197
|
+
*/
|
|
198
|
+
export function codexInnerSandboxCanStart(i) {
|
|
199
|
+
if (i.sandboxLevel === 'disabled')
|
|
200
|
+
return { canStart: true, reason: 'no inner sandbox requested' };
|
|
201
|
+
if (i.sandboxLevel === 'unelevated') {
|
|
202
|
+
// Two independent blockers, in the order Codex hits them. (1) With a read-only profile Codex applies a network block that creates "<Known-Folder user profile>/.sbx-denybin"
|
|
203
|
+
// (dirs_next::home_dir, not the USERPROFILE variable); an identity that cannot write the real profile gets ERROR_ACCESS_DENIED (5). (2) The inner token needs an unrestricted base.
|
|
204
|
+
const blockers = [];
|
|
205
|
+
if (i.outerCanWriteUserProfile === false || (i.outerCanWriteUserProfile === undefined && i.outerTokenRestricted))
|
|
206
|
+
blockers.push('cannot create <user profile>/.sbx-denybin (ERROR_ACCESS_DENIED 5; the path comes from the Known Folder API and cannot be redirected by environment)');
|
|
207
|
+
if (i.outerTokenRestricted)
|
|
208
|
+
blockers.push('CreateRestrictedToken(WRITE_RESTRICTED) from an already-restricted token fails with ERROR_INVALID_PARAMETER (87)');
|
|
209
|
+
return blockers.length ? { canStart: false, reason: blockers.join('; then ') } : { canStart: true, reason: 'the base token is unrestricted and the profile is writable' };
|
|
210
|
+
}
|
|
211
|
+
return { canStart: false, reason: 'elevated sandbox needs administrator-run machine setup (not authorized, not modelled as startable)' };
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=executionDiagnostics.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ModelExecutionMode } from '../../../../packages/contracts/dist/index.js';
|
|
2
|
+
export type ModelExecutionPolicy = {
|
|
3
|
+
mode: 'STRICT_ISOLATED';
|
|
4
|
+
readiness: ReturnType<typeof modelExecutionReadiness>;
|
|
5
|
+
} | {
|
|
6
|
+
mode: 'TRUSTED_LOCAL_CLI_PROPOSAL_ONLY';
|
|
7
|
+
authority: 'EXPLICIT_SCOPED_CONSENT';
|
|
8
|
+
isolation: 'NOT_ISOLATED';
|
|
9
|
+
};
|
|
10
|
+
export declare function modelExecutionPolicy(mode?: ModelExecutionMode): ModelExecutionPolicy;
|
|
11
|
+
/** C06 MODEL_EXECUTION readiness, independent of UNTRUSTED_TEST_EXECUTION.
|
|
12
|
+
* There is deliberately no caller-supplied override or attestation consumer.
|
|
13
|
+
* The reviewed SDK's empty capability list still yields an unidentified native
|
|
14
|
+
* capability. Until its authority is established, presenting authentication to
|
|
15
|
+
* this boundary cannot be approved. Never substitute the legacy shared token.
|
|
16
|
+
*/
|
|
17
|
+
export declare function modelExecutionReadiness(): {
|
|
18
|
+
ready: false;
|
|
19
|
+
code: 'MODEL_BOUNDARY_UNVERIFIED';
|
|
20
|
+
reasons: readonly string[];
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=modelExecutionPolicy.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function modelExecutionPolicy(mode = 'STRICT_ISOLATED') {
|
|
2
|
+
if (mode !== 'STRICT_ISOLATED' && mode !== 'TRUSTED_LOCAL_CLI_PROPOSAL_ONLY')
|
|
3
|
+
throw new Error('MODEL_MODE_INVALID');
|
|
4
|
+
return mode === 'STRICT_ISOLATED' ? { mode, readiness: modelExecutionReadiness() } : { mode, authority: 'EXPLICIT_SCOPED_CONSENT', isolation: 'NOT_ISOLATED' };
|
|
5
|
+
}
|
|
6
|
+
/** C06 MODEL_EXECUTION readiness, independent of UNTRUSTED_TEST_EXECUTION.
|
|
7
|
+
* There is deliberately no caller-supplied override or attestation consumer.
|
|
8
|
+
* The reviewed SDK's empty capability list still yields an unidentified native
|
|
9
|
+
* capability. Until its authority is established, presenting authentication to
|
|
10
|
+
* this boundary cannot be approved. Never substitute the legacy shared token.
|
|
11
|
+
*/
|
|
12
|
+
export function modelExecutionReadiness() {
|
|
13
|
+
return { ready: false, code: 'MODEL_BOUNDARY_UNVERIFIED', reasons: [
|
|
14
|
+
'NATIVE_CAPABILITY_AUTHORITY_UNIDENTIFIED',
|
|
15
|
+
'ISOLATED_AUTHENTICATION_PRESENTATION_UNVERIFIED',
|
|
16
|
+
'PROVIDER_SCOPED_NETWORK_ROUTE_UNVERIFIED',
|
|
17
|
+
] };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=modelExecutionPolicy.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WindowsJobSupervisor } from './windows/windowsJobSupervisor.js';
|
|
2
|
+
import { type TestExecutor } from './testExecution.js';
|
|
3
|
+
/** C06 adapter; production readiness is deliberately absent. A caller cannot
|
|
4
|
+
* choose an executable/argv/network rule. The existing host/supervisor owns the
|
|
5
|
+
* broker tree; MXC owns the inner PSEC. No restricted-token fallback. */
|
|
6
|
+
export declare function createMxcTestExecutor(cfg: {
|
|
7
|
+
projectRoot: string;
|
|
8
|
+
supervisor: WindowsJobSupervisor;
|
|
9
|
+
syntheticWorkspaceBoundary?: string;
|
|
10
|
+
tempBoundary: string;
|
|
11
|
+
}): TestExecutor;
|
|
12
|
+
//# sourceMappingURL=mxcExecution.d.ts.map
|