mdcode: support actions in the semantic model (prototype) - #346
Draft
libei wants to merge 3 commits into
Draft
Conversation
Add model-level actions -- named write operations over the ontology, the write-side counterpart to metrics -- across the pipeline: - IR: Action / ActionParameter / Executor (mcp|rest|grpc tagged union). - Loader: parse the actions block; normalize the single-key executor to the tagged union; resolve each parameter type to an entity (object reference) or a scalar datatype (isEntityRef), warning on an unresolved type; enforce exactly one executor kind at parse. - OSI converter: emit actions back to the open-format YAML (round-trip stable). - Validate: hard-gate unresolved parameter types and blank executor coordinates; runs for every --target (actions publish regardless of BQ). - BigQuery leg: actions have no graph construct; warn once, emit nothing. - Knowledge Catalog: publish actions on the model anchor's built-in overview aspect (Markdown + an embedded JSON block); pull recovers them from the JSON. - Docs + tests + a PlaceOrder fixture. Scope: precondition and affects are intentionally not modelled in this prototype.
- KC re-push: always name the conditional overview/guidelines aspect keys in the entries.patch aspectKeys so a dropped action aspect is cleared server-side instead of being resurrected by a later pull. - loader: warn on duplicate parameter names within an action, matching the duplicate field/metric/action-name checks. - push: warn when a model declares actions but the selected --target omits the Knowledge Catalog leg, so they are not dropped silently. - Correct the bigquery warning and reference doc to say actions publish to Knowledge Catalog only when that destination is in the push. - Drop the now-unused DataType import.
De-reflow the actions prototype so the PR diff carries only the feature. Revert clang-format churn across ir/loader/validate/knowledge_catalog/ osi_converter/pull_kc and the osi_* tests, keeping the actions additions in the repo's own style (net diff drops from ~1465 lines to ~990, deletions from 342 to 10 -- the remaining deletions are intentional import merges and two call-site changes). Also address the remaining code-review findings: - kc_converter.readExecutor rejects blank executor coordinates on pull, so a hand-edited empty coordinate is treated as malformed exactly as push-side validate would, instead of recovering an action the next push cannot deploy. - kc_converter.readParameter warns when a parameter type resolves to neither a known entity nor a scalar (e.g. the referenced entity was absent from the pull) rather than silently dropping isEntityRef; add a pull test. - kc_converter.jsonBlockAfterMarker keys off lastIndexOf so a stray marker in the human-readable section cannot shadow the real fenced JSON block. - deploy_knowledge_catalog.reconciledAspectKeys scopes the anchor-only overview key to the model anchor; guidelines stays reconciled on every entry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Prototype support for actions in the mdcode semantic model — named write operations over the ontology, the write-side counterpart to metrics. Both are model-level and defined over the concepts (not bound to one entity); the difference is direction (a metric reads a value, an action changes state).
An action names a business operation and delegates the mechanics to an executor; the model contributes what a plain tool schema can't — parameters typed by the ontology, where an entity-typed parameter is an object reference and a scalar type is a value.
Changes (by pipeline leg)
ir.ts):Action/ActionParameter/Executor(tagged union overmcp|rest|grpc).loader.ts): parse theactionsblock; normalize the open format's single-key executor to the tagged union; resolve each parametertypeto a known entity (isEntityRef: true) or a scalar datatype (false), warning on an unresolved type; enforce "exactly one executor kind" at parse.osi_converter.ts): emit actions back to open-format YAML — round-trip stable (covered by the existing loader↔serialize round-trip test via a new fixture).validate.ts): hard-gate unresolved parameter types and blank executor coordinates; runs for every--target, since actions publish to Knowledge Catalog regardless of the BigQuery leg.bigquery.ts): actions are write-side and have no graph construct — warn once, emit nothing.knowledge_catalog.ts/kc_converter.ts/pull_kc.ts): actions have nosemantic-*system type, so they ride the model anchor's built-inoverviewaspect (human-readable Markdown + an embedded JSON block);pullrecovers them losslessly from the JSON.actions.test.ts(loader parse, validation, KC publish/pull round trip) and aPlaceOrderfixture.Scope
This is a prototype. An action's
precondition(gate) andaffects(blast radius) are intentionally not modelled yet.Testing
tsc -p src/libts/tsconfig.json --noEmit— clean.npm test— 501 semantic tests pass (incl. the new round-trip and OSI-schema guardrail tolerance for theactionssuperset).