validate

package
v0.194.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0, MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package validate holds the workflow DSL validators. Rules are plain functions over the resolved ir.Graph returning []Diagnostic: no framework, no registry, no reflection. A rule never mutates the graph and never assumes the graph was built honestly, and an aggregate runs every rule in its family so a caller reports all findings at once instead of only the first.

Rule codes are the stable contract with authors and with the trace surface. This family owns the structural rules:

WF001  the document does not describe a graph: strict decoding or
       resolution failed (unknown fields, unknown enum values,
       missing required fields, parse limits, unbound references)
WF002  node ids are unique in their scope and every step reference
       (needs, branch arms, gate dispositions) names a step that exists,
       and a call names a subworkflow the registry resolves: a legal
       name under --workflow-root loadable as a document, or a shape
       that cannot be one (path shapes are refused as names)
WF003  needs is acyclic, a call node's declared depth is bounded, and
       the call graph the registry resolves is acyclic across documents
       within the depth ceiling — the direct self-call stays the one
       legal recursion, bounded by its declared max_depth
WF004  every node is reachable from the entry set
WF005  output bindings have non-empty unique names in their scope, and a
       declared schema is a schema name or a well-formed JSON Schema
       object

The value and template family owns what a structurally sound graph can still get wrong about the values it moves. Rules read the IR's compiled templates and selectors, never the source strings, and stay silent about any value whose type or shape nobody declared — "shallow but explicit": a finding always names a declaration the graph really carries.

WF010  every compiled reference resolves in scope: a declared param, a
       step the node can see, output or collect, an item binding or
       index inside the body that declares it
WF011  a consumer reads the kind of value it acts on — fanout.over,
       settle.proposals, and settle.where need a list, branch.on and the
       seed/continue/fork bindings must not read one, json_merge needs
       objects, and a declared output type cannot contradict its own
       schema
WF012  a field a reference reads exists in the shape the producer
       declares, whether it is read through an access path or through a
       selector's field:
WF013  no recursion and no calls: a node cannot read its own output or
       the collect of the fan-out that contains it, a compiled name is a
       plain identifier rather than an invocation, and a template's
       segments and references agree
WF014  a payload field belongs to its node kind: cases on a branch,
       on_pass on a gate, until on a loop, over on a fan-out, role on a
       delegate — a field the resolver drops is a constraint the author
       believes is set

The proposal linearity family closes the catalog. It is a dataflow analysis over the resolved graph rather than a runtime check written twice, and its subject is a document's settlement plan: which steps retain a proposal, and what happens to each one.

WF020  settle.proposals refers to a proposal-lane collection
WF021  every proposal is settled exactly once on every reachable path
WF022  a select or apply target was not released or discarded earlier
WF023  parallel applies name disjoint paths or are ordered by needs
WF024  on_conflict: skip has a later settle that catches what it skipped
WF025  a run that can end with proposals open says so
WF026  a settle over a possibly-empty set declares on_empty
WF027  continue_from and fork_from name one proposal from the same role
       and lane, and a fork leaves its source settled elsewhere
WF028  select candidates are inhabited and a judge policy declares its
       judge
WF029  a fan-out over a run-time list stays inside the concurrency the
       workflow budgets

The analysis carries, for each proposal token — a producing node, keyed by its path — the set of paths along which it is still open, already settled once, or settled twice, and it joins those sets the way the scheduler joins steps: needs and data dependencies are completions, so the later state wins; branch arms and gate dispositions are alternatives, so they union, which is what turns a proposal settled in one arm only into a leak on the other. A body's proposals leave it through its container's collect and nowhere else, and an empty SettlePolicy is read as the runtime default path_disjoint because resolve does not materialize it. Repetition is collapsed: one token stands for a proposal produced per item or per iteration, since a settlement expression is written over the set, and a filtered or conflict-skipped settle counts as naming its set rather than as disposing of every element of it — partial coverage is WF024's and WF026's subject, not WF021's. WF025 reads the document-level `on_abort` (yaah-0u0v.24): any of its three values discharges the finding, because the rule's subject is that the author said what becomes of the residue, not which thing they said. Prove publishes the resulting disposition map as a SettlementProof for `yaah workflow explain`.

