flows check knows which specs will park or fail at run time, and says nothing: spend the analysis it already does

Merged
AG
1mo ago
+940-22

Spend the analysis flows check already does

flows check computed the facts that would have prevented five dead runs and
said nothing about them. This spends two of them, and establishes that the
third fact is not a fact.

What changed

agent_worker_unresolved — a check-only warning (permanent)

A spec with agent steps needs a worker attached for step type agent.
Without one the run parks at the first such step. flows check already walks
those steps to print REQUIRES codex (step "implement"), … — the analysis
exists; it just stopped one sentence short of the remedy.

REQUIRES claude (step "implement")
WARNING [agent_worker_unresolved] 2 agent steps ("implement", "review") require an
attached worker. For a local run, use `flows run --local-agent <flow>`, unless you
already attach an agent worker for this daemon. `flows check` does not verify
worker attachment: with no worker attached the run parks at the first agent step.

Design decisions worth naming:

  • Warning, never a refusal, worded as a requirement rather than a
    prediction.
    Worker attachment is unknown to flows check, not absent:
    check is daemon-free by construction, so it cannot see a worker attached
    elsewhere. Saying "this will park" would be a guess.
  • It is a property of the invocation, not of the spec, so it opts in
    through a new CheckInvocation seam on checkFlow / checkAuthoredFlow
    rather than entering preflight, which stays a pure function of the spec
    plus environment probes. Only flows check sets it. flows run knows the
    answer (it attaches its own worker under --local-agent), flows build and
    flows deploy check a spec that will run elsewhere, and an SDK caller
    reaching checkAuthoredFlow directly is generally running a worker already.
  • Scoped to agent steps. --local-agent attaches no llm worker on the
    YAML path, so counting llm steps and naming that flag for them would be
    false. They are not counted and not mentioned.
  • Counted from the compiled steps, not from requirements. A YAML helper
    step (slack: { post: … }) compiles to an agent step carrying a helper
    envelope and needs the same SDK worker, but requirements reports it as an
    integration, dedupes by harness, and includes llm use. Compilation is the
    only walk that sees every step that needs the worker.
  • Emitted in the REQUIRES position, because it reads as a footnote to
    that line. emitCheckReport holds it back from the leading diagnostic batch
    and emits it once, after REQUIRES and before CHECK PASSED; diagnostics
    stay on stderr, report lines stay on stdout. --json returns before any of
    that and keeps the single ordered diagnostics array.
  • Emitted alongside a preflight refusal. An environment refusal is fixed
    and rerun; the worker question is still open on the next pass, and staying
    silent about it is what made an author meet it one dead run at a time.

Known blind spot, documented rather than papered over: an authored .flow.ts
is checked through checkMcpHeader, which preflights a synthetic one-step
header spec without compiling the body, so there are no agent steps to count.
Same blind spot as permissions_unenforced.

