Repository navigation
mcpx: operator-declared readOnlyTools + typed gate refusals (#6116) #6265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -414,6 +414,13 @@ func describeInstance(in pool.InstanceStatus) string { | |
| // ---- confirm a destructive call ---- | ||
|
|
||
| // ErrNotConfirmed is returned when a destructive call was not approved. | ||
| // | ||
| // It is a typed refusal, not a tool failure (#6116): failureStatus | ||
| // answers it 403 and callErrorBody carries code | ||
| // "confirmation_required", so a caller -- above all a headless one, | ||
| // which can never answer the question -- can tell "the gate refused | ||
| // this call" apart from "the tool ran and failed" (a 502 with an | ||
| // upstream error) instead of quoting the gate text as a result. | ||
| type ErrNotConfirmed struct { | ||
| Tool string | ||
| Reason string | ||
|
|
@@ -434,7 +441,27 @@ func (e ErrNotConfirmed) Error() string { | |
| // An unanswered question refuses the call. That is the opposite of the | ||
| // disambiguation default, and for the opposite reason: there, doing nothing | ||
| // is safe; here, doing nothing is the destructive thing. | ||
| func (r *Registry) confirmDestructive(ctx context.Context, p *pool.Pool, tool string, cc config.CallContext) error { | ||
| // declaredReadOnly reports whether the operator declared this tool | ||
| // read-only for this server in local configuration (#6116): the | ||
| // per-server readOnlyTools list, read from the requested server's | ||
| // view for the same reason the write policy override is -- pools are | ||
| // shared between aliases, and the declaration belongs to the name | ||
| // the caller asked for. The operator's own declaration is trusted | ||
| // outright, as the locally declared stdio server's annotations are | ||
| // (#2191); a server cannot declare its own tools read-only this way. | ||
| func (r *Registry) declaredReadOnly(server, tool string) bool { | ||
| view, ok := r.View(server) | ||
| return ok && view.DeclaresReadOnly(tool) | ||
| } | ||
|
|
||
| func (r *Registry) confirmDestructive(ctx context.Context, p *pool.Pool, server, tool string, cc config.CallContext) error { | ||
| if r.declaredReadOnly(server, tool) { | ||
| // The operator declared this tool read-only (#6116): a | ||
| // pre-authorized call, not a destructive one, so there is | ||
| // nothing to confirm -- in any session mode, including a | ||
| // headless one with nobody to answer. | ||
| return nil | ||
| } | ||
| if !r.consumer.ConfirmDestructive || r.broker == nil { | ||
| return nil | ||
| } | ||
|
|
@@ -566,7 +593,8 @@ func (r *Registry) applyWritePolicy(ctx context.Context, p *pool.Pool, server, t | |
| tools = fresh | ||
| } | ||
| for _, candidate := range tools { | ||
| if candidate.Name == tool && policy.Classify(candidate.Annotations).ReadOnly { | ||
| if candidate.Name == tool && (policy.Classify(candidate.Annotations).ReadOnly || | ||
| r.declaredReadOnly(server, tool)) { | ||
| return policy.Decision{}, false | ||
| } | ||
| } | ||
|
|
@@ -655,6 +683,16 @@ func (r *Registry) applyWritePolicy(ctx context.Context, p *pool.Pool, server, t | |
| break | ||
| } | ||
| } | ||
| if r.declaredReadOnly(server, tool) { | ||
| // The operator declared this tool read-only in local | ||
| // configuration (#6116). That declaration outranks the | ||
| // server's annotations -- including their absence, which | ||
| // the specification's defaults read as a possibly | ||
| // destructive write and which is what gated manifestly | ||
| // read-only search tools (fff.find_files) in headless | ||
| // sessions, where the gate's question has no answerer. | ||
| class = policy.Classification{ReadOnly: true} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an operator-declared read-only tool without Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| decision := policy.Evaluator{}.Evaluate(policy.Input{ | ||
| Mode: parsed, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the configured fleet deployment,
services.mcpx.packagedeliberately uses the cascade's package rather than this checkout's build (home/common/default.nix:1163–1168). However,flake.lockstill pins that cascade'smcpx-srcto031cde20f71c2fafa068c47b69e68175b72994a5, whose parser lacksReadOnlyToolsand rejects unknownmcpxkeys usingDisallowUnknownFields. A fleet switch therefore feeds this new configuration to an incompatible daemon, preventing it from starting. Update the cascade source pin alongside this configuration so the selected service binary includes the new parser support.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by the cascade pin bump tracked in #6492: developing-today-forks/opencode#1911 bumped the fork mcpx-src pin 031cde2 → bcc0901 (the first code rev line whose parser carries ReadOnlyTools, via your finding PR #6265 merge 4e6cdb9), and #6750 bumped code's opencode pin to the fork merge rev, moving the transitive mcpx-src node to bcc0901. Verified on the laptop: the cascade build at the new pin parses the live rendered mcpx config, while the old-parser binary refuses the same file with server "fff": its "mcpx" block has no key "readOnlyTools". Full evidence on #6492.