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,255 @@
|
|
|
1
|
+
# Grammar Specification
|
|
2
|
+
|
|
3
|
+
Canonical reference for the SEA DSL grammar. This mirrors `domainforge-core/grammar/sea.pest` and demonstrates the supported syntax with copy/pasteable examples. Keywords are case-insensitive in the parser (`^"keyword"`), but documentation and pretty-printing use capitalized forms (e.g., `Entity`, `Resource`, `Flow`).
|
|
4
|
+
|
|
5
|
+
## File shape
|
|
6
|
+
|
|
7
|
+
```sea
|
|
8
|
+
program = { SOI ~ file_header? ~ declaration* ~ EOI }
|
|
9
|
+
file_header = { annotation* ~ import_decl* }
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
- **Annotations**: `@namespace`, `@version`, `@owner`, `@profile` with string values.
|
|
13
|
+
- **Imports**: `Import {Foo, Bar as Baz} from "path/to/file.sea"`, `Import * as alias from "module"`, or `Import { Service } from "std:core"`.
|
|
14
|
+
|
|
15
|
+
Example header:
|
|
16
|
+
|
|
17
|
+
```sea
|
|
18
|
+
@namespace "finance.payments"
|
|
19
|
+
@owner "platform-team"
|
|
20
|
+
@profile "cloud"
|
|
21
|
+
Import {Ledger as L} from "../common/ledger.sea"
|
|
22
|
+
Import { Service } from "std:core"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Names, identifiers, literals
|
|
26
|
+
|
|
27
|
+
- **Names** (`name` rule): double-quoted string or `"""` multiline string.
|
|
28
|
+
- **Identifiers** (`identifier` rule): `[A-Za-z_][A-Za-z0-9_]*`.
|
|
29
|
+
- **String literal**: double-quoted with escapes; multiline uses triple quotes.
|
|
30
|
+
- **Number**: decimal with optional fraction and leading sign; no scientific notation.
|
|
31
|
+
- **Boolean**: `true` / `false`.
|
|
32
|
+
- **Comments/whitespace**: `// ...` to end of line; whitespace ignored outside strings.
|
|
33
|
+
|
|
34
|
+
## Declarations
|
|
35
|
+
|
|
36
|
+
Order is flexible; duplicates fail validation.
|
|
37
|
+
|
|
38
|
+
### Entity
|
|
39
|
+
|
|
40
|
+
```sea
|
|
41
|
+
Entity "Name" [v1.2.3] [@replaces "Old" v1.0.0] [@changes ["note1", "note2"]] [in domain]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Example:
|
|
45
|
+
|
|
46
|
+
```sea
|
|
47
|
+
Entity "VendorV2" v2.0.0
|
|
48
|
+
@replaces "Vendor" v1.0.0
|
|
49
|
+
@changes ["added credit_limit", "added payment_terms"]
|
|
50
|
+
in procurement
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Resource
|
|
54
|
+
|
|
55
|
+
```sea
|
|
56
|
+
Resource "Name" [units|<unit>] [in domain]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Examples:
|
|
60
|
+
|
|
61
|
+
```sea
|
|
62
|
+
Resource "Money" USD in finance
|
|
63
|
+
Resource "Logs" units
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Flow
|
|
67
|
+
|
|
68
|
+
```sea
|
|
69
|
+
Flow "ResourceName" from "SourceEntity" to "TargetEntity" [quantity <number>]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Example:
|
|
73
|
+
|
|
74
|
+
```sea
|
|
75
|
+
Flow "Money" from "Customer" to "PaymentProcessor" quantity 1000
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Custom flow annotations are supported using `@<identifier> <value>` with JSON-like values:
|
|
79
|
+
|
|
80
|
+
```sea
|
|
81
|
+
Flow "Money"
|
|
82
|
+
@cqrs { "kind": "command" }
|
|
83
|
+
@tx { "transactional": false }
|
|
84
|
+
from "Customer" to "PaymentProcessor" quantity 1000
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Pattern
|
|
88
|
+
|
|
89
|
+
```sea
|
|
90
|
+
Pattern "Email" matches "^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Role
|
|
94
|
+
|
|
95
|
+
```sea
|
|
96
|
+
Role "Approver" [in domain]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Relation
|
|
100
|
+
|
|
101
|
+
```sea
|
|
102
|
+
Relation "Payment"
|
|
103
|
+
subject: "Payer"
|
|
104
|
+
predicate: "pays"
|
|
105
|
+
object: "Payee"
|
|
106
|
+
[via: flow "Money"]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### ConceptChange
|
|
110
|
+
|
|
111
|
+
```sea
|
|
112
|
+
ConceptChange "Vendor_v2_migration"
|
|
113
|
+
@from_version v2.0.0
|
|
114
|
+
@to_version v2.1.0
|
|
115
|
+
@migration_policy mandatory
|
|
116
|
+
@breaking_change true
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Instance
|
|
120
|
+
|
|
121
|
+
```sea
|
|
122
|
+
Instance instance_id of "EntityName" [{
|
|
123
|
+
field: expression,
|
|
124
|
+
other: expression
|
|
125
|
+
}]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Example:
|
|
129
|
+
|
|
130
|
+
```sea
|
|
131
|
+
Instance order_123 of "Order" {
|
|
132
|
+
amount: 150,
|
|
133
|
+
currency: "USD"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Dimension and Unit
|
|
138
|
+
|
|
139
|
+
```sea
|
|
140
|
+
Dimension "Currency"
|
|
141
|
+
Unit "USD" of "Currency" factor 1 base "USD"
|
|
142
|
+
Unit "EUR" of "Currency" factor 1.07 base "USD"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Policy
|
|
146
|
+
|
|
147
|
+
```sea
|
|
148
|
+
Policy policy_name [per Constraint|Derivation|Obligation] [Obligation|Prohibition|Permission] [priority <number>] [@rationale "..."] [@tags ["a","b"]] [v1.0.0] as:
|
|
149
|
+
expression
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Example:
|
|
153
|
+
|
|
154
|
+
```sea
|
|
155
|
+
Policy payment_threshold per Constraint Obligation priority 5 @tags ["finance"] as:
|
|
156
|
+
forall f in flows: (f.resource = "Money" and f.quantity <= 10000)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Metric
|
|
160
|
+
|
|
161
|
+
```sea
|
|
162
|
+
Metric "name" as: expression
|
|
163
|
+
[@refresh_interval <number> "seconds"]
|
|
164
|
+
[@unit "USD"]
|
|
165
|
+
[@threshold <number>]
|
|
166
|
+
[@severity "critical"]
|
|
167
|
+
[@target <number>]
|
|
168
|
+
[@window <number> "seconds"]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Mapping
|
|
172
|
+
|
|
173
|
+
```sea
|
|
174
|
+
Mapping "name" for calm|kg|sbvr {
|
|
175
|
+
Entity "Customer" -> Target { "id": "customer_id" }
|
|
176
|
+
Flow "Money" -> Target { "from": true }
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Projection
|
|
181
|
+
|
|
182
|
+
```sea
|
|
183
|
+
Projection "name" for calm|kg|sbvr {
|
|
184
|
+
Entity "Customer" { "name": "customer_name" }
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Expressions (summary)
|
|
189
|
+
|
|
190
|
+
```sea
|
|
191
|
+
expression = or_expr
|
|
192
|
+
or_expr = and_expr ("or" and_expr)*
|
|
193
|
+
and_expr = not_expr ("and" not_expr)*
|
|
194
|
+
not_expr = "not" not_expr | comparison_expr
|
|
195
|
+
comparison_expr = additive_expr (comparison_op additive_expr)?
|
|
196
|
+
comparison_op = >= | <= | != | = | > | < | contains | startswith | endswith | matches | before | after | during | has_role
|
|
197
|
+
additive_expr = multiplicative_expr ((+|-) multiplicative_expr)*
|
|
198
|
+
multiplicative_expr = unary_expr ((*|/) unary_expr)*
|
|
199
|
+
unary_expr = ("-" | "!")* cast_expr
|
|
200
|
+
cast_expr = primary_expr ("as" string_literal)*
|
|
201
|
+
primary_expr = (expression) | group_by_expr | member_access | aggregation_expr | quantified_expr | instance_reference | literal | identifier
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Additional forms:
|
|
205
|
+
|
|
206
|
+
- **Quantifier**: `forall x in flows: (x.quantity > 0)` (the `in` keyword is case-insensitive).
|
|
207
|
+
- **Aggregation**: `sum(f in flows where f.resource = "Money": f.quantity as "USD")`.
|
|
208
|
+
- **Group by**: `group_by(f in flows: f.to) { sum(f.quantity) > 10 }`.
|
|
209
|
+
- **Member access**: `flow.quantity`, `entity.name`.
|
|
210
|
+
- **Casting**: `100 "ms" as "s"`, `f.quantity as "USD"`.
|
|
211
|
+
- **Literals**: strings, multiline strings, numbers, booleans, quantities (`100 "USD"`), time literals (`"2025-12-31T23:59:59Z"`), interval literals (`interval("09:00","17:00")`).
|
|
212
|
+
|
|
213
|
+
## Validation highlights
|
|
214
|
+
|
|
215
|
+
- Duplicate declarations in the same namespace are rejected.
|
|
216
|
+
- Unknown references (entities, resources, roles, units) fail validation.
|
|
217
|
+
- Unit conversions must align with declared dimensions or documented built-in units (see Time units below).
|
|
218
|
+
- ConceptChange annotations must include valid semantic versions.
|
|
219
|
+
- Policies and metrics use three-valued logic; undefined data may yield `Unknown`.
|
|
220
|
+
|
|
221
|
+
### Unit conversions & "as" usage
|
|
222
|
+
|
|
223
|
+
The SEA DSL supports unit literals and a general-purpose `as` coercion operator.
|
|
224
|
+
|
|
225
|
+
- **Quantity literal**: Write a number followed by a quoted unit (e.g., `100 "USD"`, `1_500 "USD"`, `100.5 "kg"`).
|
|
226
|
+
- **Explicit Casting**: Use the `as` operator to convert between compatible units in any expression.
|
|
227
|
+
```sea
|
|
228
|
+
1000 "ms" as "s" // Evaluates to 1 "s"
|
|
229
|
+
f.quantity as "USD" // Converts flow quantity to USD
|
|
230
|
+
```
|
|
231
|
+
- **Aggregation**: The `as` operator is commonly used in aggregations to normalize units before summing.
|
|
232
|
+
```sea
|
|
233
|
+
sum(f in flows where f.resource = "Money": f.quantity as "USD")
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
- **Declaration `as:` introducer**: The `as` keyword is also used in `Policy` and `Metric` declarations to introduce expression bodies (e.g. `Policy name as:`). This is a distinct syntactic usage.
|
|
237
|
+
|
|
238
|
+
### Built-in Time units
|
|
239
|
+
|
|
240
|
+
Common time units are available without explicit declarations. The compiler preloads the `Time` dimension with the following units:
|
|
241
|
+
|
|
242
|
+
- `s` (base, seconds)
|
|
243
|
+
- `ms` (milliseconds, factor `0.001` to `s`)
|
|
244
|
+
- `us` (microseconds, factor `0.000001` to `s`)
|
|
245
|
+
- `ns` (nanoseconds, factor `0.000000001` to `s`)
|
|
246
|
+
|
|
247
|
+
Examples such as `1000 "ms" as "s"` rely on these built-ins. Projects can still declare additional time units, and all conversions must remain dimensionally compatible.
|
|
248
|
+
|
|
249
|
+
## Workflow for grammar changes
|
|
250
|
+
|
|
251
|
+
1. Update `domainforge-core/grammar/sea.pest`.
|
|
252
|
+
2. Update AST and parser in `domainforge-core/src/parser/`.
|
|
253
|
+
3. Add parser tests in `domainforge-core/tests/parser_*.rs`.
|
|
254
|
+
4. Update projections (CALM/KG) if affected.
|
|
255
|
+
5. Refresh this document and relevant examples.
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# Primitives API Reference
|
|
2
|
+
|
|
3
|
+
This reference documents the core data structures used throughout DomainForge across Rust, Python, and TypeScript bindings. It mirrors the definitions in `domainforge-core/src/primitives/` and the exposed binding classes in `domainforge-core/src/python/` and `domainforge-core/src/typescript/`.
|
|
4
|
+
|
|
5
|
+
## Types
|
|
6
|
+
|
|
7
|
+
- `AttributeValue`: Union used for attribute payloads. Acceptable values include:
|
|
8
|
+
- `null`
|
|
9
|
+
- `boolean`
|
|
10
|
+
- `string`
|
|
11
|
+
- `Decimal` (arbitrary-precision decimal represented as a `string` in JSON)
|
|
12
|
+
- `bytes` (base64 encoded strings in JSON)
|
|
13
|
+
- `array` of `AttributeValue`
|
|
14
|
+
- `object` maps (`string` -> `AttributeValue`)
|
|
15
|
+
|
|
16
|
+
- `AttributeMap`: A map of `string` -> `AttributeValue`. Implementations use `IndexMap` for deterministic iteration.
|
|
17
|
+
|
|
18
|
+
- `Decimal`: Arbitrary-precision decimal used for quantities and numeric values. In JSON, `Decimal` values are serialized as strings to preserve precision (for example, `"1.07"`).
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
The SEA DSL produces a graph of primitives:
|
|
23
|
+
|
|
24
|
+
- **Entity**: actors or systems participating in flows.
|
|
25
|
+
- **Resource**: what is being transferred or measured.
|
|
26
|
+
- **Flow**: movement of a resource between entities.
|
|
27
|
+
- **ResourceInstance**: concrete instance of a resource with optional quantity.
|
|
28
|
+
- **Role**: label describing a participant category.
|
|
29
|
+
- **Relation**: predicate connecting roles, optionally tied to a flow.
|
|
30
|
+
- **Policy**: expression evaluated against the graph.
|
|
31
|
+
|
|
32
|
+
Each section below lists fields, constructors, methods, validation rules, and serialization notes.
|
|
33
|
+
|
|
34
|
+
## Entity
|
|
35
|
+
|
|
36
|
+
### Fields
|
|
37
|
+
|
|
38
|
+
- `id: Uuid` — stable identifier used in references.
|
|
39
|
+
- `name: String` — user-supplied name from the DSL.
|
|
40
|
+
- `namespace: Option<String>` — defaults to `"default"` when omitted.
|
|
41
|
+
- `attributes: IndexMap<String, AttributeValue>` — arbitrary key/value metadata.
|
|
42
|
+
|
|
43
|
+
### Constructors
|
|
44
|
+
|
|
45
|
+
- Rust: `Entity::new(name, namespace, attributes)`
|
|
46
|
+
- Python: `Entity(name: str, namespace: Optional[str] = None, attributes: Optional[dict] = None)`
|
|
47
|
+
- TypeScript: `new Entity(name: string, namespace?: string, attributes?: Record<string, AttributeValue>)`
|
|
48
|
+
|
|
49
|
+
### Methods
|
|
50
|
+
|
|
51
|
+
- Accessors for `id`, `name`, `namespace`, `attributes` (read-only in bindings).
|
|
52
|
+
- Equality based on `id`.
|
|
53
|
+
|
|
54
|
+
### Validation
|
|
55
|
+
|
|
56
|
+
- Names must be unique per namespace.
|
|
57
|
+
- Attributes accept string, number, or boolean values; nested objects are not supported.
|
|
58
|
+
|
|
59
|
+
## Resource
|
|
60
|
+
|
|
61
|
+
### Fields
|
|
62
|
+
|
|
63
|
+
- `id: Uuid`
|
|
64
|
+
- `name: String`
|
|
65
|
+
- `namespace: Option<String>`
|
|
66
|
+
- `unit: Option<String>` — concrete unit if bound.
|
|
67
|
+
- `has_units: bool` — true when declared with `units` keyword.
|
|
68
|
+
- `attributes: AttributeMap`
|
|
69
|
+
|
|
70
|
+
### Constructors
|
|
71
|
+
|
|
72
|
+
- Rust: `Resource::new(name, namespace, unit, has_units, attributes)`
|
|
73
|
+
- Python: `Resource(name, namespace=None, unit=None, has_units=False, attributes=None)`
|
|
74
|
+
- TypeScript: `new Resource(name, namespace?, unit?, hasUnits?, attributes?)`
|
|
75
|
+
|
|
76
|
+
### Methods
|
|
77
|
+
|
|
78
|
+
- Getters for `id`, `name`, `namespace`, `unit`, `has_units`, `attributes`.
|
|
79
|
+
- `is_dimensional()` in Rust to check units.
|
|
80
|
+
|
|
81
|
+
### Validation
|
|
82
|
+
|
|
83
|
+
- If `unit` is set, it must resolve to a declared unit; otherwise validation fails.
|
|
84
|
+
- If `has_units` is false, providing quantities with units will error during validation.
|
|
85
|
+
|
|
86
|
+
## Flow
|
|
87
|
+
|
|
88
|
+
### Fields
|
|
89
|
+
|
|
90
|
+
- `id: Uuid`
|
|
91
|
+
- `resource_id: Uuid`
|
|
92
|
+
- `from: Uuid`
|
|
93
|
+
- `to: Uuid`
|
|
94
|
+
- `quantity: Option<Quantity>` — `Quantity { value: Decimal, unit: Option<String> }`
|
|
95
|
+
- `namespace: Option<String>`
|
|
96
|
+
- `attributes: AttributeMap`
|
|
97
|
+
|
|
98
|
+
### Constructors
|
|
99
|
+
|
|
100
|
+
- Rust: `Flow::new(resource_id, from, to, quantity, namespace, attributes)`
|
|
101
|
+
- Python: `Flow(resource_id: str, from_id: str, to_id: str, quantity: Optional[Quantity] = None, namespace: Optional[str] = None, attributes: Optional[dict] = None)`
|
|
102
|
+
- TypeScript: `new Flow(resourceId: string, fromId: string, toId: string, quantity?: Quantity, namespace?: string, attributes?: Record<string, AttributeValue>)`
|
|
103
|
+
|
|
104
|
+
### Methods
|
|
105
|
+
|
|
106
|
+
- Accessors for `id`, `resource_id`, `from_id`, `to_id`, `quantity`, `namespace`, `attributes`.
|
|
107
|
+
- `quantity.as_unit("<Unit>")` is available in Rust for conversions; bindings expose quantity fields directly.
|
|
108
|
+
|
|
109
|
+
### Validation
|
|
110
|
+
|
|
111
|
+
- `resource_id`, `from`, and `to` must refer to existing resources/entities in the same namespace.
|
|
112
|
+
- Quantity units must match the resource dimension or be convertible.
|
|
113
|
+
|
|
114
|
+
## ResourceInstance
|
|
115
|
+
|
|
116
|
+
### Fields
|
|
117
|
+
|
|
118
|
+
- `id: Uuid`
|
|
119
|
+
- `name: String` — instance name from DSL `Instance "name"`.
|
|
120
|
+
- `resource_id: Uuid`
|
|
121
|
+
- `quantity: Option<Quantity>`
|
|
122
|
+
- `namespace: Option<String>`
|
|
123
|
+
- `attributes: AttributeMap`
|
|
124
|
+
|
|
125
|
+
### Constructors
|
|
126
|
+
|
|
127
|
+
- Rust: `ResourceInstance::new(name, resource_id, quantity, namespace, attributes)`
|
|
128
|
+
- Python: `ResourceInstance(name: str, resource_id: str, quantity: Optional[Quantity] = None, namespace: Optional[str] = None, attributes: Optional[dict] = None)`
|
|
129
|
+
- TypeScript: `new ResourceInstance(name: string, resourceId: string, quantity?: Quantity, namespace?: string, attributes?: Record<string, AttributeValue>)`
|
|
130
|
+
|
|
131
|
+
### Methods
|
|
132
|
+
|
|
133
|
+
- Accessors for `id`, `name`, `resource_id`, `quantity`, `namespace`, `attributes`.
|
|
134
|
+
- Instances can be added to a graph via `Graph.add_instance`/`addInstance`.
|
|
135
|
+
|
|
136
|
+
### Validation
|
|
137
|
+
|
|
138
|
+
- Resource must exist.
|
|
139
|
+
- Quantity validation mirrors flows.
|
|
140
|
+
|
|
141
|
+
## Role
|
|
142
|
+
|
|
143
|
+
### Fields
|
|
144
|
+
|
|
145
|
+
- `id: Uuid`
|
|
146
|
+
- `name: String`
|
|
147
|
+
- `namespace: Option<String>`
|
|
148
|
+
- `attributes: AttributeMap`
|
|
149
|
+
|
|
150
|
+
### Constructors
|
|
151
|
+
|
|
152
|
+
- Rust: `Role::new(name, namespace, attributes)`
|
|
153
|
+
- Python: `Role(name: str, namespace: Optional[str] = None, attributes: Optional[dict] = None)`
|
|
154
|
+
- TypeScript: `new Role(name: string, namespace?: string, attributes?: Record<string, AttributeValue>)`
|
|
155
|
+
|
|
156
|
+
### Methods
|
|
157
|
+
|
|
158
|
+
- Accessors: `id`, `name`, `namespace`, `attributes`.
|
|
159
|
+
- Roles are used primarily as references from relations.
|
|
160
|
+
|
|
161
|
+
### Validation
|
|
162
|
+
|
|
163
|
+
- Names unique per namespace.
|
|
164
|
+
- Attributes follow the same rules as entities.
|
|
165
|
+
|
|
166
|
+
## Relation
|
|
167
|
+
|
|
168
|
+
### Fields
|
|
169
|
+
|
|
170
|
+
- `id: Uuid`
|
|
171
|
+
- `name: String`
|
|
172
|
+
- `subject_role_id: Uuid`
|
|
173
|
+
- `predicate: String`
|
|
174
|
+
- `object_role_id: Uuid`
|
|
175
|
+
- `via_flow_id: Option<Uuid>`
|
|
176
|
+
- `namespace: Option<String>`
|
|
177
|
+
- `attributes: AttributeMap`
|
|
178
|
+
|
|
179
|
+
### Constructors
|
|
180
|
+
|
|
181
|
+
- Rust: `Relation::new(name, namespace, subject_role, predicate, object_role, via_flow)`
|
|
182
|
+
- Python: `Relation(name: str, subject_role_id: str, predicate: str, object_role_id: str, via_flow_id: Optional[str] = None, namespace: Optional[str] = None, attributes: Optional[dict] = None)`
|
|
183
|
+
- TypeScript: `new Relation(name: string, subjectRoleId: string, predicate: string, objectRoleId: string, viaFlowId?: string, namespace?: string, attributes?: Record<string, AttributeValue>)`
|
|
184
|
+
|
|
185
|
+
### Methods
|
|
186
|
+
|
|
187
|
+
- Accessors for all fields.
|
|
188
|
+
- Relations are added to the graph via `Graph.add_relation`/`addRelation`.
|
|
189
|
+
|
|
190
|
+
### Validation
|
|
191
|
+
|
|
192
|
+
- Subject/object role IDs must exist.
|
|
193
|
+
- `via_flow_id`, if present, must point to a declared flow.
|
|
194
|
+
- Namespace alignment is enforced with the referenced roles/flows.
|
|
195
|
+
|
|
196
|
+
## Policy
|
|
197
|
+
|
|
198
|
+
Policies are represented as serialized JSON across bindings and evaluated via graph methods.
|
|
199
|
+
|
|
200
|
+
- Rust: `Graph::evaluate_policy(policy: Policy) -> EvaluationResult`
|
|
201
|
+
- Python: `Graph.evaluate_policy(policy_json: str) -> PolicyResult`
|
|
202
|
+
- TypeScript: `graph.evaluatePolicy(policyJson: string): PolicyResult`
|
|
203
|
+
|
|
204
|
+
Validation: policies must reference existing entities/resources/flows. Unknown references produce `Unknown` outcomes in three-valued logic.
|
|
205
|
+
|
|
206
|
+
## Quantity type
|
|
207
|
+
|
|
208
|
+
Quantities are reused by flows and instances.
|
|
209
|
+
|
|
210
|
+
- Fields: `value: Decimal`, `unit: Option<String>`
|
|
211
|
+
- Python: `Quantity(value: Decimal, unit: Optional[str])`
|
|
212
|
+
- TypeScript: `{ value: number | string; unit?: string }` — The TypeScript bindings return a `number` for convenience; however, when serializing to JSON the Decimal is represented as a `string` to preserve precision. Consumers should prefer string representation when round-tripping or when precise decimal fidelity is required.
|
|
213
|
+
|
|
214
|
+
Conversions follow the dimension/unit registry; mismatches are surfaced as validation errors.
|
|
215
|
+
|
|
216
|
+
## Graph methods (shared subset)
|
|
217
|
+
|
|
218
|
+
While not primitives themselves, the graph API is the primary way to create and retrieve primitives.
|
|
219
|
+
|
|
220
|
+
Common methods across bindings:
|
|
221
|
+
|
|
222
|
+
- Add: `add_entity`, `add_resource`, `add_flow`, `add_instance`, `add_role`, `add_relation`
|
|
223
|
+
- Counts: `entity_count`, `resource_count`, `flow_count`, `instance_count`, `role_count`, `relation_count`, `pattern_count`
|
|
224
|
+
- Lookup by ID: `get_entity`, `get_resource`, `get_flow`, `get_instance`
|
|
225
|
+
- Lookup by name: `find_entity_by_name`, `find_resource_by_name`, `find_role_by_name`
|
|
226
|
+
- Collection accessors: `all_entities`, `all_resources`, `all_flows`, `all_instances`, `all_roles`, `all_relations`
|
|
227
|
+
|
|
228
|
+
## Serialization
|
|
229
|
+
|
|
230
|
+
Primitives serialize to JSON for interop. The canonical Rust structures derive `Serialize`/`Deserialize`; bindings reuse those shapes.
|
|
231
|
+
|
|
232
|
+
Example `Resource` JSON:
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"id": "3a3e5d08-9c4d-4f59-a8af-5f52a1d69c20",
|
|
237
|
+
"name": "Money",
|
|
238
|
+
"namespace": "finance",
|
|
239
|
+
"unit": "USD",
|
|
240
|
+
"has_units": true,
|
|
241
|
+
"attributes": {"type": "currency"}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### CALM mapping
|
|
246
|
+
|
|
247
|
+
- Entities map to `models[n].entities`.
|
|
248
|
+
- Resources map to `models[n].resources` with units preserved.
|
|
249
|
+
- Roles/relations emit as typed facts (`subjectRole`, `predicate`, `objectRole`).
|
|
250
|
+
- Flows and instances become facts with `sea:id` linking back to DSL IDs.
|
|
251
|
+
|
|
252
|
+
See `calm-mapping.md` for full mapping tables.
|
|
253
|
+
|
|
254
|
+
## Equality and hashing
|
|
255
|
+
|
|
256
|
+
- Equality for primitives is defined on `id` only; names/attributes do not affect equality.
|
|
257
|
+
- Hashing uses UUID bytes to ensure stable map keys across projections.
|
|
258
|
+
|
|
259
|
+
## Thread safety
|
|
260
|
+
|
|
261
|
+
- Rust structs are `Send + Sync` where possible; binding wrappers ensure ownership rules are upheld.
|
|
262
|
+
- Python uses PyO3 `PyClass` wrappers; TypeScript uses `napi` classes backed by Arc-managed Rust data.
|
|
263
|
+
|
|
264
|
+
## Error handling
|
|
265
|
+
|
|
266
|
+
- Constructor errors surface as `PyValueError` in Python and `Error` in TypeScript when references are invalid.
|
|
267
|
+
- Semantic validation returns `ValidationError` (Rust) with codes listed in `error-codes.md`.
|
|
268
|
+
|
|
269
|
+
## Examples
|
|
270
|
+
|
|
271
|
+
### Creating primitives in Python
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
from domainforge import Graph, Entity, Resource, Flow, Role, Relation
|
|
275
|
+
|
|
276
|
+
graph = Graph()
|
|
277
|
+
user = Entity("User")
|
|
278
|
+
money = Resource("Money", has_units=True)
|
|
279
|
+
payer = Role("Payer")
|
|
280
|
+
payee = Role("Payee")
|
|
281
|
+
flow = Flow(money.id, user.id, user.id)
|
|
282
|
+
relation = Relation("Payment", payer.id, "pays", payee.id, flow.id)
|
|
283
|
+
|
|
284
|
+
graph.add_entity(user)
|
|
285
|
+
graph.add_resource(money)
|
|
286
|
+
graph.add_flow(flow)
|
|
287
|
+
graph.add_role(payer)
|
|
288
|
+
graph.add_role(payee)
|
|
289
|
+
graph.add_relation(relation)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Creating primitives in TypeScript
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
import { Graph, Entity, Resource, Flow, Role, Relation } from "@godspeedai/domainforge";
|
|
296
|
+
|
|
297
|
+
const graph = new Graph();
|
|
298
|
+
const user = new Entity("User");
|
|
299
|
+
const money = new Resource("Money", undefined, undefined, true);
|
|
300
|
+
const payer = new Role("Payer");
|
|
301
|
+
const payee = new Role("Payee");
|
|
302
|
+
const flow = new Flow(money.id, user.id, user.id);
|
|
303
|
+
const relation = new Relation("Payment", payer.id, "pays", payee.id, flow.id);
|
|
304
|
+
|
|
305
|
+
graph.addEntity(user);
|
|
306
|
+
graph.addResource(money);
|
|
307
|
+
graph.addFlow(flow);
|
|
308
|
+
graph.addRole(payer);
|
|
309
|
+
graph.addRole(payee);
|
|
310
|
+
graph.addRelation(relation);
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## See also
|
|
314
|
+
|
|
315
|
+
- `docs/new_docs/reference/python-api.md` and `typescript-api.md` for method-level binding docs.
|
|
316
|
+
- `docs/new_docs/reference/cli-commands.md` for CLI operations over these primitives.
|
|
317
|
+
- `docs/new_docs/how-tos/parse-sea-files.md` for creating graphs from DSL input.
|