Linearity is the last family the plan calls for, so the table above is the whole contract between this package and the documents it checks: adding a rule still means a new constant and a row here, but there is no reserved range left to grow into.

WF014 is an extension of the plan catalog, which listed this family as WF010–WF013. It is appended to the family rather than folded into WF011 because "the value is the wrong shape" and "the value was written where no shape can hold it" are different fixes, and the codes are the contract authors and the trace surface depend on.

Values is the aggregate for that family and Validate runs it after Structural. It takes the authoring document alongside the graph for one reason: ir.compileSelector does not carry Selector.Field into the IR (bead yaah-0u0v.32), so the only place a `where: {field: verdict}` still exists is the document. A nil document runs every other check and keeps that one silent.

Scope discipline is shared by WF005 and this family, and is stated once here because both files enforce halves of it. A name a node binds is unique in the scope a reader resolves it in: step ids at the top level, earlier siblings inside a body, and nothing visible across that boundary in either direction. Output names follow the same rule — a container's body is its own namespace, and a body-local name may not shadow a top-level one — because a fan-out body rebinds per item and cannot own a graph-wide handle.

The authority and cost family treats the workflow file as a permission plan: what a run may touch, and how much it may spend. Authority and Cost both take an Env of plain host data — role registry, declared worlds, network ceiling, configured caps — because the validator must not import the runtime; the CLI (bead yaah-0u0v.9) resolves Env from the live registry and configuration. A zero field means "not configured", and the rule declines that axis rather than inventing a ceiling. Authority judges every node, reachable or not — a stranded escalation is still a defect in the plan, and WF004 has already said why it will not run — while the Explain summary counts only reachable nodes, because a run cannot touch what the scheduler cannot enter.

WF030  every dispatch names a role the host registry knows and may
       delegate to; a primary-only persona is refused by name
WF031  filesystem grants are world-relative, disjoint within one
       dispatch, and inside a world the host declares; an emit
       artifact path may not climb out of its world either
WF032  a network mode may narrow the host ceiling but never widen
       it, and a broker with no configured hosts admits nothing
WF033  the worst-case dispatch count — fan-out bound × enclosing
       loop bound × call expansion over reachable nodes — fits the
       declared budget, and the declared budget fits the host
       ceiling; a bound the document does not supply makes the
       estimate a floor, flagged as such, rather than a guess
WF034  every loop declares max_iterations and every fan-out declares
       max_parallel: repetition is bounded in the document, not at
       run time
WF035  prompts and cost limits stay within the configured caps that
       sit above the decode-level floor
WF036  no credential is written into the document itself — a marker
       tripwire until the vocabulary grows a `secrets:` reference
WF037  a gate has exactly one runnable condition: one of assert/judge, an
       assert name the fixed registry holds, arguments that check reads, and
       a non-empty judge prompt

Explain is the family's summary artifact for the CLI: the authority union (every reachable grant at its widest access, every broker host, every artifact path, sorted and deduplicated so two runs over one graph agree byte for byte) and the worst-case cost.

One more family is planned for this package: the proposal-linearity rules (WF020–WF029). It gets its own aggregate next to Structural, Values, Authority, and Cost and its own rows in this table: the code set is small and part of the document contract, so it stays somewhere a human can read all of it.

Index

Constants

