project-tiny-context-harness 0.8.3 → 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.
- package/LICENSE +21 -21
- package/README.md +400 -366
- package/assets/README.md +579 -528
- package/assets/README.zh-CN.md +341 -309
- package/assets/agents/.gitkeep +1 -1
- package/assets/agents/AGENTS_CORE.md +44 -25
- package/assets/context_templates/architecture.md +28 -28
- package/assets/context_templates/area.md +34 -34
- package/assets/context_templates/context.toml +30 -30
- package/assets/context_templates/deployment.md +35 -35
- package/assets/context_templates/global.md +57 -57
- package/assets/context_templates/product-surface-contract.md +70 -70
- package/assets/context_templates/screen-contract.md +189 -189
- package/assets/context_templates/verification.md +32 -32
- 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 +148 -125
- package/assets/skills/context_full_project_export/SKILL.md +28 -28
- package/assets/skills/context_harness_upgrade/SKILL.md +60 -60
- package/assets/skills/context_product_plan/SKILL.md +99 -79
- package/assets/skills/context_surface_contract/SKILL.md +191 -191
- package/assets/skills/context_uiux_design/SKILL.md +171 -171
- package/assets/skills/design-resource-authoring/SKILL.md +86 -84
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +138 -123
- package/assets/skills/design-resource-authoring/references/open-design-provider.md +132 -127
- package/assets/skills/design-resource-authoring/references/resource-selection.md +181 -154
- package/assets/skills/design-system-authoring/SKILL.md +57 -57
- package/assets/skills/design-system-authoring/agents/openai.yaml +6 -6
- package/assets/skills/design-system-authoring/references/authority-adoption.md +48 -48
- package/assets/skills/design-system-authoring/references/open-design-design-system-provider.md +110 -110
- package/assets/skills/long-task-workflow/SKILL.md +98 -92
- package/assets/skills/long-task-workflow/agents/openai.yaml +3 -1
- package/assets/skills/long-task-workflow/references/authority-lifecycle.md +72 -72
- package/assets/skills/long-task-workflow/references/contract-authoring.md +122 -101
- package/assets/skills/long-task-workflow/references/evidence-design.md +82 -61
- package/assets/skills/long-task-workflow/references/source-authoring.md +109 -90
- package/assets/skills/source-plan-authoring/SKILL.md +14 -14
- package/assets/tools/validate_context.py +442 -442
- package/dist/commands/long-task-authoring.js +27 -2
- package/dist/lib/context-templates.js +1 -1
- package/dist/lib/design-resource-fact-enums.d.ts +20 -0
- package/dist/lib/design-resource-fact-enums.js +170 -0
- package/dist/lib/design-resource-fact-locator-extractors.d.ts +8 -0
- package/dist/lib/design-resource-fact-locator-extractors.js +108 -0
- package/dist/lib/design-resource-fact-locator-resolver.d.ts +3 -0
- package/dist/lib/design-resource-fact-locator-resolver.js +112 -0
- package/dist/lib/design-resource-fact-locator-validation.d.ts +5 -0
- package/dist/lib/design-resource-fact-locator-validation.js +16 -0
- package/dist/lib/design-resource-fact-manifest-catalog.d.ts +4 -0
- package/dist/lib/design-resource-fact-manifest-catalog.js +249 -0
- package/dist/lib/design-resource-fact-manifest-model.d.ts +91 -0
- package/dist/lib/design-resource-fact-manifest-model.js +21 -0
- package/dist/lib/design-resource-fact-manifest-shape-axes.d.ts +6 -0
- package/dist/lib/design-resource-fact-manifest-shape-axes.js +159 -0
- package/dist/lib/design-resource-fact-manifest-shape-evidence.d.ts +4 -0
- package/dist/lib/design-resource-fact-manifest-shape-evidence.js +59 -0
- package/dist/lib/design-resource-fact-manifest-shape-facts.d.ts +4 -0
- package/dist/lib/design-resource-fact-manifest-shape-facts.js +109 -0
- package/dist/lib/design-resource-fact-manifest-shape-inspector.d.ts +5 -0
- package/dist/lib/design-resource-fact-manifest-shape-inspector.js +144 -0
- package/dist/lib/design-resource-fact-manifest-shape.d.ts +7 -0
- package/dist/lib/design-resource-fact-manifest-shape.js +75 -0
- package/dist/lib/design-resource-fact-manifest-types.d.ts +3 -0
- package/dist/lib/design-resource-fact-manifest-types.js +3 -0
- package/dist/lib/design-resource-fact-manifest-universe.d.ts +5 -0
- package/dist/lib/design-resource-fact-manifest-universe.js +50 -0
- package/dist/lib/design-resource-fact-manifest-validation.d.ts +3 -0
- package/dist/lib/design-resource-fact-manifest-validation.js +106 -0
- package/dist/lib/design-resource-fact-policy.d.ts +18 -0
- package/dist/lib/design-resource-fact-policy.js +72 -1
- package/dist/lib/design-resource-fact-property-methods.d.ts +3 -0
- package/dist/lib/design-resource-fact-property-methods.js +158 -0
- package/dist/lib/design-resource-fact-shape-primitives.d.ts +3 -0
- package/dist/lib/design-resource-fact-shape-primitives.js +18 -0
- package/dist/lib/design-resource-fact-types.d.ts +164 -0
- package/dist/lib/design-resource-fact-types.js +1 -0
- package/dist/lib/design-resource-fact-universe-assets.d.ts +4 -0
- package/dist/lib/design-resource-fact-universe-assets.js +71 -0
- package/dist/lib/design-resource-fact-universe-catalog.d.ts +4 -0
- package/dist/lib/design-resource-fact-universe-catalog.js +151 -0
- package/dist/lib/design-resource-fact-universe-conditions.d.ts +2 -0
- package/dist/lib/design-resource-fact-universe-conditions.js +92 -0
- package/dist/lib/design-resource-fact-universe-facts.d.ts +4 -0
- package/dist/lib/design-resource-fact-universe-facts.js +108 -0
- package/dist/lib/design-resource-fact-universe-helpers.d.ts +30 -0
- package/dist/lib/design-resource-fact-universe-helpers.js +167 -0
- package/dist/lib/design-resource-fact-universe-inspector.d.ts +7 -0
- package/dist/lib/design-resource-fact-universe-inspector.js +119 -0
- package/dist/lib/design-resource-fact-universe-proof.d.ts +4 -0
- package/dist/lib/design-resource-fact-universe-proof.js +113 -0
- package/dist/lib/design-resource-fact-universe-subjects.d.ts +5 -0
- package/dist/lib/design-resource-fact-universe-subjects.js +97 -0
- package/dist/lib/design-resource-fact-universe-variations.d.ts +2 -0
- package/dist/lib/design-resource-fact-universe-variations.js +75 -0
- package/dist/lib/design-resource-fact-value-validation.d.ts +2 -0
- package/dist/lib/design-resource-fact-value-validation.js +80 -0
- package/dist/lib/design-resource-handoff-file-primitives.js +2 -0
- package/dist/lib/design-resource-handoff-file-validation.js +13 -100
- package/dist/lib/design-resource-handoff-policy.d.ts +1 -0
- package/dist/lib/design-resource-handoff-policy.js +118 -11
- package/dist/lib/design-resource-handoff-shape-evidence.js +46 -3
- package/dist/lib/design-resource-handoff-shape-primitives.d.ts +5 -0
- package/dist/lib/design-resource-handoff-shape-primitives.js +28 -0
- package/dist/lib/design-resource-handoff-shape-structure.js +143 -22
- package/dist/lib/design-resource-handoff-shape.js +25 -0
- package/dist/lib/design-resource-handoff-types.d.ts +97 -21
- package/dist/lib/design-resource-handoff-types.js +22 -0
- package/dist/lib/design-resource-handoff-validation-coverage.d.ts +1 -1
- package/dist/lib/design-resource-handoff-validation-coverage.js +145 -118
- package/dist/lib/design-resource-handoff-validation-fact-cells.d.ts +2 -0
- package/dist/lib/design-resource-handoff-validation-fact-cells.js +60 -0
- package/dist/lib/design-resource-handoff-validation-fact-records.d.ts +2 -0
- package/dist/lib/design-resource-handoff-validation-fact-records.js +90 -0
- package/dist/lib/design-resource-handoff-validation-facts.js +10 -94
- package/dist/lib/design-resource-handoff-validation-proofs.d.ts +2 -0
- package/dist/lib/design-resource-handoff-validation-proofs.js +67 -0
- package/dist/lib/design-resource-handoff-validation-resource-closure.d.ts +3 -0
- package/dist/lib/design-resource-handoff-validation-resource-closure.js +88 -0
- package/dist/lib/design-resource-handoff-validation-structure.js +43 -14
- package/dist/lib/design-resource-handoff-validation.js +32 -0
- package/dist/lib/design-resource-handoff-web-dependency-validation.d.ts +2 -1
- package/dist/lib/design-resource-handoff-web-dependency-validation.js +67 -7
- package/dist/lib/execution-target-capabilities.d.ts +1 -1
- package/dist/lib/execution-target-capabilities.js +14 -0
- package/dist/lib/long-task-activation-validation.js +6 -2
- package/dist/lib/long-task-applicability-shape.js +3 -3
- package/dist/lib/long-task-authoring-authority-preview.js +1 -0
- package/dist/lib/long-task-authority-policy.d.ts +1 -0
- package/dist/lib/long-task-authority-policy.js +1 -0
- package/dist/lib/long-task-authority.js +13 -0
- package/dist/lib/long-task-claim-definitions.js +13 -1
- package/dist/lib/long-task-claims.js +23 -1
- package/dist/lib/long-task-contract-types.d.ts +3 -0
- package/dist/lib/long-task-delivery-compiler.js +1 -0
- package/dist/lib/long-task-delivery-parser.js +11 -1
- package/dist/lib/long-task-delivery-types.d.ts +1 -0
- package/dist/lib/long-task-delivery-types.js +1 -0
- package/dist/lib/long-task-delivery-validation.js +17 -0
- package/dist/lib/long-task-design-resource-handoff.js +62 -38
- package/dist/lib/long-task-design-target-capabilities.d.ts +14 -0
- package/dist/lib/long-task-design-target-capabilities.js +126 -0
- package/dist/lib/long-task-evidence-capability-codec.d.ts +94 -0
- package/dist/lib/long-task-evidence-capability-codec.js +395 -22
- package/dist/lib/long-task-evidence-capability-policy.js +18 -0
- package/dist/lib/long-task-evidence-capability-runtime.js +78 -0
- package/dist/lib/long-task-evidence-capability-types.d.ts +114 -1
- package/dist/lib/long-task-outcome-parser.js +4 -0
- package/dist/lib/long-task-playwright-capability-records.d.ts +5 -0
- package/dist/lib/long-task-playwright-capability-records.js +146 -0
- package/dist/lib/long-task-playwright-case-evidence.d.ts +3 -2
- package/dist/lib/long-task-playwright-case-evidence.js +10 -79
- package/dist/lib/long-task-playwright-case-primitives.d.ts +28 -0
- package/dist/lib/long-task-playwright-case-primitives.js +143 -0
- package/dist/lib/long-task-playwright-evidence.d.ts +1 -1
- package/dist/lib/long-task-playwright-evidence.js +10 -75
- package/dist/lib/long-task-runner-freeze.d.ts +2 -2
- package/dist/lib/long-task-runner-freeze.js +15 -1
- package/dist/lib/long-task-runtime-types.d.ts +4 -1
- package/dist/lib/long-task-semantic-contract-types.d.ts +1 -1
- package/dist/lib/long-task-semantic-drift-migration.js +2 -2
- package/dist/lib/long-task-semantic-fact-binding-types.d.ts +57 -0
- package/dist/lib/long-task-semantic-fact-binding-types.js +1 -0
- package/dist/lib/long-task-semantic-fact-closure-primitives.d.ts +5 -0
- package/dist/lib/long-task-semantic-fact-closure-primitives.js +43 -0
- package/dist/lib/long-task-semantic-fact-closure.d.ts +13 -0
- package/dist/lib/long-task-semantic-fact-closure.js +48 -0
- package/dist/lib/long-task-semantic-fact-contract-closure.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-contract-closure.js +24 -0
- package/dist/lib/long-task-semantic-fact-contract-facts.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-contract-facts.js +30 -0
- package/dist/lib/long-task-semantic-fact-contract-proofs.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-contract-proofs.js +97 -0
- package/dist/lib/long-task-semantic-fact-evidence.d.ts +21 -0
- package/dist/lib/long-task-semantic-fact-evidence.js +165 -0
- package/dist/lib/long-task-semantic-fact-input-closure.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-input-closure.js +101 -0
- package/dist/lib/long-task-semantic-fact-provenance-closure.d.ts +4 -0
- package/dist/lib/long-task-semantic-fact-provenance-closure.js +140 -0
- package/dist/lib/long-task-semantic-fact-shape.d.ts +3 -0
- package/dist/lib/long-task-semantic-fact-shape.js +89 -0
- package/dist/lib/long-task-semantic-fact-value-closure.d.ts +3 -0
- package/dist/lib/long-task-semantic-fact-value-closure.js +110 -0
- package/dist/lib/long-task-shape-primitives.d.ts +2 -1
- package/dist/lib/long-task-shape-primitives.js +7 -0
- package/dist/lib/long-task-source-item-parser.js +25 -6
- package/dist/lib/long-task-source-target-continuity.js +4 -1
- package/dist/lib/long-task-source-target-index.d.ts +1 -1
- package/dist/lib/long-task-source-target-index.js +5 -1
- package/dist/lib/long-task-ui-design-policy.js +8 -4
- package/dist/lib/long-task-ui-surface-shape.js +83 -1
- package/dist/lib/long-task-ui-surface-types.d.ts +29 -0
- package/dist/lib/migrations.js +64 -0
- package/dist/lib/modularity.js +7 -1
- package/dist/lib/profiles.js +0 -2
- package/dist/lib/semantic-fact-base-types.d.ts +14 -0
- package/dist/lib/semantic-fact-base-types.js +1 -0
- package/dist/lib/semantic-fact-catalog.d.ts +8 -0
- package/dist/lib/semantic-fact-catalog.js +191 -0
- package/dist/lib/semantic-fact-condition-shape.d.ts +48 -0
- package/dist/lib/semantic-fact-condition-shape.js +111 -0
- package/dist/lib/semantic-fact-input-shape.d.ts +34 -0
- package/dist/lib/semantic-fact-input-shape.js +111 -0
- package/dist/lib/semantic-fact-inventory-types.d.ts +147 -0
- package/dist/lib/semantic-fact-inventory-types.js +1 -0
- package/dist/lib/semantic-fact-manifest-shape.d.ts +4 -0
- package/dist/lib/semantic-fact-manifest-shape.js +135 -0
- package/dist/lib/semantic-fact-manifest-types.d.ts +58 -0
- package/dist/lib/semantic-fact-manifest-types.js +19 -0
- package/dist/lib/semantic-fact-policy-authority.d.ts +8 -0
- package/dist/lib/semantic-fact-policy-authority.js +79 -0
- package/dist/lib/semantic-fact-policy-census.d.ts +2 -0
- package/dist/lib/semantic-fact-policy-census.js +80 -0
- package/dist/lib/semantic-fact-policy-condition-references.d.ts +7 -0
- package/dist/lib/semantic-fact-policy-condition-references.js +19 -0
- package/dist/lib/semantic-fact-policy-conditions.d.ts +2 -0
- package/dist/lib/semantic-fact-policy-conditions.js +105 -0
- package/dist/lib/semantic-fact-policy-facts.d.ts +3 -0
- package/dist/lib/semantic-fact-policy-facts.js +73 -0
- package/dist/lib/semantic-fact-policy-primitives.d.ts +26 -0
- package/dist/lib/semantic-fact-policy-primitives.js +169 -0
- package/dist/lib/semantic-fact-policy-proofs.d.ts +2 -0
- package/dist/lib/semantic-fact-policy-proofs.js +75 -0
- package/dist/lib/semantic-fact-policy-properties.d.ts +3 -0
- package/dist/lib/semantic-fact-policy-properties.js +84 -0
- package/dist/lib/semantic-fact-policy-units.d.ts +4 -0
- package/dist/lib/semantic-fact-policy-units.js +103 -0
- package/dist/lib/semantic-fact-policy.d.ts +17 -0
- package/dist/lib/semantic-fact-policy.js +41 -0
- package/dist/lib/semantic-fact-proof-shape.d.ts +51 -0
- package/dist/lib/semantic-fact-proof-shape.js +121 -0
- package/dist/lib/semantic-fact-proof-types.d.ts +74 -0
- package/dist/lib/semantic-fact-proof-types.js +1 -0
- package/dist/lib/semantic-fact-property-shape.d.ts +29 -0
- package/dist/lib/semantic-fact-property-shape.js +77 -0
- package/dist/lib/semantic-fact-shape-constants.d.ts +3 -0
- package/dist/lib/semantic-fact-shape-constants.js +38 -0
- package/dist/lib/semantic-fact-shape-primitives.d.ts +15 -0
- package/dist/lib/semantic-fact-shape-primitives.js +68 -0
- package/dist/lib/semantic-fact-source-parser.d.ts +9 -0
- package/dist/lib/semantic-fact-source-parser.js +46 -0
- package/dist/lib/semantic-fact-support-shape.d.ts +21 -0
- package/dist/lib/semantic-fact-support-shape.js +59 -0
- package/dist/lib/semantic-fact-types.d.ts +5 -0
- package/dist/lib/semantic-fact-types.js +5 -0
- package/dist/lib/semantic-fact-unit-shape.d.ts +34 -0
- package/dist/lib/semantic-fact-unit-shape.js +89 -0
- package/dist/lib/semantic-fact-value-shape.d.ts +12 -0
- package/dist/lib/semantic-fact-value-shape.js +39 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +1339 -131
- package/migrations/README.md +15 -15
- package/package.json +84 -84
- package/source-mappings.yaml +25 -25
- package/assets/skills/normal-long-task/SKILL.md +0 -12
|
@@ -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
|
+
}[];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { EVIDENCE_CAPABILITIES } from "./long-task-shape-primitives.js";
|
|
2
|
+
import { SEMANTIC_FACT_VALUE_KINDS } from "./semantic-fact-shape-constants.js";
|
|
3
|
+
import { semanticArray, semanticLiteral, semanticNullable, semanticObject, semanticStableRef, semanticStableRefs, semanticString, } from "./semantic-fact-shape-primitives.js";
|
|
4
|
+
import { parseSemanticFactBoolean } from "./semantic-fact-value-shape.js";
|
|
5
|
+
export function parseSemanticFactPropertyDispositions(value, label) {
|
|
6
|
+
return semanticArray(value, label).map((item, index) => {
|
|
7
|
+
const itemLabel = `${label}[${index}]`;
|
|
8
|
+
const row = semanticObject(item, itemLabel, [
|
|
9
|
+
"key",
|
|
10
|
+
"family_ref",
|
|
11
|
+
"property",
|
|
12
|
+
"standard",
|
|
13
|
+
"value_kind",
|
|
14
|
+
"required_methods",
|
|
15
|
+
"required_evidence_capabilities",
|
|
16
|
+
"applicable_unit_refs",
|
|
17
|
+
"not_applicable_unit_refs",
|
|
18
|
+
"decision_required_unit_refs",
|
|
19
|
+
"unavailable_unit_refs",
|
|
20
|
+
"condition_refs",
|
|
21
|
+
"source_item_refs",
|
|
22
|
+
"basis_refs",
|
|
23
|
+
"rationale",
|
|
24
|
+
]);
|
|
25
|
+
return {
|
|
26
|
+
key: semanticStableRef(row.key, `${itemLabel}.key`),
|
|
27
|
+
family_ref: semanticStableRef(row.family_ref, `${itemLabel}.family_ref`),
|
|
28
|
+
property: semanticStableRef(row.property, `${itemLabel}.property`),
|
|
29
|
+
standard: parseSemanticFactBoolean(row.standard, `${itemLabel}.standard`),
|
|
30
|
+
value_kind: semanticLiteral(row.value_kind, SEMANTIC_FACT_VALUE_KINDS, `${itemLabel}.value_kind`),
|
|
31
|
+
required_methods: semanticStableRefs(row.required_methods, `${itemLabel}.required_methods`),
|
|
32
|
+
required_evidence_capabilities: semanticArray(row.required_evidence_capabilities, `${itemLabel}.required_evidence_capabilities`).map((entry, capabilityIndex) => semanticLiteral(entry, EVIDENCE_CAPABILITIES, `${itemLabel}.required_evidence_capabilities[${capabilityIndex}]`)),
|
|
33
|
+
applicable_unit_refs: semanticStableRefs(row.applicable_unit_refs, `${itemLabel}.applicable_unit_refs`),
|
|
34
|
+
not_applicable_unit_refs: semanticStableRefs(row.not_applicable_unit_refs, `${itemLabel}.not_applicable_unit_refs`),
|
|
35
|
+
decision_required_unit_refs: semanticStableRefs(row.decision_required_unit_refs, `${itemLabel}.decision_required_unit_refs`),
|
|
36
|
+
unavailable_unit_refs: semanticStableRefs(row.unavailable_unit_refs, `${itemLabel}.unavailable_unit_refs`),
|
|
37
|
+
condition_refs: semanticStableRefs(row.condition_refs, `${itemLabel}.condition_refs`),
|
|
38
|
+
source_item_refs: semanticStableRefs(row.source_item_refs, `${itemLabel}.source_item_refs`),
|
|
39
|
+
basis_refs: semanticStableRefs(row.basis_refs, `${itemLabel}.basis_refs`),
|
|
40
|
+
rationale: semanticString(row.rationale, `${itemLabel}.rationale`),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function parseSemanticFactCells(value, label) {
|
|
45
|
+
return semanticArray(value, label).map((item, index) => {
|
|
46
|
+
const itemLabel = `${label}[${index}]`;
|
|
47
|
+
const row = semanticObject(item, itemLabel, [
|
|
48
|
+
"key",
|
|
49
|
+
"outcome_ref",
|
|
50
|
+
"unit_ref",
|
|
51
|
+
"condition_ref",
|
|
52
|
+
"property_ref",
|
|
53
|
+
"disposition",
|
|
54
|
+
"fact_ref",
|
|
55
|
+
"source_item_refs",
|
|
56
|
+
"basis_refs",
|
|
57
|
+
"rationale",
|
|
58
|
+
]);
|
|
59
|
+
return {
|
|
60
|
+
key: semanticStableRef(row.key, `${itemLabel}.key`),
|
|
61
|
+
outcome_ref: semanticStableRef(row.outcome_ref, `${itemLabel}.outcome_ref`),
|
|
62
|
+
unit_ref: semanticStableRef(row.unit_ref, `${itemLabel}.unit_ref`),
|
|
63
|
+
condition_ref: semanticStableRef(row.condition_ref, `${itemLabel}.condition_ref`),
|
|
64
|
+
property_ref: semanticStableRef(row.property_ref, `${itemLabel}.property_ref`),
|
|
65
|
+
disposition: semanticLiteral(row.disposition, [
|
|
66
|
+
"specified",
|
|
67
|
+
"not_applicable",
|
|
68
|
+
"decision_required",
|
|
69
|
+
"unavailable",
|
|
70
|
+
], `${itemLabel}.disposition`),
|
|
71
|
+
fact_ref: semanticNullable(row.fact_ref, (entry) => semanticStableRef(entry, `${itemLabel}.fact_ref`)),
|
|
72
|
+
source_item_refs: semanticStableRefs(row.source_item_refs, `${itemLabel}.source_item_refs`),
|
|
73
|
+
basis_refs: semanticStableRefs(row.basis_refs, `${itemLabel}.basis_refs`),
|
|
74
|
+
rationale: semanticString(row.rationale, `${itemLabel}.rationale`),
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const SEMANTIC_FACT_DISPOSITIONS: readonly ["applicable", "not_applicable", "decision_required", "unavailable"];
|
|
2
|
+
export declare const SEMANTIC_FACT_VALUE_KINDS: readonly ["boolean", "number", "string", "enum", "set", "ordered_list", "object", "schema", "relation", "decision_table", "formula", "range", "duration", "timestamp", "rate", "ratio", "digest", "trace", "custom"];
|
|
3
|
+
export declare const SEMANTIC_FACT_LOCATOR_KINDS: readonly ["source_item", "manifest_pointer", "json_pointer", "yaml_pointer", "whole_resource", "schema_pointer", "api_operation", "code_symbol", "custom"];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const SEMANTIC_FACT_DISPOSITIONS = [
|
|
2
|
+
"applicable",
|
|
3
|
+
"not_applicable",
|
|
4
|
+
"decision_required",
|
|
5
|
+
"unavailable",
|
|
6
|
+
];
|
|
7
|
+
export const SEMANTIC_FACT_VALUE_KINDS = [
|
|
8
|
+
"boolean",
|
|
9
|
+
"number",
|
|
10
|
+
"string",
|
|
11
|
+
"enum",
|
|
12
|
+
"set",
|
|
13
|
+
"ordered_list",
|
|
14
|
+
"object",
|
|
15
|
+
"schema",
|
|
16
|
+
"relation",
|
|
17
|
+
"decision_table",
|
|
18
|
+
"formula",
|
|
19
|
+
"range",
|
|
20
|
+
"duration",
|
|
21
|
+
"timestamp",
|
|
22
|
+
"rate",
|
|
23
|
+
"ratio",
|
|
24
|
+
"digest",
|
|
25
|
+
"trace",
|
|
26
|
+
"custom",
|
|
27
|
+
];
|
|
28
|
+
export const SEMANTIC_FACT_LOCATOR_KINDS = [
|
|
29
|
+
"source_item",
|
|
30
|
+
"manifest_pointer",
|
|
31
|
+
"json_pointer",
|
|
32
|
+
"yaml_pointer",
|
|
33
|
+
"whole_resource",
|
|
34
|
+
"schema_pointer",
|
|
35
|
+
"api_operation",
|
|
36
|
+
"code_symbol",
|
|
37
|
+
"custom",
|
|
38
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type SemanticShape = Record<string, unknown>;
|
|
2
|
+
export declare function semanticObject(value: unknown, label: string, required: string[], optional?: string[]): SemanticShape;
|
|
3
|
+
export declare function semanticArray(value: unknown, label: string): unknown[];
|
|
4
|
+
export declare function semanticString(value: unknown, label: string): string;
|
|
5
|
+
export declare function semanticStrings(value: unknown, label: string): string[];
|
|
6
|
+
export declare function semanticStableRef(value: unknown, label: string): string;
|
|
7
|
+
export declare function semanticStableRefs(value: unknown, label: string): string[];
|
|
8
|
+
export declare function semanticSha256(value: unknown, label: string): string;
|
|
9
|
+
export declare function semanticNullableSha256(value: unknown, label: string): string | null;
|
|
10
|
+
export declare function semanticInteger(value: unknown, label: string, minimum?: number): number;
|
|
11
|
+
export declare function semanticFiniteNumber(value: unknown, label: string): number;
|
|
12
|
+
export declare function semanticNullableNumber(value: unknown, label: string): number | null;
|
|
13
|
+
export declare function semanticLiteral<T extends string>(value: unknown, allowed: readonly T[], label: string): T;
|
|
14
|
+
export declare function semanticNullable<T>(value: unknown, parser: (value: unknown) => T): T | null;
|
|
15
|
+
export declare function semanticFail(label: string, message: string): never;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export function semanticObject(value, label, required, optional = []) {
|
|
2
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3
|
+
semanticFail(label, "must be an object");
|
|
4
|
+
const row = value;
|
|
5
|
+
const allowed = new Set([...required, ...optional]);
|
|
6
|
+
const unknown = Object.keys(row).filter((key) => !allowed.has(key));
|
|
7
|
+
if (unknown.length)
|
|
8
|
+
semanticFail(label, `unknown keys: ${unknown.join(",")}`);
|
|
9
|
+
const missing = required.filter((key) => !Object.hasOwn(row, key));
|
|
10
|
+
if (missing.length)
|
|
11
|
+
semanticFail(label, `missing keys: ${missing.join(",")}`);
|
|
12
|
+
return row;
|
|
13
|
+
}
|
|
14
|
+
export function semanticArray(value, label) {
|
|
15
|
+
if (!Array.isArray(value))
|
|
16
|
+
semanticFail(label, "must be an array");
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
export function semanticString(value, label) {
|
|
20
|
+
if (typeof value !== "string" || !value.trim())
|
|
21
|
+
semanticFail(label, "must be a non-empty string");
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
export function semanticStrings(value, label) {
|
|
25
|
+
return semanticArray(value, label).map((item, index) => semanticString(item, `${label}[${index}]`));
|
|
26
|
+
}
|
|
27
|
+
export function semanticStableRef(value, label) {
|
|
28
|
+
const result = semanticString(value, label);
|
|
29
|
+
if (!/^[a-z0-9][a-z0-9._:-]*$/u.test(result))
|
|
30
|
+
semanticFail(label, "must be a stable lowercase reference");
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
export function semanticStableRefs(value, label) {
|
|
34
|
+
return semanticArray(value, label).map((item, index) => semanticStableRef(item, `${label}[${index}]`));
|
|
35
|
+
}
|
|
36
|
+
export function semanticSha256(value, label) {
|
|
37
|
+
const result = semanticString(value, label);
|
|
38
|
+
if (!/^[a-f0-9]{64}$/u.test(result))
|
|
39
|
+
semanticFail(label, "must be a lowercase SHA-256 digest");
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
export function semanticNullableSha256(value, label) {
|
|
43
|
+
return value === null ? null : semanticSha256(value, label);
|
|
44
|
+
}
|
|
45
|
+
export function semanticInteger(value, label, minimum = 0) {
|
|
46
|
+
if (!Number.isInteger(value) || Number(value) < minimum)
|
|
47
|
+
semanticFail(label, `must be an integer >= ${minimum}`);
|
|
48
|
+
return Number(value);
|
|
49
|
+
}
|
|
50
|
+
export function semanticFiniteNumber(value, label) {
|
|
51
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
52
|
+
semanticFail(label, "must be a finite number");
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
export function semanticNullableNumber(value, label) {
|
|
56
|
+
return value === null ? null : semanticFiniteNumber(value, label);
|
|
57
|
+
}
|
|
58
|
+
export function semanticLiteral(value, allowed, label) {
|
|
59
|
+
if (typeof value !== "string" || !allowed.includes(value))
|
|
60
|
+
semanticFail(label, `must be one of ${allowed.join(",")}`);
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
export function semanticNullable(value, parser) {
|
|
64
|
+
return value === null ? null : parser(value);
|
|
65
|
+
}
|
|
66
|
+
export function semanticFail(label, message) {
|
|
67
|
+
throw new Error(`semantic_fact_manifest_invalid:${label}:${message}`);
|
|
68
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SemanticFactManifestV1 } from "./semantic-fact-types.js";
|
|
2
|
+
export interface ParsedSemanticFactManifestV1 {
|
|
3
|
+
source_path: string;
|
|
4
|
+
line: number;
|
|
5
|
+
manifest: SemanticFactManifestV1;
|
|
6
|
+
sha256: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function parseSemanticFactManifestBlocks(sourcePath: string, content: string): ParsedSemanticFactManifestV1[];
|
|
9
|
+
export declare function loadSemanticFactManifest(repository: string, sourcePaths: string[]): Promise<ParsedSemanticFactManifestV1>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { assertProtectedRepositoryFile } from "./long-task-protected-files.js";
|
|
4
|
+
import { parseSemanticFactManifestShape } from "./semantic-fact-manifest-shape.js";
|
|
5
|
+
import { canonicalValueJson, parseStrictYaml, sha256Hex, } from "./strict-codec.js";
|
|
6
|
+
const START = /^\s*```yaml[ \t]+semantic-fact-manifest-v1[ \t]*$/u;
|
|
7
|
+
const END = /^\s*```[ \t]*$/u;
|
|
8
|
+
export function parseSemanticFactManifestBlocks(sourcePath, content) {
|
|
9
|
+
const rows = [];
|
|
10
|
+
const lines = content.replace(/\r\n?/gu, "\n").split("\n");
|
|
11
|
+
let open = null;
|
|
12
|
+
for (const [index, line] of lines.entries()) {
|
|
13
|
+
if (!open) {
|
|
14
|
+
if (START.test(line))
|
|
15
|
+
open = { line: index + 1, lines: [] };
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (!END.test(line)) {
|
|
19
|
+
open.lines.push(line);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const manifest = parseSemanticFactManifestShape(parseStrictYaml(open.lines.join("\n")));
|
|
23
|
+
rows.push({
|
|
24
|
+
source_path: sourcePath,
|
|
25
|
+
line: open.line,
|
|
26
|
+
manifest,
|
|
27
|
+
sha256: sha256Hex(canonicalValueJson(manifest)),
|
|
28
|
+
});
|
|
29
|
+
open = null;
|
|
30
|
+
}
|
|
31
|
+
if (open)
|
|
32
|
+
throw new Error(`source_formal_block_unclosed:${sourcePath}:semantic-fact-manifest-v1:${open.line}`);
|
|
33
|
+
return rows;
|
|
34
|
+
}
|
|
35
|
+
export async function loadSemanticFactManifest(repository, sourcePaths) {
|
|
36
|
+
const rows = [];
|
|
37
|
+
for (const [index, sourcePath] of sourcePaths.entries()) {
|
|
38
|
+
if (!sourcePath.toLowerCase().endsWith(".md"))
|
|
39
|
+
continue;
|
|
40
|
+
const file = await assertProtectedRepositoryFile(repository, path.resolve(repository, ...sourcePath.split("/")), `semantic_fact_manifest_source:${index}:${sourcePath}`);
|
|
41
|
+
rows.push(...parseSemanticFactManifestBlocks(sourcePath, await readFile(file, "utf8")));
|
|
42
|
+
}
|
|
43
|
+
if (rows.length !== 1)
|
|
44
|
+
throw new Error(`semantic_fact_manifest_exactly_one_required:${rows.length}`);
|
|
45
|
+
return rows[0];
|
|
46
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare function parseSemanticFactOracles(value: unknown, label: string): {
|
|
2
|
+
key: string;
|
|
3
|
+
trust: "frozen_executable" | "named_external_tcb";
|
|
4
|
+
identity: string;
|
|
5
|
+
version: string;
|
|
6
|
+
sha256: string | null;
|
|
7
|
+
capabilities: string[];
|
|
8
|
+
}[];
|
|
9
|
+
export declare function parseSemanticFactEnvironments(value: unknown, label: string): {
|
|
10
|
+
key: string;
|
|
11
|
+
identity: string;
|
|
12
|
+
definition: import("./semantic-fact-base-types.js").SemanticFactLocatedValueV1;
|
|
13
|
+
}[];
|
|
14
|
+
export declare function parseSemanticFactBlockers(value: unknown, label: string): {
|
|
15
|
+
key: string;
|
|
16
|
+
kind: "conflict" | "decision_required" | "unavailable" | "unreadable";
|
|
17
|
+
affected_refs: string[];
|
|
18
|
+
source_item_refs: string[];
|
|
19
|
+
owner: string;
|
|
20
|
+
resolution: string;
|
|
21
|
+
}[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { semanticArray, semanticLiteral, semanticNullableSha256, semanticObject, semanticStableRef, semanticStableRefs, semanticString, } from "./semantic-fact-shape-primitives.js";
|
|
2
|
+
import { parseSemanticFactLocatedValue } from "./semantic-fact-value-shape.js";
|
|
3
|
+
export function parseSemanticFactOracles(value, label) {
|
|
4
|
+
return semanticArray(value, label).map((item, index) => {
|
|
5
|
+
const itemLabel = `${label}[${index}]`;
|
|
6
|
+
const row = semanticObject(item, itemLabel, [
|
|
7
|
+
"key",
|
|
8
|
+
"trust",
|
|
9
|
+
"identity",
|
|
10
|
+
"version",
|
|
11
|
+
"sha256",
|
|
12
|
+
"capabilities",
|
|
13
|
+
]);
|
|
14
|
+
return {
|
|
15
|
+
key: semanticStableRef(row.key, `${itemLabel}.key`),
|
|
16
|
+
trust: semanticLiteral(row.trust, ["frozen_executable", "named_external_tcb"], `${itemLabel}.trust`),
|
|
17
|
+
identity: semanticString(row.identity, `${itemLabel}.identity`),
|
|
18
|
+
version: semanticString(row.version, `${itemLabel}.version`),
|
|
19
|
+
sha256: semanticNullableSha256(row.sha256, `${itemLabel}.sha256`),
|
|
20
|
+
capabilities: semanticStableRefs(row.capabilities, `${itemLabel}.capabilities`),
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function parseSemanticFactEnvironments(value, label) {
|
|
25
|
+
return semanticArray(value, label).map((item, index) => {
|
|
26
|
+
const itemLabel = `${label}[${index}]`;
|
|
27
|
+
const row = semanticObject(item, itemLabel, [
|
|
28
|
+
"key",
|
|
29
|
+
"identity",
|
|
30
|
+
"definition",
|
|
31
|
+
]);
|
|
32
|
+
return {
|
|
33
|
+
key: semanticStableRef(row.key, `${itemLabel}.key`),
|
|
34
|
+
identity: semanticString(row.identity, `${itemLabel}.identity`),
|
|
35
|
+
definition: parseSemanticFactLocatedValue(row.definition, `${itemLabel}.definition`),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function parseSemanticFactBlockers(value, label) {
|
|
40
|
+
return semanticArray(value, label).map((item, index) => {
|
|
41
|
+
const itemLabel = `${label}[${index}]`;
|
|
42
|
+
const row = semanticObject(item, itemLabel, [
|
|
43
|
+
"key",
|
|
44
|
+
"kind",
|
|
45
|
+
"affected_refs",
|
|
46
|
+
"source_item_refs",
|
|
47
|
+
"owner",
|
|
48
|
+
"resolution",
|
|
49
|
+
]);
|
|
50
|
+
return {
|
|
51
|
+
key: semanticStableRef(row.key, `${itemLabel}.key`),
|
|
52
|
+
kind: semanticLiteral(row.kind, ["decision_required", "unavailable", "conflict", "unreadable"], `${itemLabel}.kind`),
|
|
53
|
+
affected_refs: semanticStableRefs(row.affected_refs, `${itemLabel}.affected_refs`),
|
|
54
|
+
source_item_refs: semanticStableRefs(row.source_item_refs, `${itemLabel}.source_item_refs`),
|
|
55
|
+
owner: semanticString(row.owner, `${itemLabel}.owner`),
|
|
56
|
+
resolution: semanticString(row.resolution, `${itemLabel}.resolution`),
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare function parseSemanticFactSubjects(value: unknown, label: string): {
|
|
2
|
+
key: string;
|
|
3
|
+
family_ref: string;
|
|
4
|
+
outcome_ref: string;
|
|
5
|
+
kind: string;
|
|
6
|
+
parent_ref: string | null;
|
|
7
|
+
owner_ref: string | null;
|
|
8
|
+
source_item_refs: string[];
|
|
9
|
+
basis_refs: string[];
|
|
10
|
+
}[];
|
|
11
|
+
export declare function parseSemanticFactRelations(value: unknown, label: string): {
|
|
12
|
+
key: string;
|
|
13
|
+
family_ref: string;
|
|
14
|
+
outcome_ref: string;
|
|
15
|
+
kind: string;
|
|
16
|
+
endpoints: {
|
|
17
|
+
role: string;
|
|
18
|
+
unit_ref: string;
|
|
19
|
+
}[];
|
|
20
|
+
source_item_refs: string[];
|
|
21
|
+
basis_refs: string[];
|
|
22
|
+
}[];
|
|
23
|
+
export declare function parseSemanticFactPopulations(value: unknown, label: string): {
|
|
24
|
+
key: string;
|
|
25
|
+
family_ref: string;
|
|
26
|
+
outcome_ref: string;
|
|
27
|
+
kind: "dynamic" | "static";
|
|
28
|
+
member_unit_refs: string[];
|
|
29
|
+
universe: import("./semantic-fact-base-types.js").SemanticFactLocatedValueV1;
|
|
30
|
+
enumeration_rule: string;
|
|
31
|
+
exclusion_refs: string[];
|
|
32
|
+
source_item_refs: string[];
|
|
33
|
+
basis_refs: string[];
|
|
34
|
+
}[];
|