project-tiny-context-harness 0.8.4 → 0.8.5

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.
Files changed (252) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +393 -371
  3. package/assets/README.md +573 -526
  4. package/assets/README.zh-CN.md +333 -311
  5. package/assets/agents/.gitkeep +1 -1
  6. package/assets/agents/AGENTS_CORE.md +44 -25
  7. package/assets/context_templates/architecture.md +28 -28
  8. package/assets/context_templates/area.md +34 -34
  9. package/assets/context_templates/context.toml +30 -30
  10. package/assets/context_templates/deployment.md +35 -35
  11. package/assets/context_templates/global.md +57 -57
  12. package/assets/context_templates/product-surface-contract.md +70 -70
  13. package/assets/context_templates/screen-contract.md +189 -189
  14. package/assets/context_templates/verification.md +32 -32
  15. package/assets/github/.gitkeep +1 -1
  16. package/assets/github/harness.yml +39 -39
  17. package/assets/make/.gitkeep +1 -1
  18. package/assets/make/ty-context.mk +48 -48
  19. package/assets/skills/context_development_engineer/SKILL.md +148 -125
  20. package/assets/skills/context_full_project_export/SKILL.md +28 -28
  21. package/assets/skills/context_harness_upgrade/SKILL.md +60 -60
  22. package/assets/skills/context_product_plan/SKILL.md +99 -79
  23. package/assets/skills/context_surface_contract/SKILL.md +191 -191
  24. package/assets/skills/context_uiux_design/SKILL.md +171 -171
  25. package/assets/skills/design-resource-authoring/SKILL.md +86 -84
  26. package/assets/skills/design-resource-authoring/references/downstream-handoff.md +138 -123
  27. package/assets/skills/design-resource-authoring/references/open-design-provider.md +132 -127
  28. package/assets/skills/design-resource-authoring/references/resource-selection.md +181 -154
  29. package/assets/skills/design-system-authoring/SKILL.md +57 -57
  30. package/assets/skills/design-system-authoring/agents/openai.yaml +6 -6
  31. package/assets/skills/design-system-authoring/references/authority-adoption.md +48 -48
  32. package/assets/skills/design-system-authoring/references/open-design-design-system-provider.md +110 -110
  33. package/assets/skills/long-task-workflow/SKILL.md +98 -92
  34. package/assets/skills/long-task-workflow/agents/openai.yaml +3 -1
  35. package/assets/skills/long-task-workflow/references/authority-lifecycle.md +72 -72
  36. package/assets/skills/long-task-workflow/references/contract-authoring.md +122 -101
  37. package/assets/skills/long-task-workflow/references/evidence-design.md +82 -61
  38. package/assets/skills/long-task-workflow/references/source-authoring.md +109 -90
  39. package/assets/skills/source-plan-authoring/SKILL.md +14 -14
  40. package/assets/tools/validate_context.py +442 -442
  41. package/dist/commands/long-task-authoring.js +27 -2
  42. package/dist/lib/context-templates.js +1 -1
  43. package/dist/lib/design-resource-fact-enums.d.ts +20 -0
  44. package/dist/lib/design-resource-fact-enums.js +170 -0
  45. package/dist/lib/design-resource-fact-locator-extractors.d.ts +8 -0
  46. package/dist/lib/design-resource-fact-locator-extractors.js +108 -0
  47. package/dist/lib/design-resource-fact-locator-resolver.d.ts +3 -0
  48. package/dist/lib/design-resource-fact-locator-resolver.js +112 -0
  49. package/dist/lib/design-resource-fact-locator-validation.d.ts +5 -0
  50. package/dist/lib/design-resource-fact-locator-validation.js +16 -0
  51. package/dist/lib/design-resource-fact-manifest-catalog.d.ts +4 -0
  52. package/dist/lib/design-resource-fact-manifest-catalog.js +249 -0
  53. package/dist/lib/design-resource-fact-manifest-model.d.ts +91 -0
  54. package/dist/lib/design-resource-fact-manifest-model.js +21 -0
  55. package/dist/lib/design-resource-fact-manifest-shape-axes.d.ts +6 -0
  56. package/dist/lib/design-resource-fact-manifest-shape-axes.js +159 -0
  57. package/dist/lib/design-resource-fact-manifest-shape-evidence.d.ts +4 -0
  58. package/dist/lib/design-resource-fact-manifest-shape-evidence.js +59 -0
  59. package/dist/lib/design-resource-fact-manifest-shape-facts.d.ts +4 -0
  60. package/dist/lib/design-resource-fact-manifest-shape-facts.js +109 -0
  61. package/dist/lib/design-resource-fact-manifest-shape-inspector.d.ts +5 -0
  62. package/dist/lib/design-resource-fact-manifest-shape-inspector.js +144 -0
  63. package/dist/lib/design-resource-fact-manifest-shape.d.ts +7 -0
  64. package/dist/lib/design-resource-fact-manifest-shape.js +75 -0
  65. package/dist/lib/design-resource-fact-manifest-types.d.ts +3 -0
  66. package/dist/lib/design-resource-fact-manifest-types.js +3 -0
  67. package/dist/lib/design-resource-fact-manifest-universe.d.ts +5 -0
  68. package/dist/lib/design-resource-fact-manifest-universe.js +50 -0
  69. package/dist/lib/design-resource-fact-manifest-validation.d.ts +3 -0
  70. package/dist/lib/design-resource-fact-manifest-validation.js +106 -0
  71. package/dist/lib/design-resource-fact-policy.d.ts +18 -0
  72. package/dist/lib/design-resource-fact-policy.js +72 -1
  73. package/dist/lib/design-resource-fact-property-methods.d.ts +3 -0
  74. package/dist/lib/design-resource-fact-property-methods.js +158 -0
  75. package/dist/lib/design-resource-fact-shape-primitives.d.ts +3 -0
  76. package/dist/lib/design-resource-fact-shape-primitives.js +18 -0
  77. package/dist/lib/design-resource-fact-types.d.ts +164 -0
  78. package/dist/lib/design-resource-fact-types.js +1 -0
  79. package/dist/lib/design-resource-fact-universe-assets.d.ts +4 -0
  80. package/dist/lib/design-resource-fact-universe-assets.js +71 -0
  81. package/dist/lib/design-resource-fact-universe-catalog.d.ts +4 -0
  82. package/dist/lib/design-resource-fact-universe-catalog.js +151 -0
  83. package/dist/lib/design-resource-fact-universe-conditions.d.ts +2 -0
  84. package/dist/lib/design-resource-fact-universe-conditions.js +92 -0
  85. package/dist/lib/design-resource-fact-universe-facts.d.ts +4 -0
  86. package/dist/lib/design-resource-fact-universe-facts.js +108 -0
  87. package/dist/lib/design-resource-fact-universe-helpers.d.ts +30 -0
  88. package/dist/lib/design-resource-fact-universe-helpers.js +167 -0
  89. package/dist/lib/design-resource-fact-universe-inspector.d.ts +7 -0
  90. package/dist/lib/design-resource-fact-universe-inspector.js +119 -0
  91. package/dist/lib/design-resource-fact-universe-proof.d.ts +4 -0
  92. package/dist/lib/design-resource-fact-universe-proof.js +113 -0
  93. package/dist/lib/design-resource-fact-universe-subjects.d.ts +5 -0
  94. package/dist/lib/design-resource-fact-universe-subjects.js +97 -0
  95. package/dist/lib/design-resource-fact-universe-variations.d.ts +2 -0
  96. package/dist/lib/design-resource-fact-universe-variations.js +75 -0
  97. package/dist/lib/design-resource-fact-value-validation.d.ts +2 -0
  98. package/dist/lib/design-resource-fact-value-validation.js +80 -0
  99. package/dist/lib/design-resource-handoff-file-primitives.js +2 -0
  100. package/dist/lib/design-resource-handoff-file-validation.js +13 -100
  101. package/dist/lib/design-resource-handoff-policy.d.ts +1 -0
  102. package/dist/lib/design-resource-handoff-policy.js +118 -11
  103. package/dist/lib/design-resource-handoff-shape-evidence.js +46 -3
  104. package/dist/lib/design-resource-handoff-shape-primitives.d.ts +5 -0
  105. package/dist/lib/design-resource-handoff-shape-primitives.js +28 -0
  106. package/dist/lib/design-resource-handoff-shape-structure.js +143 -22
  107. package/dist/lib/design-resource-handoff-shape.js +25 -0
  108. package/dist/lib/design-resource-handoff-types.d.ts +97 -21
  109. package/dist/lib/design-resource-handoff-types.js +22 -0
  110. package/dist/lib/design-resource-handoff-validation-coverage.d.ts +1 -1
  111. package/dist/lib/design-resource-handoff-validation-coverage.js +145 -118
  112. package/dist/lib/design-resource-handoff-validation-fact-cells.d.ts +2 -0
  113. package/dist/lib/design-resource-handoff-validation-fact-cells.js +60 -0
  114. package/dist/lib/design-resource-handoff-validation-fact-records.d.ts +2 -0
  115. package/dist/lib/design-resource-handoff-validation-fact-records.js +90 -0
  116. package/dist/lib/design-resource-handoff-validation-facts.js +10 -94
  117. package/dist/lib/design-resource-handoff-validation-proofs.d.ts +2 -0
  118. package/dist/lib/design-resource-handoff-validation-proofs.js +67 -0
  119. package/dist/lib/design-resource-handoff-validation-resource-closure.d.ts +3 -0
  120. package/dist/lib/design-resource-handoff-validation-resource-closure.js +88 -0
  121. package/dist/lib/design-resource-handoff-validation-structure.js +43 -14
  122. package/dist/lib/design-resource-handoff-validation.js +32 -0
  123. package/dist/lib/design-resource-handoff-web-dependency-validation.d.ts +2 -1
  124. package/dist/lib/design-resource-handoff-web-dependency-validation.js +67 -7
  125. package/dist/lib/execution-target-capabilities.d.ts +1 -1
  126. package/dist/lib/execution-target-capabilities.js +14 -0
  127. package/dist/lib/long-task-activation-validation.js +6 -2
  128. package/dist/lib/long-task-applicability-shape.js +3 -3
  129. package/dist/lib/long-task-authoring-authority-preview.js +1 -0
  130. package/dist/lib/long-task-authority-policy.d.ts +1 -0
  131. package/dist/lib/long-task-authority-policy.js +1 -0
  132. package/dist/lib/long-task-authority.js +13 -0
  133. package/dist/lib/long-task-claim-definitions.js +13 -1
  134. package/dist/lib/long-task-claims.js +23 -1
  135. package/dist/lib/long-task-contract-types.d.ts +3 -0
  136. package/dist/lib/long-task-delivery-compiler.js +1 -0
  137. package/dist/lib/long-task-delivery-parser.js +11 -1
  138. package/dist/lib/long-task-delivery-types.d.ts +1 -0
  139. package/dist/lib/long-task-delivery-types.js +1 -0
  140. package/dist/lib/long-task-delivery-validation.js +17 -0
  141. package/dist/lib/long-task-design-resource-handoff.js +62 -38
  142. package/dist/lib/long-task-design-target-capabilities.d.ts +14 -0
  143. package/dist/lib/long-task-design-target-capabilities.js +126 -0
  144. package/dist/lib/long-task-evidence-capability-codec.d.ts +94 -0
  145. package/dist/lib/long-task-evidence-capability-codec.js +395 -22
  146. package/dist/lib/long-task-evidence-capability-policy.js +18 -0
  147. package/dist/lib/long-task-evidence-capability-runtime.js +78 -0
  148. package/dist/lib/long-task-evidence-capability-types.d.ts +114 -1
  149. package/dist/lib/long-task-outcome-parser.js +4 -0
  150. package/dist/lib/long-task-playwright-capability-records.d.ts +5 -0
  151. package/dist/lib/long-task-playwright-capability-records.js +146 -0
  152. package/dist/lib/long-task-playwright-case-evidence.d.ts +3 -2
  153. package/dist/lib/long-task-playwright-case-evidence.js +10 -79
  154. package/dist/lib/long-task-playwright-case-primitives.d.ts +28 -0
  155. package/dist/lib/long-task-playwright-case-primitives.js +143 -0
  156. package/dist/lib/long-task-playwright-evidence.d.ts +1 -1
  157. package/dist/lib/long-task-playwright-evidence.js +10 -75
  158. package/dist/lib/long-task-runner-freeze.d.ts +2 -2
  159. package/dist/lib/long-task-runner-freeze.js +15 -1
  160. package/dist/lib/long-task-runtime-types.d.ts +4 -1
  161. package/dist/lib/long-task-semantic-contract-types.d.ts +1 -1
  162. package/dist/lib/long-task-semantic-drift-migration.js +2 -2
  163. package/dist/lib/long-task-semantic-fact-binding-types.d.ts +57 -0
  164. package/dist/lib/long-task-semantic-fact-binding-types.js +1 -0
  165. package/dist/lib/long-task-semantic-fact-closure-primitives.d.ts +5 -0
  166. package/dist/lib/long-task-semantic-fact-closure-primitives.js +43 -0
  167. package/dist/lib/long-task-semantic-fact-closure.d.ts +13 -0
  168. package/dist/lib/long-task-semantic-fact-closure.js +48 -0
  169. package/dist/lib/long-task-semantic-fact-contract-closure.d.ts +4 -0
  170. package/dist/lib/long-task-semantic-fact-contract-closure.js +24 -0
  171. package/dist/lib/long-task-semantic-fact-contract-facts.d.ts +4 -0
  172. package/dist/lib/long-task-semantic-fact-contract-facts.js +30 -0
  173. package/dist/lib/long-task-semantic-fact-contract-proofs.d.ts +4 -0
  174. package/dist/lib/long-task-semantic-fact-contract-proofs.js +97 -0
  175. package/dist/lib/long-task-semantic-fact-evidence.d.ts +21 -0
  176. package/dist/lib/long-task-semantic-fact-evidence.js +165 -0
  177. package/dist/lib/long-task-semantic-fact-input-closure.d.ts +4 -0
  178. package/dist/lib/long-task-semantic-fact-input-closure.js +101 -0
  179. package/dist/lib/long-task-semantic-fact-provenance-closure.d.ts +4 -0
  180. package/dist/lib/long-task-semantic-fact-provenance-closure.js +140 -0
  181. package/dist/lib/long-task-semantic-fact-shape.d.ts +3 -0
  182. package/dist/lib/long-task-semantic-fact-shape.js +89 -0
  183. package/dist/lib/long-task-semantic-fact-value-closure.d.ts +3 -0
  184. package/dist/lib/long-task-semantic-fact-value-closure.js +110 -0
  185. package/dist/lib/long-task-shape-primitives.d.ts +2 -1
  186. package/dist/lib/long-task-shape-primitives.js +7 -0
  187. package/dist/lib/long-task-source-item-parser.js +25 -6
  188. package/dist/lib/long-task-source-target-continuity.js +4 -1
  189. package/dist/lib/long-task-source-target-index.d.ts +1 -1
  190. package/dist/lib/long-task-source-target-index.js +5 -1
  191. package/dist/lib/long-task-ui-design-policy.js +8 -4
  192. package/dist/lib/long-task-ui-surface-shape.js +83 -1
  193. package/dist/lib/long-task-ui-surface-types.d.ts +29 -0
  194. package/dist/lib/modularity.js +7 -1
  195. package/dist/lib/semantic-fact-base-types.d.ts +14 -0
  196. package/dist/lib/semantic-fact-base-types.js +1 -0
  197. package/dist/lib/semantic-fact-catalog.d.ts +8 -0
  198. package/dist/lib/semantic-fact-catalog.js +191 -0
  199. package/dist/lib/semantic-fact-condition-shape.d.ts +48 -0
  200. package/dist/lib/semantic-fact-condition-shape.js +111 -0
  201. package/dist/lib/semantic-fact-input-shape.d.ts +34 -0
  202. package/dist/lib/semantic-fact-input-shape.js +111 -0
  203. package/dist/lib/semantic-fact-inventory-types.d.ts +147 -0
  204. package/dist/lib/semantic-fact-inventory-types.js +1 -0
  205. package/dist/lib/semantic-fact-manifest-shape.d.ts +4 -0
  206. package/dist/lib/semantic-fact-manifest-shape.js +135 -0
  207. package/dist/lib/semantic-fact-manifest-types.d.ts +58 -0
  208. package/dist/lib/semantic-fact-manifest-types.js +19 -0
  209. package/dist/lib/semantic-fact-policy-authority.d.ts +8 -0
  210. package/dist/lib/semantic-fact-policy-authority.js +79 -0
  211. package/dist/lib/semantic-fact-policy-census.d.ts +2 -0
  212. package/dist/lib/semantic-fact-policy-census.js +80 -0
  213. package/dist/lib/semantic-fact-policy-condition-references.d.ts +7 -0
  214. package/dist/lib/semantic-fact-policy-condition-references.js +19 -0
  215. package/dist/lib/semantic-fact-policy-conditions.d.ts +2 -0
  216. package/dist/lib/semantic-fact-policy-conditions.js +105 -0
  217. package/dist/lib/semantic-fact-policy-facts.d.ts +3 -0
  218. package/dist/lib/semantic-fact-policy-facts.js +73 -0
  219. package/dist/lib/semantic-fact-policy-primitives.d.ts +26 -0
  220. package/dist/lib/semantic-fact-policy-primitives.js +169 -0
  221. package/dist/lib/semantic-fact-policy-proofs.d.ts +2 -0
  222. package/dist/lib/semantic-fact-policy-proofs.js +75 -0
  223. package/dist/lib/semantic-fact-policy-properties.d.ts +3 -0
  224. package/dist/lib/semantic-fact-policy-properties.js +84 -0
  225. package/dist/lib/semantic-fact-policy-units.d.ts +4 -0
  226. package/dist/lib/semantic-fact-policy-units.js +103 -0
  227. package/dist/lib/semantic-fact-policy.d.ts +17 -0
  228. package/dist/lib/semantic-fact-policy.js +41 -0
  229. package/dist/lib/semantic-fact-proof-shape.d.ts +51 -0
  230. package/dist/lib/semantic-fact-proof-shape.js +121 -0
  231. package/dist/lib/semantic-fact-proof-types.d.ts +74 -0
  232. package/dist/lib/semantic-fact-proof-types.js +1 -0
  233. package/dist/lib/semantic-fact-property-shape.d.ts +29 -0
  234. package/dist/lib/semantic-fact-property-shape.js +77 -0
  235. package/dist/lib/semantic-fact-shape-constants.d.ts +3 -0
  236. package/dist/lib/semantic-fact-shape-constants.js +38 -0
  237. package/dist/lib/semantic-fact-shape-primitives.d.ts +15 -0
  238. package/dist/lib/semantic-fact-shape-primitives.js +68 -0
  239. package/dist/lib/semantic-fact-source-parser.d.ts +9 -0
  240. package/dist/lib/semantic-fact-source-parser.js +46 -0
  241. package/dist/lib/semantic-fact-support-shape.d.ts +21 -0
  242. package/dist/lib/semantic-fact-support-shape.js +59 -0
  243. package/dist/lib/semantic-fact-types.d.ts +5 -0
  244. package/dist/lib/semantic-fact-types.js +5 -0
  245. package/dist/lib/semantic-fact-unit-shape.d.ts +34 -0
  246. package/dist/lib/semantic-fact-unit-shape.js +89 -0
  247. package/dist/lib/semantic-fact-value-shape.d.ts +12 -0
  248. package/dist/lib/semantic-fact-value-shape.js +39 -0
  249. package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +1339 -131
  250. package/migrations/README.md +15 -15
  251. package/package.json +84 -84
  252. package/source-mappings.yaml +25 -25