View Source
const (
	// CodeWF030 marks a dispatch authority the host does not grant: a
	// delegate or judge that names no role, names a role the registry has
	// never heard of, or names a primary-only persona it may not delegate
	// to.
	CodeWF030 = "WF030"
	// CodeWF031 marks a filesystem grant that is not world-relative, that
	// overlaps another grant on the same dispatch, or that names a world
	// the host does not declare — including an emit artifact path that
	// climbs out of its world.
	CodeWF031 = "WF031"
	// CodeWF032 marks a network policy the host cannot honour: a broker
	// with no hosts to broker, or a mode more permissive than the host's
	// configured ceiling.
	CodeWF032 = "WF032"
	// CodeWF033 marks a run whose worst-case dispatch count exceeds the
	// budget it declares, or a declared budget above the host ceiling.
	CodeWF033 = "WF033"
	// CodeWF034 marks an unbounded repetition: a loop without
	// max_iterations or a fan-out without max_parallel.
	CodeWF034 = "WF034"
	// CodeWF035 marks a prompt or a cost limit above the configured cap.
	CodeWF035 = "WF035"
	// CodeWF036 marks a credential written into the document itself
	// instead of reached through a reference.
	CodeWF036 = "WF036"
	// CodeWF037 marks a gate whose condition cannot run: no assert and no
	// judge, both at once, or an assert name/argument set the fixed registry
	// does not accept. See gate.go — the code lives here so the family's
	// vocabulary stays in one place.
	CodeWF037 = "WF037"
)

Rule codes for the authority and cost family. A workflow file is a permission plan, so these rules answer the two questions a plan must answer before anything runs: what may this run touch, and how much may it spend. As with the structural family, adding a rule means a new constant here and a row in the table in doc.go.

View Source
const (
	// CodeWF001 marks a document that never became a graph: the strict
	// decoder or the resolver rejected it, so no node-level rule could
	// run. See Diagnose.
	CodeWF001 = "WF001"
	// CodeWF002 marks an id-scope defect or a step reference that names
	// no step: duplicate ids, an unlabelled top-level step, an unknown
	// needs, branch arm, or gate disposition — and, for a call node, a
	// workflow the registry does not resolve: no name, a shape that cannot
	// be one (path shapes), no registry, or no document under
	// --workflow-root carries it (yaah-0u0v.23).
	CodeWF002 = "WF002"
	// CodeWF003 marks a needs cycle, an unbounded call depth, or the
	// cross-document defects the registry exposed: a cycle of documents
	// calling one another, or a call chain deeper than the ceiling the
	// validator holds (yaah-0u0v.23).
	CodeWF003 = "WF003"
	// CodeWF004 marks a node the scheduler can never enter: needs joins
	// on every entry, so one need that names no step or is itself
	// stranded keeps the node out of every possible run.
	CodeWF004 = "WF004"
	// CodeWF005 marks an output binding: an empty or duplicated name, or
	// a schema that is neither a schema name nor a well-formed JSON
	// Schema object.
	CodeWF005 = "WF005"
)

Rule codes. The strings are part of the workflow document contract and must not change meaning: adding a rule means a new constant here and a row in the table in doc.go.

View Source
const (
	// CodeWF020 marks a settle whose `proposals:` handle provably cannot
	// denote a proposal: a report-lane dispatch, or a step of a kind that
	// yields no proposal at all.
	CodeWF020 = "WF020"
	// CodeWF021 marks a proposal that is not disposed of exactly once on
	// every reachable path — a proposal no settlement step ever takes, and a
	// proposal a second step takes after it was already settled.
	CodeWF021 = "WF021"
	// CodeWF022 marks a select or apply whose target a settlement step
	// upstream may already have released or discarded.
	CodeWF022 = "WF022"
	// CodeWF023 marks two settlement steps that can run concurrently without
	// declaring disjoint path intent or being ordered by a dependency.
	CodeWF023 = "WF023"
	// CodeWF024 marks `on_conflict: skip` on a set of more than one proposal
	// with no later settle that could catch what it skipped.
	CodeWF024 = "WF024"
	// CodeWF025 marks a run that can finish with proposals still open and
	// declared no `on_abort` for them.
	CodeWF025 = "WF025"
	// CodeWF026 marks a settle over a possibly-empty proposal set with no
	// `on_empty`.
	CodeWF026 = "WF026"
	// CodeWF027 marks a continue_from or fork_from that does not name one
	// proposal from the same role and lane, or a fork that leaves its source
	// with no disposition anywhere downstream.
	CodeWF027 = "WF027"
	// CodeWF028 marks a select with a candidate set that is provably empty,
	// or a judge policy with no judge declared.
	CodeWF028 = "WF028"
	// CodeWF029 marks a fan-out over a run-time-sized list whose declared
	// concurrency the workflow's own budget does not cover.
	CodeWF029 = "WF029"
)

