Third batch of v1 features. With the gates honored, configuration
mistakes (orphan tokens, dependency cycles, ordering bugs) became
silently fatal: the action skips/blocks at runtime with a misleading
"reason" like "after-not-met:foo" without telling the developer that
"foo" is never produced by anything. validate() catches those before
the first event arrives.
API: EngineOrca.validate(): OrcaValidateResult
- ok: false iff any issue has severity 'error'
- issues: array of OrcaValidateIssue { kind, severity, event,
actionId?, token?, cycle?, message }
- Never throws. Read-only over the registered set; safe to call
multiple times during config; engine does not gate runs on result.
Issue kinds:
- unsatisfiable-after (ERROR) — an action's `after: [T]` is not
produced by any earlier action in canonical order. Action would
always skip at runtime.
- orphan-unless / orphan-abort-on (WARN) — gate token has no
upstream producer. May be deliberate (forward-compat / typo
guard); demoted to warning so `ok` stays true.
- dependency-cycle (ERROR) — actions block on each other through
`after` / `provides`. DFS over an action-level adjacency map
(A → set of action ids it depends on); cycles deduped via a
canonical fingerprint (rotated to lexicographically smallest id
first).
Canonical order matters: actions are sorted by (stage, registeredAt)
so the validator's "did any earlier action provide T" matches what
the engine does at runtime. Concrete consequences:
- A producer registered AFTER the consumer in the same stage is
NOT considered upstream — runtime would skip the consumer, and
validate() reports it.
- A producer in a LATER stage (e.g. POST when consumer is MAIN)
is NOT considered upstream either.
Tests (+11):
- empty engine returns { ok: true, issues: [] }
- happy path: provider in earlier stage satisfies consumer
- reports unsatisfiable-after for missing token
- reports unsatisfiable-after when producer registered AFTER consumer
in the same stage (subtle ordering bug)
- reports unsatisfiable-after when producer is in a later stage
- reports orphan-unless as warning (ok stays true)
- reports orphan-abort-on as warning
- detects direct 2-action cycle
- detects indirect 3-action cycle (cycle.length === 4 with closure)
- warnings do not flip ok to false
- issues are isolated per event (cross-event tokens don't satisfy
each other)
Constants exported from $orca:
ORCA_VALIDATE_UNSATISFIABLE_AFTER
ORCA_VALIDATE_ORPHAN_UNLESS
ORCA_VALIDATE_ORPHAN_ABORT_ON
ORCA_VALIDATE_DEPENDENCY_CYCLE
ORCA_VALIDATE_SEVERITY_ERROR
ORCA_VALIDATE_SEVERITY_WARN
Types exported: OrcaValidateIssue, OrcaValidateIssueKind,
OrcaValidateResult, OrcaValidateSeverity.
README updated: validate() moved from "Roadmap v1" into "Ya en el motor
(de v1)". Remaining v1 items: compensate, commit() configuration freeze,
queue policies (commit/replace), transaction groups, parallel,
payload-bearing tokens, fan-in, bus interception (Option B), and
createActiveOrca() reactive wrapper.
Verification: 1392/1392 tests pass (82 in orca, +11 from this commit).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
master
parent
79d6d1f776
commit
7aebe7c673
Loading…
Reference in new issue