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,53 @@
|
|
|
1
|
+
# Documentation Guidelines — Diataxis + MECE
|
|
2
|
+
|
|
3
|
+
This file describes expected structure and minimal content for new documentation pages under `docs/new_docs`.
|
|
4
|
+
|
|
5
|
+
## General guidelines
|
|
6
|
+
|
|
7
|
+
- Write for a single audience per document.
|
|
8
|
+
- Keep documents focused: one main goal or concept.
|
|
9
|
+
- Use examples and short runnable snippets.
|
|
10
|
+
- Ensure linkages: each tutorial should link to how-tos and references.
|
|
11
|
+
|
|
12
|
+
## MECE checklist per category
|
|
13
|
+
|
|
14
|
+
### Tutorials
|
|
15
|
+
|
|
16
|
+
- Audience and goal
|
|
17
|
+
- Prereqs
|
|
18
|
+
- Step-by-step instructions with runnable examples
|
|
19
|
+
- Troubleshooting
|
|
20
|
+
- Related docs and next steps
|
|
21
|
+
|
|
22
|
+
### How-Tos
|
|
23
|
+
|
|
24
|
+
- Short goal/one-liner
|
|
25
|
+
- Step-by-step instructions (copy-paste-able)
|
|
26
|
+
- Common pitfalls and minimal verification steps
|
|
27
|
+
|
|
28
|
+
### Reference
|
|
29
|
+
|
|
30
|
+
- Stable, canonical API signatures and CLI options
|
|
31
|
+
- Example code snippets per API
|
|
32
|
+
- Version and compatibility notes
|
|
33
|
+
|
|
34
|
+
### Explanations
|
|
35
|
+
|
|
36
|
+
- Problem statement and background
|
|
37
|
+
- Conceptual diagrams and tradeoffs
|
|
38
|
+
- When/how to use the concept and links to examples
|
|
39
|
+
|
|
40
|
+
### Playbooks
|
|
41
|
+
|
|
42
|
+
- Clear scope and preconditions
|
|
43
|
+
- Step-by-step runbook with commands to run
|
|
44
|
+
- Safety checks and rollback steps
|
|
45
|
+
- Escalation/contacts
|
|
46
|
+
|
|
47
|
+
## Tips for maintainers
|
|
48
|
+
|
|
49
|
+
- Add `tags` at the top or metadata in the document so it can be surfaced by search/index.
|
|
50
|
+
- When adding new reference docs, ensure automated tests (where relevant) are added to `tests/` or `typescript-tests/`.
|
|
51
|
+
- Keep a single source of truth and avoid duplicated explanations. Link instead of copy-paste when possible.
|
|
52
|
+
|
|
53
|
+
By following these guidelines we achieve clarity, maintainability, and pragmatic coverage for new users, engineers, and operators.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Explanations — DomainForge
|
|
2
|
+
|
|
3
|
+
Purpose: Provide background information, architecture, and conceptual explanations to help users understand why things work the way they do.
|
|
4
|
+
|
|
5
|
+
MECE checklist:
|
|
6
|
+
|
|
7
|
+
- Intended audience and scope
|
|
8
|
+
- Conceptual diagrams and textual explanation
|
|
9
|
+
- Trades and rationale
|
|
10
|
+
- Links to related Reference and How-Tos
|
|
11
|
+
|
|
12
|
+
## Current Explanations
|
|
13
|
+
|
|
14
|
+
- [Architecture Overview](architecture-overview.md)
|
|
15
|
+
- [Graph Store Design](graph-store-design.md)
|
|
16
|
+
- [Cross-Language Binding Strategy](cross-language-binding-strategy.md)
|
|
17
|
+
- [Policy Evaluation Logic](policy-evaluation-logic.md)
|
|
18
|
+
- [Three-Valued Logic](three-valued-logic.md)
|
|
19
|
+
- [Semantic Modeling Concepts](semantic-modeling-concepts.md)
|
|
20
|
+
- [Versioning Strategy](versioning-strategy.md)
|
|
21
|
+
- [Performance Benchmarks](performance-benchmarks.md)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Architecture Overview
|
|
2
|
+
|
|
3
|
+
DomainForge (SEA) is built on a **Rust-first, multi-language** architecture designed to provide a single source of truth for semantic modeling while remaining accessible to developers in Python, TypeScript, and the web.
|
|
4
|
+
|
|
5
|
+
## High-Level Architecture
|
|
6
|
+
|
|
7
|
+
The system is organized as a central Rust core that projects its functionality outwards to other ecosystems through high-performance bindings.
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
graph TD
|
|
11
|
+
subgraph "Core (Rust)"
|
|
12
|
+
Grammar[Pest Grammar] --> Parser[AST Parser]
|
|
13
|
+
Parser --> Primitives[Core Primitives]
|
|
14
|
+
Primitives --> Graph[Graph Store]
|
|
15
|
+
Primitives --> Policy[Policy Engine]
|
|
16
|
+
Graph --> CALM[CALM Export]
|
|
17
|
+
Graph --> KG[Knowledge Graph]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
subgraph "Bindings"
|
|
21
|
+
PyO3[PyO3 Bindings]
|
|
22
|
+
Napi[napi-rs Bindings]
|
|
23
|
+
Wasm[wasm-bindgen]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
subgraph "Ecosystems"
|
|
27
|
+
Python[Python SDK]
|
|
28
|
+
TS[TypeScript SDK]
|
|
29
|
+
Browser[Web/React Apps]
|
|
30
|
+
CLI[CLI Tools]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Primitives --> PyO3
|
|
34
|
+
Primitives --> Napi
|
|
35
|
+
Primitives --> Wasm
|
|
36
|
+
|
|
37
|
+
PyO3 --> Python
|
|
38
|
+
Napi --> TS
|
|
39
|
+
Wasm --> Browser
|
|
40
|
+
Graph --> CLI
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Core Components (`domainforge-core`)
|
|
44
|
+
|
|
45
|
+
The `domainforge-core` crate is the canonical implementation of the Semantic Enterprise Architecture DSL.
|
|
46
|
+
|
|
47
|
+
### 1. Grammar & Parsing
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
- **Source**: `domainforge-core/grammar/sea.pest`
|
|
56
|
+
|
|
57
|
+
- **Technology**: [Pest](https://pest.rs/) (PEG parser)
|
|
58
|
+
|
|
59
|
+
- **Role**: Defines the authoritative syntax. All language changes start here. The parser generates an Abstract Syntax Tree (AST) which is then lowered into semantic primitives.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### 2. Primitives
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
- **Location**: `domainforge-core/src/primitives/`
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
- **Types**: `Entity`, `Resource`, `Flow`, `Instance`, `Policy`
|
|
73
|
+
- **Role**: These are the domain objects. They are rich structs containing metadata, configuration, and relationships. They are designed to be serialized/deserialized and passed across FFI boundaries.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### 3. Graph Store
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
- **Location**: `domainforge-core/src/graph/mod.rs`
|
|
81
|
+
- **Technology**: `IndexMap` (for deterministic iteration)
|
|
82
|
+
|
|
83
|
+
- **Role**: Acts as the in-memory database for the model. It resolves references (e.g., linking a Flow to its source Entity) and enables graph traversal algorithms.
|
|
84
|
+
|
|
85
|
+
### 4. Policy Engine
|
|
86
|
+
|
|
87
|
+
- **Location**: `domainforge-core/src/policy/`
|
|
88
|
+
- **Logic**: Three-valued logic (True, False, Unknown)
|
|
89
|
+
- **Role**: Evaluates constraints against the model. It handles type inference and expression evaluation.
|
|
90
|
+
|
|
91
|
+
## Binding Strategy
|
|
92
|
+
|
|
93
|
+
We do not reimplement logic in other languages. Instead, we wrap the Rust types.
|
|
94
|
+
|
|
95
|
+
- **Python**: Uses [PyO3](https://pyo3.rs/). Rust structs are exposed as Python classes. Methods call directly into Rust code.
|
|
96
|
+
- **TypeScript**: Uses [napi-rs](https://napi.rs/). High-performance Node.js addons.
|
|
97
|
+
- **WASM**: Uses [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen). Allows the full compiler and policy engine to run in the browser.
|
|
98
|
+
|
|
99
|
+
## Key Design Principles
|
|
100
|
+
|
|
101
|
+
1. **Canonical Core**: Business logic exists only in Rust. If a bug is fixed in Core, it is fixed for Python, TS, and CLI simultaneously.
|
|
102
|
+
2. **Deterministic Execution**: We use `IndexMap` instead of `HashMap` to ensure that policy evaluation order and export formats are stable across runs.
|
|
103
|
+
3. **Zero-Copy (where possible)**: Bindings attempt to reference memory rather than copy it, though serialization is sometimes necessary for complex object graphs.
|
|
104
|
+
|
|
105
|
+
## See Also
|
|
106
|
+
|
|
107
|
+
- [Semantic Modeling Concepts](semantic-modeling-concepts.md)
|
|
108
|
+
- [Cross-Language Binding Strategy](cross-language-binding-strategy.md)
|
|
109
|
+
- [Graph Store Design](graph-store-design.md)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Cross-Language Binding Strategy
|
|
2
|
+
|
|
3
|
+
DomainForge is designed to be usable from Python, TypeScript, and WebAssembly while maintaining a single, high-performance Rust core. This document explains how we achieve this.
|
|
4
|
+
|
|
5
|
+
## The "Wrapper" Pattern
|
|
6
|
+
|
|
7
|
+
We do not rewrite business logic. We wrap Rust structs in language-specific containers.
|
|
8
|
+
|
|
9
|
+
### Python (PyO3)
|
|
10
|
+
|
|
11
|
+
- **Crate**: `pyo3`
|
|
12
|
+
- **Implementation**: `domainforge-core/src/python/`
|
|
13
|
+
- **Mechanism**: Rust structs are annotated with `#[pyclass]`. Methods are annotated with `#[pymethods]`.
|
|
14
|
+
- **Memory**: Python objects hold a reference to the underlying Rust data. When the Python object is garbage collected, the Rust memory is freed (if no other references exist).
|
|
15
|
+
|
|
16
|
+
### TypeScript (napi-rs)
|
|
17
|
+
|
|
18
|
+
- **Crate**: `napi`
|
|
19
|
+
- **Implementation**: `domainforge-core/src/typescript/`
|
|
20
|
+
- **Mechanism**: We define structs that mirror the core primitives but are compatible with N-API.
|
|
21
|
+
- **Async**: Heavy operations (like parsing large files) can be offloaded to the libuv thread pool to avoid blocking the Node.js event loop.
|
|
22
|
+
|
|
23
|
+
### WebAssembly (wasm-bindgen)
|
|
24
|
+
|
|
25
|
+
- **Crate**: `wasm-bindgen`
|
|
26
|
+
- **Implementation**: `domainforge-core/src/wasm/`
|
|
27
|
+
- **Mechanism**: Rust types are compiled to WASM. JavaScript "glue code" is generated to bridge the gap.
|
|
28
|
+
- **Constraint**: WASM runs in a sandbox. File I/O is not directly available; input must be passed as strings or byte arrays.
|
|
29
|
+
|
|
30
|
+
## Synchronization Rules
|
|
31
|
+
|
|
32
|
+
To maintain consistency, we follow strict rules:
|
|
33
|
+
|
|
34
|
+
1. **Core First**: Changes happen in `domainforge-core` first.
|
|
35
|
+
2. **Update All Bindings**: If a field is added to `Entity` in Rust, it *must* be exposed in Python and TypeScript immediately.
|
|
36
|
+
3. **Unified Testing**: `just all-tests` runs the test suites for all languages. A failure in Python bindings blocks the Rust PR.
|
|
37
|
+
|
|
38
|
+
## Error Handling
|
|
39
|
+
|
|
40
|
+
Rust errors (`Result<T, E>`) are mapped to language-specific exceptions:
|
|
41
|
+
|
|
42
|
+
- **Rust**: `domainforge_core::error::SeaError`
|
|
43
|
+
- **Python**: `sea.SeaError` (inherits from `Exception`)
|
|
44
|
+
- **TypeScript**: `Error` object with specific code properties.
|
|
45
|
+
|
|
46
|
+
## Build isolation and feature flags
|
|
47
|
+
|
|
48
|
+
- Cargo features are mutually exclusive for Python and TypeScript builds; do **not** enable both in a single build.
|
|
49
|
+
|
|
50
|
+
```toml
|
|
51
|
+
[features]
|
|
52
|
+
default = []
|
|
53
|
+
python = ["pyo3", "pythonize"]
|
|
54
|
+
typescript = ["napi", "napi-derive"]
|
|
55
|
+
three_valued_logic = []
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- Build commands by target:
|
|
59
|
+
- **Python**: `maturin develop --features python,three_valued_logic` (or `maturin build --release ...`), then `pytest`/`just python-test`.
|
|
60
|
+
- **TypeScript**: `npm run build` (or `cargo build --features typescript,three_valued_logic` for debugging), then `npm test`.
|
|
61
|
+
- **WASM**: `wasm-pack build domainforge-core --target web --features wasm` (see the WASM tutorial for serving).
|
|
62
|
+
- When switching between bindings, run `cargo clean` to avoid cross-contamination of artifacts and symbol leaks.
|
|
63
|
+
|
|
64
|
+
## See Also
|
|
65
|
+
|
|
66
|
+
- [Architecture Overview](architecture-overview.md)
|
|
67
|
+
- [Adding a New Primitive](../playbooks/adding-new-primitive.md)
|
|
68
|
+
- [Troubleshoot NAPI Builds](../how-tos/troubleshoot-napi-builds.md)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Graph Store Design
|
|
2
|
+
|
|
3
|
+
The Graph Store (`domainforge-core/src/graph/mod.rs`) is the in-memory database that holds the semantic model. It is designed for performance, correctness, and deterministic behavior.
|
|
4
|
+
|
|
5
|
+
## Data Structure: IndexMap
|
|
6
|
+
|
|
7
|
+
We use `indexmap::IndexMap` instead of the standard library's `HashMap` for all primary collections (Entities, Flows, Resources).
|
|
8
|
+
|
|
9
|
+
### Why?
|
|
10
|
+
|
|
11
|
+
1. **Determinism**: `HashMap` iteration order is randomized (SipHash). This means running the same policy on the same model could produce errors in a different order, or result in different generated code output (e.g., Terraform files changing order every run).
|
|
12
|
+
2. **Stability**: `IndexMap` preserves insertion order. This ensures that `forall` loops in policies always visit nodes in a predictable sequence.
|
|
13
|
+
|
|
14
|
+
## Node and Edge Model
|
|
15
|
+
|
|
16
|
+
The graph is not a generic adjacency matrix. It is a structured collection of typed stores:
|
|
17
|
+
|
|
18
|
+
```rust
|
|
19
|
+
pub struct Graph {
|
|
20
|
+
pub entities: IndexMap<ConceptId, Entity>,
|
|
21
|
+
pub resources: IndexMap<ConceptId, Resource>,
|
|
22
|
+
pub flows: Vec<Flow>, // Flows are edges
|
|
23
|
+
// ...
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- **Nodes**: Entities and Resources are nodes. They are indexed by `ConceptId` (a hash of namespace + name).
|
|
28
|
+
- **Edges**: Flows are directed edges connecting nodes. They are stored separately to allow fast iteration over all interactions.
|
|
29
|
+
|
|
30
|
+
## Query Patterns
|
|
31
|
+
|
|
32
|
+
The graph supports specific access patterns optimized for policy evaluation:
|
|
33
|
+
|
|
34
|
+
- **Lookup by ID**: O(1) access to any Entity or Resource.
|
|
35
|
+
- **Flow Traversal**: "Get all flows originating from Entity X".
|
|
36
|
+
- **Type Filtering**: "Get all Resources of type 'database'".
|
|
37
|
+
|
|
38
|
+
## Performance Characteristics
|
|
39
|
+
|
|
40
|
+
- **Parsing**: Linear time relative to file size.
|
|
41
|
+
- **Graph Construction**: Near-linear. Resolution of references happens in a second pass.
|
|
42
|
+
- **Policy Evaluation**: Depends on complexity. Simple `forall` is O(N). Nested quantifiers can be O(N^2).
|
|
43
|
+
|
|
44
|
+
## See Also
|
|
45
|
+
|
|
46
|
+
- [Architecture Overview](architecture-overview.md)
|
|
47
|
+
- [Policy Evaluation Logic](policy-evaluation-logic.md)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Performance Benchmarks for Three-Valued Logic
|
|
2
|
+
|
|
3
|
+
This note summarizes the tri-state (three-valued) performance benchmarks and how to run them.
|
|
4
|
+
|
|
5
|
+
## Why it matters
|
|
6
|
+
|
|
7
|
+
Policy evaluation defaults to three-valued logic. Benchmarks show the runtime overhead is modest (≈10% worst case) and often neutral or faster when data contains `Unknown` values.
|
|
8
|
+
|
|
9
|
+
## How to run
|
|
10
|
+
|
|
11
|
+
- **Criterion suite (recommended)**: statistical results and HTML reports.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd domainforge-core
|
|
15
|
+
cargo bench --bench null_overhead
|
|
16
|
+
# view reports under target/criterion/
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- **Quick micro-benchmark (sanity)**:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
cargo test --release -p domainforge-core --lib -- --ignored bench_microbench --nocapture
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Results snapshot
|
|
26
|
+
|
|
27
|
+
- Criterion output shows lower/median/upper bounds of the 95% confidence interval. Use the median for comparisons.
|
|
28
|
+
- Sample findings from recent runs (1k items):
|
|
29
|
+
|
|
30
|
+
| Benchmark | Median (µs) | vs strict | Notes |
|
|
31
|
+
| --- | --- | --- | --- |
|
|
32
|
+
| Strict sum (baseline) | 8.23 | baseline | No null handling |
|
|
33
|
+
| Nullable, 0% nulls | 9.09 | +10.4% | Worst case |
|
|
34
|
+
| Nullable, 10% nulls | 7.61 | -7.5% | Typical |
|
|
35
|
+
| Nullable, 50% nulls | 4.05 | -51% | Sparse |
|
|
36
|
+
| Non-null, 10% nulls | 7.33 | -11% | Filters nulls |
|
|
37
|
+
|
|
38
|
+
- Micro-benchmark sanity check: ~4.9% overhead at 10% nulls.
|
|
39
|
+
|
|
40
|
+
## When to re-run
|
|
41
|
+
|
|
42
|
+
- After changing policy evaluation, `ThreeValuedBool`, or Decimal handling.
|
|
43
|
+
- Before releases to confirm no regressions in tri-state toggling or parsing hot paths.
|
|
44
|
+
|
|
45
|
+
## Appendix: raw outputs and files
|
|
46
|
+
|
|
47
|
+
- Benchmark code: `domainforge-core/benches/null_overhead.rs`
|
|
48
|
+
- Micro-bench: `domainforge-core/src/policy/three_valued_microbench.rs`
|
|
49
|
+
- Sample raw Criterion output:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
sum_baseline/sum_strict_1k
|
|
53
|
+
time: [7.9087 µs 8.2293 µs 8.6586 µs]
|
|
54
|
+
|
|
55
|
+
three_valued_sum/sum_nullable/0pct_null
|
|
56
|
+
time: [8.5873 µs 9.0864 µs 9.6445 µs]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## See also
|
|
60
|
+
|
|
61
|
+
- [Three-Valued Logic](three-valued-logic.md)
|
|
62
|
+
- [Policy Evaluation Logic](policy-evaluation-logic.md)
|
|
63
|
+
- [CLI Commands](../reference/cli-commands.md) (`bench` targets are Rust-only; CI can run `cargo bench`)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Policy Evaluation Logic
|
|
2
|
+
|
|
3
|
+
The policy engine is the brain of DomainForge. It verifies that an architecture model adheres to defined rules. This document explains how policies are parsed, evaluated, and enforced.
|
|
4
|
+
|
|
5
|
+
## Evaluation Flow
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph LR
|
|
9
|
+
A[Source .sea File] --> B[Parser]
|
|
10
|
+
B --> C[AST]
|
|
11
|
+
C --> D[Graph Store]
|
|
12
|
+
D --> E[Policy Engine]
|
|
13
|
+
E --> F{Result}
|
|
14
|
+
F -->|Pass| G[Success]
|
|
15
|
+
F -->|Fail| H[Validation Error]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Expression Parsing
|
|
19
|
+
|
|
20
|
+
Policies are written in a subset of the SEA DSL designed for logic. Expressions are parsed into an expression tree defined in `domainforge-core/src/policy/expression.rs`.
|
|
21
|
+
|
|
22
|
+
Common expression types:
|
|
23
|
+
|
|
24
|
+
- **Quantifiers**: `forall`, `exists`
|
|
25
|
+
- **Comparisons**: `==`, `!=`, `>`, `<`
|
|
26
|
+
- **Logical Operators**: `and`, `or`, `not`, `implies`
|
|
27
|
+
- **Property Access**: `f.from.type`
|
|
28
|
+
|
|
29
|
+
## Variable Binding
|
|
30
|
+
|
|
31
|
+
When a quantifier is evaluated (e.g., `forall f in Flow`), the engine:
|
|
32
|
+
|
|
33
|
+
1. Iterates deterministically over the collection (`Flow`).
|
|
34
|
+
2. Binds the current item to the variable name (`f`).
|
|
35
|
+
3. Evaluates the inner expression body with this context.
|
|
36
|
+
|
|
37
|
+
## Evaluation Order
|
|
38
|
+
|
|
39
|
+
Evaluation is strictly deterministic due to the use of `IndexMap` in the underlying graph store.
|
|
40
|
+
|
|
41
|
+
1. **Global Scope**: Constants and global definitions are loaded.
|
|
42
|
+
2. **Policy Iteration**: Policies are evaluated in the order they appear in the source file (or import order).
|
|
43
|
+
3. **Short-Circuiting**:
|
|
44
|
+
- `forall`: Stops at the first `False` result (returns `False`).
|
|
45
|
+
- `exists`: Stops at the first `True` result (returns `True`).
|
|
46
|
+
|
|
47
|
+
## Three-Valued Logic
|
|
48
|
+
|
|
49
|
+
The engine uses Kleene's three-valued logic (`True`, `False`, `Unknown`).
|
|
50
|
+
|
|
51
|
+
- If a property is missing (e.g., `f.encryption`), the comparison returns `Unknown` rather than crashing or defaulting to false.
|
|
52
|
+
- This allows policies to distinguish between "bad architecture" (False) and "incomplete architecture" (Unknown).
|
|
53
|
+
|
|
54
|
+
### Runtime toggle
|
|
55
|
+
|
|
56
|
+
- Three-valued logic is **on by default**. Switch to strict boolean evaluation via:
|
|
57
|
+
- Rust: `graph.set_evaluation_mode(false)`
|
|
58
|
+
- Python: `graph.set_evaluation_mode(False)`
|
|
59
|
+
- TypeScript/WASM: `graph.setEvaluationMode(false)`
|
|
60
|
+
- Use this only for environments that require binary pass/fail semantics; unknown facts will then be treated as errors.
|
|
61
|
+
|
|
62
|
+
## Side Effects
|
|
63
|
+
|
|
64
|
+
Policy evaluation is **read-only**. It cannot modify the graph. It produces a list of `ValidationResult` objects, which contain:
|
|
65
|
+
- The policy name.
|
|
66
|
+
- The result (Pass/Fail/Unknown).
|
|
67
|
+
- A trace of the specific elements that caused a failure (e.g., the specific Flow that violated the rule).
|
|
68
|
+
|
|
69
|
+
### ValidationResult & TraceEntry schema
|
|
70
|
+
|
|
71
|
+
The policy engine returns a structured `ValidationResult` that is convenient to consume in CI and automation. The JSON schema is:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"policyName": "string",
|
|
76
|
+
"result": "Pass|Fail|Unknown",
|
|
77
|
+
"violations": [
|
|
78
|
+
{
|
|
79
|
+
"id": "string", // UUID of the primitive involved
|
|
80
|
+
"type": "Entity|Resource|Flow|Instance|Role|Relation",
|
|
81
|
+
"displayName": "string", // optional human-readable name
|
|
82
|
+
"path": ["string"], // optional path (e.g., ["flows", "0"]) for locating in larger payloads
|
|
83
|
+
"details": { // optional free-form details useful for diagnostics
|
|
84
|
+
"field": "value"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Example `ValidationResult` (policy failure):
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"policyName": "payment_threshold",
|
|
96
|
+
"result": "Fail",
|
|
97
|
+
"violations": [
|
|
98
|
+
{ "id": "3a3e5d08-...", "type":"Flow", "displayName":"Money transfer", "path":["flows","0"], "details":{"quantity": 15000, "expectedMax": 10000} }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## See Also
|
|
104
|
+
|
|
105
|
+
- [Three-Valued Logic](three-valued-logic.md)
|
|
106
|
+
- [Graph Store Design](graph-store-design.md)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Semantic Modeling Concepts
|
|
2
|
+
|
|
3
|
+
DomainForge uses a specific set of primitives to model enterprise architecture. Unlike generic diagramming tools, these primitives have semantic meaning that allows for automated analysis, policy enforcement, and code generation.
|
|
4
|
+
|
|
5
|
+
## The Core Primitives
|
|
6
|
+
|
|
7
|
+
### 1. Entity
|
|
8
|
+
|
|
9
|
+
**What it is**: A logical component, service, actor, or system boundary.
|
|
10
|
+
**When to use**: Use Entities to represent *who* or *what* is performing actions.
|
|
11
|
+
**Examples**: `Customer`, `PaymentService`, `InventorySystem`.
|
|
12
|
+
|
|
13
|
+
```sea
|
|
14
|
+
Entity "PaymentService"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 2. Resource
|
|
18
|
+
|
|
19
|
+
**What it is**: Passive data, infrastructure, or state that is acted upon.
|
|
20
|
+
**When to use**: Use Resources to represent databases, queues, file stores, or API endpoints.
|
|
21
|
+
**Examples**: `UserDatabase`, `OrderQueue`, `S3Bucket`.
|
|
22
|
+
|
|
23
|
+
```sea
|
|
24
|
+
Resource "UserDatabase" units
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`units` denotes a count-based unit (i.e., number of instances/items). Use `units` for raw counts or specify another unit (e.g., `kg`, `USD`) when applicable; this aligns the resource with the `Unit` registry so flow quantities and aggregations can be compared consistently.
|
|
28
|
+
|
|
29
|
+
### 3. Flow
|
|
30
|
+
|
|
31
|
+
**What it is**: A directional interaction between two concepts, often involving a resource.
|
|
32
|
+
**When to use**: Use Flows to model data movement, API calls, or dependencies.
|
|
33
|
+
**Key Attribute**: Flows are strictly typed (e.g., `read`, `write`, `trigger`).
|
|
34
|
+
|
|
35
|
+
```sea
|
|
36
|
+
flow "Payment" {
|
|
37
|
+
from = "PaymentService",
|
|
38
|
+
to = "UserDatabase",
|
|
39
|
+
interaction = "write",
|
|
40
|
+
quantity = 1
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 4. Instance
|
|
45
|
+
|
|
46
|
+
**What it is**: A concrete realization of an Entity or Resource in a specific environment.
|
|
47
|
+
**When to use**: Use Instances to model physical deployments (e.g., "Production Payment Service" vs "Staging Payment Service").
|
|
48
|
+
|
|
49
|
+
```sea
|
|
50
|
+
Instance prod_payment_db of "UserDatabase" {
|
|
51
|
+
env: "production",
|
|
52
|
+
region: "us-east-1"
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 5. Policy
|
|
57
|
+
|
|
58
|
+
**What it is**: A constraint or rule that must be true for the model to be valid.
|
|
59
|
+
**When to use**: Use Policies to enforce security, compliance, or architectural standards.
|
|
60
|
+
|
|
61
|
+
```sea
|
|
62
|
+
Policy secure_writes as:
|
|
63
|
+
forall f in flows: (f.to = "UserDatabase" and f.quantity >= 1)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Modeling Patterns
|
|
67
|
+
|
|
68
|
+
### The "Actor-Action-Object" Pattern
|
|
69
|
+
|
|
70
|
+
Most architectural interactions can be modeled as:
|
|
71
|
+
|
|
72
|
+
- **Actor**: An Entity (e.g., WebServer)
|
|
73
|
+
- **Action**: A Flow (e.g., reads from)
|
|
74
|
+
- **Object**: A Resource (e.g., Database)
|
|
75
|
+
|
|
76
|
+
### The "Service-to-Service" Pattern
|
|
77
|
+
|
|
78
|
+
Direct communication between services is modeled as a Flow between two Entities.
|
|
79
|
+
|
|
80
|
+
- `Frontend` -> (Flow: HTTP/REST) -> `Backend`
|
|
81
|
+
|
|
82
|
+
## Semantic vs. Visual
|
|
83
|
+
|
|
84
|
+
In DomainForge, the *meaning* comes first. A box on a diagram is just a rendering of an Entity. Because the model is semantic, we can ask questions like:
|
|
85
|
+
|
|
86
|
+
- "Show me all services that write to the UserDatabase."
|
|
87
|
+
- "Are there any flows crossing trust boundaries without encryption?"
|
|
88
|
+
|
|
89
|
+
## Semantic Packs
|
|
90
|
+
|
|
91
|
+
While the primitives above define individual concepts in a single .sea file, **semantic packs** provide organization-wide vocabulary governance. A semantic pack is a deterministic, review-gated, signed JSON artifact that defines an organization's approved business concepts, relations, metrics, dimensions, units, aliases, and mapping rules.
|
|
92
|
+
|
|
93
|
+
Semantic packs serve as the authoritative vocabulary that the DomainForge LSP and CI validators use to check .sea source files. When you write `Entity "PaymentService"` in a .sea file, the LSP resolves that name against the loaded semantic pack and reports diagnostics if the term is unknown, ambiguous, deprecated, or rejected.
|
|
94
|
+
|
|
95
|
+
Key properties of semantic packs:
|
|
96
|
+
|
|
97
|
+
- **Review-gated**: Every concept in an approved pack must have a matching human review record.
|
|
98
|
+
- **Signed**: Packs can be signed with Ed25519 to provide tamper evidence.
|
|
99
|
+
- **Three-valued truth**: Concept resolution returns `valid`, `invalid`, or `unknown`---not just true/false.
|
|
100
|
+
- **Deterministic**: Two builds from identical inputs produce bit-for-bit identical output.
|
|
101
|
+
|
|
102
|
+
For full details, see [Semantic Packs](../semantic-packs.md).
|
|
103
|
+
|
|
104
|
+
## See Also
|
|
105
|
+
|
|
106
|
+
- [Policy Evaluation Logic](policy-evaluation-logic.md)
|
|
107
|
+
- [Architecture Overview](architecture-overview.md)
|
|
108
|
+
- [Semantic Packs](../semantic-packs.md)
|
|
109
|
+
- [Semantic Diagnostic Codes](../diagnostics.md)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Three-Valued Logic
|
|
2
|
+
|
|
3
|
+
DomainForge uses **Kleene's Three-Valued Logic (3VL)** for policy evaluation. This is a critical design choice for modeling architecture, where information is often incomplete.
|
|
4
|
+
|
|
5
|
+
## The Three States
|
|
6
|
+
|
|
7
|
+
1. **True**: The statement is demonstrably true.
|
|
8
|
+
2. **False**: The statement is demonstrably false.
|
|
9
|
+
3. **Unknown**: There is insufficient information to determine truth.
|
|
10
|
+
|
|
11
|
+
## Why Not Boolean?
|
|
12
|
+
|
|
13
|
+
In standard boolean logic, `null` or missing values often default to `False` or cause errors. In architecture modeling:
|
|
14
|
+
|
|
15
|
+
- **Scenario**: You have a policy "All databases must be encrypted".
|
|
16
|
+
- **Model**: You define a database `UserDB` but forget to specify the `encrypted` property.
|
|
17
|
+
- **Boolean Logic**: `UserDB.encrypted == true` evaluates to `False`. The policy fails. You think the DB is unencrypted.
|
|
18
|
+
- **3VL**: `UserDB.encrypted` is `Unknown`. The comparison evaluates to `Unknown`. The policy result is `Unknown`.
|
|
19
|
+
|
|
20
|
+
This distinction tells the architect: "I don't know if this is safe yet," rather than "This is unsafe."
|
|
21
|
+
|
|
22
|
+
## Truth Tables
|
|
23
|
+
|
|
24
|
+
### NOT (Negation)
|
|
25
|
+
| Input | Result |
|
|
26
|
+
|-------|--------|
|
|
27
|
+
| True | False |
|
|
28
|
+
| False | True |
|
|
29
|
+
| Unknown | Unknown |
|
|
30
|
+
|
|
31
|
+
### AND (Conjunction)
|
|
32
|
+
| A | B | Result |
|
|
33
|
+
|---|---|--------|
|
|
34
|
+
| True | True | True |
|
|
35
|
+
| True | False | False |
|
|
36
|
+
| True | Unknown | Unknown |
|
|
37
|
+
| False | True | False |
|
|
38
|
+
| False | False | False |
|
|
39
|
+
| False | Unknown | False |
|
|
40
|
+
| Unknown | True | Unknown |
|
|
41
|
+
| Unknown | False | False |
|
|
42
|
+
| Unknown | Unknown | Unknown |
|
|
43
|
+
|
|
44
|
+
### OR (Disjunction)
|
|
45
|
+
| A | B | Result |
|
|
46
|
+
|---|---|--------|
|
|
47
|
+
| True | True | True |
|
|
48
|
+
| True | False | True |
|
|
49
|
+
| True | Unknown | True |
|
|
50
|
+
| False | True | True |
|
|
51
|
+
| False | False | False |
|
|
52
|
+
| False | Unknown | Unknown |
|
|
53
|
+
| Unknown | True | True |
|
|
54
|
+
| Unknown | False | Unknown |
|
|
55
|
+
| Unknown | Unknown | Unknown |
|
|
56
|
+
|
|
57
|
+
## Practical Implications
|
|
58
|
+
|
|
59
|
+
When writing policies:
|
|
60
|
+
|
|
61
|
+
- **Strict Enforcement**: If you want to fail on unknowns, check for them explicitly or ensure your CI pipeline treats `Unknown` as a failure for production releases.
|
|
62
|
+
- **Progressive Modeling**: 3VL allows models to evolve. You can run policies against a partial sketch of a system without getting flooded with false positives.
|
|
63
|
+
|
|
64
|
+
## See Also
|
|
65
|
+
|
|
66
|
+
- [Policy Evaluation Logic](policy-evaluation-logic.md)
|