fix: give a scoped presetless call its scope's kind

RA
2d ago
+169-103

Linked issue

Approved issue: #1649

What changes

resolve_caller_role now takes the route's ScopeKind (Option<ScopeKind>) instead of a scoped_route bool. A call that names no preset on a head or worker scope runs as that kind. Before, it was refused.

Unchanged:

  • A preset named on the call still wins on every route.
  • An unscoped route keeps worker_session / UNSCOPED_DEFAULT_PRESET.
  • ephemeral, federated and any future kind still require a named preset. The error text now says so.

This unblocks the MCP gateway. subc-mcp registers every host session as a head scope (subconscious, crates/subc-mcp/src/session_scope.rs:169) and deliberately sends no preset (crates/subc-mcp/src/main.rs:4509-4511). As a result, no MCP host could call a scoped AFT tool.

Call sites change only in how they pass the scope: identity.scope.is_some() becomes identity.scope.as_ref().map(|stamp| stamp.kind). The completion-ack exemption is unchanged. It still clears the scope for bash_ack_completions.

How it was checked

  • cargo fmt --all -- --check.
  • cargo check --workspace --tests --features test-hooks.
  • The changed tests, which pass:
    • call_presets_resolve_by_route_kind: covers every preset × route-scope combination, including ephemeral and federated refusal.
    • missing_preset_takes_the_route_scope_kind, renamed from missing_preset_is_head_unscoped_and_refused_scoped because head and worker scopes are no longer refused. The rename is recorded in crates/aft/test-ledger/moves.tsv. The route-level matrix now includes an ephemeral scope: presetless head/worker scopes dispatch, and ephemeral is refused before dispatch.
    • The admit cases in caller_role_and_preset_admission.
  • cargo test -p agent-file-tools --features test-hooks --test rest -- tool_provider_conformance: 52 pass. The 6 failing s1_*/s2_* scoped-shell tests fail the same way on unpatched main on this host, because the approved scoped shell needs the strict sandbox (assert_approved_scoped_shell_result).
  • cargo test -p aft-subc --features test-hooks --lib: the failure set is identical to unpatched main at 06e03a749, apart from two order-dependent tests that also fail on main when run together:
    • consent::tests::consent_folder_grant_* and the straddling_tests::secret_bash::* tests fail on unmodified main on this host (Linux x64).
    • remote_calls::…::remote_shell_wire_holds_and_settles_after_scope_end_revoke_and_timeout and consent::tests::secret_fetch_cancellation::foreground_fetch_cancel_with_two_pending_labels_… each pass alone. Run together, remote_shell_wire… fails on unpatched main too, 3 of 3 times.
  • End-to-end reproduction in #1649: driving ck-subc-mcp shim directly with aft_bash is refused on v0.68.1 for every client name and --harness value.

Confidence Score: 3/5RetriggerView in Greptile

Fix worker remote settings and saved-grant restoration before merging.

Findings

  1. P1 Workers use head remote settings ▶
  2. P1 Saved worker paths stay unavailable ▶

Summary

Presetless calls now take the role declared by a head or worker scope.

  • Presetless calls use the role declared by a head or worker scope.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Tool call] --> B{Named preset?}
  B -->|Yes| C[Use named role]
  B -->|No| D{Route scope}
  D -->|Head| E[Head role]
  D -->|Worker| F[Worker role]
  D -->|Other kind| G[Refuse missing preset]
  D -->|Unscoped| H[Keep existing default]
  F --> I[Shell policy still reads raw preset]
  F --> J[Grant restoration still requires named worker preset]

Reviews (1) · Last reviewed commit: "fix: give a scoped presetless call its s..." · Reviewed by Greptile