Rule codes for the proposal linearity family. This is the last family the plan calls for, so the catalog in doc.go is complete from here on.

Two of these codes sit slightly outside the original one-line summaries and each does so for a reason recorded at its rule, in the same voice as WF014:

WF025 demands an `on_abort` declaration wherever a proposal may remain
       open — the field landed with the executor (yaah-0u0v.24), so the
       rule reads the declaration and any of its three values
       discharges the finding: the rule's subject is that the author
       said SOMETHING about the residue, not which thing they said.
WF029 keeps only the clause WF034 cannot reach: WF034 already demands
       max_parallel from every fan-out, so what is left is whether the
       enclosing budget covers it.
View Source
const (
	// CodeWF010 marks a compiled reference that names nothing in scope: an
	// undeclared param, a step the node cannot see, a collect on a node that
	// produces none, an item binding or index outside the body that declares
	// it, or a reference with no source at all.
	CodeWF010 = "WF010"
	// CodeWF011 marks a producer/consumer type mismatch: a consumer that
	// needs a list reading a value declared as something else, a consumer
	// that needs one value reading a list, an element type a settle cannot
	// act on, and an output whose declared value type contradicts its own
	// declared schema.
	CodeWF011 = "WF011"
	// CodeWF012 marks a field access the declared shape cannot supply: a
	// template or selector path into a step output that the output's schema
	// does not declare, a field read off a list or a scalar, and a selector
	// `field:` naming a property the element schema does not declare.
	CodeWF012 = "WF012"
	// CodeWF013 marks a value that cannot be produced from itself: a node
	// reading its own output, a body reading the collect of the fan-out that
	// contains it, a reference written as a call or a filter, and a template
	// whose compiled segments do not match its compiled references.
	CodeWF013 = "WF013"
	// CodeWF014 marks a payload field that belongs to another node kind,
	// which the resolver drops: the declaration can have no effect, so the
	// author believes a value is set that never reaches the graph.
	CodeWF014 = "WF014"
)

Rule codes for the value and template family. Like the structural codes, these strings are part of the document contract: adding a rule means a new constant here and a row in the table in doc.go.

WF014 is not in the original plan catalog, which reserved WF010–WF013 for "value and template validation". It joins the family because a payload field on the wrong node kind is the same failure one step earlier: the author wrote a value at a place the graph cannot carry it, so nothing can ever read it back. It is appended rather than folded into WF011 so that "type incompatible" and "field misplaced" stay separately addressable.

View Source
const MaxCallDepth = 16

MaxCallDepth is the ceiling on a call node's declared recursion depth. The bound lives in the validator rather than only in the runtime so a runaway workflow is reported from the document, before a run spends its dispatch budget discovering the same thing at depth 17.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorityUnion added in v0.179.0

type AuthorityUnion struct {
	// Grants is the merged filesystem set. Two nodes granting one path
	// appear once, at the wider access, because that is what any of them
	// may do.
	Grants []PathGrant
	// Hosts names every broker host the run may reach, taken from the
	// configured allowlist, since the document states only the mode.
	Hosts []string
	// OpenNetwork reports that some reachable dispatch may address any
	// host, so Hosts cannot bound the run.
	OpenNetwork bool
	// NetworkModes lists the effective modes in use, narrowest first. A
	// dispatch that states nothing inherits HostNetwork, which is what
	// the runtime will apply.
	NetworkModes []ir.NetworkMode
	// Artifacts lists the emit paths a reachable node may write: the
	// workflow's own writes rather than delegated grants.
	Artifacts []string
	// Unreachable counts the nodes left out of the union, so a report can
	// say the plan is stranded instead of implying it is small.
	Unreachable int
}

