Skip to content

feat(workflow): declarative shelf-key schema contract + contract-driven debug probes - #1

Merged
moonexpr merged 1 commit into
betafrom
feat/shelf-schema-contract
Jul 7, 2026
Merged

moonexpr merged 1 commit into
betafrom
feat/shelf-schema-contract

Conversation

@moonexpr

@moonexpr moonexpr commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

Adds a declarative, per-shelf-key type contract to the workflow engine and drives the debug viewer's probe forms from it. A shelf key (e.g. input.job, read by 11 actions) is declared once and shared — the contract lives with the key, not the action.

Why

The debug viewer's probe previously used a single freeform textarea per input, with no type information anywhere in the model (IORef carried only alias/shelf/key; shelves are untyped Any stores). This introduces a real, single-source contract that both drives typed tooling and can enforce shape at runtime.

Changes

Engine (foundation/workflow/)

  • schema.py — ShelfSchema/FieldSchema: a self-defined type spec (no jsonschema dep, keeps the package a leaf) with validate() + to_dict().
  • loader.py — load_schemas() resolves a schemas: include (file globs or inline) into WorkflowNode.schemas; wired through the normal and overlay paths.
  • graph.py — emits graph["schemas"] so any UI gets the contract.
  • visitor.py — opt-in enforcement in _write_outputs, gated by DISPATCH_ENFORCE_SCHEMA (off by default); a violation fails the step cleanly via SchemaContractError.

Contract

  • app/config/schemas/baseworkflow.yml — types for all 17 input-read shelf refs (required, enum, numeric bounds, descriptions, prefill examples), referenced from baseworkflow.yml via schemas: [../config/schemas/*.yml].

Debug viewer (tools/debugviewer/)

  • server.py — probe validates inputs against the contract, returns per-field errors.
  • viewer.html — probe forms render typed controls from the declared schema (enum → dropdown, required markers, numeric bounds, prefill) with client + server validation. Also: Cirrus CSS, centered graph, draggable inspector resize, collapsible attributes, light/dark toggle, native-control theming, and fixes for Cirrus global class collisions.

Verification

  • foundation/workflow + baseworkflow test suites green
  • New foundation/workflow/test_schema.py (8 cases)
  • Workflow validation unchanged: [PASS] … (4 phases)
  • run_mock green with enforcement off and on — the contract matches real data (no false positives)
  • Enforcement teeth proven: bad enum / out-of-range → precise SchemaContractError
  • Probe forms + validation verified in a real browser

Safety

Enforcement ships off (DISPATCH_ENFORCE_SCHEMA unset) — zero change to live-pipeline behavior. Recommend a shadow/log-only pass across a few live ticks before enabling it.

…en debug probes

Add a declarative, per-shelf-key type contract to the workflow engine and wire it
through the debug viewer's probe forms. A shelf key (e.g. input.job, read by 11
actions) is declared ONCE and shared — the contract lives with the key, not the
action.

Engine (foundation/workflow):
- schema.py: ShelfSchema/FieldSchema — a self-defined type spec (no jsonschema
  dependency, keeps the package a leaf) with validate() + to_dict().
- loader.py: load_schemas() resolves a `schemas:` include (file globs or inline)
  into WorkflowNode.schemas; wired through both the normal and overlay paths.
- graph.py: emit graph["schemas"] so any UI gets the contract for free.
- visitor.py: opt-in enforcement in _write_outputs, gated by
  DISPATCH_ENFORCE_SCHEMA (OFF by default) — a violation fails the step cleanly
  via SchemaContractError, with zero change to live-pipeline behavior when unset.

Contract:
- app/config/schemas/baseworkflow.yml: types for all 17 input-read shelf refs
  (required, enum, numeric bounds, descriptions, prefill examples), referenced
  from baseworkflow.yml via `schemas: [../config/schemas/*.yml]`.

Debug viewer (tools/debugviewer):
- server.py: probe validates inputs against the contract, returns field errors.
- viewer.html: probe forms render typed controls from the DECLARED schema
  (enum -> dropdown, required markers, numeric bounds, prefill), with client +
  server validation. Also: Cirrus CSS framework, centered graph, draggable
  inspector resize (persisted), collapsible attributes, light/dark toggle
  (persisted), color-scheme for native controls, and fixes for Cirrus global
  class collisions (button/select overflow, .row spacing).

Tests: foundation/workflow/test_schema.py (8 cases). Full workflow + baseworkflow
suites green; workflow validation unchanged (4 phases).
@moonexpr moonexpr added the Candidate Complete and validated — proposed for review/merge label Jul 7, 2026
@moonexpr
moonexpr merged commit 16ad0ef into beta Jul 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Candidate Complete and validated — proposed for review/merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant