feat(workflow): iw-support-workflow — declarative workflow kernel extracted from MEDECA #34

Merged
mprihoda merged 2 commits from workflow-kernel-extraction into main 2026-07-12 18:52:30 +00:00
mprihoda commented 2026-07-12 16:23:49 +00:00 (Migrated from github.com)

What

New cross-built (JVM + Scala.js) module workflow, published as iw-support-workflow, package works.iterative.workflow. It is the executable workflow kernel extracted from MEDECA mdr.workflow (built under MEDECA-381/382; copied from merged MEDECA main @ 3db92b52f, byte-verified against the source worktree):

  • Guard algebra: Guard (Requirement / Invalid / RequireRole / RequireIdentity / And / Or / always) with co-located check/describe, GuardContext, GuardFailure, GuardDescription, Predicate, stripAuth
  • Engine types: CommandMatch, EventShape, Outcome, Transition (+ Transition.simple), EngineDefinition
  • WorkflowInterpreter.decide — pure match → gate → classify → emit, with AuthEnforcement.Skip/Enforce and Rejection vocabulary
  • ConformanceCheck + Witness — in main sources (it is a pure List[String] harness with no test-framework deps; consumers exercise it from their own test suites, and published test sources don't exist)

The role type is now a leading type parameter R (e.g. Guard[R, S], EngineDefinition[R, State, Entity, Command, Event]), replacing the hardcoded mdr.poptavky.AppRole — this completes what MEDECA-379 anticipated. CommandMatch/EventShape/Outcome/Witness/Rejection/AuthEnforcement hold no guards and gain no parameter.

Ported specs: GuardSpec, WorkflowInterpreterSpec (all original test cases, AppRole fixtures replaced by a test-local TestRole enum). MEDECA's descriptive layer (Phase, StateDefinition, ClockOwner, WorkflowDefinition, EngineProjection, WorkflowDiagram) deliberately stays in MEDECA — it carries MEDECA vocabulary and is a possible second extraction after generalization.

Verification

  • workflow.{jvm,js}.{compile,test}, checkFormat, fix --check all green at Scala 3.3.7 LTS; full __.compile and pre-push __.test green across the repo
  • Multi-lens adversarial review (parity vs originals / API / build wiring): zero confirmed defects
  • Consumption spike: published 0.1.19-SNAPSHOT via publishLocal and compiled + executed a foreign consumer (Scala 3.8.4, Mill, own enum SpikeRole) exercising Transition.simple, decide under Enforce, describe, and ConformanceCheck.errors — full type inference, no explicit type args needed; runtime assertions passed

Notes for reviewer

  • Scaladoc in Engine.scala/GuardFailure.scala/Guard.scala still uses MEDECA examples (Poptávka/Podání, MEDECA issue IDs) as motivating illustrations. Comment-only; left intact deliberately (only GuardContext's now-false MEDECA-379 deferral note and WorkflowInterpreter's CommandError references were generalized). Happy to sweep them if preferred.
  • Version stays 0.1.19-SNAPSHOT — no tag; release when a consumer needs a durable resolver.
  • MEDECA adoption of the artifact (deleting its local kernel copy) is out of scope → MEDECA-379.

🤖 Generated with Claude Code

## What New cross-built (JVM + Scala.js) module **`workflow`**, published as `iw-support-workflow`, package `works.iterative.workflow`. It is the executable workflow kernel extracted from MEDECA `mdr.workflow` (built under MEDECA-381/382; copied from merged MEDECA main @ `3db92b52f`, byte-verified against the source worktree): - Guard algebra: `Guard` (Requirement / Invalid / RequireRole / RequireIdentity / And / Or / always) with co-located `check`/`describe`, `GuardContext`, `GuardFailure`, `GuardDescription`, `Predicate`, `stripAuth` - Engine types: `CommandMatch`, `EventShape`, `Outcome`, `Transition` (+ `Transition.simple`), `EngineDefinition` - `WorkflowInterpreter.decide` — pure match → gate → classify → emit, with `AuthEnforcement.Skip/Enforce` and `Rejection` vocabulary - `ConformanceCheck` + `Witness` — in **main** sources (it is a pure `List[String]` harness with no test-framework deps; consumers exercise it from their own test suites, and published test sources don't exist) The role type is now a leading type parameter `R` (e.g. `Guard[R, S]`, `EngineDefinition[R, State, Entity, Command, Event]`), replacing the hardcoded `mdr.poptavky.AppRole` — this completes what MEDECA-379 anticipated. `CommandMatch`/`EventShape`/`Outcome`/`Witness`/`Rejection`/`AuthEnforcement` hold no guards and gain no parameter. Ported specs: `GuardSpec`, `WorkflowInterpreterSpec` (all original test cases, `AppRole` fixtures replaced by a test-local `TestRole` enum). MEDECA's descriptive layer (Phase, StateDefinition, ClockOwner, WorkflowDefinition, EngineProjection, WorkflowDiagram) deliberately stays in MEDECA — it carries MEDECA vocabulary and is a possible second extraction after generalization. ## Verification - `workflow.{jvm,js}.{compile,test}`, `checkFormat`, `fix --check` all green at Scala 3.3.7 LTS; full `__.compile` and pre-push `__.test` green across the repo - Multi-lens adversarial review (parity vs originals / API / build wiring): zero confirmed defects - Consumption spike: published `0.1.19-SNAPSHOT` via publishLocal and compiled + executed a foreign consumer (Scala 3.8.4, Mill, own `enum SpikeRole`) exercising `Transition.simple`, `decide` under `Enforce`, `describe`, and `ConformanceCheck.errors` — full type inference, no explicit type args needed; runtime assertions passed ## Notes for reviewer - Scaladoc in `Engine.scala`/`GuardFailure.scala`/`Guard.scala` still uses MEDECA examples (Poptávka/Podání, MEDECA issue IDs) as motivating illustrations. Comment-only; left intact deliberately (only `GuardContext`'s now-false MEDECA-379 deferral note and `WorkflowInterpreter`'s CommandError references were generalized). Happy to sweep them if preferred. - Version stays `0.1.19-SNAPSHOT` — no tag; release when a consumer needs a durable resolver. - MEDECA adoption of the artifact (deleting its local kernel copy) is out of scope → MEDECA-379. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mph referenced this pull request from a commit 2026-07-13 10:21:58 +00:00
Sign in to join this conversation.
No description provided.