project-tiny-context-harness 0.8.10 → 0.8.12
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 +490 -472
- package/assets/README.md +762 -749
- package/assets/README.zh-CN.md +446 -431
- package/assets/agents/.gitkeep +1 -1
- package/assets/agents/AGENTS_CORE.md +17 -23
- package/assets/agents/long-task-implementation.toml +15 -0
- package/assets/context_templates/architecture.md +18 -18
- package/assets/context_templates/area.md +30 -30
- package/assets/context_templates/context.toml +24 -24
- package/assets/context_templates/deployment.md +35 -35
- package/assets/context_templates/global.md +56 -56
- 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 +25 -25
- 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 +64 -185
- 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 +35 -101
- package/assets/skills/context_surface_contract/SKILL.md +194 -191
- package/assets/skills/context_uiux_design/SKILL.md +49 -172
- package/assets/skills/design-resource-authoring/SKILL.md +52 -88
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +51 -163
- package/assets/skills/design-resource-authoring/references/formal-selected-web-app-handoff.md +96 -0
- package/assets/skills/design-resource-authoring/references/open-design-provider.md +119 -119
- package/assets/skills/design-resource-authoring/references/resource-selection.md +158 -181
- 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 +71 -106
- package/assets/skills/long-task-workflow/agents/openai.yaml +1 -1
- package/assets/skills/long-task-workflow/references/authority-lifecycle.md +71 -69
- package/assets/skills/long-task-workflow/references/contract-authoring.md +98 -94
- package/assets/skills/long-task-workflow/references/evidence-design.md +67 -63
- package/assets/skills/long-task-workflow/references/source-authoring.md +90 -90
- package/assets/tools/validate_context.py +442 -442
- package/dist/commands/design-resource.js +9 -2
- package/dist/commands/enable.js +2 -0
- package/dist/commands/index.js +1 -1
- package/dist/commands/long-task-revision.js +8 -7
- package/dist/commands/sync.js +2 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -1
- package/dist/lib/compact-authoring-support.d.ts +22 -0
- package/dist/lib/compact-authoring-support.js +143 -0
- package/dist/lib/compact-shared-structure-authoring.d.ts +5 -0
- package/dist/lib/compact-shared-structure-authoring.js +9 -0
- package/dist/lib/compact-shared-structure-types.d.ts +61 -0
- package/dist/lib/compact-shared-structure-types.js +1 -0
- package/dist/lib/compact-shared-structure-validation.d.ts +2 -0
- package/dist/lib/compact-shared-structure-validation.js +159 -0
- package/dist/lib/compact-shared-structures.d.ts +3 -0
- package/dist/lib/compact-shared-structures.js +204 -0
- package/dist/lib/design-resource-fact-enums.d.ts +4 -0
- package/dist/lib/design-resource-fact-enums.js +12 -0
- package/dist/lib/design-resource-fact-manifest-shape-evidence.js +2 -2
- package/dist/lib/design-resource-fact-manifest-validation.d.ts +2 -1
- package/dist/lib/design-resource-fact-policy.d.ts +2 -2
- package/dist/lib/design-resource-fact-types.d.ts +2 -2
- package/dist/lib/design-resource-handoff-bundle-draft.d.ts +11 -0
- package/dist/lib/design-resource-handoff-bundle-draft.js +40 -0
- package/dist/lib/design-resource-handoff-bundle.js +4 -28
- package/dist/lib/design-resource-handoff-input-types.d.ts +14 -0
- package/dist/lib/design-resource-handoff-input-types.js +1 -0
- package/dist/lib/design-resource-handoff-manifest-projection.d.ts +2 -1
- package/dist/lib/design-resource-handoff-parser.d.ts +2 -2
- package/dist/lib/design-resource-handoff-parser.js +2 -2
- package/dist/lib/design-resource-handoff-shape.d.ts +4 -1
- package/dist/lib/design-resource-handoff-shape.js +10 -0
- package/dist/lib/design-resource-handoff-snapshot.d.ts +1 -1
- package/dist/lib/design-resource-handoff-snapshot.js +4 -0
- package/dist/lib/design-resource-handoff-types.d.ts +0 -10
- package/dist/lib/design-resource-handoff-validation.d.ts +6 -2
- package/dist/lib/design-resource-handoff-validation.js +11 -0
- package/dist/lib/design-resource-handoff-web-dependency-validation.d.ts +4 -2
- package/dist/lib/design-resource-symbolic-applicability-authority.d.ts +7 -0
- package/dist/lib/design-resource-symbolic-applicability-authority.js +19 -0
- package/dist/lib/design-resource-symbolic-applicability-policy.d.ts +12 -0
- package/dist/lib/design-resource-symbolic-applicability-policy.js +79 -0
- package/dist/lib/design-resource-symbolic-applicability-profiles.d.ts +8 -0
- package/dist/lib/design-resource-symbolic-applicability-profiles.js +55 -0
- package/dist/lib/design-resource-symbolic-applicability-shape.d.ts +2 -0
- package/dist/lib/design-resource-symbolic-applicability-shape.js +76 -0
- package/dist/lib/design-resource-symbolic-applicability-validation.d.ts +7 -0
- package/dist/lib/design-resource-symbolic-applicability-validation.js +128 -0
- package/dist/lib/design-resource-symbolic-compilation.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-compilation.js +13 -0
- package/dist/lib/design-resource-symbolic-denotation.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-denotation.js +167 -0
- package/dist/lib/design-resource-symbolic-disposition-validation.d.ts +4 -0
- package/dist/lib/design-resource-symbolic-disposition-validation.js +28 -0
- package/dist/lib/design-resource-symbolic-fact-policy.d.ts +12 -0
- package/dist/lib/design-resource-symbolic-fact-policy.js +12 -0
- package/dist/lib/design-resource-symbolic-fact-shape.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-fact-shape.js +138 -0
- package/dist/lib/design-resource-symbolic-fact-types.d.ts +213 -0
- package/dist/lib/design-resource-symbolic-fact-types.js +1 -0
- package/dist/lib/design-resource-symbolic-fact-validation.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-fact-validation.js +86 -0
- package/dist/lib/design-resource-symbolic-indexes.d.ts +23 -0
- package/dist/lib/design-resource-symbolic-indexes.js +54 -0
- package/dist/lib/design-resource-symbolic-manifest-shape.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-manifest-shape.js +155 -0
- package/dist/lib/design-resource-symbolic-manifest-validation.d.ts +6 -0
- package/dist/lib/design-resource-symbolic-manifest-validation.js +132 -0
- package/dist/lib/design-resource-symbolic-noninterference-artifact.d.ts +33 -0
- package/dist/lib/design-resource-symbolic-noninterference-artifact.js +110 -0
- package/dist/lib/design-resource-symbolic-noninterference-equivalence.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-noninterference-equivalence.js +77 -0
- package/dist/lib/design-resource-symbolic-noninterference-recompute.d.ts +4 -0
- package/dist/lib/design-resource-symbolic-noninterference-recompute.js +146 -0
- package/dist/lib/design-resource-symbolic-noninterference-scope.d.ts +7 -0
- package/dist/lib/design-resource-symbolic-noninterference-scope.js +49 -0
- package/dist/lib/design-resource-symbolic-noninterference-shape.d.ts +2 -0
- package/dist/lib/design-resource-symbolic-noninterference-shape.js +152 -0
- package/dist/lib/design-resource-symbolic-noninterference-types.d.ts +103 -0
- package/dist/lib/design-resource-symbolic-noninterference-types.js +1 -0
- package/dist/lib/design-resource-symbolic-noninterference-validation.d.ts +5 -0
- package/dist/lib/design-resource-symbolic-noninterference-validation.js +62 -0
- package/dist/lib/design-resource-symbolic-oracle-fingerprint.d.ts +1 -0
- package/dist/lib/design-resource-symbolic-oracle-fingerprint.js +47 -0
- package/dist/lib/design-resource-symbolic-predicate-shape.d.ts +6 -0
- package/dist/lib/design-resource-symbolic-predicate-shape.js +123 -0
- package/dist/lib/design-resource-symbolic-production-closure.d.ts +4 -0
- package/dist/lib/design-resource-symbolic-production-closure.js +144 -0
- package/dist/lib/design-resource-symbolic-proof-authority-validation.d.ts +10 -0
- package/dist/lib/design-resource-symbolic-proof-authority-validation.js +68 -0
- package/dist/lib/design-resource-symbolic-proof-validation.d.ts +10 -0
- package/dist/lib/design-resource-symbolic-proof-validation.js +89 -0
- package/dist/lib/design-resource-symbolic-region-validation.d.ts +19 -0
- package/dist/lib/design-resource-symbolic-region-validation.js +146 -0
- package/dist/lib/design-resource-symbolic-resource-validation.d.ts +5 -0
- package/dist/lib/design-resource-symbolic-resource-validation.js +90 -0
- package/dist/lib/design-resource-symbolic-rule-shape.d.ts +27 -0
- package/dist/lib/design-resource-symbolic-rule-shape.js +158 -0
- package/dist/lib/design-resource-symbolic-safety-validation.d.ts +6 -0
- package/dist/lib/design-resource-symbolic-safety-validation.js +29 -0
- package/dist/lib/design-resource-symbolic-source-ir-evaluation.d.ts +19 -0
- package/dist/lib/design-resource-symbolic-source-ir-evaluation.js +74 -0
- package/dist/lib/design-resource-symbolic-source-ir-evidence.d.ts +44 -0
- package/dist/lib/design-resource-symbolic-source-ir-evidence.js +88 -0
- package/dist/lib/design-resource-symbolic-source-ir-oracle.d.ts +13 -0
- package/dist/lib/design-resource-symbolic-source-ir-oracle.js +96 -0
- package/dist/lib/design-resource-symbolic-source-ir-proof.d.ts +14 -0
- package/dist/lib/design-resource-symbolic-source-ir-proof.js +98 -0
- package/dist/lib/design-resource-symbolic-source-ir-shape.d.ts +2 -0
- package/dist/lib/design-resource-symbolic-source-ir-shape.js +38 -0
- package/dist/lib/design-resource-symbolic-source-ir-types.d.ts +17 -0
- package/dist/lib/design-resource-symbolic-source-ir-types.js +2 -0
- package/dist/lib/design-resource-symbolic-static-dependency-validation.d.ts +2 -0
- package/dist/lib/design-resource-symbolic-static-dependency-validation.js +83 -0
- package/dist/lib/design-resource-symbolic-structural-closure-validation.d.ts +6 -0
- package/dist/lib/design-resource-symbolic-structural-closure-validation.js +79 -0
- package/dist/lib/design-resource-symbolic-validation-support.d.ts +29 -0
- package/dist/lib/design-resource-symbolic-validation-support.js +111 -0
- package/dist/lib/design-resource-v1-capacity-header.d.ts +8 -0
- package/dist/lib/design-resource-v1-capacity-header.js +231 -0
- package/dist/lib/design-resource-v1-capacity.d.ts +5 -0
- package/dist/lib/design-resource-v1-capacity.js +45 -0
- package/dist/lib/init.js +1 -0
- package/dist/lib/long-task-activation-validation.js +2 -2
- package/dist/lib/long-task-authority-policy.d.ts +3 -0
- package/dist/lib/long-task-authority-policy.js +3 -0
- package/dist/lib/long-task-codex-agent-profile.d.ts +42 -0
- package/dist/lib/long-task-codex-agent-profile.js +276 -0
- package/dist/lib/long-task-compact-authoring-projections.d.ts +12 -0
- package/dist/lib/long-task-compact-authoring-projections.js +67 -0
- package/dist/lib/long-task-compact-authoring.d.ts +3 -0
- package/dist/lib/long-task-compact-authoring.js +173 -0
- package/dist/lib/long-task-compact-carrier.d.ts +7 -0
- package/dist/lib/long-task-compact-carrier.js +132 -0
- package/dist/lib/long-task-compact-parser.d.ts +14 -0
- package/dist/lib/long-task-compact-parser.js +123 -0
- package/dist/lib/long-task-compact-primitives.d.ts +22 -0
- package/dist/lib/long-task-compact-primitives.js +132 -0
- package/dist/lib/long-task-compact-projections.d.ts +4 -0
- package/dist/lib/long-task-compact-projections.js +153 -0
- package/dist/lib/long-task-compact-structure-targets.d.ts +2 -0
- package/dist/lib/long-task-compact-structure-targets.js +90 -0
- package/dist/lib/long-task-counterfactual-sandbox.d.ts +1 -1
- package/dist/lib/long-task-counterfactual-sandbox.js +7 -5
- package/dist/lib/long-task-delivery-parser.d.ts +1 -0
- package/dist/lib/long-task-delivery-parser.js +38 -6
- package/dist/lib/long-task-design-resource-handoff.d.ts +2 -1
- package/dist/lib/long-task-design-resource-handoff.js +71 -11
- package/dist/lib/long-task-design-resource-method-binding.d.ts +8 -1
- package/dist/lib/long-task-design-resource-method-binding.js +150 -0
- package/dist/lib/long-task-evidence-capability-codec.js +256 -34
- package/dist/lib/long-task-evidence-capability-policy.js +28 -0
- package/dist/lib/long-task-evidence-capability-runtime.js +271 -63
- package/dist/lib/long-task-evidence-capability-types.d.ts +70 -2
- package/dist/lib/long-task-evidence-v2.d.ts +1 -1
- package/dist/lib/long-task-evidence-v2.js +5 -5
- package/dist/lib/long-task-hook-install.d.ts +19 -2
- package/dist/lib/long-task-hook-install.js +288 -91
- package/dist/lib/long-task-playwright-capability-records.d.ts +2 -0
- package/dist/lib/long-task-playwright-capability-records.js +74 -2
- package/dist/lib/long-task-runner-freeze.d.ts +1 -1
- package/dist/lib/long-task-runner-freeze.js +4 -2
- package/dist/lib/long-task-semantic-contract-types.d.ts +1 -1
- package/dist/lib/long-task-semantic-fact-binding-types.d.ts +8 -0
- package/dist/lib/long-task-semantic-fact-closure.js +4 -1
- package/dist/lib/long-task-semantic-fact-contract-closure.d.ts +1 -1
- package/dist/lib/long-task-semantic-fact-contract-closure.js +15 -3
- package/dist/lib/long-task-semantic-fact-contract-facts.d.ts +1 -1
- package/dist/lib/long-task-semantic-fact-contract-facts.js +4 -1
- package/dist/lib/long-task-semantic-fact-contract-proofs.d.ts +1 -1
- package/dist/lib/long-task-semantic-fact-contract-proofs.js +12 -3
- package/dist/lib/long-task-semantic-fact-evidence.d.ts +5 -1
- package/dist/lib/long-task-semantic-fact-evidence.js +47 -4
- package/dist/lib/long-task-semantic-fact-shape.js +17 -6
- package/dist/lib/long-task-shape-primitives.d.ts +1 -1
- package/dist/lib/long-task-shape-primitives.js +1 -0
- package/dist/lib/long-task-source-item-parser.d.ts +2 -2
- package/dist/lib/long-task-source-item-parser.js +20 -11
- package/dist/lib/long-task-ui-design-policy.js +64 -4
- package/dist/lib/long-task-ui-surface-shape.js +195 -0
- package/dist/lib/long-task-ui-surface-types.d.ts +53 -0
- package/dist/lib/long-task-verifier-v2.js +1 -1
- package/dist/lib/long-task-worker-selection.d.ts +2 -0
- package/dist/lib/long-task-worker-selection.js +7 -0
- package/dist/lib/long-task-workspace-scope.js +3 -1
- package/dist/lib/long-task-workspace.js +11 -1
- package/dist/lib/migrations.js +58 -0
- package/dist/lib/profiles.js +0 -1
- package/dist/lib/semantic-fact-compact-authoring.d.ts +2 -0
- package/dist/lib/semantic-fact-compact-authoring.js +160 -0
- package/dist/lib/semantic-fact-compact-capacity.d.ts +9 -0
- package/dist/lib/semantic-fact-compact-capacity.js +40 -0
- package/dist/lib/semantic-fact-compact-carrier.d.ts +16 -0
- package/dist/lib/semantic-fact-compact-carrier.js +146 -0
- package/dist/lib/semantic-fact-compact-parser.d.ts +17 -0
- package/dist/lib/semantic-fact-compact-parser.js +168 -0
- package/dist/lib/semantic-fact-compact-revision.d.ts +11 -0
- package/dist/lib/semantic-fact-compact-revision.js +64 -0
- package/dist/lib/semantic-fact-compact-support.d.ts +23 -0
- package/dist/lib/semantic-fact-compact-support.js +159 -0
- package/dist/lib/semantic-fact-policy-census.d.ts +1 -0
- package/dist/lib/semantic-fact-policy-census.js +43 -0
- package/dist/lib/semantic-fact-proof-shape.d.ts +1 -1
- package/dist/lib/semantic-fact-property-shape.d.ts +1 -1
- package/dist/lib/semantic-fact-source-parser.d.ts +5 -0
- package/dist/lib/semantic-fact-source-parser.js +47 -6
- package/dist/lib/structural-closure-cost.d.ts +79 -0
- package/dist/lib/structural-closure-cost.js +91 -0
- package/dist/lib/symbolic-denotation-dag-builder.d.ts +25 -0
- package/dist/lib/symbolic-denotation-dag-builder.js +176 -0
- package/dist/lib/symbolic-denotation-domain-validation.d.ts +3 -0
- package/dist/lib/symbolic-denotation-domain-validation.js +56 -0
- package/dist/lib/symbolic-denotation-engine.d.ts +32 -0
- package/dist/lib/symbolic-denotation-engine.js +140 -0
- package/dist/lib/symbolic-denotation-public.d.ts +11 -0
- package/dist/lib/symbolic-denotation-public.js +12 -0
- package/dist/lib/symbolic-denotation-runtime.d.ts +20 -0
- package/dist/lib/symbolic-denotation-runtime.js +90 -0
- package/dist/lib/symbolic-denotation-support.d.ts +11 -0
- package/dist/lib/symbolic-denotation-support.js +49 -0
- package/dist/lib/symbolic-denotation-types.d.ts +133 -0
- package/dist/lib/symbolic-denotation-types.js +18 -0
- package/dist/lib/symbolic-denotation-validation.d.ts +6 -0
- package/dist/lib/symbolic-denotation-validation.js +126 -0
- package/dist/lib/sync-engine.d.ts +1 -0
- package/dist/lib/sync-engine.js +4 -1
- package/dist/lib/upgrade.js +1 -0
- package/dist/long-task-hook.js +40 -1
- package/dist/public-types.d.ts +8 -0
- package/dist/public-types.js +1 -0
- package/dist/schemas/design-resource-symbolic-noninterference-artifact-v2.schema.json +289 -0
- package/dist/schemas/design-resource-symbolic-source-ir-v1.schema.json +130 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +390 -5
- package/migrations/README.md +15 -15
- package/package.json +2 -2
- package/source-mappings.yaml +28 -25
- package/assets/skills/source-plan-authoring/SKILL.md +0 -14
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { stableKey, stableKeys, } from "./design-resource-handoff-shape-primitives.js";
|
|
2
|
+
import { array, boolean, literal, object, } from "./long-task-shape-primitives.js";
|
|
3
|
+
export function parseSymbolicAxisDomains(value, label) {
|
|
4
|
+
return array(value, label).map((item, index) => {
|
|
5
|
+
const itemLabel = `${label}[${index}]`;
|
|
6
|
+
const kindValue = object(item, itemLabel, ["key", "kind"], ["values", "minimum", "maximum", "integer"]).kind;
|
|
7
|
+
if (kindValue === "enum") {
|
|
8
|
+
const row = object(item, itemLabel, ["key", "kind", "values"]);
|
|
9
|
+
return {
|
|
10
|
+
key: stableKey(row.key, `${itemLabel}.key`),
|
|
11
|
+
kind: literal(row.kind, ["enum"], `${itemLabel}.kind`),
|
|
12
|
+
values: stableKeys(row.values, `${itemLabel}.values`),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const row = object(item, itemLabel, [
|
|
16
|
+
"key",
|
|
17
|
+
"kind",
|
|
18
|
+
"minimum",
|
|
19
|
+
"maximum",
|
|
20
|
+
"integer",
|
|
21
|
+
]);
|
|
22
|
+
return {
|
|
23
|
+
key: stableKey(row.key, `${itemLabel}.key`),
|
|
24
|
+
kind: literal(row.kind, ["bounded_number"], `${itemLabel}.kind`),
|
|
25
|
+
minimum: parseSymbolicSafeInteger(row.minimum, `${itemLabel}.minimum`),
|
|
26
|
+
maximum: parseSymbolicSafeInteger(row.maximum, `${itemLabel}.maximum`),
|
|
27
|
+
integer: parseLiteralBooleanTrue(row.integer, `${itemLabel}.integer`),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function parseSymbolicPredicate(value, label) {
|
|
32
|
+
const operator = object(value, label, ["op"], [
|
|
33
|
+
"axis_ref",
|
|
34
|
+
"value",
|
|
35
|
+
"values",
|
|
36
|
+
"minimum",
|
|
37
|
+
"maximum",
|
|
38
|
+
"minimum_inclusive",
|
|
39
|
+
"maximum_inclusive",
|
|
40
|
+
"predicates",
|
|
41
|
+
"predicate",
|
|
42
|
+
]).op;
|
|
43
|
+
if (operator === "eq")
|
|
44
|
+
return parseEquality(value, label);
|
|
45
|
+
if (operator === "in")
|
|
46
|
+
return parseMembership(value, label);
|
|
47
|
+
if (operator === "range")
|
|
48
|
+
return parseRange(value, label);
|
|
49
|
+
if (operator === "all" || operator === "any")
|
|
50
|
+
return parseGroup(value, label);
|
|
51
|
+
if (operator === "not")
|
|
52
|
+
return parseNegation(value, label);
|
|
53
|
+
throw new Error(`design_resource_symbolic_manifest_invalid:${label}.op:unknown:${String(operator)}`);
|
|
54
|
+
}
|
|
55
|
+
function parseEquality(value, label) {
|
|
56
|
+
const row = object(value, label, ["op", "axis_ref", "value"]);
|
|
57
|
+
return {
|
|
58
|
+
op: "eq",
|
|
59
|
+
axis_ref: stableKey(row.axis_ref, `${label}.axis_ref`),
|
|
60
|
+
value: parseSymbolicScalar(row.value, `${label}.value`),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function parseMembership(value, label) {
|
|
64
|
+
const row = object(value, label, ["op", "axis_ref", "values"]);
|
|
65
|
+
return {
|
|
66
|
+
op: "in",
|
|
67
|
+
axis_ref: stableKey(row.axis_ref, `${label}.axis_ref`),
|
|
68
|
+
values: array(row.values, `${label}.values`).map((entry, index) => parseSymbolicScalar(entry, `${label}.values[${index}]`)),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function parseRange(value, label) {
|
|
72
|
+
const row = object(value, label, [
|
|
73
|
+
"op",
|
|
74
|
+
"axis_ref",
|
|
75
|
+
"minimum",
|
|
76
|
+
"maximum",
|
|
77
|
+
"minimum_inclusive",
|
|
78
|
+
"maximum_inclusive",
|
|
79
|
+
]);
|
|
80
|
+
return {
|
|
81
|
+
op: "range",
|
|
82
|
+
axis_ref: stableKey(row.axis_ref, `${label}.axis_ref`),
|
|
83
|
+
minimum: parseSymbolicSafeInteger(row.minimum, `${label}.minimum`),
|
|
84
|
+
maximum: parseSymbolicSafeInteger(row.maximum, `${label}.maximum`),
|
|
85
|
+
minimum_inclusive: boolean(row.minimum_inclusive, `${label}.minimum_inclusive`),
|
|
86
|
+
maximum_inclusive: boolean(row.maximum_inclusive, `${label}.maximum_inclusive`),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function parseGroup(value, label) {
|
|
90
|
+
const row = object(value, label, ["op", "predicates"]);
|
|
91
|
+
return {
|
|
92
|
+
op: literal(row.op, ["all", "any"], `${label}.op`),
|
|
93
|
+
predicates: array(row.predicates, `${label}.predicates`).map((entry, index) => parseSymbolicPredicate(entry, `${label}.predicates[${index}]`)),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function parseNegation(value, label) {
|
|
97
|
+
const row = object(value, label, ["op", "predicate"]);
|
|
98
|
+
return {
|
|
99
|
+
op: "not",
|
|
100
|
+
predicate: parseSymbolicPredicate(row.predicate, `${label}.predicate`),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function parseSymbolicScalar(value, label) {
|
|
104
|
+
if (typeof value === "string")
|
|
105
|
+
return stableKey(value, label);
|
|
106
|
+
return parseSymbolicSafeInteger(value, label);
|
|
107
|
+
}
|
|
108
|
+
export function parseSymbolicSafeInteger(value, label) {
|
|
109
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value))
|
|
110
|
+
throw new Error(`design_resource_symbolic_manifest_invalid:${label}:safe_integer_required`);
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
export function parseSymbolicNonnegativeInteger(value, label) {
|
|
114
|
+
const parsed = parseSymbolicSafeInteger(value, label);
|
|
115
|
+
if (parsed < 0)
|
|
116
|
+
throw new Error(`design_resource_symbolic_manifest_invalid:${label}:nonnegative_required`);
|
|
117
|
+
return parsed;
|
|
118
|
+
}
|
|
119
|
+
function parseLiteralBooleanTrue(value, label) {
|
|
120
|
+
if (boolean(value, label) !== true)
|
|
121
|
+
throw new Error(`design_resource_symbolic_manifest_invalid:${label}:must_be_true`);
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import type { DesignResource } from "./design-resource-handoff-file-primitives.js";
|
|
3
|
+
import type { DesignResourceSymbolicHandoffTargetV2, DesignResourceSymbolicNoninterferenceCertificateV2, DesignResourceSymbolicNoninterferenceFailureWitnessV1 } from "./design-resource-symbolic-fact-types.js";
|
|
4
|
+
export declare function productionClosureFailure(target: DesignResourceSymbolicHandoffTargetV2, certificate: DesignResourceSymbolicNoninterferenceCertificateV2, resources: ReadonlyMap<string, DesignResource>, contents: ReadonlyMap<string, Buffer>): DesignResourceSymbolicNoninterferenceFailureWitnessV1 | null;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { symbolicNoninterferenceCertificateScopeSha256 } from "./design-resource-symbolic-noninterference-scope.js";
|
|
3
|
+
import { DESIGN_RESOURCE_SYMBOLIC_SOURCE_IR_MEDIA_TYPE } from "./design-resource-symbolic-source-ir-types.js";
|
|
4
|
+
import { canonicalJson } from "./strict-codec.js";
|
|
5
|
+
const SAFE_STATIC_HTML_TAGS = new Set([
|
|
6
|
+
"article",
|
|
7
|
+
"aside",
|
|
8
|
+
"body",
|
|
9
|
+
"br",
|
|
10
|
+
"div",
|
|
11
|
+
"footer",
|
|
12
|
+
"h1",
|
|
13
|
+
"h2",
|
|
14
|
+
"h3",
|
|
15
|
+
"h4",
|
|
16
|
+
"h5",
|
|
17
|
+
"h6",
|
|
18
|
+
"head",
|
|
19
|
+
"header",
|
|
20
|
+
"html",
|
|
21
|
+
"li",
|
|
22
|
+
"main",
|
|
23
|
+
"nav",
|
|
24
|
+
"ol",
|
|
25
|
+
"p",
|
|
26
|
+
"section",
|
|
27
|
+
"span",
|
|
28
|
+
"strong",
|
|
29
|
+
"ul",
|
|
30
|
+
]);
|
|
31
|
+
const SAFE_STATIC_HTML_ATTRIBUTE = /^(?:aria-[a-z0-9-]+|class|data-[a-z0-9-]+|dir|id|lang|role|title)$/u;
|
|
32
|
+
const HTML_TOKEN = /<!doctype\s+html\s*>|<\/?[A-Za-z][A-Za-z0-9]*\b[^<>]*>/giu;
|
|
33
|
+
const HTML_TAG = /^<(\/)?([A-Za-z][A-Za-z0-9]*)([^<>]*)>$/u;
|
|
34
|
+
const HTML_ATTRIBUTE = /\s+([A-Za-z_:][A-Za-z0-9_.:-]*)(?:\s*=\s*(?:"[^"]*"|'[^']*'))?/guy;
|
|
35
|
+
export function productionClosureFailure(target, certificate, resources, contents) {
|
|
36
|
+
for (const resourceRef of target.resource_refs) {
|
|
37
|
+
const resource = resources.get(resourceRef);
|
|
38
|
+
const bytes = contents.get(resourceRef);
|
|
39
|
+
if (!resource || !bytes)
|
|
40
|
+
continue;
|
|
41
|
+
if (resourceRef === target.source_profile.entry_resource_ref) {
|
|
42
|
+
if (resource.media_type !== "text/html")
|
|
43
|
+
return witness(certificate, resource, null, `unsupported_entry_media:${resource.media_type}`);
|
|
44
|
+
const failure = staticHtmlFailure(bytes.toString("utf8"));
|
|
45
|
+
if (failure)
|
|
46
|
+
return witness(certificate, resource, failure.offset, failure.detail, bytes.toString("utf8"));
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (resource.media_type !== "application/json" &&
|
|
50
|
+
resource.media_type !== DESIGN_RESOURCE_SYMBOLIC_SOURCE_IR_MEDIA_TYPE)
|
|
51
|
+
return witness(certificate, resource, null, `unsupported_dependency_media:${resource.media_type}`);
|
|
52
|
+
try {
|
|
53
|
+
const parsed = JSON.parse(bytes.toString("utf8"));
|
|
54
|
+
if (resource.media_type === DESIGN_RESOURCE_SYMBOLIC_SOURCE_IR_MEDIA_TYPE &&
|
|
55
|
+
canonicalJson(parsed) !== bytes.toString("utf8"))
|
|
56
|
+
return witness(certificate, resource, null, "noncanonical_symbolic_source_ir");
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return witness(certificate, resource, null, "invalid_inert_json");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
function staticHtmlFailure(source) {
|
|
65
|
+
let cursor = 0;
|
|
66
|
+
let doctypeSeen = false;
|
|
67
|
+
for (const match of source.matchAll(HTML_TOKEN)) {
|
|
68
|
+
const token = match[0];
|
|
69
|
+
const offset = match.index;
|
|
70
|
+
if (source.slice(cursor, offset).includes("<"))
|
|
71
|
+
return {
|
|
72
|
+
offset: cursor + source.slice(cursor, offset).indexOf("<"),
|
|
73
|
+
detail: "unsupported_html_token",
|
|
74
|
+
};
|
|
75
|
+
cursor = offset + token.length;
|
|
76
|
+
if (/^<!doctype/iu.test(token)) {
|
|
77
|
+
if (doctypeSeen || source.slice(0, offset).trim())
|
|
78
|
+
return { offset, detail: "misplaced_or_duplicate_doctype" };
|
|
79
|
+
doctypeSeen = true;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const parsed = HTML_TAG.exec(token);
|
|
83
|
+
if (!parsed)
|
|
84
|
+
return { offset, detail: "unsupported_html_token" };
|
|
85
|
+
const closing = parsed[1] === "/";
|
|
86
|
+
const tag = parsed[2].toLowerCase();
|
|
87
|
+
if (!SAFE_STATIC_HTML_TAGS.has(tag))
|
|
88
|
+
return { offset, detail: `unsupported_html_tag:${tag}` };
|
|
89
|
+
const attributes = parsed[3];
|
|
90
|
+
if (closing) {
|
|
91
|
+
if (attributes.trim())
|
|
92
|
+
return { offset, detail: "closing_tag_attributes" };
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const attributeFailure = staticAttributeFailure(attributes);
|
|
96
|
+
if (attributeFailure)
|
|
97
|
+
return {
|
|
98
|
+
offset: offset + token.indexOf(attributes) + attributeFailure.offset,
|
|
99
|
+
detail: attributeFailure.detail,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const remainder = source.slice(cursor);
|
|
103
|
+
if (remainder.includes("<"))
|
|
104
|
+
return {
|
|
105
|
+
offset: cursor + remainder.indexOf("<"),
|
|
106
|
+
detail: "unsupported_html_token",
|
|
107
|
+
};
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function staticAttributeFailure(source) {
|
|
111
|
+
const value = source.endsWith("/") ? source.slice(0, -1) : source;
|
|
112
|
+
let cursor = 0;
|
|
113
|
+
HTML_ATTRIBUTE.lastIndex = 0;
|
|
114
|
+
while (cursor < value.length) {
|
|
115
|
+
HTML_ATTRIBUTE.lastIndex = cursor;
|
|
116
|
+
const match = HTML_ATTRIBUTE.exec(value);
|
|
117
|
+
if (!match || match.index !== cursor)
|
|
118
|
+
return { offset: cursor, detail: "unsupported_html_attribute_syntax" };
|
|
119
|
+
const name = match[1].toLowerCase();
|
|
120
|
+
if (!SAFE_STATIC_HTML_ATTRIBUTE.test(name))
|
|
121
|
+
return { offset: cursor, detail: `unsupported_html_attribute:${name}` };
|
|
122
|
+
cursor = HTML_ATTRIBUTE.lastIndex;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
function witness(certificate, resource, byteOffset, detail, source = "") {
|
|
127
|
+
const axisRef = certificate.omitted_axis_refs.find((axis) => source.includes(axis));
|
|
128
|
+
return {
|
|
129
|
+
kind: axisRef ? "omitted_axis_dependency" : "unsupported_dependency",
|
|
130
|
+
side: "production",
|
|
131
|
+
certificate_scope_sha256: symbolicNoninterferenceCertificateScopeSha256(certificate),
|
|
132
|
+
axis_ref: axisRef ?? null,
|
|
133
|
+
fact_rule_ref: null,
|
|
134
|
+
resource_ref: resource.key,
|
|
135
|
+
path: resource.path,
|
|
136
|
+
locator: null,
|
|
137
|
+
node_ref: null,
|
|
138
|
+
byte_offset: byteOffset === null
|
|
139
|
+
? null
|
|
140
|
+
: Buffer.byteLength(source.slice(0, byteOffset)),
|
|
141
|
+
assignment: null,
|
|
142
|
+
detail,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DesignResourcePropertyDefinitionV1 } from "./design-resource-fact-types.js";
|
|
2
|
+
import type { DesignResource } from "./design-resource-handoff-file-primitives.js";
|
|
3
|
+
import type { DesignResourceObservableRuleManifestV2, DesignResourceSymbolicHandoffTargetV2 } from "./design-resource-symbolic-fact-types.js";
|
|
4
|
+
type Rule = DesignResourceObservableRuleManifestV2["fact_rules"][number];
|
|
5
|
+
type Obligation = DesignResourceObservableRuleManifestV2["semantic_proof_obligations"][number];
|
|
6
|
+
type Oracle = DesignResourceObservableRuleManifestV2["oracles"][number];
|
|
7
|
+
type Environment = DesignResourceObservableRuleManifestV2["environments"][number];
|
|
8
|
+
export declare function validateSymbolicProofAuthorities(manifest: DesignResourceObservableRuleManifestV2, target: DesignResourceSymbolicHandoffTargetV2, resources: Map<string, DesignResource>, contents: Map<string, Buffer>): void;
|
|
9
|
+
export declare function validateSymbolicObligationPolicy(obligation: Obligation, rule: Rule, property: DesignResourcePropertyDefinitionV1, oracle: Oracle, environment: Environment, target: DesignResourceSymbolicHandoffTargetV2, resources: Map<string, DesignResource>, contents: Map<string, Buffer>): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { designFactComparatorSupportsMethod, designFactMethodIsCompatible, designFactOracleSupportsMethod, } from "./design-resource-fact-policy.js";
|
|
2
|
+
import { validateDesignResourceLocatedDigest } from "./design-resource-fact-locator-validation.js";
|
|
3
|
+
import { invalid, unique, } from "./design-resource-symbolic-validation-support.js";
|
|
4
|
+
export function validateSymbolicProofAuthorities(manifest, target, resources, contents) {
|
|
5
|
+
for (const oracle of manifest.oracles) {
|
|
6
|
+
if (!oracle.capability_refs.length)
|
|
7
|
+
invalid("v2_oracle_capabilities_required", oracle.key);
|
|
8
|
+
unique(oracle.capability_refs, `v2_oracle_capability_duplicate:${oracle.key}`);
|
|
9
|
+
if (oracle.trust === "frozen_executable" && oracle.sha256 === null)
|
|
10
|
+
invalid("v2_oracle_digest_required", oracle.key);
|
|
11
|
+
if (oracle.trust === "named_external_tcb" && oracle.sha256 !== null)
|
|
12
|
+
invalid("v2_external_oracle_digest_forbidden", oracle.key);
|
|
13
|
+
}
|
|
14
|
+
for (const environment of manifest.environments) {
|
|
15
|
+
validateDesignResourceLocatedDigest(environment.definition, resources, contents, `v2.environment.${environment.key}`);
|
|
16
|
+
requireTargetResource(target, environment.definition.locator.resource_ref, "v2_environment_resource_outside_target", environment.key);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function validateSymbolicObligationPolicy(obligation, rule, property, oracle, environment, target, resources, contents) {
|
|
20
|
+
if (!designFactMethodIsCompatible(property.dimension, obligation.method))
|
|
21
|
+
invalid("v2_proof_method_incompatible", `${obligation.key}:${property.dimension}:${obligation.method}`);
|
|
22
|
+
if (!designFactComparatorSupportsMethod(obligation.method, obligation.comparison.comparator))
|
|
23
|
+
invalid("v2_proof_comparator_method_incompatible", `${obligation.key}:${obligation.method}:${obligation.comparison.comparator}`);
|
|
24
|
+
if (!designFactOracleSupportsMethod(obligation.method, oracle.capability_refs))
|
|
25
|
+
invalid("v2_proof_oracle_capability_missing", `${obligation.key}:${oracle.key}:${obligation.method}`);
|
|
26
|
+
validateComparison(obligation, target, resources, contents);
|
|
27
|
+
requireTargetResource(target, environment.definition.locator.resource_ref, "v2_proof_environment_outside_target", obligation.key);
|
|
28
|
+
validateProtectedValuePolicy(rule, obligation);
|
|
29
|
+
if (obligation.proof_surface === "proxy_only")
|
|
30
|
+
invalid("v2_obligation_proxy_only_forbidden", obligation.key);
|
|
31
|
+
if (!obligation.proof_surface.trim() ||
|
|
32
|
+
!obligation.observation_boundary.trim() ||
|
|
33
|
+
obligation.completion_effect !== "required_for_rule_method_region")
|
|
34
|
+
invalid("v2_obligation_proof_meaning_incomplete", obligation.key);
|
|
35
|
+
}
|
|
36
|
+
function validateComparison(obligation, target, resources, contents) {
|
|
37
|
+
const { comparison } = obligation;
|
|
38
|
+
if (comparison.mode === "exact" &&
|
|
39
|
+
(comparison.tolerance !== null || comparison.mask !== null))
|
|
40
|
+
invalid("v2_exact_proof_tolerance_forbidden", obligation.key);
|
|
41
|
+
if (comparison.mode === "tolerance" && comparison.tolerance === null)
|
|
42
|
+
invalid("v2_tolerance_proof_tolerance_required", obligation.key);
|
|
43
|
+
if (comparison.mask !== null &&
|
|
44
|
+
comparison.comparator !== "pixel_diff" &&
|
|
45
|
+
!comparison.comparator.startsWith("custom."))
|
|
46
|
+
invalid("v2_proof_mask_comparator_incompatible", `${obligation.key}:${comparison.comparator}`);
|
|
47
|
+
for (const [name, located] of [
|
|
48
|
+
["parameters", comparison.parameters],
|
|
49
|
+
["tolerance", comparison.tolerance],
|
|
50
|
+
["mask", comparison.mask],
|
|
51
|
+
]) {
|
|
52
|
+
if (!located)
|
|
53
|
+
continue;
|
|
54
|
+
validateDesignResourceLocatedDigest(located, resources, contents, `v2.obligation.${obligation.key}.${name}`);
|
|
55
|
+
requireTargetResource(target, located.locator.resource_ref, "v2_proof_resource_outside_target", obligation.key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function validateProtectedValuePolicy(rule, obligation) {
|
|
59
|
+
const plain = obligation.protected_value_policy === "plain_exact_observation";
|
|
60
|
+
if ((rule.observation_sensitivity === "plain" && !plain) ||
|
|
61
|
+
(rule.observation_sensitivity === "protected" &&
|
|
62
|
+
(plain || !obligation.protected_value_policy.trim())))
|
|
63
|
+
invalid("v2_protected_value_policy_mismatch", obligation.key);
|
|
64
|
+
}
|
|
65
|
+
function requireTargetResource(target, resourceRef, code, detail) {
|
|
66
|
+
if (!target.resource_refs.includes(resourceRef))
|
|
67
|
+
invalid(code, `${detail}:${resourceRef}`);
|
|
68
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DesignResourcePropertyDefinitionV1 } from "./design-resource-fact-types.js";
|
|
2
|
+
import type { DesignResource } from "./design-resource-handoff-file-primitives.js";
|
|
3
|
+
import type { DesignResourceSymbolicCompilationSession } from "./design-resource-symbolic-compilation.js";
|
|
4
|
+
import type { DesignResourceHandoffPreflightV2, DesignResourceObservableRuleManifestV2, DesignResourceSymbolicHandoffTargetV2 } from "./design-resource-symbolic-fact-types.js";
|
|
5
|
+
import type { SymbolicManifestIndexes } from "./design-resource-symbolic-indexes.js";
|
|
6
|
+
export declare function validateSymbolicObligations(manifest: DesignResourceObservableRuleManifestV2, projections: DesignResourceHandoffPreflightV2["rule_projections"], properties: Map<string, DesignResourcePropertyDefinitionV1>, oracles: Map<string, DesignResourceObservableRuleManifestV2["oracles"][number]>, environments: Map<string, DesignResourceObservableRuleManifestV2["environments"][number]>, target: DesignResourceSymbolicHandoffTargetV2, resources: Map<string, DesignResource>, contents: Map<string, Buffer>): void;
|
|
7
|
+
export declare function validateSymbolicCertificates(manifest: DesignResourceObservableRuleManifestV2, projections: DesignResourceHandoffPreflightV2["rule_projections"], indexes: SymbolicManifestIndexes, compilation: DesignResourceSymbolicCompilationSession, target: DesignResourceSymbolicHandoffTargetV2, resources: Map<string, DesignResource>, contents: Map<string, Buffer>): {
|
|
8
|
+
coveredOmittedAxes: number;
|
|
9
|
+
coveredDependencyEdges: number;
|
|
10
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { validateSymbolicObligationPolicy, validateSymbolicProofAuthorities, } from "./design-resource-symbolic-proof-authority-validation.js";
|
|
2
|
+
import { validateTrustedSymbolicNoninterference } from "./design-resource-symbolic-noninterference-validation.js";
|
|
3
|
+
import { assertCanonicalSet, assertSameSet, compareText, designResourceSymbolicCertificateKey, designResourceSymbolicCombinedRuleDigest, designResourceSymbolicObligationKey, invalid, omitKey, unique, } from "./design-resource-symbolic-validation-support.js";
|
|
4
|
+
export function validateSymbolicObligations(manifest, projections, properties, oracles, environments, target, resources, contents) {
|
|
5
|
+
validateSymbolicProofAuthorities(manifest, target, resources, contents);
|
|
6
|
+
const obligations = new Map(manifest.semantic_proof_obligations.map((item) => [item.key, item]));
|
|
7
|
+
for (const projection of projections)
|
|
8
|
+
validateRuleObligations(projection, obligations, properties, oracles, environments, target, resources, contents);
|
|
9
|
+
assertSameSet([...obligations.keys()], projections.flatMap((projection) => projection.rule.semantic_obligation_refs), "v2_semantic_obligation_set_mismatch", manifest.target_key);
|
|
10
|
+
}
|
|
11
|
+
function validateRuleObligations(projection, obligations, properties, oracles, environments, target, resources, contents) {
|
|
12
|
+
const { rule } = projection;
|
|
13
|
+
const property = properties.get(rule.property_ref);
|
|
14
|
+
const local = rule.semantic_obligation_refs.map((ref) => {
|
|
15
|
+
const obligation = obligations.get(ref);
|
|
16
|
+
if (!obligation)
|
|
17
|
+
invalid("v2_rule_obligation_unknown", `${rule.key}:${ref}`);
|
|
18
|
+
return obligation;
|
|
19
|
+
});
|
|
20
|
+
assertSameSet(local.map((item) => item.method), property.required_methods, "v2_rule_required_methods_mismatch", rule.key);
|
|
21
|
+
for (const obligation of local)
|
|
22
|
+
validateObligation(obligation, projection, property, oracles, environments, target, resources, contents);
|
|
23
|
+
}
|
|
24
|
+
function validateObligation(obligation, projection, property, oracles, environments, target, resources, contents) {
|
|
25
|
+
if (obligation.fact_rule_ref !== projection.rule.key ||
|
|
26
|
+
obligation.region_sha256 !== projection.compiled_region.canonical_sha256)
|
|
27
|
+
invalid("v2_obligation_rule_region_mismatch", obligation.key);
|
|
28
|
+
const expectedKey = designResourceSymbolicObligationKey(omitKey(obligation));
|
|
29
|
+
if (obligation.key !== expectedKey)
|
|
30
|
+
invalid("v2_obligation_identity_mismatch", `${obligation.key}:${expectedKey}`);
|
|
31
|
+
const oracle = oracles.get(obligation.oracle_ref);
|
|
32
|
+
if (!oracle)
|
|
33
|
+
invalid("v2_obligation_oracle_unknown", obligation.key);
|
|
34
|
+
const environment = environments.get(obligation.environment_ref);
|
|
35
|
+
if (!environment)
|
|
36
|
+
invalid("v2_obligation_environment_unknown", obligation.key);
|
|
37
|
+
validateSymbolicObligationPolicy(obligation, projection.rule, property, oracle, environment, target, resources, contents);
|
|
38
|
+
}
|
|
39
|
+
export function validateSymbolicCertificates(manifest, projections, indexes, compilation, target, resources, contents) {
|
|
40
|
+
const byRule = new Map(projections.map((item) => [item.rule.key, item]));
|
|
41
|
+
assertCanonicalSet(manifest.dependency_edges, [], "v2_dependency_edge_set_mismatch");
|
|
42
|
+
const coveredRules = [];
|
|
43
|
+
const coveredAxes = new Set();
|
|
44
|
+
const coveredEdges = new Set();
|
|
45
|
+
for (const certificate of manifest.noninterference_certificates) {
|
|
46
|
+
if (!certificate.fact_rule_refs.length)
|
|
47
|
+
invalid("v2_certificate_rule_refs_required", certificate.key);
|
|
48
|
+
const local = certificate.fact_rule_refs.map((ref) => {
|
|
49
|
+
const projection = byRule.get(ref);
|
|
50
|
+
if (!projection)
|
|
51
|
+
invalid("v2_certificate_rule_unknown", `${certificate.key}:${ref}`);
|
|
52
|
+
return projection;
|
|
53
|
+
});
|
|
54
|
+
validateCertificate(manifest, certificate, local, indexes, compilation, target, resources, contents);
|
|
55
|
+
coveredRules.push(...certificate.fact_rule_refs);
|
|
56
|
+
certificate.omitted_axis_refs.forEach((ref) => coveredAxes.add(ref));
|
|
57
|
+
certificate.dependency_edge_refs.forEach((ref) => coveredEdges.add(ref));
|
|
58
|
+
}
|
|
59
|
+
assertCertificateCoverage(manifest, projections, coveredRules, coveredEdges);
|
|
60
|
+
return {
|
|
61
|
+
coveredOmittedAxes: coveredAxes.size,
|
|
62
|
+
coveredDependencyEdges: coveredEdges.size,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function validateCertificate(manifest, certificate, projections, indexes, compilation, target, resources, contents) {
|
|
66
|
+
unique(certificate.fact_rule_refs, `v2_certificate_rule_ref_duplicate:${certificate.key}`);
|
|
67
|
+
unique(certificate.omitted_axis_refs, `v2_certificate_omitted_axis_duplicate:${certificate.key}`);
|
|
68
|
+
unique(certificate.dependency_edge_refs, `v2_certificate_dependency_edge_duplicate:${certificate.key}`);
|
|
69
|
+
const expectedAxes = [
|
|
70
|
+
...new Set(projections.flatMap((item) => item.compiled_region.omitted_axis_refs)),
|
|
71
|
+
].sort(compareText);
|
|
72
|
+
if (expectedAxes.length &&
|
|
73
|
+
(!certificate.source_noninterference_proof ||
|
|
74
|
+
!certificate.production_noninterference_proof))
|
|
75
|
+
invalid("v2_noninterference_proof_unavailable", `${certificate.key}:${expectedAxes.join(",")}`);
|
|
76
|
+
assertSameSet(certificate.omitted_axis_refs, expectedAxes, "v2_certificate_omitted_axes_mismatch", certificate.key);
|
|
77
|
+
assertSameSet(certificate.dependency_edge_refs, [], "v2_certificate_dependency_edges_mismatch", certificate.key);
|
|
78
|
+
if (certificate.canonical_rule_dag_sha256 !==
|
|
79
|
+
designResourceSymbolicCombinedRuleDigest(projections))
|
|
80
|
+
invalid("v2_certificate_rule_digest_mismatch", certificate.key);
|
|
81
|
+
const expectedKey = designResourceSymbolicCertificateKey(omitKey(certificate));
|
|
82
|
+
if (certificate.key !== expectedKey)
|
|
83
|
+
invalid("v2_certificate_identity_mismatch", `${certificate.key}:${expectedKey}`);
|
|
84
|
+
validateTrustedSymbolicNoninterference(manifest, certificate, projections, indexes, compilation, target, resources, contents);
|
|
85
|
+
}
|
|
86
|
+
function assertCertificateCoverage(manifest, projections, coveredRules, coveredEdges) {
|
|
87
|
+
assertSameSet(coveredRules, projections.map((item) => item.rule.key), "v2_certificate_rule_coverage_mismatch", manifest.target_key);
|
|
88
|
+
assertSameSet([...coveredEdges], [], "v2_certificate_edge_coverage_mismatch", manifest.target_key);
|
|
89
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DesignResourceHandoffPreflightV2, DesignResourceObservableRuleManifestV2, DesignResourceSymbolicFactRuleV2, ParsedDesignResourceHandoffV2 } from "./design-resource-symbolic-fact-types.js";
|
|
2
|
+
import type { CompiledSymbolicDenotationV1, SymbolicDenotationPredicate } from "./symbolic-denotation-types.js";
|
|
3
|
+
import type { SymbolicApplicabilityIndex } from "./design-resource-symbolic-applicability-validation.js";
|
|
4
|
+
import type { DesignResourceSymbolicCompilationSession } from "./design-resource-symbolic-compilation.js";
|
|
5
|
+
import { type SymbolicManifestIndexes } from "./design-resource-symbolic-indexes.js";
|
|
6
|
+
export declare function validateSymbolicApplicabilityClosure(manifest: DesignResourceObservableRuleManifestV2, reachable: CompiledSymbolicDenotationV1, indexes: SymbolicManifestIndexes, applicability: SymbolicApplicabilityIndex, compilation: DesignResourceSymbolicCompilationSession): void;
|
|
7
|
+
export declare function validateSymbolicCoverage(parsed: ParsedDesignResourceHandoffV2, manifest: DesignResourceObservableRuleManifestV2): void;
|
|
8
|
+
export declare function validateSymbolicRegionWithinReachable(region: SymbolicDenotationPredicate, reachable: SymbolicDenotationPredicate, label: string, compilation: DesignResourceSymbolicCompilationSession): void;
|
|
9
|
+
export declare function validateSymbolicPopulationAndQuantifier(item: {
|
|
10
|
+
key: string;
|
|
11
|
+
population_ref: string | null;
|
|
12
|
+
quantifier: DesignResourceSymbolicFactRuleV2["quantifier"];
|
|
13
|
+
}, subjectPopulationRef: string | null, populations: Map<string, DesignResourceObservableRuleManifestV2["populations"][number]>): void;
|
|
14
|
+
export declare function validateSymbolicQuantifier(quantifier: DesignResourceSymbolicFactRuleV2["quantifier"], label: string): void;
|
|
15
|
+
export declare function aggregateSymbolicCanonicalMetrics(projections: DesignResourceHandoffPreflightV2["rule_projections"]): {
|
|
16
|
+
nodes: number;
|
|
17
|
+
edges: number;
|
|
18
|
+
bytes: number;
|
|
19
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { DEFAULT_SYMBOLIC_DENOTATION_COMPLEXITY_LIMITS } from "./symbolic-denotation-engine.js";
|
|
2
|
+
import { assertSameSet, compareText, invalid, requireKnownRefs, stableJson, } from "./design-resource-symbolic-validation-support.js";
|
|
3
|
+
import { symbolicSubjectPropertyKey, } from "./design-resource-symbolic-indexes.js";
|
|
4
|
+
export function validateSymbolicApplicabilityClosure(manifest, reachable, indexes, applicability, compilation) {
|
|
5
|
+
for (const subject of manifest.subjects)
|
|
6
|
+
for (const property of manifest.properties)
|
|
7
|
+
validateSubjectPropertyPartition(reachable, subject.key, property.key, indexes, applicability, compilation);
|
|
8
|
+
}
|
|
9
|
+
function validateSubjectPropertyPartition(reachable, subjectRef, propertyRef, indexes, applicability, compilation) {
|
|
10
|
+
const tupleKey = symbolicSubjectPropertyKey(subjectRef, propertyRef);
|
|
11
|
+
const regions = [
|
|
12
|
+
...(indexes.rulesBySubjectProperty.get(tupleKey) ?? []),
|
|
13
|
+
...(indexes.dispositionsBySubjectProperty.get(tupleKey) ?? []),
|
|
14
|
+
];
|
|
15
|
+
const label = `${subjectRef}:${propertyRef}`;
|
|
16
|
+
if (!applicability.isApplicable(subjectRef, propertyRef)) {
|
|
17
|
+
if (regions.length)
|
|
18
|
+
invalid("v2_structural_not_applicable_materialized", label);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!regions.length)
|
|
22
|
+
invalid("v2_applicability_remainder_uncovered", label);
|
|
23
|
+
assertRegionsMutuallyExclusive(regions, compilation);
|
|
24
|
+
const union = compilation.compile({
|
|
25
|
+
op: "any",
|
|
26
|
+
predicates: regions.map((region) => region.region),
|
|
27
|
+
});
|
|
28
|
+
if (union.canonical_sha256 !== reachable.canonical_sha256)
|
|
29
|
+
invalid("v2_effective_region_coverage_gap", label);
|
|
30
|
+
}
|
|
31
|
+
function assertRegionsMutuallyExclusive(regions, compilation) {
|
|
32
|
+
for (let left = 0; left < regions.length; left += 1)
|
|
33
|
+
for (let right = left + 1; right < regions.length; right += 1) {
|
|
34
|
+
const overlap = compilation.compile({
|
|
35
|
+
op: "all",
|
|
36
|
+
predicates: [regions[left].region, regions[right].region],
|
|
37
|
+
});
|
|
38
|
+
if (overlap.canonical_dag.root_ref !== "terminal.false")
|
|
39
|
+
invalid("v2_effective_region_overlap", `${regions[left].key}:${regions[right].key}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function validateSymbolicCoverage(parsed, manifest) {
|
|
43
|
+
const rows = parsed.handoff.coverage.filter((row) => row.target_ref === manifest.target_key);
|
|
44
|
+
if (!rows.length)
|
|
45
|
+
invalid("v2_coverage_required", manifest.target_key);
|
|
46
|
+
for (const [code, actual, expected] of coverageSets(rows, manifest))
|
|
47
|
+
assertSameSet(actual, expected, code, manifest.target_key);
|
|
48
|
+
requireKnownRefs(rows.flatMap((row) => row.source_item_refs), new Set(parsed.source_item_keys), "v2_coverage_source_item_unknown");
|
|
49
|
+
}
|
|
50
|
+
function coverageSets(rows, manifest) {
|
|
51
|
+
return [
|
|
52
|
+
[
|
|
53
|
+
"v2_coverage_subject_set_mismatch",
|
|
54
|
+
rows.flatMap((row) => row.subject_or_relation_refs),
|
|
55
|
+
manifest.subjects.map((item) => item.key),
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
"v2_coverage_property_set_mismatch",
|
|
59
|
+
rows.flatMap((row) => row.property_refs),
|
|
60
|
+
manifest.properties.map((item) => item.key),
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"v2_coverage_rule_set_mismatch",
|
|
64
|
+
rows.flatMap((row) => row.fact_rule_refs),
|
|
65
|
+
manifest.fact_rules.map((item) => item.key),
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"v2_coverage_obligation_set_mismatch",
|
|
69
|
+
rows.flatMap((row) => row.semantic_obligation_refs),
|
|
70
|
+
manifest.semantic_proof_obligations.map((item) => item.key),
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
"v2_coverage_certificate_set_mismatch",
|
|
74
|
+
rows.flatMap((row) => row.certificate_refs),
|
|
75
|
+
manifest.noninterference_certificates.map((item) => item.key),
|
|
76
|
+
],
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
export function validateSymbolicRegionWithinReachable(region, reachable, label, compilation) {
|
|
80
|
+
const outside = compilation.compile({
|
|
81
|
+
op: "all",
|
|
82
|
+
predicates: [region, { op: "not", predicate: reachable }],
|
|
83
|
+
});
|
|
84
|
+
if (outside.canonical_dag.root_ref !== "terminal.false")
|
|
85
|
+
invalid("v2_region_claims_unreachable", label);
|
|
86
|
+
}
|
|
87
|
+
export function validateSymbolicPopulationAndQuantifier(item, subjectPopulationRef, populations) {
|
|
88
|
+
if (item.population_ref !== subjectPopulationRef)
|
|
89
|
+
invalid("v2_population_binding_mismatch", item.key);
|
|
90
|
+
const expected = item.population_ref
|
|
91
|
+
? populations.get(item.population_ref)?.quantifier
|
|
92
|
+
: { kind: "one", minimum: 1, maximum: 1 };
|
|
93
|
+
if (!expected || stableJson(item.quantifier) !== stableJson(expected))
|
|
94
|
+
invalid("v2_quantifier_mismatch", item.key);
|
|
95
|
+
validateSymbolicQuantifier(item.quantifier, item.key);
|
|
96
|
+
}
|
|
97
|
+
export function validateSymbolicQuantifier(quantifier, label) {
|
|
98
|
+
const { kind, minimum, maximum } = quantifier;
|
|
99
|
+
const invalidParameters = kind === "one"
|
|
100
|
+
? minimum !== 1 || maximum !== 1
|
|
101
|
+
: kind === "exactly"
|
|
102
|
+
? minimum === null || maximum !== minimum
|
|
103
|
+
: kind === "at_least"
|
|
104
|
+
? minimum === null || maximum !== null
|
|
105
|
+
: kind === "at_most"
|
|
106
|
+
? minimum !== null || maximum === null
|
|
107
|
+
: kind === "range"
|
|
108
|
+
? minimum === null || maximum === null || minimum > maximum
|
|
109
|
+
: minimum !== null || maximum !== null;
|
|
110
|
+
if (invalidParameters)
|
|
111
|
+
invalid("v2_quantifier_parameters_invalid", label);
|
|
112
|
+
}
|
|
113
|
+
export function aggregateSymbolicCanonicalMetrics(projections) {
|
|
114
|
+
const nodes = collectCanonicalNodes(projections);
|
|
115
|
+
const roots = projections
|
|
116
|
+
.map((projection) => ({
|
|
117
|
+
rule_ref: projection.rule.key,
|
|
118
|
+
root_ref: projection.compiled_region.canonical_dag.root_ref,
|
|
119
|
+
}))
|
|
120
|
+
.sort((left, right) => compareText(left.rule_ref, right.rule_ref));
|
|
121
|
+
const canonicalNodes = [...nodes.values()].sort((left, right) => compareText(left.key, right.key));
|
|
122
|
+
const bytes = Buffer.byteLength(stableJson({
|
|
123
|
+
schema_version: "design-resource-symbolic-rule-dag-set-v2",
|
|
124
|
+
roots,
|
|
125
|
+
nodes: canonicalNodes,
|
|
126
|
+
}), "utf8");
|
|
127
|
+
const limit = DEFAULT_SYMBOLIC_DENOTATION_COMPLEXITY_LIMITS.max_canonical_bytes;
|
|
128
|
+
if (bytes > limit)
|
|
129
|
+
invalid("v2_shared_canonical_byte_limit_exceeded", `actual=${bytes}:limit=${limit}`);
|
|
130
|
+
return {
|
|
131
|
+
nodes: canonicalNodes.length,
|
|
132
|
+
edges: canonicalNodes.reduce((total, node) => total + node.edges.length, 0),
|
|
133
|
+
bytes,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function collectCanonicalNodes(projections) {
|
|
137
|
+
const nodes = new Map();
|
|
138
|
+
for (const projection of projections)
|
|
139
|
+
for (const node of projection.compiled_region.canonical_dag.nodes) {
|
|
140
|
+
const previous = nodes.get(node.key);
|
|
141
|
+
if (previous && stableJson(previous) !== stableJson(node))
|
|
142
|
+
invalid("v2_shared_dag_node_collision", node.key);
|
|
143
|
+
nodes.set(node.key, node);
|
|
144
|
+
}
|
|
145
|
+
return nodes;
|
|
146
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DesignResourcePropertyDefinitionV1 } from "./design-resource-fact-types.js";
|
|
2
|
+
import type { DesignResource } from "./design-resource-handoff-file-primitives.js";
|
|
3
|
+
import type { DesignResourceObservableRuleManifestV2, ParsedDesignResourceHandoffV2 } from "./design-resource-symbolic-fact-types.js";
|
|
4
|
+
export declare function validateSymbolicInspectorAndResources(manifest: DesignResourceObservableRuleManifestV2, target: ParsedDesignResourceHandoffV2["handoff"]["targets"][number], resources: Map<string, DesignResource>, contents: Map<string, Buffer>): void;
|
|
5
|
+
export declare function validateSymbolicPropertyCatalog(properties: DesignResourcePropertyDefinitionV1[]): void;
|