@@ -0,0 +1,75 @@
1
+ import { isCustomSemanticFactName, SEMANTIC_FACT_COMPARATORS, } from "./semantic-fact-catalog.js";
2
+ import { assertSameSemanticFactSet, semanticFactInvalid, uniqueNonemptySemanticFacts, uniqueSemanticFacts, validateSemanticFactLocatedValue, } from "./semantic-fact-policy-primitives.js";
3
+ export function validateSemanticFactProofClosure(manifest) {
4
+ const propertyByRef = new Map(manifest.property_dispositions.map((item) => [item.key, item]));
5
+ const factByRef = new Map(manifest.facts.map((item) => [item.key, item]));
6
+ const oracleByRef = new Map(manifest.oracles.map((item) => [item.key, item]));
7
+ const environmentByRef = new Map(manifest.environments.map((item) => [item.key, item]));
8
+ for (const fact of manifest.facts) {
9
+ const property = propertyByRef.get(fact.property_ref);
10
+ const proofs = manifest.proof_obligations.filter((item) => item.fact_ref === fact.key);
11
+ assertSameSemanticFactSet(proofs.map((item) => item.method), property.required_methods, `fact_proof_method_universe:${fact.key}`);
12
+ if (fact.quantifier.kind !== "one" &&
13
+ !proofs.some((proof) => proof.method === "population_set_equality"))
14
+ semanticFactInvalid("quantified_fact_population_proof_required", fact.key);
15
+ }
16
+ for (const proof of manifest.proof_obligations)
17
+ validateProof(manifest, proof, propertyByRef, factByRef, oracleByRef, environmentByRef);
18
+ for (const oracle of manifest.oracles) {
19
+ uniqueNonemptySemanticFacts(oracle.capabilities, `oracle_capabilities:${oracle.key}`);
20
+ if (oracle.trust === "frozen_executable" && !oracle.sha256)
21
+ semanticFactInvalid("frozen_oracle_sha256_required", oracle.key);
22
+ if (oracle.trust === "named_external_tcb" && oracle.sha256)
23
+ semanticFactInvalid("external_oracle_sha256_forbidden", oracle.key);
24
+ }
25
+ for (const environment of manifest.environments)
26
+ validateSemanticFactLocatedValue(manifest, environment.definition, `environment:${environment.key}`);
27
+ }
28
+ function validateProof(manifest, proof, propertyByRef, factByRef, oracleByRef, environmentByRef) {
29
+ const fact = factByRef.get(proof.fact_ref);
30
+ if (!fact)
31
+ semanticFactInvalid("proof_fact_unknown", `${proof.key}:${proof.fact_ref}`);
32
+ const property = propertyByRef.get(fact.property_ref);
33
+ assertSameSemanticFactSet(proof.evidence_capabilities, property.required_evidence_capabilities, `proof_capability_mismatch:${proof.key}`);
34
+ if (!proof.evidence_capabilities.includes("semantic_fact"))
35
+ semanticFactInvalid("proof_semantic_fact_capability_required", proof.key);
36
+ if (!SEMANTIC_FACT_COMPARATORS.includes(proof.comparison.comparator) &&
37
+ !isCustomSemanticFactName(proof.comparison.comparator))
38
+ semanticFactInvalid("proof_comparator_unknown", `${proof.key}:${proof.comparison.comparator}`);
39
+ if ((proof.comparison.mode === "exact" &&
40
+ proof.comparison.tolerance !== null) ||
41
+ (proof.comparison.mode === "tolerance" &&
42
+ proof.comparison.tolerance === null))
43
+ semanticFactInvalid("proof_tolerance_mode_mismatch", proof.key);
44
+ validateSemanticFactLocatedValue(manifest, proof.comparison.parameters, `proof:${proof.key}:parameters`);
45
+ if (proof.comparison.tolerance)
46
+ validateSemanticFactLocatedValue(manifest, proof.comparison.tolerance, `proof:${proof.key}:tolerance`);
47
+ if (proof.comparison.mask)
48
+ validateSemanticFactLocatedValue(manifest, proof.comparison.mask, `proof:${proof.key}:mask`);
49
+ const oracle = oracleByRef.get(proof.oracle_ref);
50
+ if (!oracle)
51
+ semanticFactInvalid("proof_oracle_unknown", `${proof.key}:${proof.oracle_ref}`);
52
+ for (const capability of [proof.method, proof.comparison.comparator])
53
+ if (!oracle.capabilities.includes(capability))
54
+ semanticFactInvalid("proof_oracle_capability_missing", `${proof.key}:${proof.oracle_ref}:${capability}`);
55
+ if (!environmentByRef.has(proof.environment_ref))
56
+ semanticFactInvalid("proof_environment_unknown", `${proof.key}:${proof.environment_ref}`);
57
+ uniqueSemanticFacts(proof.observer_refs, `proof_observer_refs:${proof.key}`);
58
+ uniqueSemanticFacts(proof.counterfactual.refs, `proof_counterfactual_refs:${proof.key}`);
59
+ validateProofCounterfactual(proof);
60
+ }
61
+ function validateProofCounterfactual(proof) {
62
+ if (proof.counterfactual.disposition === "required" &&
63
+ !proof.counterfactual.refs.length)
64
+ semanticFactInvalid("proof_counterfactual_required", proof.key);
65
+ if (proof.counterfactual.disposition === "not_applicable" &&
66
+ (!proof.counterfactual.basis_refs.length ||
67
+ proof.counterfactual.refs.length))
68
+ semanticFactInvalid("proof_counterfactual_na_basis_required", proof.key);
69
+ if (proof.counterfactual.disposition === "external" &&
70
+ proof.authority !== "external_confirmation")
71
+ semanticFactInvalid("proof_counterfactual_external_authority_required", proof.key);
72
+ if (proof.authority === "external_confirmation" &&
73
+ proof.counterfactual.disposition !== "external")
74
+ semanticFactInvalid("external_proof_counterfactual_external_required", proof.key);
75
+ }
@@ -0,0 +1,3 @@
1
+ import type { SemanticFactManifestIndexV1 } from "./semantic-fact-policy.js";
2
+ import type { SemanticFactManifestV1 } from "./semantic-fact-types.js";
3
+ export declare function validateSemanticFactPropertyClosure(manifest: SemanticFactManifestV1, units: SemanticFactManifestIndexV1["unit_by_ref"]): void;
@@ -0,0 +1,84 @@
1
+ import { isCustomSemanticFactName, SEMANTIC_FACT_PROOF_METHODS, SEMANTIC_FACT_STANDARD_PROPERTIES, } from "./semantic-fact-catalog.js";
2
+ import { assertSameSemanticFactSet, requireSemanticFactBasis, semanticFactInvalid, uniqueNonemptySemanticFacts, uniqueSemanticFacts, } from "./semantic-fact-policy-primitives.js";
3
+ export function validateSemanticFactPropertyClosure(manifest, units) {
4
+ const conditionByRef = new Map(manifest.conditions.map((item) => [item.key, item]));
5
+ for (const family of manifest.family_dispositions) {
6
+ const properties = manifest.property_dispositions.filter((item) => item.family_ref === family.key);
7
+ uniqueSemanticFacts(properties.map((item) => item.property), `family_property_identity:${family.key}`);
8
+ if (family.disposition !== "applicable") {
9
+ if (properties.length)
10
+ semanticFactInvalid("inapplicable_family_properties_forbidden", `${family.key}:${properties.map((item) => item.key).join(",")}`);
11
+ continue;
12
+ }
13
+ const familyUnits = [...units.values()].filter((item) => item.family_ref === family.key);
14
+ const standardProperties = family.standard
15
+ ? SEMANTIC_FACT_STANDARD_PROPERTIES[family.family]
16
+ : [];
17
+ if (!properties.length)
18
+ semanticFactInvalid("applicable_family_property_required", family.key);
19
+ assertSameSemanticFactSet(properties.filter((item) => item.standard).map((item) => item.property), [...standardProperties], `standard_property_universe:${family.key}`);
20
+ for (const property of properties)
21
+ validateProperty(manifest, property, family, familyUnits, standardProperties, units, conditionByRef);
22
+ for (const unit of familyUnits)
23
+ if (!properties.some((property) => property.applicable_unit_refs.includes(unit.key)))
24
+ semanticFactInvalid("applicable_unit_property_required", `${family.key}:${unit.key}`);
25
+ }
26
+ }
27
+ function validateProperty(manifest, property, family, familyUnits, standardProperties, units, conditionByRef) {
28
+ const knownStandard = standardProperties.includes(property.property);
29
+ if (property.standard !== knownStandard)
30
+ semanticFactInvalid("property_standard_flag_mismatch", `${family.key}:${property.property}`);
31
+ if (!property.standard && !isCustomSemanticFactName(property.property))
32
+ semanticFactInvalid("custom_property_name_required", property.property);
33
+ const partitions = [
34
+ property.applicable_unit_refs,
35
+ property.not_applicable_unit_refs,
36
+ property.decision_required_unit_refs,
37
+ property.unavailable_unit_refs,
38
+ ];
39
+ uniqueSemanticFacts(partitions.flat(), `property_unit_partition:${property.key}`);
40
+ assertSameSemanticFactSet(partitions.flat(), familyUnits.map((item) => item.key), `property_unit_universe:${property.key}`);
41
+ if (property.decision_required_unit_refs.length ||
42
+ property.unavailable_unit_refs.length)
43
+ semanticFactInvalid("property_unresolved", `${property.key}:${[
44
+ ...property.decision_required_unit_refs,
45
+ ...property.unavailable_unit_refs,
46
+ ].join(",")}`);
47
+ uniqueSemanticFacts(property.required_methods, `property_required_methods:${property.key}`);
48
+ uniqueSemanticFacts(property.required_evidence_capabilities, `property_required_capabilities:${property.key}`);
49
+ validatePropertyProof(property);
50
+ validatePropertyConditions(manifest, property, units, conditionByRef);
51
+ requireSemanticFactBasis(property, `property:${property.key}`);
52
+ }
53
+ function validatePropertyProof(property) {
54
+ if (property.applicable_unit_refs.length) {
55
+ uniqueNonemptySemanticFacts(property.required_methods, `property_required_methods:${property.key}`);
56
+ if (!property.required_evidence_capabilities.includes("semantic_fact"))
57
+ semanticFactInvalid("property_semantic_fact_capability_required", property.key);
58
+ for (const method of property.required_methods)
59
+ if (!SEMANTIC_FACT_PROOF_METHODS.includes(method) &&
60
+ !isCustomSemanticFactName(method))
61
+ semanticFactInvalid("property_proof_method_unknown", `${property.key}:${method}`);
62
+ }
63
+ else if (property.required_methods.length ||
64
+ property.required_evidence_capabilities.length ||
65
+ property.condition_refs.length)
66
+ semanticFactInvalid("inapplicable_property_proof_forbidden", property.key);
67
+ }
68
+ function validatePropertyConditions(manifest, property, units, conditionByRef) {
69
+ uniqueSemanticFacts(property.condition_refs, `property_condition_refs:${property.key}`);
70
+ for (const conditionRef of property.condition_refs) {
71
+ const condition = conditionByRef.get(conditionRef);
72
+ if (!condition)
73
+ semanticFactInvalid("property_condition_unknown", `${property.key}:${conditionRef}`);
74
+ if (!property.applicable_unit_refs.some((unitRef) => units.get(unitRef)?.outcome_ref === condition.outcome_ref))
75
+ semanticFactInvalid("property_condition_outcome_unused", `${property.key}:${conditionRef}`);
76
+ }
77
+ for (const unitRef of property.applicable_unit_refs) {
78
+ const unit = units.get(unitRef);
79
+ const expectedConditions = manifest.conditions
80
+ .filter((item) => item.outcome_ref === unit.outcome_ref)
81
+ .map((item) => item.key);
82
+ assertSameSemanticFactSet(property.condition_refs.filter((conditionRef) => conditionByRef.get(conditionRef)?.outcome_ref === unit.outcome_ref), expectedConditions, `property_condition_universe:${property.key}:${unitRef}`);
83
+ }
84
+ }
@@ -0,0 +1,4 @@
1
+ import type { SemanticFactManifestIndexV1 } from "./semantic-fact-policy.js";
2
+ import type { SemanticFactManifestV1 } from "./semantic-fact-types.js";
3
+ export declare function validateSemanticFactFamilyClosure(manifest: SemanticFactManifestV1): void;
4
+ export declare function validateSemanticFactUnits(manifest: SemanticFactManifestV1): SemanticFactManifestIndexV1["unit_by_ref"];
@@ -0,0 +1,103 @@
1
+ import { isCustomSemanticFactName, SEMANTIC_FACT_STANDARD_FAMILIES, } from "./semantic-fact-catalog.js";
2
+ import { assertNoSemanticFactParentCycle, assertSameSemanticFactSet, requireSemanticFactBasis, requireSemanticFactSubset, semanticFactInvalid, uniqueNonemptySemanticFacts, uniqueSemanticFacts, validateSemanticFactLocatedValue, } from "./semantic-fact-policy-primitives.js";
3
+ export function validateSemanticFactFamilyClosure(manifest) {
4
+ const standardRows = manifest.family_dispositions.filter((item) => item.standard);
5
+ uniqueSemanticFacts(manifest.family_dispositions.flatMap((item) => item.outcome_refs.map((outcomeRef) => `${outcomeRef}\0${item.family}`)), "family_outcome_identity");
6
+ assertSameSemanticFactSet(standardRows.map((item) => item.family), [...SEMANTIC_FACT_STANDARD_FAMILIES], "standard_family_universe");
7
+ for (const family of manifest.family_dispositions) {
8
+ if (family.standard !==
9
+ SEMANTIC_FACT_STANDARD_FAMILIES.includes(family.family))
10
+ semanticFactInvalid("family_standard_flag_mismatch", family.family);
11
+ if (!family.standard && !isCustomSemanticFactName(family.family))
12
+ semanticFactInvalid("custom_family_name_required", family.family);
13
+ uniqueNonemptySemanticFacts(family.outcome_refs, `family_outcomes:${family.key}`);
14
+ requireSemanticFactSubset(family.outcome_refs, manifest.scope.outcome_refs, "family_outcome_unknown", family.key);
15
+ requireSemanticFactBasis(family, `family:${family.key}`);
16
+ if (family.disposition === "decision_required" ||
17
+ family.disposition === "unavailable")
18
+ semanticFactInvalid("family_unresolved", `${family.key}:${family.disposition}`);
19
+ }
20
+ for (const outcomeRef of manifest.scope.outcome_refs)
21
+ for (const family of SEMANTIC_FACT_STANDARD_FAMILIES) {
22
+ const rows = standardRows.filter((item) => item.family === family && item.outcome_refs.includes(outcomeRef));
23
+ if (rows.length !== 1)
24
+ semanticFactInvalid("standard_family_outcome_disposition_required", `${outcomeRef}:${family}:${rows.length}`);
25
+ }
26
+ }
27
+ export function validateSemanticFactUnits(manifest) {
28
+ const familyByRef = new Map(manifest.family_dispositions.map((item) => [item.key, item]));
29
+ const unitRows = [
30
+ ...manifest.subjects,
31
+ ...manifest.relations,
32
+ ...manifest.populations,
33
+ ];
34
+ uniqueSemanticFacts(unitRows.map((item) => item.key), "semantic_unit_key");
35
+ const units = new Map(unitRows.map((item) => [item.key, item]));
36
+ validateSemanticFactUnitFamilies(unitRows, familyByRef);
37
+ validateSemanticFactSubjectParents(manifest, units);
38
+ validateSemanticFactRelations(manifest, units);
39
+ validateSemanticFactPopulations(manifest, units);
40
+ validateSemanticFactApplicableFamilyMembers(manifest, unitRows);
41
+ return units;
42
+ }
43
+ function validateSemanticFactUnitFamilies(units, familyByRef) {
44
+ for (const unit of units) {
45
+ const family = familyByRef.get(unit.family_ref);
46
+ if (!family)
47
+ semanticFactInvalid("unit_family_unknown", `${unit.key}:${unit.family_ref}`);
48
+ if (family.disposition !== "applicable")
49
+ semanticFactInvalid("unit_family_not_applicable", `${unit.key}:${unit.family_ref}:${family.disposition}`);
50
+ if (unit.outcome_ref !== undefined &&
51
+ !family.outcome_refs.includes(unit.outcome_ref))
52
+ semanticFactInvalid("unit_outcome_family_mismatch", `${unit.key}:${unit.outcome_ref}:${unit.family_ref}`);
53
+ requireSemanticFactBasis(unit, `unit:${unit.key}`);
54
+ }
55
+ }
56
+ function validateSemanticFactSubjectParents(manifest, units) {
57
+ for (const subject of manifest.subjects) {
58
+ if (subject.parent_ref && !units.has(subject.parent_ref))
59
+ semanticFactInvalid("subject_parent_unknown", `${subject.key}:${subject.parent_ref}`);
60
+ assertNoSemanticFactParentCycle(subject.key, manifest.subjects);
61
+ }
62
+ }
63
+ function validateSemanticFactRelations(manifest, units) {
64
+ for (const relation of manifest.relations) {
65
+ if (relation.endpoints.length < 2)
66
+ semanticFactInvalid("relation_endpoints_required", relation.key);
67
+ uniqueSemanticFacts(relation.endpoints.map((item) => item.role), `relation_endpoint_role:${relation.key}`);
68
+ for (const endpoint of relation.endpoints)
69
+ if (!units.has(endpoint.unit_ref))
70
+ semanticFactInvalid("relation_endpoint_unknown", `${relation.key}:${endpoint.unit_ref}`);
71
+ }
72
+ }
73
+ function validateSemanticFactPopulations(manifest, units) {
74
+ for (const population of manifest.populations) {
75
+ uniqueSemanticFacts(population.member_unit_refs, `population_members:${population.key}`);
76
+ for (const unitRef of population.member_unit_refs)
77
+ if (!units.has(unitRef))
78
+ semanticFactInvalid("population_member_unknown", `${population.key}:${unitRef}`);
79
+ if (population.kind === "static" && !population.member_unit_refs.length)
80
+ semanticFactInvalid("static_population_members_required", population.key);
81
+ uniqueSemanticFacts(population.exclusion_refs, `population_exclusion_refs:${population.key}`);
82
+ if (population.kind === "static") {
83
+ if (population.universe.representation !== "inline" ||
84
+ !Array.isArray(population.universe.value) ||
85
+ population.universe.value.some((item) => typeof item !== "string"))
86
+ semanticFactInvalid("static_population_inline_universe_required", population.key);
87
+ assertSameSemanticFactSet(population.universe.value, population.member_unit_refs, `static_population_universe:${population.key}`);
88
+ }
89
+ validateSemanticFactLocatedValue(manifest, population.universe, `population:${population.key}:universe`);
90
+ }
91
+ }
92
+ function validateSemanticFactApplicableFamilyMembers(manifest, units) {
93
+ for (const family of manifest.family_dispositions) {
94
+ const members = units.filter((item) => item.family_ref === family.key);
95
+ if (family.disposition === "applicable") {
96
+ for (const outcomeRef of family.outcome_refs)
97
+ if (!members.some((item) => item.outcome_ref === outcomeRef))
98
+ semanticFactInvalid("applicable_family_unit_required", `${family.key}:${outcomeRef}`);
99
+ }
100
+ else if (members.length)
101
+ semanticFactInvalid("inapplicable_family_units_forbidden", `${family.key}:${members.map((item) => item.key).join(",")}`);
102
+ }
103
+ }
@@ -0,0 +1,17 @@
1
+ import type { SemanticFactManifestV1 } from "./semantic-fact-types.js";
2
+ export { semanticFactCollectionIdentity } from "./semantic-fact-policy-authority.js";
3
+ export interface SemanticFactManifestIndexV1 {
4
+ family_by_ref: Map<string, SemanticFactManifestV1["family_dispositions"][number]>;
5
+ unit_by_ref: Map<string, SemanticFactManifestV1["subjects"][number] | SemanticFactManifestV1["relations"][number] | SemanticFactManifestV1["populations"][number]>;
6
+ condition_by_ref: Map<string, SemanticFactManifestV1["conditions"][number]>;
7
+ property_by_ref: Map<string, SemanticFactManifestV1["property_dispositions"][number]>;
8
+ fact_by_ref: Map<string, SemanticFactManifestV1["facts"][number]>;
9
+ proof_by_ref: Map<string, SemanticFactManifestV1["proof_obligations"][number]>;
10
+ oracle_by_ref: Map<string, SemanticFactManifestV1["oracles"][number]>;
11
+ environment_by_ref: Map<string, SemanticFactManifestV1["environments"][number]>;
12
+ }
13
+ export declare function validateSemanticFactManifestPolicy(manifest: SemanticFactManifestV1): SemanticFactManifestIndexV1;
14
+ export declare const complete_non_ui_semantic_fact_delivery = "expected=source=contract;proofs=current";
15
+ export declare const NO_UI_CONTROL_RELATIONS = true;
16
+ export declare const NO_SEMANTIC_FACT_SHORTCUTS = true;
17
+ export declare const SEMANTIC_INVENTORY_IS_NOT_COMPLETION = true;
@@ -0,0 +1,41 @@
1
+ import { validateSemanticFactGeneration, validateSemanticFactInspector, validateSemanticFactSourceLineage, validateSemanticFactUniqueIdentities, } from "./semantic-fact-policy-authority.js";
2
+ import { validateSemanticFactInspectorCensus } from "./semantic-fact-policy-census.js";
3
+ import { validateSemanticFactAxisAndConditionClosure } from "./semantic-fact-policy-conditions.js";
4
+ import { validateSemanticFactClosure } from "./semantic-fact-policy-facts.js";
5
+ import { semanticFactInvalid } from "./semantic-fact-policy-primitives.js";
6
+ import { validateSemanticFactProofClosure } from "./semantic-fact-policy-proofs.js";
7
+ import { validateSemanticFactPropertyClosure } from "./semantic-fact-policy-properties.js";
8
+ import { validateSemanticFactFamilyClosure, validateSemanticFactUnits, } from "./semantic-fact-policy-units.js";
9
+ export { semanticFactCollectionIdentity } from "./semantic-fact-policy-authority.js";
10
+ export function validateSemanticFactManifestPolicy(manifest) {
11
+ validateSemanticFactUniqueIdentities(manifest);
12
+ validateSemanticFactGeneration(manifest);
13
+ validateSemanticFactInspector(manifest);
14
+ validateSemanticFactSourceLineage(manifest);
15
+ validateSemanticFactFamilyClosure(manifest);
16
+ const units = validateSemanticFactUnits(manifest);
17
+ validateSemanticFactAxisAndConditionClosure(manifest);
18
+ validateSemanticFactPropertyClosure(manifest, units);
19
+ validateSemanticFactClosure(manifest, units);
20
+ validateSemanticFactProofClosure(manifest);
21
+ validateSemanticFactInspectorCensus(manifest);
22
+ if (manifest.blockers.length)
23
+ semanticFactInvalid("blockers_present", manifest.blockers
24
+ .map((item) => item.key)
25
+ .sort()
26
+ .join(","));
27
+ return {
28
+ family_by_ref: new Map(manifest.family_dispositions.map((item) => [item.key, item])),
29
+ unit_by_ref: units,
30
+ condition_by_ref: new Map(manifest.conditions.map((item) => [item.key, item])),
31
+ property_by_ref: new Map(manifest.property_dispositions.map((item) => [item.key, item])),
32
+ fact_by_ref: new Map(manifest.facts.map((item) => [item.key, item])),
33
+ proof_by_ref: new Map(manifest.proof_obligations.map((item) => [item.key, item])),
34
+ oracle_by_ref: new Map(manifest.oracles.map((item) => [item.key, item])),
35
+ environment_by_ref: new Map(manifest.environments.map((item) => [item.key, item])),
36
+ };
37
+ }
38
+ export const complete_non_ui_semantic_fact_delivery = "expected=source=contract;proofs=current";
39
+ export const NO_UI_CONTROL_RELATIONS = true;
40
+ export const NO_SEMANTIC_FACT_SHORTCUTS = true;
41
+ export const SEMANTIC_INVENTORY_IS_NOT_COMPLETION = true;
@@ -0,0 +1,51 @@
1
+ export declare function parseSemanticFacts(value: unknown, label: string): {
2
+ key: string;
3
+ cell_ref: string;
4
+ outcome_ref: string;
5
+ unit_ref: string;
6
+ family_ref: string;
7
+ condition_ref: string;
8
+ property_ref: string;
9
+ owner_ref: string;
10
+ value_kind: "boolean" | "custom" | "decision_table" | "digest" | "duration" | "enum" | "formula" | "number" | "object" | "ordered_list" | "range" | "rate" | "ratio" | "relation" | "schema" | "set" | "string" | "timestamp" | "trace";
11
+ observation_scope: "data_boundary" | "external_boundary" | "implementation_structure" | "operational_boundary" | "product_boundary" | "security_boundary" | "service_boundary";
12
+ observation_sensitivity: "plain" | "protected";
13
+ quantifier: {
14
+ kind: "all" | "any" | "at_least" | "at_most" | "exactly" | "none" | "one" | "range";
15
+ minimum: number | null;
16
+ maximum: number | null;
17
+ population_ref: string | null;
18
+ };
19
+ expected: import("./semantic-fact-base-types.js").SemanticFactLocatedValueV1;
20
+ provenance: {
21
+ kind: "direct" | "evidence_backed_preservation" | "explicitly_delegated" | "logically_derived";
22
+ authority_ref: string;
23
+ basis_refs: string[];
24
+ derivation: string | null;
25
+ };
26
+ source_item_refs: string[];
27
+ }[];
28
+ export declare function parseSemanticFactProofObligations(value: unknown, label: string): {
29
+ key: string;
30
+ fact_ref: string;
31
+ method: string;
32
+ authority: "external_confirmation" | "machine";
33
+ proof_surface: "api_contract" | "data_state" | "implementation_structure" | "population_coverage" | "runtime_behavior" | "security_boundary" | "ui_browser";
34
+ evidence_capabilities: ("boundary_invocation" | "cross_surface_consistency" | "design_conformance" | "design_method" | "durable_readback" | "external_side_effect" | "failure_injection" | "input_variation" | "interaction_trace" | "presence" | "semantic_fact" | "state_delta" | "target_runtime" | "visual_render")[];
35
+ comparison: {
36
+ comparator: string;
37
+ mode: "exact" | "tolerance";
38
+ parameters: import("./semantic-fact-base-types.js").SemanticFactLocatedValueV1;
39
+ tolerance: import("./semantic-fact-base-types.js").SemanticFactLocatedValueV1 | null;
40
+ mask: import("./semantic-fact-base-types.js").SemanticFactLocatedValueV1 | null;
41
+ };
42
+ oracle_ref: string;
43
+ environment_ref: string;
44
+ observer_refs: string[];
45
+ counterfactual: {
46
+ disposition: "external" | "not_applicable" | "required";
47
+ refs: string[];
48
+ basis_refs: string[];
49
+ rationale: string;
50
+ };
51
+ }[];
@@ -0,0 +1,121 @@
1
+ import { EVIDENCE_CAPABILITIES, PROOF_SURFACES, } from "./long-task-shape-primitives.js";
2
+ import { SEMANTIC_FACT_VALUE_KINDS } from "./semantic-fact-shape-constants.js";
3
+ import { semanticArray, semanticLiteral, semanticNullable, semanticNullableNumber, semanticObject, semanticStableRef, semanticStableRefs, semanticString, } from "./semantic-fact-shape-primitives.js";
4
+ import { parseSemanticFactLocatedValue } from "./semantic-fact-value-shape.js";
5
+ export function parseSemanticFacts(value, label) {
6
+ return semanticArray(value, label).map((item, index) => {
7
+ const itemLabel = `${label}[${index}]`;
8
+ const row = semanticObject(item, itemLabel, [
9
+ "key",
10
+ "cell_ref",
11
+ "outcome_ref",
12
+ "unit_ref",
13
+ "family_ref",
14
+ "condition_ref",
15
+ "property_ref",
16
+ "owner_ref",
17
+ "value_kind",
18
+ "observation_scope",
19
+ "observation_sensitivity",
20
+ "quantifier",
21
+ "expected",
22
+ "provenance",
23
+ "source_item_refs",
24
+ ]);
25
+ const quantifier = semanticObject(row.quantifier, `${itemLabel}.quantifier`, ["kind", "minimum", "maximum", "population_ref"]);
26
+ const provenance = semanticObject(row.provenance, `${itemLabel}.provenance`, ["kind", "authority_ref", "basis_refs", "derivation"]);
27
+ return {
28
+ key: semanticStableRef(row.key, `${itemLabel}.key`),
29
+ cell_ref: semanticStableRef(row.cell_ref, `${itemLabel}.cell_ref`),
30
+ outcome_ref: semanticStableRef(row.outcome_ref, `${itemLabel}.outcome_ref`),
31
+ unit_ref: semanticStableRef(row.unit_ref, `${itemLabel}.unit_ref`),
32
+ family_ref: semanticStableRef(row.family_ref, `${itemLabel}.family_ref`),
33
+ condition_ref: semanticStableRef(row.condition_ref, `${itemLabel}.condition_ref`),
34
+ property_ref: semanticStableRef(row.property_ref, `${itemLabel}.property_ref`),
35
+ owner_ref: semanticStableRef(row.owner_ref, `${itemLabel}.owner_ref`),
36
+ value_kind: semanticLiteral(row.value_kind, SEMANTIC_FACT_VALUE_KINDS, `${itemLabel}.value_kind`),
37
+ observation_scope: semanticLiteral(row.observation_scope, [
38
+ "product_boundary",
39
+ "service_boundary",
40
+ "data_boundary",
41
+ "security_boundary",
42
+ "operational_boundary",
43
+ "implementation_structure",
44
+ "external_boundary",
45
+ ], `${itemLabel}.observation_scope`),
46
+ observation_sensitivity: semanticLiteral(row.observation_sensitivity, ["plain", "protected"], `${itemLabel}.observation_sensitivity`),
47
+ quantifier: {
48
+ kind: semanticLiteral(quantifier.kind, [
49
+ "one",
50
+ "all",
51
+ "any",
52
+ "none",
53
+ "exactly",
54
+ "at_least",
55
+ "at_most",
56
+ "range",
57
+ ], `${itemLabel}.quantifier.kind`),
58
+ minimum: semanticNullableNumber(quantifier.minimum, `${itemLabel}.quantifier.minimum`),
59
+ maximum: semanticNullableNumber(quantifier.maximum, `${itemLabel}.quantifier.maximum`),
60
+ population_ref: semanticNullable(quantifier.population_ref, (entry) => semanticStableRef(entry, `${itemLabel}.quantifier.population_ref`)),
61
+ },
62
+ expected: parseSemanticFactLocatedValue(row.expected, `${itemLabel}.expected`),
63
+ provenance: {
64
+ kind: semanticLiteral(provenance.kind, [
65
+ "direct",
66
+ "logically_derived",
67
+ "explicitly_delegated",
68
+ "evidence_backed_preservation",
69
+ ], `${itemLabel}.provenance.kind`),
70
+ authority_ref: semanticStableRef(provenance.authority_ref, `${itemLabel}.provenance.authority_ref`),
71
+ basis_refs: semanticStableRefs(provenance.basis_refs, `${itemLabel}.provenance.basis_refs`),
72
+ derivation: semanticNullable(provenance.derivation, (entry) => semanticString(entry, `${itemLabel}.provenance.derivation`)),
73
+ },
74
+ source_item_refs: semanticStableRefs(row.source_item_refs, `${itemLabel}.source_item_refs`),
75
+ };
76
+ });
77
+ }
78
+ export function parseSemanticFactProofObligations(value, label) {
79
+ return semanticArray(value, label).map((item, index) => {
80
+ const itemLabel = `${label}[${index}]`;
81
+ const row = semanticObject(item, itemLabel, [
82
+ "key",
83
+ "fact_ref",
84
+ "method",
85
+ "authority",
86
+ "proof_surface",
87
+ "evidence_capabilities",
88
+ "comparison",
89
+ "oracle_ref",
90
+ "environment_ref",
91
+ "observer_refs",
92
+ "counterfactual",
93
+ ]);
94
+ const comparison = semanticObject(row.comparison, `${itemLabel}.comparison`, ["comparator", "mode", "parameters", "tolerance", "mask"]);
95
+ const counterfactual = semanticObject(row.counterfactual, `${itemLabel}.counterfactual`, ["disposition", "refs", "basis_refs", "rationale"]);
96
+ return {
97
+ key: semanticStableRef(row.key, `${itemLabel}.key`),
98
+ fact_ref: semanticStableRef(row.fact_ref, `${itemLabel}.fact_ref`),
99
+ method: semanticStableRef(row.method, `${itemLabel}.method`),
100
+ authority: semanticLiteral(row.authority, ["machine", "external_confirmation"], `${itemLabel}.authority`),
101
+ proof_surface: semanticLiteral(row.proof_surface, PROOF_SURFACES, `${itemLabel}.proof_surface`),
102
+ evidence_capabilities: semanticArray(row.evidence_capabilities, `${itemLabel}.evidence_capabilities`).map((entry, capabilityIndex) => semanticLiteral(entry, EVIDENCE_CAPABILITIES, `${itemLabel}.evidence_capabilities[${capabilityIndex}]`)),
103
+ comparison: {
104
+ comparator: semanticStableRef(comparison.comparator, `${itemLabel}.comparison.comparator`),
105
+ mode: semanticLiteral(comparison.mode, ["exact", "tolerance"], `${itemLabel}.comparison.mode`),
106
+ parameters: parseSemanticFactLocatedValue(comparison.parameters, `${itemLabel}.comparison.parameters`),
107
+ tolerance: semanticNullable(comparison.tolerance, (entry) => parseSemanticFactLocatedValue(entry, `${itemLabel}.comparison.tolerance`)),
108
+ mask: semanticNullable(comparison.mask, (entry) => parseSemanticFactLocatedValue(entry, `${itemLabel}.comparison.mask`)),
109
+ },
110
+ oracle_ref: semanticStableRef(row.oracle_ref, `${itemLabel}.oracle_ref`),
111
+ environment_ref: semanticStableRef(row.environment_ref, `${itemLabel}.environment_ref`),
112
+ observer_refs: semanticStableRefs(row.observer_refs, `${itemLabel}.observer_refs`),
113
+ counterfactual: {
114
+ disposition: semanticLiteral(counterfactual.disposition, ["required", "not_applicable", "external"], `${itemLabel}.counterfactual.disposition`),
115
+ refs: semanticStableRefs(counterfactual.refs, `${itemLabel}.counterfactual.refs`),
116
+ basis_refs: semanticStableRefs(counterfactual.basis_refs, `${itemLabel}.counterfactual.basis_refs`),
117
+ rationale: semanticString(counterfactual.rationale, `${itemLabel}.counterfactual.rationale`),
118
+ },
119
+ };
120
+ });
121
+ }
@@ -0,0 +1,74 @@
1
+ import type { EvidenceCapabilityV2, ProofSurface } from "./long-task-delivery-types.js";
2
+ import type { SemanticFactAuthorityKind, SemanticFactLocatedValueV1, SemanticFactValueKind } from "./semantic-fact-base-types.js";
3
+ export interface SemanticFactV1 {
4
+ key: string;
5
+ cell_ref: string;
6
+ outcome_ref: string;
7
+ unit_ref: string;
8
+ family_ref: string;
9
+ condition_ref: string;
10
+ property_ref: string;
11
+ owner_ref: string;
12
+ value_kind: SemanticFactValueKind;
13
+ observation_scope: "product_boundary" | "service_boundary" | "data_boundary" | "security_boundary" | "operational_boundary" | "implementation_structure" | "external_boundary";
14
+ observation_sensitivity: "plain" | "protected";
15
+ quantifier: {
16
+ kind: "one" | "all" | "any" | "none" | "exactly" | "at_least" | "at_most" | "range";
17
+ minimum: number | null;
18
+ maximum: number | null;
19
+ population_ref: string | null;
20
+ };
21
+ expected: SemanticFactLocatedValueV1;
22
+ provenance: {
23
+ kind: SemanticFactAuthorityKind;
24
+ authority_ref: string;
25
+ basis_refs: string[];
26
+ derivation: string | null;
27
+ };
28
+ source_item_refs: string[];
29
+ }
30
+ export interface SemanticFactOracleV1 {
31
+ key: string;
32
+ trust: "frozen_executable" | "named_external_tcb";
33
+ identity: string;
34
+ version: string;
35
+ sha256: string | null;
36
+ capabilities: string[];
37
+ }
38
+ export interface SemanticFactEnvironmentV1 {
39
+ key: string;
40
+ identity: string;
41
+ definition: SemanticFactLocatedValueV1;
42
+ }
43
+ export interface SemanticFactProofObligationV1 {
44
+ key: string;
45
+ fact_ref: string;
46
+ method: string;
47
+ authority: "machine" | "external_confirmation";
48
+ proof_surface: ProofSurface;
49
+ evidence_capabilities: EvidenceCapabilityV2[];
50
+ comparison: {
51
+ comparator: string;
52
+ mode: "exact" | "tolerance";
53
+ parameters: SemanticFactLocatedValueV1;
54
+ tolerance: SemanticFactLocatedValueV1 | null;
55
+ mask: SemanticFactLocatedValueV1 | null;
56
+ };
57
+ oracle_ref: string;
58
+ environment_ref: string;
59
+ observer_refs: string[];
60
+ counterfactual: {
61
+ disposition: "required" | "not_applicable" | "external";
62
+ refs: string[];
63
+ basis_refs: string[];
64
+ rationale: string;
65
+ };
66
+ }
67
+ export interface SemanticFactBlockerV1 {
68
+ key: string;
69
+ kind: "decision_required" | "unavailable" | "conflict" | "unreadable";
70
+ affected_refs: string[];
71
+ source_item_refs: string[];
72
+ owner: string;
73
+ resolution: string;
74
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ export declare function parseSemanticFactPropertyDispositions(value: unknown, label: string): {
2
+ key: string;
3
+ family_ref: string;
4
+ property: string;
5
+ standard: boolean;
6
+ value_kind: "boolean" | "custom" | "decision_table" | "digest" | "duration" | "enum" | "formula" | "number" | "object" | "ordered_list" | "range" | "rate" | "ratio" | "relation" | "schema" | "set" | "string" | "timestamp" | "trace";
7
+ required_methods: string[];
8
+ required_evidence_capabilities: ("boundary_invocation" | "cross_surface_consistency" | "design_conformance" | "design_method" | "durable_readback" | "external_side_effect" | "failure_injection" | "input_variation" | "interaction_trace" | "presence" | "semantic_fact" | "state_delta" | "target_runtime" | "visual_render")[];
9
+ applicable_unit_refs: string[];
10
+ not_applicable_unit_refs: string[];
11
+ decision_required_unit_refs: string[];
12
+ unavailable_unit_refs: string[];
13
+ condition_refs: string[];
14
+ source_item_refs: string[];
15
+ basis_refs: string[];
16
+ rationale: string;
17
+ }[];
18
+ export declare function parseSemanticFactCells(value: unknown, label: string): {
19
+ key: string;
20
+ outcome_ref: string;
21
+ unit_ref: string;
22
+ condition_ref: string;
23
+ property_ref: string;
24
+ disposition: "decision_required" | "not_applicable" | "specified" | "unavailable";
25
+ fact_ref: string | null;
26
+ source_item_refs: string[];
27
+ basis_refs: string[];
28
+ rationale: string;
29
+ }[];