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,90 @@
|
|
|
1
|
+
import { DESIGN_RESOURCE_STANDARD_PROPERTIES } from "./design-resource-fact-manifest-catalog.js";
|
|
2
|
+
import { resolveDesignResourceLocatorValue } from "./design-resource-fact-locator-validation.js";
|
|
3
|
+
import { assertSameSet, compareText, invalid, stableJson, } from "./design-resource-symbolic-validation-support.js";
|
|
4
|
+
export function validateSymbolicInspectorAndResources(manifest, target, resources, contents) {
|
|
5
|
+
if ((manifest.inspector.trust === "frozen_executable" &&
|
|
6
|
+
manifest.inspector.implementation_sha256 === null) ||
|
|
7
|
+
(manifest.inspector.trust === "named_external_tcb" &&
|
|
8
|
+
manifest.inspector.implementation_sha256 !== null))
|
|
9
|
+
invalid("v2_inspector_trust_digest_mismatch", target.key);
|
|
10
|
+
if (manifest.inspector.traversal !== "complete_enumeration" ||
|
|
11
|
+
manifest.inspector.dynamic_discovery !== "fully_enumerated")
|
|
12
|
+
invalid("v2_inspector_incomplete", target.key);
|
|
13
|
+
if (manifest.inspector.entry_resource_ref !==
|
|
14
|
+
target.source_profile.entry_resource_ref)
|
|
15
|
+
invalid("v2_inspector_entry_mismatch", target.key);
|
|
16
|
+
assertSameSet(manifest.inspector.input_resources.map((item) => item.resource_ref), inspectorInputResourceRefs(manifest, target), "v2_inspector_input_resource_set_mismatch", target.key);
|
|
17
|
+
for (const input of manifest.inspector.input_resources) {
|
|
18
|
+
const resource = resources.get(input.resource_ref);
|
|
19
|
+
if (!resource ||
|
|
20
|
+
resource.path !== input.path ||
|
|
21
|
+
resource.sha256 !== input.sha256 ||
|
|
22
|
+
!contents.has(input.resource_ref))
|
|
23
|
+
invalid("v2_inspector_input_resource_mismatch", input.resource_ref);
|
|
24
|
+
}
|
|
25
|
+
for (const row of manifest.inspector.census) {
|
|
26
|
+
const resource = resources.get(row.resource_ref);
|
|
27
|
+
const bytes = contents.get(row.resource_ref);
|
|
28
|
+
if (!resource || !bytes)
|
|
29
|
+
invalid("v2_census_resource_unknown", row.key);
|
|
30
|
+
if (!manifest.inspector.input_resources.some((input) => input.resource_ref === row.resource_ref))
|
|
31
|
+
invalid("v2_census_resource_outside_inspector_inputs", row.key);
|
|
32
|
+
resolveDesignResourceLocatorValue({ resource_ref: row.resource_ref, ...row.locator }, resource, bytes, `v2.inspector.census.${row.key}`);
|
|
33
|
+
if (row.disposition === "covered" && !row.fact_refs.length)
|
|
34
|
+
invalid("v2_census_rule_refs_required", row.key);
|
|
35
|
+
if (row.disposition === "non_material" && row.fact_refs.length)
|
|
36
|
+
invalid("v2_non_material_census_rule_refs_forbidden", row.key);
|
|
37
|
+
if (row.fact_cell_refs.length)
|
|
38
|
+
invalid("v2_census_ground_fact_cell_refs_forbidden", row.key);
|
|
39
|
+
}
|
|
40
|
+
if (manifest.design_system.disposition === "used") {
|
|
41
|
+
const resource = resources.get(manifest.design_system.resource_ref);
|
|
42
|
+
if (!resource || resource.sha256 !== manifest.design_system.sha256)
|
|
43
|
+
invalid("v2_design_system_resource_mismatch", target.key);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function inspectorInputResourceRefs(manifest, target) {
|
|
47
|
+
const proofArtifactRefs = new Set(manifest.noninterference_certificates.flatMap((certificate) => [
|
|
48
|
+
certificate.source_noninterference_proof,
|
|
49
|
+
certificate.production_noninterference_proof,
|
|
50
|
+
]
|
|
51
|
+
.filter((proof) => proof != null)
|
|
52
|
+
.map((proof) => proof.artifact_resource_ref)));
|
|
53
|
+
return target.resource_refs.filter((ref) => ref !== target.source_profile.fact_manifest_resource_ref &&
|
|
54
|
+
!proofArtifactRefs.has(ref));
|
|
55
|
+
}
|
|
56
|
+
export function validateSymbolicPropertyCatalog(properties) {
|
|
57
|
+
const actual = new Map(properties.map((property) => [property.key, property]));
|
|
58
|
+
for (const standard of DESIGN_RESOURCE_STANDARD_PROPERTIES) {
|
|
59
|
+
const candidate = actual.get(standard.key);
|
|
60
|
+
if (!candidate)
|
|
61
|
+
invalid("v2_standard_property_missing", standard.key);
|
|
62
|
+
if (stableJson(propertyPolicy(candidate)) !==
|
|
63
|
+
stableJson(propertyPolicy(standard)))
|
|
64
|
+
invalid("v2_standard_property_definition_mismatch", standard.key);
|
|
65
|
+
}
|
|
66
|
+
for (const property of properties)
|
|
67
|
+
validatePropertyAuthority(property);
|
|
68
|
+
}
|
|
69
|
+
function validatePropertyAuthority(property) {
|
|
70
|
+
if (property.standard) {
|
|
71
|
+
if (!DESIGN_RESOURCE_STANDARD_PROPERTIES.some((item) => item.key === property.key))
|
|
72
|
+
invalid("v2_unknown_standard_property", property.key);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!property.key.startsWith("custom.") ||
|
|
76
|
+
!property.inspector_capability_refs.length ||
|
|
77
|
+
!property.census_refs.length)
|
|
78
|
+
invalid("v2_custom_property_authority_incomplete", property.key);
|
|
79
|
+
}
|
|
80
|
+
function propertyPolicy(property) {
|
|
81
|
+
return {
|
|
82
|
+
key: property.key,
|
|
83
|
+
family: property.family,
|
|
84
|
+
dimension: property.dimension,
|
|
85
|
+
value_kind: property.value_kind,
|
|
86
|
+
required_methods: [...property.required_methods].sort(compareText),
|
|
87
|
+
standard: property.standard,
|
|
88
|
+
inspector_capability_refs: [...property.inspector_capability_refs].sort(compareText),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DesignResourceSymbolicFactRuleV2, DesignResourceSymbolicPopulationV2 } from "./design-resource-symbolic-fact-types.js";
|
|
2
|
+
export declare function parseSymbolicPopulations(value: unknown, label: string): DesignResourceSymbolicPopulationV2[];
|
|
3
|
+
export declare function parseSymbolicFactRules(value: unknown, label: string): DesignResourceSymbolicFactRuleV2[];
|
|
4
|
+
export declare function parseSymbolicObligation(value: unknown, label: string): {
|
|
5
|
+
key: string;
|
|
6
|
+
fact_rule_ref: string;
|
|
7
|
+
method: "accessibility_navigation" | "accessibility_semantics" | "accessibility_visual" | "asset_integrity" | "component_state" | "content" | "design_token" | "gesture_trace" | "haptic_feedback" | "input_method" | "interaction_trace" | "layout_geometry" | "localization" | "motion_timeline" | "responsive_reflow" | "scroll_navigation" | "sound_feedback" | "system_ui" | "visual_pixel";
|
|
8
|
+
region_sha256: string;
|
|
9
|
+
proof_surface: string;
|
|
10
|
+
observation_boundary: string;
|
|
11
|
+
comparison: {
|
|
12
|
+
comparator: string;
|
|
13
|
+
mode: "exact" | "tolerance";
|
|
14
|
+
parameters: import("./design-resource-fact-types.js").DesignResourceLocatedDigestV1;
|
|
15
|
+
tolerance: import("./design-resource-fact-types.js").DesignResourceLocatedDigestV1 | null;
|
|
16
|
+
mask: import("./design-resource-fact-types.js").DesignResourceLocatedDigestV1 | null;
|
|
17
|
+
};
|
|
18
|
+
oracle_ref: string;
|
|
19
|
+
environment_ref: string;
|
|
20
|
+
protected_value_policy: string;
|
|
21
|
+
completion_effect: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function parseSymbolicQuantifier(value: unknown, label: string): {
|
|
24
|
+
kind: "all" | "any" | "at_least" | "at_most" | "exactly" | "none" | "one" | "range";
|
|
25
|
+
minimum: number | null;
|
|
26
|
+
maximum: number | null;
|
|
27
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { parseDesignResourceLocatedDigest } from "./design-resource-fact-shape-primitives.js";
|
|
2
|
+
import { contractKey, sha256, sourceItemKeys, stableKey, stableKeys, } from "./design-resource-handoff-shape-primitives.js";
|
|
3
|
+
import { DESIGN_RESOURCE_VERIFICATION_METHODS } from "./design-resource-handoff-types.js";
|
|
4
|
+
import { parseSymbolicNonnegativeInteger, parseSymbolicPredicate, } from "./design-resource-symbolic-predicate-shape.js";
|
|
5
|
+
import { array, literal, nullable, object, string, } from "./long-task-shape-primitives.js";
|
|
6
|
+
export function parseSymbolicPopulations(value, label) {
|
|
7
|
+
return array(value, label).map((item, index) => {
|
|
8
|
+
const itemLabel = `${label}[${index}]`;
|
|
9
|
+
const row = object(item, itemLabel, [
|
|
10
|
+
"key",
|
|
11
|
+
"kind",
|
|
12
|
+
"member_subject_refs",
|
|
13
|
+
"universe",
|
|
14
|
+
"enumeration",
|
|
15
|
+
"exclusions",
|
|
16
|
+
"quantifier",
|
|
17
|
+
]);
|
|
18
|
+
return {
|
|
19
|
+
key: stableKey(row.key, `${itemLabel}.key`),
|
|
20
|
+
kind: literal(row.kind, ["static", "dynamic"], `${itemLabel}.kind`),
|
|
21
|
+
member_subject_refs: stableKeys(row.member_subject_refs, `${itemLabel}.member_subject_refs`),
|
|
22
|
+
universe: parseDesignResourceLocatedDigest(row.universe, `${itemLabel}.universe`),
|
|
23
|
+
enumeration: literal(row.enumeration, ["complete", "symbolic_partition"], `${itemLabel}.enumeration`),
|
|
24
|
+
exclusions: array(row.exclusions, `${itemLabel}.exclusions`).map((entry, exclusionIndex) => parsePopulationExclusion(entry, `${itemLabel}.exclusions[${exclusionIndex}]`)),
|
|
25
|
+
quantifier: parseSymbolicQuantifier(row.quantifier, `${itemLabel}.quantifier`),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function parsePopulationExclusion(value, label) {
|
|
30
|
+
const row = object(value, label, [
|
|
31
|
+
"key",
|
|
32
|
+
"region",
|
|
33
|
+
"basis_refs",
|
|
34
|
+
"rationale",
|
|
35
|
+
]);
|
|
36
|
+
return {
|
|
37
|
+
key: stableKey(row.key, `${label}.key`),
|
|
38
|
+
region: parseSymbolicPredicate(row.region, `${label}.region`),
|
|
39
|
+
basis_refs: stableKeys(row.basis_refs, `${label}.basis_refs`),
|
|
40
|
+
rationale: string(row.rationale, `${label}.rationale`),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function parseSymbolicFactRules(value, label) {
|
|
44
|
+
return array(value, label).map((item, index) => parseSymbolicFactRule(item, `${label}[${index}]`));
|
|
45
|
+
}
|
|
46
|
+
function parseSymbolicFactRule(value, label) {
|
|
47
|
+
const row = object(value, label, [
|
|
48
|
+
"key",
|
|
49
|
+
"subject_or_relation_ref",
|
|
50
|
+
"target_ref",
|
|
51
|
+
"property_ref",
|
|
52
|
+
"population_ref",
|
|
53
|
+
"quantifier",
|
|
54
|
+
"region",
|
|
55
|
+
"expected",
|
|
56
|
+
"value_kind",
|
|
57
|
+
"provenance_ref",
|
|
58
|
+
"observation_scope",
|
|
59
|
+
"observation_sensitivity",
|
|
60
|
+
"lineage",
|
|
61
|
+
"evidence_refs",
|
|
62
|
+
"census_refs",
|
|
63
|
+
"source_item_refs",
|
|
64
|
+
"semantic_obligation_refs",
|
|
65
|
+
]);
|
|
66
|
+
const lineage = object(row.lineage, `${label}.lineage`, [
|
|
67
|
+
"design_system_ref",
|
|
68
|
+
"token_chain_refs",
|
|
69
|
+
"override_chain_refs",
|
|
70
|
+
"resolved_value",
|
|
71
|
+
"conflict_status",
|
|
72
|
+
"conflict_resolution",
|
|
73
|
+
]);
|
|
74
|
+
return {
|
|
75
|
+
key: stableKey(row.key, `${label}.key`),
|
|
76
|
+
subject_or_relation_ref: stableKey(row.subject_or_relation_ref, `${label}.subject_or_relation_ref`),
|
|
77
|
+
target_ref: contractKey(row.target_ref, `${label}.target_ref`),
|
|
78
|
+
property_ref: stableKey(row.property_ref, `${label}.property_ref`),
|
|
79
|
+
population_ref: nullable(row.population_ref, (entry) => stableKey(entry, `${label}.population_ref`)),
|
|
80
|
+
quantifier: parseSymbolicQuantifier(row.quantifier, `${label}.quantifier`),
|
|
81
|
+
region: parseSymbolicPredicate(row.region, `${label}.region`),
|
|
82
|
+
expected: parseDesignResourceLocatedDigest(row.expected, `${label}.expected`),
|
|
83
|
+
value_kind: stableKey(row.value_kind, `${label}.value_kind`),
|
|
84
|
+
provenance_ref: string(row.provenance_ref, `${label}.provenance_ref`),
|
|
85
|
+
observation_scope: literal(row.observation_scope, ["subject", "full_target"], `${label}.observation_scope`),
|
|
86
|
+
observation_sensitivity: literal(row.observation_sensitivity, ["plain", "protected"], `${label}.observation_sensitivity`),
|
|
87
|
+
lineage: {
|
|
88
|
+
design_system_ref: nullable(lineage.design_system_ref, (entry) => stableKey(entry, `${label}.lineage.design_system_ref`)),
|
|
89
|
+
token_chain_refs: stableKeys(lineage.token_chain_refs, `${label}.lineage.token_chain_refs`),
|
|
90
|
+
override_chain_refs: stableKeys(lineage.override_chain_refs, `${label}.lineage.override_chain_refs`),
|
|
91
|
+
resolved_value: parseDesignResourceLocatedDigest(lineage.resolved_value, `${label}.lineage.resolved_value`),
|
|
92
|
+
conflict_status: literal(lineage.conflict_status, ["none", "resolved"], `${label}.lineage.conflict_status`),
|
|
93
|
+
conflict_resolution: string(lineage.conflict_resolution, `${label}.lineage.conflict_resolution`),
|
|
94
|
+
},
|
|
95
|
+
evidence_refs: stableKeys(row.evidence_refs, `${label}.evidence_refs`),
|
|
96
|
+
census_refs: stableKeys(row.census_refs, `${label}.census_refs`),
|
|
97
|
+
source_item_refs: sourceItemKeys(row.source_item_refs, `${label}.source_item_refs`),
|
|
98
|
+
semantic_obligation_refs: stableKeys(row.semantic_obligation_refs, `${label}.semantic_obligation_refs`),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function parseSymbolicObligation(value, label) {
|
|
102
|
+
const row = object(value, label, [
|
|
103
|
+
"key",
|
|
104
|
+
"fact_rule_ref",
|
|
105
|
+
"method",
|
|
106
|
+
"region_sha256",
|
|
107
|
+
"proof_surface",
|
|
108
|
+
"observation_boundary",
|
|
109
|
+
"comparison",
|
|
110
|
+
"oracle_ref",
|
|
111
|
+
"environment_ref",
|
|
112
|
+
"protected_value_policy",
|
|
113
|
+
"completion_effect",
|
|
114
|
+
]);
|
|
115
|
+
const comparison = object(row.comparison, `${label}.comparison`, [
|
|
116
|
+
"comparator",
|
|
117
|
+
"mode",
|
|
118
|
+
"parameters",
|
|
119
|
+
"tolerance",
|
|
120
|
+
"mask",
|
|
121
|
+
]);
|
|
122
|
+
return {
|
|
123
|
+
key: stableKey(row.key, `${label}.key`),
|
|
124
|
+
fact_rule_ref: stableKey(row.fact_rule_ref, `${label}.fact_rule_ref`),
|
|
125
|
+
method: literal(row.method, DESIGN_RESOURCE_VERIFICATION_METHODS, `${label}.method`),
|
|
126
|
+
region_sha256: sha256(row.region_sha256, `${label}.region_sha256`),
|
|
127
|
+
proof_surface: string(row.proof_surface, `${label}.proof_surface`),
|
|
128
|
+
observation_boundary: string(row.observation_boundary, `${label}.observation_boundary`),
|
|
129
|
+
comparison: {
|
|
130
|
+
comparator: string(comparison.comparator, `${label}.comparison.comparator`),
|
|
131
|
+
mode: literal(comparison.mode, ["exact", "tolerance"], `${label}.comparison.mode`),
|
|
132
|
+
parameters: parseDesignResourceLocatedDigest(comparison.parameters, `${label}.comparison.parameters`),
|
|
133
|
+
tolerance: nullable(comparison.tolerance, (entry) => parseDesignResourceLocatedDigest(entry, `${label}.comparison.tolerance`)),
|
|
134
|
+
mask: nullable(comparison.mask, (entry) => parseDesignResourceLocatedDigest(entry, `${label}.comparison.mask`)),
|
|
135
|
+
},
|
|
136
|
+
oracle_ref: stableKey(row.oracle_ref, `${label}.oracle_ref`),
|
|
137
|
+
environment_ref: stableKey(row.environment_ref, `${label}.environment_ref`),
|
|
138
|
+
protected_value_policy: string(row.protected_value_policy, `${label}.protected_value_policy`),
|
|
139
|
+
completion_effect: string(row.completion_effect, `${label}.completion_effect`),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function parseSymbolicQuantifier(value, label) {
|
|
143
|
+
const row = object(value, label, ["kind", "minimum", "maximum"]);
|
|
144
|
+
return {
|
|
145
|
+
kind: literal(row.kind, [
|
|
146
|
+
"one",
|
|
147
|
+
"all",
|
|
148
|
+
"any",
|
|
149
|
+
"none",
|
|
150
|
+
"exactly",
|
|
151
|
+
"at_least",
|
|
152
|
+
"at_most",
|
|
153
|
+
"range",
|
|
154
|
+
], `${label}.kind`),
|
|
155
|
+
minimum: nullable(row.minimum, (entry) => parseSymbolicNonnegativeInteger(entry, `${label}.minimum`)),
|
|
156
|
+
maximum: nullable(row.maximum, (entry) => parseSymbolicNonnegativeInteger(entry, `${label}.maximum`)),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DesignResourceHandoffPreflightV2, DesignResourceObservableRuleManifestV2 } from "./design-resource-symbolic-fact-types.js";
|
|
2
|
+
import type { DesignResourceSymbolicCompilationSession } from "./design-resource-symbolic-compilation.js";
|
|
3
|
+
import type { CompiledSymbolicDenotationV1 } from "./symbolic-denotation-types.js";
|
|
4
|
+
export declare function validateSymbolicReadinessClosure(manifest: DesignResourceObservableRuleManifestV2): void;
|
|
5
|
+
export declare function assertNoUnprovedOmittedAxes(compiled: CompiledSymbolicDenotationV1, label: string): void;
|
|
6
|
+
export declare function validateSymbolicExactTargetCoverage(interpretation: "exact_target" | "constraint", manifest: DesignResourceObservableRuleManifestV2, projections: DesignResourceHandoffPreflightV2["rule_projections"], reachable: CompiledSymbolicDenotationV1, compilation: DesignResourceSymbolicCompilationSession): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EXACT_TARGET_FULL_TARGET_METHODS } from "./design-resource-fact-policy.js";
|
|
2
|
+
import { invalid } from "./design-resource-symbolic-validation-support.js";
|
|
3
|
+
export function validateSymbolicReadinessClosure(manifest) {
|
|
4
|
+
if (manifest.acceptance_blockers.length)
|
|
5
|
+
invalid("acceptance_blockers_unresolved", manifest.acceptance_blockers.map((item) => item.key).join(","));
|
|
6
|
+
}
|
|
7
|
+
export function assertNoUnprovedOmittedAxes(compiled, label) {
|
|
8
|
+
if (compiled.omitted_axis_refs.length)
|
|
9
|
+
invalid("v2_noninterference_proof_unavailable", `${label}:${compiled.omitted_axis_refs.join(",")}`);
|
|
10
|
+
}
|
|
11
|
+
export function validateSymbolicExactTargetCoverage(interpretation, manifest, projections, reachable, compilation) {
|
|
12
|
+
if (interpretation !== "exact_target")
|
|
13
|
+
return;
|
|
14
|
+
const obligations = new Map(manifest.semantic_proof_obligations.map((item) => [item.key, item]));
|
|
15
|
+
for (const method of EXACT_TARGET_FULL_TARGET_METHODS) {
|
|
16
|
+
const regions = projections
|
|
17
|
+
.filter(({ rule }) => rule.observation_scope === "full_target" &&
|
|
18
|
+
rule.semantic_obligation_refs.some((ref) => obligations.get(ref)?.method === method))
|
|
19
|
+
.map(({ rule }) => rule.region);
|
|
20
|
+
if (!regions.length)
|
|
21
|
+
invalid("v2_exact_target_full_target_method_missing", method);
|
|
22
|
+
const covered = compilation.compile({
|
|
23
|
+
op: "any",
|
|
24
|
+
predicates: regions,
|
|
25
|
+
});
|
|
26
|
+
if (covered.canonical_sha256 !== reachable.canonical_sha256)
|
|
27
|
+
invalid("v2_exact_target_full_target_region_gap", method);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CompiledSymbolicDenotationV1, SymbolicDenotationAxisDomain, SymbolicDenotationScalar } from "./symbolic-denotation-types.js";
|
|
2
|
+
export declare const MAX_SOURCE_EXHAUSTIVE_DOMAIN_CARDINALITY = 100000n;
|
|
3
|
+
export interface SymbolicSourceExhaustiveCaseV1 {
|
|
4
|
+
fact_rule_refs: string[];
|
|
5
|
+
source: CompiledSymbolicDenotationV1;
|
|
6
|
+
rule: CompiledSymbolicDenotationV1;
|
|
7
|
+
}
|
|
8
|
+
export interface SymbolicSourceExhaustiveCounterexampleV1 {
|
|
9
|
+
kind: "source_rule_denotation_mismatch" | "complete_domain_counterexample";
|
|
10
|
+
axis_ref: string | null;
|
|
11
|
+
fact_rule_ref: string;
|
|
12
|
+
assignment: Record<string, SymbolicDenotationScalar>;
|
|
13
|
+
detail: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function evaluateCompleteSymbolicSourceDomain(domains: SymbolicDenotationAxisDomain[], omittedAxisRefs: string[], cases: SymbolicSourceExhaustiveCaseV1[]): {
|
|
16
|
+
cardinality: string;
|
|
17
|
+
evaluation_sha256: string;
|
|
18
|
+
counterexample: SymbolicSourceExhaustiveCounterexampleV1 | null;
|
|
19
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { evaluateCanonicalSymbolicDenotation } from "./symbolic-denotation-engine.js";
|
|
3
|
+
import { domainCardinality } from "./symbolic-denotation-support.js";
|
|
4
|
+
import { compareText, stableJson, } from "./design-resource-symbolic-validation-support.js";
|
|
5
|
+
export const MAX_SOURCE_EXHAUSTIVE_DOMAIN_CARDINALITY = 100000n;
|
|
6
|
+
export function evaluateCompleteSymbolicSourceDomain(domains, omittedAxisRefs, cases) {
|
|
7
|
+
const sortedDomains = [...domains].sort((left, right) => compareText(left.key, right.key));
|
|
8
|
+
const cardinality = sortedDomains.reduce((total, domain) => total * domainCardinality(domain), 1n);
|
|
9
|
+
if (cardinality > MAX_SOURCE_EXHAUSTIVE_DOMAIN_CARDINALITY)
|
|
10
|
+
throw new Error(`source_complete_domain_capacity_exceeded:actual=${cardinality}:limit=${MAX_SOURCE_EXHAUSTIVE_DOMAIN_CARDINALITY}`);
|
|
11
|
+
const omitted = new Set(omittedAxisRefs);
|
|
12
|
+
const anchor = Object.fromEntries(sortedDomains.map((domain) => [domain.key, domainValues(domain)[0]]));
|
|
13
|
+
const hash = createHash("sha256");
|
|
14
|
+
let independenceCounterexample = null;
|
|
15
|
+
let ruleCounterexample = null;
|
|
16
|
+
for (const assignment of enumerateAssignments(sortedDomains)) {
|
|
17
|
+
const axisErasedAssignment = { ...assignment };
|
|
18
|
+
for (const axisRef of omitted)
|
|
19
|
+
axisErasedAssignment[axisRef] = anchor[axisRef];
|
|
20
|
+
for (const proofCase of cases) {
|
|
21
|
+
const source = evaluateCanonicalSymbolicDenotation(proofCase.source.canonical_dag, assignment);
|
|
22
|
+
const rule = evaluateCanonicalSymbolicDenotation(proofCase.rule.canonical_dag, assignment);
|
|
23
|
+
const axisErased = evaluateCanonicalSymbolicDenotation(proofCase.source.canonical_dag, axisErasedAssignment);
|
|
24
|
+
hash.update(stableJson({
|
|
25
|
+
assignment,
|
|
26
|
+
axis_erased: axisErased,
|
|
27
|
+
rule,
|
|
28
|
+
source,
|
|
29
|
+
rule_refs: proofCase.fact_rule_refs,
|
|
30
|
+
}));
|
|
31
|
+
hash.update("\n");
|
|
32
|
+
if (!independenceCounterexample && source !== axisErased) {
|
|
33
|
+
const axisRef = omittedAxisRefs.find((ref) => assignment[ref] !== anchor[ref]);
|
|
34
|
+
independenceCounterexample = {
|
|
35
|
+
kind: "complete_domain_counterexample",
|
|
36
|
+
axis_ref: axisRef ?? omittedAxisRefs[0] ?? null,
|
|
37
|
+
fact_rule_ref: proofCase.fact_rule_refs[0],
|
|
38
|
+
assignment: { ...assignment },
|
|
39
|
+
detail: "current Source denotation changes after omitted axes are erased",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (!ruleCounterexample && source !== rule)
|
|
43
|
+
ruleCounterexample = {
|
|
44
|
+
kind: "source_rule_denotation_mismatch",
|
|
45
|
+
axis_ref: null,
|
|
46
|
+
fact_rule_ref: proofCase.fact_rule_refs[0],
|
|
47
|
+
assignment: { ...assignment },
|
|
48
|
+
detail: "current Source denotation differs from the current Rule region",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
cardinality: cardinality.toString(),
|
|
54
|
+
evaluation_sha256: hash.digest("hex"),
|
|
55
|
+
counterexample: independenceCounterexample ?? ruleCounterexample,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function* enumerateAssignments(domains, index = 0, current = {}) {
|
|
59
|
+
if (index === domains.length) {
|
|
60
|
+
yield { ...current };
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const domain = domains[index];
|
|
64
|
+
for (const value of domainValues(domain)) {
|
|
65
|
+
current[domain.key] = value;
|
|
66
|
+
yield* enumerateAssignments(domains, index + 1, current);
|
|
67
|
+
}
|
|
68
|
+
delete current[domain.key];
|
|
69
|
+
}
|
|
70
|
+
function domainValues(domain) {
|
|
71
|
+
if (domain.kind === "enum")
|
|
72
|
+
return [...domain.values];
|
|
73
|
+
return Array.from({ length: domain.maximum - domain.minimum + 1 }, (_, index) => domain.minimum + index);
|
|
74
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DesignResource } from "./design-resource-handoff-file-primitives.js";
|
|
2
|
+
import type { DesignResourceObservableRuleManifestV2, DesignResourceSymbolicNoninterferenceDerivedResultV2, DesignResourceSymbolicNoninterferenceFailureWitnessV1, DesignResourceSymbolicNoninterferenceProofMethodV2 } from "./design-resource-symbolic-fact-types.js";
|
|
3
|
+
import type { CompiledSymbolicDenotationV1, SymbolicDenotationPredicate } from "./symbolic-denotation-types.js";
|
|
4
|
+
export interface DerivedCurrentSourceNoninterferenceEvidenceV2 {
|
|
5
|
+
derived_result: DesignResourceSymbolicNoninterferenceDerivedResultV2;
|
|
6
|
+
failure_witness: DesignResourceSymbolicNoninterferenceFailureWitnessV1 | null;
|
|
7
|
+
}
|
|
8
|
+
export interface DerivedSourceCase {
|
|
9
|
+
index: number;
|
|
10
|
+
region: {
|
|
11
|
+
rule_region_sha256: string;
|
|
12
|
+
predicate: SymbolicDenotationPredicate;
|
|
13
|
+
};
|
|
14
|
+
compiledSource: CompiledSymbolicDenotationV1;
|
|
15
|
+
compiledRule: CompiledSymbolicDenotationV1;
|
|
16
|
+
factRuleRefs: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare function derivedSourceResult(method: DesignResourceSymbolicNoninterferenceProofMethodV2, sourceResourceRef: string, cases: DerivedSourceCase[], manifest: DesignResourceObservableRuleManifestV2): DesignResourceSymbolicNoninterferenceDerivedResultV2;
|
|
19
|
+
export declare function emptyDerivedSourceResult(method: DesignResourceSymbolicNoninterferenceProofMethodV2, sourceResourceRef?: string | null): DesignResourceSymbolicNoninterferenceDerivedResultV2;
|
|
20
|
+
export declare function sourceCaseWitness({ certificateScopeSha256, resource, source, proofCase, kind, axisRef, assignment, detail, }: {
|
|
21
|
+
certificateScopeSha256: string;
|
|
22
|
+
resource: DesignResource;
|
|
23
|
+
source: string;
|
|
24
|
+
proofCase: DerivedSourceCase;
|
|
25
|
+
kind: DesignResourceSymbolicNoninterferenceFailureWitnessV1["kind"];
|
|
26
|
+
axisRef?: string | null;
|
|
27
|
+
assignment?: DesignResourceSymbolicNoninterferenceFailureWitnessV1["assignment"];
|
|
28
|
+
detail: string;
|
|
29
|
+
}): DesignResourceSymbolicNoninterferenceFailureWitnessV1;
|
|
30
|
+
export declare function sourceNoninterferenceWitness({ certificateScopeSha256, kind, axisRef, factRuleRef, resource, locator, nodeRef, byteOffset, assignment, detail, }: {
|
|
31
|
+
certificateScopeSha256: string;
|
|
32
|
+
kind?: DesignResourceSymbolicNoninterferenceFailureWitnessV1["kind"];
|
|
33
|
+
axisRef?: string | null;
|
|
34
|
+
factRuleRef?: string | null;
|
|
35
|
+
resource?: DesignResource;
|
|
36
|
+
locator?: string | null;
|
|
37
|
+
nodeRef?: string | null;
|
|
38
|
+
byteOffset?: number | null;
|
|
39
|
+
assignment?: DesignResourceSymbolicNoninterferenceFailureWitnessV1["assignment"];
|
|
40
|
+
detail: string;
|
|
41
|
+
}): DesignResourceSymbolicNoninterferenceFailureWitnessV1;
|
|
42
|
+
export declare function failedSourceEvidence(derivedResult: DesignResourceSymbolicNoninterferenceDerivedResultV2, failureWitness: DesignResourceSymbolicNoninterferenceFailureWitnessV1): DerivedCurrentSourceNoninterferenceEvidenceV2;
|
|
43
|
+
export declare function sameStringSet(left: string[], right: string[]): boolean;
|
|
44
|
+
export declare function sourceOracleErrorText(error: unknown): string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { compareText, stableJson, } from "./design-resource-symbolic-validation-support.js";
|
|
3
|
+
export function derivedSourceResult(method, sourceResourceRef, cases, manifest) {
|
|
4
|
+
const result = emptyDerivedSourceResult(method, sourceResourceRef);
|
|
5
|
+
if (method === "closed_world_static_dependency_closure") {
|
|
6
|
+
const inputNodeRef = "source.input.complete";
|
|
7
|
+
result.static_dependency_nodes = [
|
|
8
|
+
{
|
|
9
|
+
key: inputNodeRef,
|
|
10
|
+
axis_refs: [],
|
|
11
|
+
dependency_refs: [],
|
|
12
|
+
input_resource_refs: manifest.inspector.input_resources
|
|
13
|
+
.map((input) => input.resource_ref)
|
|
14
|
+
.sort(compareText),
|
|
15
|
+
},
|
|
16
|
+
...cases.map((proofCase) => ({
|
|
17
|
+
key: `source.region.${proofCase.region.rule_region_sha256}`,
|
|
18
|
+
axis_refs: [...proofCase.compiledSource.referenced_axis_refs].sort(compareText),
|
|
19
|
+
dependency_refs: [inputNodeRef],
|
|
20
|
+
input_resource_refs: [],
|
|
21
|
+
})),
|
|
22
|
+
];
|
|
23
|
+
result.static_rule_roots = cases.map((proofCase) => ({
|
|
24
|
+
fact_rule_refs: [...proofCase.factRuleRefs],
|
|
25
|
+
node_ref: `source.region.${proofCase.region.rule_region_sha256}`,
|
|
26
|
+
}));
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
result.equivalence_cases = cases.map((proofCase) => ({
|
|
30
|
+
fact_rule_refs: [...proofCase.factRuleRefs],
|
|
31
|
+
side_predicate: structuredClone(proofCase.region.predicate),
|
|
32
|
+
axis_erased_predicate: structuredClone(proofCase.region.predicate),
|
|
33
|
+
}));
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
export function emptyDerivedSourceResult(method, sourceResourceRef = null) {
|
|
37
|
+
return {
|
|
38
|
+
source_ir_resource_ref: sourceResourceRef,
|
|
39
|
+
static_dependency_nodes: [],
|
|
40
|
+
static_rule_roots: [],
|
|
41
|
+
equivalence_cases: [],
|
|
42
|
+
complete_domain_cardinality: method === "finite_complete_domain_exhaustive_equivalence" ? "0" : null,
|
|
43
|
+
exhaustive_evaluation_sha256: null,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function sourceCaseWitness({ certificateScopeSha256, resource, source, proofCase, kind, axisRef = null, assignment = null, detail, }) {
|
|
47
|
+
const locator = `/certificate_scopes/*/regions/${proofCase.index}/predicate`;
|
|
48
|
+
const needle = axisRef ?? proofCase.region.rule_region_sha256;
|
|
49
|
+
const offset = source.indexOf(needle);
|
|
50
|
+
return sourceNoninterferenceWitness({
|
|
51
|
+
certificateScopeSha256,
|
|
52
|
+
kind,
|
|
53
|
+
axisRef,
|
|
54
|
+
factRuleRef: proofCase.factRuleRefs[0] ?? null,
|
|
55
|
+
resource,
|
|
56
|
+
locator,
|
|
57
|
+
nodeRef: `source.region.${proofCase.region.rule_region_sha256}`,
|
|
58
|
+
byteOffset: offset < 0 ? null : Buffer.byteLength(source.slice(0, offset), "utf8"),
|
|
59
|
+
assignment,
|
|
60
|
+
detail,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export function sourceNoninterferenceWitness({ certificateScopeSha256, kind = "unsupported_dependency", axisRef = null, factRuleRef = null, resource, locator = null, nodeRef = null, byteOffset = null, assignment = null, detail, }) {
|
|
64
|
+
return {
|
|
65
|
+
kind,
|
|
66
|
+
side: "source",
|
|
67
|
+
certificate_scope_sha256: certificateScopeSha256,
|
|
68
|
+
axis_ref: axisRef,
|
|
69
|
+
fact_rule_ref: factRuleRef,
|
|
70
|
+
resource_ref: resource?.key ?? null,
|
|
71
|
+
path: resource?.path ?? null,
|
|
72
|
+
locator,
|
|
73
|
+
node_ref: nodeRef,
|
|
74
|
+
byte_offset: byteOffset,
|
|
75
|
+
assignment,
|
|
76
|
+
detail,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function failedSourceEvidence(derivedResult, failureWitness) {
|
|
80
|
+
return { derived_result: derivedResult, failure_witness: failureWitness };
|
|
81
|
+
}
|
|
82
|
+
export function sameStringSet(left, right) {
|
|
83
|
+
return (stableJson([...new Set(left)].sort(compareText)) ===
|
|
84
|
+
stableJson([...new Set(right)].sort(compareText)));
|
|
85
|
+
}
|
|
86
|
+
export function sourceOracleErrorText(error) {
|
|
87
|
+
return error instanceof Error ? error.message : String(error);
|
|
88
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import type { DesignResource } from "./design-resource-handoff-file-primitives.js";
|
|
3
|
+
import type { DesignResourceObservableRuleManifestV2, DesignResourceSymbolicHandoffTargetV2, DesignResourceSymbolicNoninterferenceCertificateV2, DesignResourceSymbolicNoninterferenceProofMethodV2 } from "./design-resource-symbolic-fact-types.js";
|
|
4
|
+
import { type DerivedCurrentSourceNoninterferenceEvidenceV2 } from "./design-resource-symbolic-source-ir-evidence.js";
|
|
5
|
+
export type { DerivedCurrentSourceNoninterferenceEvidenceV2 } from "./design-resource-symbolic-source-ir-evidence.js";
|
|
6
|
+
export declare function deriveCurrentSourceNoninterferenceEvidence({ manifest, certificate, method, target, resources, contents, }: {
|
|
7
|
+
manifest: DesignResourceObservableRuleManifestV2;
|
|
8
|
+
certificate: DesignResourceSymbolicNoninterferenceCertificateV2;
|
|
9
|
+
method: DesignResourceSymbolicNoninterferenceProofMethodV2;
|
|
10
|
+
target: DesignResourceSymbolicHandoffTargetV2;
|
|
11
|
+
resources: ReadonlyMap<string, DesignResource>;
|
|
12
|
+
contents: ReadonlyMap<string, Buffer>;
|
|
13
|
+
}): DerivedCurrentSourceNoninterferenceEvidenceV2;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { symbolicNoninterferenceCertificateScopeSha256, symbolicNoninterferenceRuleScopeSha256, } from "./design-resource-symbolic-noninterference-scope.js";
|
|
2
|
+
import { productionClosureFailure } from "./design-resource-symbolic-production-closure.js";
|
|
3
|
+
import { emptyDerivedSourceResult, failedSourceEvidence, sourceNoninterferenceWitness, sourceOracleErrorText, } from "./design-resource-symbolic-source-ir-evidence.js";
|
|
4
|
+
import { deriveCurrentSourceScopeEvidence } from "./design-resource-symbolic-source-ir-proof.js";
|
|
5
|
+
import { parseDesignResourceSymbolicSourceIr } from "./design-resource-symbolic-source-ir-shape.js";
|
|
6
|
+
import { DESIGN_RESOURCE_SYMBOLIC_SOURCE_IR_MEDIA_TYPE } from "./design-resource-symbolic-source-ir-types.js";
|
|
7
|
+
import { canonicalJson } from "./strict-codec.js";
|
|
8
|
+
export function deriveCurrentSourceNoninterferenceEvidence({ manifest, certificate, method, target, resources, contents, }) {
|
|
9
|
+
const certificateScopeSha256 = symbolicNoninterferenceCertificateScopeSha256(certificate);
|
|
10
|
+
const ruleScopeSha256 = symbolicNoninterferenceRuleScopeSha256(manifest, certificate);
|
|
11
|
+
const empty = emptyDerivedSourceResult(method);
|
|
12
|
+
const closureFailure = currentSourceClosureFailure(manifest, certificate, target, resources, contents);
|
|
13
|
+
if (closureFailure)
|
|
14
|
+
return { derived_result: empty, failure_witness: closureFailure };
|
|
15
|
+
const sourceResourceRefs = manifest.inspector.input_resources
|
|
16
|
+
.map((input) => input.resource_ref)
|
|
17
|
+
.filter((ref) => resources.get(ref)?.media_type ===
|
|
18
|
+
DESIGN_RESOURCE_SYMBOLIC_SOURCE_IR_MEDIA_TYPE);
|
|
19
|
+
if (sourceResourceRefs.length !== 1)
|
|
20
|
+
return failedSourceEvidence(empty, sourceNoninterferenceWitness({
|
|
21
|
+
certificateScopeSha256,
|
|
22
|
+
detail: `symbolic_source_ir_count:${sourceResourceRefs.length}`,
|
|
23
|
+
}));
|
|
24
|
+
const sourceResourceRef = sourceResourceRefs[0];
|
|
25
|
+
const resource = resources.get(sourceResourceRef);
|
|
26
|
+
const bytes = contents.get(sourceResourceRef);
|
|
27
|
+
const source = bytes.toString("utf8");
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
const raw = JSON.parse(source);
|
|
31
|
+
if (canonicalJson(raw) !== source)
|
|
32
|
+
throw new Error("symbolic Source IR must use canonical JSON bytes");
|
|
33
|
+
parsed = parseDesignResourceSymbolicSourceIr(raw, `symbolic_source_ir:${sourceResourceRef}`);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return failedSourceEvidence({ ...empty, source_ir_resource_ref: sourceResourceRef }, sourceNoninterferenceWitness({
|
|
37
|
+
certificateScopeSha256,
|
|
38
|
+
resource,
|
|
39
|
+
detail: `invalid_symbolic_source_ir:${sourceOracleErrorText(error)}`,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
if (parsed.target_ref !== target.key)
|
|
43
|
+
return failedSourceEvidence({ ...empty, source_ir_resource_ref: sourceResourceRef }, sourceNoninterferenceWitness({
|
|
44
|
+
certificateScopeSha256,
|
|
45
|
+
resource,
|
|
46
|
+
locator: "/target_ref",
|
|
47
|
+
detail: `symbolic_source_ir_target_mismatch:${parsed.target_ref}:${target.key}`,
|
|
48
|
+
}));
|
|
49
|
+
const matches = parsed.certificate_scopes.filter((scope) => scope.certificate_scope_sha256 === certificateScopeSha256 &&
|
|
50
|
+
scope.rule_scope_sha256 === ruleScopeSha256);
|
|
51
|
+
if (matches.length !== 1)
|
|
52
|
+
return failedSourceEvidence({ ...empty, source_ir_resource_ref: sourceResourceRef }, sourceNoninterferenceWitness({
|
|
53
|
+
certificateScopeSha256,
|
|
54
|
+
resource,
|
|
55
|
+
locator: "/certificate_scopes",
|
|
56
|
+
detail: `symbolic_source_ir_scope_match_count:${matches.length}:rule_scope=${ruleScopeSha256}`,
|
|
57
|
+
}));
|
|
58
|
+
try {
|
|
59
|
+
return deriveCurrentSourceScopeEvidence({
|
|
60
|
+
manifest,
|
|
61
|
+
certificate,
|
|
62
|
+
method,
|
|
63
|
+
resource,
|
|
64
|
+
source,
|
|
65
|
+
sourceResourceRef,
|
|
66
|
+
scope: matches[0],
|
|
67
|
+
certificateScopeSha256,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return failedSourceEvidence({ ...empty, source_ir_resource_ref: sourceResourceRef }, sourceNoninterferenceWitness({
|
|
72
|
+
certificateScopeSha256,
|
|
73
|
+
resource,
|
|
74
|
+
locator: "/certificate_scopes",
|
|
75
|
+
detail: `unsupported_symbolic_source_ir:${sourceOracleErrorText(error)}`,
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function currentSourceClosureFailure(manifest, certificate, target, resources, contents) {
|
|
80
|
+
const inputRefs = manifest.inspector.input_resources.map((input) => input.resource_ref);
|
|
81
|
+
const failure = productionClosureFailure({
|
|
82
|
+
...target,
|
|
83
|
+
resource_refs: inputRefs,
|
|
84
|
+
source_profile: {
|
|
85
|
+
...target.source_profile,
|
|
86
|
+
dependency_resource_refs: inputRefs.filter((ref) => ref !== target.source_profile.entry_resource_ref),
|
|
87
|
+
},
|
|
88
|
+
}, certificate, resources, contents);
|
|
89
|
+
return failure
|
|
90
|
+
? {
|
|
91
|
+
...failure,
|
|
92
|
+
side: "source",
|
|
93
|
+
detail: `unsupported_source:${failure.detail}`,
|
|
94
|
+
}
|
|
95
|
+
: null;
|
|
96
|
+
}
|