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,451 @@
|
|
|
1
|
+
# SDS-001: Protobuf Projection Engine
|
|
2
|
+
|
|
3
|
+
**System:** SEA Projection Framework
|
|
4
|
+
**Component:** Protobuf Projection Engine
|
|
5
|
+
**Version:** 1.0
|
|
6
|
+
**Date:** 2025-12-14
|
|
7
|
+
**Status:** Implemented
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. High-Level Architecture
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
SEA DSL
|
|
15
|
+
↓
|
|
16
|
+
Parser
|
|
17
|
+
↓
|
|
18
|
+
Semantic Graph
|
|
19
|
+
↓
|
|
20
|
+
Projection Resolver
|
|
21
|
+
↓
|
|
22
|
+
Projection Engine (Protobuf)
|
|
23
|
+
↓
|
|
24
|
+
.proto Files
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Data Flow
|
|
28
|
+
|
|
29
|
+
1. **SEA DSL Source** → Parsed into AST
|
|
30
|
+
2. **AST** → Built into Semantic Graph
|
|
31
|
+
3. **Projection Declarations** → Resolved into `ProjectionSpec`
|
|
32
|
+
4. **Semantic Graph + ProjectionSpec** → Filtered and transformed
|
|
33
|
+
5. **Protobuf IR** → Written to `.proto` files
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 2. Core Modules
|
|
38
|
+
|
|
39
|
+
### 2.1 Projection Resolver
|
|
40
|
+
|
|
41
|
+
**Location:** `domainforge-core/src/projection/resolver.rs`
|
|
42
|
+
|
|
43
|
+
**Responsibilities:**
|
|
44
|
+
|
|
45
|
+
- Parse `Projection` declarations from AST
|
|
46
|
+
- Resolve scopes and filters against semantic graph
|
|
47
|
+
- Produce validated `ProjectionSpec`
|
|
48
|
+
|
|
49
|
+
```rust
|
|
50
|
+
pub struct ProjectionSpec {
|
|
51
|
+
pub name: String,
|
|
52
|
+
pub format: ProjectionFormat,
|
|
53
|
+
pub filters: ProjectionFilters,
|
|
54
|
+
pub metadata: ProjectionMetadata,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
pub struct ProjectionFilters {
|
|
58
|
+
pub namespaces: Vec<String>,
|
|
59
|
+
pub kinds: Vec<SeaKind>,
|
|
60
|
+
pub tags: Vec<String>,
|
|
61
|
+
pub profiles: Vec<String>,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
pub struct ProjectionMetadata {
|
|
65
|
+
pub stability: Stability,
|
|
66
|
+
pub compatibility: Compatibility,
|
|
67
|
+
pub audience: Vec<String>,
|
|
68
|
+
pub version: SemanticVersion,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
pub enum Compatibility {
|
|
72
|
+
Additive,
|
|
73
|
+
Backward,
|
|
74
|
+
Breaking,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
pub enum Stability {
|
|
78
|
+
Experimental,
|
|
79
|
+
Stable,
|
|
80
|
+
Deprecated,
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2.2 Protobuf Projection Engine
|
|
85
|
+
|
|
86
|
+
**Location:** `domainforge-core/src/projection/protobuf/engine.rs`
|
|
87
|
+
|
|
88
|
+
**Responsibilities:**
|
|
89
|
+
|
|
90
|
+
- Walk semantic graph using `ProjectionSpec`
|
|
91
|
+
- Build intermediate Protobuf IR
|
|
92
|
+
- Enforce compatibility rules
|
|
93
|
+
- Emit `.proto` files
|
|
94
|
+
|
|
95
|
+
```rust
|
|
96
|
+
pub trait ProjectionEngine {
|
|
97
|
+
fn project(&self, graph: &SemanticGraph, spec: &ProjectionSpec) -> Result<ProjectionOutput, ProjectionError>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pub struct ProtobufEngine {
|
|
101
|
+
type_mapper: TypeMapper,
|
|
102
|
+
compatibility_checker: CompatibilityChecker,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
impl ProjectionEngine for ProtobufEngine {
|
|
106
|
+
fn project(&self, graph: &SemanticGraph, spec: &ProjectionSpec) -> Result<ProjectionOutput, ProjectionError> {
|
|
107
|
+
// 1. Filter graph nodes
|
|
108
|
+
// 2. Build Protobuf IR
|
|
109
|
+
// 3. Check compatibility
|
|
110
|
+
// 4. Generate output
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 3. Protobuf Intermediate Representation (IR)
|
|
118
|
+
|
|
119
|
+
**Location:** `domainforge-core/src/projection/protobuf/ir.rs`
|
|
120
|
+
|
|
121
|
+
```rust
|
|
122
|
+
pub struct ProtoFile {
|
|
123
|
+
pub package: String,
|
|
124
|
+
pub syntax: String, // "proto3"
|
|
125
|
+
pub imports: Vec<String>,
|
|
126
|
+
pub options: ProtoOptions,
|
|
127
|
+
pub enums: Vec<ProtoEnum>,
|
|
128
|
+
pub messages: Vec<ProtoMessage>,
|
|
129
|
+
pub metadata: ProtoMetadata,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
pub struct ProtoMessage {
|
|
133
|
+
pub name: String,
|
|
134
|
+
pub fields: Vec<ProtoField>,
|
|
135
|
+
pub nested_messages: Vec<ProtoMessage>,
|
|
136
|
+
pub nested_enums: Vec<ProtoEnum>,
|
|
137
|
+
pub reserved_fields: Vec<u32>,
|
|
138
|
+
pub reserved_names: Vec<String>,
|
|
139
|
+
pub comments: Vec<String>,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
pub struct ProtoField {
|
|
143
|
+
pub name: String,
|
|
144
|
+
pub number: u32,
|
|
145
|
+
pub proto_type: ProtoType,
|
|
146
|
+
pub label: FieldLabel, // optional, repeated, required
|
|
147
|
+
pub comments: Vec<String>,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
pub struct ProtoEnum {
|
|
151
|
+
pub name: String,
|
|
152
|
+
pub values: Vec<ProtoEnumValue>,
|
|
153
|
+
pub comments: Vec<String>,
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
pub struct ProtoEnumValue {
|
|
157
|
+
pub name: String,
|
|
158
|
+
pub number: i32,
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
pub struct ProtoOptions {
|
|
162
|
+
pub java_package: Option<String>,
|
|
163
|
+
pub java_multiple_files: bool,
|
|
164
|
+
pub go_package: Option<String>,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
pub struct ProtoMetadata {
|
|
168
|
+
pub projection_name: String,
|
|
169
|
+
pub semantic_version: String,
|
|
170
|
+
pub source_namespace: String,
|
|
171
|
+
pub generated_at: String,
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 4. Mapping Rules
|
|
178
|
+
|
|
179
|
+
### 4.1 SEA Entities / Resources → Protobuf Messages
|
|
180
|
+
|
|
181
|
+
| SEA Construct | Protobuf Construct |
|
|
182
|
+
| ------------- | ------------------ |
|
|
183
|
+
| `Entity` | `message` |
|
|
184
|
+
| `Resource` | `message` |
|
|
185
|
+
| `ValueObject` | `message` |
|
|
186
|
+
| Attributes | Fields |
|
|
187
|
+
| Relations | Field references |
|
|
188
|
+
|
|
189
|
+
**Field Ordering:**
|
|
190
|
+
|
|
191
|
+
- Fields are ordered deterministically by name (alphabetical)
|
|
192
|
+
- Field numbers are assigned sequentially starting at 1
|
|
193
|
+
- Once assigned, field numbers are immutable
|
|
194
|
+
|
|
195
|
+
### 4.2 SEA Types → Protobuf Types
|
|
196
|
+
|
|
197
|
+
| SEA Type | Protobuf Type |
|
|
198
|
+
| ------------- | --------------------------- |
|
|
199
|
+
| `String` | `string` |
|
|
200
|
+
| `Int` | `int64` |
|
|
201
|
+
| `Float` | `double` |
|
|
202
|
+
| `Bool` | `bool` |
|
|
203
|
+
| `Date` | `google.protobuf.Timestamp` |
|
|
204
|
+
| `DateTime` | `google.protobuf.Timestamp` |
|
|
205
|
+
| `Money` | Custom `Money` message |
|
|
206
|
+
| `UUID` | `string` |
|
|
207
|
+
| `List<T>` | `repeated T` |
|
|
208
|
+
| `Optional<T>` | `optional T` |
|
|
209
|
+
| Custom Entity | Reference message |
|
|
210
|
+
|
|
211
|
+
### 4.3 SEA Enums → Protobuf Enums
|
|
212
|
+
|
|
213
|
+
- First value is always `UNSPECIFIED = 0`
|
|
214
|
+
- Subsequent values numbered sequentially
|
|
215
|
+
- Names converted to SCREAMING_SNAKE_CASE
|
|
216
|
+
|
|
217
|
+
**Example:**
|
|
218
|
+
|
|
219
|
+
```sea
|
|
220
|
+
enum PaymentStatus {
|
|
221
|
+
Pending
|
|
222
|
+
Completed
|
|
223
|
+
Failed
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Becomes:
|
|
228
|
+
|
|
229
|
+
```proto
|
|
230
|
+
enum PaymentStatus {
|
|
231
|
+
PAYMENT_STATUS_UNSPECIFIED = 0;
|
|
232
|
+
PAYMENT_STATUS_PENDING = 1;
|
|
233
|
+
PAYMENT_STATUS_COMPLETED = 2;
|
|
234
|
+
PAYMENT_STATUS_FAILED = 3;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### 4.4 Flows / Policies / Metrics
|
|
239
|
+
|
|
240
|
+
Emit standardized governance and telemetry messages:
|
|
241
|
+
|
|
242
|
+
```proto
|
|
243
|
+
message GovernanceEvent {
|
|
244
|
+
string event_id = 1;
|
|
245
|
+
string flow_name = 2;
|
|
246
|
+
string policy_name = 3;
|
|
247
|
+
google.protobuf.Timestamp timestamp = 4;
|
|
248
|
+
map<string, string> context = 5;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
message MetricEvent {
|
|
252
|
+
string metric_name = 1;
|
|
253
|
+
double value = 2;
|
|
254
|
+
google.protobuf.Timestamp timestamp = 3;
|
|
255
|
+
map<string, string> dimensions = 4;
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 5. Compatibility Enforcement Algorithm
|
|
262
|
+
|
|
263
|
+
**Location:** `domainforge-core/src/projection/protobuf/compatibility.rs`
|
|
264
|
+
|
|
265
|
+
```rust
|
|
266
|
+
pub struct CompatibilityChecker {
|
|
267
|
+
history_store: Box<dyn SchemaHistoryStore>,
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
impl CompatibilityChecker {
|
|
271
|
+
pub fn check(
|
|
272
|
+
&self,
|
|
273
|
+
new_schema: &ProtoFile,
|
|
274
|
+
spec: &ProjectionSpec,
|
|
275
|
+
) -> Result<(), CompatibilityViolation> {
|
|
276
|
+
// 1. Load previous schema (if available)
|
|
277
|
+
let previous = self.history_store.load(&spec.name)?;
|
|
278
|
+
|
|
279
|
+
if let Some(prev) = previous {
|
|
280
|
+
// 2. Diff old vs new
|
|
281
|
+
let diff = self.diff(&prev, new_schema);
|
|
282
|
+
|
|
283
|
+
// 3. Apply compatibility rules
|
|
284
|
+
match spec.metadata.compatibility {
|
|
285
|
+
Compatibility::Additive => self.check_additive(&diff)?,
|
|
286
|
+
Compatibility::Backward => self.check_backward(&diff)?,
|
|
287
|
+
Compatibility::Breaking => self.check_breaking(&diff)?,
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// 4. Store new schema for future checks
|
|
292
|
+
self.history_store.save(&spec.name, new_schema)?;
|
|
293
|
+
|
|
294
|
+
Ok(())
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Compatibility Rules Matrix
|
|
300
|
+
|
|
301
|
+
| Change Type | Additive | Backward | Breaking |
|
|
302
|
+
| ------------------- | -------- | ------------- | -------- |
|
|
303
|
+
| Add field | ✅ | ✅ | ✅ |
|
|
304
|
+
| Remove field | ❌ | ✅ (reserved) | ✅ |
|
|
305
|
+
| Rename field | ❌ | ❌ | ✅ |
|
|
306
|
+
| Change field type | ❌ | ❌ | ✅ |
|
|
307
|
+
| Change field number | ❌ | ❌ | ✅ |
|
|
308
|
+
| Add enum value | ✅ | ✅ | ✅ |
|
|
309
|
+
| Remove enum value | ❌ | ✅ (reserved) | ✅ |
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## 6. Output Structure
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
/generated
|
|
317
|
+
/protobuf
|
|
318
|
+
/com
|
|
319
|
+
/example
|
|
320
|
+
/finance
|
|
321
|
+
payments.proto
|
|
322
|
+
risk.proto
|
|
323
|
+
/hr
|
|
324
|
+
employees.proto
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### File Header Template
|
|
328
|
+
|
|
329
|
+
```proto
|
|
330
|
+
// =============================================================================
|
|
331
|
+
// Generated by SEA Projection Framework
|
|
332
|
+
//
|
|
333
|
+
// Projection: PaymentsProto
|
|
334
|
+
// Semantic Version: 1.3.0
|
|
335
|
+
// Source Namespace: com.example.finance.payments
|
|
336
|
+
// Generated At: 2025-12-14T15:47:05Z
|
|
337
|
+
//
|
|
338
|
+
// DO NOT EDIT - This file is generated from SEA-DSL source
|
|
339
|
+
// =============================================================================
|
|
340
|
+
|
|
341
|
+
syntax = "proto3";
|
|
342
|
+
|
|
343
|
+
package com.example.finance.payments;
|
|
344
|
+
|
|
345
|
+
option java_package = "com.example.finance.payments";
|
|
346
|
+
option java_multiple_files = true;
|
|
347
|
+
option go_package = "github.com/example/finance/payments";
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## 7. Extension Points
|
|
353
|
+
|
|
354
|
+
### 7.1 New Projection Formats
|
|
355
|
+
|
|
356
|
+
Implement the `ProjectionEngine` trait:
|
|
357
|
+
|
|
358
|
+
```rust
|
|
359
|
+
pub struct GraphQLEngine;
|
|
360
|
+
pub struct AvroEngine;
|
|
361
|
+
pub struct OpenAPIEngine;
|
|
362
|
+
|
|
363
|
+
impl ProjectionEngine for GraphQLEngine { /* ... */ }
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### 7.2 Service/RPC Projections
|
|
367
|
+
|
|
368
|
+
Future support for gRPC service definitions:
|
|
369
|
+
|
|
370
|
+
```rust
|
|
371
|
+
pub struct ProtoService {
|
|
372
|
+
pub name: String,
|
|
373
|
+
pub methods: Vec<ProtoMethod>,
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
pub struct ProtoMethod {
|
|
377
|
+
pub name: String,
|
|
378
|
+
pub input_type: String,
|
|
379
|
+
pub output_type: String,
|
|
380
|
+
pub streaming: StreamingMode,
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### 7.3 Semantic Diff Tooling
|
|
385
|
+
|
|
386
|
+
```rust
|
|
387
|
+
pub trait SchemaDiffTool {
|
|
388
|
+
fn diff(&self, old: &ProtoFile, new: &ProtoFile) -> SchemaDiff;
|
|
389
|
+
fn report(&self, diff: &SchemaDiff) -> String;
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## 8. Error Handling
|
|
396
|
+
|
|
397
|
+
```rust
|
|
398
|
+
#[derive(Debug, thiserror::Error)]
|
|
399
|
+
pub enum ProjectionError {
|
|
400
|
+
#[error("Invalid projection: {0}")]
|
|
401
|
+
InvalidProjection(String),
|
|
402
|
+
|
|
403
|
+
#[error("Namespace not found: {0}")]
|
|
404
|
+
NamespaceNotFound(String),
|
|
405
|
+
|
|
406
|
+
#[error("Compatibility violation: {0}")]
|
|
407
|
+
CompatibilityViolation(CompatibilityViolation),
|
|
408
|
+
|
|
409
|
+
#[error("IO error: {0}")]
|
|
410
|
+
IoError(#[from] std::io::Error),
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
#[derive(Debug)]
|
|
414
|
+
pub struct CompatibilityViolation {
|
|
415
|
+
pub rule: Compatibility,
|
|
416
|
+
pub message_name: String,
|
|
417
|
+
pub field_name: String,
|
|
418
|
+
pub violation_type: ViolationType,
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## 9. Testing Strategy
|
|
425
|
+
|
|
426
|
+
### Unit Tests
|
|
427
|
+
|
|
428
|
+
- Type mapping correctness
|
|
429
|
+
- Field numbering determinism
|
|
430
|
+
- Compatibility rule enforcement
|
|
431
|
+
|
|
432
|
+
### Integration Tests
|
|
433
|
+
|
|
434
|
+
- End-to-end projection from SEA → Protobuf
|
|
435
|
+
- Round-trip parsing of generated `.proto` files
|
|
436
|
+
- Multi-namespace projections
|
|
437
|
+
|
|
438
|
+
### Golden Tests
|
|
439
|
+
|
|
440
|
+
- Snapshot testing of generated output
|
|
441
|
+
- Ensure deterministic generation
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Related Documents
|
|
446
|
+
|
|
447
|
+
- [ADR-001: SEA-DSL as Semantic Source of Truth](./ADR-001-sea-dsl-semantic-source-of-truth.md)
|
|
448
|
+
- [ADR-002: Projection as First-Class Construct](./ADR-002-projection-first-class-construct.md)
|
|
449
|
+
- [ADR-003: Protobuf as Projection Target](./ADR-003-protobuf-projection-target.md)
|
|
450
|
+
- [ADR-004: Projection Compatibility Semantics](./ADR-004-projection-compatibility-semantics.md)
|
|
451
|
+
- [PRD-001: SEA Projection Framework](./PRD-001-sea-projection-framework.md)
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# SDS-002: SEA Core Architecture
|
|
2
|
+
|
|
3
|
+
**System:** DomainForge
|
|
4
|
+
**Component:** domainforge-core
|
|
5
|
+
**Version:** 0.2.1
|
|
6
|
+
**Date:** 2025-12-14
|
|
7
|
+
**Status:** Implemented
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Overview
|
|
12
|
+
|
|
13
|
+
`domainforge-core` is the Rust implementation of the SEA Domain-Specific Language. It provides:
|
|
14
|
+
|
|
15
|
+
- **Parsing**: Convert `.sea` source text to AST and semantic graph
|
|
16
|
+
- **Validation**: Enforce semantic rules and constraints
|
|
17
|
+
- **Policy Evaluation**: Execute business logic policies
|
|
18
|
+
- **Projection**: Export to external formats (JSON, YAML, DDD, Protobuf)
|
|
19
|
+
- **Multi-language Bindings**: Python, TypeScript, WASM
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. High-Level Architecture
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
27
|
+
│ domainforge-core │
|
|
28
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
29
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────────────┐ │
|
|
30
|
+
│ │ Parser │→ │ AST │→ │ Graph │→ │ Projection │ │
|
|
31
|
+
│ │ (pest) │ │ │ │ │ │ Engine │ │
|
|
32
|
+
│ └──────────┘ └──────────┘ └──────────┘ └───────────────┘ │
|
|
33
|
+
│ ↓ ↓ │
|
|
34
|
+
│ ┌──────────┐ ┌──────────┐ │
|
|
35
|
+
│ │ Linter │ │ Policy │ │
|
|
36
|
+
│ │ │ │ Evaluator│ │
|
|
37
|
+
│ └──────────┘ └──────────┘ │
|
|
38
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
39
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────────────┐ │
|
|
40
|
+
│ │ Python │ │ Node │ │ WASM │ │ CLI │ │
|
|
41
|
+
│ │ Bindings │ │ Bindings │ │ Bindings │ │ (clap) │ │
|
|
42
|
+
│ └──────────┘ └──────────┘ └──────────┘ └───────────────┘ │
|
|
43
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 3. Module Structure
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
domainforge-core/src/
|
|
52
|
+
├── lib.rs # Public API and feature-gated re-exports
|
|
53
|
+
├── bin/sea.rs # CLI entry point
|
|
54
|
+
│
|
|
55
|
+
├── parser/ # DSL parsing
|
|
56
|
+
│ ├── mod.rs # Parser API
|
|
57
|
+
│ ├── ast.rs # AST types and construction
|
|
58
|
+
│ ├── error.rs # Parse errors
|
|
59
|
+
│ ├── lint.rs # Linting rules
|
|
60
|
+
│ ├── printer.rs # Pretty printer
|
|
61
|
+
│ └── profiles.rs # Profile enforcement
|
|
62
|
+
│
|
|
63
|
+
├── grammar/ # Pest grammar
|
|
64
|
+
│ └── sea.pest # SEA grammar definition
|
|
65
|
+
│
|
|
66
|
+
├── primitives/ # Core domain types
|
|
67
|
+
│ ├── entity.rs # Entity primitive
|
|
68
|
+
│ ├── resource.rs # Resource primitive
|
|
69
|
+
│ ├── flow.rs # Flow primitive
|
|
70
|
+
│ ├── instance.rs # Instance primitive
|
|
71
|
+
│ ├── role.rs # Role primitive
|
|
72
|
+
│ ├── relation.rs # Relation types
|
|
73
|
+
│ ├── policy.rs # Policy primitive
|
|
74
|
+
│ ├── metric.rs # Metric primitive
|
|
75
|
+
│ ├── concept_change.rs # Temporal changes
|
|
76
|
+
│ ├── mapping_contract.rs
|
|
77
|
+
│ └── projection_contract.rs
|
|
78
|
+
│
|
|
79
|
+
├── graph/ # Semantic graph
|
|
80
|
+
│ ├── mod.rs # Graph structure
|
|
81
|
+
│ └── to_ast.rs # Graph → AST conversion
|
|
82
|
+
│
|
|
83
|
+
├── policy/ # Policy evaluation
|
|
84
|
+
│ ├── mod.rs # Policy engine
|
|
85
|
+
│ ├── expression.rs # Expression evaluation
|
|
86
|
+
│ └── three_valued.rs # Three-valued logic
|
|
87
|
+
│
|
|
88
|
+
├── projection/ # Output generation
|
|
89
|
+
│ ├── mod.rs # Projection API
|
|
90
|
+
│ ├── contracts.rs # Mapping/projection contracts
|
|
91
|
+
│ ├── engine.rs # Projection executor
|
|
92
|
+
│ └── registry.rs # Projection registry
|
|
93
|
+
│
|
|
94
|
+
├── registry/ # Namespace management
|
|
95
|
+
│ └── mod.rs # NamespaceRegistry
|
|
96
|
+
│
|
|
97
|
+
├── module/ # Module resolution
|
|
98
|
+
│ └── resolver.rs # Import handling
|
|
99
|
+
│
|
|
100
|
+
├── error/ # Error handling
|
|
101
|
+
│ ├── mod.rs # Error types
|
|
102
|
+
│ ├── diagnostics.rs # Formatters
|
|
103
|
+
│ └── fuzzy.rs # Did-you-mean suggestions
|
|
104
|
+
│
|
|
105
|
+
├── cli/ # CLI commands
|
|
106
|
+
│ ├── mod.rs # Command definitions
|
|
107
|
+
│ ├── validate.rs
|
|
108
|
+
│ ├── project.rs
|
|
109
|
+
│ ├── format.rs
|
|
110
|
+
│ ├── import.rs
|
|
111
|
+
│ └── test.rs
|
|
112
|
+
│
|
|
113
|
+
├── python/ # Python bindings (feature: python)
|
|
114
|
+
├── typescript/ # Node.js bindings (feature: typescript)
|
|
115
|
+
└── wasm/ # WASM bindings (feature: wasm)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 4. Core Types
|
|
121
|
+
|
|
122
|
+
### 4.1 Semantic Primitives
|
|
123
|
+
|
|
124
|
+
| Type | Description |
|
|
125
|
+
| --------------- | ----------------------------------------------------- |
|
|
126
|
+
| `Entity` | Domain concept with attributes and optional relations |
|
|
127
|
+
| `Resource` | Quantifiable items that flow between entities |
|
|
128
|
+
| `Flow` | Movement of resources between entities |
|
|
129
|
+
| `Instance` | Concrete instantiation of an entity with values |
|
|
130
|
+
| `Role` | Named capability assigned to entities |
|
|
131
|
+
| `Relation` | Typed relationship between entities |
|
|
132
|
+
| `Policy` | Executable business rule with expression |
|
|
133
|
+
| `Metric` | Observable measurement with thresholds |
|
|
134
|
+
| `ConceptChange` | Temporal evolution of a concept |
|
|
135
|
+
|
|
136
|
+
### 4.2 Graph
|
|
137
|
+
|
|
138
|
+
```rust
|
|
139
|
+
pub struct Graph {
|
|
140
|
+
entities: IndexMap<ConceptId, Entity>,
|
|
141
|
+
roles: IndexMap<ConceptId, Role>,
|
|
142
|
+
resources: IndexMap<ConceptId, Resource>,
|
|
143
|
+
flows: IndexMap<ConceptId, Flow>,
|
|
144
|
+
relations: IndexMap<ConceptId, RelationType>,
|
|
145
|
+
instances: IndexMap<ConceptId, ResourceInstance>,
|
|
146
|
+
entity_instances: IndexMap<ConceptId, Instance>,
|
|
147
|
+
policies: IndexMap<ConceptId, Policy>,
|
|
148
|
+
patterns: IndexMap<ConceptId, Pattern>,
|
|
149
|
+
concept_changes: IndexMap<ConceptId, ConceptChange>,
|
|
150
|
+
metrics: IndexMap<ConceptId, Metric>,
|
|
151
|
+
mappings: IndexMap<ConceptId, MappingContract>,
|
|
152
|
+
projections: IndexMap<ConceptId, ProjectionContract>,
|
|
153
|
+
config: GraphConfig,
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 4.3 ConceptId
|
|
158
|
+
|
|
159
|
+
Stable, content-addressable identifier for all graph nodes:
|
|
160
|
+
|
|
161
|
+
```rust
|
|
162
|
+
pub struct ConceptId {
|
|
163
|
+
namespace: String,
|
|
164
|
+
name: String,
|
|
165
|
+
uuid: Uuid, // v5 deterministic from namespace:name
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 5. Data Flow
|
|
172
|
+
|
|
173
|
+
### 5.1 Parse Pipeline
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
Source Text (.sea)
|
|
177
|
+
│
|
|
178
|
+
▼
|
|
179
|
+
┌─────────────────┐
|
|
180
|
+
│ pest Parser │ ← sea.pest grammar
|
|
181
|
+
└────────┬────────┘
|
|
182
|
+
│ Pairs
|
|
183
|
+
▼
|
|
184
|
+
┌─────────────────┐
|
|
185
|
+
│ AST Builder │ ← ast.rs
|
|
186
|
+
└────────┬────────┘
|
|
187
|
+
│ Ast
|
|
188
|
+
▼
|
|
189
|
+
┌─────────────────┐
|
|
190
|
+
│ Graph Builder │ ← ast_to_graph()
|
|
191
|
+
└────────┬────────┘
|
|
192
|
+
│ Graph
|
|
193
|
+
▼
|
|
194
|
+
┌─────────────────┐
|
|
195
|
+
│ Validation │ ← Reference checks, type checks
|
|
196
|
+
└────────┬────────┘
|
|
197
|
+
│ Result<Graph>
|
|
198
|
+
▼
|
|
199
|
+
Ready for use
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### 5.2 Policy Evaluation
|
|
203
|
+
|
|
204
|
+
```rust
|
|
205
|
+
// Three-valued logic for null-safe evaluation
|
|
206
|
+
enum TruthValue {
|
|
207
|
+
True,
|
|
208
|
+
False,
|
|
209
|
+
Unknown, // NULL propagation
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
impl Graph {
|
|
213
|
+
pub fn evaluate_policies(&self) -> Vec<Violation> {
|
|
214
|
+
self.policies
|
|
215
|
+
.values()
|
|
216
|
+
.flat_map(|policy| policy.evaluate(self))
|
|
217
|
+
.collect()
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 6. Feature Flags
|
|
225
|
+
|
|
226
|
+
| Feature | Dependencies | Description |
|
|
227
|
+
| -------------------- | ----------------- | ---------------------------- |
|
|
228
|
+
| `python` | pyo3, pythonize | Python bindings |
|
|
229
|
+
| `typescript` | napi, napi-derive | Node.js bindings |
|
|
230
|
+
| `wasm` | wasm-bindgen | WebAssembly bindings |
|
|
231
|
+
| `cli` | clap, colored | CLI binary |
|
|
232
|
+
| `shacl` | oxigraph | SHACL validation |
|
|
233
|
+
| `three_valued_logic` | (none) | NULL-aware policy evaluation |
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 7. Serialization
|
|
238
|
+
|
|
239
|
+
Graph and primitives use `serde` for serialization:
|
|
240
|
+
|
|
241
|
+
```rust
|
|
242
|
+
#[derive(Serialize, Deserialize)]
|
|
243
|
+
pub struct Entity { /* ... */ }
|
|
244
|
+
|
|
245
|
+
// JSON round-trip
|
|
246
|
+
let json = serde_json::to_string(&graph)?;
|
|
247
|
+
let restored: Graph = serde_json::from_str(&json)?;
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## 8. Extension Points
|
|
253
|
+
|
|
254
|
+
| Extension | Mechanism |
|
|
255
|
+
| ---------------- | ------------------------------------ |
|
|
256
|
+
| New primitives | Add to `primitives/`, update `Graph` |
|
|
257
|
+
| New projections | Implement in `projection/`, register |
|
|
258
|
+
| New CLI commands | Add subcommand in `cli/` |
|
|
259
|
+
| New bindings | Feature-gate new binding module |
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Related Documents
|
|
264
|
+
|
|
265
|
+
- [ADR-005: Multi-Language Support Strategy](./ADR-005-multi-language-support-strategy.md)
|
|
266
|
+
- [ADR-006: Error Handling Strategy](./ADR-006-error-handling-strategy.md)
|
|
267
|
+
- [SDS-003: Parser and Semantic Graph](./SDS-003-parser-semantic-graph.md)
|
|
268
|
+
- [PRD-002: SEA CLI Tooling](./PRD-002-sea-cli-tooling.md)
|