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,525 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# SEA Protobuf Projection Implementation Plan
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Status: Ready for Implementation
|
|
5
|
+
# Last Updated: 2025-12-14
|
|
6
|
+
# Related Specs: ADR-001 through ADR-004, PRD-001, SDS-001
|
|
7
|
+
# =============================================================================
|
|
8
|
+
|
|
9
|
+
project:
|
|
10
|
+
name: sea_projections_protobuf
|
|
11
|
+
goal: >
|
|
12
|
+
Extend SEA-DSL's existing Projection infrastructure to support Protobuf as
|
|
13
|
+
a first-class projection target, generating .proto files from the semantic graph.
|
|
14
|
+
|
|
15
|
+
# =============================================================================
|
|
16
|
+
# CURRENT STATE ANALYSIS
|
|
17
|
+
# =============================================================================
|
|
18
|
+
current_state:
|
|
19
|
+
grammar:
|
|
20
|
+
status: COMPLETE
|
|
21
|
+
details:
|
|
22
|
+
- "projection_decl rule exists in sea.pest"
|
|
23
|
+
- "Supports: Projection 'name' target <format> { overrides }"
|
|
24
|
+
|
|
25
|
+
ast:
|
|
26
|
+
status: COMPLETE
|
|
27
|
+
details:
|
|
28
|
+
- "AstNode::ProjectionDecl { name, target, overrides }"
|
|
29
|
+
- "TargetFormat enum: Calm | Kg | Sbvr (NEEDS: Protobuf)"
|
|
30
|
+
- "ProjectionOverride struct with fields HashMap"
|
|
31
|
+
|
|
32
|
+
primitives:
|
|
33
|
+
status: COMPLETE
|
|
34
|
+
details:
|
|
35
|
+
- "ProjectionContract in primitives/projection_contract.rs"
|
|
36
|
+
- "MappingContract in primitives/mapping_contract.rs"
|
|
37
|
+
|
|
38
|
+
projection_module:
|
|
39
|
+
status: PARTIAL
|
|
40
|
+
location: "domainforge-core/src/projection/"
|
|
41
|
+
existing_files:
|
|
42
|
+
- "mod.rs: re-exports"
|
|
43
|
+
- "engine.rs: ProjectionExporter trait (entity/flow only)"
|
|
44
|
+
- "contracts.rs: find_mapping_rule, find_projection_override helpers"
|
|
45
|
+
- "registry.rs: ProjectionRegistry for finding mappings/projections by target"
|
|
46
|
+
missing:
|
|
47
|
+
- "protobuf.rs: Protobuf-specific IR and engine"
|
|
48
|
+
- "ProjectionSpec with filters (namespace, kinds, tags)"
|
|
49
|
+
- "Compatibility checking logic"
|
|
50
|
+
|
|
51
|
+
cli:
|
|
52
|
+
status: PARTIAL
|
|
53
|
+
details:
|
|
54
|
+
- "sea project command exists in cli/project.rs"
|
|
55
|
+
- "Supports --format with json, ddd, yaml, calm"
|
|
56
|
+
- "NEEDS: --format protobuf option"
|
|
57
|
+
|
|
58
|
+
# =============================================================================
|
|
59
|
+
# FILE PATHS (Corrected for current codebase)
|
|
60
|
+
# =============================================================================
|
|
61
|
+
context:
|
|
62
|
+
repo_root: "."
|
|
63
|
+
core_crate: "domainforge-core"
|
|
64
|
+
grammar_file: "domainforge-core/src/grammar/sea.pest"
|
|
65
|
+
ast_module: "domainforge-core/src/parser/ast.rs"
|
|
66
|
+
graph_module: "domainforge-core/src/graph/mod.rs"
|
|
67
|
+
projection_dir: "domainforge-core/src/projection"
|
|
68
|
+
cli_project: "domainforge-core/src/cli/project.rs"
|
|
69
|
+
tests_dir: "domainforge-core/tests"
|
|
70
|
+
examples_dir: "examples"
|
|
71
|
+
|
|
72
|
+
# =============================================================================
|
|
73
|
+
# ASSUMPTIONS
|
|
74
|
+
# =============================================================================
|
|
75
|
+
assumptions:
|
|
76
|
+
- Rust stable toolchain 1.77+ is installed
|
|
77
|
+
- Existing parser, AST, and Graph are compiling (verified)
|
|
78
|
+
- Existing tests are green before changes
|
|
79
|
+
- Protobuf compiler (protoc) is optional for validation
|
|
80
|
+
|
|
81
|
+
# =============================================================================
|
|
82
|
+
# IMPLEMENTATION PHASES
|
|
83
|
+
# =============================================================================
|
|
84
|
+
phases:
|
|
85
|
+
|
|
86
|
+
# ---------------------------------------------------------------------------
|
|
87
|
+
# PHASE 1: Extend TargetFormat for Protobuf
|
|
88
|
+
# ---------------------------------------------------------------------------
|
|
89
|
+
- id: 1_extend_target_format
|
|
90
|
+
description: "Add Protobuf variant to TargetFormat enum"
|
|
91
|
+
estimated_effort: "30 minutes"
|
|
92
|
+
steps:
|
|
93
|
+
- id: 1_1_update_target_format_enum
|
|
94
|
+
action: "Add Protobuf variant to TargetFormat"
|
|
95
|
+
files:
|
|
96
|
+
- "domainforge-core/src/parser/ast.rs"
|
|
97
|
+
changes:
|
|
98
|
+
- "Add 'Protobuf' to TargetFormat enum (line ~108)"
|
|
99
|
+
- "Update Display impl to add 'Protobuf' case"
|
|
100
|
+
- "Update parse_target_format to handle 'protobuf' string"
|
|
101
|
+
code_snippet: |
|
|
102
|
+
pub enum TargetFormat {
|
|
103
|
+
Calm,
|
|
104
|
+
Kg,
|
|
105
|
+
Sbvr,
|
|
106
|
+
Protobuf, // NEW
|
|
107
|
+
}
|
|
108
|
+
acceptance_criteria:
|
|
109
|
+
- "cargo build succeeds"
|
|
110
|
+
- "Projection 'Test' target protobuf {} parses without error"
|
|
111
|
+
|
|
112
|
+
- id: 1_2_update_grammar_if_needed
|
|
113
|
+
action: "Ensure grammar accepts 'protobuf' as target"
|
|
114
|
+
files:
|
|
115
|
+
- "domainforge-core/src/grammar/sea.pest"
|
|
116
|
+
changes:
|
|
117
|
+
- "Verify target_format rule includes 'protobuf' (case-insensitive)"
|
|
118
|
+
acceptance_criteria:
|
|
119
|
+
- "cargo test passes with protobuf target"
|
|
120
|
+
|
|
121
|
+
# ---------------------------------------------------------------------------
|
|
122
|
+
# PHASE 2: Protobuf IR Model
|
|
123
|
+
# ---------------------------------------------------------------------------
|
|
124
|
+
- id: 2_protobuf_ir_model
|
|
125
|
+
description: "Create intermediate representation for .proto files"
|
|
126
|
+
estimated_effort: "2 hours"
|
|
127
|
+
depends_on: [1_extend_target_format]
|
|
128
|
+
steps:
|
|
129
|
+
- id: 2_1_create_protobuf_module
|
|
130
|
+
action: "Create domainforge-core/src/projection/protobuf.rs"
|
|
131
|
+
files:
|
|
132
|
+
- "domainforge-core/src/projection/protobuf.rs"
|
|
133
|
+
- "domainforge-core/src/projection/mod.rs"
|
|
134
|
+
changes:
|
|
135
|
+
- "Define ProtoFile struct"
|
|
136
|
+
- "Define ProtoMessage, ProtoField, ProtoEnum"
|
|
137
|
+
- "Define ProtoTypeRef enum for type references"
|
|
138
|
+
- "Add mod protobuf to projection/mod.rs"
|
|
139
|
+
code_sketch: |
|
|
140
|
+
// domainforge-core/src/projection/protobuf.rs
|
|
141
|
+
use serde::{Serialize, Deserialize};
|
|
142
|
+
|
|
143
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
144
|
+
pub struct ProtoFile {
|
|
145
|
+
pub package: String,
|
|
146
|
+
pub syntax: String, // "proto3"
|
|
147
|
+
pub imports: Vec<String>,
|
|
148
|
+
pub options: ProtoOptions,
|
|
149
|
+
pub enums: Vec<ProtoEnum>,
|
|
150
|
+
pub messages: Vec<ProtoMessage>,
|
|
151
|
+
pub metadata: ProtoMetadata,
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
155
|
+
pub struct ProtoMessage {
|
|
156
|
+
pub name: String,
|
|
157
|
+
pub fields: Vec<ProtoField>,
|
|
158
|
+
pub nested_messages: Vec<ProtoMessage>,
|
|
159
|
+
pub nested_enums: Vec<ProtoEnum>,
|
|
160
|
+
pub reserved_fields: Vec<u32>,
|
|
161
|
+
pub reserved_names: Vec<String>,
|
|
162
|
+
pub comments: Vec<String>,
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
166
|
+
pub struct ProtoField {
|
|
167
|
+
pub name: String,
|
|
168
|
+
pub number: u32,
|
|
169
|
+
pub proto_type: ProtoType,
|
|
170
|
+
pub repeated: bool,
|
|
171
|
+
pub optional: bool,
|
|
172
|
+
pub comments: Vec<String>,
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
176
|
+
pub enum ProtoType {
|
|
177
|
+
Scalar(ScalarType),
|
|
178
|
+
Message(String),
|
|
179
|
+
Enum(String),
|
|
180
|
+
Map { key: Box<ProtoType>, value: Box<ProtoType> },
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
184
|
+
pub enum ScalarType {
|
|
185
|
+
Double, Float, Int32, Int64, Uint32, Uint64,
|
|
186
|
+
Sint32, Sint64, Fixed32, Fixed64, Sfixed32, Sfixed64,
|
|
187
|
+
Bool, String, Bytes,
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
191
|
+
pub struct ProtoEnum {
|
|
192
|
+
pub name: String,
|
|
193
|
+
pub values: Vec<ProtoEnumValue>,
|
|
194
|
+
pub comments: Vec<String>,
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
198
|
+
pub struct ProtoEnumValue {
|
|
199
|
+
pub name: String,
|
|
200
|
+
pub number: i32,
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
|
204
|
+
pub struct ProtoOptions {
|
|
205
|
+
pub java_package: Option<String>,
|
|
206
|
+
pub java_multiple_files: bool,
|
|
207
|
+
pub go_package: Option<String>,
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
211
|
+
pub struct ProtoMetadata {
|
|
212
|
+
pub projection_name: String,
|
|
213
|
+
pub semantic_version: Option<String>,
|
|
214
|
+
pub source_namespace: String,
|
|
215
|
+
pub generated_at: String,
|
|
216
|
+
}
|
|
217
|
+
acceptance_criteria:
|
|
218
|
+
- "ProtoFile can be constructed in unit tests"
|
|
219
|
+
- "cargo build succeeds"
|
|
220
|
+
|
|
221
|
+
- id: 2_2_type_mapping
|
|
222
|
+
action: "Implement SEA type to Proto type mapping"
|
|
223
|
+
files:
|
|
224
|
+
- "domainforge-core/src/projection/protobuf.rs"
|
|
225
|
+
changes:
|
|
226
|
+
- "Add fn map_sea_type_to_proto(sea_type: &str) -> ProtoType"
|
|
227
|
+
- "Map String -> string, Int -> int64, Float -> double, etc."
|
|
228
|
+
- "Map UUID -> string, DateTime -> google.protobuf.Timestamp"
|
|
229
|
+
- "Map Money -> custom Money message"
|
|
230
|
+
code_sketch: |
|
|
231
|
+
pub fn map_sea_type_to_proto(sea_type: &str) -> ProtoType {
|
|
232
|
+
match sea_type.to_lowercase().as_str() {
|
|
233
|
+
"string" | "text" => ProtoType::Scalar(ScalarType::String),
|
|
234
|
+
"int" | "integer" => ProtoType::Scalar(ScalarType::Int64),
|
|
235
|
+
"float" | "double" | "decimal" => ProtoType::Scalar(ScalarType::Double),
|
|
236
|
+
"bool" | "boolean" => ProtoType::Scalar(ScalarType::Bool),
|
|
237
|
+
"uuid" => ProtoType::Scalar(ScalarType::String),
|
|
238
|
+
"date" | "datetime" | "timestamp" => ProtoType::Message("google.protobuf.Timestamp".to_string()),
|
|
239
|
+
"bytes" | "binary" => ProtoType::Scalar(ScalarType::Bytes),
|
|
240
|
+
other => ProtoType::Message(other.to_string()), // Custom types
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
acceptance_criteria:
|
|
244
|
+
- "All core SEA types map to appropriate proto types"
|
|
245
|
+
- "Unit tests cover all mappings"
|
|
246
|
+
|
|
247
|
+
# ---------------------------------------------------------------------------
|
|
248
|
+
# PHASE 3: Protobuf Projection Engine
|
|
249
|
+
# ---------------------------------------------------------------------------
|
|
250
|
+
- id: 3_protobuf_engine
|
|
251
|
+
description: "Implement the Protobuf projection engine"
|
|
252
|
+
estimated_effort: "4 hours"
|
|
253
|
+
depends_on: [2_protobuf_ir_model]
|
|
254
|
+
steps:
|
|
255
|
+
- id: 3_1_engine_struct
|
|
256
|
+
action: "Create ProtobufEngine implementing projection logic"
|
|
257
|
+
files:
|
|
258
|
+
- "domainforge-core/src/projection/protobuf.rs"
|
|
259
|
+
changes:
|
|
260
|
+
- "Define ProtobufEngine struct"
|
|
261
|
+
- "Implement fn project(graph: &Graph, namespace: &str) -> ProtoFile"
|
|
262
|
+
- "Walk graph entities/resources/enums and build ProtoFile"
|
|
263
|
+
code_sketch: |
|
|
264
|
+
pub struct ProtobufEngine;
|
|
265
|
+
|
|
266
|
+
impl ProtobufEngine {
|
|
267
|
+
pub fn project(graph: &Graph, namespace: &str) -> ProtoFile {
|
|
268
|
+
let mut proto = ProtoFile::new(namespace);
|
|
269
|
+
|
|
270
|
+
// Convert entities to messages
|
|
271
|
+
for entity in graph.all_entities() {
|
|
272
|
+
if entity.namespace() == namespace {
|
|
273
|
+
proto.messages.push(Self::entity_to_message(entity));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Convert resources to messages
|
|
278
|
+
for resource in graph.all_resources() {
|
|
279
|
+
if resource.namespace() == namespace {
|
|
280
|
+
proto.messages.push(Self::resource_to_message(resource));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
proto
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
fn entity_to_message(entity: &Entity) -> ProtoMessage {
|
|
288
|
+
let mut msg = ProtoMessage::new(entity.name());
|
|
289
|
+
let mut field_number = 1u32;
|
|
290
|
+
|
|
291
|
+
// Sort attributes alphabetically for deterministic ordering
|
|
292
|
+
let mut attrs: Vec<_> = entity.attributes().iter().collect();
|
|
293
|
+
attrs.sort_by_key(|(k, _)| *k);
|
|
294
|
+
|
|
295
|
+
for (name, value) in attrs {
|
|
296
|
+
msg.fields.push(ProtoField {
|
|
297
|
+
name: to_snake_case(name),
|
|
298
|
+
number: field_number,
|
|
299
|
+
proto_type: infer_proto_type(value),
|
|
300
|
+
repeated: false,
|
|
301
|
+
optional: true,
|
|
302
|
+
comments: vec![],
|
|
303
|
+
});
|
|
304
|
+
field_number += 1;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
msg
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
acceptance_criteria:
|
|
311
|
+
- "Given a Graph with entities, project() returns valid ProtoFile"
|
|
312
|
+
- "Field numbers are sequential and stable"
|
|
313
|
+
|
|
314
|
+
- id: 3_2_proto_serializer
|
|
315
|
+
action: "Implement serialization to .proto text format"
|
|
316
|
+
files:
|
|
317
|
+
- "domainforge-core/src/projection/protobuf.rs"
|
|
318
|
+
changes:
|
|
319
|
+
- "Add impl ProtoFile { pub fn to_proto_string(&self) -> String }"
|
|
320
|
+
- "Format messages, fields, enums according to proto3 syntax"
|
|
321
|
+
- "Include header comments with metadata"
|
|
322
|
+
code_sketch: |
|
|
323
|
+
impl ProtoFile {
|
|
324
|
+
pub fn to_proto_string(&self) -> String {
|
|
325
|
+
let mut out = String::new();
|
|
326
|
+
|
|
327
|
+
// Header
|
|
328
|
+
out.push_str(&format!("// Generated from Projection: {}\n", self.metadata.projection_name));
|
|
329
|
+
out.push_str(&format!("// Source Namespace: {}\n", self.metadata.source_namespace));
|
|
330
|
+
out.push_str(&format!("// Generated At: {}\n", self.metadata.generated_at));
|
|
331
|
+
out.push_str("// DO NOT EDIT - Generated by SEA Projection Framework\n\n");
|
|
332
|
+
|
|
333
|
+
// Syntax
|
|
334
|
+
out.push_str(&format!("syntax = \"{}\";\n\n", self.syntax));
|
|
335
|
+
|
|
336
|
+
// Package
|
|
337
|
+
out.push_str(&format!("package {};\n\n", self.package));
|
|
338
|
+
|
|
339
|
+
// Options
|
|
340
|
+
if let Some(ref pkg) = self.options.java_package {
|
|
341
|
+
out.push_str(&format!("option java_package = \"{}\";\n", pkg));
|
|
342
|
+
}
|
|
343
|
+
if self.options.java_multiple_files {
|
|
344
|
+
out.push_str("option java_multiple_files = true;\n");
|
|
345
|
+
}
|
|
346
|
+
if let Some(ref pkg) = self.options.go_package {
|
|
347
|
+
out.push_str(&format!("option go_package = \"{}\";\n", pkg));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Imports
|
|
351
|
+
for import in &self.imports {
|
|
352
|
+
out.push_str(&format!("import \"{}\";\n", import));
|
|
353
|
+
}
|
|
354
|
+
if !self.imports.is_empty() {
|
|
355
|
+
out.push('\n');
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Enums
|
|
359
|
+
for e in &self.enums {
|
|
360
|
+
out.push_str(&e.to_proto_string());
|
|
361
|
+
out.push('\n');
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Messages
|
|
365
|
+
for m in &self.messages {
|
|
366
|
+
out.push_str(&m.to_proto_string());
|
|
367
|
+
out.push('\n');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
out
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
acceptance_criteria:
|
|
374
|
+
- "Generated .proto text is syntactically valid"
|
|
375
|
+
- "Output is deterministic (same input → same output)"
|
|
376
|
+
|
|
377
|
+
- id: 3_3_governance_messages
|
|
378
|
+
action: "Add standard governance message generation"
|
|
379
|
+
files:
|
|
380
|
+
- "domainforge-core/src/projection/protobuf.rs"
|
|
381
|
+
changes:
|
|
382
|
+
- "Add fn generate_governance_messages() -> Vec<ProtoMessage>"
|
|
383
|
+
- "Include PolicyViolation, MetricEvent, GovernanceEvent messages"
|
|
384
|
+
acceptance_criteria:
|
|
385
|
+
- "Governance messages appear in output when requested"
|
|
386
|
+
|
|
387
|
+
# ---------------------------------------------------------------------------
|
|
388
|
+
# PHASE 4: CLI Integration
|
|
389
|
+
# ---------------------------------------------------------------------------
|
|
390
|
+
- id: 4_cli_integration
|
|
391
|
+
description: "Wire Protobuf projection into CLI"
|
|
392
|
+
estimated_effort: "1 hour"
|
|
393
|
+
depends_on: [3_protobuf_engine]
|
|
394
|
+
steps:
|
|
395
|
+
- id: 4_1_extend_project_command
|
|
396
|
+
action: "Add --format protobuf to sea project command"
|
|
397
|
+
files:
|
|
398
|
+
- "domainforge-core/src/cli/project.rs"
|
|
399
|
+
changes:
|
|
400
|
+
- "Add 'protobuf' to format enum/match"
|
|
401
|
+
- "Call ProtobufEngine::project when format is protobuf"
|
|
402
|
+
- "Write .proto files to output directory"
|
|
403
|
+
acceptance_criteria:
|
|
404
|
+
- "sea project --format protobuf model.sea produces .proto file"
|
|
405
|
+
- "Output directory structure matches package hierarchy"
|
|
406
|
+
|
|
407
|
+
- id: 4_2_output_options
|
|
408
|
+
action: "Add output path and namespace options"
|
|
409
|
+
files:
|
|
410
|
+
- "domainforge-core/src/cli/project.rs"
|
|
411
|
+
changes:
|
|
412
|
+
- "Add --namespace flag to filter which namespaces to project"
|
|
413
|
+
- "Add --output-dir flag for proto file destination"
|
|
414
|
+
acceptance_criteria:
|
|
415
|
+
- "Can specify output directory"
|
|
416
|
+
- "Can filter by namespace"
|
|
417
|
+
|
|
418
|
+
# ---------------------------------------------------------------------------
|
|
419
|
+
# PHASE 5: Compatibility Enforcement (Future)
|
|
420
|
+
# ---------------------------------------------------------------------------
|
|
421
|
+
- id: 5_compatibility_enforcement
|
|
422
|
+
description: "Implement schema compatibility checking"
|
|
423
|
+
estimated_effort: "3 hours"
|
|
424
|
+
depends_on: [4_cli_integration]
|
|
425
|
+
priority: LOW
|
|
426
|
+
steps:
|
|
427
|
+
- id: 5_1_schema_history
|
|
428
|
+
action: "Add mechanism to store/load previous schemas"
|
|
429
|
+
files:
|
|
430
|
+
- "domainforge-core/src/projection/protobuf.rs"
|
|
431
|
+
changes:
|
|
432
|
+
- "Add SchemaHistoryStore trait"
|
|
433
|
+
- "Implement file-based storage of previous ProtoFile"
|
|
434
|
+
acceptance_criteria:
|
|
435
|
+
- "Previous schema can be loaded for comparison"
|
|
436
|
+
|
|
437
|
+
- id: 5_2_compatibility_checker
|
|
438
|
+
action: "Implement compatibility rules"
|
|
439
|
+
files:
|
|
440
|
+
- "domainforge-core/src/projection/protobuf.rs"
|
|
441
|
+
changes:
|
|
442
|
+
- "Add CompatibilityChecker struct"
|
|
443
|
+
- "Implement check() method with additive/backward/breaking rules"
|
|
444
|
+
- "Emit reserved fields when fields are removed"
|
|
445
|
+
acceptance_criteria:
|
|
446
|
+
- "Additive mode: only new fields allowed"
|
|
447
|
+
- "Backward mode: removals become reserved"
|
|
448
|
+
- "Breaking mode: all changes allowed"
|
|
449
|
+
|
|
450
|
+
# ---------------------------------------------------------------------------
|
|
451
|
+
# PHASE 6: Tests and Examples
|
|
452
|
+
# ---------------------------------------------------------------------------
|
|
453
|
+
- id: 6_tests_and_examples
|
|
454
|
+
description: "Add comprehensive tests and examples"
|
|
455
|
+
estimated_effort: "2 hours"
|
|
456
|
+
depends_on: [4_cli_integration]
|
|
457
|
+
steps:
|
|
458
|
+
- id: 6_1_unit_tests
|
|
459
|
+
action: "Add unit tests for Protobuf projection"
|
|
460
|
+
files:
|
|
461
|
+
- "domainforge-core/tests/protobuf_projection_tests.rs"
|
|
462
|
+
changes:
|
|
463
|
+
- "Test type mapping"
|
|
464
|
+
- "Test entity → message conversion"
|
|
465
|
+
- "Test field numbering stability"
|
|
466
|
+
- "Test proto string serialization"
|
|
467
|
+
acceptance_criteria:
|
|
468
|
+
- "All unit tests pass"
|
|
469
|
+
|
|
470
|
+
- id: 6_2_integration_test
|
|
471
|
+
action: "Add end-to-end integration test"
|
|
472
|
+
files:
|
|
473
|
+
- "domainforge-core/tests/protobuf_projection_integration.rs"
|
|
474
|
+
changes:
|
|
475
|
+
- "Parse .sea file → Graph → ProtoFile → .proto text"
|
|
476
|
+
- "Verify output contains expected messages and fields"
|
|
477
|
+
acceptance_criteria:
|
|
478
|
+
- "Integration test passes"
|
|
479
|
+
|
|
480
|
+
- id: 6_3_example_files
|
|
481
|
+
action: "Add example .sea files with Protobuf projections"
|
|
482
|
+
files:
|
|
483
|
+
- "examples/protobuf/finance.sea"
|
|
484
|
+
- "examples/protobuf/expected/finance.proto"
|
|
485
|
+
changes:
|
|
486
|
+
- "Create example demonstrating Protobuf projection"
|
|
487
|
+
- "Store expected output for golden testing"
|
|
488
|
+
acceptance_criteria:
|
|
489
|
+
- "Examples parse and produce expected output"
|
|
490
|
+
|
|
491
|
+
# =============================================================================
|
|
492
|
+
# DEFINITION OF DONE
|
|
493
|
+
# =============================================================================
|
|
494
|
+
done_definition:
|
|
495
|
+
- "TargetFormat::Protobuf variant added and parsing works"
|
|
496
|
+
- "Protobuf IR model (ProtoFile, ProtoMessage, etc.) implemented"
|
|
497
|
+
- "ProtobufEngine projects Graph to ProtoFile"
|
|
498
|
+
- "ProtoFile serializes to valid .proto text"
|
|
499
|
+
- "CLI sea project --format protobuf works"
|
|
500
|
+
- "Unit tests and integration tests pass"
|
|
501
|
+
- "At least one example with expected output"
|
|
502
|
+
- "Documentation in docs/specs/SDS-001 is accurate"
|
|
503
|
+
|
|
504
|
+
# =============================================================================
|
|
505
|
+
# RISK MITIGATION
|
|
506
|
+
# =============================================================================
|
|
507
|
+
risks:
|
|
508
|
+
- risk: "Entity attributes lack type information"
|
|
509
|
+
mitigation: "Infer types from JSON values or default to 'any' message type"
|
|
510
|
+
|
|
511
|
+
- risk: "Field numbering instability across runs"
|
|
512
|
+
mitigation: "Sort attributes deterministically (alphabetically by key)"
|
|
513
|
+
|
|
514
|
+
- risk: "Complex nested structures"
|
|
515
|
+
mitigation: "Start with flat messages; add nesting in future iteration"
|
|
516
|
+
|
|
517
|
+
# =============================================================================
|
|
518
|
+
# FUTURE ENHANCEMENTS (OUT OF SCOPE)
|
|
519
|
+
# =============================================================================
|
|
520
|
+
future:
|
|
521
|
+
- "gRPC service definitions from Flow patterns"
|
|
522
|
+
- "Protobuf well-known types (Timestamp, Duration, Any)"
|
|
523
|
+
- "Custom proto options"
|
|
524
|
+
- "Buf.build integration for linting"
|
|
525
|
+
- "Multiple file output per namespace"
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Plan: SEA DSL Refactoring & Architecture Hardening
|
|
2
|
+
|
|
3
|
+
This plan addresses the critique regarding the SEA DSL implementation, focusing on grammar consistency, architectural layering (profiles), and policy simplification.
|
|
4
|
+
|
|
5
|
+
## 1. [x] Grammar & Syntax Cleanup
|
|
6
|
+
|
|
7
|
+
**Goal**: Ensure the grammar is robust, consistent, and matches the documentation/examples.
|
|
8
|
+
|
|
9
|
+
### Tasks
|
|
10
|
+
|
|
11
|
+
- [x] **Review `sea.pest`**:
|
|
12
|
+
- Verify `declaration_inner` rule is complete and not corrupted.
|
|
13
|
+
- Confirm all keywords use case-insensitive matching (e.g., `^"entity"`).
|
|
14
|
+
- [x] **Standardize Casing**:
|
|
15
|
+
- Decision: Keep grammar case-insensitive (`^"keyword"`) to be user-friendly.
|
|
16
|
+
- Action: Enforce "Capitalized" convention (e.g., `Entity`, `Resource`) in all documentation and examples.
|
|
17
|
+
- Action: Update `domainforge format` (if exists) or `PrettyPrinter` to output Capitalized keywords.
|
|
18
|
+
- [x] **Fix Examples**:
|
|
19
|
+
- Scan all `.sea` files in `examples/` and `domainforge-core/examples/`.
|
|
20
|
+
- Remove any `...` placeholders that are not valid syntax.
|
|
21
|
+
- Ensure all examples parse successfully with the current grammar.
|
|
22
|
+
|
|
23
|
+
## 2. [x] Grammar Expansion (The `as` Operator)
|
|
24
|
+
|
|
25
|
+
**Goal**: Support a general-purpose casting/conversion mechanism for units and types.
|
|
26
|
+
|
|
27
|
+
### Tasks
|
|
28
|
+
|
|
29
|
+
- [x] **Update Grammar (`sea.pest`)**:
|
|
30
|
+
- Modify `unary_expr` or `primary_expr` to support `as` syntax.
|
|
31
|
+
- Rule: `cast_expr = { primary_expr ~ (^"as" ~ string_literal)? }`.
|
|
32
|
+
- [x] **Update AST (`domainforge-core/src/parser/ast.rs`)**:
|
|
33
|
+
- Add `Expression::Cast(Box<Expression>, String)` variant.
|
|
34
|
+
- [x] **Update Parser (`domainforge-core/src/parser/mod.rs`)**:
|
|
35
|
+
- Map the new grammar rule to the AST variant.
|
|
36
|
+
- [x] **Update Evaluator (`domainforge-core/src/policy/evaluation.rs`)**:
|
|
37
|
+
- Implement `eval_cast` logic (initially for unit conversion, e.g., `1000 "ms" as "s"`).
|
|
38
|
+
|
|
39
|
+
### Casting semantics and validation
|
|
40
|
+
|
|
41
|
+
- **Compatibility matrix**:
|
|
42
|
+
- Quantity ↔ Quantity (same dimension): allowed, with conversion via the registry.
|
|
43
|
+
- Number → Quantity: allowed, wraps the numeric value with the target unit.
|
|
44
|
+
- String/Boolean/Unknown unit: rejected with a clear diagnostic.
|
|
45
|
+
- Dimension mismatch (e.g., duration → currency): rejected.
|
|
46
|
+
- **Conversion mechanics**:
|
|
47
|
+
- Use a canonical base unit per dimension with deterministic scale factors from the registry.
|
|
48
|
+
- Perform arithmetic with `Decimal` to avoid float rounding; no silent truncation.
|
|
49
|
+
- Unknown or non-convertible unit pairs surface an evaluation error.
|
|
50
|
+
- **Failure modes**:
|
|
51
|
+
- Unsupported casts return a deterministic error message that names the offending unit/value.
|
|
52
|
+
- Parsing/typecheck can pre-reject obviously invalid casts; runtime still guards conversions.
|
|
53
|
+
- **Type inference**:
|
|
54
|
+
- Successful casts return a concrete quantity typed with the requested unit, not `Any`, and downstream checks propagate that concrete type.
|
|
55
|
+
- Example: `1000 "ms" as "s"` produces `1 "s"` with the target unit recorded for later comparisons.
|
|
56
|
+
|
|
57
|
+
#### Parser contract for cast expressions
|
|
58
|
+
|
|
59
|
+
- `cast_expr` is considered the outermost form of `primary_expr` (i.e., `primary_expr = { cast_expr | ... }`) so the `as` suffix binds tighter than binary operators but looser than atom-level access (field/index) and is left-associative for chains like `value as "ms" as "s"`.
|
|
60
|
+
- The grammar accepts any string literal after `as` so validation is deferred until evaluation; the parser only ensures the operand itself is a valid `primary_expr`.
|
|
61
|
+
- The AST carries the literal verbatim (`Expression::Cast { operand, target_type }`) and keeps the operand boxed so any downstream stage can further inspect or optimize before the cast runs.
|
|
62
|
+
|
|
63
|
+
#### Evaluator validation and type propagation
|
|
64
|
+
|
|
65
|
+
- The evaluator must resolve the target unit at runtime by looking it up in the global unit registry; if the string literal does not name a registered unit, return an `EvalError` (e.g., `UnknownUnit`) that mentions the missing symbol so diagnostics stay actionable.
|
|
66
|
+
- After a successful conversion the expression result should include concrete unit/type metadata (for example, wrapping the numeric value into a `Quantity { value, unit }` structure or annotating the evaluation context) so downstream policies and projections can reason about the actual dimension rather than treating the value as untyped.
|
|
67
|
+
- Unknown units, mismatched dimensions, or forbidden conversions must fail at evaluation time, not at parse time, because the registry contents and user-defined units are only known once the runtime context is available.
|
|
68
|
+
|
|
69
|
+
## 3. [x] DSL Layering (Profiles)
|
|
70
|
+
|
|
71
|
+
**Goal**: Introduce "Profiles" to allow different DSL dialects (e.g., `profile: "cloud"`, `profile: "data"`).
|
|
72
|
+
|
|
73
|
+
### Tasks
|
|
74
|
+
|
|
75
|
+
- [x] **Create Profile Registry (`domainforge-core/src/parser/profiles.rs`)**:
|
|
76
|
+
- Define `Profile` struct (name, enabled keywords/features).
|
|
77
|
+
- Create a registry of built-in profiles.
|
|
78
|
+
- [x] **Update Parser Context**:
|
|
79
|
+
- Pass the active profile into the parser.
|
|
80
|
+
- Validate that used keywords/constructs are allowed in the current profile.
|
|
81
|
+
- [x] **Add `profile` Keyword to Grammar**:
|
|
82
|
+
- Allow `profile: "name"` at the top of the file.
|
|
83
|
+
|
|
84
|
+
### Profile enforcement rules
|
|
85
|
+
|
|
86
|
+
- **Default and precedence**:
|
|
87
|
+
- Active profile = `profile:` declared in the file, else project-level option, else `"default"`.
|
|
88
|
+
- `"default"` is permissive and allows all core/cloud/data constructs; additional profiles may restrict keywords.
|
|
89
|
+
- **Error semantics**:
|
|
90
|
+
- Profile violations are hard parse errors by default.
|
|
91
|
+
- Parser option `tolerate_profile_warnings` can downgrade violations to warnings for soft-rollout; violations are still logged.
|
|
92
|
+
- **Conflict resolution**:
|
|
93
|
+
- Explicit file profile > project-level > default.
|
|
94
|
+
- If multiple profiles define rules for a keyword, explicit allow wins over deny; tie breaks deterministically by precedence above.
|
|
95
|
+
- **Parser API**:
|
|
96
|
+
- `ParseOptions` carries `active_profile` and `tolerate_profile_warnings`.
|
|
97
|
+
- Diagnostics include the requested profile and the list of available profiles from `ProfileRegistry`.
|
|
98
|
+
|
|
99
|
+
## 4. [x] Standard Library (Modules)
|
|
100
|
+
|
|
101
|
+
**Goal**: Move built-in types (like `HTTP`, `REST`) out of the compiler and into a standard library.
|
|
102
|
+
|
|
103
|
+
### Tasks
|
|
104
|
+
|
|
105
|
+
- [x] **Create Standard Library Files**:
|
|
106
|
+
- `domainforge-core/std/core.sea` (Base types).
|
|
107
|
+
- `domainforge-core/std/http.sea` (HTTP/REST types).
|
|
108
|
+
- `domainforge-core/std/aws.sea` (AWS types).
|
|
109
|
+
- [x] **Embed Stdlib in Binary**:
|
|
110
|
+
- Use `include_str!` to embed these files in the Rust binary.
|
|
111
|
+
- [x] **Update Module Resolver**:
|
|
112
|
+
- Modify `domainforge-core/src/module/resolver.rs` to handle `std:` imports (e.g., `import { Service } from "std:core"`).
|
|
113
|
+
- When resolving `std:*`, return the embedded content.
|
|
114
|
+
|
|
115
|
+
## 5. [x] Canonical Graph & Isomorphism
|
|
116
|
+
|
|
117
|
+
**Goal**: Reinforce `Graph` as the source of truth.
|
|
118
|
+
|
|
119
|
+
### Tasks
|
|
120
|
+
|
|
121
|
+
- [x] **Verify Round-Trip**:
|
|
122
|
+
- Ensure `Graph -> DSL (PrettyPrint) -> Graph` preserves all semantics.
|
|
123
|
+
- Add a test case `tests/test_round_trip.rs` that fuzzes this cycle.
|
|
124
|
+
|
|
125
|
+
## Implementation Steps for Agent
|
|
126
|
+
|
|
127
|
+
1. **Grammar Expansion**: Implement the `as` operator in `sea.pest` and AST.
|
|
128
|
+
2. **Implement Profiles**: Create the `DslProfile` enum and integrate it into `ParseOptions`.
|
|
129
|
+
3. **Profile Validation**: Enforce profile constraints during parsing.
|
|
130
|
+
4. **Policy Tracing**: Add the tracing context to the evaluator.
|
|
131
|
+
5. **Final Verification**: Run all tests.
|