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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { CompiledCheckV2, CompiledObservationAuthorityV2, EvidenceCapabilityRecordV2, PackageObservationValueV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import { type ExactDigestComparisonResult } from "./long-task-exact-comparison.js";
|
|
3
|
+
import { JSON_POINTER_EXACT_CAPABILITY, type JsonPointerExactLocator, type JsonPointerExactObservation } from "./long-task-json-pointer-observation.js";
|
|
4
|
+
export { JSON_POINTER_EXACT_CAPABILITY, JSON_POINTER_EXACT_LIMITS, JSON_POINTER_EXACT_METHODS, JSON_POINTER_EXACT_ORACLE_IDENTITY, JSON_POINTER_EXACT_ORACLE_VERSION, JSON_POINTER_EXACT_SPEC_SHA256, createJsonPointerExactBudget, extractJsonPointerExactObservationFromBytes, isJsonPointerExactOracle, } from "./long-task-json-pointer-observation.js";
|
|
5
|
+
export type { JsonPointerExactBudget, JsonPointerExactLocator, JsonPointerExactObservation, } from "./long-task-json-pointer-observation.js";
|
|
6
|
+
export { extractJsonPointerExactObservation } from "./long-task-observation-artifact.js";
|
|
7
|
+
export interface PreparedAdmittedObservation {
|
|
8
|
+
assertion_key: string;
|
|
9
|
+
identity_ref: string;
|
|
10
|
+
authority_key: string | null;
|
|
11
|
+
obligation_ref: string | null;
|
|
12
|
+
method: string;
|
|
13
|
+
observation_key: string;
|
|
14
|
+
authority: CompiledObservationAuthorityV2["authority"] | null;
|
|
15
|
+
raw_value: unknown;
|
|
16
|
+
observation: JsonPointerExactObservation | null;
|
|
17
|
+
comparison: ExactDigestComparisonResult | null;
|
|
18
|
+
reason: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface PreparedAdmittedObservationSet {
|
|
21
|
+
readonly by_observation_key: ReadonlyMap<string, PreparedAdmittedObservation>;
|
|
22
|
+
readonly by_authority_key: ReadonlyMap<string, PreparedAdmittedObservation>;
|
|
23
|
+
readonly entries: readonly PreparedAdmittedObservation[];
|
|
24
|
+
}
|
|
25
|
+
export declare function prepareAdmittedObservations(input: {
|
|
26
|
+
check: CompiledCheckV2;
|
|
27
|
+
records: EvidenceCapabilityRecordV2[];
|
|
28
|
+
snapshot_root: string;
|
|
29
|
+
authority_paths?: readonly string[];
|
|
30
|
+
package_observations?: readonly PackageObservationValueV2[];
|
|
31
|
+
}): Promise<PreparedAdmittedObservationSet>;
|
|
32
|
+
export declare function admittedObservationAuthorityKey(authority: Pick<CompiledObservationAuthorityV2, "assertion_ref" | "obligation_ref" | "method">): string;
|
|
33
|
+
export declare function resolveObservationAuthority(check: CompiledCheckV2, candidate: {
|
|
34
|
+
assertion_key: string;
|
|
35
|
+
identity_ref: string;
|
|
36
|
+
method: string;
|
|
37
|
+
}): {
|
|
38
|
+
authority: CompiledObservationAuthorityV2;
|
|
39
|
+
reason: null;
|
|
40
|
+
} | {
|
|
41
|
+
authority: null;
|
|
42
|
+
reason: string;
|
|
43
|
+
};
|
|
44
|
+
export declare function admittedObservationKey(artifactPath: string, locator: JsonPointerExactLocator): string;
|
|
45
|
+
export declare function jsonPointerExactLocatorForIdentity(identity: string): {
|
|
46
|
+
kind: "json_pointer";
|
|
47
|
+
value: string;
|
|
48
|
+
};
|
|
49
|
+
export type ObservationCarrierRole = "expected_authority_forbidden" | "product_carrier" | "current_observer_artifact" | "unadmitted_evidence";
|
|
50
|
+
export type MachineObservationCarrierRoleConflict = "expected_authority" | "evidence_role";
|
|
51
|
+
export declare function classifyMachineObservationCarrierRoleConflict(input: {
|
|
52
|
+
carrier_pattern: string;
|
|
53
|
+
expected_authority_patterns: readonly string[];
|
|
54
|
+
evidence_role_patterns: readonly string[];
|
|
55
|
+
}): MachineObservationCarrierRoleConflict | null;
|
|
56
|
+
export declare function classifyObservationCarrier(input: {
|
|
57
|
+
artifact_path: string;
|
|
58
|
+
source_paths: string[];
|
|
59
|
+
expected_authority_paths: string[];
|
|
60
|
+
product_carrier_paths: string[];
|
|
61
|
+
current_observer_artifact_paths: string[];
|
|
62
|
+
}): ObservationCarrierRole;
|
|
63
|
+
export interface ObservationAdmissionInput {
|
|
64
|
+
method: string;
|
|
65
|
+
comparator: string;
|
|
66
|
+
mode: string;
|
|
67
|
+
tolerance: unknown;
|
|
68
|
+
mask: unknown;
|
|
69
|
+
sensitivity: string;
|
|
70
|
+
locator: JsonPointerExactLocator;
|
|
71
|
+
oracle: {
|
|
72
|
+
trust?: string;
|
|
73
|
+
identity?: string;
|
|
74
|
+
version?: string;
|
|
75
|
+
sha256?: string | null;
|
|
76
|
+
};
|
|
77
|
+
target_family: string;
|
|
78
|
+
observed_target_family?: string;
|
|
79
|
+
required_method?: string;
|
|
80
|
+
current_static_artifact: boolean;
|
|
81
|
+
historical_session?: boolean;
|
|
82
|
+
snapshot_matches?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export type ObservationAdmissionDecision = {
|
|
85
|
+
authority: "machine";
|
|
86
|
+
reason: null;
|
|
87
|
+
capability: typeof JSON_POINTER_EXACT_CAPABILITY;
|
|
88
|
+
} | {
|
|
89
|
+
authority: "external_confirmation";
|
|
90
|
+
reason: string;
|
|
91
|
+
capability: null;
|
|
92
|
+
};
|
|
93
|
+
export declare function observationAdmissionDecision(input: ObservationAdmissionInput): ObservationAdmissionDecision;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { classifyRepositoryPatternOverlap, matchesRepoPattern, } from "./long-task-paths.js";
|
|
2
|
+
import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
|
|
3
|
+
import { evaluateExactDigestComparison, } from "./long-task-exact-comparison.js";
|
|
4
|
+
import { JSON_POINTER_EXACT_CAPABILITY, JSON_POINTER_EXACT_METHODS, isJsonPointerExactOracle, normalizeObservationArtifactPath, validateJsonPointerExactLocator, } from "./long-task-json-pointer-observation.js";
|
|
5
|
+
export { JSON_POINTER_EXACT_CAPABILITY, JSON_POINTER_EXACT_LIMITS, JSON_POINTER_EXACT_METHODS, JSON_POINTER_EXACT_ORACLE_IDENTITY, JSON_POINTER_EXACT_ORACLE_VERSION, JSON_POINTER_EXACT_SPEC_SHA256, createJsonPointerExactBudget, extractJsonPointerExactObservationFromBytes, isJsonPointerExactOracle, } from "./long-task-json-pointer-observation.js";
|
|
6
|
+
export { extractJsonPointerExactObservation } from "./long-task-observation-artifact.js";
|
|
7
|
+
export async function prepareAdmittedObservations(input) {
|
|
8
|
+
const entries = [];
|
|
9
|
+
const entriesByAuthority = new Map();
|
|
10
|
+
for (const authority of input.check.observation_authorities ?? []) {
|
|
11
|
+
const authorityKey = admittedObservationAuthorityKey(authority);
|
|
12
|
+
const candidates = (input.package_observations ?? []).filter((candidate) => candidate.authority === authority.authority &&
|
|
13
|
+
candidate.observation_identity === authority.observation_identity &&
|
|
14
|
+
candidate.assertion_ref === authority.assertion_ref &&
|
|
15
|
+
candidate.obligation_ref === authority.obligation_ref &&
|
|
16
|
+
candidate.method === authority.method);
|
|
17
|
+
const candidate = candidates.length === 1 ? candidates[0] : null;
|
|
18
|
+
let reason = null;
|
|
19
|
+
let comparison = null;
|
|
20
|
+
if (authority.authority === "external_confirmation")
|
|
21
|
+
reason = "unsupported_observer_requires_external_confirmation";
|
|
22
|
+
else if (candidates.length > 1)
|
|
23
|
+
reason = "admitted_observation_duplicate";
|
|
24
|
+
else if (!candidate)
|
|
25
|
+
reason =
|
|
26
|
+
authority.authority === "package_process_json_exact"
|
|
27
|
+
? "admitted_observation_runtime_required"
|
|
28
|
+
: "admitted_observation_missing";
|
|
29
|
+
else if (candidate.reason)
|
|
30
|
+
reason = candidate.reason;
|
|
31
|
+
else if (!candidate.observation)
|
|
32
|
+
reason = "admitted_observation_missing";
|
|
33
|
+
else if (candidate.observation.locator.kind !== "json_pointer" ||
|
|
34
|
+
candidate.observation.locator.value !== authority.locator_policy.value)
|
|
35
|
+
reason = "observation_locator_identity_mismatch";
|
|
36
|
+
else {
|
|
37
|
+
try {
|
|
38
|
+
comparison = evaluateExactDigestComparison({
|
|
39
|
+
identity: {
|
|
40
|
+
kind: "compiled_observation_authority",
|
|
41
|
+
expected_identity: authority.expected_identity,
|
|
42
|
+
obligation_ref: authority.obligation_ref,
|
|
43
|
+
observation_identity: authority.observation_identity,
|
|
44
|
+
target_ref: authority.target_ref,
|
|
45
|
+
method: authority.method,
|
|
46
|
+
},
|
|
47
|
+
actual_value_sha256: projectedActualValueSha256(authority, candidate),
|
|
48
|
+
expected_value_sha256: authority.expected_value_sha256,
|
|
49
|
+
comparator: authority.comparison.comparator,
|
|
50
|
+
mode: authority.comparison.mode,
|
|
51
|
+
parameters_sha256: authority.comparison.parameters_sha256 ?? "",
|
|
52
|
+
tolerance_sha256: authority.comparison.tolerance_sha256,
|
|
53
|
+
mask_sha256: authority.comparison.mask_sha256,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
reason = error instanceof Error ? error.message : String(error);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const entry = {
|
|
61
|
+
assertion_key: authority.assertion_ref,
|
|
62
|
+
identity_ref: authority.observation_identity,
|
|
63
|
+
authority_key: authorityKey,
|
|
64
|
+
obligation_ref: authority.obligation_ref,
|
|
65
|
+
method: authority.method,
|
|
66
|
+
observation_key: candidate?.observation
|
|
67
|
+
? admittedObservationKey(candidate.observation.artifact_path, candidate.observation.locator)
|
|
68
|
+
: `compiled-authority\0${authorityKey}`,
|
|
69
|
+
authority: authority.authority,
|
|
70
|
+
raw_value: candidate?.raw_value,
|
|
71
|
+
observation: candidate?.observation ?? null,
|
|
72
|
+
comparison,
|
|
73
|
+
reason,
|
|
74
|
+
};
|
|
75
|
+
entries.push(entry);
|
|
76
|
+
entriesByAuthority.set(authorityKey, entry);
|
|
77
|
+
}
|
|
78
|
+
for (const candidate of input.package_observations ?? []) {
|
|
79
|
+
const matches = (input.check.observation_authorities ?? []).filter((authority) => authority.authority === candidate.authority &&
|
|
80
|
+
authority.observation_identity === candidate.observation_identity &&
|
|
81
|
+
authority.assertion_ref === candidate.assertion_ref &&
|
|
82
|
+
authority.obligation_ref === candidate.obligation_ref &&
|
|
83
|
+
authority.method === candidate.method);
|
|
84
|
+
if (matches.length)
|
|
85
|
+
continue;
|
|
86
|
+
entries.push({
|
|
87
|
+
assertion_key: "",
|
|
88
|
+
identity_ref: candidate.observation_identity,
|
|
89
|
+
authority_key: null,
|
|
90
|
+
obligation_ref: null,
|
|
91
|
+
method: "exact_value",
|
|
92
|
+
observation_key: candidate.observation
|
|
93
|
+
? admittedObservationKey(candidate.observation.artifact_path, candidate.observation.locator)
|
|
94
|
+
: `unbound-package-observation\0${candidate.observation_identity}`,
|
|
95
|
+
authority: null,
|
|
96
|
+
raw_value: candidate.raw_value,
|
|
97
|
+
observation: candidate.observation,
|
|
98
|
+
comparison: null,
|
|
99
|
+
reason: "machine_observer_not_admitted",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
by_observation_key: new Map(entries.map((entry) => [entry.observation_key, entry])),
|
|
104
|
+
by_authority_key: entriesByAuthority,
|
|
105
|
+
entries,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function projectedActualValueSha256(authority, candidate) {
|
|
109
|
+
if (!candidate.observation)
|
|
110
|
+
throw new Error("admitted_observation_missing");
|
|
111
|
+
if (authority.actual_projection === "raw_exact")
|
|
112
|
+
return candidate.observation.value_sha256;
|
|
113
|
+
const projected = authority.actual_projection === "presence_boolean"
|
|
114
|
+
? true
|
|
115
|
+
: Boolean(candidate.raw_value);
|
|
116
|
+
return sha256Hex(canonicalValueJson(projected));
|
|
117
|
+
}
|
|
118
|
+
export function admittedObservationAuthorityKey(authority) {
|
|
119
|
+
return `${authority.assertion_ref}\0${authority.obligation_ref}\0${authority.method}`;
|
|
120
|
+
}
|
|
121
|
+
export function resolveObservationAuthority(check, candidate) {
|
|
122
|
+
const matches = (check.observation_authorities ?? []).filter((authority) => authority.assertion_ref === candidate.assertion_key &&
|
|
123
|
+
authority.method === candidate.method &&
|
|
124
|
+
authority.observation_identity === candidate.identity_ref);
|
|
125
|
+
if (matches.length === 1)
|
|
126
|
+
return { authority: matches[0], reason: null };
|
|
127
|
+
return {
|
|
128
|
+
authority: null,
|
|
129
|
+
reason: matches.length === 0
|
|
130
|
+
? "machine_observer_not_admitted"
|
|
131
|
+
: "machine_observer_authority_ambiguous",
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export function admittedObservationKey(artifactPath, locator) {
|
|
135
|
+
return `${artifactPath}\0${canonicalValueJson(locator)}`;
|
|
136
|
+
}
|
|
137
|
+
export function jsonPointerExactLocatorForIdentity(identity) {
|
|
138
|
+
return {
|
|
139
|
+
kind: "json_pointer",
|
|
140
|
+
value: `/observations/${identity.replace(/~/gu, "~0").replace(/\//gu, "~1")}`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function classifyMachineObservationCarrierRoleConflict(input) {
|
|
144
|
+
if (input.expected_authority_patterns.some((pattern) => classifyRepositoryPatternOverlap(input.carrier_pattern, pattern)
|
|
145
|
+
.status === "proven_overlap"))
|
|
146
|
+
return "expected_authority";
|
|
147
|
+
if (input.evidence_role_patterns.some((pattern) => classifyRepositoryPatternOverlap(input.carrier_pattern, pattern)
|
|
148
|
+
.status === "proven_overlap"))
|
|
149
|
+
return "evidence_role";
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
export function classifyObservationCarrier(input) {
|
|
153
|
+
const artifactPath = normalizeObservationArtifactPath(input.artifact_path);
|
|
154
|
+
if (matchesAny(artifactPath, input.source_paths) ||
|
|
155
|
+
matchesAny(artifactPath, input.expected_authority_paths))
|
|
156
|
+
return "expected_authority_forbidden";
|
|
157
|
+
if (matchesAny(artifactPath, input.product_carrier_paths))
|
|
158
|
+
return "product_carrier";
|
|
159
|
+
if (matchesAny(artifactPath, input.current_observer_artifact_paths))
|
|
160
|
+
return "current_observer_artifact";
|
|
161
|
+
return "unadmitted_evidence";
|
|
162
|
+
}
|
|
163
|
+
export function observationAdmissionDecision(input) {
|
|
164
|
+
if (input.observed_target_family !== undefined &&
|
|
165
|
+
input.observed_target_family !== input.target_family)
|
|
166
|
+
return external("observation_target_proxy_mismatch");
|
|
167
|
+
if (input.required_method && input.required_method !== input.method)
|
|
168
|
+
return external("observation_capability_mismatch");
|
|
169
|
+
if (input.target_family !== "process" ||
|
|
170
|
+
input.historical_session === true ||
|
|
171
|
+
!input.current_static_artifact ||
|
|
172
|
+
input.snapshot_matches === false)
|
|
173
|
+
return external("observation_current_static_target_required");
|
|
174
|
+
if (!isJsonPointerExactOracle(input.oracle))
|
|
175
|
+
return external("observation_oracle_not_admitted");
|
|
176
|
+
if (!JSON_POINTER_EXACT_METHODS.some((method) => method === input.method) ||
|
|
177
|
+
input.comparator !== "exact_value" ||
|
|
178
|
+
input.mode !== "exact" ||
|
|
179
|
+
input.tolerance !== null ||
|
|
180
|
+
input.mask !== null)
|
|
181
|
+
return external("observation_method_not_admitted");
|
|
182
|
+
if (input.sensitivity !== "plain")
|
|
183
|
+
return external("observation_protected_requires_frozen_adapter");
|
|
184
|
+
try {
|
|
185
|
+
validateJsonPointerExactLocator(input.locator);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return external("observation_locator_not_admitted");
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
authority: "machine",
|
|
192
|
+
reason: null,
|
|
193
|
+
capability: JSON_POINTER_EXACT_CAPABILITY,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function external(reason) {
|
|
197
|
+
return { authority: "external_confirmation", reason, capability: null };
|
|
198
|
+
}
|
|
199
|
+
function matchesAny(candidate, patterns) {
|
|
200
|
+
return patterns.some((pattern) => matchesRepoPattern(candidate, pattern));
|
|
201
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CompiledCheckV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export { JSON_POINTER_EXACT_CAPABILITY, JSON_POINTER_EXACT_LIMITS, JSON_POINTER_EXACT_METHODS, JSON_POINTER_EXACT_ORACLE_IDENTITY, JSON_POINTER_EXACT_ORACLE_VERSION, JSON_POINTER_EXACT_SPEC_SHA256, admittedObservationKey, classifyObservationCarrier, createJsonPointerExactBudget, extractJsonPointerExactObservation, extractJsonPointerExactObservationFromBytes, isJsonPointerExactOracle, jsonPointerExactLocatorForIdentity, observationAdmissionDecision, prepareAdmittedObservations, } from "./long-task-admitted-observation.js";
|
|
2
3
|
export declare function collectCheckArtifacts(check: CompiledCheckV2, snapshotRoot: string): Promise<{
|
|
3
4
|
hashes: Record<string, string>;
|
|
4
5
|
errors: string[];
|
|
@@ -2,6 +2,7 @@ import { readFile, readdir } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { matchesRepoPattern } from "./long-task-paths.js";
|
|
4
4
|
import { sha256Hex } from "./strict-codec.js";
|
|
5
|
+
export { JSON_POINTER_EXACT_CAPABILITY, JSON_POINTER_EXACT_LIMITS, JSON_POINTER_EXACT_METHODS, JSON_POINTER_EXACT_ORACLE_IDENTITY, JSON_POINTER_EXACT_ORACLE_VERSION, JSON_POINTER_EXACT_SPEC_SHA256, admittedObservationKey, classifyObservationCarrier, createJsonPointerExactBudget, extractJsonPointerExactObservation, extractJsonPointerExactObservationFromBytes, isJsonPointerExactOracle, jsonPointerExactLocatorForIdentity, observationAdmissionDecision, prepareAdmittedObservations, } from "./long-task-admitted-observation.js";
|
|
5
6
|
export async function collectCheckArtifacts(check, snapshotRoot) {
|
|
6
7
|
if (!check.artifact_globs.length)
|
|
7
8
|
return { hashes: {}, errors: [] };
|
|
@@ -120,6 +120,7 @@ function flattenProductSemantics(projection) {
|
|
|
120
120
|
fields.set(`${prefix}.role`, target.role);
|
|
121
121
|
fields.set(`${prefix}.runtime_family`, target.runtime_family);
|
|
122
122
|
fields.set(`${prefix}.root_entrypoint`, target.root_entrypoint);
|
|
123
|
+
fields.set(`${prefix}.root_argv`, target.root_argv ?? null);
|
|
123
124
|
}
|
|
124
125
|
for (const stage of projection.stages) {
|
|
125
126
|
const prefix = `stages.${stage.key}`;
|
|
@@ -271,6 +271,7 @@ export declare const AUTHORITY_FIELD_POLICY_REGISTRIES: {
|
|
|
271
271
|
mutation: "proof_additive";
|
|
272
272
|
expected_assertion_failures: "proof_additive";
|
|
273
273
|
preserved_assertions: "proof_additive";
|
|
274
|
+
allowed_fanout_assertions: "semantic_user_review";
|
|
274
275
|
};
|
|
275
276
|
readonly global_counterfactual: {
|
|
276
277
|
key: "identity";
|
|
@@ -280,6 +281,7 @@ export declare const AUTHORITY_FIELD_POLICY_REGISTRIES: {
|
|
|
280
281
|
mutation: "proof_additive";
|
|
281
282
|
expected_assertion_failures: "proof_additive";
|
|
282
283
|
preserved_assertions: "proof_additive";
|
|
284
|
+
allowed_fanout_assertions: "semantic_user_review";
|
|
283
285
|
};
|
|
284
286
|
};
|
|
285
287
|
export declare function projectFieldsByPolicy<T extends object>(value: T, policy: Record<keyof T, AuthorityFieldPolicy>, included: ReadonlySet<AuthorityFieldPolicy>): Partial<T>;
|
|
@@ -254,6 +254,7 @@ const COUNTERFACTUAL_AUTHORITY_POLICY = {
|
|
|
254
254
|
mutation: "proof_additive",
|
|
255
255
|
expected_assertion_failures: "proof_additive",
|
|
256
256
|
preserved_assertions: "proof_additive",
|
|
257
|
+
allowed_fanout_assertions: "semantic_user_review",
|
|
257
258
|
};
|
|
258
259
|
const GLOBAL_COUNTERFACTUAL_AUTHORITY_POLICY = {
|
|
259
260
|
key: "identity",
|
|
@@ -263,6 +264,7 @@ const GLOBAL_COUNTERFACTUAL_AUTHORITY_POLICY = {
|
|
|
263
264
|
mutation: "proof_additive",
|
|
264
265
|
expected_assertion_failures: "proof_additive",
|
|
265
266
|
preserved_assertions: "proof_additive",
|
|
267
|
+
allowed_fanout_assertions: "semantic_user_review",
|
|
266
268
|
};
|
|
267
269
|
export const AUTHORITY_FIELD_POLICY_REGISTRIES = {
|
|
268
270
|
task: TASK_AUTHORITY_POLICY,
|
|
@@ -154,7 +154,9 @@ function counterfactualCoveragePreserved(previous, next) {
|
|
|
154
154
|
candidate.check_key === previous.check_key &&
|
|
155
155
|
same(candidate.mutation, previous.mutation) &&
|
|
156
156
|
includesEvery(candidate.claims, previous.claims) &&
|
|
157
|
-
includesEvery(candidate.expected_assertion_failures, previous.expected_assertion_failures)
|
|
157
|
+
includesEvery(candidate.expected_assertion_failures, previous.expected_assertion_failures) &&
|
|
158
|
+
includesEvery(candidate.preserved_assertions ?? [], previous.preserved_assertions ?? []) &&
|
|
159
|
+
includesEvery(previous.allowed_fanout_assertions ?? [], candidate.allowed_fanout_assertions ?? []));
|
|
158
160
|
}
|
|
159
161
|
function includesEvery(values, required) {
|
|
160
162
|
const available = new Set(values);
|
|
@@ -180,7 +180,8 @@ function counterfactualsStrengthened(previous, next) {
|
|
|
180
180
|
same(candidate.mutation, control.mutation) &&
|
|
181
181
|
subset(control.claims, candidate.claims) &&
|
|
182
182
|
subset(control.expected_assertion_failures, candidate.expected_assertion_failures) &&
|
|
183
|
-
subset(control.preserved_assertions, candidate.preserved_assertions)
|
|
183
|
+
subset(control.preserved_assertions, candidate.preserved_assertions) &&
|
|
184
|
+
subset(candidate.allowed_fanout_assertions ?? [], control.allowed_fanout_assertions ?? [])));
|
|
184
185
|
}
|
|
185
186
|
function subset(previous, next) {
|
|
186
187
|
const available = new Set(next.map((item) => canonicalValueJson(item)));
|
|
@@ -21,6 +21,11 @@ export function rawExecutionInputProjection(check) {
|
|
|
21
21
|
projection.known_execution_targets = check.known_execution_targets;
|
|
22
22
|
projection.design_conformance_targets =
|
|
23
23
|
check.design_conformance_targets ?? [];
|
|
24
|
+
projection.package_observation_protocol = (check.observation_authorities ?? []).some((authority) => authority.authority === "package_process_json_exact")
|
|
25
|
+
? "ty-context-product-observation-v1"
|
|
26
|
+
: null;
|
|
27
|
+
projection.process_runtime_closure_identity =
|
|
28
|
+
check.process_runtime_closure?.closure_identity ?? null;
|
|
24
29
|
for (const field of Object.keys(CHECK_EXECUTION_INPUT_POLICY)) {
|
|
25
30
|
const policy = CHECK_EXECUTION_INPUT_POLICY[field];
|
|
26
31
|
if (policy === "raw_execution") {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CompiledCheckV2, RawCommandExecutionV2 } from "./long-task-delivery-types.js";
|
|
2
|
-
export declare function executeCheckRunner(check: CompiledCheckV2, snapshotRoot: string): Promise<RawCommandExecutionV2>;
|
|
1
|
+
import type { CompiledCheckV2, CheckRunnerExecutionContextV2, RawCommandExecutionV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function executeCheckRunner(check: CompiledCheckV2, snapshotRoot: string, context?: CheckRunnerExecutionContextV2): Promise<RawCommandExecutionV2>;
|