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,420 @@
|
|
|
1
|
+
# SEA Core WASM Bindings
|
|
2
|
+
|
|
3
|
+
This document describes the WebAssembly (WASM) bindings for the SEA Core library, enabling browser and edge runtime usage.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Phase 9 implements WASM bindings using `wasm-bindgen`, providing a lightweight (<500KB gzipped) module for browser and Node.js environments.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
1. **Rust toolchain** (1.77+)
|
|
12
|
+
2. **wasm-pack**:
|
|
13
|
+
```bash
|
|
14
|
+
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
|
15
|
+
```
|
|
16
|
+
3. **wasm-opt** (optional, for size optimization):
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# macOS
|
|
20
|
+
brew install binaryen
|
|
21
|
+
|
|
22
|
+
# Ubuntu/Debian
|
|
23
|
+
sudo apt install binaryen
|
|
24
|
+
|
|
25
|
+
# Or download from https://github.com/WebAssembly/binaryen/releases
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Building
|
|
29
|
+
|
|
30
|
+
### Quick Build
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
chmod +x scripts/build-wasm.sh
|
|
34
|
+
./scripts/build-wasm.sh
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Manual Build
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cd domainforge-core
|
|
41
|
+
wasm-pack build --target web --release --out-dir ../pkg --features wasm
|
|
42
|
+
cd ..
|
|
43
|
+
|
|
44
|
+
# Optional: Optimize with wasm-opt
|
|
45
|
+
wasm-opt -Oz -o pkg/domainforge_core_bg_opt.wasm pkg/domainforge_core_bg.wasm
|
|
46
|
+
mv pkg/domainforge_core_bg_opt.wasm pkg/domainforge_core_bg.wasm
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Testing
|
|
50
|
+
|
|
51
|
+
### Unit Tests
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cd domainforge-core
|
|
55
|
+
wasm-pack test --headless --firefox --features wasm
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Browser Testing
|
|
59
|
+
|
|
60
|
+
1. Build the package:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
./scripts/build-wasm.sh
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
2. Start a local server:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
python3 -m http.server 8000
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
3. Open `http://localhost:8000/examples/browser.html`
|
|
73
|
+
|
|
74
|
+
## Package Structure
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
pkg/
|
|
78
|
+
├── package.json # npm package metadata
|
|
79
|
+
├── index.js # JavaScript wrapper with lazy loading
|
|
80
|
+
├── README.md # Package documentation
|
|
81
|
+
├── domainforge_core.js # Generated WASM bindings
|
|
82
|
+
├── domainforge_core.d.ts # TypeScript definitions
|
|
83
|
+
└── domainforge_core_bg.wasm # Compiled WASM binary
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## API
|
|
87
|
+
|
|
88
|
+
The WASM bindings expose the same API as the Rust core:
|
|
89
|
+
|
|
90
|
+
- `Entity` - Business actors, locations, organizational units
|
|
91
|
+
- `Resource` - Quantifiable subjects of value
|
|
92
|
+
- `Flow` - Transfers of resources between entities
|
|
93
|
+
- `Instance` - Physical instances of resources at locations
|
|
94
|
+
- `ResourceInstance` - Physical instances of resources at locations (use `ResourceInstance.new(name, resourceId, quantity?, namespace?, attributes?)`)
|
|
95
|
+
- `Role` - A role label used to classify entities and to define relations (construct via `Role.new(name, namespace?)`)
|
|
96
|
+
- `Relation` - A relation connecting roles, optionally tied to a flow (`Relation.new(name, subjectRoleId, predicate, objectRoleId, viaFlowId?, namespace?, attributes?)`)
|
|
97
|
+
- `Metric` - Observability metrics collected for flows and resources (created via `Metric.new(name, unit?, namespace?)`)
|
|
98
|
+
- `Mapping` - Used for data projections and mapping definitions across models (mapping constructor: `Mapping.new(...)` - refer to mapping docs for details)
|
|
99
|
+
- `Projection` - Projections allow building derived views (e.g., CALM projections) from the Graph
|
|
100
|
+
- `Graph` - Graph container with validation and traversal (uses IndexMap for deterministic iteration)
|
|
101
|
+
- `Graph.parse(source)` - Parse DSL to Graph
|
|
102
|
+
- `Graph.parseToAstJson(source)` - Parse DSL to AST JSON string
|
|
103
|
+
- `formatSource` - Format SEA-DSL source code
|
|
104
|
+
- `checkFormat` - Check if source is already formatted
|
|
105
|
+
|
|
106
|
+
### Constructor Patterns (November 2025)
|
|
107
|
+
|
|
108
|
+
**Entities:**
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
// Default namespace
|
|
112
|
+
const entity = Entity.new("Warehouse"); // namespace() returns "default"
|
|
113
|
+
|
|
114
|
+
// Explicit namespace
|
|
115
|
+
const entity = Entity.newWithNamespace("Warehouse", "logistics");
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Resources:**
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
const resource = Resource.new("Cameras", "units"); // Default namespace
|
|
122
|
+
const resource = Resource.newWithNamespace("Cameras", "units", "inventory");
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Flows:**
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
// Takes ConceptId values - clone before passing
|
|
129
|
+
const flow = Flow.new(resourceId.clone(), fromId.clone(), toId.clone(), 100);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Usage Examples
|
|
133
|
+
|
|
134
|
+
### Parse from DSL
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
import { Graph } from "@godspeedai/domainforge-wasm";
|
|
138
|
+
|
|
139
|
+
// Supports multiline strings with """ syntax
|
|
140
|
+
const source = `
|
|
141
|
+
Entity "Warehouse" in logistics
|
|
142
|
+
Entity """Multi-line
|
|
143
|
+
Factory Name""" in manufacturing
|
|
144
|
+
Resource "Cameras" units
|
|
145
|
+
Flow "Cameras" from "Warehouse" to "Multi-line\\nFactory Name" quantity 100
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
const graph = await Graph.parse(source);
|
|
149
|
+
console.log("Entities:", graph.entityCount());
|
|
150
|
+
console.log("Flows:", graph.flowCount());
|
|
151
|
+
|
|
152
|
+
// Parse to AST JSON directly
|
|
153
|
+
const astJson = Graph.parseToAstJson(source);
|
|
154
|
+
console.log(astJson);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Build Programmatically
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
import { Graph, Entity, Resource, Flow } from "@godspeedai/domainforge-wasm";
|
|
161
|
+
|
|
162
|
+
const graph = new Graph();
|
|
163
|
+
|
|
164
|
+
// Use new() for default namespace, newWithNamespace() for explicit
|
|
165
|
+
const warehouse = Entity.new("Warehouse");
|
|
166
|
+
const factory = Entity.newWithNamespace("Factory", "manufacturing");
|
|
167
|
+
const cameras = Resource.new("Cameras", "units");
|
|
168
|
+
|
|
169
|
+
await graph.addEntity(warehouse);
|
|
170
|
+
await graph.addEntity(factory);
|
|
171
|
+
await graph.addResource(cameras);
|
|
172
|
+
|
|
173
|
+
// Flow constructor takes ConceptId values - clone before passing
|
|
174
|
+
const flow = Flow.new(
|
|
175
|
+
cameras.id().clone(),
|
|
176
|
+
warehouse.id().clone(),
|
|
177
|
+
factory.id().clone(),
|
|
178
|
+
100
|
|
179
|
+
);
|
|
180
|
+
await graph.addFlow(flow);
|
|
181
|
+
|
|
182
|
+
// Namespace is always a string (not null)
|
|
183
|
+
console.log(warehouse.namespace()); // "default"
|
|
184
|
+
console.log(factory.namespace()); // "manufacturing"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Formatting Source Code
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
import { formatSource, checkFormat } from "@godspeedai/domainforge-wasm";
|
|
191
|
+
|
|
192
|
+
const source = 'Entity "Foo" in bar';
|
|
193
|
+
|
|
194
|
+
// Format with defaults
|
|
195
|
+
const formatted = formatSource(source);
|
|
196
|
+
console.log(formatted); // Entity "Foo" in bar
|
|
197
|
+
|
|
198
|
+
// Format with custom options
|
|
199
|
+
const formatted2 = formatSource(source, 2, false, true, true);
|
|
200
|
+
// args: source, indentWidth, useTabs, preserveComments, sortImports
|
|
201
|
+
|
|
202
|
+
// Check if formatted
|
|
203
|
+
const isFormatted = checkFormat(source);
|
|
204
|
+
console.log(isFormatted); // false
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Size Optimization
|
|
208
|
+
|
|
209
|
+
The WASM module is optimized for size:
|
|
210
|
+
|
|
211
|
+
1. **Cargo.toml** optimizations:
|
|
212
|
+
|
|
213
|
+
```toml
|
|
214
|
+
[profile.release]
|
|
215
|
+
opt-level = "z" # Optimize for size
|
|
216
|
+
lto = true # Link-time optimization
|
|
217
|
+
codegen-units = 1 # Better optimization
|
|
218
|
+
strip = true # Strip debug symbols
|
|
219
|
+
panic = 'abort' # Smaller panic handler
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
2. **wasm-opt** post-processing:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
wasm-opt -Oz pkg/domainforge_core_bg.wasm
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
3. **Feature flags** to reduce dependencies:
|
|
229
|
+
```toml
|
|
230
|
+
uuid = { version = "1.6", features = ["v4", "v7", "serde", "wasm-bindgen"] }
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Publishing
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
cd pkg
|
|
237
|
+
npm publish --access public
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Troubleshooting
|
|
241
|
+
|
|
242
|
+
### WASM module fails to load
|
|
243
|
+
|
|
244
|
+
- Ensure server sends correct MIME type: `application/wasm`
|
|
245
|
+
- Check browser console for detailed errors
|
|
246
|
+
- Verify WASM file exists and is not corrupted
|
|
247
|
+
|
|
248
|
+
### Size exceeds 500KB
|
|
249
|
+
|
|
250
|
+
- Run `wasm-opt -Oz` optimization
|
|
251
|
+
- Check for unused dependencies
|
|
252
|
+
- Use feature flags to exclude optional code
|
|
253
|
+
|
|
254
|
+
### TypeScript errors
|
|
255
|
+
|
|
256
|
+
- Ensure `domainforge_core.d.ts` is present in `pkg/`
|
|
257
|
+
- Check TypeScript version compatibility (4.5+)
|
|
258
|
+
|
|
259
|
+
## Architecture
|
|
260
|
+
|
|
261
|
+
### WASM Bindings Layer
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
JavaScript/TypeScript
|
|
265
|
+
↓
|
|
266
|
+
index.js (Wrapper + lazy loading)
|
|
267
|
+
↓
|
|
268
|
+
domainforge_core.js (wasm-bindgen generated)
|
|
269
|
+
↓
|
|
270
|
+
domainforge_core_bg.wasm (Compiled Rust)
|
|
271
|
+
↓
|
|
272
|
+
Rust Core (primitives, graph, parser)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Type Conversions
|
|
276
|
+
|
|
277
|
+
| Rust Type | WASM Boundary | JavaScript Type |
|
|
278
|
+
| --------------- | ------------- | --------------- |
|
|
279
|
+
| `String` | `String` | `string` |
|
|
280
|
+
| `Uuid` | `String` | `string` |
|
|
281
|
+
| `Decimal` | `String` | `string` |
|
|
282
|
+
| `Option<T>` | `nullable T` | `T \| null` |
|
|
283
|
+
| `Result<T, E>` | `throws E` | `Promise<T>` |
|
|
284
|
+
| `Vec<T>` | `Array<T>` | `T[]` |
|
|
285
|
+
| `HashMap<K, V>` | `Object` | `object` |
|
|
286
|
+
|
|
287
|
+
## Performance
|
|
288
|
+
|
|
289
|
+
- **Bundle size**: <500KB gzipped ✅
|
|
290
|
+
- **Parse time**: ~1ms for typical models
|
|
291
|
+
- **Memory**: ~2MB runtime overhead
|
|
292
|
+
- **Initialization**: <50ms (lazy loaded)
|
|
293
|
+
- **Deterministic**: IndexMap ensures reproducible results across runs
|
|
294
|
+
|
|
295
|
+
## CALM Integration (Architecture-as-Code)
|
|
296
|
+
|
|
297
|
+
Export/import graphs to/from FINOS CALM format:
|
|
298
|
+
|
|
299
|
+
```javascript
|
|
300
|
+
import { Graph } from "@godspeedai/domainforge-wasm";
|
|
301
|
+
|
|
302
|
+
// Build your model
|
|
303
|
+
const graph = new Graph();
|
|
304
|
+
// ... add entities, resources, flows ...
|
|
305
|
+
|
|
306
|
+
// Export to CALM JSON
|
|
307
|
+
const calmJson = await graph.exportCalm();
|
|
308
|
+
console.log(calmJson); // CALM JSON string
|
|
309
|
+
|
|
310
|
+
// Import from CALM
|
|
311
|
+
const importedGraph = await Graph.importCalm(calmJson);
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Semantic Pack API
|
|
315
|
+
|
|
316
|
+
The WASM bindings expose semantic pack enums and functions for browser and edge runtime usage.
|
|
317
|
+
|
|
318
|
+
### Enums
|
|
319
|
+
|
|
320
|
+
```javascript
|
|
321
|
+
import {
|
|
322
|
+
SemanticTruth, // Valid = 0, Invalid = 1, Unknown = 2
|
|
323
|
+
DiagnosticSeverity, // Error = 0, Warning = 1, Info = 2, Hint = 3
|
|
324
|
+
ValidationMode, // Off = 0, Warn = 1, Strict = 2
|
|
325
|
+
ApprovalState, // Candidate = 0, Approved = 1, Rejected = 2
|
|
326
|
+
SignatureState, // Unsigned = 0, Signed = 1, InvalidSignature = 2
|
|
327
|
+
ConceptStatus, // Active = 0, Proposed = 1, Deprecated = 2, Rejected = 3, ExternalOnly = 4
|
|
328
|
+
ConceptKind, // Entity = 0, Resource = 1, Role = 2, Flow = 3, Policy = 4, Metric = 5, Dimension = 6, Unit = 7, External = 8
|
|
329
|
+
AliasStatus, // Approved = 0, Deprecated = 1, Ambiguous = 2, Blocked = 3
|
|
330
|
+
SemanticValidationStatus, // Passed = 0, Failed = 1, Unknown = 2, Blocked = 3
|
|
331
|
+
} from "@godspeedai/domainforge-wasm";
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Functions
|
|
335
|
+
|
|
336
|
+
#### semanticPackBuild
|
|
337
|
+
|
|
338
|
+
Build a semantic pack from input JSON. Returns a JSON string with `pack`, `pack_content_hash`, `meaning_fingerprint`, `pre_pack_diagnostics`, and `build_warnings`.
|
|
339
|
+
|
|
340
|
+
```javascript
|
|
341
|
+
const result = semanticPackBuild(inputJson);
|
|
342
|
+
const { pack, pack_content_hash, meaning_fingerprint } = JSON.parse(result);
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### semanticPackValidate
|
|
346
|
+
|
|
347
|
+
Validate a pack's internal consistency. Returns a JSON array of diagnostics.
|
|
348
|
+
|
|
349
|
+
```javascript
|
|
350
|
+
const diagnosticsJson = semanticPackValidate(packJson);
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### semanticPackValidateGraph
|
|
354
|
+
|
|
355
|
+
Validate a source against a pack with options. Returns a JSON validation result.
|
|
356
|
+
|
|
357
|
+
```javascript
|
|
358
|
+
const resultJson = semanticPackValidateGraph(packJson, "source_uri", optionsJson);
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### semanticPackSign
|
|
362
|
+
|
|
363
|
+
Sign a pack with an Ed25519 private key (PEM string). Returns the signed pack JSON. Throws `JsError` on failure.
|
|
364
|
+
|
|
365
|
+
```javascript
|
|
366
|
+
const signedJson = semanticPackSign(packJson, privateKeyPem);
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
#### semanticPackVerify
|
|
370
|
+
|
|
371
|
+
Verify a pack's Ed25519 signature. Returns `true` if valid, throws `JsError` on failure.
|
|
372
|
+
|
|
373
|
+
```javascript
|
|
374
|
+
const isValid = semanticPackVerify(packJson, publicKeyPem);
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
#### semanticPackDiff
|
|
378
|
+
|
|
379
|
+
Compare two packs. Returns a JSON diff with entries and summary.
|
|
380
|
+
|
|
381
|
+
```javascript
|
|
382
|
+
const diffJson = semanticPackDiff(oldPackJson, newPackJson);
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
#### semanticPackHash
|
|
386
|
+
|
|
387
|
+
Compute the content hash of a pack (excluding signature fields).
|
|
388
|
+
|
|
389
|
+
```javascript
|
|
390
|
+
const hash = semanticPackHash(packJson);
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
#### semanticNormalizeKey
|
|
394
|
+
|
|
395
|
+
Normalize a term for lookup (NFC, case-fold, whitespace collapse).
|
|
396
|
+
|
|
397
|
+
```javascript
|
|
398
|
+
const normalized = semanticNormalizeKey(" Hello World "); // "hello world"
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
#### semanticResolveConcept
|
|
402
|
+
|
|
403
|
+
Resolve a term against a pack. Returns a JSON object with `resolved_concept_id`, `semantic_truth`, `diagnostic_code`, `diagnostic_severity`, `message`, and `suggestions`.
|
|
404
|
+
|
|
405
|
+
```javascript
|
|
406
|
+
const resultJson = semanticResolveConcept("Supplier", packJson, optionsJson);
|
|
407
|
+
const result = JSON.parse(resultJson);
|
|
408
|
+
console.log(result.resolved_concept_id); // "supplier" or null
|
|
409
|
+
console.log(result.semantic_truth); // "valid", "invalid", or "unknown"
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Related Documentation
|
|
413
|
+
|
|
414
|
+
- [Phase 9 Plan](../../work/plans/Phase 9_WASM Bindings.md)
|
|
415
|
+
- [Package README](../../pkg/README.md)
|
|
416
|
+
- [Browser Example](../../examples/browser.html)
|
|
417
|
+
|
|
418
|
+
## License
|
|
419
|
+
|
|
420
|
+
Apache-2.0
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Semantic Pack Review Process
|
|
2
|
+
|
|
3
|
+
Every semantic pack that transitions from `candidate` to `approved` must pass a review gate. This document describes the review manifest format, the allowed decisions, and the checks the build system performs.
|
|
4
|
+
|
|
5
|
+
## Why Review Is Required
|
|
6
|
+
|
|
7
|
+
Semantic packs define the vocabulary that downstream tools---the LSP, CI validators, code generators---treat as authoritative. An unreviewed pack that introduces a misspelled concept name or an ambiguous alias can silently corrupt generated code, produce misleading diagnostics, or break compatibility with existing consumers.
|
|
8
|
+
|
|
9
|
+
Review is the **bootstrapping boundary**: it is the moment when a human confirms that the vocabulary is intentional, the definitions are correct, and the ownership is assigned. The build system enforces that every active concept in an approved pack has a matching review record.
|
|
10
|
+
|
|
11
|
+
## Review Manifest Format
|
|
12
|
+
|
|
13
|
+
Review records are stored as JSONL (one JSON object per line). Each record captures a single review decision:
|
|
14
|
+
|
|
15
|
+
```jsonl
|
|
16
|
+
{"decision_id":"rev-001","subject_type":"concept","subject_id":"supplier","decision":"approve","rationale":"Approved after stakeholder review","reviewer":"alice@acme.com","reviewed_at":"2025-06-01T10:00:00Z","definition_hash":"sha256:a1b2c3...","previous_definition_hash":null,"new_definition_hash":null}
|
|
17
|
+
{"decision_id":"rev-002","subject_type":"concept","subject_id":"warehouse","decision":"approve","rationale":"Matches supply chain taxonomy","reviewer":"bob@acme.com","reviewed_at":"2025-06-01T11:00:00Z","definition_hash":"sha256:d4e5f6...","previous_definition_hash":null,"new_definition_hash":null}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Fields
|
|
21
|
+
|
|
22
|
+
| Field | Type | Description |
|
|
23
|
+
|------------------------------|--------|--------------------------------------------------------------------|
|
|
24
|
+
| `decision_id` | string | Unique identifier for this review decision. |
|
|
25
|
+
| `subject_type` | string | What is being reviewed. Currently `concept`. |
|
|
26
|
+
| `subject_id` | string | The `id` of the concept being reviewed. |
|
|
27
|
+
| `decision` | string | The review decision. See below for allowed values. |
|
|
28
|
+
| `rationale` | string | Human-readable explanation for the decision. |
|
|
29
|
+
| `reviewer` | string | Identifier for the reviewer (email, username, or system ID). |
|
|
30
|
+
| `reviewed_at` | string | RFC 3339 timestamp of when the review occurred. |
|
|
31
|
+
| `definition_hash` | string | The definition hash at the time of review. |
|
|
32
|
+
| `previous_definition_hash` | string | (Optional) The hash before a minor amendment. |
|
|
33
|
+
| `new_definition_hash` | string | (Optional) The hash after a minor amendment. |
|
|
34
|
+
|
|
35
|
+
## Allowed Decision Values
|
|
36
|
+
|
|
37
|
+
| Decision | Effect |
|
|
38
|
+
|---------------------------------------|------------------------------------------------------------------------|
|
|
39
|
+
| `approve` | The concept is approved for inclusion in the pack. |
|
|
40
|
+
| `reject` | The concept must not appear in an approved pack. |
|
|
41
|
+
| `deprecate` | The concept is approved but marked for future removal. |
|
|
42
|
+
| `merge_into` | The concept should be merged into another concept. |
|
|
43
|
+
| `split_required` | The concept covers too many meanings and must be split. |
|
|
44
|
+
| `needs_definition` | The concept lacks a definition and must be defined before approval. |
|
|
45
|
+
| `needs_owner` | The concept lacks an owner and must have one assigned. |
|
|
46
|
+
| `minor_amendment_no_semantic_change` | A cosmetic change (formatting, typo fix) that does not alter semantics. |
|
|
47
|
+
|
|
48
|
+
Only `approve` and `minor_amendment_no_semantic_change` count as passing reviews for the purpose of review coverage.
|
|
49
|
+
|
|
50
|
+
## Definition Hash Matching
|
|
51
|
+
|
|
52
|
+
When building an approved pack, the builder validates that each active concept's `definition_hash` matches the hash recorded in the review manifest. This ensures that no concept has been modified after review without a corresponding review record.
|
|
53
|
+
|
|
54
|
+
The builder checks hashes in order:
|
|
55
|
+
|
|
56
|
+
1. **Match**: The current definition hash matches the reviewed hash. Pass.
|
|
57
|
+
2. **Minor Amendment**: The decision is `minor_amendment_no_semantic_change` and the `new_definition_hash` matches the current hash. Pass.
|
|
58
|
+
3. **Mismatch**: The current hash differs from the reviewed hash and no minor amendment covers the transition. The build emits an `unreviewed_concept` diagnostic.
|
|
59
|
+
4. **No Review**: No review record exists for this concept. The build emits an `unreviewed_concept` diagnostic.
|
|
60
|
+
|
|
61
|
+
### What Happens on Mismatch
|
|
62
|
+
|
|
63
|
+
A hash mismatch blocks the approved build. The error message includes both the reviewed hash and the current hash:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
[ERROR] unreviewed_concept: Definition hash mismatch for 'supplier': reviewed='sha256:a1b2c3...', current='sha256:x9y8z7...'
|
|
67
|
+
hint: Re-review or record minor_amendment_no_semantic_change
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To resolve a mismatch:
|
|
71
|
+
|
|
72
|
+
- **If the change is cosmetic** (whitespace, formatting, typo in examples): add a `minor_amendment_no_semantic_change` review record with `previous_definition_hash` set to the old hash and `new_definition_hash` set to the current hash.
|
|
73
|
+
- **If the change is semantic** (definition text, status, meaning): add a full `approve` review record with the new definition hash.
|
|
74
|
+
|
|
75
|
+
## Minor Amendment Path
|
|
76
|
+
|
|
77
|
+
The minor amendment path exists because small formatting changes should not require a full re-review cycle. The rules are:
|
|
78
|
+
|
|
79
|
+
1. A minor amendment must still have a `decision_id`, a `reviewer`, and a `reviewed_at` timestamp.
|
|
80
|
+
2. The amendment must include both `previous_definition_hash` and `new_definition_hash`.
|
|
81
|
+
3. The amendment does not reset the `meaning_version`---it is explicitly a non-semantic change.
|
|
82
|
+
|
|
83
|
+
Example minor amendment record:
|
|
84
|
+
|
|
85
|
+
```jsonl
|
|
86
|
+
{"decision_id":"rev-042","subject_type":"concept","subject_id":"supplier","decision":"minor_amendment_no_semantic_change","rationale":"Fixed typo in counterexample","reviewer":"alice@acme.com","reviewed_at":"2025-06-05T14:00:00Z","definition_hash":"sha256:a1b2c3...","previous_definition_hash":"sha256:a1b2c3...","new_definition_hash":"sha256:m3n4o5..."}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Operational Cost
|
|
90
|
+
|
|
91
|
+
Any change to a concept's `text`, `examples`, `counterexamples`, or `status` changes the `definition_hash`. This means:
|
|
92
|
+
|
|
93
|
+
- **Fixing a typo in an example** changes the hash and forces re-review (or a minor amendment).
|
|
94
|
+
- **Adding a counterexample** changes the hash and forces re-review.
|
|
95
|
+
- **Changing status** (e.g., `active` to `deprecated`) changes the hash.
|
|
96
|
+
|
|
97
|
+
This is intentional. The hash covers the full definition surface to prevent silent semantic drift. Teams should expect that most changes to active concepts require a review record.
|
|
98
|
+
|
|
99
|
+
## CLI Usage
|
|
100
|
+
|
|
101
|
+
### Building an Approved Pack with Review
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
domainforge pack build \
|
|
105
|
+
--source "models/**/*.sea" \
|
|
106
|
+
--org acme \
|
|
107
|
+
--domain logistics \
|
|
108
|
+
--version 1.1.0 \
|
|
109
|
+
--meaning-version 1.1.0 \
|
|
110
|
+
--approval approved \
|
|
111
|
+
--review reviews/logistics-review.jsonl \
|
|
112
|
+
--previous-pack packs/acme-logistics-1.0.0.json \
|
|
113
|
+
--out packs/acme-logistics-1.1.0.json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The `--review` flag points to the JSONL file containing review records. The builder reads all records, validates coverage for active concepts, and checks definition hash matches.
|
|
117
|
+
|
|
118
|
+
### Review Coverage Errors
|
|
119
|
+
|
|
120
|
+
If any active concept lacks a passing review, the build fails:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
[ERROR] unreviewed_concept: Concept 'new_concept' lacks review approval
|
|
124
|
+
hint: Add review decision for this concept
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Definition Hash Mismatch Errors
|
|
128
|
+
|
|
129
|
+
If a concept's definition changed after review without a new review record:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
[ERROR] unreviewed_concept: Definition hash mismatch for 'supplier': reviewed='sha256:a1b2c3...', current='sha256:x9y8z7...'
|
|
133
|
+
hint: Re-review or record minor_amendment_no_semantic_change
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Review Manifest Hash
|
|
137
|
+
|
|
138
|
+
The builder computes a deterministic hash of the review manifest itself (`review_manifest_hash`). This hash is included in the pack so downstream consumers can verify that the review records used during the build have not been tampered with. The hash is computed by sorting review records by `decision_id` and hashing the canonical JSON representation.
|
|
139
|
+
|
|
140
|
+
## See Also
|
|
141
|
+
|
|
142
|
+
- [Semantic Packs](semantic-packs.md) for the overall pack system.
|
|
143
|
+
- [Semantic Pack Signing and Verification](semantic-pack-signing.md) for the signing layer that runs after review.
|
|
144
|
+
- [Semantic Diagnostic Codes](diagnostics.md) for `unreviewed_concept` and related codes.
|