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,199 @@
|
|
|
1
|
+
//! Protobuf projection integration tests
|
|
2
|
+
//!
|
|
3
|
+
//! Tests the full pipeline: parse SEA -> Graph -> ProtoFile -> .proto text
|
|
4
|
+
|
|
5
|
+
use domainforge_core::parser::ast::ast_to_graph;
|
|
6
|
+
use domainforge_core::parser::parse_source;
|
|
7
|
+
use domainforge_core::projection::protobuf::ProtobufEngine;
|
|
8
|
+
|
|
9
|
+
#[test]
|
|
10
|
+
fn test_parse_entity_to_protobuf() {
|
|
11
|
+
let source = r#"
|
|
12
|
+
Entity "Customer"
|
|
13
|
+
Entity "Order"
|
|
14
|
+
Entity "Product"
|
|
15
|
+
"#;
|
|
16
|
+
|
|
17
|
+
let ast = parse_source(source).expect("Failed to parse");
|
|
18
|
+
let graph = ast_to_graph(ast).expect("Failed to build graph");
|
|
19
|
+
|
|
20
|
+
let proto = ProtobufEngine::project(&graph, "", "test.package");
|
|
21
|
+
|
|
22
|
+
assert_eq!(proto.package, "test.package");
|
|
23
|
+
assert_eq!(proto.messages.len(), 3);
|
|
24
|
+
|
|
25
|
+
// Messages should be sorted alphabetically
|
|
26
|
+
assert_eq!(proto.messages[0].name, "Customer");
|
|
27
|
+
assert_eq!(proto.messages[1].name, "Order");
|
|
28
|
+
assert_eq!(proto.messages[2].name, "Product");
|
|
29
|
+
|
|
30
|
+
// Each message should have id and name fields
|
|
31
|
+
for msg in &proto.messages {
|
|
32
|
+
assert!(msg.fields.iter().any(|f| f.name == "id"));
|
|
33
|
+
assert!(msg.fields.iter().any(|f| f.name == "name"));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[test]
|
|
38
|
+
fn test_parse_resource_to_protobuf() {
|
|
39
|
+
let source = r#"
|
|
40
|
+
Resource "Money" USD
|
|
41
|
+
Resource "Inventory" units
|
|
42
|
+
"#;
|
|
43
|
+
|
|
44
|
+
let ast = parse_source(source).expect("Failed to parse");
|
|
45
|
+
let graph = ast_to_graph(ast).expect("Failed to build graph");
|
|
46
|
+
|
|
47
|
+
let proto = ProtobufEngine::project(&graph, "", "resources.package");
|
|
48
|
+
|
|
49
|
+
assert_eq!(proto.messages.len(), 2);
|
|
50
|
+
|
|
51
|
+
// Each resource message should have id, name, quantity, unit fields
|
|
52
|
+
for msg in &proto.messages {
|
|
53
|
+
let field_names: Vec<&str> = msg.fields.iter().map(|f| f.name.as_str()).collect();
|
|
54
|
+
assert!(field_names.contains(&"id"));
|
|
55
|
+
assert!(field_names.contains(&"name"));
|
|
56
|
+
assert!(field_names.contains(&"quantity"));
|
|
57
|
+
assert!(field_names.contains(&"unit"));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#[test]
|
|
62
|
+
fn test_namespace_filtering() {
|
|
63
|
+
let source = r#"
|
|
64
|
+
@namespace "logistics"
|
|
65
|
+
Entity "Warehouse"
|
|
66
|
+
Entity "Vehicle"
|
|
67
|
+
"#;
|
|
68
|
+
|
|
69
|
+
let ast = parse_source(source).expect("Failed to parse");
|
|
70
|
+
let graph = ast_to_graph(ast).expect("Failed to build graph");
|
|
71
|
+
|
|
72
|
+
// Filter by logistics namespace
|
|
73
|
+
let proto = ProtobufEngine::project(&graph, "logistics", "logistics.package");
|
|
74
|
+
assert_eq!(proto.messages.len(), 2);
|
|
75
|
+
|
|
76
|
+
// Filter by non-existent namespace
|
|
77
|
+
let proto_empty = ProtobufEngine::project(&graph, "finance", "finance.package");
|
|
78
|
+
assert_eq!(proto_empty.messages.len(), 0);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#[test]
|
|
82
|
+
fn test_protobuf_text_output() {
|
|
83
|
+
let source = r#"
|
|
84
|
+
Entity "PaymentProcessor"
|
|
85
|
+
"#;
|
|
86
|
+
|
|
87
|
+
let ast = parse_source(source).expect("Failed to parse");
|
|
88
|
+
let graph = ast_to_graph(ast).expect("Failed to build graph");
|
|
89
|
+
|
|
90
|
+
let proto = ProtobufEngine::project(&graph, "", "payments");
|
|
91
|
+
let proto_text = proto.to_proto_string();
|
|
92
|
+
|
|
93
|
+
// Check essential proto3 elements
|
|
94
|
+
assert!(proto_text.contains("syntax = \"proto3\";"));
|
|
95
|
+
assert!(proto_text.contains("package payments;"));
|
|
96
|
+
assert!(proto_text.contains("message PaymentProcessor {"));
|
|
97
|
+
assert!(proto_text.contains("string id = 1;"));
|
|
98
|
+
assert!(proto_text.contains("string name = 2;"));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#[test]
|
|
102
|
+
fn test_governance_messages() {
|
|
103
|
+
let source = r#"
|
|
104
|
+
Entity "TestEntity"
|
|
105
|
+
"#;
|
|
106
|
+
|
|
107
|
+
let ast = parse_source(source).expect("Failed to parse");
|
|
108
|
+
let graph = ast_to_graph(ast).expect("Failed to build graph");
|
|
109
|
+
|
|
110
|
+
let proto = ProtobufEngine::project_with_options(
|
|
111
|
+
&graph,
|
|
112
|
+
"",
|
|
113
|
+
"governance.test",
|
|
114
|
+
"GovernanceProjection",
|
|
115
|
+
true,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Should have entity + 2 governance messages
|
|
119
|
+
assert_eq!(proto.messages.len(), 3);
|
|
120
|
+
|
|
121
|
+
let message_names: Vec<&str> = proto.messages.iter().map(|m| m.name.as_str()).collect();
|
|
122
|
+
assert!(message_names.contains(&"PolicyViolation"));
|
|
123
|
+
assert!(message_names.contains(&"MetricEvent"));
|
|
124
|
+
assert!(message_names.contains(&"TestEntity"));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#[test]
|
|
128
|
+
fn test_protobuf_projection_declaration() {
|
|
129
|
+
let source = r#"
|
|
130
|
+
Entity "Vendor"
|
|
131
|
+
|
|
132
|
+
Projection "vendor_proto" for protobuf {
|
|
133
|
+
Entity "Vendor" {
|
|
134
|
+
package: "vendor.api"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
"#;
|
|
138
|
+
|
|
139
|
+
let ast = parse_source(source).expect("Failed to parse");
|
|
140
|
+
let graph = ast_to_graph(ast).expect("Failed to build graph");
|
|
141
|
+
|
|
142
|
+
// Verify the projection was parsed
|
|
143
|
+
assert_eq!(graph.projection_count(), 1);
|
|
144
|
+
|
|
145
|
+
// Project to protobuf
|
|
146
|
+
let proto = ProtobufEngine::project(&graph, "", "vendor.api");
|
|
147
|
+
assert_eq!(proto.messages.len(), 1);
|
|
148
|
+
assert_eq!(proto.messages[0].name, "Vendor");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#[test]
|
|
152
|
+
fn test_deterministic_field_ordering() {
|
|
153
|
+
let source = r#"
|
|
154
|
+
Entity "Customer"
|
|
155
|
+
Entity "Order"
|
|
156
|
+
"#;
|
|
157
|
+
|
|
158
|
+
let ast1 = parse_source(source).expect("Failed to parse");
|
|
159
|
+
let graph1 = ast_to_graph(ast1).expect("Failed to build graph");
|
|
160
|
+
let proto1 = ProtobufEngine::project(&graph1, "", "test");
|
|
161
|
+
|
|
162
|
+
let ast2 = parse_source(source).expect("Failed to parse");
|
|
163
|
+
let graph2 = ast_to_graph(ast2).expect("Failed to build graph");
|
|
164
|
+
let proto2 = ProtobufEngine::project(&graph2, "", "test");
|
|
165
|
+
|
|
166
|
+
// Messages should be identical (same count, same names, same fields)
|
|
167
|
+
assert_eq!(proto1.messages.len(), proto2.messages.len());
|
|
168
|
+
|
|
169
|
+
for (m1, m2) in proto1.messages.iter().zip(proto2.messages.iter()) {
|
|
170
|
+
assert_eq!(m1.name, m2.name);
|
|
171
|
+
assert_eq!(m1.fields.len(), m2.fields.len());
|
|
172
|
+
|
|
173
|
+
for (f1, f2) in m1.fields.iter().zip(m2.fields.iter()) {
|
|
174
|
+
assert_eq!(f1.name, f2.name);
|
|
175
|
+
assert_eq!(f1.number, f2.number);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#[test]
|
|
181
|
+
fn test_proto_options() {
|
|
182
|
+
let source = r#"
|
|
183
|
+
Entity "Example"
|
|
184
|
+
"#;
|
|
185
|
+
|
|
186
|
+
let ast = parse_source(source).expect("Failed to parse");
|
|
187
|
+
let graph = ast_to_graph(ast).expect("Failed to build graph");
|
|
188
|
+
|
|
189
|
+
let mut proto = ProtobufEngine::project(&graph, "", "com.example");
|
|
190
|
+
proto.options.java_package = Some("com.example.proto".to_string());
|
|
191
|
+
proto.options.java_multiple_files = true;
|
|
192
|
+
proto.options.go_package = Some("github.com/example/proto".to_string());
|
|
193
|
+
|
|
194
|
+
let proto_text = proto.to_proto_string();
|
|
195
|
+
|
|
196
|
+
assert!(proto_text.contains("option java_package = \"com.example.proto\";"));
|
|
197
|
+
assert!(proto_text.contains("option java_multiple_files = true;"));
|
|
198
|
+
assert!(proto_text.contains("option go_package = \"github.com/example/proto\";"));
|
|
199
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#[cfg(feature = "formatting")]
|
|
2
|
+
use domainforge_core::primitives::quantity::QuantityFormatter;
|
|
3
|
+
use domainforge_core::primitives::Quantity;
|
|
4
|
+
use domainforge_core::units::Dimension;
|
|
5
|
+
#[cfg(feature = "formatting")]
|
|
6
|
+
use icu_locid::locale;
|
|
7
|
+
|
|
8
|
+
#[cfg(feature = "formatting")]
|
|
9
|
+
#[test]
|
|
10
|
+
fn test_quantity_formatting_en_us() {
|
|
11
|
+
let quantity = Quantity::new(1500.0, "USD".to_string(), Dimension::Currency).unwrap();
|
|
12
|
+
let formatter = QuantityFormatter::new(locale!("en-US"));
|
|
13
|
+
assert_eq!(formatter.format(&quantity).unwrap(), "1,500 \"USD\"");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#[cfg(feature = "formatting")]
|
|
17
|
+
#[test]
|
|
18
|
+
fn test_quantity_formatting_de_de() {
|
|
19
|
+
let quantity = Quantity::new(1500.0, "EUR".to_string(), Dimension::Currency).unwrap();
|
|
20
|
+
let formatter = QuantityFormatter::new(locale!("de-DE"));
|
|
21
|
+
assert_eq!(formatter.format(&quantity).unwrap(), "1.500 \"EUR\"");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#[cfg(feature = "formatting")]
|
|
25
|
+
#[test]
|
|
26
|
+
fn test_quantity_formatting_fr_fr() {
|
|
27
|
+
let quantity = Quantity::new(1500.0, "EUR".to_string(), Dimension::Currency).unwrap();
|
|
28
|
+
let formatter = QuantityFormatter::new(locale!("fr-FR"));
|
|
29
|
+
// ICU might use narrow non-breaking space or space depending on version/data
|
|
30
|
+
// We'll check if it contains the number formatted correctly
|
|
31
|
+
let formatted = formatter.format(&quantity).unwrap();
|
|
32
|
+
assert!(formatted.contains("1") && formatted.contains("500"));
|
|
33
|
+
assert!(formatted.contains("\"EUR\""));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#[test]
|
|
37
|
+
fn test_quantity_validation() {
|
|
38
|
+
assert!(Quantity::new(f64::NAN, "USD".to_string(), Dimension::Currency).is_err());
|
|
39
|
+
assert!(Quantity::new(f64::INFINITY, "USD".to_string(), Dimension::Currency).is_err());
|
|
40
|
+
assert!(Quantity::new(f64::NEG_INFINITY, "USD".to_string(), Dimension::Currency).is_err());
|
|
41
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#[cfg(test)]
|
|
2
|
+
mod rdf_xml_typed_literal_tests {
|
|
3
|
+
use domainforge_core::primitives::{Entity, Flow, Resource};
|
|
4
|
+
use domainforge_core::{
|
|
5
|
+
kg::{KnowledgeGraph, Triple},
|
|
6
|
+
unit_from_string, Graph,
|
|
7
|
+
};
|
|
8
|
+
use roxmltree::Document;
|
|
9
|
+
use rust_decimal::Decimal;
|
|
10
|
+
|
|
11
|
+
#[test]
|
|
12
|
+
fn test_decimal_datatype_preserved() {
|
|
13
|
+
let mut graph = Graph::new();
|
|
14
|
+
|
|
15
|
+
let supplier = Entity::new_with_namespace("Supplier", "default".to_string());
|
|
16
|
+
let manufacturer = Entity::new_with_namespace("Manufacturer", "default".to_string());
|
|
17
|
+
let money =
|
|
18
|
+
Resource::new_with_namespace("Money", unit_from_string("USD"), "default".to_string());
|
|
19
|
+
|
|
20
|
+
let supplier_id = supplier.id().clone();
|
|
21
|
+
let manufacturer_id = manufacturer.id().clone();
|
|
22
|
+
let money_id = money.id().clone();
|
|
23
|
+
|
|
24
|
+
graph.add_entity(supplier).unwrap();
|
|
25
|
+
graph.add_entity(manufacturer).unwrap();
|
|
26
|
+
graph.add_resource(money).unwrap();
|
|
27
|
+
|
|
28
|
+
let flow = Flow::new_with_namespace(
|
|
29
|
+
money_id,
|
|
30
|
+
supplier_id,
|
|
31
|
+
manufacturer_id,
|
|
32
|
+
Decimal::new(2500, 2),
|
|
33
|
+
"default",
|
|
34
|
+
);
|
|
35
|
+
graph.add_flow(flow).unwrap();
|
|
36
|
+
|
|
37
|
+
let kg = KnowledgeGraph::from_graph(&graph).unwrap();
|
|
38
|
+
let rdf_xml = kg.to_rdf_xml();
|
|
39
|
+
|
|
40
|
+
assert!(
|
|
41
|
+
rdf_xml.contains("rdf:datatype=\"http://www.w3.org/2001/XMLSchema#decimal\"")
|
|
42
|
+
|| rdf_xml.contains("rdf:datatype=\"http://domainforge.ai/xsd#decimal\"")
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#[test]
|
|
47
|
+
fn test_language_tag_preserved() {
|
|
48
|
+
let mut kg = KnowledgeGraph::new();
|
|
49
|
+
kg.triples.push(Triple {
|
|
50
|
+
subject: "sea:TestEntity".to_string(),
|
|
51
|
+
predicate: "rdfs:label".to_string(),
|
|
52
|
+
object: "\"Warehouse\"@en".to_string(),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
let rdf_xml = kg.to_rdf_xml();
|
|
56
|
+
|
|
57
|
+
let doc = Document::parse(&rdf_xml).expect("Failed to parse RDF/XML");
|
|
58
|
+
let label_node = doc
|
|
59
|
+
.descendants()
|
|
60
|
+
.find(|node| {
|
|
61
|
+
node.is_element()
|
|
62
|
+
&& node.tag_name().name() == "label"
|
|
63
|
+
&& node.tag_name().namespace() == Some("http://www.w3.org/2000/01/rdf-schema#")
|
|
64
|
+
})
|
|
65
|
+
.expect("Missing rdfs:label element");
|
|
66
|
+
|
|
67
|
+
assert_eq!(label_node.text(), Some("Warehouse"));
|
|
68
|
+
// Use namespace-aware attribute lookup: roxmltree allows checking attributes by
|
|
69
|
+
// expanded name (namespace URI, local name). The `xml:lang` attribute lives in
|
|
70
|
+
// the XML namespace "http://www.w3.org/XML/1998/namespace".
|
|
71
|
+
assert_eq!(
|
|
72
|
+
label_node.attribute(("http://www.w3.org/XML/1998/namespace", "lang")),
|
|
73
|
+
Some("en")
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#[test]
|
|
78
|
+
fn test_escaped_literal_in_xml() {
|
|
79
|
+
let mut graph = Graph::new();
|
|
80
|
+
let warehouse = Entity::new_with_namespace("Warehouse", "default".to_string());
|
|
81
|
+
let resource = Resource::new_with_namespace(
|
|
82
|
+
"Resource<With>&Special\"'Chars",
|
|
83
|
+
unit_from_string("units"),
|
|
84
|
+
"default".to_string(),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
graph.add_entity(warehouse).unwrap();
|
|
88
|
+
graph.add_resource(resource).unwrap();
|
|
89
|
+
|
|
90
|
+
let kg = KnowledgeGraph::from_graph(&graph).unwrap();
|
|
91
|
+
let rdf_xml = kg.to_rdf_xml();
|
|
92
|
+
|
|
93
|
+
assert!(rdf_xml.contains("<"));
|
|
94
|
+
assert!(rdf_xml.contains(">"));
|
|
95
|
+
assert!(rdf_xml.contains("&"));
|
|
96
|
+
assert!(rdf_xml.contains("""));
|
|
97
|
+
assert!(rdf_xml.contains("'"));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#[test]
|
|
101
|
+
fn test_escape_xml_helper_covers_all_entities() {
|
|
102
|
+
let escaped = KnowledgeGraph::escape_xml("&<>\"'");
|
|
103
|
+
assert_eq!(escaped, "&<>"'");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
use jsonschema::{Draft, JSONSchema};
|
|
2
|
+
use serde_json::Value;
|
|
3
|
+
use std::fs;
|
|
4
|
+
use std::path::PathBuf;
|
|
5
|
+
|
|
6
|
+
#[test]
|
|
7
|
+
fn registry_schema_validates_sample() {
|
|
8
|
+
let manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
9
|
+
let schema_path = manifest
|
|
10
|
+
.join("..")
|
|
11
|
+
.join("schemas")
|
|
12
|
+
.join("sea-registry.schema.json");
|
|
13
|
+
let schema = fs::read_to_string(&schema_path).expect("schema must exist");
|
|
14
|
+
let schema_json: Value = serde_json::from_str(&schema).expect("valid JSON schema");
|
|
15
|
+
let compiled = JSONSchema::options()
|
|
16
|
+
.with_draft(Draft::Draft7)
|
|
17
|
+
.compile(&schema_json)
|
|
18
|
+
.expect("schema compiles");
|
|
19
|
+
|
|
20
|
+
let sample_toml = r#"
|
|
21
|
+
version = 1
|
|
22
|
+
default_namespace = "default"
|
|
23
|
+
|
|
24
|
+
[[namespaces]]
|
|
25
|
+
namespace = "logistics"
|
|
26
|
+
patterns = ["domains/logistics/**/*.sea"]
|
|
27
|
+
"#;
|
|
28
|
+
let value: toml::Value = toml::from_str(sample_toml).expect("valid toml");
|
|
29
|
+
let json_val = serde_json::to_value(value).expect("serde conversion");
|
|
30
|
+
|
|
31
|
+
let result = compiled.validate(&json_val);
|
|
32
|
+
assert!(result.is_ok(), "schema must validate sample registry");
|
|
33
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
use domainforge_core::primitives::Resource;
|
|
2
|
+
use domainforge_core::units::{unit_from_string, Dimension, Unit};
|
|
3
|
+
use rust_decimal::Decimal;
|
|
4
|
+
use serde_json::json;
|
|
5
|
+
use uuid::Uuid;
|
|
6
|
+
|
|
7
|
+
#[test]
|
|
8
|
+
fn test_resource_new_creates_valid_uuid() {
|
|
9
|
+
let units = unit_from_string("units");
|
|
10
|
+
let resource = Resource::new_with_namespace("Camera", units, "default".to_string());
|
|
11
|
+
assert!(Uuid::parse_str(&resource.id().to_string()).is_ok());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
fn test_resource_name_and_unit_stored() {
|
|
16
|
+
let kg = unit_from_string("kg");
|
|
17
|
+
let resource = Resource::new_with_namespace("Steel Beam", kg, "default".to_string());
|
|
18
|
+
assert_eq!(resource.name(), "Steel Beam");
|
|
19
|
+
assert_eq!(resource.unit().symbol(), "kg");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#[test]
|
|
23
|
+
fn test_resource_with_namespace() {
|
|
24
|
+
let currency = unit_from_string("USD");
|
|
25
|
+
let resource = Resource::new_with_namespace("USD", currency, "finance");
|
|
26
|
+
assert_eq!(resource.namespace(), "finance");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#[test]
|
|
30
|
+
fn test_resource_set_attribute() {
|
|
31
|
+
let kg = unit_from_string("kg");
|
|
32
|
+
let mut resource = Resource::new_with_namespace("Gold", kg, "default".to_string());
|
|
33
|
+
resource.set_attribute("purity", json!(0.999));
|
|
34
|
+
assert_eq!(resource.get_attribute("purity"), Some(&json!(0.999)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[test]
|
|
38
|
+
fn test_resource_serializes() {
|
|
39
|
+
let oz = Unit::new(
|
|
40
|
+
"oz",
|
|
41
|
+
"ounce",
|
|
42
|
+
Dimension::Mass,
|
|
43
|
+
Decimal::new(28349523, 9),
|
|
44
|
+
"oz",
|
|
45
|
+
);
|
|
46
|
+
let resource = Resource::new_with_namespace("Silver", oz, "default".to_string());
|
|
47
|
+
let json = serde_json::to_string(&resource).unwrap();
|
|
48
|
+
assert!(json.contains("Silver"));
|
|
49
|
+
assert!(json.contains("oz"));
|
|
50
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
use domainforge_core::primitives::Resource;
|
|
2
|
+
use domainforge_core::units::{Dimension, Unit};
|
|
3
|
+
use rust_decimal::Decimal;
|
|
4
|
+
|
|
5
|
+
#[test]
|
|
6
|
+
fn test_resource_with_unit() {
|
|
7
|
+
let kg = Unit::new("kg", "kilogram", Dimension::Mass, Decimal::from(1), "kg");
|
|
8
|
+
let gold = Resource::new_with_namespace("Gold", kg, "default".to_string());
|
|
9
|
+
|
|
10
|
+
assert_eq!(gold.name(), "Gold");
|
|
11
|
+
assert_eq!(gold.unit().symbol(), "kg");
|
|
12
|
+
assert_eq!(gold.unit().dimension(), &Dimension::Mass);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#[test]
|
|
16
|
+
fn test_resource_unit_serialization() {
|
|
17
|
+
let kg = Unit::new("kg", "kilogram", Dimension::Mass, Decimal::from(1), "kg");
|
|
18
|
+
let gold = Resource::new_with_namespace("Gold", kg, "default".to_string());
|
|
19
|
+
|
|
20
|
+
let json = serde_json::to_string(&gold).unwrap();
|
|
21
|
+
let deserialized: Resource = serde_json::from_str(&json).unwrap();
|
|
22
|
+
|
|
23
|
+
assert_eq!(gold.unit().symbol(), deserialized.unit().symbol());
|
|
24
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
use domainforge_core::kg::KnowledgeGraph;
|
|
2
|
+
use domainforge_core::parser::parse_to_graph;
|
|
3
|
+
use domainforge_core::sbvr::SbvrModel;
|
|
4
|
+
|
|
5
|
+
#[test]
|
|
6
|
+
fn parses_roles_relations_and_projects() {
|
|
7
|
+
let dsl = r#"
|
|
8
|
+
Role "Payer"
|
|
9
|
+
Role "Payee"
|
|
10
|
+
|
|
11
|
+
Resource "Money" units
|
|
12
|
+
|
|
13
|
+
Entity "Alice"
|
|
14
|
+
Entity "Bob"
|
|
15
|
+
|
|
16
|
+
Flow "Money" from "Alice" to "Bob" quantity 10
|
|
17
|
+
|
|
18
|
+
Relation "Payment"
|
|
19
|
+
subject: "Payer"
|
|
20
|
+
predicate: "pays"
|
|
21
|
+
object: "Payee"
|
|
22
|
+
via: flow "Money"
|
|
23
|
+
|
|
24
|
+
Policy role_check as:
|
|
25
|
+
exists e in entities: (e has_role "Payer")
|
|
26
|
+
"#;
|
|
27
|
+
|
|
28
|
+
let mut graph = parse_to_graph(dsl).expect("should parse role and relation declarations");
|
|
29
|
+
|
|
30
|
+
assert_eq!(graph.role_count(), 2);
|
|
31
|
+
assert_eq!(graph.relation_count(), 1);
|
|
32
|
+
|
|
33
|
+
let payer_role = graph
|
|
34
|
+
.find_role_by_name("Payer")
|
|
35
|
+
.expect("payer role should exist");
|
|
36
|
+
let alice = graph
|
|
37
|
+
.find_entity_by_name("Alice")
|
|
38
|
+
.expect("alice entity should exist");
|
|
39
|
+
|
|
40
|
+
graph
|
|
41
|
+
.assign_role_to_entity(alice, payer_role)
|
|
42
|
+
.expect("role assignment should succeed");
|
|
43
|
+
|
|
44
|
+
let validation = graph.validate();
|
|
45
|
+
assert_eq!(
|
|
46
|
+
validation.error_count, 0,
|
|
47
|
+
"policy should pass once role assigned"
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
let kg = KnowledgeGraph::from_graph(&graph).expect("kg projection should succeed");
|
|
51
|
+
assert!(kg
|
|
52
|
+
.triples
|
|
53
|
+
.iter()
|
|
54
|
+
.any(|triple| triple.predicate == "sea:subjectRole" && triple.object.contains("Payer")));
|
|
55
|
+
|
|
56
|
+
let sbvr = SbvrModel::from_graph(&graph).expect("sbvr projection should succeed");
|
|
57
|
+
assert!(sbvr
|
|
58
|
+
.facts
|
|
59
|
+
.iter()
|
|
60
|
+
.any(|fact| fact.verb == "pays" && fact.object.contains("Payee")));
|
|
61
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
use domainforge_core::parser::{parse_to_graph, PrettyPrinter};
|
|
2
|
+
|
|
3
|
+
#[test]
|
|
4
|
+
fn test_round_trip_basic() {
|
|
5
|
+
let source = r#"Entity "Server"
|
|
6
|
+
Resource "CPU"
|
|
7
|
+
"#;
|
|
8
|
+
|
|
9
|
+
// 1. Parse to Graph
|
|
10
|
+
let graph = parse_to_graph(source).unwrap();
|
|
11
|
+
|
|
12
|
+
// 2. Graph to AST
|
|
13
|
+
let ast = graph.to_ast();
|
|
14
|
+
|
|
15
|
+
// 3. AST to Source (PrettyPrint)
|
|
16
|
+
let printer = PrettyPrinter::new();
|
|
17
|
+
let printed = printer.print(&ast);
|
|
18
|
+
|
|
19
|
+
println!("Printed:\n{}", printed);
|
|
20
|
+
|
|
21
|
+
// 4. Parse Printed to Graph
|
|
22
|
+
let graph2 = parse_to_graph(&printed).unwrap();
|
|
23
|
+
|
|
24
|
+
// 5. Compare Graphs (structural check via serialization)
|
|
25
|
+
let graph_json =
|
|
26
|
+
serde_json::to_value(&graph).expect("Failed to serialize graph for comparison");
|
|
27
|
+
let graph2_json =
|
|
28
|
+
serde_json::to_value(&graph2).expect("Failed to serialize parsed graph for comparison");
|
|
29
|
+
assert_eq!(graph_json, graph2_json);
|
|
30
|
+
|
|
31
|
+
// 6. Ensure serialized forms stay stable across another round-trip
|
|
32
|
+
let printed_again = printer.print(&graph2.to_ast());
|
|
33
|
+
assert_eq!(printed, printed_again);
|
|
34
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
use domainforge_core::graph::Graph;
|
|
2
|
+
use domainforge_core::policy::{BinaryOp, Expression, Policy, Severity};
|
|
3
|
+
use domainforge_core::primitives::Entity;
|
|
4
|
+
|
|
5
|
+
#[test]
|
|
6
|
+
fn test_runtime_toggle_three_valued_logic() {
|
|
7
|
+
// Create a graph with an entity that has a null attribute
|
|
8
|
+
let mut graph = Graph::new();
|
|
9
|
+
|
|
10
|
+
let mut entity = Entity::new_with_namespace("TestEntity".to_string(), "default".to_string());
|
|
11
|
+
entity.set_attribute("status", serde_json::Value::Null);
|
|
12
|
+
graph.add_entity(entity).unwrap();
|
|
13
|
+
|
|
14
|
+
// Create a policy that inspects the null status attribute so modes diverge
|
|
15
|
+
let policy = Policy::new(
|
|
16
|
+
"TestPolicy",
|
|
17
|
+
Expression::binary(
|
|
18
|
+
BinaryOp::Equal,
|
|
19
|
+
Expression::member_access("TestEntity", "status"),
|
|
20
|
+
Expression::literal(true),
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// Test with three-valued logic enabled (default)
|
|
25
|
+
graph.set_evaluation_mode(true);
|
|
26
|
+
let result_with_tristate = policy.evaluate(&graph).unwrap();
|
|
27
|
+
|
|
28
|
+
// NULL attribute bubbles up to an indeterminate result
|
|
29
|
+
assert_eq!(result_with_tristate.is_satisfied_tristate, None);
|
|
30
|
+
assert!(!result_with_tristate.is_satisfied);
|
|
31
|
+
assert_eq!(result_with_tristate.violations.len(), 1);
|
|
32
|
+
assert_eq!(result_with_tristate.violations[0].severity, Severity::Error);
|
|
33
|
+
|
|
34
|
+
// Test with three-valued logic disabled
|
|
35
|
+
graph.set_evaluation_mode(false);
|
|
36
|
+
let result_without_tristate = policy.evaluate(&graph).unwrap();
|
|
37
|
+
|
|
38
|
+
// Boolean mode treats missing data as false
|
|
39
|
+
assert_eq!(result_without_tristate.is_satisfied_tristate, Some(false));
|
|
40
|
+
assert!(!result_without_tristate.is_satisfied);
|
|
41
|
+
assert_eq!(result_without_tristate.violations.len(), 1);
|
|
42
|
+
assert_eq!(
|
|
43
|
+
result_without_tristate.violations[0].severity,
|
|
44
|
+
Severity::Error
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[test]
|
|
49
|
+
fn test_runtime_toggle_default_is_three_valued() {
|
|
50
|
+
let graph = Graph::new();
|
|
51
|
+
|
|
52
|
+
// Default should be three-valued logic enabled
|
|
53
|
+
assert!(graph.use_three_valued_logic());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#[test]
|
|
57
|
+
fn test_runtime_toggle_can_be_changed() {
|
|
58
|
+
let mut graph = Graph::new();
|
|
59
|
+
|
|
60
|
+
// Start with default (three-valued enabled)
|
|
61
|
+
assert!(graph.use_three_valued_logic());
|
|
62
|
+
|
|
63
|
+
// Disable three-valued logic
|
|
64
|
+
graph.set_evaluation_mode(false);
|
|
65
|
+
assert!(!graph.use_three_valued_logic());
|
|
66
|
+
|
|
67
|
+
// Re-enable three-valued logic
|
|
68
|
+
graph.set_evaluation_mode(true);
|
|
69
|
+
assert!(graph.use_three_valued_logic());
|
|
70
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#[cfg(test)]
|
|
2
|
+
mod sbvr_fact_schema_tests {
|
|
3
|
+
use domainforge_core::sbvr::SbvrFactType;
|
|
4
|
+
|
|
5
|
+
#[test]
|
|
6
|
+
fn test_fact_type_includes_destination_and_schema_version() {
|
|
7
|
+
let fact = SbvrFactType {
|
|
8
|
+
id: "fact-001".to_string(),
|
|
9
|
+
subject: "entity-from".to_string(),
|
|
10
|
+
verb: "transfers".to_string(),
|
|
11
|
+
object: "resource-123".to_string(),
|
|
12
|
+
destination: Some("entity-to".to_string()),
|
|
13
|
+
schema_version: "2.0".to_string(),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let json = serde_json::to_string(&fact).unwrap();
|
|
17
|
+
let value: serde_json::Value = serde_json::from_str(&json).unwrap();
|
|
18
|
+
|
|
19
|
+
assert_eq!(value["schema_version"], "2.0");
|
|
20
|
+
assert_eq!(value["destination"].as_str(), Some("entity-to"));
|
|
21
|
+
assert_eq!(value["object"], "resource-123");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#[test]
|
|
25
|
+
fn test_fact_v1_upgrade_without_destination() {
|
|
26
|
+
let legacy = r#"{
|
|
27
|
+
"id":"legacy-fact",
|
|
28
|
+
"subject":"legacy-from",
|
|
29
|
+
"verb":"transfers",
|
|
30
|
+
"object":"legacy-to"
|
|
31
|
+
}"#;
|
|
32
|
+
|
|
33
|
+
let upgraded: SbvrFactType = serde_json::from_str(legacy).unwrap();
|
|
34
|
+
assert_eq!(upgraded.schema_version, "2.0");
|
|
35
|
+
assert_eq!(upgraded.destination, None);
|
|
36
|
+
assert_eq!(upgraded.object, "legacy-to");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#[test]
|
|
40
|
+
fn test_sbvr_fact_round_trip() {
|
|
41
|
+
let fact = SbvrFactType {
|
|
42
|
+
id: "fact-002".to_string(),
|
|
43
|
+
subject: "warehouse".to_string(),
|
|
44
|
+
verb: "transfers".to_string(),
|
|
45
|
+
object: "camera-resource".to_string(),
|
|
46
|
+
destination: Some("factory".to_string()),
|
|
47
|
+
schema_version: "2.0".to_string(),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
let json = serde_json::to_string(&fact).unwrap();
|
|
51
|
+
let deserialized: SbvrFactType = serde_json::from_str(&json).unwrap();
|
|
52
|
+
|
|
53
|
+
assert_eq!(deserialized.id, "fact-002");
|
|
54
|
+
assert_eq!(deserialized.subject, "warehouse");
|
|
55
|
+
assert_eq!(deserialized.verb, "transfers");
|
|
56
|
+
assert_eq!(deserialized.object, "camera-resource");
|
|
57
|
+
assert_eq!(deserialized.destination.as_deref(), Some("factory"));
|
|
58
|
+
assert_eq!(deserialized.schema_version, "2.0");
|
|
59
|
+
}
|
|
60
|
+
}
|