AuthorityUnion is the filesystem and network authority the run could reach: what Explain reports and the explain CLI renders. Every list is sorted and deduplicated, so two runs over one graph agree byte for byte without the caller sorting anything.

type CallDocument added in v0.191.0

type CallDocument struct {
	Name     string
	SpecHash string
	Graph    *ir.Graph
}

CallDocument is one resolvable subworkflow, and CallResolver is the seam the CLI's registry hangs from: validation judges name resolution, cycles, and depth over the graphs this answers with, and never reads a file itself.

type CallResolver added in v0.191.0

type CallResolver interface {
	ResolveCall(name string) (CallDocument, bool)
}

CallDocument is one resolvable subworkflow, and CallResolver is the seam the CLI's registry hangs from: validation judges name resolution, cycles, and depth over the graphs this answers with, and never reads a file itself.

type CostEstimate added in v0.179.0

type CostEstimate struct {
	// Dispatches is the worst-case sub-agent dispatch count over every
	// reachable node: fan-out items times enclosing loop iterations
	// times the node's own declared retry attempts, with each call
	// expanded by its declared max_depth.
	Dispatches int
	// Complete reports that Dispatches bounds the run from above. When it
	// is false, Dispatches is a floor: at least one fan-out resolves its
	// item list at run time or one call reaches a workflow this graph
	// cannot see, and no document value bounds them.
	Complete bool
	// Unbound lists the node paths whose repetition the estimate could
	// not bound, in document order.
	Unbound []string
	// Turns bounds the model turns the run may spend, and WallClock
	// seconds the elapsed cost. Each is reported only when Env prices
	// the axis: Turns needs MaxTurnsPerDispatch, WallClock needs
	// SecondsPerDispatch or a timeout on every reachable dispatch.
	Turns          int
	TurnsKnown     bool
	WallClock      int
	WallClockKnown bool
	// Ceiling is the dispatch bound the run must fit under — the
	// declared budgets.max_dispatches, lowered by the host ceiling when
	// both exist — and ExceedsCeiling says Dispatches is over it. Ceiling
	// is 0 with ExceedsCeiling false when neither the document nor the
	// host declares one, which WF033 reports as unchecked rather than as
	// passing; a declared budget of 0 is a real ceiling and is honoured as
	// one.
	Ceiling        int
	ExceedsCeiling bool
}

CostEstimate is the conservative dispatch, turn, and wall-clock bound for one run, plus the honesty flags a report needs: a total is only a ceiling when every repetition in the document is bounded.

type Diagnostic

type Diagnostic struct {
	Code    string `json:"code"`
	Path    string `json:"path,omitempty"`
	Message string `json:"message"`
}

Diagnostic is one validation finding. Path anchors it: a resolved node path ("steps.build.body[0].needs[1]") for the graph rules, a document path ("spec.steps[0].kolect") for a WF001 that came from the decoder. Path is empty only when the finding has no location — a document that is not valid YAML at all, or a diagnostic that describes the whole graph.

func Authority added in v0.179.0

func Authority(g *ir.Graph, env Env) []Diagnostic

Authority runs the authority half of the family — WF030, WF031, WF032, WF036, WF037 — over a resolved graph and returns every finding, nodes in document order and rules in code order, so the slice is deterministic without the caller sorting anything.

These rules look at every node, reachable or not, while Explain's union counts only reachable ones. The split is deliberate: a role escalation stranded behind a bad `needs:` is still a defect in the plan, and WF004 has already said why it will not run; the union, by contrast, answers "what could this run touch" and must not credit authority no scheduler can enter.

func Calls added in v0.191.0

func Calls(g *ir.Graph, env Env) []Diagnostic

Calls runs the call family over a resolved graph: the reference half of WF002 for a call node's `workflow`, and the cross-document half of WF003 — the cycles and the total depth the plan's single-document rules cannot see. The family is separate from Structural because it needs the registry the CLI resolves names against: without one, every call is reported as unresolvable, which is fail-closed by design and the message says why.

