Repository navigation
feat(wo): add optional pending-approval gate for work-order writes - #642
Open
sharanharsoor wants to merge 1 commit into
Open
sharanharsoor wants to merge 1 commit into
sharanharsoor wants to merge 1 commit into
Conversation
approve_workorder, close_workorder, and cancel_workorder currently apply their target status unconditionally (documented in docs/mcp-servers.md: 'There is no status-transition guard'). This adds a separate, opt-in human checkpoint in front of those three calls. Off by default (AOB_REQUIRE_APPROVAL=1 to enable), same convention as the existing AOB_READONLY. When enabled, the first call to a gated tool returns an action_id instead of running. An operator approves or denies it with scripts/wo_pending.py; the agent must then repeat the identical call. The approval is bound to a SHA-256 digest of the call's arguments and consumed exactly once, so approving one call never covers a different one (a different wonum, different reason, etc.), and the pending store being unreachable fails closed instead of letting the call through. Also adds destructiveHint=True to the three gated tools' ToolAnnotations (previously unset on any write tool in this server; the one existing usage is on a read-only tool). This does not add the status-transition check itself. It adds a human checkpoint in front of whatever transition the agent requests. The two are independent and composable. 30/30 existing + new WO server tests pass with the gate both on and off. Signed-off-by: Sharan Harsoor <sharanharsoor@gmail.com>
Collaborator
|
@sharanharsoor Maybe it's better to create a git issue for any code changes, and we can discuss the reasoning behind certain decisions. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
approve_workorder,close_workorder, andcancel_workordercurrently apply theirtarget status unconditionally.
docs/mcp-servers.mdalready documents this: "Thereis no status-transition guard." This PR adds a separate, opt-in human checkpoint in
front of those three calls, it does not add the transition check itself. The two are
independent and composable.
How it works
AOB_REQUIRE_APPROVAL=1to enable, same convention as theexisting
AOB_READONLY.pendingresult with anaction_idinstead of running.scripts/wo_pending.pyCLI (
list/approve/deny), which talks to the same CouchDB-backed pendingstore the server uses.
digest of the call's arguments and consumed exactly once, so approving one call
never covers a different one (different
wonum, differentreason, etc.).letting the call through.
destructiveHint=True/idempotentHint=Falseto the three gated tools'ToolAnnotations(previously unset on any write tool in this server).Why
Looked into whether this server has any human-in-the-loop mechanism for its
destructive write tools before building this. It doesn't,
AOB_READONLYis the onlyrelated control, and it's a binary on/off that isn't specific to these three
higher-risk transitions. This adds a lightweight, opt-in checkpoint without touching
default behavior for anyone not using the env var.
Testing
that call
main.approve_workorder()directly and confirm the work order staysWAPPRwhile gated and only transitions after operator approval + an identicalretry.
mcp.list_tools()) picks up the newannotations correctly, and that
AOB_READONLY=1still behaves as before alongsidethis change.
ruff format --checkclean; no newruff checkfindings beyond pre-existingtyping-style debt already present throughout this file.
Size
This is ~570 lines against the project's stated 300-line preference. Splitting it
would mean reviewing the gate without its tests, or shipping the operator CLI
separately from the feature it operates on, so it's kept as one PR.