gate_path_unreachable — a preflight refusal (temporary, retires with #513)

An artifact_exists gate reads the journaled output.artifacts list and
nothing else. The bundled worker's scan skips any entry whose name starts with
. and any entry named exactly node_modules. A gate on a path inside one of
those prefixes can therefore never match, however faithfully the agent writes
the file. That is unsatisfiable, not merely unproven — so, as the issue
suggested, it refuses:

REFUSED [gate_path_unreachable] Step "review" gates on artifact_exists path
".workflow-artifacts/rust/review.md", but the bundled agent worker's artifact scan
never records anything under ".workflow-artifacts": it skips entries whose name
starts with "." and entries named "node_modules". The path can never appear in the
journaled output.artifacts this gate reads, so the gate cannot pass. Write the
artifact to a scanned path.
  • One rule, two consumers. The exclusion predicate moved out of
    agent-artifacts.ts into src/artifact-scan-policy.ts; the real scan now
    consumes it, so the refusal cannot drift from the scan it describes. A
    parity test writes all twelve case paths to a temp dir and asserts the real
    snapshotWorkspaceFiles output is exactly the predicate's complement.
  • The whole excluded prefix is named, not the offending segment alone —
    that prefix is the directory the author has to move the artifact out of.
  • Segments are compared exactly, with no normalization. The gate matches
    the author's literal string against the worker's literal list, so
    node_modules-copy/out.md, reports/node_modules.md, review.md and
    reports/v1.2/review.md are all accepted, and a backslash is an ordinary
    filename character rather than a separator.
  • Collected before preflight's early returns. probeNamedGate runs after
    CLI resolution, model governance, scope and budget can each return, so an
    author with an unresolved CLI would not learn about the dead gate until a
    later pass — or at run time. A test pins the diagnostic order as
    ['gate_path_unreachable', 'cli_unresolved'].
  • Scope consequence, recorded deliberately: the kind lives in
    PREFLIGHT_ENVIRONMENT_FAILURE_KINDS, so it also fires at flows build and
    on SDK submissions. That is correct — the gate is unsatisfiable under the
    bundled worker regardless of host — and it is a property of the bundled
    worker, not of the journal protocol: step.complete accepts any output,
    so a custom worker may journal a hidden path.

gate_output_not_captured — not added, because it is not true

The acceptance criterion was conditional: warn that a subprocess_gate's
output is not captured "for as long as that is true". It is not true today.
Verified against a live relayflowd before writing anything:

"stepId": "emit.gate", "completionReason": "retries_exhausted", "exitCode": 1,
"stdoutTail": "GATE_STDOUT_MARKER\n", "stderrTail": "GATE_STDERR_MARKER\n"

and in the journal itself, on the lowered gate step's step.completed:

"output": { "exit_code": 1, "stdout_tail": "GATE_STDOUT_MARKER\n",
            "stderr_tail": "GATE_STDERR_MARKER\n" }

A warning claiming otherwise would have been a false diagnostic added to a
change whose whole point is that check should only say what it knows. What
the criterion actually asks for is that the warning exist exactly while the
bug does — so instead of the warning, this adds a live-kernel regression
that pins the capture
. If capture ever regresses, that test fails, and the
warning becomes warranted at the moment it becomes true.

Tests

  • tests/artifact-gates.test.ts — six parameterised refusals asserting the
    full excluded prefix is named; six lookalike paths that must be accepted;
    the scan/predicate parity test against a real snapshotWorkspaceFiles run;
    the early-return ordering test; and an end-to-end checkFlow refusal.
  • tests/check-worker-surface.test.ts (new) — message content, singular vs
    plural and the "and N more" truncation, exit code 0, the YAML helper step
    being counted where requirements omits it, silence for llm-only and
    deterministic-only flows, survival alongside a preflight refusal, opt-in
    discipline, --json emitting it once in both the payload and on stderr, and
    an ordered CliIo transcript (both streams in one list) pinning the
    position after REQUIRES and before CHECK PASSED — in both the
    REQUIRES-present and REQUIRES-absent shapes.
  • tests/preflight.test.ts — gate_path_unreachable added to the
    refusal-reachability list, which asserts set equality against
    PREFLIGHT_FAILURE_KINDS.
  • tests/live-kernel.test.ts (new block) — the subprocess_gate capture
    regression, asserting both the rendered message and the journal payload, with
    a silent-gate control so the assertions cannot pass on a fixed string.

npm test in packages/sdk: 2380 passed, 40 failed. All 40 failures are
pre-existing and environmental — they reproduce identically on a stashed tree
(same 40 failures, same 7 files): relayflowd looked up under
kernel/target/{debug,release}/ while this toolchain builds outside the repo,
and flows needing real harness CLIs. tsc --noEmit is clean for src, the
type tests, and tests.

Files

FileChange
src/artifact-scan-policy.tsnew — the scan's exclusion rule as a pure predicate, shared
src/named-gate-preflight.tsnew — the gate_path_unreachable refusal (retires with #513)
src/cli/check-worker-surface.tsnew — the agent_worker_unresolved warning
src/agent-artifacts.tsconsumes the extracted predicate instead of its own copy
src/preflight.tscollects gate reachability before every early return
src/failure-kinds.tsthe two new kinds, each with its retirement note
src/cli/check.tsCheckInvocation opt-in seam
src/cli.tsopts in at the check dispatch; defers the warning to the REQUIRES position
docs/SURFACE.mddocuments both kinds where the facts they describe already live

Each diagnostic is a distinct kind, so it can be suppressed and later deleted
on its own. Both temporary kinds carry their retirement condition in a comment
at the definition site.

Out of scope, unchanged

The underlying bugs (#511, #513) are not fixed, and the spec is not
round-tripped past the daemon's validator (#502).


[!NOTE]
Medium Risk
Changes check/preflight diagnostics and CLI report ordering across check, run, build, and SDK submissions, but new outcomes are warnings only except unchanged refusal paths.

Overview
flows check now spends analysis it already had: specs with agent steps get an opt-in agent_worker_unresolved warning (never a refusal) that names the steps and points at flows run --local-agent, emitted as a footnote after REQUIRES in plain text. Only the CLI check path sets CheckInvocation.warnUnresolvedAgentWorker; run, build, and default checkFlow callers stay quiet.

Preflight adds gate_path_unscanned when an artifact_exists path crosses a scan-skipped segment (exactly .git, .relayflowd, or node_modules). The exclusion rule moves to shared artifact-scan-policy.ts so the walk and static analysis stay aligned; the warning is collected before preflight early returns and warns rather than refusing because JSON stdout or custom workers can still journal those paths.

A proposed subprocess_gate output warning was not added; a live-kernel test instead pins that gate stdout/stderr are already journaled and reported.

Reviewed by Cursor Bugbot for commit eb64e47eca55ae89b6bf32cbaa6023e3b1c17103. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

flows check now reports two dead-run causes it already had the facts to detect: specs with agent steps but no attached worker, and artifact_exists gates on paths the bundled artifact scan never records. A third proposed warning was dropped because the bug it warned about does not exist; a live-kernel regression test pins that instead.

Agent worker warning

  • New agent_worker_unresolved warning names the agent steps and points at flows run --local-agent.
  • Warns rather than refuses, since check is daemon-free and cannot see a worker attached elsewhere.
  • Only flows check opts in, so flows run, flows build, and SDK callers get no noise.

Unreachable gate warning

  • New gate_path_unscanned warning for artifact_exists paths under a segment named exactly node_modules, .git, or .relayflowd — after merging main's scan change, dot-directories like .workflow-artifacts/ are scanned and journaled, so only those exact names trigger it.
  • Warns rather than refuses: the bundled worker can journal an excluded path itself via JSON stdout, so the gate is not statically unsatisfiable — a regression drives the real worker and the lowered gate to pin that.
  • The exclusion rule moved to artifact-scan-policy.ts and the real scan consumes it, so the warning cannot drift.
  • Also fires at flows build and on SDK submissions; temporary, and retires when the scan exclusion is fixed (#513).

Fixes #514


Agent Relay sessions

  • devin session bead-mac · contributor · pushed commits · last active 2026-09-23