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,88 @@
|
|
|
1
|
+
use crate::registry::{NamespaceBinding as RustBinding, NamespaceRegistry as RustRegistry};
|
|
2
|
+
use napi::bindgen_prelude::*;
|
|
3
|
+
use napi_derive::napi;
|
|
4
|
+
use std::path::Path;
|
|
5
|
+
|
|
6
|
+
#[napi]
|
|
7
|
+
pub struct NamespaceBinding {
|
|
8
|
+
inner: RustBinding,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#[napi]
|
|
12
|
+
impl NamespaceBinding {
|
|
13
|
+
#[napi(constructor)]
|
|
14
|
+
pub fn new(path: String, namespace: String) -> Self {
|
|
15
|
+
Self {
|
|
16
|
+
inner: RustBinding {
|
|
17
|
+
path: Path::new(&path).to_path_buf(),
|
|
18
|
+
namespace,
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[napi(getter)]
|
|
24
|
+
pub fn path(&self) -> String {
|
|
25
|
+
self.inner.path.display().to_string()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[napi(getter)]
|
|
29
|
+
pub fn namespace(&self) -> String {
|
|
30
|
+
self.inner.namespace.clone()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#[napi]
|
|
35
|
+
pub struct NamespaceRegistry {
|
|
36
|
+
inner: RustRegistry,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#[napi]
|
|
40
|
+
impl NamespaceRegistry {
|
|
41
|
+
#[napi(factory)]
|
|
42
|
+
pub fn from_file(path: String) -> Result<Self> {
|
|
43
|
+
let reg = RustRegistry::from_file(Path::new(&path))
|
|
44
|
+
.map_err(|e| Error::from_reason(format!("{}", e)))?;
|
|
45
|
+
Ok(Self { inner: reg })
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[napi]
|
|
49
|
+
pub fn discover(path: String) -> Result<Option<NamespaceRegistry>> {
|
|
50
|
+
let res = RustRegistry::discover(Path::new(&path))
|
|
51
|
+
.map_err(|e| Error::from_reason(format!("{}", e)))?;
|
|
52
|
+
Ok(res.map(|r| NamespaceRegistry { inner: r }))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#[napi]
|
|
56
|
+
pub fn resolve_files(&self, fail_on_ambiguity: Option<bool>) -> Result<Vec<NamespaceBinding>> {
|
|
57
|
+
let fail = fail_on_ambiguity.unwrap_or(false);
|
|
58
|
+
let bindings = self
|
|
59
|
+
.inner
|
|
60
|
+
.resolve_files_with_options(fail)
|
|
61
|
+
.map_err(|e| Error::from_reason(format!("{}", e)))?;
|
|
62
|
+
Ok(bindings
|
|
63
|
+
.into_iter()
|
|
64
|
+
.map(|b| NamespaceBinding { inner: b })
|
|
65
|
+
.collect())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#[napi]
|
|
69
|
+
pub fn namespace_for(&self, path: String, fail_on_ambiguity: Option<bool>) -> Result<String> {
|
|
70
|
+
let fail = fail_on_ambiguity.unwrap_or(false);
|
|
71
|
+
let res = self
|
|
72
|
+
.inner
|
|
73
|
+
.namespace_for_with_options(Path::new(&path), fail)
|
|
74
|
+
.map(|s| s.to_string())
|
|
75
|
+
.map_err(|e| Error::from_reason(format!("{}", e)))?;
|
|
76
|
+
Ok(res)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#[napi(getter)]
|
|
80
|
+
pub fn root(&self) -> String {
|
|
81
|
+
self.inner.root().display().to_string()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#[napi(getter)]
|
|
85
|
+
pub fn default_namespace(&self) -> String {
|
|
86
|
+
self.inner.default_namespace().to_string()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
use crate::semantic_pack::{
|
|
2
|
+
build_semantic_pack, canonical_json, diff_packs, normalize_lookup_key, resolve_concept,
|
|
3
|
+
validate_graph_with_pack, validate_semantic_pack, AliasStatus as RustAliasStatus,
|
|
4
|
+
ApprovalState as RustApprovalState, ConceptKind as RustConceptKind,
|
|
5
|
+
ConceptStatus as RustConceptStatus, DiagnosticSeverity as RustDiagnosticSeverity,
|
|
6
|
+
PackBuildInput, ResolveRequest, SemanticTruth as RustSemanticTruth,
|
|
7
|
+
SemanticValidationStatus as RustSemanticValidationStatus, SignatureState as RustSignatureState,
|
|
8
|
+
ValidationMode as RustValidationMode, ValidationOptions,
|
|
9
|
+
};
|
|
10
|
+
#[cfg(feature = "signing")]
|
|
11
|
+
use crate::semantic_pack::{derive_signer_id, sign_pack, verify_pack_signature};
|
|
12
|
+
use napi_derive::napi;
|
|
13
|
+
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Enums
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
#[napi]
|
|
19
|
+
pub enum SemanticTruth {
|
|
20
|
+
Valid = 0,
|
|
21
|
+
Invalid = 1,
|
|
22
|
+
Unknown = 2,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
impl From<SemanticTruth> for RustSemanticTruth {
|
|
26
|
+
fn from(v: SemanticTruth) -> Self {
|
|
27
|
+
match v {
|
|
28
|
+
SemanticTruth::Valid => RustSemanticTruth::Valid,
|
|
29
|
+
SemanticTruth::Invalid => RustSemanticTruth::Invalid,
|
|
30
|
+
SemanticTruth::Unknown => RustSemanticTruth::Unknown,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
impl From<RustSemanticTruth> for SemanticTruth {
|
|
36
|
+
fn from(v: RustSemanticTruth) -> Self {
|
|
37
|
+
match v {
|
|
38
|
+
RustSemanticTruth::Valid => SemanticTruth::Valid,
|
|
39
|
+
RustSemanticTruth::Invalid => SemanticTruth::Invalid,
|
|
40
|
+
RustSemanticTruth::Unknown => SemanticTruth::Unknown,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[napi]
|
|
46
|
+
pub enum DiagnosticSeverity {
|
|
47
|
+
Error = 0,
|
|
48
|
+
Warning = 1,
|
|
49
|
+
Info = 2,
|
|
50
|
+
Hint = 3,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
impl From<DiagnosticSeverity> for RustDiagnosticSeverity {
|
|
54
|
+
fn from(v: DiagnosticSeverity) -> Self {
|
|
55
|
+
match v {
|
|
56
|
+
DiagnosticSeverity::Error => RustDiagnosticSeverity::Error,
|
|
57
|
+
DiagnosticSeverity::Warning => RustDiagnosticSeverity::Warning,
|
|
58
|
+
DiagnosticSeverity::Info => RustDiagnosticSeverity::Info,
|
|
59
|
+
DiagnosticSeverity::Hint => RustDiagnosticSeverity::Hint,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
impl From<RustDiagnosticSeverity> for DiagnosticSeverity {
|
|
65
|
+
fn from(v: RustDiagnosticSeverity) -> Self {
|
|
66
|
+
match v {
|
|
67
|
+
RustDiagnosticSeverity::Error => DiagnosticSeverity::Error,
|
|
68
|
+
RustDiagnosticSeverity::Warning => DiagnosticSeverity::Warning,
|
|
69
|
+
RustDiagnosticSeverity::Info => DiagnosticSeverity::Info,
|
|
70
|
+
RustDiagnosticSeverity::Hint => DiagnosticSeverity::Hint,
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#[napi]
|
|
76
|
+
pub enum ValidationMode {
|
|
77
|
+
Off = 0,
|
|
78
|
+
Warn = 1,
|
|
79
|
+
Strict = 2,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
impl From<ValidationMode> for RustValidationMode {
|
|
83
|
+
fn from(v: ValidationMode) -> Self {
|
|
84
|
+
match v {
|
|
85
|
+
ValidationMode::Off => RustValidationMode::Off,
|
|
86
|
+
ValidationMode::Warn => RustValidationMode::Warn,
|
|
87
|
+
ValidationMode::Strict => RustValidationMode::Strict,
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
impl From<RustValidationMode> for ValidationMode {
|
|
93
|
+
fn from(v: RustValidationMode) -> Self {
|
|
94
|
+
match v {
|
|
95
|
+
RustValidationMode::Off => ValidationMode::Off,
|
|
96
|
+
RustValidationMode::Warn => ValidationMode::Warn,
|
|
97
|
+
RustValidationMode::Strict => ValidationMode::Strict,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#[napi]
|
|
103
|
+
pub enum ApprovalState {
|
|
104
|
+
Candidate = 0,
|
|
105
|
+
Approved = 1,
|
|
106
|
+
Rejected = 2,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
impl From<ApprovalState> for RustApprovalState {
|
|
110
|
+
fn from(v: ApprovalState) -> Self {
|
|
111
|
+
match v {
|
|
112
|
+
ApprovalState::Candidate => RustApprovalState::Candidate,
|
|
113
|
+
ApprovalState::Approved => RustApprovalState::Approved,
|
|
114
|
+
ApprovalState::Rejected => RustApprovalState::Rejected,
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
impl From<RustApprovalState> for ApprovalState {
|
|
120
|
+
fn from(v: RustApprovalState) -> Self {
|
|
121
|
+
match v {
|
|
122
|
+
RustApprovalState::Candidate => ApprovalState::Candidate,
|
|
123
|
+
RustApprovalState::Approved => ApprovalState::Approved,
|
|
124
|
+
RustApprovalState::Rejected => ApprovalState::Rejected,
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#[napi]
|
|
130
|
+
pub enum SignatureState {
|
|
131
|
+
Unsigned = 0,
|
|
132
|
+
Signed = 1,
|
|
133
|
+
InvalidSignature = 2,
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
impl From<SignatureState> for RustSignatureState {
|
|
137
|
+
fn from(v: SignatureState) -> Self {
|
|
138
|
+
match v {
|
|
139
|
+
SignatureState::Unsigned => RustSignatureState::Unsigned,
|
|
140
|
+
SignatureState::Signed => RustSignatureState::Signed,
|
|
141
|
+
SignatureState::InvalidSignature => RustSignatureState::InvalidSignature,
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
impl From<RustSignatureState> for SignatureState {
|
|
147
|
+
fn from(v: RustSignatureState) -> Self {
|
|
148
|
+
match v {
|
|
149
|
+
RustSignatureState::Unsigned => SignatureState::Unsigned,
|
|
150
|
+
RustSignatureState::Signed => SignatureState::Signed,
|
|
151
|
+
RustSignatureState::InvalidSignature => SignatureState::InvalidSignature,
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
#[napi]
|
|
157
|
+
pub enum ConceptStatus {
|
|
158
|
+
Active = 0,
|
|
159
|
+
Proposed = 1,
|
|
160
|
+
Deprecated = 2,
|
|
161
|
+
Rejected = 3,
|
|
162
|
+
ExternalOnly = 4,
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
impl From<ConceptStatus> for RustConceptStatus {
|
|
166
|
+
fn from(v: ConceptStatus) -> Self {
|
|
167
|
+
match v {
|
|
168
|
+
ConceptStatus::Active => RustConceptStatus::Active,
|
|
169
|
+
ConceptStatus::Proposed => RustConceptStatus::Proposed,
|
|
170
|
+
ConceptStatus::Deprecated => RustConceptStatus::Deprecated,
|
|
171
|
+
ConceptStatus::Rejected => RustConceptStatus::Rejected,
|
|
172
|
+
ConceptStatus::ExternalOnly => RustConceptStatus::ExternalOnly,
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
impl From<RustConceptStatus> for ConceptStatus {
|
|
178
|
+
fn from(v: RustConceptStatus) -> Self {
|
|
179
|
+
match v {
|
|
180
|
+
RustConceptStatus::Active => ConceptStatus::Active,
|
|
181
|
+
RustConceptStatus::Proposed => ConceptStatus::Proposed,
|
|
182
|
+
RustConceptStatus::Deprecated => ConceptStatus::Deprecated,
|
|
183
|
+
RustConceptStatus::Rejected => ConceptStatus::Rejected,
|
|
184
|
+
RustConceptStatus::ExternalOnly => ConceptStatus::ExternalOnly,
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
#[napi]
|
|
190
|
+
pub enum ConceptKind {
|
|
191
|
+
Entity = 0,
|
|
192
|
+
Resource = 1,
|
|
193
|
+
Role = 2,
|
|
194
|
+
Flow = 3,
|
|
195
|
+
Policy = 4,
|
|
196
|
+
Metric = 5,
|
|
197
|
+
Dimension = 6,
|
|
198
|
+
Unit = 7,
|
|
199
|
+
External = 8,
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
impl From<ConceptKind> for RustConceptKind {
|
|
203
|
+
fn from(v: ConceptKind) -> Self {
|
|
204
|
+
match v {
|
|
205
|
+
ConceptKind::Entity => RustConceptKind::Entity,
|
|
206
|
+
ConceptKind::Resource => RustConceptKind::Resource,
|
|
207
|
+
ConceptKind::Role => RustConceptKind::Role,
|
|
208
|
+
ConceptKind::Flow => RustConceptKind::Flow,
|
|
209
|
+
ConceptKind::Policy => RustConceptKind::Policy,
|
|
210
|
+
ConceptKind::Metric => RustConceptKind::Metric,
|
|
211
|
+
ConceptKind::Dimension => RustConceptKind::Dimension,
|
|
212
|
+
ConceptKind::Unit => RustConceptKind::Unit,
|
|
213
|
+
ConceptKind::External => RustConceptKind::External,
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
impl From<RustConceptKind> for ConceptKind {
|
|
219
|
+
fn from(v: RustConceptKind) -> Self {
|
|
220
|
+
match v {
|
|
221
|
+
RustConceptKind::Entity => ConceptKind::Entity,
|
|
222
|
+
RustConceptKind::Resource => ConceptKind::Resource,
|
|
223
|
+
RustConceptKind::Role => ConceptKind::Role,
|
|
224
|
+
RustConceptKind::Flow => ConceptKind::Flow,
|
|
225
|
+
RustConceptKind::Policy => ConceptKind::Policy,
|
|
226
|
+
RustConceptKind::Metric => ConceptKind::Metric,
|
|
227
|
+
RustConceptKind::Dimension => ConceptKind::Dimension,
|
|
228
|
+
RustConceptKind::Unit => ConceptKind::Unit,
|
|
229
|
+
RustConceptKind::External => ConceptKind::External,
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
#[napi]
|
|
235
|
+
pub enum AliasStatus {
|
|
236
|
+
Approved = 0,
|
|
237
|
+
Deprecated = 1,
|
|
238
|
+
Ambiguous = 2,
|
|
239
|
+
Blocked = 3,
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
impl From<AliasStatus> for RustAliasStatus {
|
|
243
|
+
fn from(v: AliasStatus) -> Self {
|
|
244
|
+
match v {
|
|
245
|
+
AliasStatus::Approved => RustAliasStatus::Approved,
|
|
246
|
+
AliasStatus::Deprecated => RustAliasStatus::Deprecated,
|
|
247
|
+
AliasStatus::Ambiguous => RustAliasStatus::Ambiguous,
|
|
248
|
+
AliasStatus::Blocked => RustAliasStatus::Blocked,
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
impl From<RustAliasStatus> for AliasStatus {
|
|
254
|
+
fn from(v: RustAliasStatus) -> Self {
|
|
255
|
+
match v {
|
|
256
|
+
RustAliasStatus::Approved => AliasStatus::Approved,
|
|
257
|
+
RustAliasStatus::Deprecated => AliasStatus::Deprecated,
|
|
258
|
+
RustAliasStatus::Ambiguous => AliasStatus::Ambiguous,
|
|
259
|
+
RustAliasStatus::Blocked => AliasStatus::Blocked,
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#[napi]
|
|
265
|
+
pub enum SemanticValidationStatus {
|
|
266
|
+
Passed = 0,
|
|
267
|
+
Failed = 1,
|
|
268
|
+
Unknown = 2,
|
|
269
|
+
Blocked = 3,
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
impl From<SemanticValidationStatus> for RustSemanticValidationStatus {
|
|
273
|
+
fn from(v: SemanticValidationStatus) -> Self {
|
|
274
|
+
match v {
|
|
275
|
+
SemanticValidationStatus::Passed => RustSemanticValidationStatus::Passed,
|
|
276
|
+
SemanticValidationStatus::Failed => RustSemanticValidationStatus::Failed,
|
|
277
|
+
SemanticValidationStatus::Unknown => RustSemanticValidationStatus::Unknown,
|
|
278
|
+
SemanticValidationStatus::Blocked => RustSemanticValidationStatus::Blocked,
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
impl From<RustSemanticValidationStatus> for SemanticValidationStatus {
|
|
284
|
+
fn from(v: RustSemanticValidationStatus) -> Self {
|
|
285
|
+
match v {
|
|
286
|
+
RustSemanticValidationStatus::Passed => SemanticValidationStatus::Passed,
|
|
287
|
+
RustSemanticValidationStatus::Failed => SemanticValidationStatus::Failed,
|
|
288
|
+
RustSemanticValidationStatus::Unknown => SemanticValidationStatus::Unknown,
|
|
289
|
+
RustSemanticValidationStatus::Blocked => SemanticValidationStatus::Blocked,
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// =============================================================================
|
|
295
|
+
// Shared helpers
|
|
296
|
+
// =============================================================================
|
|
297
|
+
|
|
298
|
+
fn parse_validation_options(options_json: &str) -> napi::Result<ValidationOptions> {
|
|
299
|
+
if options_json.is_empty() {
|
|
300
|
+
Ok(ValidationOptions::default())
|
|
301
|
+
} else {
|
|
302
|
+
serde_json::from_str(options_json)
|
|
303
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid options JSON: {}", e)))
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// =============================================================================
|
|
308
|
+
// Functions
|
|
309
|
+
// =============================================================================
|
|
310
|
+
|
|
311
|
+
#[napi]
|
|
312
|
+
pub fn semantic_pack_build(input_json: String) -> napi::Result<String> {
|
|
313
|
+
let input: PackBuildInput = serde_json::from_str(&input_json)
|
|
314
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid build input: {}", e)))?;
|
|
315
|
+
|
|
316
|
+
let output = build_semantic_pack(input).map_err(|diags| {
|
|
317
|
+
let messages: Vec<String> = diags.iter().map(|d| d.message.clone()).collect();
|
|
318
|
+
napi::Error::from_reason(format!("Build failed: {}", messages.join("; ")))
|
|
319
|
+
})?;
|
|
320
|
+
|
|
321
|
+
let result = serde_json::json!({
|
|
322
|
+
"pack": output.pack,
|
|
323
|
+
"pack_content_hash": output.pack_content_hash,
|
|
324
|
+
"meaning_fingerprint": output.meaning_fingerprint,
|
|
325
|
+
"pre_pack_diagnostics": output.pre_pack_diagnostics,
|
|
326
|
+
"build_warnings": output.build_warnings,
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
serde_json::to_string(&result)
|
|
330
|
+
.map_err(|e| napi::Error::from_reason(format!("Serialization error: {}", e)))
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
#[napi]
|
|
334
|
+
pub fn semantic_pack_validate(pack_json: String) -> napi::Result<String> {
|
|
335
|
+
let pack: crate::semantic_pack::SemanticPack = serde_json::from_str(&pack_json)
|
|
336
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid pack JSON: {}", e)))?;
|
|
337
|
+
|
|
338
|
+
let diagnostics = validate_semantic_pack(&pack)
|
|
339
|
+
.map_err(|e| napi::Error::from_reason(format!("Validation error: {:?}", e)))?;
|
|
340
|
+
|
|
341
|
+
serde_json::to_string(&diagnostics)
|
|
342
|
+
.map_err(|e| napi::Error::from_reason(format!("Serialization error: {}", e)))
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
#[napi]
|
|
346
|
+
pub fn semantic_pack_validate_graph(
|
|
347
|
+
pack_json: String,
|
|
348
|
+
source: String,
|
|
349
|
+
options_json: String,
|
|
350
|
+
) -> napi::Result<String> {
|
|
351
|
+
let pack: crate::semantic_pack::SemanticPack = serde_json::from_str(&pack_json)
|
|
352
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid pack JSON: {}", e)))?;
|
|
353
|
+
|
|
354
|
+
let options = parse_validation_options(&options_json)?;
|
|
355
|
+
|
|
356
|
+
let result = validate_graph_with_pack(&pack, &source, &options);
|
|
357
|
+
|
|
358
|
+
serde_json::to_string(&result)
|
|
359
|
+
.map_err(|e| napi::Error::from_reason(format!("Serialization error: {}", e)))
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
#[cfg(feature = "signing")]
|
|
363
|
+
#[napi]
|
|
364
|
+
pub fn semantic_pack_sign(pack_json: String, private_key_pem: String) -> napi::Result<String> {
|
|
365
|
+
let mut pack: crate::semantic_pack::SemanticPack = serde_json::from_str(&pack_json)
|
|
366
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid pack JSON: {}", e)))?;
|
|
367
|
+
|
|
368
|
+
let sign_output = sign_pack(&pack, private_key_pem.as_bytes())
|
|
369
|
+
.map_err(|e| napi::Error::from_reason(format!("Signing error: {:?}", e)))?;
|
|
370
|
+
let signer_id = derive_signer_id(private_key_pem.as_bytes())
|
|
371
|
+
.map_err(|e| napi::Error::from_reason(format!("Key derivation error: {:?}", e)))?;
|
|
372
|
+
|
|
373
|
+
pack.trust.signature_state = RustSignatureState::Signed;
|
|
374
|
+
pack.trust.signature = Some(sign_output.signature);
|
|
375
|
+
pack.trust.signature_alg = Some(sign_output.signature_alg);
|
|
376
|
+
pack.trust.signed_by = Some(signer_id);
|
|
377
|
+
|
|
378
|
+
serde_json::to_string(&pack)
|
|
379
|
+
.map_err(|e| napi::Error::from_reason(format!("Serialization error: {}", e)))
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
#[cfg(not(feature = "signing"))]
|
|
383
|
+
#[napi]
|
|
384
|
+
pub fn semantic_pack_sign(_pack_json: String, _private_key_pem: String) -> napi::Result<String> {
|
|
385
|
+
Err(napi::Error::from_reason(
|
|
386
|
+
"signing requires the 'signing' feature",
|
|
387
|
+
))
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
#[cfg(feature = "signing")]
|
|
391
|
+
#[napi]
|
|
392
|
+
pub fn semantic_pack_verify(pack_json: String, public_key_pem: String) -> napi::Result<bool> {
|
|
393
|
+
let pack: crate::semantic_pack::SemanticPack = serde_json::from_str(&pack_json)
|
|
394
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid pack JSON: {}", e)))?;
|
|
395
|
+
|
|
396
|
+
match verify_pack_signature(&pack, public_key_pem.as_bytes()) {
|
|
397
|
+
Ok(()) => Ok(true),
|
|
398
|
+
Err(e) => Err(napi::Error::from_reason(format!(
|
|
399
|
+
"Signature verification failed: {:?}",
|
|
400
|
+
e
|
|
401
|
+
))),
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
#[cfg(not(feature = "signing"))]
|
|
406
|
+
#[napi]
|
|
407
|
+
pub fn semantic_pack_verify(_pack_json: String, _public_key_pem: String) -> napi::Result<bool> {
|
|
408
|
+
Err(napi::Error::from_reason(
|
|
409
|
+
"signing requires the 'signing' feature",
|
|
410
|
+
))
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
#[napi]
|
|
414
|
+
pub fn semantic_pack_diff(old_json: String, new_json: String) -> napi::Result<String> {
|
|
415
|
+
let old_pack: crate::semantic_pack::SemanticPack = serde_json::from_str(&old_json)
|
|
416
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid old pack JSON: {}", e)))?;
|
|
417
|
+
let new_pack: crate::semantic_pack::SemanticPack = serde_json::from_str(&new_json)
|
|
418
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid new pack JSON: {}", e)))?;
|
|
419
|
+
|
|
420
|
+
let diff = diff_packs(&old_pack, &new_pack);
|
|
421
|
+
|
|
422
|
+
serde_json::to_string(&diff)
|
|
423
|
+
.map_err(|e| napi::Error::from_reason(format!("Serialization error: {}", e)))
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
#[napi]
|
|
427
|
+
pub fn semantic_pack_hash(pack_json: String) -> napi::Result<String> {
|
|
428
|
+
let pack: crate::semantic_pack::SemanticPack = serde_json::from_str(&pack_json)
|
|
429
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid pack JSON: {}", e)))?;
|
|
430
|
+
|
|
431
|
+
Ok(canonical_json::compute_pack_content_hash(&pack))
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
#[napi]
|
|
435
|
+
pub fn semantic_normalize_key(text: String) -> String {
|
|
436
|
+
normalize_lookup_key(&text)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
#[napi]
|
|
440
|
+
pub fn semantic_resolve_concept(
|
|
441
|
+
raw_text: String,
|
|
442
|
+
pack_json: String,
|
|
443
|
+
options_json: String,
|
|
444
|
+
) -> napi::Result<String> {
|
|
445
|
+
let pack: crate::semantic_pack::SemanticPack = serde_json::from_str(&pack_json)
|
|
446
|
+
.map_err(|e| napi::Error::from_reason(format!("Invalid pack JSON: {}", e)))?;
|
|
447
|
+
|
|
448
|
+
let options = parse_validation_options(&options_json)?;
|
|
449
|
+
|
|
450
|
+
let source_ref = crate::semantic_pack::schema::SourceRef::synthetic("typescript://resolve");
|
|
451
|
+
let request = ResolveRequest {
|
|
452
|
+
raw_text: &raw_text,
|
|
453
|
+
expected_kind: None,
|
|
454
|
+
source_ref,
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
let result = resolve_concept(&request, &pack, &options);
|
|
458
|
+
|
|
459
|
+
let json = serde_json::json!({
|
|
460
|
+
"resolved_concept_id": result.resolved_concept_id,
|
|
461
|
+
"semantic_truth": serde_json::to_value(result.semantic_truth).unwrap_or_default(),
|
|
462
|
+
"diagnostic_code": result.diagnostic_code.as_ref().map(|c| c.as_str().to_string()),
|
|
463
|
+
"diagnostic_severity": serde_json::to_value(result.diagnostic_severity).unwrap_or_default(),
|
|
464
|
+
"message": result.message,
|
|
465
|
+
"suggestions": result.suggestions,
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
serde_json::to_string(&json)
|
|
469
|
+
.map_err(|e| napi::Error::from_reason(format!("Serialization error: {}", e)))
|
|
470
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
use crate::units::{Dimension as RustDimension, Unit as RustUnit};
|
|
2
|
+
use napi_derive::napi;
|
|
3
|
+
use rust_decimal::prelude::{FromPrimitive, ToPrimitive};
|
|
4
|
+
|
|
5
|
+
#[napi]
|
|
6
|
+
pub struct Dimension {
|
|
7
|
+
inner: RustDimension,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
#[napi]
|
|
11
|
+
impl Dimension {
|
|
12
|
+
#[napi(factory)]
|
|
13
|
+
pub fn parse(name: String) -> Self {
|
|
14
|
+
Self {
|
|
15
|
+
inner: RustDimension::parse(&name),
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#[napi(getter)]
|
|
20
|
+
pub fn name(&self) -> String {
|
|
21
|
+
format!("{}", self.inner)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#[napi]
|
|
26
|
+
pub struct Unit {
|
|
27
|
+
inner: RustUnit,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#[napi]
|
|
31
|
+
impl Unit {
|
|
32
|
+
#[napi(constructor)]
|
|
33
|
+
pub fn new(
|
|
34
|
+
symbol: String,
|
|
35
|
+
name: String,
|
|
36
|
+
dimension: String,
|
|
37
|
+
base_factor: f64,
|
|
38
|
+
base_unit: String,
|
|
39
|
+
) -> Self {
|
|
40
|
+
let dec =
|
|
41
|
+
rust_decimal::Decimal::from_f64(base_factor).unwrap_or(rust_decimal::Decimal::ONE);
|
|
42
|
+
let dim = crate::units::Dimension::parse(&dimension);
|
|
43
|
+
let inner = RustUnit::new(symbol, name, dim, dec, base_unit);
|
|
44
|
+
Self { inner }
|
|
45
|
+
}
|
|
46
|
+
#[napi(getter)]
|
|
47
|
+
pub fn symbol(&self) -> String {
|
|
48
|
+
self.inner.symbol().to_string()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#[napi(getter)]
|
|
52
|
+
pub fn name(&self) -> String {
|
|
53
|
+
self.inner.name().to_string()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#[napi(getter)]
|
|
57
|
+
pub fn dimension(&self) -> String {
|
|
58
|
+
format!("{}", self.inner.dimension())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#[napi(getter)]
|
|
62
|
+
pub fn base_factor(&self) -> f64 {
|
|
63
|
+
self.inner.base_factor().to_f64().unwrap_or(1.0)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#[napi(getter)]
|
|
67
|
+
pub fn base_unit(&self) -> String {
|
|
68
|
+
self.inner.base_unit().to_string()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
impl Unit {
|
|
73
|
+
pub fn from_rust(inner: RustUnit) -> Self {
|
|
74
|
+
Self { inner }
|
|
75
|
+
}
|
|
76
|
+
}
|