project-tiny-context-harness 0.8.4 → 0.8.6
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/LICENSE +21 -21
- package/README.md +394 -363
- package/assets/README.md +570 -514
- package/assets/README.zh-CN.md +331 -300
- package/assets/agents/.gitkeep +1 -1
- package/assets/agents/AGENTS_CORE.md +45 -25
- package/assets/context_templates/architecture.md +26 -25
- package/assets/context_templates/area.md +32 -31
- package/assets/context_templates/context.toml +30 -24
- package/assets/context_templates/deployment.md +35 -35
- package/assets/context_templates/global.md +57 -57
- package/assets/context_templates/product-surface-contract.md +70 -70
- package/assets/context_templates/screen-contract.md +189 -189
- package/assets/context_templates/verification.md +31 -30
- package/assets/github/.gitkeep +1 -1
- package/assets/github/harness.yml +39 -39
- package/assets/make/.gitkeep +1 -1
- package/assets/make/ty-context.mk +48 -48
- package/assets/skills/context_development_engineer/SKILL.md +155 -122
- package/assets/skills/context_full_project_export/SKILL.md +28 -28
- package/assets/skills/context_harness_upgrade/SKILL.md +60 -60
- package/assets/skills/context_product_plan/SKILL.md +99 -79
- package/assets/skills/context_surface_contract/SKILL.md +191 -191
- package/assets/skills/context_uiux_design/SKILL.md +171 -171
- package/assets/skills/design-resource-authoring/SKILL.md +86 -84
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +138 -123
- package/assets/skills/design-resource-authoring/references/open-design-provider.md +132 -127
- package/assets/skills/design-resource-authoring/references/resource-selection.md +181 -154
- package/assets/skills/design-system-authoring/SKILL.md +57 -57
- package/assets/skills/design-system-authoring/agents/openai.yaml +6 -6
- package/assets/skills/design-system-authoring/references/authority-adoption.md +48 -48
- package/assets/skills/design-system-authoring/references/open-design-design-system-provider.md +110 -110
- package/assets/skills/long-task-workflow/SKILL.md +98 -92
- package/assets/skills/long-task-workflow/agents/openai.yaml +3 -1
- package/assets/skills/long-task-workflow/references/authority-lifecycle.md +72 -72
- package/assets/skills/long-task-workflow/references/contract-authoring.md +122 -101
- package/assets/skills/long-task-workflow/references/evidence-design.md +82 -61
- package/assets/skills/long-task-workflow/references/source-authoring.md +109 -90
- package/assets/skills/source-plan-authoring/SKILL.md +14 -14
- package/assets/tools/validate_context.py +442 -442
- package/dist/commands/long-task-authoring.js +27 -2
- package/dist/lib/context-default-footprint.js +2 -0
- package/dist/lib/context-manifest.js +6 -0
- package/dist/lib/context-templates.js +1 -1
- package/dist/lib/design-resource-fact-enums.d.ts +20 -0
- package/dist/lib/design-resource-fact-enums.js +170 -0
- package/dist/lib/design-resource-fact-locator-extractors.d.ts +8 -0
- package/dist/lib/design-resource-fact-locator-extractors.js +108 -0
- package/dist/lib/design-resource-fact-locator-resolver.d.ts +3 -0
- package/dist/lib/design-resource-fact-locator-resolver.js +112 -0
- package/dist/lib/design-resource-fact-locator-validation.d.ts +5 -0
- package/dist/lib/design-resource-fact-locator-validation.js +16 -0
- package/dist/lib/design-resource-fact-manifest-catalog.d.ts +4 -0
- package/dist/lib/design-resource-fact-manifest-catalog.js +249 -0
- package/dist/lib/design-resource-fact-manifest-model.d.ts +91 -0
- package/dist/lib/design-resource-fact-manifest-model.js +21 -0
- package/dist/lib/design-resource-fact-manifest-shape-axes.d.ts +6 -0
- package/dist/lib/design-resource-fact-manifest-shape-axes.js +159 -0
- package/dist/lib/design-resource-fact-manifest-shape-evidence.d.ts +4 -0
- package/dist/lib/design-resource-fact-manifest-shape-evidence.js +59 -0
- package/dist/lib/design-resource-fact-manifest-shape-facts.d.ts +4 -0
- package/dist/lib/design-resource-fact-manifest-shape-facts.js +109 -0
- package/dist/lib/design-resource-fact-manifest-shape-inspector.d.ts +5 -0
- package/dist/lib/design-resource-fact-manifest-shape-inspector.js +144 -0
- package/dist/lib/design-resource-fact-manifest-shape.d.ts +7 -0
- package/dist/lib/design-resource-fact-manifest-shape.js +75 -0
- package/dist/lib/design-resource-fact-manifest-types.d.ts +3 -0
- package/dist/lib/design-resource-fact-manifest-types.js +3 -0
- package/dist/lib/design-resource-fact-manifest-universe.d.ts +5 -0
- package/dist/lib/design-resource-fact-manifest-universe.js +50 -0
- package/dist/lib/design-resource-fact-manifest-validation.d.ts +3 -0
- package/dist/lib/design-resource-fact-manifest-validation.js +106 -0
- package/dist/lib/design-resource-fact-policy.d.ts +18 -0
- package/dist/lib/design-resource-fact-policy.js +72 -1
- package/dist/lib/design-resource-fact-property-methods.d.ts +3 -0
- package/dist/lib/design-resource-fact-property-methods.js +158 -0
- package/dist/lib/design-resource-fact-shape-primitives.d.ts +3 -0
- package/dist/lib/design-resource-fact-shape-primitives.js +18 -0
- package/dist/lib/design-resource-fact-types.d.ts +164 -0
- package/dist/lib/design-resource-fact-types.js +1 -0
- package/dist/lib/design-resource-fact-universe-assets.d.ts +4 -0
- package/dist/lib/design-resource-fact-universe-assets.js +71 -0
- package/dist/lib/design-resource-fact-universe-catalog.d.ts +4 -0
- package/dist/lib/design-resource-fact-universe-catalog.js +151 -0
- package/dist/lib/design-resource-fact-universe-conditions.d.ts +2 -0
- package/dist/lib/design-resource-fact-universe-conditions.js +92 -0
- package/dist/lib/design-resource-fact-universe-facts.d.ts +4 -0
- package/dist/lib/design-resource-fact-universe-facts.js +108 -0
- package/dist/lib/design-resource-fact-universe-helpers.d.ts +30 -0
- package/dist/lib/design-resource-fact-universe-helpers.js +167 -0
- package/dist/lib/design-resource-fact-universe-inspector.d.ts +7 -0
- package/dist/lib/design-resource-fact-universe-inspector.js +119 -0
- package/dist/lib/design-resource-fact-universe-proof.d.ts +4 -0
- package/dist/lib/design-resource-fact-universe-proof.js +113 -0
- package/dist/lib/design-resource-fact-universe-subjects.d.ts +5 -0
- package/dist/lib/design-resource-fact-universe-subjects.js +97 -0
- package/dist/lib/design-resource-fact-universe-variations.d.ts +2 -0
- package/dist/lib/design-resource-fact-universe-variations.js +75 -0
- package/dist/lib/design-resource-fact-value-validation.d.ts +2 -0
- package/dist/lib/design-resource-fact-value-validation.js +80 -0
- package/dist/lib/design-resource-handoff-file-primitives.js +2 -0
- package/dist/lib/design-resource-handoff-file-validation.js +13 -100
- package/dist/lib/design-resource-handoff-policy.d.ts +1 -0
- package/dist/lib/design-resource-handoff-policy.js +118 -11
- package/dist/lib/design-resource-handoff-shape-evidence.js +46 -3
- package/dist/lib/design-resource-handoff-shape-primitives.d.ts +5 -0
- package/dist/lib/design-resource-handoff-shape-primitives.js +28 -0
- package/dist/lib/design-resource-handoff-shape-structure.js +143 -22
- package/dist/lib/design-resource-handoff-shape.js +25 -0
- package/dist/lib/design-resource-handoff-types.d.ts +97 -21
- package/dist/lib/design-resource-handoff-types.js +22 -0
- package/dist/lib/design-resource-handoff-validation-coverage.d.ts +1 -1
- package/dist/lib/design-resource-handoff-validation-coverage.js +145 -118
- package/dist/lib/design-resource-handoff-validation-fact-cells.d.ts +2 -0
- package/dist/lib/design-resource-handoff-validation-fact-cells.js +60 -0
- package/dist/lib/design-resource-handoff-validation-fact-records.d.ts +2 -0
- package/dist/lib/design-resource-handoff-validation-fact-records.js +90 -0
- package/dist/lib/design-resource-handoff-validation-facts.js +10 -94
- package/dist/lib/design-resource-handoff-validation-proofs.d.ts +2 -0
- package/dist/lib/design-resource-handoff-validation-proofs.js +67 -0
- package/dist/lib/design-resource-handoff-validation-resource-closure.d.ts +3 -0
- package/dist/lib/design-resource-handoff-validation-resource-closure.js +88 -0
- package/dist/lib/design-resource-handoff-validation-structure.js +43 -14
- package/dist/lib/design-resource-handoff-validation.js +32 -0
- package/dist/lib/design-resource-handoff-web-dependency-validation.d.ts +2 -1
- package/dist/lib/design-resource-handoff-web-dependency-validation.js +67 -7
- package/dist/lib/execution-target-capabilities.d.ts +1 -1
- package/dist/lib/execution-target-capabilities.js +14 -0
- package/dist/lib/long-task-activation-validation.js +6 -2
- package/dist/lib/long-task-applicability-shape.js +3 -3
- package/dist/lib/long-task-authoring-authority-preview.js +1 -0
- package/dist/lib/long-task-authority-policy.d.ts +1 -0
- package/dist/lib/long-task-authority-policy.js +1 -0
- package/dist/lib/long-task-authority.js +13 -0
- package/dist/lib/long-task-claim-definitions.js +13 -1
- package/dist/lib/long-task-claims.js +23 -1
- package/dist/lib/long-task-contract-types.d.ts +3 -0
- package/dist/lib/long-task-delivery-compiler.js +1 -0
- package/dist/lib/long-task-delivery-parser.js +11 -1
- package/dist/lib/long-task-delivery-types.d.ts +1 -0
- package/dist/lib/long-task-delivery-types.js +1 -0
- package/dist/lib/long-task-delivery-validation.js +17 -0
- package/dist/lib/long-task-design-resource-handoff.js +62 -38
- package/dist/lib/long-task-design-target-capabilities.d.ts +14 -0
- package/dist/lib/long-task-design-target-capabilities.js +126 -0
- package/dist/lib/long-task-evidence-capability-codec.d.ts +94 -0
- package/dist/lib/long-task-evidence-capability-codec.js +395 -22
- package/dist/lib/long-task-evidence-capability-policy.js +18 -0
- package/dist/lib/long-task-evidence-capability-runtime.js +78 -0
- package/dist/lib/long-task-evidence-capability-types.d.ts +114 -1
- package/dist/lib/long-task-outcome-parser.js +4 -0
- package/dist/lib/long-task-playwright-capability-records.d.ts +5 -0
- package/dist/lib/long-task-playwright-capability-records.js +146 -0
- package/dist/lib/long-task-playwright-case-evidence.d.ts +3 -2
- package/dist/lib/long-task-playwright-case-evidence.js +10 -79
- package/dist/lib/long-task-playwright-case-primitives.d.ts +28 -0
- package/dist/lib/long-task-playwright-case-primitives.js +143 -0
- package/dist/lib/long-task-playwright-evidence.d.ts +1 -1
- package/dist/lib/long-task-playwright-evidence.js +10 -75
- package/dist/lib/long-task-runner-freeze.d.ts +2 -2
- package/dist/lib/long-task-runner-freeze.js +15 -1
- package/dist/lib/long-task-runtime-types.d.ts +4 -1
- package/dist/lib/long-task-semantic-contract-types.d.ts +1 -1
- package/dist/lib/long-task-semantic-drift-migration.js +2 -2
- package/dist/lib/long-task-semantic-fact-binding-types.d.ts +57 -0
- package/dist/lib/long-task-semantic-fact-binding-types.js +1 -0
- package/dist/lib/long-task-semantic-fact-closure-primitives.d.ts +5 -0
- package/dist/lib/long-task-semantic-fact-closure-primitives.js +43 -0
- package/dist/lib/long-task-semantic-fact-closure.d.ts +13 -0
- package/dist/lib/long-task-semantic-fact-closure.js +48 -0
- package/dist/lib/long-task-semantic-fact-contract-closure.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-contract-closure.js +24 -0
- package/dist/lib/long-task-semantic-fact-contract-facts.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-contract-facts.js +30 -0
- package/dist/lib/long-task-semantic-fact-contract-proofs.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-contract-proofs.js +97 -0
- package/dist/lib/long-task-semantic-fact-evidence.d.ts +21 -0
- package/dist/lib/long-task-semantic-fact-evidence.js +165 -0
- package/dist/lib/long-task-semantic-fact-input-closure.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-input-closure.js +101 -0
- package/dist/lib/long-task-semantic-fact-provenance-closure.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-provenance-closure.js +140 -0
- package/dist/lib/long-task-semantic-fact-shape.d.ts +3 -0
- package/dist/lib/long-task-semantic-fact-shape.js +89 -0
- package/dist/lib/long-task-semantic-fact-value-closure.d.ts +3 -0
- package/dist/lib/long-task-semantic-fact-value-closure.js +110 -0
- package/dist/lib/long-task-shape-primitives.d.ts +2 -1
- package/dist/lib/long-task-shape-primitives.js +7 -0
- package/dist/lib/long-task-source-item-parser.js +25 -6
- package/dist/lib/long-task-source-target-continuity.js +4 -1
- package/dist/lib/long-task-source-target-index.d.ts +1 -1
- package/dist/lib/long-task-source-target-index.js +5 -1
- package/dist/lib/long-task-ui-design-policy.js +8 -4
- package/dist/lib/long-task-ui-surface-shape.js +83 -1
- package/dist/lib/long-task-ui-surface-types.d.ts +29 -0
- package/dist/lib/modularity.js +7 -1
- package/dist/lib/semantic-fact-base-types.d.ts +14 -0
- package/dist/lib/semantic-fact-base-types.js +1 -0
- package/dist/lib/semantic-fact-catalog.d.ts +8 -0
- package/dist/lib/semantic-fact-catalog.js +191 -0
- package/dist/lib/semantic-fact-condition-shape.d.ts +48 -0
- package/dist/lib/semantic-fact-condition-shape.js +111 -0
- package/dist/lib/semantic-fact-input-shape.d.ts +34 -0
- package/dist/lib/semantic-fact-input-shape.js +111 -0
- package/dist/lib/semantic-fact-inventory-types.d.ts +147 -0
- package/dist/lib/semantic-fact-inventory-types.js +1 -0
- package/dist/lib/semantic-fact-manifest-shape.d.ts +4 -0
- package/dist/lib/semantic-fact-manifest-shape.js +135 -0
- package/dist/lib/semantic-fact-manifest-types.d.ts +58 -0
- package/dist/lib/semantic-fact-manifest-types.js +19 -0
- package/dist/lib/semantic-fact-policy-authority.d.ts +8 -0
- package/dist/lib/semantic-fact-policy-authority.js +79 -0
- package/dist/lib/semantic-fact-policy-census.d.ts +2 -0
- package/dist/lib/semantic-fact-policy-census.js +80 -0
- package/dist/lib/semantic-fact-policy-condition-references.d.ts +7 -0
- package/dist/lib/semantic-fact-policy-condition-references.js +19 -0
- package/dist/lib/semantic-fact-policy-conditions.d.ts +2 -0
- package/dist/lib/semantic-fact-policy-conditions.js +105 -0
- package/dist/lib/semantic-fact-policy-facts.d.ts +3 -0
- package/dist/lib/semantic-fact-policy-facts.js +73 -0
- package/dist/lib/semantic-fact-policy-primitives.d.ts +26 -0
- package/dist/lib/semantic-fact-policy-primitives.js +169 -0
- package/dist/lib/semantic-fact-policy-proofs.d.ts +2 -0
- package/dist/lib/semantic-fact-policy-proofs.js +75 -0
- package/dist/lib/semantic-fact-policy-properties.d.ts +3 -0
- package/dist/lib/semantic-fact-policy-properties.js +84 -0
- package/dist/lib/semantic-fact-policy-units.d.ts +4 -0
- package/dist/lib/semantic-fact-policy-units.js +103 -0
- package/dist/lib/semantic-fact-policy.d.ts +17 -0
- package/dist/lib/semantic-fact-policy.js +41 -0
- package/dist/lib/semantic-fact-proof-shape.d.ts +51 -0
- package/dist/lib/semantic-fact-proof-shape.js +121 -0
- package/dist/lib/semantic-fact-proof-types.d.ts +74 -0
- package/dist/lib/semantic-fact-proof-types.js +1 -0
- package/dist/lib/semantic-fact-property-shape.d.ts +29 -0
- package/dist/lib/semantic-fact-property-shape.js +77 -0
- package/dist/lib/semantic-fact-shape-constants.d.ts +3 -0
- package/dist/lib/semantic-fact-shape-constants.js +38 -0
- package/dist/lib/semantic-fact-shape-primitives.d.ts +15 -0
- package/dist/lib/semantic-fact-shape-primitives.js +68 -0
- package/dist/lib/semantic-fact-source-parser.d.ts +9 -0
- package/dist/lib/semantic-fact-source-parser.js +46 -0
- package/dist/lib/semantic-fact-support-shape.d.ts +21 -0
- package/dist/lib/semantic-fact-support-shape.js +59 -0
- package/dist/lib/semantic-fact-types.d.ts +5 -0
- package/dist/lib/semantic-fact-types.js +5 -0
- package/dist/lib/semantic-fact-unit-shape.d.ts +34 -0
- package/dist/lib/semantic-fact-unit-shape.js +89 -0
- package/dist/lib/semantic-fact-value-shape.d.ts +12 -0
- package/dist/lib/semantic-fact-value-shape.js +39 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +1339 -131
- package/migrations/README.md +15 -15
- package/package.json +84 -84
- package/source-mappings.yaml +25 -25
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { collectCases, declaredCaseIds, duplicateCaseInstance, record, same, } from "./long-task-playwright-case-evidence.js";
|
|
2
|
+
import { evidenceRecordsForPlaywrightCases } from "./long-task-playwright-capability-records.js";
|
|
3
|
+
export { designMethodAttachmentName, semanticFactAttachmentName, } from "./long-task-playwright-capability-records.js";
|
|
2
4
|
export function extractPlaywrightEvidence(check, report, exitCode) {
|
|
3
5
|
const stats = record(report.stats);
|
|
4
6
|
if (!stats)
|
|
@@ -62,78 +64,11 @@ export function extractPlaywrightEvidence(check, report, exitCode) {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
observations["playwright.case_ids"] = cases.map((item) => item.id).sort();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (const item of cases) {
|
|
71
|
-
const assertion = [
|
|
72
|
-
...check.positive_assertions,
|
|
73
|
-
...check.negative_assertions,
|
|
74
|
-
].find((candidate) => candidate.key === item.id);
|
|
75
|
-
if (assertion?.evidence_capabilities.includes("interaction_trace") &&
|
|
76
|
-
item.executed)
|
|
77
|
-
evidenceRecords.push({
|
|
78
|
-
assertion_key: assertion.key,
|
|
79
|
-
capability: "interaction_trace",
|
|
80
|
-
target_ref: check.execution_target.target_ref,
|
|
81
|
-
given_keys: item.given_keys,
|
|
82
|
-
action_keys: item.action_keys,
|
|
83
|
-
});
|
|
84
|
-
if (assertion?.evidence_capabilities.includes("target_runtime") &&
|
|
85
|
-
item.executed)
|
|
86
|
-
evidenceRecords.push({
|
|
87
|
-
assertion_key: assertion.key,
|
|
88
|
-
capability: "target_runtime",
|
|
89
|
-
target_ref: check.execution_target.target_ref,
|
|
90
|
-
root_entrypoint: check.execution_target_definition.root_entrypoint,
|
|
91
|
-
session_id: `playwright:${item.id}:${item.project_ids.join(",")}`,
|
|
92
|
-
cold_start: check.execution_target.entrypoint === "root",
|
|
93
|
-
});
|
|
94
|
-
if (assertion?.evidence_capabilities.includes("design_conformance") &&
|
|
95
|
-
item.executed) {
|
|
96
|
-
for (const target of (check.design_conformance_targets ?? []).filter((candidate) => candidate.conformance_assertion_ref === assertion.key ||
|
|
97
|
-
candidate.verification_method_bindings.some((binding) => binding.assertion_ref === assertion.key)))
|
|
98
|
-
evidenceRecords.push({
|
|
99
|
-
assertion_key: assertion.key,
|
|
100
|
-
capability: "design_conformance",
|
|
101
|
-
design_target_ref: target.key,
|
|
102
|
-
target_ref: target.target_ref,
|
|
103
|
-
condition_keys: target.condition_keys,
|
|
104
|
-
actual_artifact_path: target.actual_artifact_path,
|
|
105
|
-
comparison_artifact_path: target.comparison_artifact_path,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
if (assertion?.evidence_capabilities.includes("design_method") &&
|
|
109
|
-
item.executed) {
|
|
110
|
-
for (const target of check.design_conformance_targets ?? []) {
|
|
111
|
-
const binding = target.verification_method_bindings.find((candidate) => candidate.assertion_ref === assertion.key);
|
|
112
|
-
if (!binding)
|
|
113
|
-
continue;
|
|
114
|
-
const requiredAttachments = binding.evidence_artifacts.flatMap((artifact) => [
|
|
115
|
-
designMethodAttachmentName(target.key, binding.method, artifact.condition_key, "record"),
|
|
116
|
-
designMethodAttachmentName(target.key, binding.method, artifact.condition_key, "observation"),
|
|
117
|
-
]);
|
|
118
|
-
if (!requiredAttachments.every((name) => item.attachment_names.includes(name)))
|
|
119
|
-
continue;
|
|
120
|
-
evidenceRecords.push({
|
|
121
|
-
assertion_key: assertion.key,
|
|
122
|
-
capability: "design_method",
|
|
123
|
-
design_target_ref: target.key,
|
|
124
|
-
target_ref: target.target_ref,
|
|
125
|
-
method: binding.method,
|
|
126
|
-
cells: binding.evidence_artifacts.map((artifact) => ({
|
|
127
|
-
condition_key: artifact.condition_key,
|
|
128
|
-
artifact_path: artifact.path,
|
|
129
|
-
observation_artifact_path: artifact.observation_path,
|
|
130
|
-
fact_refs: artifact.fact_refs,
|
|
131
|
-
})),
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return evidenceRecords;
|
|
67
|
+
return {
|
|
68
|
+
observations,
|
|
69
|
+
evidence_records: evidenceRecordsForPlaywrightCases(check, cases),
|
|
70
|
+
error: null,
|
|
71
|
+
};
|
|
137
72
|
}
|
|
138
73
|
function aggregateCases(instances) {
|
|
139
74
|
const grouped = new Map();
|
|
@@ -197,13 +132,13 @@ function aggregateCases(instances) {
|
|
|
197
132
|
attachment_names: rows.length === 0
|
|
198
133
|
? []
|
|
199
134
|
: rows[0].attachment_names.filter((name) => rows.every((row) => row.attachment_names.includes(name))),
|
|
135
|
+
attachment_payloads: rows.length === 0
|
|
136
|
+
? {}
|
|
137
|
+
: Object.fromEntries(Object.entries(rows[0].attachment_payloads).filter(([name, value]) => rows.every((row) => row.attachment_payloads[name] === value))),
|
|
200
138
|
};
|
|
201
139
|
})
|
|
202
140
|
.sort((left, right) => left.id.localeCompare(right.id));
|
|
203
141
|
}
|
|
204
|
-
export function designMethodAttachmentName(target, method, condition, kind) {
|
|
205
|
-
return `ty-context-design-method:${target}:${method}:${condition}:${kind}`;
|
|
206
|
-
}
|
|
207
142
|
function integer(value) {
|
|
208
143
|
return Number.isInteger(value) && Number(value) >= 0 ? Number(value) : null;
|
|
209
144
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CompiledCheckV2, CompiledDesignTargetV2, DeliveryCheckV2, ExecutionTargetV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
2
|
-
export declare function freezeDeliveryCheck(check: DeliveryCheckV2, outcomeKey: string | null, repository: string, baseline: WorkspaceManifestV2, executionTarget: ExecutionTargetV2, knownExecutionTargets: ExecutionTargetV2[], designConformanceTargets: CompiledDesignTargetV2[]): Promise<CompiledCheckV2>;
|
|
1
|
+
import type { CompiledCheckV2, CompiledDesignTargetV2, DeliveryCheckV2, ExecutionTargetV2, SemanticFactExpectationV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function freezeDeliveryCheck(check: DeliveryCheckV2, outcomeKey: string | null, repository: string, baseline: WorkspaceManifestV2, executionTarget: ExecutionTargetV2, knownExecutionTargets: ExecutionTargetV2[], designConformanceTargets: CompiledDesignTargetV2[], semanticFactExpectations: SemanticFactExpectationV2[]): Promise<CompiledCheckV2>;
|
|
@@ -8,7 +8,7 @@ import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
|
|
|
8
8
|
import { repoRelative, resolveInsideRepository, } from "./long-task-workspace.js";
|
|
9
9
|
import { evidenceAdapterForRunner } from "./long-task-evidence-adapter-policy.js";
|
|
10
10
|
import { freezeLocalVerifierDependencyClosure, packageScriptVerifierRoots, } from "./long-task-verifier-dependency-closure.js";
|
|
11
|
-
export async function freezeDeliveryCheck(check, outcomeKey, repository, baseline, executionTarget, knownExecutionTargets, designConformanceTargets) {
|
|
11
|
+
export async function freezeDeliveryCheck(check, outcomeKey, repository, baseline, executionTarget, knownExecutionTargets, designConformanceTargets, semanticFactExpectations) {
|
|
12
12
|
const prefix = outcomeKey ? `CHECK.${outcomeKey}` : "CHECK.GLOBAL";
|
|
13
13
|
const expectedOutputs = check.expected_output_paths.map((pattern, index) => assertRepositoryPattern(repository, pattern, `${check.key}.expected_output_paths[${index}]`));
|
|
14
14
|
for (const [index, pattern] of check.input_paths.entries()) {
|
|
@@ -24,6 +24,7 @@ export async function freezeDeliveryCheck(check, outcomeKey, repository, baselin
|
|
|
24
24
|
throw new Error(`runner_cwd_not_found:${check.key}:${check.runner.cwd}`);
|
|
25
25
|
const target = await resolvedRunnerTarget(check, repository, cwd);
|
|
26
26
|
const verificationInputHashes = await freezeVerificationInputs(check, repository, baseline, cwd, target);
|
|
27
|
+
validateSemanticFactOracleInputs(check.key, semanticFactExpectations, verificationInputHashes);
|
|
27
28
|
const compiled = {
|
|
28
29
|
...check,
|
|
29
30
|
internal_id: `${prefix}.${check.key}`,
|
|
@@ -34,12 +35,25 @@ export async function freezeDeliveryCheck(check, outcomeKey, repository, baselin
|
|
|
34
35
|
execution_target_definition: executionTarget,
|
|
35
36
|
known_execution_targets: knownExecutionTargets,
|
|
36
37
|
design_conformance_targets: designConformanceTargets,
|
|
38
|
+
semantic_fact_expectations: semanticFactExpectations,
|
|
37
39
|
};
|
|
38
40
|
return {
|
|
39
41
|
...compiled,
|
|
40
42
|
raw_execution_identity: computeRawExecutionIdentity(compiled),
|
|
41
43
|
};
|
|
42
44
|
}
|
|
45
|
+
function validateSemanticFactOracleInputs(checkKey, expectations, verificationInputHashes) {
|
|
46
|
+
const frozenOracles = new Map(expectations
|
|
47
|
+
.filter((expectation) => expectation.oracle.trust === "frozen_executable")
|
|
48
|
+
.map((expectation) => [expectation.oracle.key, expectation.oracle]));
|
|
49
|
+
for (const oracle of frozenOracles.values()) {
|
|
50
|
+
const frozenSha256 = verificationInputHashes[oracle.identity];
|
|
51
|
+
if (!frozenSha256)
|
|
52
|
+
throw new Error(`semantic_fact_oracle_verification_input_missing:${checkKey}:${oracle.key}:${oracle.identity}`);
|
|
53
|
+
if (frozenSha256 !== oracle.sha256)
|
|
54
|
+
throw new Error(`semantic_fact_oracle_verification_input_mismatch:${checkKey}:${oracle.key}:${oracle.identity}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
43
57
|
async function resolvedRunnerTarget(check, repository, cwd) {
|
|
44
58
|
if (check.runner.type === "package_script") {
|
|
45
59
|
const packageFile = await nearestRunnerFile(cwd, repository, "package.json");
|
|
@@ -5,6 +5,7 @@ import type { AuthorityHashesV2, ContextAuthoritySnapshotV2, InitialTaskBaseV2,
|
|
|
5
5
|
import type { EvidenceAdapter } from "./long-task-evidence-adapter-types.js";
|
|
6
6
|
import type { EvidenceCapabilityRecordV2 } from "./long-task-evidence-capability-types.js";
|
|
7
7
|
import type { EffectiveRiskLevel, RiskFactName } from "./long-task-risk-types.js";
|
|
8
|
+
import type { SemanticFactExpectationV2 } from "./semantic-fact-types.js";
|
|
8
9
|
import type { CompiledSourceItemV2 } from "./long-task-source-authority-types.js";
|
|
9
10
|
import type { WorkspaceManifestV2 } from "./long-task-workspace-runtime-types.js";
|
|
10
11
|
export interface FrozenRunnerV2 extends DeliveryRunnerV2 {
|
|
@@ -27,12 +28,13 @@ export interface CompiledCheckV2 extends Omit<DeliveryCheckV2, "runner"> {
|
|
|
27
28
|
execution_target_definition: ExecutionTargetV2;
|
|
28
29
|
known_execution_targets: ExecutionTargetV2[];
|
|
29
30
|
design_conformance_targets: CompiledDesignTargetV2[];
|
|
31
|
+
semantic_fact_expectations: SemanticFactExpectationV2[];
|
|
30
32
|
}
|
|
31
33
|
export interface ProductClaimV2 {
|
|
32
34
|
id: string;
|
|
33
35
|
outcome_key: string;
|
|
34
36
|
local_key: string;
|
|
35
|
-
kind: "result" | "requirement" | "control" | "control_relation" | "non_completing" | "obligation" | "forbidden_shortcut";
|
|
37
|
+
kind: "result" | "requirement" | "control" | "control_relation" | "non_completing" | "obligation" | "semantic_fact" | "forbidden_shortcut";
|
|
36
38
|
required_proof_surfaces: ProofSurface[];
|
|
37
39
|
required_polarity: "positive" | "negative";
|
|
38
40
|
applicability_refs: string[];
|
|
@@ -99,6 +101,7 @@ export interface CompiledDeliveryContractV2 {
|
|
|
99
101
|
authority_materials: NextAuthorityMaterialsV2;
|
|
100
102
|
authority_revision: number;
|
|
101
103
|
claim_coverage: ClaimCoverageSummaryV2;
|
|
104
|
+
semantic_fact_manifest: DeliveryContractV2["semantic_fact_manifest"];
|
|
102
105
|
task: DeliveryContractV2["task"];
|
|
103
106
|
risk: DeliveryContractV2["risk"];
|
|
104
107
|
source_claims: DeliveryContractV2["source_claims"];
|
|
@@ -42,7 +42,7 @@ export interface ClaimApplicabilityV2 {
|
|
|
42
42
|
given_refs: string[];
|
|
43
43
|
when_refs: string[];
|
|
44
44
|
}
|
|
45
|
-
export type EvidenceCapabilityV2 = "presence" | "interaction_trace" | "state_delta" | "cross_surface_consistency" | "durable_readback" | "boundary_invocation" | "external_side_effect" | "failure_injection" | "visual_render" | "design_conformance" | "design_method" | "target_runtime" | "input_variation";
|
|
45
|
+
export type EvidenceCapabilityV2 = "presence" | "interaction_trace" | "state_delta" | "cross_surface_consistency" | "durable_readback" | "boundary_invocation" | "external_side_effect" | "failure_injection" | "visual_render" | "design_conformance" | "design_method" | "semantic_fact" | "target_runtime" | "input_variation";
|
|
46
46
|
export interface CheckExecutionTargetV2 {
|
|
47
47
|
target_ref: string;
|
|
48
48
|
entrypoint: "root" | "internal";
|
|
@@ -3,7 +3,7 @@ export function semanticDriftMigrationFields(value) {
|
|
|
3
3
|
if (!root || root.schema_version !== "long-task-delivery-v2")
|
|
4
4
|
return [];
|
|
5
5
|
const missing = [];
|
|
6
|
-
required(root, "$", ["stages"], missing);
|
|
6
|
+
required(root, "$", ["stages", "semantic_fact_manifest"], missing);
|
|
7
7
|
const task = row(root.task);
|
|
8
8
|
if (task) {
|
|
9
9
|
required(task, "task", ["target_profile", "execution_targets", "context_snapshot_mode"], missing);
|
|
@@ -41,7 +41,7 @@ export function assertNoSemanticDriftMigration(fields) {
|
|
|
41
41
|
throw new Error(`long_task_delivery_v2_semantic_drift_migration_required:${detail}${suffix}`);
|
|
42
42
|
}
|
|
43
43
|
function collectOutcome(outcome, label, missing) {
|
|
44
|
-
required(outcome, label, ["stage", "applicability"], missing);
|
|
44
|
+
required(outcome, label, ["stage", "applicability", "semantic_fact_bindings"], missing);
|
|
45
45
|
collectApplicability(outcome.applicability, `${label}.applicability`, missing);
|
|
46
46
|
const product = row(outcome.product);
|
|
47
47
|
if (product) {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { EvidenceCapabilityV2, ProofSurface } from "./long-task-delivery-types.js";
|
|
2
|
+
import type { SemanticFactLocatedValueV1 } from "./semantic-fact-base-types.js";
|
|
3
|
+
import type { SemanticFactEnvironmentV1, SemanticFactOracleV1, SemanticFactProofObligationV1 } from "./semantic-fact-proof-types.js";
|
|
4
|
+
export interface SemanticFactManifestRefV2 {
|
|
5
|
+
key: string;
|
|
6
|
+
source_path: string;
|
|
7
|
+
sha256: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SemanticFactBindingV2 {
|
|
10
|
+
fact_ref: string;
|
|
11
|
+
claim_ref: string;
|
|
12
|
+
applicability_ref: string;
|
|
13
|
+
}
|
|
14
|
+
export type SemanticFactProofBindingV2 = {
|
|
15
|
+
proof_ref: string;
|
|
16
|
+
fact_ref: string;
|
|
17
|
+
method: string;
|
|
18
|
+
proof_surface: ProofSurface;
|
|
19
|
+
evidence_capabilities: EvidenceCapabilityV2[];
|
|
20
|
+
authority: "machine";
|
|
21
|
+
check_ref: string;
|
|
22
|
+
assertion_ref: string;
|
|
23
|
+
} | {
|
|
24
|
+
proof_ref: string;
|
|
25
|
+
fact_ref: string;
|
|
26
|
+
method: string;
|
|
27
|
+
proof_surface: ProofSurface;
|
|
28
|
+
evidence_capabilities: EvidenceCapabilityV2[];
|
|
29
|
+
authority: "external_confirmation";
|
|
30
|
+
confirmation_ref: string;
|
|
31
|
+
};
|
|
32
|
+
export interface SemanticFactOutcomeBindingsV2 {
|
|
33
|
+
manifest_ref: string;
|
|
34
|
+
facts: SemanticFactBindingV2[];
|
|
35
|
+
proofs: SemanticFactProofBindingV2[];
|
|
36
|
+
}
|
|
37
|
+
export interface SemanticFactExpectationV2 {
|
|
38
|
+
manifest_ref: string;
|
|
39
|
+
manifest_sha256: string;
|
|
40
|
+
fact_ref: string;
|
|
41
|
+
proof_ref: string;
|
|
42
|
+
method: string;
|
|
43
|
+
check_ref: string;
|
|
44
|
+
assertion_ref: string;
|
|
45
|
+
outcome_ref: string;
|
|
46
|
+
claim_ref: string;
|
|
47
|
+
applicability_ref: string;
|
|
48
|
+
subject_ref: string;
|
|
49
|
+
condition_ref: string;
|
|
50
|
+
property_ref: string;
|
|
51
|
+
observation_sensitivity: "plain" | "protected";
|
|
52
|
+
expected: SemanticFactLocatedValueV1;
|
|
53
|
+
comparison: SemanticFactProofObligationV1["comparison"];
|
|
54
|
+
oracle: SemanticFactOracleV1;
|
|
55
|
+
environment: SemanticFactEnvironmentV1;
|
|
56
|
+
observer_refs: string[];
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function resolveSemanticFactPointer(value: unknown, pointer: string, label: string): unknown;
|
|
2
|
+
export declare function uniqueSemanticFactClosureValues(values: string[], label: string): void;
|
|
3
|
+
export declare function sameSemanticFactClosureSet(left: string[], right: string[]): boolean;
|
|
4
|
+
export declare function assertSameSemanticFactClosureSet(left: string[], right: string[], label: string): void;
|
|
5
|
+
export declare function semanticFactClosureInvalid(code: string, detail: unknown): never;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export function resolveSemanticFactPointer(value, pointer, label) {
|
|
2
|
+
if (pointer === "")
|
|
3
|
+
return value;
|
|
4
|
+
if (!pointer.startsWith("/"))
|
|
5
|
+
semanticFactClosureInvalid("located_value_pointer_invalid", `${label}:${pointer}`);
|
|
6
|
+
let current = value;
|
|
7
|
+
for (const segment of pointer
|
|
8
|
+
.slice(1)
|
|
9
|
+
.split("/")
|
|
10
|
+
.map((item) => item.replaceAll("~1", "/").replaceAll("~0", "~"))) {
|
|
11
|
+
if (Array.isArray(current)) {
|
|
12
|
+
if (!/^(0|[1-9][0-9]*)$/u.test(segment))
|
|
13
|
+
semanticFactClosureInvalid("located_value_pointer_invalid", `${label}:${pointer}`);
|
|
14
|
+
current = current[Number(segment)];
|
|
15
|
+
}
|
|
16
|
+
else if (current && typeof current === "object")
|
|
17
|
+
current = current[segment];
|
|
18
|
+
else
|
|
19
|
+
current = undefined;
|
|
20
|
+
if (current === undefined)
|
|
21
|
+
semanticFactClosureInvalid("located_value_pointer_missing", `${label}:${pointer}`);
|
|
22
|
+
}
|
|
23
|
+
return current;
|
|
24
|
+
}
|
|
25
|
+
export function uniqueSemanticFactClosureValues(values, label) {
|
|
26
|
+
if (new Set(values).size !== values.length)
|
|
27
|
+
semanticFactClosureInvalid(`${label}_duplicate`, values.join(","));
|
|
28
|
+
}
|
|
29
|
+
export function sameSemanticFactClosureSet(left, right) {
|
|
30
|
+
return (left.length === right.length &&
|
|
31
|
+
new Set(left).size === left.length &&
|
|
32
|
+
left.every((item) => right.includes(item)));
|
|
33
|
+
}
|
|
34
|
+
export function assertSameSemanticFactClosureSet(left, right, label) {
|
|
35
|
+
if (!sameSemanticFactClosureSet(left, right))
|
|
36
|
+
semanticFactClosureInvalid(label, {
|
|
37
|
+
expected: [...right].sort(),
|
|
38
|
+
actual: [...left].sort(),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function semanticFactClosureInvalid(code, detail) {
|
|
42
|
+
throw new Error(`semantic_fact_closure_invalid:${code}:${typeof detail === "string" ? detail : JSON.stringify(detail)}`);
|
|
43
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CompiledSourceItemV2, DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import { semanticFactCollectionIdentity } from "./semantic-fact-policy.js";
|
|
3
|
+
import type { SemanticFactExpectationV2, SemanticFactManifestV1 } from "./semantic-fact-types.js";
|
|
4
|
+
export interface LongTaskSemanticFactClosureV2 {
|
|
5
|
+
manifest: SemanticFactManifestV1;
|
|
6
|
+
manifest_sha256: string;
|
|
7
|
+
manifest_source_path: string;
|
|
8
|
+
expectations_by_check: Map<string, SemanticFactExpectationV2[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare function validateLongTaskSemanticFactClosure(contract: DeliveryContractV2, repository: string, sourceItems: CompiledSourceItemV2[], contextFiles: string[]): Promise<LongTaskSemanticFactClosureV2>;
|
|
11
|
+
export declare const semantic_fact_manifest = "semantic-fact-manifest-v1";
|
|
12
|
+
export declare const semantic_fact_contract_projection_enabled = true;
|
|
13
|
+
export declare const expected_semantic_fact_universe: typeof semanticFactCollectionIdentity;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { validateSemanticFactContractProjection } from "./long-task-semantic-fact-contract-closure.js";
|
|
2
|
+
import { assertSameSemanticFactClosureSet, semanticFactClosureInvalid, } from "./long-task-semantic-fact-closure-primitives.js";
|
|
3
|
+
import { collectDesignOwnedSemanticFactSourceItems, validateSemanticFactInputInventory, } from "./long-task-semantic-fact-input-closure.js";
|
|
4
|
+
import { validateSemanticFactBasisClosure } from "./long-task-semantic-fact-provenance-closure.js";
|
|
5
|
+
import { validateSemanticFactLocatedValues } from "./long-task-semantic-fact-value-closure.js";
|
|
6
|
+
import { semanticFactCollectionIdentity, validateSemanticFactManifestPolicy, } from "./semantic-fact-policy.js";
|
|
7
|
+
import { loadSemanticFactManifest } from "./semantic-fact-source-parser.js";
|
|
8
|
+
export async function validateLongTaskSemanticFactClosure(contract, repository, sourceItems, contextFiles) {
|
|
9
|
+
const parsed = await loadSemanticFactManifest(repository, contract.task.source_paths);
|
|
10
|
+
const manifest = parsed.manifest;
|
|
11
|
+
const index = validateSemanticFactManifestPolicy(manifest);
|
|
12
|
+
validateManifestReference(contract, parsed);
|
|
13
|
+
const designOwnedSourceItems = await collectDesignOwnedSemanticFactSourceItems(repository, contract.task.source_paths);
|
|
14
|
+
await validateSemanticFactInputInventory(repository, sourceItems, contextFiles, manifest, designOwnedSourceItems);
|
|
15
|
+
validateSemanticFactBasisClosure(manifest, sourceItems);
|
|
16
|
+
await validateSemanticFactLocatedValues(repository, manifest, sourceItems);
|
|
17
|
+
const expectations = validateSemanticFactContractProjection(contract, manifest, index);
|
|
18
|
+
return {
|
|
19
|
+
manifest,
|
|
20
|
+
manifest_sha256: parsed.sha256,
|
|
21
|
+
manifest_source_path: parsed.source_path,
|
|
22
|
+
expectations_by_check: expectations,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function validateManifestReference(contract, parsed) {
|
|
26
|
+
const declared = contract.semantic_fact_manifest;
|
|
27
|
+
if (declared.key !== parsed.manifest.key ||
|
|
28
|
+
declared.source_path !== parsed.source_path ||
|
|
29
|
+
declared.sha256 !== parsed.sha256)
|
|
30
|
+
semanticFactClosureInvalid("manifest_identity_mismatch", {
|
|
31
|
+
expected: declared,
|
|
32
|
+
actual: {
|
|
33
|
+
key: parsed.manifest.key,
|
|
34
|
+
source_path: parsed.source_path,
|
|
35
|
+
sha256: parsed.sha256,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (!contract.task.source_paths.includes(declared.source_path))
|
|
39
|
+
semanticFactClosureInvalid("manifest_source_not_declared", declared.source_path);
|
|
40
|
+
assertSameSemanticFactClosureSet(parsed.manifest.scope.outcome_refs, contract.outcomes.map((item) => item.key), "manifest_outcome_universe");
|
|
41
|
+
for (const outcome of contract.outcomes)
|
|
42
|
+
if (outcome.semantic_fact_bindings.manifest_ref !==
|
|
43
|
+
contract.semantic_fact_manifest.key)
|
|
44
|
+
semanticFactClosureInvalid("outcome_manifest_ref_mismatch", `${outcome.key}:${outcome.semantic_fact_bindings.manifest_ref}`);
|
|
45
|
+
}
|
|
46
|
+
export const semantic_fact_manifest = "semantic-fact-manifest-v1";
|
|
47
|
+
export const semantic_fact_contract_projection_enabled = true;
|
|
48
|
+
export const expected_semantic_fact_universe = semanticFactCollectionIdentity;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import type { SemanticFactManifestIndexV1 } from "./semantic-fact-policy.js";
|
|
3
|
+
import type { SemanticFactExpectationV2, SemanticFactManifestV1 } from "./semantic-fact-types.js";
|
|
4
|
+
export declare function validateSemanticFactContractProjection(contract: DeliveryContractV2, manifest: SemanticFactManifestV1, index: SemanticFactManifestIndexV1): Map<string, SemanticFactExpectationV2[]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { validateSemanticFactOutcomeBindings } from "./long-task-semantic-fact-contract-facts.js";
|
|
2
|
+
import { validateSemanticFactProofBindings } from "./long-task-semantic-fact-contract-proofs.js";
|
|
3
|
+
import { assertSameSemanticFactClosureSet, uniqueSemanticFactClosureValues, } from "./long-task-semantic-fact-closure-primitives.js";
|
|
4
|
+
export function validateSemanticFactContractProjection(contract, manifest, index) {
|
|
5
|
+
const expectations = new Map();
|
|
6
|
+
const allFactBindings = [];
|
|
7
|
+
const allProofBindings = [];
|
|
8
|
+
const targetByRef = new Map(contract.task.execution_targets.map((item) => [item.key, item]));
|
|
9
|
+
for (const outcome of contract.outcomes) {
|
|
10
|
+
const facts = manifest.facts.filter((item) => item.outcome_ref === outcome.key);
|
|
11
|
+
const proofs = manifest.proof_obligations.filter((proof) => facts.some((fact) => fact.key === proof.fact_ref));
|
|
12
|
+
const bindings = outcome.semantic_fact_bindings;
|
|
13
|
+
assertSameSemanticFactClosureSet(bindings.facts.map((item) => item.fact_ref), facts.map((item) => item.key), `contract_fact_set:${outcome.key}`);
|
|
14
|
+
assertSameSemanticFactClosureSet(bindings.proofs.map((item) => item.proof_ref), proofs.map((item) => item.key), `contract_proof_set:${outcome.key}`);
|
|
15
|
+
uniqueSemanticFactClosureValues(bindings.proofs.map((item) => item.authority === "machine"
|
|
16
|
+
? `${item.check_ref}\0${item.assertion_ref}`
|
|
17
|
+
: `external\0${item.confirmation_ref}`), `contract_proof_target:${outcome.key}`);
|
|
18
|
+
validateSemanticFactOutcomeBindings(outcome, manifest, index, allFactBindings);
|
|
19
|
+
validateSemanticFactProofBindings(contract, outcome, manifest, index, targetByRef, expectations, allProofBindings);
|
|
20
|
+
}
|
|
21
|
+
assertSameSemanticFactClosureSet(allFactBindings, manifest.facts.map((item) => item.key), "contract_all_fact_set");
|
|
22
|
+
assertSameSemanticFactClosureSet(allProofBindings, manifest.proof_obligations.map((item) => item.key), "contract_all_proof_set");
|
|
23
|
+
return expectations;
|
|
24
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import type { SemanticFactManifestIndexV1 } from "./semantic-fact-policy.js";
|
|
3
|
+
import type { SemanticFactManifestV1 } from "./semantic-fact-types.js";
|
|
4
|
+
export declare function validateSemanticFactOutcomeBindings(outcome: DeliveryContractV2["outcomes"][number], manifest: SemanticFactManifestV1, index: SemanticFactManifestIndexV1, allFactBindings: string[]): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { semanticFactClosureInvalid, uniqueSemanticFactClosureValues, } from "./long-task-semantic-fact-closure-primitives.js";
|
|
2
|
+
export function validateSemanticFactOutcomeBindings(outcome, manifest, index, allFactBindings) {
|
|
3
|
+
uniqueSemanticFactClosureValues(outcome.semantic_fact_bindings.facts.map((item) => item.claim_ref), `contract_fact_claim:${outcome.key}`);
|
|
4
|
+
const applicabilityRefs = new Set(outcome.applicability.map((item) => item.key));
|
|
5
|
+
for (const binding of outcome.semantic_fact_bindings.facts) {
|
|
6
|
+
const fact = index.fact_by_ref.get(binding.fact_ref);
|
|
7
|
+
const expectedClaim = `semantic_fact.${binding.fact_ref}`;
|
|
8
|
+
if (binding.claim_ref !== expectedClaim)
|
|
9
|
+
semanticFactClosureInvalid("contract_fact_claim_identity_mismatch", `${outcome.key}:${binding.fact_ref}:${binding.claim_ref}:${expectedClaim}`);
|
|
10
|
+
if (!applicabilityRefs.has(binding.applicability_ref))
|
|
11
|
+
semanticFactClosureInvalid("contract_fact_applicability_unknown", `${outcome.key}:${binding.fact_ref}:${binding.applicability_ref}`);
|
|
12
|
+
validateSemanticFactApplicabilityProjection(manifest, fact, outcome.applicability.find((item) => item.key === binding.applicability_ref));
|
|
13
|
+
if (fact.outcome_ref !== outcome.key)
|
|
14
|
+
semanticFactClosureInvalid("contract_fact_outcome_mismatch", `${outcome.key}:${binding.fact_ref}`);
|
|
15
|
+
allFactBindings.push(binding.fact_ref);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function validateSemanticFactApplicabilityProjection(manifest, fact, applicability) {
|
|
19
|
+
const condition = manifest.conditions.find((item) => item.key === fact.condition_ref);
|
|
20
|
+
if (!condition)
|
|
21
|
+
semanticFactClosureInvalid("contract_fact_condition_unknown", `${fact.key}:${fact.condition_ref}`);
|
|
22
|
+
for (const assignment of condition.axis_values) {
|
|
23
|
+
const axis = manifest.axis_dispositions.find((item) => item.key === assignment.axis_ref);
|
|
24
|
+
if (!axis)
|
|
25
|
+
semanticFactClosureInvalid("contract_fact_condition_axis_unknown", `${fact.key}:${assignment.axis_ref}`);
|
|
26
|
+
if (!applicability.dimensions.some((dimension) => dimension.key === axis.axis &&
|
|
27
|
+
dimension.value === assignment.value_ref))
|
|
28
|
+
semanticFactClosureInvalid("contract_fact_applicability_condition_mismatch", `${fact.key}:${applicability.key}:${axis.axis}:${assignment.value_ref}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DeliveryContractV2, ExecutionTargetV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import type { SemanticFactManifestIndexV1 } from "./semantic-fact-policy.js";
|
|
3
|
+
import type { SemanticFactExpectationV2, SemanticFactManifestV1 } from "./semantic-fact-types.js";
|
|
4
|
+
export declare function validateSemanticFactProofBindings(contract: DeliveryContractV2, outcome: DeliveryContractV2["outcomes"][number], manifest: SemanticFactManifestV1, index: SemanticFactManifestIndexV1, targetByRef: Map<string, ExecutionTargetV2>, expectations: Map<string, SemanticFactExpectationV2[]>, allProofBindings: string[]): void;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { sameSemanticFactClosureSet, semanticFactClosureInvalid, } from "./long-task-semantic-fact-closure-primitives.js";
|
|
2
|
+
export function validateSemanticFactProofBindings(contract, outcome, manifest, index, targetByRef, expectations, allProofBindings) {
|
|
3
|
+
for (const binding of outcome.semantic_fact_bindings.proofs) {
|
|
4
|
+
const proof = index.proof_by_ref.get(binding.proof_ref);
|
|
5
|
+
const factBinding = outcome.semantic_fact_bindings.facts.find((item) => item.fact_ref === binding.fact_ref);
|
|
6
|
+
if (!factBinding)
|
|
7
|
+
semanticFactClosureInvalid("contract_proof_fact_binding_missing", `${outcome.key}:${binding.proof_ref}:${binding.fact_ref}`);
|
|
8
|
+
validateProofIdentity(outcome, proof, binding);
|
|
9
|
+
validateObserverTargets(proof, binding, targetByRef);
|
|
10
|
+
if (binding.authority === "external_confirmation")
|
|
11
|
+
validateExternalProofProjection(contract, outcome, binding, factBinding.claim_ref);
|
|
12
|
+
else
|
|
13
|
+
validateMachineProofProjection(contract, outcome, manifest, index, binding, proof, factBinding, expectations);
|
|
14
|
+
allProofBindings.push(binding.proof_ref);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function validateProofIdentity(outcome, proof, binding) {
|
|
18
|
+
if (proof.fact_ref !== binding.fact_ref ||
|
|
19
|
+
proof.method !== binding.method ||
|
|
20
|
+
proof.proof_surface !== binding.proof_surface ||
|
|
21
|
+
proof.authority !== binding.authority ||
|
|
22
|
+
!sameSemanticFactClosureSet(proof.evidence_capabilities, binding.evidence_capabilities))
|
|
23
|
+
semanticFactClosureInvalid("contract_proof_identity_mismatch", `${outcome.key}:${binding.proof_ref}`);
|
|
24
|
+
}
|
|
25
|
+
function validateObserverTargets(proof, binding, targetByRef) {
|
|
26
|
+
for (const observerRef of proof.observer_refs)
|
|
27
|
+
if (!targetByRef.has(observerRef))
|
|
28
|
+
semanticFactClosureInvalid("proof_observer_target_unknown", `${binding.proof_ref}:${observerRef}`);
|
|
29
|
+
else if (targetByRef.get(observerRef).role !== "observer")
|
|
30
|
+
semanticFactClosureInvalid("proof_observer_target_role_mismatch", `${binding.proof_ref}:${observerRef}:${targetByRef.get(observerRef).role}`);
|
|
31
|
+
}
|
|
32
|
+
function validateExternalProofProjection(contract, outcome, binding, claimRef) {
|
|
33
|
+
const confirmation = contract.global.acceptance.external_confirmations.find((item) => item.key === binding.confirmation_ref);
|
|
34
|
+
const fullClaim = `${outcome.key}.${claimRef}`;
|
|
35
|
+
if (!confirmation)
|
|
36
|
+
semanticFactClosureInvalid("semantic_fact_confirmation_unknown", `${binding.proof_ref}:${binding.confirmation_ref}`);
|
|
37
|
+
if (!confirmation.impact_claims.includes(fullClaim))
|
|
38
|
+
semanticFactClosureInvalid("semantic_fact_confirmation_lineage_missing", `${binding.confirmation_ref}:${fullClaim}`);
|
|
39
|
+
}
|
|
40
|
+
function validateMachineProofProjection(contract, outcome, manifest, index, binding, proof, factBinding, expectations) {
|
|
41
|
+
const check = outcome.acceptance.checks.find((item) => item.key === binding.check_ref);
|
|
42
|
+
if (!check)
|
|
43
|
+
semanticFactClosureInvalid("semantic_fact_check_unknown", `${outcome.key}:${binding.check_ref}`);
|
|
44
|
+
for (const observerRef of proof.observer_refs)
|
|
45
|
+
if (observerRef === check.execution_target.target_ref)
|
|
46
|
+
semanticFactClosureInvalid("proof_observer_not_independent", `${binding.proof_ref}:${observerRef}`);
|
|
47
|
+
if (check.proof_surface !== binding.proof_surface)
|
|
48
|
+
semanticFactClosureInvalid("semantic_fact_check_surface_mismatch", `${binding.proof_ref}:${check.proof_surface}:${binding.proof_surface}`);
|
|
49
|
+
const assertion = check.positive_assertions.find((item) => item.key === binding.assertion_ref);
|
|
50
|
+
if (!assertion)
|
|
51
|
+
semanticFactClosureInvalid("semantic_fact_assertion_unknown", `${binding.check_ref}:${binding.assertion_ref}`);
|
|
52
|
+
if (assertion.claims.length !== 1 ||
|
|
53
|
+
assertion.claims[0] !== factBinding.claim_ref ||
|
|
54
|
+
assertion.applicability_ref !== factBinding.applicability_ref ||
|
|
55
|
+
assertion.operator !== "equals" ||
|
|
56
|
+
assertion.expected !== true ||
|
|
57
|
+
!sameSemanticFactClosureSet(assertion.evidence_capabilities, binding.evidence_capabilities))
|
|
58
|
+
semanticFactClosureInvalid("semantic_fact_assertion_binding_mismatch", `${binding.check_ref}:${binding.assertion_ref}`);
|
|
59
|
+
validateSemanticFactCounterfactualProjection(outcome, proof, factBinding.claim_ref, binding.check_ref, binding.assertion_ref);
|
|
60
|
+
const fact = index.fact_by_ref.get(binding.fact_ref);
|
|
61
|
+
const rows = expectations.get(binding.check_ref) ?? [];
|
|
62
|
+
rows.push({
|
|
63
|
+
manifest_ref: manifest.key,
|
|
64
|
+
manifest_sha256: contract.semantic_fact_manifest.sha256,
|
|
65
|
+
fact_ref: fact.key,
|
|
66
|
+
proof_ref: proof.key,
|
|
67
|
+
method: proof.method,
|
|
68
|
+
check_ref: binding.check_ref,
|
|
69
|
+
assertion_ref: binding.assertion_ref,
|
|
70
|
+
outcome_ref: outcome.key,
|
|
71
|
+
claim_ref: factBinding.claim_ref,
|
|
72
|
+
applicability_ref: factBinding.applicability_ref,
|
|
73
|
+
subject_ref: fact.unit_ref,
|
|
74
|
+
condition_ref: fact.condition_ref,
|
|
75
|
+
property_ref: fact.property_ref,
|
|
76
|
+
observation_sensitivity: fact.observation_sensitivity,
|
|
77
|
+
expected: fact.expected,
|
|
78
|
+
comparison: proof.comparison,
|
|
79
|
+
oracle: index.oracle_by_ref.get(proof.oracle_ref),
|
|
80
|
+
environment: index.environment_by_ref.get(proof.environment_ref),
|
|
81
|
+
observer_refs: proof.observer_refs,
|
|
82
|
+
});
|
|
83
|
+
expectations.set(binding.check_ref, rows);
|
|
84
|
+
}
|
|
85
|
+
function validateSemanticFactCounterfactualProjection(outcome, proof, claimRef, checkRef, assertionRef) {
|
|
86
|
+
if (proof.counterfactual.disposition !== "required")
|
|
87
|
+
return;
|
|
88
|
+
for (const counterfactualRef of proof.counterfactual.refs) {
|
|
89
|
+
const counterfactual = outcome.acceptance.counterfactual_controls.find((item) => item.key === counterfactualRef);
|
|
90
|
+
if (!counterfactual)
|
|
91
|
+
semanticFactClosureInvalid("semantic_fact_counterfactual_unknown", `${proof.key}:${counterfactualRef}`);
|
|
92
|
+
if (counterfactual.check_key !== checkRef ||
|
|
93
|
+
!counterfactual.claims.includes(claimRef) ||
|
|
94
|
+
!counterfactual.expected_assertion_failures.includes(assertionRef))
|
|
95
|
+
semanticFactClosureInvalid("semantic_fact_counterfactual_binding_mismatch", `${proof.key}:${counterfactualRef}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CompiledCheckV2, EvidenceCapabilityRecordV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
type SemanticRecord = Extract<EvidenceCapabilityRecordV2, {
|
|
3
|
+
capability: "semantic_fact";
|
|
4
|
+
}>;
|
|
5
|
+
export declare function validateSemanticFactEvidence(check: CompiledCheckV2, record: SemanticRecord, artifactHashes: Record<string, string>): string | null;
|
|
6
|
+
export declare function semanticFactComparisonResultIdentity(value: {
|
|
7
|
+
fact_ref: string;
|
|
8
|
+
proof_ref: string;
|
|
9
|
+
target_ref: string;
|
|
10
|
+
actual_value_sha256: string;
|
|
11
|
+
expected_value_sha256: string;
|
|
12
|
+
comparator: string;
|
|
13
|
+
mode: "exact" | "tolerance";
|
|
14
|
+
parameters_sha256: string;
|
|
15
|
+
tolerance_sha256: string | null;
|
|
16
|
+
mask_sha256: string | null;
|
|
17
|
+
passed: boolean;
|
|
18
|
+
}): string;
|
|
19
|
+
export declare function validateDistinctSemanticFactEvidence(records: EvidenceCapabilityRecordV2[]): string | null;
|
|
20
|
+
export declare const typed_semantic_fact_runtime_evidence = "fact_ref+actual+comparison+verdict+oracle+environment";
|
|
21
|
+
export {};
|