Skip to content

refactor(studio): have the BFF report each schedule fire's outcome - #2317

Merged
kantord merged 1 commit into
studio-followups/06-schedules-focus-shortcutsfrom
studio-followups/07-schedules-bff-outcome
Oct 15, 2026
Merged

kantord merged 1 commit into
studio-followups/06-schedules-focus-shortcutsfrom
studio-followups/07-schedules-bff-outcome

Conversation

@kantord

@kantord kantord commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

The mapping from the daemon's stop reason to a fire outcome lived in the web app. The BFF now owns it, so every client reads the same vocabulary.

Part of #2303 ("Tiny follow-up fixes"); it does not close it. This is PR 7 of 14 in a stack of draft PRs, reviewed and merged in order.

What changed

  • Contract: scheduleFireOutcomeSchema enum (claimed, in_flight, completed, failed, cancelled, timed_out, limit_reached, stopped) and a required outcome on scheduleFireSchema. stop, error and inFlight are unchanged. The schema comment says consumers must treat unknown future values as stopped.
  • BFF: fireOutcome(fire), ported verbatim from the web function with its precedence and DECISION comment. no_progress stays stopped.
  • Web: the stop-reason sets are gone; OUTCOME_LABEL and OUTCOME_VARIANT are Records over the generated union (compile-time exhaustive). An unknown or missing outcome reads "Stopped". The raw "Stop: ..." line is kept.
  • openapi.json and types.gen.ts regenerated with pnpm run generate.

Behavior changes

None user-visible; labels and badge variants are identical to before.

API compatibility

  • Scope: the Studio BFF /api/v1 OpenAPI contract, not the daemon wire API. engine/session and contracts/proto are untouched, and none of the paths in .claude/rules/wire-api-compatibility.md are touched, so the rule is not triggered. The wire policy (docs/architecture/api-surface.md#wire-api-compatibility) says additions stay in-major and stop reasons remain open strings; nothing here changes that.
  • Additive: one new required response field. Existing readers of stop, error and inFlight are unaffected.
  • No version skew: the BFF and web ship together.
  • If the enum later grows, third-party BFF consumers must tolerate unknown values (documented in the schema).

Verification

Biome, typecheck, the full Studio test suite and pnpm generated:check pass on this branch, run on the assembled stack. The full Playwright suite passes on the stack tip (122 passed, 30 skipped, 0 failed, including chat-approval against a real mecated build). A 17-case BFF table test (including no_progress and an unknown stop) asserts it covers every enum value; a service test asserts stop, error and inFlight are still emitted. Only the two service-level server tests fail without the production change; the table and web tests call functions that exist only with this change.

Not included

The daemon, its protobuf contracts and the stop-reason vocabulary.

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

@kantord
kantord added this pull request to stack #2325 October 14, 2026 13:27
@kantord kantord mentioned this pull request Oct 14, 2026
41 tasks done
@kantord
kantord marked this pull request as ready for review October 15, 2026 08:41

@peppescg peppescg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Daniel. Moving the stop-reason mapping into the BFF with a closed enum, typed label maps on the web, and a test that checks every enum value is covered is exactly the shape I hoped for.

Nits:

  • apps/server/src/mecatl/schedules.ts:234: type FireOutcome = z.infer<typeof scheduleFireOutcomeSchema> would tie the BFF to the schema directly instead of going through the generated response type.

@kantord
kantord force-pushed the studio-followups/07-schedules-bff-outcome branch 4 times, most recently from 120473a to 0f40385 Compare October 15, 2026 09:29
Add a closed `outcome` enum to the schedule fire contract and compute it in
the BFF from the daemon's stop reason, so every client reads one vocabulary.
`stop`, `error`, and `inFlight` are unchanged. The web drops its own
stop-reason mapping and only labels the outcome, reading an unknown value as
stopped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kantord
kantord force-pushed the studio-followups/07-schedules-bff-outcome branch from 0f40385 to bbc9c6c Compare October 15, 2026 12:25
@kantord
kantord merged commit 2b29871 into main Oct 15, 2026
30 of 31 checks passed
@kantord
kantord deleted the studio-followups/07-schedules-bff-outcome branch October 15, 2026 13:00
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants