logs.gokuls.in

1 pull request merged across 1 repo

bahdotsh/wrkflw

I ran wrkflw the way a coding agent does: through the JSON CLI and the MCP server, on a probe repo. These are the problems that turned up, and how this PR fixes each one.

Problems found

1. False passes on OS matrices. In a matrix over [ubuntu-latest, macos-latest, windows-latest], a step gated on runner.os == 'Windows' that runs exit 1 was reported as success on every leg, in both the CLI and MCP output. Locally those labels run as Linux (or as the host under emulation), so that step never ran. Nothing said so.

2. gate sent agents to the wrong run. gate --format json printed text. The recovery AGENTS.md documented, runs failure latest, reads the newest run. That's whichever workflow the gate ran last, which can be one that passed, so the agent got failures: [] after a failed gate.

3. The MCP server had no fast path. There was no gate tool, and run_workflow couldn't reuse earlier passing results. MCP job results also dropped repeated_from.

4. No live output. In JSON mode a step's output only arrived when the step ended, so an agent couldn't tell a slow step from a hung one.

5. Nothing flagged before a run. plan didn't warn that some jobs would run as a different OS.

Commits

  • feat(executor): flag jobs that ran as another OS than runs-on asked. The engine compares the OS that runs-on names with the runner.os the job actually saw. On a mismatch it logs a warning, adds runner: {requested, ran_as} to job_finished and to run_finished.jobs, and adds the job to a new run_finished.unverified array. This also covers matrix legs folded into another leg and jobs whose earlier pass was reused. It skips jobs with container:, labels mapped with --platform, and labels that name no OS. run_finished.jobs now also carries repeated_from.
  • feat(gate): print one JSON object with --format json, and add it to MCP. The gate object has passed, failed, unverified, uncommitted_changes, and for each workflow its status, run_id, jobs and failure digest. There's a new MCP gate tool, and run_workflow takes reuse_results.
  • feat(run): stream step output as NDJSON with --stream-output. Opt-in step_output lines, {job, step, index, lines}, masked like the rest of the output. It's opt-in because step_finished already carries the full output, so streaming by default would make agents read everything twice.
  • feat(plan): list jobs that would run as another OS. plan --runtime (default auto, resolved the same way run resolves it) reports the same unverified entries for each matrix leg. MCP plan_workflow takes runtime too. On this repo's own ci.yml, it flags the macOS and Windows build legs.
  • feat(ui): mark jobs that ran as another OS in the run story. The job's line shows ⚠ ran as Linux (windows-latest) next to its result.

AGENTS.md and README are updated in the same commits as the behaviour they describe.

What I deliberately did *not* change

An unverified job keeps status success and exit code 0. Failing it would break every workflow with an OS matrix. If we want a hard failure, that belongs behind a flag such as --strict-runners in a follow-up.

Verification

  • Each commit was built and checked on its own: cargo clippy --workspace --all-features --all-targets -D warnings is clean and cargo test --workspace --all-features passes.
  • New tests:
  • the OS check itself;
  • unverified in run_finished;
  • the gate report, including a child that crashes and a child that claims success but exits non-zero;
  • the MCP gate and reuse_results arguments;
  • an integration test that streamed lines arrive before step_finished and contain no secrets;
  • an integration test for plan's unverified with --runtime docker;
  • a TUI render test for the badge, including at narrow widths.
  • Manual runs on a probe repo:
  • Docker, emulation and --reuse-results runs all list the Windows and macOS legs as unverified.
  • gate --format json exits 1 and returns the failing workflow's run id and failure digest. The MCP gate tool returns the same.
  • With --stream-output under Docker, step lines arrived about a second apart while the step was still running.

Follow-ups from review

  • fix(mcp): pass the server's own signals on to its tool calls. Each tool call runs in its own process group, so terminal Ctrl+C and hangup no longer reached it. The server now interrupts every live tool call's group on SIGINT, SIGTERM or SIGHUP, waits the usual grace period, and only then exits.
  • refactor(executor): judge runs-on from the labels that pick the image. The engine and the runner check now share one label expansion and --platform lookup. Run records store the executor's RunnerSubstitution directly; the JSON is unchanged. A reused matrix leg that matches no leg now logs a warning instead of silently counting as verified, and the reused OS-matrix path has an integration test.
  • perf(plan): only probe for Docker when the answer changes something. plan --runtime auto skips the Docker/Podman probe on Linux hosts and when no job names an OS.
  • fix(gate): pass each workflow's run_finished through whole, so new run_finished fields reach the gate. Adds a test for gate --install-hook --format json.
  • fix(run): refuse --stream-output without --format json instead of silently ignoring it.
  • fix(runs): record a run stopped by a signal as interrupted. A group-wide SIGINT also kills the step, so the run could be recorded as failure if the engine finished before the handler exited. macOS CI caught this. The handler now marks the process interrupted first, and run_finished for an interrupted run has exit code 1.