Files
ruv 350bcf0606 feat(browser): #2041 ADR-122 Phase 7 — Workflow Compiler + production-aware UCT
Phase 7 (substrate-layer compiler):
- domain/workflow.ts — CompiledWorkflow schema with WorkflowStep (primary
  SelectorSpec + ordered fallback chain), WorkflowRequirements (sessionCapsule,
  origins[], taskClass), WorkflowGuards (irreversibleAction,
  requiresUserConfirmation), WorkflowReplay (maxRetries, timeoutMs).
  ProductionUctSignals/Weights for the production-aware UCT formula.
- application/workflow-compiler.ts — WorkflowCompiler.compile() walks a signed
  trajectory envelope's steps, extracts the primary locator from each step
  input, derives an ordered selector fallback chain from observed snapshot
  metadata (role+name → text → ref), classifies highest-risk action via
  Phase 6 RiskClassifier, gates requirements + guards. toYaml() emits
  deterministic, parseable YAML for VCS check-in.
- application/production-uct.ts — productionUct(input, weights) implements
  the full substrate scoring formula:
    score = Q + C·√(ln(N)/n) + λ_R·replayability
            − λ_risk·risk − μ_cost·cost − α_auth·auth_fragility
  Unvisited branches still return +Infinity for parity with Phase 4 UCB1.
  blendQ() linearly mixes scorer value + replay-success-rate.
- 12 new tests: compile login flow + fallback chain, financial-action
  guard escalation, origin extraction, deterministic YAML output, UCT
  invariants (infinity for unvisited, prefers safe over risky, penalises
  cost, rewards replayability, custom weights honoured), blendQ linearity.

Renames in src/index.ts re-export: WorkflowStep → CompiledWorkflowStep
(avoids collision with workflow-templates.ts's pre-existing WorkflowStep).

230/230 tests passing (+12 for Phase 7). Build + typecheck clean.

Beyond SOTA: no other web agent compiles MCTS traces into signed, replayable
YAML workflows with selector fallback graphs. The compiler is the "output of
the substrate" — what makes browser experience truly reusable.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-18 19:28:31 -04:00
..