What it reports:

  • a call naming no workflow, or a name that is not a subworkflow identifier (path shapes — "../secrets", "sub/../../x" — are refused as names, which is the containment rule's first half; the second half lives in the registry's path check);
  • a call the registry cannot resolve — no registry supplied, or no document under --workflow-root carries that name;
  • a cycle across documents (a -> b -> a) — the direct self-call stays the one legal recursion, bounded by its declared max_depth the same way callDepth bounds it in a single document;
  • a call chain whose total depth exceeds MaxCallDepth, counting each re-entry a self-call's bound allows.

Determinism: the walk follows the root's call nodes in canonical order and each document's in turn, reports each finding the first time its edge is seen, and a finding per violating node, so two runs over one registry agree.

func Cost added in v0.179.0

func Cost(g *ir.Graph, env Env) []Diagnostic

Cost runs the cost half of the family — WF033, WF034, WF035 — over a resolved graph and returns every finding in code order, nodes in document order.

func Diagnose

func Diagnose(err error) []Diagnostic

func Linearity added in v0.180.0

func Linearity(g *ir.Graph) []Diagnostic

Linearity runs the proposal linearity family (WF020–WF029) over a resolved graph and returns every finding, rules in code order and within a rule in document order, so the slice is deterministic without the caller sorting.

The family is a dataflow analysis (see proposal.go) and the rules are views over one fixed point, which is what lets WF021 answer "on every reachable path" instead of "somewhere in the graph". Four approximations come with the collapse that makes a repeated body checkable, and each is a decision rather than an oversight:

  • Instances are not counted. A token is a producing node, not a proposal per item or per iteration, because a settlement step is written over the set. A run that settles three items' proposals through one collect expression proves three dispositions here, and that is the right answer for a validator: the author's mistake is a missing or duplicated *expression*, never a duplicated item.
  • One iteration represents a loop body. The body's own dispositions do not feed its next iteration, so a proposal produced and settled inside a body twice across iterations reads as once.
  • A filtered or conflict-skipped settle counts as naming the set it targets, not as disposing of every element of it. Partial coverage is WF024's and WF026's subject, and charging it to WF021 as well would flag every `where:` in the corpus instead of the sets that really have nobody downstream.
  • Only proposals the document itself claims are counted as leakable. A token enters the plan when a settle, a selection, or a continuation reaches for it, or when its dispatch declares the proposal lane or a Proposal output type; a graph that never mentions settlement has no settlement plan to prove, which is the same shallow-but-explicit discipline the value family keeps. See claimScope.
  • A select decides its candidates. The rejected proposals are closed by the selection and the winner is a fresh token still owed a disposition; the alternative reading makes every speculative workflow leak each candidate it did not pick.

func Structural

func Structural(g *ir.Graph) []Diagnostic

Structural runs the structural family (WF002–WF005) over a resolved graph and returns every finding. Rules run in code order and each rule reports in document order, so the slice is deterministic for a given graph: it can be compared, counted, or shown verbatim without sorting first. A nil graph has nothing to check and yields no findings.

Later families (values and templates, proposal linearity, authority and cost) are separate aggregates over the same graph. They do not join here — "structural" is the name of this family, not a stage in a pipeline. Values and Linearity are the other two that Validate runs; Authority and Cost take a host Env, so a caller that has one runs them itself.

func Validate

func Validate(data []byte) (*ir.Graph, []Diagnostic)

Validate is the end-to-end seam: workflow document bytes in, the resolved graph and its diagnostics out. A document that strict decoding or resolution rejects never becomes a graph, so the failure is reported as one WF001 diagnostic through Diagnose; otherwise Structural runs first, Values runs after it, and Linearity runs last — all three over the same graph and the document it came from.

Return contract: a document that parses and resolves yields a non-nil graph and diagnostics carrying only WF002–WF029 findings (possibly none); a document that never became a graph yields a nil graph and exactly one WF001. The graph is therefore nil exactly when the diagnostics contain a WF001. Findings stay grouped by rule in catalog order — WF005 before WF010 is numeric, not lexical — and in document order within a rule, so a caller can diff and display them without sorting. Callers that want to run a validated workflow should require zero diagnostics, which is what the spec goldens assert.

