Repository navigation
Conversation
09e2543 to
52d6ada
Compare
rdimitrov
left a comment
There was a problem hiding this comment.
Approving. Admission is checked on the shared create path, so gRPC and HTTP return the same result. The refuse-never-narrow rule holds on create, resume, and successors. The --no-shell check runs before /clear cancels the source. Focused server, executionclient, and app tests pass locally.
I left one non-blocking comment on successor admission.
| } | ||
| stampExecutionCapabilities(created, engine, binding.Environment) | ||
| stampExecutionCapabilities(created, engine, binding.Environment, admitted) | ||
| if err := checkEffectiveCapabilities(requested, created); err != nil { |
There was a problem hiding this comment.
Non-blocking: requested is the source's recorded set (admitted ∩ registered), but this check compares it against the successor's effective set, which also applies bound authority. If a session's authority withholds a tool its engine registers, fork and /clear are refused even though the client never asked for anything.
To reproduce with this PR's own ceilingAgent fixture: create an agent-bound session (WithAgentDefinitionName("reviewer")) with no capability request. The source records {Files:true Shell:true}. Then both ForkSessionSuccessor and ClearSessionSuccessor fail with agent definition "reviewer" does not allow "foreground-command".
The real agent-definition and root factories mint authority from the same catalog they register, so I don't think production can reach this today. It is still an easy trap if authority ever narrows separately. Two possible fixes: request executionSessionCapabilities(source) for successors, or check the successor's recorded set rather than its effective set.
There was a problem hiding this comment.
Thanks for the review, I should have addressed this issue.
Replace the blanket refusal of `execution.template.capabilities` with admission through the shared `Service` path. A request is forwarded to `EnsureTemplate`, honored exactly, or refused with `FAILED_PRECONDITION` (`failed_precondition`); malformed names stay `INVALID_ARGUMENT`. Refusals cover file-only requests, `--no-shell`, templates that do not declare a capability, agent-definition ceilings, debug targets, and placements that cannot enforce capabilities. The session records admitted ∩ registered capabilities. Factories get the set through the context and omit `Shell` without `foreground-command`; run environments drop the command runner. Resume reuses the recorded set without re-admission, and `/clear` and fork successors request the source's set.
52d6ada to
7e77cec
Compare
Summary
execution.template.capabilitiesis replaced by admission in the sharedServicecreate path, so gRPC and HTTP behave the same. A request is honored exactly or refused, never narrowed.INVALID_ARGUMENT(invalid_argument). Well-formed requests that cannot be honored areFAILED_PRECONDITION(failed_precondition, HTTP 412) through the newErrExecutionCapabilityRefused: file-only while it is postponed,--no-shell, a debug target, placements that cannot enforce a request (local, worktree, microVM, explicit placements), a capability the template does not declare, and an agent-definition ceiling.PlacementBindRequest.Capabilitiescarries the request toEnsureTemplatethrough the newClient.EnsureTemplateCapabilities;EnsureTemplatekeeps its signature. The provider's admission refusal message is kept forEnsureTemplaterefusals (bounded, printable, non-generic) and surfaced asExecutionCapabilityRefusal; every other provider error stays sanitised.PlacementBinding.AdmittedCapabilities. The session still recordsExecutionCapabilities{Files, Shell}, now stamped as admitted ∩ registered; the reported list stays admitted ∩ registered ∩ bound authority.ContextWithExecutionCapabilitiesand omitShellwithoutforeground-command; the agent-definition root also drops its runner.acquireExecutionstrips the runner from run environments, and a per-session engine is forced when the shared engine registers tools the session does not have.EnsureTemplate; it fails withErrPlacementChangedif the environment no longer admits the recorded set./clearand fork successors request the source's recorded set throughPlacementSuccessorRequest.Capabilities;ReserveSuccessorrefuses anything outside the inherited admitted set. Scheduled fires that borrow the source's environment make the same request and inherit only the source's recorded set. A Shell source on a deployment that now runs--no-shellis refused before/clearcancels the source and before fork or a fire reserves an environment. A successor's recorded set must match its source's; bound authority is not part of that comparison.Issue relationship
Closes #2712
Type of change
Test plan
Baseline checks
task lint)task test): covered bytask test:racetask test:race)go run ./cmd/mecademo)task docs)task site:build)task api:check): nothing underengine/changestask api:update+engine/CHANGELOG.mdAlso passing:
task check:prandtask sdk:e2e.Acceptance criteria
TestResumeUsesRecordedCapabilitiesWithoutReadmission./clearand fork request the source's capabilities and go through admission:TestSuccessorsRequestSourceCapabilities,TestSuccessorRefusesUnadmittedSourceCapabilities,TestSuccessorsOfShellSourceRefusedAfterNoShell,TestSuccessorsOfAgentBoundSourceIgnoreAuthority,TestScheduleFiresRequestSourceCapabilities.foreground-commandhas noShelltool and no runner:TestRealFactoryWithholdsShellAndRunnerWithoutForegroundCommand.TestExecutionCapabilityRequestsAcrossTransportscovers unknown, duplicate, file-only,--no-shell, debug target, non-enforcing placement, undeclared, narrowed by the provider, agent-definition ceiling, and honored. Client forwarding and message handling:TestBindForwardsCapabilitiesAndKeepsAdmissionRefusals.Changes
internal/adapter/server/execution_templates.gointernal/adapter/server/service.gointernal/adapter/server/placement.go,placement_successor.gointernal/adapter/executionclient/client.goEnsureTemplateCapabilities, admission messages, successor check, admitted set on bindingsinternal/app/build.go,agentdef_root.go,placement.goShelland the runner;--no-shellwiringcmd/mecak8s/flags.go--no-shellhelp textcontracts/proto/mecatl/v1/harness.protouser-docs/User-facing change
Clients can now request
execution.template.capabilitieson Kubernetes deployments.["filesystem", "foreground-command"]is honored; any request that cannot be honored is refused with a reason instead of the previous blanketINVALID_ARGUMENT.--no-shelldeployments refuse requests forforeground-command.API compatibility
No break and no major or feature identifier change; this is the in-major-2 behaviour the #2692 assessment reserved when #2693 made non-empty requests refuse until this issue. Request and response shapes are unchanged and the proto change is comment-only. A non-empty request was always
INVALID_ARGUMENTbefore, so no client relied on it; now a full request is honored and unsatisfiable ones getFAILED_PRECONDITIONwith a reason, using an existing error code, so the SDK error list is unchanged.session_capabilities.executionkeeps its meaning.On the private
mecatl.execution.v1API, mecak8s now fillsEnsureTemplateRequest.capabilities(no.protochange) and surfaces the provider's admission messages. Upgrade: the provider must include #2706, already merged. Stored session data is unchanged; Kubernetes execution state is purged at upgrade per #2692.Special notes for reviewers
ExecutionAccessapplies to a session must reportAdmittedCapabilities, or resume of a session with recorded capabilities fails withErrPlacementChanged. The Kubernetes provider does; two test fakes were updated to match.Bindalready does.