← Back to Pull requests

feat(agent): enforce authorization at tool execution boundary #169

Merged
Koiyd merged 10 files (853 lines) on Oct 17, 2026 14:38 UTC
View on GitHub
Koiyd Koiyd commented on Oct 16, 2026 06:28 UTC
Author

Describe what this PR does / why we need it

Adds opt-in authorization enforcement at the tool execution boundary, enabling applications to control which principals can invoke which tools based on runtime context.

This PR introduces:

  • AuthorizationDecision: Immutable allow/deny result with optional reason

  • ToolAuthorizationPolicy: Application SPI for authorization decisions with three built-in factory methods (allowAll, denyAll, requireMatchingTenant)

  • ToolAuthorizationInterceptor: ToolInterceptor that invokes the policy before dispatching; strict mode (default) rejects calls without trusted execution context

  • Tenant-scoped BackgroundTask access: TaskRepository now supports tenant-isolated task lookup to prevent cross-tenant access
  • Does this pull request fix one issue?

    Fixes #120
    Refs agentic-ai-java/argi#117

    Describe how you did it

    1. Created AuthorizationDecision as an immutable value type representing allow/deny outcomes
    2. Defined ToolAuthorizationPolicy functional interface as the application SPI, with three built-in static factory methods covering common cases
    3. Implemented ToolAuthorizationInterceptor extending ToolInterceptor, which reads TrustedExecutionContext from RunnableConfig and invokes the policy before forwarding to the next handler
    4. Extended BackgroundTask to record the creating principal's tenant
    5. Added tenant-scoped getTask(id, callerTenantId) method to TaskRepository interface as a default method; null caller has unrestricted access
    6. Implemented tenant-isolated lookup in DefaultTaskRepository and updated TaskOutputTool to pass caller's tenantId from trusted execution context

    Describe how to verify it

    Run the test suite:

    ./mvnw -pl :argi-agent-framework test \
      -Dtest="ToolAuthorizationInterceptorTest,DefaultTaskRepositoryTenantIsolationTest,BuiltInAuthorizationPoliciesTest"
    

    All 18 tests pass, covering:

  • Authorization decisions (allow/deny with reason)

  • Built-in policies (allowAll, denyAll, requireMatchingTenant)

  • Interceptor behavior in strict/lenient modes

  • Tenant-isolated task repository access
  • Special notes for reviews

    Opt-in design: No ToolAuthorizationInterceptor is registered by default. Existing AgentToolNode configurations are unaffected and execute tools without authorization checks. Applications must explicitly add the interceptor to enable authorization.

    Built-in policies reduce friction: The three factory methods (allowAll, denyAll, requireMatchingTenant) provide reasonable starting points without requiring a full custom policy implementation.

    Execution order matters: ToolAuthorizationInterceptor should typically be placed early in the interceptor chain (before retry/fallback) so that revoked access takes effect immediately, including on retries.

    Diff: 853 lines (+851 / -2) across 10 files Reviewer: yuluo-yx Review duration: 1929m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.79) × (1 − Review Confidence (0.65)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.79 · 853 lines diff across 10 files
    0.79
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.35 · 1 substantive comment(s)
    0.35
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    65%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Sensitive Paths sensitive_paths
    0.079
    Real PR Conversation Timeline
    2 items
    yuluo-yx yuluo-yx approved these changes on Oct 17, 2026 14:38 UTC
    Approved Reviewer

    LGTM,thanks for you

    Reviewers
    Assignees
    Koiyd Koiyd
    Labels
    risk: low confidence: 65% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 79.4% (HIGH) · Higher = larger blast radius
    79.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 65% · Lower = rushed or shallow review
    65%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.8% · Safe to merge
    27.8%