func Values added in v0.179.0

func Values(doc *spec.Document, g *ir.Graph) []Diagnostic

Values runs the value and template family (WF010–WF014) over a resolved graph and returns every finding, in the same order contract Structural documents: rule by rule in code order, and within a rule in document order with a fixed field order per node.

The graph alone carries almost everything this family needs, because the resolver already compiled the templates and selectors. doc is the authoring document the graph came from, and it is a parameter for exactly one reason: ir.compileSelector drops Selector.Field (bead yaah-0u0v.32), so the `field:` a settle or loop author wrote exists only in the document. A nil doc means the graph was built or edited outside the pipeline, and the checks that need authoring syntax stay silent — every other check in the family still runs.

Like Structural, this takes no position on whether the graph was built honestly: a graph assembled by hand or by a later stage is walked the same way, and the compiled forms are treated as claims to re-check rather than as guarantees.

func (Diagnostic) String

func (d Diagnostic) String() string

String renders the finding as "WF004 steps.tail: not reachable …".

type Env added in v0.179.0

type Env struct {
	// Roles indexes the delegatable surface. An empty or nil map skips
	// WF030's name checks: a caller that has not loaded the registry must
	// not get every workflow flagged for roles it cannot resolve.
	Roles map[string]Role

	// Worlds lists the worlds the host declares. With none listed, WF031
	// checks no world name and a document's `world:` goes unverified.
	Worlds []string
	// DefaultWorld names the world a dispatch without `world:` lands in.
	// It is reporting data for the authority union; empty means the host
	// default is unnamed and the union reports it as "".
	DefaultWorld string

	// HostNetwork is the configured ceiling from agents.subagent.network.
	// A document may narrow it per dispatch but never widen it, which is
	// the whole of WF032's consistency check. Empty skips the check.
	HostNetwork ir.NetworkMode
	// BrokerHosts is agents.subagent.network_hosts: the exact host names
	// the broker admits. Meaningful only with a broker mode; empty means
	// the broker admits nothing.
	BrokerHosts []string

	// MaxDispatches is the host ceiling on one run's dispatch count,
	// applied when the document declares no budgets.max_dispatches and
	// used as the widening bound when it does. Zero means no ceiling.
	MaxDispatches int
	// MaxFanoutItems bounds a fan-out whose item count the document does
	// not bound — an `over:` a selector resolves at run time. Zero keeps
	// the estimate honest instead of inventing a number: the total becomes
	// a floor, flagged in CostEstimate, and WF033 only fires when even
	// that floor is over budget.
	MaxFanoutItems int
	// MaxCallDispatches bounds the work a `call:` node reaches into, for
	// the same reason: this graph cannot see the called workflow. Zero
	// contributes only the declared depth and marks the total a floor.
	MaxCallDispatches int

	// MaxPromptBytes caps one prompt as written. Decode already refuses a
	// prompt over spec.MaxPromptBytes, so this is the host's tighter layer
	// above it; zero takes spec.MaxPromptBytes.
	MaxPromptBytes int
	// MaxTurnsPerDispatch is the host ceiling on a node's max_turns and,
	// when set, the per-dispatch turn budget for the cost estimate. Zero
	// checks no max_turns and reports no turn bound.
	MaxTurnsPerDispatch int
	// MaxTokens is the host ceiling on budgets.max_tokens. Zero skips it.
	MaxTokens int
	// SecondsPerDispatch prices a dispatch that declares no
	// timeout_seconds. Zero reports no wall-clock bound.
	SecondsPerDispatch int

	// Calls resolves a call node's `workflow` name to the graph the host's
	// registry loaded for it (yaah-0u0v.23). Nil means no registry: every
	// reference a call makes is unresolvable, which the Calls family
	// reports, and cost keeps its ceiling-times-depth floor for calls.
	Calls CallResolver
}

