Skip to content

feat(executioncontroller): add the authorizing Files and Commands proxy - #2899

Merged
blkt merged 5 commits into
mainfrom
feat/2701-authorizing-proxy-c1
Nov 20, 2026
Merged

blkt merged 5 commits into
mainfrom
feat/2701-authorizing-proxy-c1

Conversation

@blkt

@blkt blkt commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the authorizing proxy for the executor FileService and CommandService to mecatl-execution-provider: FileProxy and CommandProxy in internal/adapter/executioncontroller authorize each call with today's checks and forward it to the session's executor.

  • Authorization before forwarding. Each call authenticates the client through the Handler's security policy, requires a complete RequestContext and MayAttestOwner, and asks Store.ExecutorRoute to validate the run claim, epoch, grant generation, binding and current client policy. ValidateRunClaim is split so both paths share those checks from one read of the environment. The same read refuses a lifecycle operation in progress and a service the session was not admitted for (PermissionDenied), and returns the executor pin and the template's limits. Nothing is forwarded until all of it passes.
  • Refusals the client can trust. Every refusal before forwarding, including an executor that cannot be reached when the upstream stream is created, carries the new executor reason ERROR_REASON_NOT_FORWARDED, and executorclient reports such a command as not started instead of ErrOutcomeUnknown. The proxy drops that reason from executor responses, so only the proxy can claim it.
  • Template limits as data flows. File chunks are relayed without assembling them, and a read or write over MaxFileBytes fails with LIMIT_EXCEEDED; a refused write cancels upstream, so nothing is stored. RunCommand bounds the command length by MaxCommandBytes and the timeout by MaxCommandDuration, forwards cancels, and clips stdout and stderr at MaxCommandBytes as they stream, setting output_truncated on the result.
  • Per-client limits on streams. RPCLimiter.StreamInterceptor holds the per-client and global capacity for a stream's lifetime, and the provider now chains it next to the unary interceptor, so RunCommand counts.
  • Pinned addressing. ExecutorDialer.Connector dials per call and re-resolves the pinned Pod name and UID on every connection, so a replacement Pod at the same address is refused before the handshake, and the certificate pin still applies.
  • Conformance through the proxy. fileconformance.Target and commandconformance.Harness gain an optional request context, and both suites run through the proxy over memexecutor and the Files gRPC server #2694 fileserver.

Issue relationship

Closes #2701

