Skip to content

fix(github): resolve the apply an operator meant when a control command names none - #974

Draft
aparajon wants to merge 3 commits into
mainfrom
armand/control-infer-apply-id
Draft

fix(github): resolve the apply an operator meant when a control command names none#974
aparajon wants to merge 3 commits into
mainfrom
armand/control-infer-apply-id

Conversation

@aparajon

@aparajon aparajon commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Why this matters

schemabot apply takes no apply ID, so operators reach for schemabot cancel -e <env> the same way. Every apply-scoped control command answers that with a usage line, sending them to schemabot status to copy back an identifier SchemaBot already has — on a PR whose only schema change in that environment is the one they obviously meant.

What it does

  • Resolves a control command that names no apply from the PR itself: acted on when exactly one schema change in that environment could be meant, answered with the candidates when several could, and given the existing usage reply when none match.
  • Guesses nothing. An ambiguous command cancels nothing and lists the identifiers so the operator names the one they mean.
  • Counts stopped applies as candidates. Stopping leaves a schema change half-applied and cancel is how an operator finishes it, so the state cancel is most often issued against stays reachable.
  • Keeps the usage reply for an unscoped command on an aggregate repo. Each participant holds its own slice of the PR's applies, so "exactly one here" is not "exactly one on this PR".
  • Threads the resolved apply back to the caller, so the acknowledgement names the apply it acted on rather than a blank.

Applies to every apply-scoped control command, since they share one lifecycle and the ask is the same on each.

🤖 Generated with Claude Code

…nd names none

`schemabot apply` takes no apply ID, so operators reach for `schemabot
cancel -e <env>` the same way. Today every apply-scoped control command
answers with a usage line, sending them to `schemabot status` to copy
back an identifier SchemaBot already has.

A control command that names no apply is now resolved from the PR: acted
on when exactly one schema change in that environment could be meant,
and answered with the candidates themselves when several could. Nothing
is guessed — an ambiguous command still cancels nothing.

Stopped applies count as candidates. Stopping leaves a schema change
half-applied and cancel is how an operator finishes it, so the state
cancel is most often issued against stays reachable.

Inference is scoped to what one deployment stores, so an unscoped
command on an aggregate repo keeps the usage reply: each participant
holds its own slice of the PR's applies, and "exactly one here" is not
"exactly one on this PR".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 7, 2026 20:44

Copilot AI 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.

Pull request overview

Improves the operator experience for apply-scoped control commands (e.g., schemabot cancel) when issued without an explicit apply ID by resolving the intended apply from the PR when unambiguous, and replying with a candidate list when ambiguous.

Changes:

  • Added control-command apply inference (and ambiguous-candidate replies) for apply-scoped control commands missing an apply ID.
  • Added a new “Control Command Ambiguous Apply ID” PR comment template and CLI preview output for it.
  • Added integration tests covering cancel-without-apply-id behavior for both unambiguous and ambiguous PRs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
TEMPLATES.md Documents the new ambiguous-apply-ID control-command template output.
pkg/webhook/templates/issue_comment.go Adds rendering for the ambiguous apply-ID reply (candidate list + usage).
pkg/webhook/control.go Implements apply inference for missing apply IDs and threads the resolved apply ID downstream.
pkg/webhook/control_integration_test.go Adds E2E-style integration tests for cancel-without-apply-id behavior.
pkg/cmd/internal/templates/preview_comment.go Adds preview entry for the new ambiguous apply-ID control-command comment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/webhook/control.go Outdated
Comment thread pkg/webhook/control.go
aparajon and others added 2 commits August 7, 2026 16:57
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Two ways an unresolved apply id reached the operator with more than it should.
A storage lookup failure rendered the raw error into a public PR comment, and
on an aggregate repo the candidate table was built from this deployment's own
applies, presenting a partial view of the PR as the whole of it.

The lookup failure now posts a fixed line and keeps the cause in the server
log, and an unscoped fan-out falls back to the usage reply the leader posts
once.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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