project-tiny-context-harness 0.8.12 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -19
- package/assets/README.md +81 -40
- package/assets/README.zh-CN.md +44 -22
- package/assets/agents/AGENTS_CORE.md +8 -4
- package/assets/skills/context_development_engineer/SKILL.md +9 -1
- package/assets/skills/design-resource-authoring/SKILL.md +7 -5
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +2 -2
- package/assets/skills/design-resource-authoring/references/open-design-provider.md +22 -2
- package/assets/skills/design-resource-authoring/references/recovery-and-writeback.md +199 -0
- package/assets/skills/design-resource-authoring/references/resource-selection.md +2 -2
- package/assets/skills/long-task-workflow/SKILL.md +6 -6
- package/assets/skills/long-task-workflow/references/contract-authoring.md +27 -22
- package/assets/skills/long-task-workflow/references/evidence-design.md +49 -32
- package/assets/skills/long-task-workflow/references/source-authoring.md +2 -2
- package/dist/commands/design-resource-recovery.d.ts +1 -0
- package/dist/commands/design-resource-recovery.js +152 -0
- package/dist/commands/design-resource.js +20 -1
- package/dist/commands/index.js +1 -1
- package/dist/lib/design-resource-reconciliation-codec.d.ts +2 -0
- package/dist/lib/design-resource-reconciliation-codec.js +174 -0
- package/dist/lib/design-resource-reconciliation-types.d.ts +62 -0
- package/dist/lib/design-resource-reconciliation-types.js +1 -0
- package/dist/lib/design-resource-reconciliation.d.ts +3 -0
- package/dist/lib/design-resource-reconciliation.js +224 -0
- package/dist/lib/design-resource-recovery-authority-policy.d.ts +8 -0
- package/dist/lib/design-resource-recovery-authority-policy.js +123 -0
- package/dist/lib/design-resource-recovery-catalog-resources.d.ts +6 -0
- package/dist/lib/design-resource-recovery-catalog-resources.js +121 -0
- package/dist/lib/design-resource-recovery-catalog-shape.d.ts +3 -0
- package/dist/lib/design-resource-recovery-catalog-shape.js +104 -0
- package/dist/lib/design-resource-recovery-catalog.d.ts +9 -0
- package/dist/lib/design-resource-recovery-catalog.js +103 -0
- package/dist/lib/design-resource-recovery-cleanup.d.ts +2 -0
- package/dist/lib/design-resource-recovery-cleanup.js +11 -0
- package/dist/lib/design-resource-recovery-codec-primitives.d.ts +19 -0
- package/dist/lib/design-resource-recovery-codec-primitives.js +92 -0
- package/dist/lib/design-resource-recovery-codec.d.ts +4 -0
- package/dist/lib/design-resource-recovery-codec.js +93 -0
- package/dist/lib/design-resource-recovery-current.d.ts +9 -0
- package/dist/lib/design-resource-recovery-current.js +41 -0
- package/dist/lib/design-resource-recovery-delta-policy.d.ts +5 -0
- package/dist/lib/design-resource-recovery-delta-policy.js +108 -0
- package/dist/lib/design-resource-recovery-files.d.ts +37 -0
- package/dist/lib/design-resource-recovery-files.js +204 -0
- package/dist/lib/design-resource-recovery-final-disposition-shape.d.ts +2 -0
- package/dist/lib/design-resource-recovery-final-disposition-shape.js +47 -0
- package/dist/lib/design-resource-recovery-patch-types.d.ts +54 -0
- package/dist/lib/design-resource-recovery-patch-types.js +1 -0
- package/dist/lib/design-resource-recovery-replay.d.ts +7 -0
- package/dist/lib/design-resource-recovery-replay.js +112 -0
- package/dist/lib/design-resource-recovery-repository-bindings.d.ts +9 -0
- package/dist/lib/design-resource-recovery-repository-bindings.js +49 -0
- package/dist/lib/design-resource-recovery-schema.d.ts +5 -0
- package/dist/lib/design-resource-recovery-schema.js +5 -0
- package/dist/lib/design-resource-recovery-shape.d.ts +10 -0
- package/dist/lib/design-resource-recovery-shape.js +184 -0
- package/dist/lib/design-resource-recovery-source-authority.d.ts +5 -0
- package/dist/lib/design-resource-recovery-source-authority.js +219 -0
- package/dist/lib/design-resource-recovery-text.d.ts +17 -0
- package/dist/lib/design-resource-recovery-text.js +186 -0
- package/dist/lib/design-resource-recovery-types.d.ts +197 -0
- package/dist/lib/design-resource-recovery-types.js +1 -0
- package/dist/lib/design-resource-recovery-writeback-policy.d.ts +5 -0
- package/dist/lib/design-resource-recovery-writeback-policy.js +326 -0
- package/dist/lib/design-resource-recovery-writeback-shape.d.ts +6 -0
- package/dist/lib/design-resource-recovery-writeback-shape.js +155 -0
- package/dist/lib/design-resource-recovery.d.ts +44 -0
- package/dist/lib/design-resource-recovery.js +216 -0
- package/dist/lib/long-task-acceptance-shape.js +8 -2
- package/dist/lib/long-task-activation-validation.js +13 -3
- package/dist/lib/long-task-admitted-observation-records.d.ts +25 -0
- package/dist/lib/long-task-admitted-observation-records.js +40 -0
- package/dist/lib/long-task-admitted-observation.d.ts +93 -0
- package/dist/lib/long-task-admitted-observation.js +201 -0
- package/dist/lib/long-task-artifacts.d.ts +1 -0
- package/dist/lib/long-task-artifacts.js +1 -0
- package/dist/lib/long-task-authority-material-diff.js +1 -0
- package/dist/lib/long-task-authority-policy.d.ts +2 -0
- package/dist/lib/long-task-authority-policy.js +2 -0
- package/dist/lib/long-task-authority-revision-details.js +3 -1
- package/dist/lib/long-task-authority.js +2 -1
- package/dist/lib/long-task-check-execution-policy.js +5 -0
- package/dist/lib/long-task-check-runner.d.ts +2 -2
- package/dist/lib/long-task-check-runner.js +440 -23
- package/dist/lib/long-task-claims.d.ts +18 -0
- package/dist/lib/long-task-claims.js +35 -0
- package/dist/lib/long-task-compact-structure-targets.js +1 -0
- package/dist/lib/long-task-conformance-policy.js +3 -1
- package/dist/lib/long-task-counterfactual-claim-policy.d.ts +3 -4
- package/dist/lib/long-task-counterfactual-claim-policy.js +11 -3
- package/dist/lib/long-task-counterfactual-sandbox.js +1 -0
- package/dist/lib/long-task-counterfactual-types.d.ts +2 -0
- package/dist/lib/long-task-delivery-compiler.js +2 -0
- package/dist/lib/long-task-evidence-capability-policy.d.ts +3 -2
- package/dist/lib/long-task-evidence-capability-policy.js +114 -8
- package/dist/lib/long-task-evidence-capability-runtime.d.ts +5 -2
- package/dist/lib/long-task-evidence-capability-runtime.js +149 -5
- package/dist/lib/long-task-evidence-sensitivity-policy.d.ts +9 -0
- package/dist/lib/long-task-evidence-sensitivity-policy.js +31 -1
- package/dist/lib/long-task-evidence-v2.d.ts +4 -4
- package/dist/lib/long-task-evidence-v2.js +321 -43
- package/dist/lib/long-task-exact-comparison.d.ts +16 -0
- package/dist/lib/long-task-exact-comparison.js +28 -0
- package/dist/lib/long-task-execution-observation.d.ts +24 -0
- package/dist/lib/long-task-execution-observation.js +332 -0
- package/dist/lib/long-task-explain-acceptance-link.d.ts +4 -0
- package/dist/lib/long-task-explain-acceptance-link.js +4 -0
- package/dist/lib/long-task-explain-claim-links.d.ts +2 -0
- package/dist/lib/long-task-explain-claim-links.js +2 -0
- package/dist/lib/long-task-explain-source-links.d.ts +6 -0
- package/dist/lib/long-task-final-v2.js +7 -4
- package/dist/lib/long-task-json-pointer-observation.d.ts +59 -0
- package/dist/lib/long-task-json-pointer-observation.js +184 -0
- package/dist/lib/long-task-observation-artifact.d.ts +8 -0
- package/dist/lib/long-task-observation-artifact.js +58 -0
- package/dist/lib/long-task-observation-authority.d.ts +17 -0
- package/dist/lib/long-task-observation-authority.js +348 -0
- package/dist/lib/long-task-paths.js +1 -1
- package/dist/lib/long-task-process-observation.d.ts +6 -0
- package/dist/lib/long-task-process-observation.js +117 -0
- package/dist/lib/long-task-process-runtime-closure.d.ts +13 -0
- package/dist/lib/long-task-process-runtime-closure.js +175 -0
- package/dist/lib/long-task-progress.js +2 -0
- package/dist/lib/long-task-protected-files.d.ts +1 -1
- package/dist/lib/long-task-protected-files.js +1 -30
- package/dist/lib/long-task-risk.js +8 -3
- package/dist/lib/long-task-root-shape.js +10 -1
- package/dist/lib/long-task-runner-environment.d.ts +1 -1
- package/dist/lib/long-task-runner-environment.js +4 -4
- package/dist/lib/long-task-runner-freeze.d.ts +4 -2
- package/dist/lib/long-task-runner-freeze.js +128 -28
- package/dist/lib/long-task-runtime-types.d.ts +111 -0
- package/dist/lib/long-task-scoped-binding.d.ts +13 -0
- package/dist/lib/long-task-scoped-binding.js +11 -0
- package/dist/lib/long-task-semantic-contract-types.d.ts +1 -0
- package/dist/lib/long-task-semantic-fact-contract-closure.js +3 -3
- package/dist/lib/long-task-semantic-fact-evidence.d.ts +3 -3
- package/dist/lib/long-task-semantic-fact-evidence.js +75 -58
- package/dist/lib/long-task-source-claim-validation.js +4 -1
- package/dist/lib/long-task-source-target-continuity.d.ts +2 -2
- package/dist/lib/long-task-source-target-continuity.js +35 -2
- package/dist/lib/long-task-source-target-index.d.ts +3 -0
- package/dist/lib/long-task-source-target-index.js +19 -0
- package/dist/lib/long-task-stage-policy.js +10 -4
- package/dist/lib/long-task-static-observation-freeze.d.ts +83 -0
- package/dist/lib/long-task-static-observation-freeze.js +428 -0
- package/dist/lib/long-task-status-projection.js +5 -1
- package/dist/lib/long-task-target-policy.d.ts +1 -1
- package/dist/lib/long-task-target-policy.js +3 -0
- package/dist/lib/long-task-verifier-dependency-closure.js +7 -3
- package/dist/lib/long-task-verifier-v2.js +70 -9
- package/dist/lib/long-task-workspace.d.ts +1 -1
- package/dist/lib/long-task-workspace.js +1 -12
- package/dist/lib/repository-path-safety.d.ts +14 -0
- package/dist/lib/repository-path-safety.js +126 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +53 -8
- package/migrations/README.md +77 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { scopeDeliveryBindings, } from "./long-task-scoped-binding.js";
|
|
1
2
|
export function validateCounterfactualBindingClaims(outcome, control, binding) {
|
|
2
3
|
if (binding.verification_check_key &&
|
|
3
4
|
binding.verification_check_key !== control.check_key)
|
|
@@ -21,10 +22,10 @@ export function resolveGlobalCounterfactualBinding(contract, control) {
|
|
|
21
22
|
const outcome = contract.outcomes.find((item) => item.key === outcomeKey);
|
|
22
23
|
if (!outcome)
|
|
23
24
|
throw new Error(`global_counterfactual_binding_ref_invalid:${control.key}:${control.binding_ref}`);
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
25
|
+
const scoped = scopeDeliveryBindings(outcome.key, outcome.technical.bindings).find((item) => item.binding_ref === control.binding_ref && item.local_key === bindingKey);
|
|
26
|
+
if (!scoped)
|
|
26
27
|
throw new Error(`global_counterfactual_binding_unknown:${control.key}:${control.binding_ref}`);
|
|
27
|
-
return { outcome,
|
|
28
|
+
return { outcome, ...scoped };
|
|
28
29
|
}
|
|
29
30
|
export function validateGlobalCounterfactualBindingClaims(contract, control) {
|
|
30
31
|
const resolved = resolveGlobalCounterfactualBinding(contract, control);
|
|
@@ -55,10 +56,17 @@ function validateExpectedAssertions(control, check, unknownPrefix) {
|
|
|
55
56
|
if (!assertions.has(key))
|
|
56
57
|
throw new Error(`${unknownPrefix}:${key}`);
|
|
57
58
|
const failures = new Set(control.expected_assertion_failures);
|
|
59
|
+
const preserved = new Set(control.preserved_assertions);
|
|
58
60
|
for (const key of control.preserved_assertions) {
|
|
59
61
|
if (!assertions.has(key))
|
|
60
62
|
throw new Error(`${unknownPrefix}:${key}`);
|
|
61
63
|
if (failures.has(key))
|
|
62
64
|
throw new Error(`counterfactual_preserved_assertion_conflict:${unknownPrefix}:${key}`);
|
|
63
65
|
}
|
|
66
|
+
for (const key of control.allowed_fanout_assertions) {
|
|
67
|
+
if (!assertions.has(key))
|
|
68
|
+
throw new Error(`${unknownPrefix}:${key}`);
|
|
69
|
+
if (failures.has(key) || preserved.has(key))
|
|
70
|
+
throw new Error(`counterfactual_fanout_assertion_conflict:${unknownPrefix}:${key}`);
|
|
71
|
+
}
|
|
64
72
|
}
|
|
@@ -24,6 +24,7 @@ export async function createCounterfactualSandbox(snapshotRoot, check, control,
|
|
|
24
24
|
const exactPaths = new Set([
|
|
25
25
|
...Object.keys(check.runner.frozen_files),
|
|
26
26
|
...Object.keys(check.verification_input_hashes),
|
|
27
|
+
...(check.process_runtime_closure?.allowed_runtime_files ?? []),
|
|
27
28
|
check.runner.resolved_target,
|
|
28
29
|
...(control.mutation.type === "replace_file"
|
|
29
30
|
? [control.mutation.fixture_path]
|
|
@@ -24,6 +24,7 @@ export interface CounterfactualControlV2 {
|
|
|
24
24
|
mutation: CounterfactualMutationV2;
|
|
25
25
|
expected_assertion_failures: string[];
|
|
26
26
|
preserved_assertions: string[];
|
|
27
|
+
allowed_fanout_assertions: string[];
|
|
27
28
|
}
|
|
28
29
|
export interface GlobalCounterfactualControlV2 {
|
|
29
30
|
key: string;
|
|
@@ -33,4 +34,5 @@ export interface GlobalCounterfactualControlV2 {
|
|
|
33
34
|
mutation: CounterfactualMutationV2;
|
|
34
35
|
expected_assertion_failures: string[];
|
|
35
36
|
preserved_assertions: string[];
|
|
37
|
+
allowed_fanout_assertions: string[];
|
|
36
38
|
}
|
|
@@ -86,6 +86,8 @@ export async function compileDeliveryContract(workdirInput, projectRootInput = p
|
|
|
86
86
|
verification_inputs: check.verification_input_hashes,
|
|
87
87
|
raw_execution_identity: check.raw_execution_identity,
|
|
88
88
|
evidence_adapter: check.evidence_adapter,
|
|
89
|
+
observation_authorities: check.observation_authorities,
|
|
90
|
+
process_runtime_closure: check.process_runtime_closure,
|
|
89
91
|
})),
|
|
90
92
|
}));
|
|
91
93
|
let authorityRevision = options.authority_revision ?? previous?.authority_revision ?? 1;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { CompiledCheckV2, DeliveryContractV2, EvidenceCapabilityRecordV2, LongTaskFindingV2 } from "./long-task-delivery-types.js";
|
|
1
|
+
import type { CompiledCheckV2, DeliveryContractV2, EvidenceCapabilityRecordV2, LongTaskFindingV2, RawCommandExecutionV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import { type PreparedAdmittedObservationSet } from "./long-task-admitted-observation.js";
|
|
2
3
|
export { decodeEvidenceCapabilityRecords } from "./long-task-evidence-capability-codec.js";
|
|
3
4
|
type Reporter = (message: string) => void;
|
|
4
5
|
export declare function validateEvidenceCapabilityDeclarations(contract: DeliveryContractV2, report?: Reporter): void;
|
|
5
|
-
export declare function evaluateEvidenceCapabilities(check: CompiledCheckV2, records: EvidenceCapabilityRecordV2[], artifactHashes: Record<string, string
|
|
6
|
+
export declare function evaluateEvidenceCapabilities(check: CompiledCheckV2, records: EvidenceCapabilityRecordV2[], artifactHashes: Record<string, string>, admittedObservations?: PreparedAdmittedObservationSet, rawExecution?: RawCommandExecutionV2): {
|
|
6
7
|
complete: Record<string, boolean>;
|
|
7
8
|
findings: LongTaskFindingV2[];
|
|
8
9
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { validateRuntimeEvidenceRecord } from "./long-task-evidence-capability-runtime.js";
|
|
2
2
|
import { validateDistinctSemanticFactEvidence } from "./long-task-semantic-fact-evidence.js";
|
|
3
3
|
import { checkFinding } from "./long-task-evidence-findings.js";
|
|
4
|
+
import { admittedObservationAuthorityKey, } from "./long-task-admitted-observation.js";
|
|
4
5
|
export { decodeEvidenceCapabilityRecords } from "./long-task-evidence-capability-codec.js";
|
|
5
6
|
export function validateEvidenceCapabilityDeclarations(contract, report) {
|
|
6
7
|
const targets = new Map(contract.task.execution_targets.map((target) => [target.key, target]));
|
|
@@ -100,7 +101,7 @@ function validateJourneySeparation(contract, report) {
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
|
-
export function evaluateEvidenceCapabilities(check, records, artifactHashes) {
|
|
104
|
+
export function evaluateEvidenceCapabilities(check, records, artifactHashes, admittedObservations, rawExecution) {
|
|
104
105
|
const runtimeRecords = records ?? [];
|
|
105
106
|
const complete = {};
|
|
106
107
|
const findings = [];
|
|
@@ -129,15 +130,22 @@ export function evaluateEvidenceCapabilities(check, records, artifactHashes) {
|
|
|
129
130
|
for (const assertion of assertions) {
|
|
130
131
|
let assertionComplete = true;
|
|
131
132
|
for (const capability of assertion.evidence_capabilities) {
|
|
132
|
-
if (capability === "presence")
|
|
133
|
-
continue;
|
|
134
133
|
const matches = runtimeRecords.filter((record) => record.assertion_key === assertion.key &&
|
|
135
134
|
record.capability === capability);
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
const derived = packageDerivedCapability(check, assertion.key, capability, admittedObservations, rawExecution);
|
|
136
|
+
const submittedReason = matches.length === 1
|
|
137
|
+
? validateRuntimeEvidenceRecord(check, matches[0], artifactHashes, admittedObservations, rawExecution?.host_execution_attestation ?? null)
|
|
138
|
+
: matches.length > 1
|
|
139
|
+
? "record_duplicate"
|
|
140
|
+
: null;
|
|
141
|
+
const reason = submittedReason ??
|
|
142
|
+
(derived.supported
|
|
143
|
+
? derived.reason
|
|
144
|
+
: capability === "presence"
|
|
145
|
+
? null
|
|
146
|
+
: matches.length === 0
|
|
147
|
+
? "record_missing"
|
|
148
|
+
: null);
|
|
141
149
|
if (!reason)
|
|
142
150
|
continue;
|
|
143
151
|
assertionComplete = false;
|
|
@@ -149,6 +157,22 @@ export function evaluateEvidenceCapabilities(check, records, artifactHashes) {
|
|
|
149
157
|
actual: reason,
|
|
150
158
|
});
|
|
151
159
|
}
|
|
160
|
+
const authorityIssues = assertionObservationAuthorityIssues(check, assertion.key, assertion.claims.length > 0, admittedObservations);
|
|
161
|
+
if (authorityIssues.length) {
|
|
162
|
+
assertionComplete = false;
|
|
163
|
+
for (const authorityIssue of authorityIssues) {
|
|
164
|
+
findings.push({
|
|
165
|
+
...checkFinding(check, "evidence_capability_invalid", `Assertion ${assertion.key} has no complete package-admitted current-Actual chain for ${authorityIssue.obligation_ref ?? "an unplanned machine obligation"}: ${authorityIssue.reason}.`, "Bind every machine-closing or liveness-preserving obligation to its compiled package observation authority, or move unsupported observation to an explicit blocking External Confirmation."),
|
|
166
|
+
assertion_key: assertion.key,
|
|
167
|
+
claim_keys: assertion.claims,
|
|
168
|
+
expected: {
|
|
169
|
+
authority: authorityIssue.authority,
|
|
170
|
+
obligation_ref: authorityIssue.obligation_ref,
|
|
171
|
+
},
|
|
172
|
+
actual: authorityIssue.reason,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
152
176
|
complete[assertion.key] = assertionComplete;
|
|
153
177
|
}
|
|
154
178
|
validateDistinctDesignMethodArtifacts(check, runtimeRecords, artifactHashes, findings);
|
|
@@ -159,8 +183,90 @@ export function evaluateEvidenceCapabilities(check, records, artifactHashes) {
|
|
|
159
183
|
expected: "unique_fact_proof_and_artifact_locator_identity",
|
|
160
184
|
actual: semanticDistinctness,
|
|
161
185
|
});
|
|
186
|
+
for (const entry of admittedObservations?.entries ?? [])
|
|
187
|
+
if (!entry.authority_key && entry.reason)
|
|
188
|
+
findings.push({
|
|
189
|
+
...checkFinding(check, "evidence_capability_invalid", `A package observation was not bound to the compiled observation plan: ${entry.identity_ref}:${entry.reason}.`, "Emit only the exact identity set selected by the Harness-owned compiled observation plan."),
|
|
190
|
+
expected: "compiled_observation_identity",
|
|
191
|
+
actual: entry.identity_ref,
|
|
192
|
+
});
|
|
162
193
|
return { complete, findings };
|
|
163
194
|
}
|
|
195
|
+
function packageDerivedCapability(check, assertionKey, capability, admitted, raw) {
|
|
196
|
+
const authorities = (check.observation_authorities ?? []).filter((authority) => authority.assertion_ref === assertionKey);
|
|
197
|
+
const supported = capability === "presence" ||
|
|
198
|
+
capability === "semantic_fact" ||
|
|
199
|
+
capability === "design_method" ||
|
|
200
|
+
capability === "target_runtime";
|
|
201
|
+
if (!supported || !authorities.length)
|
|
202
|
+
return { supported: false, reason: null };
|
|
203
|
+
for (const authority of authorities) {
|
|
204
|
+
if (authority.authority === "external_confirmation")
|
|
205
|
+
return {
|
|
206
|
+
supported: true,
|
|
207
|
+
reason: "unsupported_observer_requires_external_confirmation",
|
|
208
|
+
};
|
|
209
|
+
const prepared = admitted?.by_authority_key.get(admittedObservationAuthorityKey(authority));
|
|
210
|
+
if (!prepared)
|
|
211
|
+
return { supported: true, reason: "admitted_observation_missing" };
|
|
212
|
+
if (prepared.reason)
|
|
213
|
+
return { supported: true, reason: prepared.reason };
|
|
214
|
+
if (!prepared.observation || !prepared.comparison)
|
|
215
|
+
return { supported: true, reason: "admitted_observation_missing" };
|
|
216
|
+
}
|
|
217
|
+
const processRequired = capability === "target_runtime" ||
|
|
218
|
+
authorities.some((authority) => authority.authority === "package_process_json_exact");
|
|
219
|
+
if (processRequired) {
|
|
220
|
+
const attestation = raw?.host_execution_attestation;
|
|
221
|
+
if (!attestation)
|
|
222
|
+
return { supported: true, reason: "host_attestation_required" };
|
|
223
|
+
if (!attestation.direct_root_match ||
|
|
224
|
+
attestation.raw_execution_identity !== check.raw_execution_identity ||
|
|
225
|
+
!attestation.snapshot_sha256 ||
|
|
226
|
+
!check.process_runtime_closure ||
|
|
227
|
+
attestation.process_runtime_closure_identity !==
|
|
228
|
+
check.process_runtime_closure.closure_identity ||
|
|
229
|
+
attestation.exit_code !== 0 ||
|
|
230
|
+
attestation.exit_code !== raw?.exit_code)
|
|
231
|
+
return { supported: true, reason: "host_attestation_mismatch" };
|
|
232
|
+
}
|
|
233
|
+
return { supported: true, reason: null };
|
|
234
|
+
}
|
|
235
|
+
function assertionObservationAuthorityIssues(check, assertionKey, machineClosing, admitted) {
|
|
236
|
+
const authorities = (check.observation_authorities ?? []).filter((authority) => authority.assertion_ref === assertionKey);
|
|
237
|
+
if (!authorities.length)
|
|
238
|
+
return machineClosing
|
|
239
|
+
? [
|
|
240
|
+
{
|
|
241
|
+
obligation_ref: null,
|
|
242
|
+
authority: null,
|
|
243
|
+
reason: "machine_observer_not_admitted",
|
|
244
|
+
},
|
|
245
|
+
]
|
|
246
|
+
: [];
|
|
247
|
+
const issues = [];
|
|
248
|
+
for (const authority of authorities) {
|
|
249
|
+
let reason = null;
|
|
250
|
+
if (authority.authority === "external_confirmation")
|
|
251
|
+
reason = "unsupported_observer_requires_external_confirmation";
|
|
252
|
+
else if (!admitted)
|
|
253
|
+
reason = "admitted_observation_runtime_required";
|
|
254
|
+
else {
|
|
255
|
+
const authorityKey = admittedObservationAuthorityKey(authority);
|
|
256
|
+
const prepared = admitted.by_authority_key.get(authorityKey);
|
|
257
|
+
reason =
|
|
258
|
+
prepared?.reason ??
|
|
259
|
+
(prepared?.observation ? null : "admitted_observation_missing");
|
|
260
|
+
}
|
|
261
|
+
if (reason)
|
|
262
|
+
issues.push({
|
|
263
|
+
obligation_ref: authority.obligation_ref,
|
|
264
|
+
authority: authority.authority,
|
|
265
|
+
reason,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return issues;
|
|
269
|
+
}
|
|
164
270
|
function validateDistinctDesignMethodArtifacts(check, records, artifactHashes, findings) {
|
|
165
271
|
const pathOwners = new Map();
|
|
166
272
|
const digestOwners = new Map();
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import type { CompiledCheckV2, EvidenceCapabilityRecordV2 } from "./long-task-delivery-types.js";
|
|
2
|
-
|
|
1
|
+
import type { CompiledCheckV2, EvidenceCapabilityRecordV2, HostExecutionAttestationV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import { evaluateExactDigestComparison, exactComparisonResultIdentity } from "./long-task-exact-comparison.js";
|
|
3
|
+
import { type PreparedAdmittedObservationSet } from "./long-task-admitted-observation.js";
|
|
4
|
+
export { evaluateExactDigestComparison, exactComparisonResultIdentity };
|
|
5
|
+
export declare function validateRuntimeEvidenceRecord(check: CompiledCheckV2, record: EvidenceCapabilityRecordV2, artifactHashes: Record<string, string>, admittedObservations?: PreparedAdmittedObservationSet, hostAttestation?: HostExecutionAttestationV2 | null): string | null;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { evaluateExactDigestComparison, exactComparisonResultIdentity, } from "./long-task-exact-comparison.js";
|
|
2
|
+
import { admittedObservationAuthorityKey, isJsonPointerExactOracle, resolveObservationAuthority, } from "./long-task-admitted-observation.js";
|
|
1
3
|
import { validateSemanticFactEvidence } from "./long-task-semantic-fact-evidence.js";
|
|
2
|
-
export
|
|
4
|
+
export { evaluateExactDigestComparison, exactComparisonResultIdentity };
|
|
5
|
+
export function validateRuntimeEvidenceRecord(check, record, artifactHashes, admittedObservations, hostAttestation = null) {
|
|
6
|
+
const admittedObservationIssue = validateAdmittedObservationRecord(check, record, admittedObservations);
|
|
7
|
+
if (admittedObservationIssue)
|
|
8
|
+
return admittedObservationIssue;
|
|
3
9
|
switch (record.capability) {
|
|
4
10
|
case "interaction_trace":
|
|
5
|
-
return validateInteractionTrace(check, record);
|
|
11
|
+
return validateInteractionTrace(check, record, hostAttestation);
|
|
6
12
|
case "state_delta":
|
|
7
13
|
if (record.before_sha256 === record.after_sha256)
|
|
8
14
|
return "state_unchanged";
|
|
@@ -35,11 +41,81 @@ export function validateRuntimeEvidenceRecord(check, record, artifactHashes) {
|
|
|
35
41
|
case "semantic_fact":
|
|
36
42
|
return validateSemanticFactEvidence(check, record, artifactHashes);
|
|
37
43
|
case "target_runtime":
|
|
38
|
-
return validateTargetRuntime(check, record);
|
|
44
|
+
return validateTargetRuntime(check, record, hostAttestation);
|
|
39
45
|
case "input_variation":
|
|
40
46
|
return validateInputVariation(record);
|
|
41
47
|
}
|
|
42
48
|
}
|
|
49
|
+
function validateAdmittedObservationRecord(check, record, admitted) {
|
|
50
|
+
if (record.capability === "semantic_fact" &&
|
|
51
|
+
record.observer_results.length > 0)
|
|
52
|
+
return "semantic_fact_machine_observer_not_admitted";
|
|
53
|
+
const candidates = runtimeAdmittedObservationCandidates(record);
|
|
54
|
+
for (const candidate of candidates) {
|
|
55
|
+
if (!isJsonPointerExactOracle(candidate.oracle))
|
|
56
|
+
return "custom_oracle_machine_completion_forbidden";
|
|
57
|
+
const authorityResolution = resolveObservationAuthority(check, {
|
|
58
|
+
assertion_key: record.assertion_key,
|
|
59
|
+
identity_ref: candidate.identity_ref,
|
|
60
|
+
method: record.capability === "semantic_fact" ||
|
|
61
|
+
record.capability === "design_method"
|
|
62
|
+
? record.method
|
|
63
|
+
: "exact_value",
|
|
64
|
+
});
|
|
65
|
+
if (!authorityResolution.authority)
|
|
66
|
+
return authorityResolution.reason;
|
|
67
|
+
if (authorityResolution.authority.authority === "external_confirmation")
|
|
68
|
+
return "unsupported_observer_requires_external_confirmation";
|
|
69
|
+
if (!admitted)
|
|
70
|
+
return "admitted_observation_runtime_required";
|
|
71
|
+
const key = admittedObservationAuthorityKey(authorityResolution.authority);
|
|
72
|
+
const prepared = admitted.by_authority_key.get(key);
|
|
73
|
+
if (!prepared ||
|
|
74
|
+
prepared.obligation_ref !== authorityResolution.authority.obligation_ref)
|
|
75
|
+
return "admitted_observation_missing";
|
|
76
|
+
if (prepared.reason)
|
|
77
|
+
return prepared.reason;
|
|
78
|
+
if (!prepared.observation)
|
|
79
|
+
return "admitted_observation_missing";
|
|
80
|
+
if (authorityResolution.authority.authority === "package_static_json_exact" &&
|
|
81
|
+
(prepared.observation.artifact_path !==
|
|
82
|
+
candidate.actual_observation.artifact_path ||
|
|
83
|
+
prepared.observation.artifact_sha256 !==
|
|
84
|
+
candidate.actual_observation.artifact_sha256))
|
|
85
|
+
return "admitted_observation_artifact_mismatch";
|
|
86
|
+
if (candidate.actual_observation.locator.kind !== "json_pointer" ||
|
|
87
|
+
candidate.actual_observation.locator.value !==
|
|
88
|
+
authorityResolution.authority.locator_policy.value)
|
|
89
|
+
return "observation_locator_identity_mismatch";
|
|
90
|
+
if (prepared.observation.value_sha256 !==
|
|
91
|
+
candidate.actual_observation.value_sha256)
|
|
92
|
+
return "admitted_observation_value_mismatch";
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
function runtimeAdmittedObservationCandidates(record) {
|
|
97
|
+
if (record.capability === "semantic_fact")
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
identity_ref: record.fact_ref,
|
|
101
|
+
actual_observation: record.actual_observation,
|
|
102
|
+
oracle: record.oracle,
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
if (record.capability !== "design_method")
|
|
106
|
+
return [];
|
|
107
|
+
return "fact_model" in record
|
|
108
|
+
? record.rule_results.map((result) => ({
|
|
109
|
+
identity_ref: result.obligation_ref,
|
|
110
|
+
actual_observation: result.actual_observation,
|
|
111
|
+
oracle: result.oracle,
|
|
112
|
+
}))
|
|
113
|
+
: record.cells.flatMap((cell) => cell.fact_results.map((result) => ({
|
|
114
|
+
identity_ref: result.fact_ref,
|
|
115
|
+
actual_observation: result.actual_observation,
|
|
116
|
+
oracle: result.oracle,
|
|
117
|
+
})));
|
|
118
|
+
}
|
|
43
119
|
function validateDesignMethod(check, record, artifactHashes) {
|
|
44
120
|
return "fact_model" in record
|
|
45
121
|
? validateSymbolicDesignMethod(check, record, artifactHashes)
|
|
@@ -111,6 +187,9 @@ function validateGroundCellResults(cell, expectedCell, artifactHashes) {
|
|
|
111
187
|
const artifactIssue = validateGroundFactArtifacts(result, expectation, cell, artifactHashes);
|
|
112
188
|
if (artifactIssue)
|
|
113
189
|
return artifactIssue;
|
|
190
|
+
const exactIssue = validateGroundExactComparison(result);
|
|
191
|
+
if (exactIssue)
|
|
192
|
+
return exactIssue;
|
|
114
193
|
const actualIdentity = `${result.actual_observation.artifact_path}\0${canonicalJson(result.actual_observation.locator)}`;
|
|
115
194
|
if (actualIdentities.has(actualIdentity))
|
|
116
195
|
return "design_method_actual_observation_reused";
|
|
@@ -124,6 +203,28 @@ function validateGroundCellResults(cell, expectedCell, artifactHashes) {
|
|
|
124
203
|
}
|
|
125
204
|
return null;
|
|
126
205
|
}
|
|
206
|
+
function validateGroundExactComparison(result) {
|
|
207
|
+
if (result.comparison.comparator !== "exact_value" ||
|
|
208
|
+
result.comparison.mode !== "exact")
|
|
209
|
+
return null;
|
|
210
|
+
if (result.comparison.tolerance !== null || result.comparison.mask !== null)
|
|
211
|
+
return "design_method_comparison_authority_mismatch";
|
|
212
|
+
const recomputed = evaluateExactDigestComparison({
|
|
213
|
+
identity: {
|
|
214
|
+
kind: "selected_design_ground_v1",
|
|
215
|
+
fact_ref: result.fact_ref,
|
|
216
|
+
subject_ref: result.subject_ref,
|
|
217
|
+
variation_ref: result.variation_ref,
|
|
218
|
+
property_ref: result.property_ref,
|
|
219
|
+
},
|
|
220
|
+
...exactComparisonMaterial(result),
|
|
221
|
+
});
|
|
222
|
+
if (!recomputed.passed)
|
|
223
|
+
return "design_method_exact_value_mismatch";
|
|
224
|
+
return result.comparison.result_sha256 === recomputed.result_sha256
|
|
225
|
+
? null
|
|
226
|
+
: "design_method_comparison_result_identity_mismatch";
|
|
227
|
+
}
|
|
127
228
|
function validateGroundFactIdentity(result, expectation) {
|
|
128
229
|
if (result.subject_ref !== expectation.subject_ref ||
|
|
129
230
|
result.variation_ref !== expectation.variation_ref ||
|
|
@@ -220,6 +321,9 @@ function validateSymbolicRuleResults(binding, record, artifactHashes) {
|
|
|
220
321
|
const artifactIssue = validateSymbolicResultArtifacts(result, expectation, record, artifactHashes);
|
|
221
322
|
if (artifactIssue)
|
|
222
323
|
return artifactIssue;
|
|
324
|
+
const exactIssue = validateSymbolicExactComparison(result);
|
|
325
|
+
if (exactIssue)
|
|
326
|
+
return exactIssue;
|
|
223
327
|
const actualIdentity = `${result.actual_observation.artifact_path}\0${canonicalJson(result.actual_observation.locator)}`;
|
|
224
328
|
if (actualIdentities.has(actualIdentity))
|
|
225
329
|
return "design_symbolic_method_actual_observation_reused";
|
|
@@ -233,6 +337,42 @@ function validateSymbolicRuleResults(binding, record, artifactHashes) {
|
|
|
233
337
|
}
|
|
234
338
|
return null;
|
|
235
339
|
}
|
|
340
|
+
function validateSymbolicExactComparison(result) {
|
|
341
|
+
if (result.comparison.comparator !== "exact_value" ||
|
|
342
|
+
result.comparison.mode !== "exact")
|
|
343
|
+
return null;
|
|
344
|
+
if (result.comparison.tolerance !== null || result.comparison.mask !== null)
|
|
345
|
+
return "design_symbolic_method_comparison_authority_mismatch";
|
|
346
|
+
const recomputed = evaluateExactDigestComparison({
|
|
347
|
+
identity: {
|
|
348
|
+
kind: "selected_design_symbolic_v2",
|
|
349
|
+
obligation_ref: result.obligation_ref,
|
|
350
|
+
fact_rule_ref: result.fact_rule_ref,
|
|
351
|
+
region_sha256: result.region_sha256,
|
|
352
|
+
subject_or_relation_ref: result.subject_or_relation_ref,
|
|
353
|
+
property_ref: result.property_ref,
|
|
354
|
+
population_ref: result.population_ref,
|
|
355
|
+
quantifier: result.quantifier,
|
|
356
|
+
},
|
|
357
|
+
...exactComparisonMaterial(result),
|
|
358
|
+
});
|
|
359
|
+
if (!recomputed.passed)
|
|
360
|
+
return "design_symbolic_method_exact_value_mismatch";
|
|
361
|
+
return result.comparison.result_sha256 === recomputed.result_sha256
|
|
362
|
+
? null
|
|
363
|
+
: "design_symbolic_method_comparison_result_identity_mismatch";
|
|
364
|
+
}
|
|
365
|
+
function exactComparisonMaterial(result) {
|
|
366
|
+
return {
|
|
367
|
+
actual_value_sha256: result.actual_observation.value_sha256,
|
|
368
|
+
expected_value_sha256: result.expected.sha256,
|
|
369
|
+
comparator: result.comparison.comparator,
|
|
370
|
+
mode: result.comparison.mode,
|
|
371
|
+
parameters_sha256: result.comparison.parameters.sha256,
|
|
372
|
+
tolerance_sha256: result.comparison.tolerance?.sha256 ?? null,
|
|
373
|
+
mask_sha256: result.comparison.mask?.sha256 ?? null,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
236
376
|
function validateSymbolicResultIdentity(result, expectation) {
|
|
237
377
|
if (result.fact_rule_ref !== expectation.fact_rule_ref ||
|
|
238
378
|
result.region_sha256 !== expectation.region_sha256 ||
|
|
@@ -381,7 +521,9 @@ function designTargetUsesAssertion(target, assertionKey) {
|
|
|
381
521
|
target.verification_method_bindings.some((item) => item.assertion_ref === assertionKey) ||
|
|
382
522
|
(target.symbolic_method_bindings ?? []).some((item) => item.assertion_ref === assertionKey));
|
|
383
523
|
}
|
|
384
|
-
function validateInteractionTrace(check, record) {
|
|
524
|
+
function validateInteractionTrace(check, record, hostAttestation) {
|
|
525
|
+
if (!hostAttestation?.direct_root_match)
|
|
526
|
+
return "legacy_interaction_trace_non_authoritative";
|
|
385
527
|
if (record.target_ref !== check.execution_target.target_ref)
|
|
386
528
|
return "target_mismatch";
|
|
387
529
|
if (!same(record.given_keys, check.scenario.given.map((step) => step.key)))
|
|
@@ -410,7 +552,9 @@ function validateObserverEvidence(check, observerTargetRef) {
|
|
|
410
552
|
return "check_must_execute_on_observer";
|
|
411
553
|
return null;
|
|
412
554
|
}
|
|
413
|
-
function validateTargetRuntime(check, record) {
|
|
555
|
+
function validateTargetRuntime(check, record, hostAttestation) {
|
|
556
|
+
if (!hostAttestation?.direct_root_match)
|
|
557
|
+
return "legacy_target_runtime_non_authoritative";
|
|
414
558
|
if (record.target_ref !== check.execution_target.target_ref)
|
|
415
559
|
return "target_mismatch";
|
|
416
560
|
if (record.root_entrypoint !== check.execution_target_definition.root_entrypoint)
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { CompiledCheckV2, CompiledOutcomeV2, DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function validateCounterfactualObservationImpact(input: {
|
|
3
|
+
baseline_by_fact: Record<string, string>;
|
|
4
|
+
mutated_by_fact: Record<string, string>;
|
|
5
|
+
expected_affected_fact_refs: string[];
|
|
6
|
+
preserved_fact_refs: string[];
|
|
7
|
+
allowed_fanout_fact_refs?: string[];
|
|
8
|
+
target_live: boolean;
|
|
9
|
+
carrier_role: "product" | "evidence";
|
|
10
|
+
}): string | null;
|
|
2
11
|
export declare function validateClaimEvidenceSensitivity(contract: DeliveryContractV2, globalChecks: CompiledCheckV2[], outcomes: CompiledOutcomeV2[], report?: ValidationReporter): void;
|
|
3
12
|
type ValidationReporter = (message: string) => void;
|
|
4
13
|
export {};
|
|
@@ -6,6 +6,37 @@ const NON_RESULT_SENSITIVITY_PREFIXES = [
|
|
|
6
6
|
"non_completing.",
|
|
7
7
|
"forbidden_shortcut.",
|
|
8
8
|
];
|
|
9
|
+
export function validateCounterfactualObservationImpact(input) {
|
|
10
|
+
if (input.carrier_role === "evidence")
|
|
11
|
+
return "counterfactual_mutates_generated_evidence";
|
|
12
|
+
if (!input.target_live)
|
|
13
|
+
return "counterfactual_target_not_live";
|
|
14
|
+
const expected = new Set(input.expected_affected_fact_refs);
|
|
15
|
+
const preserved = new Set(input.preserved_fact_refs);
|
|
16
|
+
const allowedFanout = new Set(input.allowed_fanout_fact_refs ?? []);
|
|
17
|
+
for (const factRef of expected) {
|
|
18
|
+
if (!Object.hasOwn(input.baseline_by_fact, factRef) ||
|
|
19
|
+
!Object.hasOwn(input.mutated_by_fact, factRef))
|
|
20
|
+
return "counterfactual_expected_fact_observation_missing";
|
|
21
|
+
if (input.baseline_by_fact[factRef] === input.mutated_by_fact[factRef])
|
|
22
|
+
return "counterfactual_expected_fact_unchanged";
|
|
23
|
+
}
|
|
24
|
+
for (const factRef of new Set([
|
|
25
|
+
...Object.keys(input.baseline_by_fact),
|
|
26
|
+
...Object.keys(input.mutated_by_fact),
|
|
27
|
+
])) {
|
|
28
|
+
if (expected.has(factRef) || allowedFanout.has(factRef))
|
|
29
|
+
continue;
|
|
30
|
+
const baseline = input.baseline_by_fact[factRef];
|
|
31
|
+
const mutated = input.mutated_by_fact[factRef];
|
|
32
|
+
if (preserved.has(factRef) &&
|
|
33
|
+
(baseline === undefined || mutated === undefined || baseline !== mutated))
|
|
34
|
+
return "counterfactual_unexpected_fact_impact";
|
|
35
|
+
if (!preserved.has(factRef) && baseline !== mutated)
|
|
36
|
+
return "counterfactual_unexpected_fact_impact";
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
9
40
|
export function validateClaimEvidenceSensitivity(contract, globalChecks, outcomes, report) {
|
|
10
41
|
validateGlobalStructuredSensitivity(contract, globalChecks, report);
|
|
11
42
|
validateGlobalSemanticWitnesses(contract, globalChecks, report);
|
|
@@ -62,7 +93,6 @@ function isNarrowSemanticMutation(type) {
|
|
|
62
93
|
}
|
|
63
94
|
function isBehavioralAssertion(check, assertion) {
|
|
64
95
|
return !(check.proof_surface === "implementation_structure" &&
|
|
65
|
-
assertion.operator === "exists" &&
|
|
66
96
|
assertion.evidence_capabilities.every((capability) => capability === "presence"));
|
|
67
97
|
}
|
|
68
98
|
function isLivenessAssertion(check, reference) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CheckExecutionResultV2, CompiledCheckV2, CompiledDeliveryContractV2, CompiledOutcomeV2, LongTaskFindingV2, RawCommandExecutionV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
2
|
-
export declare function evaluateCheckEvidence(check: CompiledCheckV2, raw: RawCommandExecutionV2, snapshotRoot: string, outcome?: CompiledOutcomeV2): Promise<CheckExecutionResultV2>;
|
|
3
|
-
export declare function evaluateOutcomeCounterfactuals(outcome: CompiledOutcomeV2, snapshotRoot: string, manifest?: WorkspaceManifestV2, protectedAuthorityPaths?: readonly string[]): Promise<LongTaskFindingV2[]>;
|
|
4
|
-
export declare function evaluateGlobalCounterfactuals(compiled: CompiledDeliveryContractV2, snapshotRoot: string, selectedCheckKeys?: ReadonlySet<string>, manifest?: WorkspaceManifestV2): Promise<LongTaskFindingV2[]>;
|
|
5
|
-
export declare function isValidCounterfactualCheckResult(result: CheckExecutionResultV2, expectedAssertionFailures: string[]): boolean;
|
|
2
|
+
export declare function evaluateCheckEvidence(check: CompiledCheckV2, raw: RawCommandExecutionV2, snapshotRoot: string, outcome?: CompiledOutcomeV2, observationAuthorityPaths?: readonly string[]): Promise<CheckExecutionResultV2>;
|
|
3
|
+
export declare function evaluateOutcomeCounterfactuals(outcome: CompiledOutcomeV2, snapshotRoot: string, manifest?: WorkspaceManifestV2, protectedAuthorityPaths?: readonly string[], baselineResults?: readonly CheckExecutionResultV2[], baselineExecutions?: ReadonlyMap<string, RawCommandExecutionV2>, executionUniverse?: readonly CompiledCheckV2[]): Promise<LongTaskFindingV2[]>;
|
|
4
|
+
export declare function evaluateGlobalCounterfactuals(compiled: CompiledDeliveryContractV2, snapshotRoot: string, selectedCheckKeys?: ReadonlySet<string>, manifest?: WorkspaceManifestV2, baselineResults?: readonly CheckExecutionResultV2[], baselineExecutions?: ReadonlyMap<string, RawCommandExecutionV2>, executionUniverse?: readonly CompiledCheckV2[]): Promise<LongTaskFindingV2[]>;
|
|
5
|
+
export declare function isValidCounterfactualCheckResult(result: CheckExecutionResultV2, expectedAssertionFailures: string[], allowedFanoutAssertions?: string[]): boolean;
|