The provider does not register the proxy services yet: executor Pods have no server port until the transport switch (#2718), which also carries the demo criterion. No unary buffering is added for mecak8s (optional in the issue); StartCommand still uses Pod exec. Withdrawal of in-flight calls and fencing on unknown command outcomes land after the switch, per implementation.md. The proxy passes the RequestContext to the executor unchanged, as executor-protocol.md describes.

Type of change

  • New feature

Test plan

Baseline checks

  • Linting (task lint, task lint:proto against main)
  • Pre-review race suite (task test:race)
  • Offline demo (go run ./cmd/mecademo): tool call, permission ask and approval, result. The demo does not go through the proxy yet.
  • task check:pr, task generate:data:check
  • go vet untagged and with all custom tags on Linux and darwin (darwin with the e2e tag fails on main too, in e2e/harness/local.go)

Focused tests:

  • TestProxyRefusesBeforeForwarding: stale epoch, stale and revoked grant generation, lapsed claim, files or commands not admitted, missing request context, request context without claim or owner, and a replaced executor Pod. Each case checks the gRPC code, the NOT_FORWARDED detail, and that nothing was forwarded.
  • TestFileProxyConformance and TestCommandProxyConformance run the conformance suites through the proxy.
  • TestCommandProxyClipsOutputMidStream, TestCommandProxyBoundsTheStart, TestFileProxyEnforcesTheTemplateFileLimit, TestRunCommandHoldsPerClientCapacity, TestExecutorConnectorFollowsThePinnedPod, TestExecutorErrorDropsNotForwarded.
  • TestCommandProxyTagsAnUnreachableExecutor: a refused connection to the executor fails when the upstream stream is created, before the start is sent; it is tagged NOT_FORWARDED and executorclient reports the command as not started.
  • TestFailureBeforeStartedIsUnknownUnlessRefused gains the NOT_FORWARDED cases; an untagged PermissionDenied before Started stays unknown.

Changes

+1,448 −55 across 15 files.

Files Added / removed
App code 8 +740 / −19
Tests 5 +688 / −24
Generated, docs, config 2 +20 / −12
  • App code: proxy_files.go (+233), proxy.go (+226), proxy_commands.go (+166); the rest is store_run.go (+42 −12), executor_dial.go (+38), security_limit.go (+32 −6).
  • Tests: proxy_test.go (+634), executor_dial_test.go (+31 −20), the two conformance helpers (+19 −4).
  • Generated, docs, config: errors.pb.go (+18 −12) and errors.proto (+2).

Comment ratio on touched files: 0.17 in app code, 0.01 in tests.

File Change
internal/adapter/executioncontroller/proxy.go, proxy_files.go, proxy_commands.go FileProxy, CommandProxy, ExecutorRoute, ExecutorConnector, notForwarded
internal/adapter/executioncontroller/store_run.go ValidateRunClaim split into validateRunClaim, which returns the environment it read
internal/adapter/executioncontroller/executor_dial.go ExecutorDialer.Connector
internal/adapter/executioncontroller/security_limit.go RPCLimiter.StreamInterceptor
cmd/mecatl-execution-provider/main.go Chains the stream interceptor
contracts/proto/mecatl/executor/v1/errors.proto ERROR_REASON_NOT_FORWARDED
internal/executorrpc/executorclient/runner.go Treats NOT_FORWARDED before Started as not started
internal/executorrpc/fileconformance, commandconformance Optional request context

User-facing change

None. The proxy services are not registered yet.

API compatibility

  • Assessment: additive. ErrorReason gains ERROR_REASON_NOT_FORWARDED = 10. Nothing outside this repo consumes mecatl.executor.v1 yet. A client that does not know the value reads it as an unrecognized reason and keeps today's behavior: outcome unknown for commands, a plain error for files. Existing executors never send it. The provider's ExecutionProviderService is unchanged, and the new stream interceptor affects nothing until streaming services are registered.
  • Major/feature changes: feature (new enum value).
  • Upgrade implications: none for this PR.
  • Go source: fileconformance.Target and commandconformance.Harness gain optional fields; existing callers are unaffected.

@blkt
blkt force-pushed the feat/2701-authorizing-proxy-c1 branch from b8fd414 to 8fd56cc Compare November 20, 2026 09:47
@blkt blkt self-assigned this Nov 20, 2026
@blkt
blkt force-pushed the feat/2701-authorizing-proxy-c1 branch from 9350108 to 6829254 Compare November 20, 2026 12:43

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Every refusal tagged NOT_FORWARDED happens before the start message or first chunk reaches the executor. A failed NewStream can't have started a command, and errors after Send correctly stay untagged, so they're reported as unknown. Sharing validateRunClaim keeps the proxy and the exec path on the same checks, and dropping the reason from executor responses means only the proxy can claim it.

@blkt
blkt enabled auto-merge (squash) November 20, 2026 13:22
blkt added 5 commits November 20, 2026 14:24
`FileProxy` and `CommandProxy` implement the executor `FileService`
and `CommandService` on the provider. Each call authenticates the
client through the `Handler`'s security policy, requires a complete
`RequestContext`, and asks `Store.ExecutorRoute` to validate the run
claim, epoch, grant generation, binding and current client policy
with the same checks as `ValidateRunClaim`. The route also refuses a
service the session was not admitted for, and returns the executor
pin and the template's limits. Nothing is forwarded until it passes.

The proxy relays file chunks without assembling them and fails a
read or write that exceeds `MaxFileBytes`. `RunCommand` bounds the
command length and timeout by the template, forwards cancels, and
clips stdout and stderr at `MaxCommandBytes` as they stream, setting
`output_truncated` on the result.

`ExecutorDialer.Connector` dials the executor for each call and
re-resolves the pinned Pod name and UID on every connection, so a
replacement Pod at the same address is refused before the handshake
and the certificate pin still applies.

`RPCLimiter.StreamInterceptor` holds the per-client and global
capacity for a stream's lifetime, and the provider now chains it
next to the unary interceptor. The provider does not register the
proxy services yet; that happens with the transport switch.

`fileconformance.Target` gains an optional request context so the
suite runs through the proxy.

Every refusal the proxy makes before forwarding carries the new
`ERROR_REASON_NOT_FORWARDED` executor detail, and `executorclient`
reports such a command as not started rather than outcome unknown.
The proxy drops that reason from executor responses, so only the
proxy can claim it. The reason is additive: older clients keep
treating it as unknown.

`commandconformance.Harness` gains an optional request context, and
both conformance suites run through the proxy over `memexecutor`.

Closes: #2701
Wrapped calls in the proxy tests put each argument on its own line,
and no `if` statement wraps around an init.
A refused connection surfaces when the proxy creates the upstream
`RunCommand` stream, before the start message is sent, so the
executor cannot have started the command. Tag that error with
`ERROR_REASON_NOT_FORWARDED` so `executorclient` reports the
command as not started instead of outcome unknown. Errors from
sending the start onwards stay untagged.
…nce suites

`commandconformance.Harness.Context` takes an
`executorclient.RequestContextFunc`, like `fileconformance.Target`,
so both proxy conformance tests pass the same function.
The proxy takes an `ExecutorConnectFunc` instead of the
`ExecutorConnector` interface, and drops its unused context.
`ExecutorDialer.Connect` implements it on
`executionenv.ExecutorServerPort`, replacing the `Connector(port)`
wrapper. `Dial` and `Connect` share one resolve-and-dial step.
@blkt
blkt force-pushed the feat/2701-authorizing-proxy-c1 branch from 6829254 to 2cc8aa7 Compare November 20, 2026 13:25
@blkt
blkt merged commit b233a09 into main Nov 20, 2026
78 of 80 checks passed
@blkt
blkt deleted the feat/2701-authorizing-proxy-c1 branch November 20, 2026 14:12
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.

Authorizing proxy for Files and Commands

2 participants