Env is the host authority a workflow is checked against. Every field is plain data so the rules stay pure and testable and the caller — the CLI in bead yaah-0u0v.9 — resolves roles, worlds, and caps from the live registry and configuration. One authority model, in the runtime; this is a read of it.

Zero means "not configured". Most rules then decline to check that axis rather than guess, because a guessed ceiling would invent policy the host never set. The exceptions are documented at their fields: MaxPromptBytes falls back to the decode-level cap, and an unset role registry still refuses dispatches that name no role.

type ExplainResult added in v0.179.0

type ExplainResult struct {
	Diagnostics []Diagnostic
	Authority   AuthorityUnion
	Cost        CostEstimate
}

ExplainResult is the explain artifact: diagnostics plus the two summaries, each computed over the same reachability as the rules that reference them.

func Explain added in v0.179.0

func Explain(g *ir.Graph, env Env) ExplainResult

Explain is the seam for `yaah workflow explain` (bead yaah-0u0v.9): the whole family's findings beside the two artifacts a human needs before approving a permission plan — the authority union and the worst-case cost. It computes nothing that Authority, Cost, and the two summarisers do not, and it returns the findings in the order the two aggregates emit them, which is ascending within each half: WF030, WF031, WF032, WF036, then WF033, WF034, WF035. The split is by what a rule needs (host authority versus configured caps), not by code order, so the renderer sorts if it wants the codes contiguous.

type PathGrant added in v0.179.0

type PathGrant struct {
	World  string
	Path   string
	Access ir.GrantAccess
}

PathGrant is one world-relative path and the widest access any reachable dispatch may use there.

type ProposalProof added in v0.180.0

type ProposalProof struct {
	// Proposal is the producing node's path, which is the token's identity.
	Proposal string
	// Dispositions names the steps that settle it — a settlement step, a
	// select that decides it, or a dispatch that continues it — in sorted
	// node-path order. More than one entry does not by itself break
	// linearity: two alternatives in different branch arms each settle it
	// once. OnceOnEveryPath is the property.
	Dispositions []string
	// Actions is the verbs applied to it, rendered by disposition.String.
	Actions string
	// OnceOnEveryPath reports that no reachable path applies a second
	// disposition.
	OnceOnEveryPath bool
	// SettledOnEveryPath reports that no reachable path leaves it undisposed.
	SettledOnEveryPath bool
	// Stranded reports a proposal sealed inside a body that declares no
	// collect, which no step outside can name.
	Stranded bool
}

ProposalProof is one proposal's disposition record.

func (ProposalProof) String added in v0.180.0

func (p ProposalProof) String() string

String renders one record as the line a report prints: the proposal, the verbs applied to it, and where they came from.

type Role added in v0.179.0

type Role struct {
	// Delegatable reports that the role may be dispatched as a sub-agent.
	Delegatable bool
	// PrimaryOnly reports that the role is deliberately a primary
	// persona, which is the interesting half of "not delegatable": it
	// exists, so an author will assume it is usable.
	PrimaryOnly bool
}

Role is one entry of the host role registry as the caller saw it. Plain data, because the validator must not import the runtime: rolefile mode maps onto these two flags as primary → {false, true}, subagent → {true, false}, all → {true, false}, and a name absent from Env.Roles is a name the registry does not have.

type SettlementProof added in v0.180.0

type SettlementProof struct {
	// Proposals lists one record per token, in document order of the node
	// that produces it.
	Proposals []ProposalProof
	// OpenAtExit names the proposals a run can finish without disposing of,
	// in the same order.
	OpenAtExit []string
}

SettlementProof is the linearity artifact: one disposition record per proposal the graph can create. It is the same fixed point the rules read, published for `yaah workflow explain` (bead yaah-0u0v.9) and for the property test that keeps the two honest — a workflow the family accepts must have a proof in which every proposal is accounted for exactly once.

func Prove added in v0.180.0

func Prove(g *ir.Graph) *SettlementProof

Prove runs the linearity analysis and returns the settlement proof for a resolved graph. A nil graph produces no proof.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL