Skip to content

mdcode: support actions in the semantic model (prototype) - #346

Draft
libei wants to merge 3 commits into
GoogleCloudPlatform:mainfrom
libei:worktree-kcmd-actions
Draft

mdcode: support actions in the semantic model (prototype)#346
libei wants to merge 3 commits into
GoogleCloudPlatform:mainfrom
libei:worktree-kcmd-actions

Conversation

@libei

@libei libei commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

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 (ir.ts): Action / ActionParameter / Executor (tagged union over mcp | rest | grpc).
  • Loader (loader.ts): parse the actions block; normalize the open format's single-key executor to the tagged union; resolve each parameter type to a known entity (isEntityRef: true) or a scalar datatype (false), warning on an unresolved type; enforce "exactly one executor kind" at parse.
  • OSI converter (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 (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 (bigquery.ts): actions are write-side and have no graph construct — warn once, emit nothing.
  • Knowledge Catalog (knowledge_catalog.ts / kc_converter.ts / pull_kc.ts): actions have no semantic-* system type, so they ride the model anchor's built-in overview aspect (human-readable Markdown + an embedded JSON block); pull recovers them losslessly from the JSON.
  • Docs: authoring section, the BigQuery/KC "what gets created" tables, validation + permissions bullets, and the fidelity matrix.
  • Tests + fixture: actions.test.ts (loader parse, validation, KC publish/pull round trip) and a PlaceOrder fixture.

Scope

This is a prototype. An action's precondition (gate) and affects (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 the actions superset).

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.
libei added 2 commits August 28, 2026 15:04
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant