Support authored cancellation and review-failure outcomes in the CLI

Closed
WI
3mo ago
+792-7

An authored flow can express an explicit cancellation with f.done("canceled") or a failed review with f.done("step_failed"), but the executor currently rejects both valid surface outcomes. This change records those outcomes through the existing terminal-marker mechanism and returns an explicit reason with CLI exit 1.

Event subscription matching happens before handler invocation and is separate work. A nonmatching event should create no run. This PR adds no issue schema, provider catalog, filter helper, surface API, or kernel primitive; cancellation is tested only as an explicit request to stop work.

Behavior and validation

  • Terminal outcomes are recorded before reporting them. Unawaited work and terminal journal failures still fail closed.
  • Ten focused real-daemon tests exercise terminal markers and the built CLI, including explicit cancellation before starting an agent, reporting review failure, and retaining needs_human handoff behavior. The revised fixtures remove provider and label filtering. Current fixture build, typecheck and test commands/output.
  • SDK build, source/test typechecks, and 95 focused tests passed. Literal commands and captured output are included.
  • Verification uses a locally packed build of the unchanged surface, matching repository CI. The locked registry version is older than the current SDK source; the initial typecheck failure and corrected setup are documented.

The terminal marker itself remains a successful kernel step whose output records the authored outcome, following existing needs_human semantics. This does not add durable authored-root resume, Cloud launch wiring, or provider authentication. No package version or release was changed. Release the CLI/SDK fix after human review and merge.

Schema CI repair

CI also exposed an existing generator failure on readonly string[] in the SDK's workspace/tool scope declarations. The generator now handles readonly arrays, and the checked-in schema is regenerated from the existing specification. A regression test checks generation consistency and rejects invalid scope values and array elements. No CI gates were changed.

The 70 schema tests passed using CI's Bun/npm versions. Literal commands and captured output include the original failure and verification.

At commit e64a335846e84194193c1044fa4f45170b2cdcf0, schema validate and packed-consumer pass. The Cloud-backed review remains blocked before code review. Command:

env -u GITHUB_TOKEN -u GH_TOKEN /opt/homebrew/bin/gh run view 34899046453 --repo AgentWorkforce/flows --log-failed

Captured error line:

review	Validate cloud authentication	2026-09-14T21:29:16.3246980Z ##[error]https://agentrelay.com/cloud returned HTTP 500 while validating CLOUD_API_KEY. That is not an authentication verdict — treat it as Cloud being unhealthy rather than the credential being bad.

Failed Cloud authentication job. The review needs rerunning after Cloud recovers; this PR does not bypass it.

Event-driven onboarding follow-up

The upstream event subscription and handler-input contract is in https://github.com/AgentWorkforce/relayfile-adapters/pull/278. After that merges and adapter-core is published, Flows/Cloud can consume the shared contract for authenticated subscription matching before handler invocation. This PR remains useful independently for explicit completion outcomes and schema generation; it is not the event integration implementation.