domainforge 0.13.0
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/.cargo/config.toml +6 -0
- package/.claude/settings.local.json +18 -0
- package/.coderabbit.yml +43 -0
- package/.codex/skills/release-management/SKILL.md +151 -0
- package/.codex/skills/release-management/agents/openai.yaml +4 -0
- package/.github/actions/decrypt-secrets/action.yml +121 -0
- package/.github/agents/Coder.agent.md +97 -0
- package/.github/agents/DeepResearch.agent.md +61 -0
- package/.github/chatmodes/tdd.vibepro.chatmode.md +1183 -0
- package/.github/copilot-instructions.md +13 -0
- package/.github/dependabot.yml +68 -0
- package/.github/workflows/README.md +165 -0
- package/.github/workflows/ci.yml +335 -0
- package/.github/workflows/dependabot-automerge.yml +114 -0
- package/.github/workflows/dependency-review.yml +27 -0
- package/.github/workflows/deploy.yml +87 -0
- package/.github/workflows/prepare-release.yml +168 -0
- package/.github/workflows/release-crates.yml +42 -0
- package/.github/workflows/release-npm.yml +137 -0
- package/.github/workflows/release-please.yml +29 -0
- package/.github/workflows/release-pypi.yml +96 -0
- package/.gitkeep +1 -0
- package/.release-please-manifest.json +5 -0
- package/.sea-registry.toml +10 -0
- package/.serena/project.yml +133 -0
- package/.sops.yaml +10 -0
- package/AGENTS.md +216 -0
- package/CHANGELOG.md +400 -0
- package/CLAUDE.md +62 -0
- package/CONTRIBUTING.md +323 -0
- package/Cargo.lock +3612 -0
- package/Cargo.toml +12 -0
- package/LICENSE +201 -0
- package/README.md +660 -0
- package/README_PYTHON.md +256 -0
- package/README_TYPESCRIPT.md +305 -0
- package/README_WASM.md +329 -0
- package/RELEASE_NOTES.md +41 -0
- package/bun.lock +378 -0
- package/bunfig.toml +11 -0
- package/check_output.txt +83 -0
- package/clippy_output.txt +80 -0
- package/commitlint.config.cjs +8 -0
- package/deny.toml +42 -0
- package/devbox.json +14 -0
- package/devbox.lock +76 -0
- package/docs/RELEASE_PROCESS.md +360 -0
- package/docs/diagnostics.md +161 -0
- package/docs/doc_guidelines.md +53 -0
- package/docs/explanations/README.md +21 -0
- package/docs/explanations/architecture-overview.md +109 -0
- package/docs/explanations/cross-language-binding-strategy.md +68 -0
- package/docs/explanations/graph-store-design.md +47 -0
- package/docs/explanations/performance-benchmarks.md +63 -0
- package/docs/explanations/policy-evaluation-logic.md +106 -0
- package/docs/explanations/semantic-modeling-concepts.md +109 -0
- package/docs/explanations/three-valued-logic.md +66 -0
- package/docs/explanations/versioning-strategy.md +45 -0
- package/docs/governance.md +168 -0
- package/docs/how-tos/README.md +46 -0
- package/docs/how-tos/ci-cd-validation.md +93 -0
- package/docs/how-tos/create-custom-units.md +125 -0
- package/docs/how-tos/define-policies.md +119 -0
- package/docs/how-tos/export-to-calm.md +110 -0
- package/docs/how-tos/export-to-protobuf.md +312 -0
- package/docs/how-tos/extend-grammar.md +133 -0
- package/docs/how-tos/generate-rdf-turtle.md +106 -0
- package/docs/how-tos/import-from-calm.md +114 -0
- package/docs/how-tos/import-from-sbvr.md +249 -0
- package/docs/how-tos/install-cli.md +126 -0
- package/docs/how-tos/parse-sea-files.md +132 -0
- package/docs/how-tos/policy-evaluation-modes.md +30 -0
- package/docs/how-tos/run-cross-language-tests.md +115 -0
- package/docs/how-tos/troubleshoot-napi-builds.md +55 -0
- package/docs/how-tos/use-modules-imports.md +285 -0
- package/docs/index.md +13 -0
- package/docs/plans/canonical-normalizer.md +121 -0
- package/docs/plans/cd_improvement.md +112 -0
- package/docs/plans/cli-ast.md +29 -0
- package/docs/plans/expression-bindings-and-normalizer-integration.md +174 -0
- package/docs/plans/protobuf_advanced_features_plan.md +597 -0
- package/docs/plans/protobuf_plan.yml +525 -0
- package/docs/plans/refactor_dsl_architecture.md +131 -0
- package/docs/plans/release-plan.md +163 -0
- package/docs/plans/sea_fmt_implementation_plan.md +516 -0
- package/docs/playbooks/README.md +18 -0
- package/docs/playbooks/adding-new-primitive.md +68 -0
- package/docs/playbooks/debugging-parser-failures.md +42 -0
- package/docs/playbooks/local-release-preparation.md +139 -0
- package/docs/playbooks/migrating-schema-versions.md +43 -0
- package/docs/playbooks/onboarding-contributors.md +64 -0
- package/docs/playbooks/releasing-beta.md +86 -0
- package/docs/playbooks/secret-management.md +64 -0
- package/docs/reference/README.md +199 -0
- package/docs/reference/ast-json-api.md +427 -0
- package/docs/reference/calm-mapping.md +519 -0
- package/docs/reference/cli-commands.md +588 -0
- package/docs/reference/configuration.md +202 -0
- package/docs/reference/error-codes.md +664 -0
- package/docs/reference/generated-artifacts-policy.md +53 -0
- package/docs/reference/grammar-spec.md +255 -0
- package/docs/reference/primitives-api.md +317 -0
- package/docs/reference/protobuf-api.md +426 -0
- package/docs/reference/python-api.md +485 -0
- package/docs/reference/registry.md +50 -0
- package/docs/reference/sea-dsl-ai-cheatsheet.yaml +913 -0
- package/docs/reference/security-model.md +74 -0
- package/docs/reference/typescript-api.md +508 -0
- package/docs/reference/wasm-api.md +420 -0
- package/docs/semantic-pack-review.md +144 -0
- package/docs/semantic-pack-signing.md +234 -0
- package/docs/semantic-packs.md +284 -0
- package/docs/specs/ADR-001-sea-dsl-semantic-source-of-truth.md +33 -0
- package/docs/specs/ADR-002-projection-first-class-construct.md +50 -0
- package/docs/specs/ADR-003-protobuf-projection-target.md +51 -0
- package/docs/specs/ADR-004-projection-compatibility-semantics.md +57 -0
- package/docs/specs/ADR-005-multi-language-support-strategy.md +112 -0
- package/docs/specs/ADR-006-error-handling-strategy.md +115 -0
- package/docs/specs/ADR-007-policy-evaluation-engine.md +95 -0
- package/docs/specs/ADR-008-knowledge-graph-integration.md +90 -0
- package/docs/specs/ADR-009-module-resolution-strategy.md +115 -0
- package/docs/specs/ADR-010-unit-system.md +106 -0
- package/docs/specs/PRD-001-sea-projection-framework.md +155 -0
- package/docs/specs/PRD-002-sea-cli-tooling.md +169 -0
- package/docs/specs/PRD-003-dsl-core-capabilities.md +275 -0
- package/docs/specs/README.md +62 -0
- package/docs/specs/SDS-001-protobuf-projection-engine.md +451 -0
- package/docs/specs/SDS-002-sea-core-architecture.md +268 -0
- package/docs/specs/SDS-003-parser-semantic-graph.md +377 -0
- package/docs/specs/SDS-004-policy-engine-design.md +362 -0
- package/docs/specs/SDS-005-knowledge-graph-module.md +364 -0
- package/docs/specs/SDS-006-calm-integration.md +367 -0
- package/docs/specs/SDS-007-sbvr-import.md +347 -0
- package/docs/templates/template_explanation.md +14 -0
- package/docs/templates/template_howto.md +21 -0
- package/docs/templates/template_playbook.md +21 -0
- package/docs/templates/template_reference.md +17 -0
- package/docs/templates/template_tutorial.md +24 -0
- package/docs/tutorials/README.md +12 -0
- package/docs/tutorials/first-sea-model.md +85 -0
- package/docs/tutorials/getting-started.md +98 -0
- package/docs/tutorials/python-binding-quickstart.md +107 -0
- package/docs/tutorials/typescript-binding-quickstart.md +91 -0
- package/docs/tutorials/wasm-in-browser.md +75 -0
- package/domainforge-core/CHANGELOG.md +138 -0
- package/domainforge-core/Cargo.toml +101 -0
- package/domainforge-core/MIGRATING.md +32 -0
- package/domainforge-core/README.md +197 -0
- package/domainforge-core/benchmark_results.txt +51 -0
- package/domainforge-core/build.rs +6 -0
- package/domainforge-core/deny.toml +31 -0
- package/domainforge-core/docs/specs/projections/sbvr_kg_mapping.md +43 -0
- package/domainforge-core/examples/basic.sea +7 -0
- package/domainforge-core/examples/cli/import_export_workflow.sh +38 -0
- package/domainforge-core/examples/cli/validate_example.sh +30 -0
- package/domainforge-core/examples/evolution_semantics.sea +31 -0
- package/domainforge-core/examples/parser_demo.rs +203 -0
- package/domainforge-core/grammar/sea.pest +408 -0
- package/domainforge-core/schemas/calm-v1.schema.json +170 -0
- package/domainforge-core/schemas/shacl/sea_shapes.ttl +19 -0
- package/domainforge-core/src/authority/compiler.rs +309 -0
- package/domainforge-core/src/authority/environment.rs +203 -0
- package/domainforge-core/src/authority/error.rs +164 -0
- package/domainforge-core/src/authority/fact_resolver.rs +224 -0
- package/domainforge-core/src/authority/mod.rs +25 -0
- package/domainforge-core/src/authority/pack.rs +133 -0
- package/domainforge-core/src/authority/policy.rs +224 -0
- package/domainforge-core/src/authority/resolver.rs +446 -0
- package/domainforge-core/src/authority/trace.rs +217 -0
- package/domainforge-core/src/authority/transform.rs +168 -0
- package/domainforge-core/src/authority/types.rs +617 -0
- package/domainforge-core/src/bin/domainforge.rs +25 -0
- package/domainforge-core/src/calm/export.rs +538 -0
- package/domainforge-core/src/calm/import.rs +1220 -0
- package/domainforge-core/src/calm/mod.rs +9 -0
- package/domainforge-core/src/calm/models.rs +108 -0
- package/domainforge-core/src/calm/sbvr_import.rs +9 -0
- package/domainforge-core/src/cli/authority.rs +149 -0
- package/domainforge-core/src/cli/format.rs +85 -0
- package/domainforge-core/src/cli/import.rs +133 -0
- package/domainforge-core/src/cli/mod.rs +64 -0
- package/domainforge-core/src/cli/normalize.rs +180 -0
- package/domainforge-core/src/cli/pack.rs +904 -0
- package/domainforge-core/src/cli/parse.rs +112 -0
- package/domainforge-core/src/cli/project.rs +294 -0
- package/domainforge-core/src/cli/registry.rs +41 -0
- package/domainforge-core/src/cli/test.rs +12 -0
- package/domainforge-core/src/cli/validate.rs +195 -0
- package/domainforge-core/src/cli/validate_kg.rs +80 -0
- package/domainforge-core/src/concept_id.rs +89 -0
- package/domainforge-core/src/error/diagnostics.rs +426 -0
- package/domainforge-core/src/error/fuzzy.rs +253 -0
- package/domainforge-core/src/error/mod.rs +13 -0
- package/domainforge-core/src/formatter/comments.rs +223 -0
- package/domainforge-core/src/formatter/config.rs +114 -0
- package/domainforge-core/src/formatter/mod.rs +22 -0
- package/domainforge-core/src/formatter/printer.rs +906 -0
- package/domainforge-core/src/graph/mod.rs +858 -0
- package/domainforge-core/src/graph/to_ast.rs +66 -0
- package/domainforge-core/src/kg.rs +1476 -0
- package/domainforge-core/src/kg_import.rs +251 -0
- package/domainforge-core/src/lib.rs +203 -0
- package/domainforge-core/src/module/mod.rs +1 -0
- package/domainforge-core/src/module/resolver.rs +260 -0
- package/domainforge-core/src/parser/ast.rs +2919 -0
- package/domainforge-core/src/parser/ast_convert.rs +494 -0
- package/domainforge-core/src/parser/ast_schema.rs +491 -0
- package/domainforge-core/src/parser/error.rs +291 -0
- package/domainforge-core/src/parser/lint.rs +39 -0
- package/domainforge-core/src/parser/mod.rs +193 -0
- package/domainforge-core/src/parser/printer.rs +702 -0
- package/domainforge-core/src/parser/profiles.rs +71 -0
- package/domainforge-core/src/parser/string_utils.rs +138 -0
- package/domainforge-core/src/patterns.rs +68 -0
- package/domainforge-core/src/policy/core.rs +1148 -0
- package/domainforge-core/src/policy/expression.rs +399 -0
- package/domainforge-core/src/policy/mod.rs +18 -0
- package/domainforge-core/src/policy/normalize.rs +1028 -0
- package/domainforge-core/src/policy/quantifier.rs +940 -0
- package/domainforge-core/src/policy/three_valued.rs +140 -0
- package/domainforge-core/src/policy/three_valued_microbench.rs +104 -0
- package/domainforge-core/src/policy/type_inference.rs +67 -0
- package/domainforge-core/src/policy/violation.rs +36 -0
- package/domainforge-core/src/primitives/concept_change.rs +61 -0
- package/domainforge-core/src/primitives/entity.rs +224 -0
- package/domainforge-core/src/primitives/flow.rs +111 -0
- package/domainforge-core/src/primitives/instance.rs +93 -0
- package/domainforge-core/src/primitives/mapping_contract.rs +50 -0
- package/domainforge-core/src/primitives/metric.rs +79 -0
- package/domainforge-core/src/primitives/mod.rs +25 -0
- package/domainforge-core/src/primitives/projection_contract.rs +50 -0
- package/domainforge-core/src/primitives/quantity.rs +56 -0
- package/domainforge-core/src/primitives/relation.rs +68 -0
- package/domainforge-core/src/primitives/resource.rs +237 -0
- package/domainforge-core/src/primitives/resource_instance.rs +88 -0
- package/domainforge-core/src/primitives/role.rs +49 -0
- package/domainforge-core/src/projection/buf.rs +404 -0
- package/domainforge-core/src/projection/contracts.rs +22 -0
- package/domainforge-core/src/projection/engine.rs +19 -0
- package/domainforge-core/src/projection/mod.rs +16 -0
- package/domainforge-core/src/projection/protobuf.rs +3331 -0
- package/domainforge-core/src/projection/registry.rs +43 -0
- package/domainforge-core/src/python/authority.rs +253 -0
- package/domainforge-core/src/python/error.rs +227 -0
- package/domainforge-core/src/python/formatter.rs +86 -0
- package/domainforge-core/src/python/graph.rs +366 -0
- package/domainforge-core/src/python/mod.rs +9 -0
- package/domainforge-core/src/python/policy.rs +651 -0
- package/domainforge-core/src/python/primitives.rs +796 -0
- package/domainforge-core/src/python/registry.rs +98 -0
- package/domainforge-core/src/python/semantic_pack.rs +619 -0
- package/domainforge-core/src/python/units.rs +96 -0
- package/domainforge-core/src/registry/mod.rs +432 -0
- package/domainforge-core/src/registry/tests.rs +210 -0
- package/domainforge-core/src/sbvr.rs +744 -0
- package/domainforge-core/src/semantic_pack/builder.rs +470 -0
- package/domainforge-core/src/semantic_pack/canonical_json.rs +184 -0
- package/domainforge-core/src/semantic_pack/diagnostics.rs +214 -0
- package/domainforge-core/src/semantic_pack/diff.rs +216 -0
- package/domainforge-core/src/semantic_pack/mod.rs +31 -0
- package/domainforge-core/src/semantic_pack/pack_set.rs +240 -0
- package/domainforge-core/src/semantic_pack/resolver.rs +437 -0
- package/domainforge-core/src/semantic_pack/review.rs +125 -0
- package/domainforge-core/src/semantic_pack/schema.rs +342 -0
- package/domainforge-core/src/semantic_pack/signing.rs +105 -0
- package/domainforge-core/src/semantic_pack/validator.rs +368 -0
- package/domainforge-core/src/semantic_version.rs +140 -0
- package/domainforge-core/src/test_utils.rs +12 -0
- package/domainforge-core/src/typescript/authority.rs +184 -0
- package/domainforge-core/src/typescript/error.rs +146 -0
- package/domainforge-core/src/typescript/formatter.rs +76 -0
- package/domainforge-core/src/typescript/graph.rs +391 -0
- package/domainforge-core/src/typescript/mod.rs +9 -0
- package/domainforge-core/src/typescript/policy.rs +564 -0
- package/domainforge-core/src/typescript/primitives.rs +784 -0
- package/domainforge-core/src/typescript/registry.rs +88 -0
- package/domainforge-core/src/typescript/semantic_pack.rs +470 -0
- package/domainforge-core/src/typescript/units.rs +76 -0
- package/domainforge-core/src/units/mod.rs +462 -0
- package/domainforge-core/src/uuid_module.rs +42 -0
- package/domainforge-core/src/validation_error.rs +818 -0
- package/domainforge-core/src/validation_result.rs +30 -0
- package/domainforge-core/src/wasm/authority.rs +192 -0
- package/domainforge-core/src/wasm/error.rs +145 -0
- package/domainforge-core/src/wasm/formatter.rs +69 -0
- package/domainforge-core/src/wasm/graph.rs +471 -0
- package/domainforge-core/src/wasm/mod.rs +16 -0
- package/domainforge-core/src/wasm/policy.rs +607 -0
- package/domainforge-core/src/wasm/primitives.rs +295 -0
- package/domainforge-core/src/wasm/semantic_pack.rs +471 -0
- package/domainforge-core/src/wasm/units.rs +62 -0
- package/domainforge-core/std/aws.sea +6 -0
- package/domainforge-core/std/core.sea +6 -0
- package/domainforge-core/std/http.sea +27 -0
- package/domainforge-core/tests/aggregation_enhanced_tests.rs +162 -0
- package/domainforge-core/tests/aggregation_eval_tests.rs +248 -0
- package/domainforge-core/tests/aggregation_integration_tests.rs +379 -0
- package/domainforge-core/tests/aggregation_parser_tests.rs +92 -0
- package/domainforge-core/tests/aggregation_tests.rs +102 -0
- package/domainforge-core/tests/authority_conformance_tests.rs +1173 -0
- package/domainforge-core/tests/calm_round_trip_tests.rs +283 -0
- package/domainforge-core/tests/calm_schema_validation_tests.rs +137 -0
- package/domainforge-core/tests/cast_operator_tests.rs +85 -0
- package/domainforge-core/tests/cli_binary_check.rs +37 -0
- package/domainforge-core/tests/cli_import_tests.rs +291 -0
- package/domainforge-core/tests/cli_path_traversal_tests.rs +124 -0
- package/domainforge-core/tests/cli_tests.rs +63 -0
- package/domainforge-core/tests/diagnostics_tests.rs +203 -0
- package/domainforge-core/tests/dimension_unit_tests.rs +80 -0
- package/domainforge-core/tests/entity_tests.rs +69 -0
- package/domainforge-core/tests/evolution_semantics_tests.rs +157 -0
- package/domainforge-core/tests/flow_tests.rs +78 -0
- package/domainforge-core/tests/flow_unit_validation_tests.rs +31 -0
- package/domainforge-core/tests/graph_integration_tests.rs +218 -0
- package/domainforge-core/tests/graph_tests.rs +626 -0
- package/domainforge-core/tests/import_parsing_tests.rs +23 -0
- package/domainforge-core/tests/instance_integration_tests.rs +98 -0
- package/domainforge-core/tests/instance_parsing_tests.rs +58 -0
- package/domainforge-core/tests/instance_tests.rs +61 -0
- package/domainforge-core/tests/kg_uri_encoding_tests.rs +53 -0
- package/domainforge-core/tests/lint_tests.rs +19 -0
- package/domainforge-core/tests/metric_tests.rs +143 -0
- package/domainforge-core/tests/module_resolution_tests.rs +100 -0
- package/domainforge-core/tests/namespace_registry_tests.rs +247 -0
- package/domainforge-core/tests/null_handling_tests.rs +26 -0
- package/domainforge-core/tests/parser_ast_v3.rs +53 -0
- package/domainforge-core/tests/parser_dimension_registry_tests.rs +20 -0
- package/domainforge-core/tests/parser_integration_tests.rs +294 -0
- package/domainforge-core/tests/parser_metadata_tests.rs +97 -0
- package/domainforge-core/tests/parser_resource_domain_only_graph_test.rs +21 -0
- package/domainforge-core/tests/parser_resource_limits_tests.rs +122 -0
- package/domainforge-core/tests/parser_tests.rs +512 -0
- package/domainforge-core/tests/pattern_semantics_tests.rs +87 -0
- package/domainforge-core/tests/phase_14_determinism_tests.rs +166 -0
- package/domainforge-core/tests/phase_15_validation_error_tests.rs +136 -0
- package/domainforge-core/tests/phase_16_unicode_tests.rs +248 -0
- package/domainforge-core/tests/phase_17_export_tests.rs +285 -0
- package/domainforge-core/tests/phase_17_round_trip_tests.rs +264 -0
- package/domainforge-core/tests/policy_tests.rs +635 -0
- package/domainforge-core/tests/primitives_integration_tests.rs +151 -0
- package/domainforge-core/tests/print_rdf_xml.rs +14 -0
- package/domainforge-core/tests/printer_tests.rs +204 -0
- package/domainforge-core/tests/profile_tests.rs +35 -0
- package/domainforge-core/tests/projection_contracts_tests.rs +154 -0
- package/domainforge-core/tests/protobuf_projection_tests.rs +199 -0
- package/domainforge-core/tests/quantity_tests.rs +41 -0
- package/domainforge-core/tests/rdf_xml_typed_literal_tests.rs +105 -0
- package/domainforge-core/tests/registry_schema_tests.rs +33 -0
- package/domainforge-core/tests/resource_tests.rs +50 -0
- package/domainforge-core/tests/resource_unit_tests.rs +24 -0
- package/domainforge-core/tests/roles_relations_tests.rs +61 -0
- package/domainforge-core/tests/round_trip_tests.rs +34 -0
- package/domainforge-core/tests/runtime_toggle_tests.rs +70 -0
- package/domainforge-core/tests/sbvr_fact_schema_tests.rs +60 -0
- package/domainforge-core/tests/sbvr_flow_facts_tests.rs +55 -0
- package/domainforge-core/tests/sbvr_parsing_tests.rs +53 -0
- package/domainforge-core/tests/semantic_pack_alias_resolution.rs +197 -0
- package/domainforge-core/tests/semantic_pack_build.rs +302 -0
- package/domainforge-core/tests/semantic_pack_consumer_smoke.rs +150 -0
- package/domainforge-core/tests/semantic_pack_pack_set.rs +160 -0
- package/domainforge-core/tests/semantic_pack_signing.rs +157 -0
- package/domainforge-core/tests/semantic_pack_three_valued.rs +250 -0
- package/domainforge-core/tests/semantic_pack_validate.rs +196 -0
- package/domainforge-core/tests/std_lib_tests.rs +37 -0
- package/domainforge-core/tests/temporal_evaluation_tests.rs +159 -0
- package/domainforge-core/tests/temporal_semantics_tests.rs +214 -0
- package/domainforge-core/tests/three_valued_quantifiers_tests.rs +164 -0
- package/domainforge-core/tests/turtle_entity_export_tests.rs +38 -0
- package/domainforge-core/tests/turtle_escaping_tests.rs +53 -0
- package/domainforge-core/tests/turtle_resource_export_tests.rs +34 -0
- package/domainforge-core/tests/type_inference_tests.rs +40 -0
- package/domainforge-core/tests/unicode_validation_tests.rs +169 -0
- package/domainforge-core/tests/unit_tests.rs +81 -0
- package/domainforge-core/tests/validate_tests.rs +38 -0
- package/domainforge-core/tests/validation_unit_mismatch_tests.rs +83 -0
- package/domainforge-core/tests/wasm_tests.rs +229 -0
- package/domainforge-python/CHANGELOG-python.md +12 -0
- package/domainforge-python/MIGRATING.md +24 -0
- package/domainforge-python/README.md +256 -0
- package/domainforge-python/domainforge/__init__.py +95 -0
- package/domainforge-python/domainforge/domainforge.pyi +519 -0
- package/domainforge-python/pyproject.toml +36 -0
- package/domainforge-typescript/CHANGELOG-typescript.md +12 -0
- package/domainforge-typescript/LICENSE +201 -0
- package/domainforge-typescript/MIGRATING.md +24 -0
- package/domainforge-typescript/README.md +305 -0
- package/domainforge-typescript/index.d.ts +452 -0
- package/domainforge-typescript/index.js +361 -0
- package/domainforge-typescript/package.json +60 -0
- package/example.js +61 -0
- package/examples/browser.html +366 -0
- package/examples/namespaces/finance/cashflow.sea +5 -0
- package/examples/namespaces/logistics/core.sea +7 -0
- package/examples/observability_metrics.sea +38 -0
- package/fixtures/semantic_packs/acme_procurement/domain/entities.sea +39 -0
- package/fixtures/semantic_packs/acme_procurement/domain/metrics.sea +11 -0
- package/fixtures/semantic_packs/acme_procurement/domain/relations.sea +7 -0
- package/fixtures/semantic_packs/acme_procurement/domain/resources.sea +9 -0
- package/fixtures/semantic_packs/acme_procurement/review/acme.procurement.semantic-review.jsonl +7 -0
- package/fixtures/semantic_packs/acme_procurement/tests/ambiguous_vendor_alias.sea +8 -0
- package/fixtures/semantic_packs/acme_procurement/tests/deprecated_vendor_alias.sea +8 -0
- package/fixtures/semantic_packs/acme_procurement/tests/invalid_relation.sea +3 -0
- package/fixtures/semantic_packs/acme_procurement/tests/proposed_concept.sea +8 -0
- package/fixtures/semantic_packs/acme_procurement/tests/rejected_concept.sea +8 -0
- package/fixtures/semantic_packs/acme_procurement/tests/unit_mismatch.sea +7 -0
- package/fixtures/semantic_packs/acme_procurement/tests/unknown_vendor_policy.sea +8 -0
- package/fixtures/semantic_packs/acme_procurement/tests/valid_purchase_policy.sea +8 -0
- package/index.d.ts +2 -0
- package/index.js +8 -0
- package/justfile +200 -0
- package/lefthook.yml +13 -0
- package/lib/validate_native_exports.d.ts +4 -0
- package/lib/validate_native_exports.js +12 -0
- package/package.json +22 -0
- package/pytest.ini +5 -0
- package/python/tests/test_registry.py +75 -0
- package/python/tests/test_units.py +18 -0
- package/release-please-config.json +49 -0
- package/requirements-dev.txt +3 -0
- package/requirements.txt +3 -0
- package/rust-toolchain.toml +3 -0
- package/schemas/ast-v1.schema.json +72 -0
- package/schemas/ast-v2.schema.json +1200 -0
- package/schemas/ast-v3.schema.json +1200 -0
- package/schemas/sea-registry.schema.json +45 -0
- package/scripts/build-python.sh +37 -0
- package/scripts/build-release.sh +279 -0
- package/scripts/build-typescript.sh +13 -0
- package/scripts/build-wasm.sh +113 -0
- package/scripts/bump-version.sh +245 -0
- package/scripts/check_unused_test_imports.py +85 -0
- package/scripts/ci_tasks.py +379 -0
- package/scripts/clear_debug_test.sh +10 -0
- package/scripts/create-github-release.sh +262 -0
- package/scripts/create-tag.sh +203 -0
- package/scripts/find_and_link_test_binary.sh +70 -0
- package/scripts/generate-changelog.sh +271 -0
- package/scripts/generate-release-notes.sh +205 -0
- package/scripts/lint_release_security.py +96 -0
- package/scripts/lint_release_workflows.py +82 -0
- package/scripts/lint_workflow_gates.py +113 -0
- package/scripts/optimized-wasm-build.sh +61 -0
- package/scripts/patch_napi_types.py +62 -0
- package/scripts/pre-release-check.sh +289 -0
- package/scripts/prepare_rust_debug.sh +52 -0
- package/scripts/release.sh +373 -0
- package/scripts/resolve_rust_binary.py +230 -0
- package/scripts/run_commitlint.sh +29 -0
- package/scripts/test-all.sh +77 -0
- package/scripts/update_launch_program.py +93 -0
- package/secrets/README.md +27 -0
- package/secrets/secrets.yaml +21 -0
- package/test_integration.py +67 -0
- package/tests/test_authority.py +328 -0
- package/tests/test_ci_tasks.py +143 -0
- package/tests/test_expression.py +256 -0
- package/tests/test_golden_payment_flow.py +42 -0
- package/tests/test_graph.py +127 -0
- package/tests/test_instance.py +136 -0
- package/tests/test_parser.py +82 -0
- package/tests/test_primitives.py +68 -0
- package/tests/test_role_relation_parity.py +56 -0
- package/tests/test_runtime_toggle.py +156 -0
- package/tests/test_semantic_pack.py +639 -0
- package/tests/test_three_valued_eval.py +159 -0
- package/tsconfig.json +30 -0
- package/typescript-tests/advanced.test.ts +165 -0
- package/typescript-tests/authority.test.ts +216 -0
- package/typescript-tests/expression.test.ts +228 -0
- package/typescript-tests/golden-payment-flow.test.ts +51 -0
- package/typescript-tests/graph.test.ts +142 -0
- package/typescript-tests/native-binding.test.ts +20 -0
- package/typescript-tests/primitives.test.ts +88 -0
- package/typescript-tests/registry.test.ts +122 -0
- package/typescript-tests/role_relation.test.ts +63 -0
- package/typescript-tests/runtime_toggle.test.ts +141 -0
- package/typescript-tests/semantic-pack.test.ts +556 -0
- package/typescript-tests/three_valued_eval.test.ts +135 -0
- package/typescript-tests/units.test.ts +36 -0
- package/vitest.config.ts +13 -0
- package/wasm_demo.html +225 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
use super::canonical_json;
|
|
2
|
+
use super::diagnostics::{
|
|
3
|
+
DiagnosticSeverity, SemanticDiagnostic, SemanticDiagnosticCode, SemanticTruth,
|
|
4
|
+
SemanticValidationResult, SemanticValidationStatus, ValidationMode, ValidationOptions,
|
|
5
|
+
};
|
|
6
|
+
use super::resolver::{self, ResolveRequest};
|
|
7
|
+
use super::schema::{ConceptStatus, PackRef, PackSetRef, SemanticPack, SignatureState, SourceRef};
|
|
8
|
+
|
|
9
|
+
const CURRENT_SCHEMA_VERSION: &str = "0.3";
|
|
10
|
+
|
|
11
|
+
/// Validate a semantic pack itself (internal consistency).
|
|
12
|
+
pub fn validate_semantic_pack(
|
|
13
|
+
pack: &SemanticPack,
|
|
14
|
+
) -> Result<Vec<SemanticDiagnostic>, SemanticPackError> {
|
|
15
|
+
let mut diagnostics = Vec::new();
|
|
16
|
+
let pack_ref = make_pack_ref(pack);
|
|
17
|
+
|
|
18
|
+
// Schema version check
|
|
19
|
+
if pack.schema_version != CURRENT_SCHEMA_VERSION {
|
|
20
|
+
diagnostics.push(SemanticDiagnostic {
|
|
21
|
+
code: SemanticDiagnosticCode::PackSchemaMismatch,
|
|
22
|
+
severity: DiagnosticSeverity::Error,
|
|
23
|
+
semantic_truth: SemanticTruth::Invalid,
|
|
24
|
+
message: format!(
|
|
25
|
+
"Expected schema_version '{}', got '{}'",
|
|
26
|
+
CURRENT_SCHEMA_VERSION, pack.schema_version
|
|
27
|
+
),
|
|
28
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
29
|
+
pack_ref: pack_ref.clone(),
|
|
30
|
+
suggestions: vec![],
|
|
31
|
+
recoverability_hint: format!("Update schema_version to {}", CURRENT_SCHEMA_VERSION),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Duplicate concept IDs
|
|
36
|
+
let mut seen_ids: std::collections::HashSet<String> = std::collections::HashSet::new();
|
|
37
|
+
for c in &pack.concepts {
|
|
38
|
+
if !seen_ids.insert(c.id.clone()) {
|
|
39
|
+
diagnostics.push(SemanticDiagnostic {
|
|
40
|
+
code: SemanticDiagnosticCode::DuplicateConceptId,
|
|
41
|
+
severity: DiagnosticSeverity::Error,
|
|
42
|
+
semantic_truth: SemanticTruth::Invalid,
|
|
43
|
+
message: format!("Duplicate concept ID: '{}'", c.id),
|
|
44
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
45
|
+
pack_ref: pack_ref.clone(),
|
|
46
|
+
suggestions: vec![],
|
|
47
|
+
recoverability_hint: "Rename one of the duplicate concepts".to_string(),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Duplicate canonical names targeting different IDs
|
|
53
|
+
let mut seen_names: std::collections::HashMap<String, String> =
|
|
54
|
+
std::collections::HashMap::new();
|
|
55
|
+
for c in &pack.concepts {
|
|
56
|
+
let norm = resolver::normalize_lookup_key(&c.canonical_name);
|
|
57
|
+
if let Some(existing_id) = seen_names.get(&norm) {
|
|
58
|
+
if existing_id != &c.id {
|
|
59
|
+
diagnostics.push(SemanticDiagnostic {
|
|
60
|
+
code: SemanticDiagnosticCode::DuplicateCanonicalName,
|
|
61
|
+
severity: DiagnosticSeverity::Error,
|
|
62
|
+
semantic_truth: SemanticTruth::Invalid,
|
|
63
|
+
message: format!(
|
|
64
|
+
"Duplicate canonical name '{}' targets '{}' and '{}'",
|
|
65
|
+
c.canonical_name, existing_id, c.id
|
|
66
|
+
),
|
|
67
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
68
|
+
pack_ref: pack_ref.clone(),
|
|
69
|
+
suggestions: vec![],
|
|
70
|
+
recoverability_hint: "Ensure canonical names are unique".to_string(),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
seen_names.insert(norm, c.id.clone());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Missing definitions on active concepts
|
|
79
|
+
for c in &pack.concepts {
|
|
80
|
+
if matches!(c.status, ConceptStatus::Active | ConceptStatus::Proposed) {
|
|
81
|
+
if c.definition.text.is_empty() {
|
|
82
|
+
diagnostics.push(SemanticDiagnostic {
|
|
83
|
+
code: SemanticDiagnosticCode::MissingDefinition,
|
|
84
|
+
severity: DiagnosticSeverity::Warning,
|
|
85
|
+
semantic_truth: SemanticTruth::Unknown,
|
|
86
|
+
message: format!("Active concept '{}' has no definition", c.id),
|
|
87
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
88
|
+
pack_ref: pack_ref.clone(),
|
|
89
|
+
suggestions: vec![],
|
|
90
|
+
recoverability_hint: "Add a definition text".to_string(),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if c.owner.is_empty() {
|
|
94
|
+
diagnostics.push(SemanticDiagnostic {
|
|
95
|
+
code: SemanticDiagnosticCode::MissingOwner,
|
|
96
|
+
severity: DiagnosticSeverity::Warning,
|
|
97
|
+
semantic_truth: SemanticTruth::Unknown,
|
|
98
|
+
message: format!("Active concept '{}' has no owner", c.id),
|
|
99
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
100
|
+
pack_ref: pack_ref.clone(),
|
|
101
|
+
suggestions: vec![],
|
|
102
|
+
recoverability_hint: "Assign an owner".to_string(),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Alias target validation
|
|
109
|
+
let concept_ids: std::collections::HashSet<&str> =
|
|
110
|
+
pack.concepts.iter().map(|c| c.id.as_str()).collect();
|
|
111
|
+
for a in &pack.aliases {
|
|
112
|
+
if !concept_ids.contains(a.target_concept_id.as_str()) {
|
|
113
|
+
diagnostics.push(SemanticDiagnostic {
|
|
114
|
+
code: SemanticDiagnosticCode::UnknownConcept,
|
|
115
|
+
severity: DiagnosticSeverity::Error,
|
|
116
|
+
semantic_truth: SemanticTruth::Invalid,
|
|
117
|
+
message: format!(
|
|
118
|
+
"Alias '{}' targets unknown concept '{}'",
|
|
119
|
+
a.alias, a.target_concept_id
|
|
120
|
+
),
|
|
121
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
122
|
+
pack_ref: pack_ref.clone(),
|
|
123
|
+
suggestions: vec![],
|
|
124
|
+
recoverability_hint: "Add the target concept or fix the alias".to_string(),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Relation endpoint validation
|
|
130
|
+
for r in &pack.relations {
|
|
131
|
+
if !concept_ids.contains(r.subject_id.as_str()) {
|
|
132
|
+
diagnostics.push(SemanticDiagnostic {
|
|
133
|
+
code: SemanticDiagnosticCode::InvalidRelation,
|
|
134
|
+
severity: DiagnosticSeverity::Error,
|
|
135
|
+
semantic_truth: SemanticTruth::Invalid,
|
|
136
|
+
message: format!(
|
|
137
|
+
"Relation '{}' references unknown subject '{}'",
|
|
138
|
+
r.id, r.subject_id
|
|
139
|
+
),
|
|
140
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
141
|
+
pack_ref: pack_ref.clone(),
|
|
142
|
+
suggestions: vec![],
|
|
143
|
+
recoverability_hint: "Add the missing concept or fix the relation".to_string(),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if !concept_ids.contains(r.object_id.as_str()) {
|
|
147
|
+
diagnostics.push(SemanticDiagnostic {
|
|
148
|
+
code: SemanticDiagnosticCode::InvalidRelation,
|
|
149
|
+
severity: DiagnosticSeverity::Error,
|
|
150
|
+
semantic_truth: SemanticTruth::Invalid,
|
|
151
|
+
message: format!(
|
|
152
|
+
"Relation '{}' references unknown object '{}'",
|
|
153
|
+
r.id, r.object_id
|
|
154
|
+
),
|
|
155
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
156
|
+
pack_ref: pack_ref.clone(),
|
|
157
|
+
suggestions: vec![],
|
|
158
|
+
recoverability_hint: "Add the missing concept or fix the relation".to_string(),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Metric dimension/unit validation
|
|
164
|
+
let dimension_ids: std::collections::HashSet<&str> =
|
|
165
|
+
pack.dimensions.iter().map(|d| d.id.as_str()).collect();
|
|
166
|
+
let unit_ids: std::collections::HashSet<&str> =
|
|
167
|
+
pack.units.iter().map(|u| u.id.as_str()).collect();
|
|
168
|
+
for m in &pack.metrics {
|
|
169
|
+
if let Some(ref dim_id) = m.dimension_id {
|
|
170
|
+
if !dimension_ids.contains(dim_id.as_str()) {
|
|
171
|
+
diagnostics.push(SemanticDiagnostic {
|
|
172
|
+
code: SemanticDiagnosticCode::UnknownDimension,
|
|
173
|
+
severity: DiagnosticSeverity::Warning,
|
|
174
|
+
semantic_truth: SemanticTruth::Unknown,
|
|
175
|
+
message: format!(
|
|
176
|
+
"Metric '{}' references unknown dimension '{}'",
|
|
177
|
+
m.id, dim_id
|
|
178
|
+
),
|
|
179
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
180
|
+
pack_ref: pack_ref.clone(),
|
|
181
|
+
suggestions: vec![],
|
|
182
|
+
recoverability_hint: "Add the missing dimension".to_string(),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if let Some(ref unit_id) = m.unit_id {
|
|
187
|
+
if !unit_ids.contains(unit_id.as_str()) {
|
|
188
|
+
diagnostics.push(SemanticDiagnostic {
|
|
189
|
+
code: SemanticDiagnosticCode::UnknownUnit,
|
|
190
|
+
severity: DiagnosticSeverity::Warning,
|
|
191
|
+
semantic_truth: SemanticTruth::Unknown,
|
|
192
|
+
message: format!("Metric '{}' references unknown unit '{}'", m.id, unit_id),
|
|
193
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
194
|
+
pack_ref: pack_ref.clone(),
|
|
195
|
+
suggestions: vec![],
|
|
196
|
+
recoverability_hint: "Add the missing unit".to_string(),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
Ok(diagnostics)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/// Validate a parsed graph against a semantic pack.
|
|
206
|
+
pub fn validate_graph_with_pack(
|
|
207
|
+
pack: &SemanticPack,
|
|
208
|
+
source_uri: &str,
|
|
209
|
+
options: &ValidationOptions,
|
|
210
|
+
) -> SemanticValidationResult {
|
|
211
|
+
let pack_ref = make_pack_ref(pack);
|
|
212
|
+
|
|
213
|
+
// Check unsigned requirement
|
|
214
|
+
if options.require_signed_pack
|
|
215
|
+
&& pack.trust.signature_state != SignatureState::Signed
|
|
216
|
+
&& !options.allow_unsigned_test_fixtures
|
|
217
|
+
{
|
|
218
|
+
let mut result = empty_result(&pack_ref, options);
|
|
219
|
+
result.status = SemanticValidationStatus::Blocked;
|
|
220
|
+
result.diagnostics.push(SemanticDiagnostic {
|
|
221
|
+
code: SemanticDiagnosticCode::PackUnsigned,
|
|
222
|
+
severity: DiagnosticSeverity::Error,
|
|
223
|
+
semantic_truth: SemanticTruth::Invalid,
|
|
224
|
+
message: format!(
|
|
225
|
+
"Pack '{}' is unsigned but signature is required",
|
|
226
|
+
pack.pack_id
|
|
227
|
+
),
|
|
228
|
+
source_ref: SourceRef::pack_uri(&pack.pack_id),
|
|
229
|
+
pack_ref: pack_ref.clone(),
|
|
230
|
+
suggestions: vec![],
|
|
231
|
+
recoverability_hint: "Sign the pack or use --allow-unsigned-for-test-fixtures"
|
|
232
|
+
.to_string(),
|
|
233
|
+
});
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Run pack self-validation first
|
|
238
|
+
let mut diagnostics = match validate_semantic_pack(pack) {
|
|
239
|
+
Ok(d) => d,
|
|
240
|
+
Err(e) => {
|
|
241
|
+
let mut result = empty_result(&pack_ref, options);
|
|
242
|
+
result.status = SemanticValidationStatus::Failed;
|
|
243
|
+
result.diagnostics.push(SemanticDiagnostic {
|
|
244
|
+
code: SemanticDiagnosticCode::PackSchemaMismatch,
|
|
245
|
+
severity: DiagnosticSeverity::Error,
|
|
246
|
+
semantic_truth: SemanticTruth::Invalid,
|
|
247
|
+
message: format!("Pack self-validation failed: {:?}", e),
|
|
248
|
+
source_ref: SourceRef::synthetic("internal"),
|
|
249
|
+
pack_ref: pack_ref.clone(),
|
|
250
|
+
suggestions: vec![],
|
|
251
|
+
recoverability_hint: "Check pack structure and retry".to_string(),
|
|
252
|
+
});
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// Sort diagnostics deterministically
|
|
258
|
+
super::canonical_json::sort_diagnostics(&mut diagnostics);
|
|
259
|
+
|
|
260
|
+
// Compute status per §4.7
|
|
261
|
+
let status = compute_status(&diagnostics, options);
|
|
262
|
+
|
|
263
|
+
SemanticValidationResult {
|
|
264
|
+
status,
|
|
265
|
+
diagnostics,
|
|
266
|
+
pack_set_ref: PackSetRef {
|
|
267
|
+
merged_pack_hash: pack_ref.pack_content_hash.clone(),
|
|
268
|
+
pack_refs: vec![pack_ref.clone()],
|
|
269
|
+
},
|
|
270
|
+
input_hash: canonical_json::hash_canonical_json(&serde_json::json!({
|
|
271
|
+
"source_uri": source_uri,
|
|
272
|
+
"pack_id": pack.pack_id,
|
|
273
|
+
})),
|
|
274
|
+
validation_mode: options.mode,
|
|
275
|
+
expected_hashes: vec![],
|
|
276
|
+
unsigned_fixture_bypass_used: options.allow_unsigned_test_fixtures,
|
|
277
|
+
first_approved_version_bypass_used: false,
|
|
278
|
+
evidence_ref: None,
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/// Validate a specific term against a pack (resolver-backed).
|
|
283
|
+
pub fn validate_term(
|
|
284
|
+
raw_text: &str,
|
|
285
|
+
pack: &SemanticPack,
|
|
286
|
+
options: &ValidationOptions,
|
|
287
|
+
source_ref: SourceRef,
|
|
288
|
+
) -> Option<SemanticDiagnostic> {
|
|
289
|
+
let request = ResolveRequest {
|
|
290
|
+
raw_text,
|
|
291
|
+
expected_kind: None,
|
|
292
|
+
source_ref: source_ref.clone(),
|
|
293
|
+
};
|
|
294
|
+
let result = resolver::resolve_concept(&request, pack, options);
|
|
295
|
+
|
|
296
|
+
if let Some(code) = result.diagnostic_code {
|
|
297
|
+
let pack_ref = make_pack_ref(pack);
|
|
298
|
+
Some(SemanticDiagnostic {
|
|
299
|
+
code,
|
|
300
|
+
severity: result.diagnostic_severity,
|
|
301
|
+
semantic_truth: result.semantic_truth,
|
|
302
|
+
message: result.message,
|
|
303
|
+
source_ref,
|
|
304
|
+
pack_ref,
|
|
305
|
+
suggestions: result.suggestions,
|
|
306
|
+
recoverability_hint: String::new(),
|
|
307
|
+
})
|
|
308
|
+
} else {
|
|
309
|
+
None
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
fn compute_status(
|
|
314
|
+
diagnostics: &[SemanticDiagnostic],
|
|
315
|
+
options: &ValidationOptions,
|
|
316
|
+
) -> SemanticValidationStatus {
|
|
317
|
+
if matches!(options.mode, ValidationMode::Off) {
|
|
318
|
+
return SemanticValidationStatus::Passed;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
let has_blocking_error = diagnostics
|
|
322
|
+
.iter()
|
|
323
|
+
.any(|d| d.severity == DiagnosticSeverity::Error);
|
|
324
|
+
let has_unknown = diagnostics
|
|
325
|
+
.iter()
|
|
326
|
+
.any(|d| d.semantic_truth == SemanticTruth::Unknown);
|
|
327
|
+
|
|
328
|
+
if has_blocking_error || (matches!(options.mode, ValidationMode::Strict) && has_unknown) {
|
|
329
|
+
SemanticValidationStatus::Failed
|
|
330
|
+
} else if has_unknown {
|
|
331
|
+
SemanticValidationStatus::Unknown
|
|
332
|
+
} else {
|
|
333
|
+
SemanticValidationStatus::Passed
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
fn make_pack_ref(pack: &SemanticPack) -> PackRef {
|
|
338
|
+
PackRef {
|
|
339
|
+
pack_id: pack.pack_id.clone(),
|
|
340
|
+
pack_content_hash: canonical_json::compute_pack_content_hash(pack),
|
|
341
|
+
path_or_uri: format!("pack://{}", pack.pack_id),
|
|
342
|
+
priority: 0,
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
fn empty_result(pack_ref: &PackRef, options: &ValidationOptions) -> SemanticValidationResult {
|
|
347
|
+
SemanticValidationResult {
|
|
348
|
+
status: SemanticValidationStatus::Passed,
|
|
349
|
+
diagnostics: vec![],
|
|
350
|
+
pack_set_ref: PackSetRef {
|
|
351
|
+
merged_pack_hash: pack_ref.pack_content_hash.clone(),
|
|
352
|
+
pack_refs: vec![pack_ref.clone()],
|
|
353
|
+
},
|
|
354
|
+
input_hash: String::new(),
|
|
355
|
+
validation_mode: options.mode,
|
|
356
|
+
expected_hashes: vec![],
|
|
357
|
+
unsigned_fixture_bypass_used: false,
|
|
358
|
+
first_approved_version_bypass_used: false,
|
|
359
|
+
evidence_ref: None,
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
#[derive(Debug, Clone)]
|
|
364
|
+
pub enum SemanticPackError {
|
|
365
|
+
IoError(String),
|
|
366
|
+
JsonError(String),
|
|
367
|
+
ValidationError(String),
|
|
368
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
use serde::{Deserialize, Serialize};
|
|
2
|
+
|
|
3
|
+
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
|
4
|
+
pub struct SemanticVersion {
|
|
5
|
+
pub major: u32,
|
|
6
|
+
pub minor: u32,
|
|
7
|
+
pub patch: u32,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
impl SemanticVersion {
|
|
11
|
+
pub fn new(major: u32, minor: u32, patch: u32) -> Self {
|
|
12
|
+
Self {
|
|
13
|
+
major,
|
|
14
|
+
minor,
|
|
15
|
+
patch,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pub fn parse(s: &str) -> Result<Self, String> {
|
|
20
|
+
let parts: Vec<&str> = s.split('.').collect();
|
|
21
|
+
if parts.len() != 3 {
|
|
22
|
+
return Err("Version must be in format major.minor.patch".to_string());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Ok(Self {
|
|
26
|
+
major: parts[0]
|
|
27
|
+
.parse()
|
|
28
|
+
.map_err(|_| "Invalid major version".to_string())?,
|
|
29
|
+
minor: parts[1]
|
|
30
|
+
.parse()
|
|
31
|
+
.map_err(|_| "Invalid minor version".to_string())?,
|
|
32
|
+
patch: parts[2]
|
|
33
|
+
.parse()
|
|
34
|
+
.map_err(|_| "Invalid patch version".to_string())?,
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
pub fn bump_major(&mut self) {
|
|
39
|
+
self.major += 1;
|
|
40
|
+
self.minor = 0;
|
|
41
|
+
self.patch = 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
pub fn bump_minor(&mut self) {
|
|
45
|
+
self.minor += 1;
|
|
46
|
+
self.patch = 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
pub fn bump_patch(&mut self) {
|
|
50
|
+
self.patch += 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
impl std::fmt::Display for SemanticVersion {
|
|
55
|
+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
56
|
+
write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
impl Default for SemanticVersion {
|
|
61
|
+
fn default() -> Self {
|
|
62
|
+
Self::new(1, 0, 0)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#[cfg(test)]
|
|
67
|
+
mod tests {
|
|
68
|
+
use super::*;
|
|
69
|
+
|
|
70
|
+
#[test]
|
|
71
|
+
fn test_semantic_version_parsing() {
|
|
72
|
+
let v = SemanticVersion::parse("1.2.3").unwrap();
|
|
73
|
+
assert_eq!(v.major, 1);
|
|
74
|
+
assert_eq!(v.minor, 2);
|
|
75
|
+
assert_eq!(v.patch, 3);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#[test]
|
|
79
|
+
fn test_semantic_version_parsing_invalid() {
|
|
80
|
+
assert!(SemanticVersion::parse("1.2").is_err());
|
|
81
|
+
assert!(SemanticVersion::parse("1.2.3.4").is_err());
|
|
82
|
+
assert!(SemanticVersion::parse("a.b.c").is_err());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#[test]
|
|
86
|
+
fn test_version_comparison() {
|
|
87
|
+
let v1 = SemanticVersion::new(1, 0, 0);
|
|
88
|
+
let v2 = SemanticVersion::new(2, 0, 0);
|
|
89
|
+
assert!(v1 < v2);
|
|
90
|
+
|
|
91
|
+
let v3 = SemanticVersion::new(1, 2, 0);
|
|
92
|
+
let v4 = SemanticVersion::new(1, 1, 0);
|
|
93
|
+
assert!(v3 > v4);
|
|
94
|
+
|
|
95
|
+
let v5 = SemanticVersion::new(1, 1, 2);
|
|
96
|
+
let v6 = SemanticVersion::new(1, 1, 1);
|
|
97
|
+
assert!(v5 > v6);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#[test]
|
|
101
|
+
fn test_version_bump_major() {
|
|
102
|
+
let mut v = SemanticVersion::new(1, 2, 3);
|
|
103
|
+
v.bump_major();
|
|
104
|
+
assert_eq!(v, SemanticVersion::new(2, 0, 0));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#[test]
|
|
108
|
+
fn test_version_bump_minor() {
|
|
109
|
+
let mut v = SemanticVersion::new(1, 2, 3);
|
|
110
|
+
v.bump_minor();
|
|
111
|
+
assert_eq!(v, SemanticVersion::new(1, 3, 0));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#[test]
|
|
115
|
+
fn test_version_bump_patch() {
|
|
116
|
+
let mut v = SemanticVersion::new(1, 2, 3);
|
|
117
|
+
v.bump_patch();
|
|
118
|
+
assert_eq!(v, SemanticVersion::new(1, 2, 4));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#[test]
|
|
122
|
+
fn test_version_display() {
|
|
123
|
+
let v = SemanticVersion::new(1, 2, 3);
|
|
124
|
+
assert_eq!(format!("{}", v), "1.2.3");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#[test]
|
|
128
|
+
fn test_version_default() {
|
|
129
|
+
let v = SemanticVersion::default();
|
|
130
|
+
assert_eq!(v, SemanticVersion::new(1, 0, 0));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#[test]
|
|
134
|
+
fn test_version_serialization() {
|
|
135
|
+
let v = SemanticVersion::new(1, 2, 3);
|
|
136
|
+
let json = serde_json::to_string(&v).unwrap();
|
|
137
|
+
let deserialized: SemanticVersion = serde_json::from_str(&json).unwrap();
|
|
138
|
+
assert_eq!(v, deserialized);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
use crate::authority::{
|
|
2
|
+
AuthorityEnvironment as RustAuthorityEnvironment,
|
|
3
|
+
AuthorityEnvironmentConfig as RustAuthorityEnvironmentConfig, ClaimLevel as RustClaimLevel,
|
|
4
|
+
FactEnvelope as RustFactEnvelope, FinalDecision as RustFinalDecision,
|
|
5
|
+
PolicyModality as RustPolicyModality, SourceClass as RustSourceClass,
|
|
6
|
+
};
|
|
7
|
+
use napi_derive::napi;
|
|
8
|
+
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Enums
|
|
11
|
+
// =============================================================================
|
|
12
|
+
|
|
13
|
+
#[napi]
|
|
14
|
+
pub enum FinalDecision {
|
|
15
|
+
Allow,
|
|
16
|
+
Deny,
|
|
17
|
+
Escalate,
|
|
18
|
+
NotApplicable,
|
|
19
|
+
Reject,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
impl From<FinalDecision> for RustFinalDecision {
|
|
23
|
+
fn from(v: FinalDecision) -> Self {
|
|
24
|
+
match v {
|
|
25
|
+
FinalDecision::Allow => RustFinalDecision::Allow,
|
|
26
|
+
FinalDecision::Deny => RustFinalDecision::Deny,
|
|
27
|
+
FinalDecision::Escalate => RustFinalDecision::Escalate,
|
|
28
|
+
FinalDecision::NotApplicable => RustFinalDecision::NotApplicable,
|
|
29
|
+
FinalDecision::Reject => RustFinalDecision::Reject,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
impl From<RustFinalDecision> for FinalDecision {
|
|
35
|
+
fn from(v: RustFinalDecision) -> Self {
|
|
36
|
+
match v {
|
|
37
|
+
RustFinalDecision::Allow => FinalDecision::Allow,
|
|
38
|
+
RustFinalDecision::Deny => FinalDecision::Deny,
|
|
39
|
+
RustFinalDecision::Escalate => FinalDecision::Escalate,
|
|
40
|
+
RustFinalDecision::NotApplicable => FinalDecision::NotApplicable,
|
|
41
|
+
RustFinalDecision::Reject => FinalDecision::Reject,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#[napi]
|
|
47
|
+
pub enum PolicyModality {
|
|
48
|
+
Permission,
|
|
49
|
+
Prohibition,
|
|
50
|
+
Obligation,
|
|
51
|
+
Override,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
impl From<PolicyModality> for RustPolicyModality {
|
|
55
|
+
fn from(v: PolicyModality) -> Self {
|
|
56
|
+
match v {
|
|
57
|
+
PolicyModality::Permission => RustPolicyModality::Permission,
|
|
58
|
+
PolicyModality::Prohibition => RustPolicyModality::Prohibition,
|
|
59
|
+
PolicyModality::Obligation => RustPolicyModality::Obligation,
|
|
60
|
+
PolicyModality::Override => RustPolicyModality::Override,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
impl From<RustPolicyModality> for PolicyModality {
|
|
66
|
+
fn from(v: RustPolicyModality) -> Self {
|
|
67
|
+
match v {
|
|
68
|
+
RustPolicyModality::Permission => PolicyModality::Permission,
|
|
69
|
+
RustPolicyModality::Prohibition => PolicyModality::Prohibition,
|
|
70
|
+
RustPolicyModality::Obligation => PolicyModality::Obligation,
|
|
71
|
+
RustPolicyModality::Override => PolicyModality::Override,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#[napi]
|
|
77
|
+
pub enum SourceClass {
|
|
78
|
+
CallerSupplied,
|
|
79
|
+
RuntimeObserved,
|
|
80
|
+
SystemOfRecord,
|
|
81
|
+
Attested,
|
|
82
|
+
ManualApproval,
|
|
83
|
+
Derived,
|
|
84
|
+
UnknownSource,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
impl From<SourceClass> for RustSourceClass {
|
|
88
|
+
fn from(v: SourceClass) -> Self {
|
|
89
|
+
match v {
|
|
90
|
+
SourceClass::CallerSupplied => RustSourceClass::CallerSupplied,
|
|
91
|
+
SourceClass::RuntimeObserved => RustSourceClass::RuntimeObserved,
|
|
92
|
+
SourceClass::SystemOfRecord => RustSourceClass::SystemOfRecord,
|
|
93
|
+
SourceClass::Attested => RustSourceClass::Attested,
|
|
94
|
+
SourceClass::ManualApproval => RustSourceClass::ManualApproval,
|
|
95
|
+
SourceClass::Derived => RustSourceClass::Derived,
|
|
96
|
+
SourceClass::UnknownSource => RustSourceClass::UnknownSource,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
impl From<RustSourceClass> for SourceClass {
|
|
102
|
+
fn from(v: RustSourceClass) -> Self {
|
|
103
|
+
match v {
|
|
104
|
+
RustSourceClass::CallerSupplied => SourceClass::CallerSupplied,
|
|
105
|
+
RustSourceClass::RuntimeObserved => SourceClass::RuntimeObserved,
|
|
106
|
+
RustSourceClass::SystemOfRecord => SourceClass::SystemOfRecord,
|
|
107
|
+
RustSourceClass::Attested => SourceClass::Attested,
|
|
108
|
+
RustSourceClass::ManualApproval => SourceClass::ManualApproval,
|
|
109
|
+
RustSourceClass::Derived => SourceClass::Derived,
|
|
110
|
+
RustSourceClass::UnknownSource => SourceClass::UnknownSource,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#[napi]
|
|
116
|
+
pub enum ClaimLevel {
|
|
117
|
+
AuditBacked,
|
|
118
|
+
Validated,
|
|
119
|
+
FormallyProven,
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
impl From<ClaimLevel> for RustClaimLevel {
|
|
123
|
+
fn from(v: ClaimLevel) -> Self {
|
|
124
|
+
match v {
|
|
125
|
+
ClaimLevel::AuditBacked => RustClaimLevel::AuditBacked,
|
|
126
|
+
ClaimLevel::Validated => RustClaimLevel::Validated,
|
|
127
|
+
ClaimLevel::FormallyProven => RustClaimLevel::FormallyProven,
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
impl From<RustClaimLevel> for ClaimLevel {
|
|
133
|
+
fn from(v: RustClaimLevel) -> Self {
|
|
134
|
+
match v {
|
|
135
|
+
RustClaimLevel::AuditBacked => ClaimLevel::AuditBacked,
|
|
136
|
+
RustClaimLevel::Validated => ClaimLevel::Validated,
|
|
137
|
+
RustClaimLevel::FormallyProven => ClaimLevel::FormallyProven,
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// =============================================================================
|
|
143
|
+
// Functions
|
|
144
|
+
// =============================================================================
|
|
145
|
+
|
|
146
|
+
/// Evaluate an authority request against a policy environment.
|
|
147
|
+
#[napi]
|
|
148
|
+
pub fn evaluate_authority(
|
|
149
|
+
config_json: String,
|
|
150
|
+
request_json: String,
|
|
151
|
+
facts_json: Option<String>,
|
|
152
|
+
) -> napi::Result<EvaluateAuthorityResult> {
|
|
153
|
+
let facts = facts_json.unwrap_or_else(|| "[]".to_string());
|
|
154
|
+
|
|
155
|
+
let config: RustAuthorityEnvironmentConfig = serde_json::from_str(&config_json)
|
|
156
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid config: {}", e)))?;
|
|
157
|
+
let mut env = RustAuthorityEnvironment::new(config)
|
|
158
|
+
.map_err(|e| napi::Error::from_reason(format!("Environment error: {}", e)))?;
|
|
159
|
+
env.validate()
|
|
160
|
+
.map_err(|e| napi::Error::from_reason(format!("Validation error: {}", e)))?;
|
|
161
|
+
|
|
162
|
+
let request: crate::authority::AuthorityRequest = serde_json::from_str(&request_json)
|
|
163
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid request: {}", e)))?;
|
|
164
|
+
let fact_envs: Vec<RustFactEnvelope> = serde_json::from_str(&facts)
|
|
165
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid facts: {}", e)))?;
|
|
166
|
+
|
|
167
|
+
let (trace, decision) = env
|
|
168
|
+
.evaluate(&request, &fact_envs)
|
|
169
|
+
.map_err(|e| napi::Error::from_reason(format!("Evaluation error: {}", e)))?;
|
|
170
|
+
|
|
171
|
+
Ok(EvaluateAuthorityResult {
|
|
172
|
+
trace_json: serde_json::to_string(&trace)
|
|
173
|
+
.map_err(|e| napi::Error::from_reason(format!("Trace serialization error: {}", e)))?,
|
|
174
|
+
decision_json: serde_json::to_string(&decision).map_err(|e| {
|
|
175
|
+
napi::Error::from_reason(format!("Decision serialization error: {}", e))
|
|
176
|
+
})?,
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#[napi(object)]
|
|
181
|
+
pub struct EvaluateAuthorityResult {
|
|
182
|
+
pub trace_json: String,
|
|
183
|
+
pub decision_json: String,
|
|
184
|
+
}
|