This repository was archived by the owner on Sep 2, 2026. It is now read-only.
Repository navigation
[Spec] Stage authority & in-app MCP server - #61
Merged
Merged
Conversation
decideStageWrite/assertStageWriteAllowed gate workflowStage writes by caller kind: agents may declare working stages and clear but never shipped (fail-closed with steering message); humans are unrestricted. Governing facts shape only the explanation and effective stage via the existing derivation engine.
…e.update (#39) Guard runs in the handler before any write; agent shipped attempts fail closed with the steering message as a stage_authority_refused error. Human UI paths (direct IPC, service layer) stay unrestricted.
--stage <id|null> maps onto the workflowStage RPC param (null clears, absent leaves unchanged); refusal errors from the host surface verbatim. No client-side guard: authority lives on the RPC so SSH/remote shims inherit it.
HTTP JSON-RPC server in the Electron main process exposing agent tools (declare_stage, link_issue, read_board) behind a per-launch bearer token. Every stage write routes through assertStageWriteAllowed with callerKind 'agent' BEFORE any store mutation, so shipped refusals surface the steering message fail-closed. Sessions bind a workspace selector at initialize; endpoint+token publish to orca-mcp.json for terminal-agent discovery.
Drops an unused protocol constant, routes notification detection through isNotification(), and adds docs/reference/mcp-server.md covering endpoint discovery via orca-mcp.json, bearer auth, session binding and stage authority.
Track the MCP server reference (endpoint+token via orca-mcp.json, bearer auth, session binding, shipped authority) by allow-listing it like the other durable reference docs.
…code trims (#43) - folder link_issue derives provider from URL host and fails closed on unknown hosts - stage authority explains "no provider facts consulted" when facts absent - drop unused McpSessionRegistry.size(), unexport getOrcaMcpMetadataPath - hoist duplicated linkedIssue expression; trim overlong comments
…stituents string literal tags in 'string | too_large | unreadable' are absorbed by string, tripping oxlint type-aware rule; failures now ride a kind/reason discriminant so reasons stay distinct types. Behavior unchanged.
64ix
marked this pull request as ready for review
August 24, 2026 16:35
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Implements spec #23: one pure authority guard deciding which caller (agent vs human) may set which workflow stage, exposed through CLI parity (
orca worktree set --stage) and Orca's first in-app MCP server.shippedis refused fail-closed for agents with a steering message; the human can place any stage from UI paths, including de-shipping.Spec & Tickets
Criteria
stage-write-authority.test.ts— 48-cell matrix (7 stages + null-clear × agent/human × no-facts/open-PR/unconsumed-merge)shippedrefused with steering message, no state changeSHIPPED_STAGE_STEERING_MESSAGE; RPC test assertsupdateManagedWorktreeMetanot calledassertStageWriteAllowedfirst statement inworktree.set/folderWorkspace.updatehandlers; spy-proofed in testsshipped/ de-ship via UI pathsworktrees:updateMeta) untouchedorca worktree set --stage <id|null>; guard lives server-side in RPC;stage_authority_refusedin passthrough codes reaches remote shimssrc/shared/stage-authority/stage-write-authority.ts— pure, serializable decisions; reused by MCP ticket #43declare_stagetool, auto-approved; manifest served bytools/listwith zero approval flow (orca-mcp-server.test.ts)node:http: 401 on wrong + missing token before routing/body parsingtools/listmanifest callable immediately post-boot;declare_stagedescription carries the shipped rule at discovery timemcp-session-idheader binding at initialize; test proves two sessions bound to different workspaces never cross wiresmcp-stage-tools.test.ts: shipped refusal before write with runtime spies untouched; steering message pinned to shared guard module outputArbitrations (Problem → Resolution)
read_board: tasks are workspaces in Orca's model; a separate task-listing tool would duplicate it.orca-mcp.json(runtime metadata file is owned/rewritten by runtime-rpc and would clobber merged-in fields).link_issuerequires title+url because folder workspaces persist full provider items; git worktrees take just the number.Changes
Stage authority guard (#39)
src/shared/stage-authority/stage-write-authority.ts— pure decision gate: (caller kind, requested stage, governing facts) → allowed/refused + explanation; agents declaringshippedare refused with the steering message regardless of facts.src/main/runtime/rpc/methods/worktree.ts,folder-workspace.ts— guard asserted before any write inworktree.setandfolderWorkspace.update.src/main/runtime/rpc/errors.ts—stage_authority_refusedjoins structured passthrough codes so CLI/SSH shims see typed refusals.src/cli/—orca worktree set --stage <id|null>flag (tri-state: absent = no change,null= clear), registry parity + help text.Updated as tickets merge.
In-app MCP server (#43)
src/main/mcp/— stdlib-only (node:http/node:crypto) loopback JSON-RPC server: bearer auth before routing (digesttimingSafeEqual), 1 MiB body cap, notifications → 202; toolsdeclare_stage/link_issue/read_board; workspace-bound sessions with idle TTL; per-launch token + endpoint published to<userData>/orca-mcp.json(0600).src/main/index.ts— server constructed beside the runtime RPC, started in headless + desktop paths, teardown joined to the quit barrier.docs/reference/mcp-server.md— discovery/auth/tools reference.Code-review fixes
link_issuederives the provider from the URL host (github/gitlab/jira/linear) and fails closed on unrecognized hosts instead of stampinggithub.McpSessionRegistry.size(), over-exposed metadata path helper), duplicated expression hoisted, comment trims, deferred human-caller-kind wiring documented onStageWriteCallerKind.QA Plan
pnpm testgreenorca worktree set --stage specmoves a card;--stage shippedis refused with the steering message and no state changeinitialize/tools/listwith a valid bearer token; 401 on wrong/missing tokendeclare_stagewithshippedreturns refusal text and leaves storage untouchedstage_authority_refusedfailure sanely (generic typed failure, no crash)