Skip to content

Add GitHub bot-role lookup behavior matrix for ADR 0107 #8413

Closed

Description

@ifireball

What is missing

The behavior-test suite now has a real GitHub mint matrix in
e2e/behaviour/features/platform/mint-scope.feature, backed by
pkg/behaviourtest/steps/mint_probe.go.

ADR 0107 needs equivalent executable coverage for provider-backed bot-role
lookup. Without this, an implementation could continue deriving roles inside
the authorization gate, rely on hardcoded bot names, or treat mint permission
as dispatch authorization without being caught by behavior tests.

What should happen

Add a GitHub bot-role lookup API and implementation covered by a behavior-test
matrix using real mint-accessible GitHub App identities.

The matrix should cover:

  • a registered app identity resolving to its exact canonical Fullsend role;
  • the existing e2e App, which is installed in the test organization and
    accessible to the suite but is not included in the test mint's registered
    role set, producing a successful no-match for the target repository;
  • an identity registered for a different target not matching the current
    repository;
  • provider/API lookup failure;
  • the corresponding actor.kind, actor.role, actor.bot_role, and
    actor.role_verified results;
  • non-label dispatch being allowed only for a recognized bot role;
  • successful no-match and lookup failure being distinguishable and denied
    before CEL authorization.

The test must use the existing test-organization App inventory. It must not
require creating a new unauthorized App, depend on production
fullsend-ai-* App names, or accept a role claimed by event content.

Minted credentials and private material must not be written to artifacts or
logs. The test should retain only sanitized lookup results and dispatch
outcomes.

Context

This is the GitHub lookup/test slice of #8329,
which tracks the complete ADR 0107 implementation.

The test should follow the existing mint-probe pattern: real provider
authentication, a scenario outline or equivalent example matrix, and explicit
failure handling so infrastructure errors cannot pass as expected lookup
denials.

Non-GitHub lookup behavior remains deferred until a non-GitHub behavior-test
environment exists.

Activity

  1. self-assigned this
    on Oct 14, 2026
  2. fullsend-ai-triage commented on Oct 14, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 7:03 AM UTC · Completed 7:05 AM UTC

    Commit: f75a156 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.23

  3. added
    feature
    triaged
    on Oct 14, 2026
  4. fullsend-ai-triage commented on Oct 14, 2026

    @fullsend-ai-triage

    Your responses settle the open points from the previous round, and the scope below now reflects them. No open or merged PR addresses this issue, and #8329 stays the owner of the shared resolver contract.

    Updated scope

    • Resolver files and types are named so the package can later cover token retrieval and other bot-identity management. That wider design is not part of this issue.
    • The e2e App is treated as a stand-in for a third-party app: it is installed in the test org, but not in the test mint's role set. Its login is discovered at runtime.
    • The "registered for a different target" row is dropped from the matrix.
    • pkg/behaviourtest must not import mintcore. Small duplication is acceptable, and TestBehaviourtestDepsExcludeMintcore guards the boundary.
    • Mintcore changes need the .embed sync and must stay within the WASM size limit.
    • Docs to update: the normalized-event projection table, harness-fields.md and the Authorization v1 banner.

    The API shapes proposed earlier are otherwise unchanged: the forge-neutral BotRoleResolver, the OIDC-bound POST /v1/bot-role endpoint, the outcome-to-actor-field mapping, and the extended mint-probe steps.

    Matrix after the scope change

    registered:review   -> recognized, bot_role=review, role_verified=true, dispatch allowed
    unregistered-e2e    -> no_match, bot_role absent, role_verified=true, denied-before-cel
    forced-failure      -> lookup error, bot_role absent, role_verified=false, denied-before-cel
    claimed-in-event    -> ignored (same as no_match)
    infra/control error -> scenario fails (never passes as a denial)
    

    As you requested, this is not auto-promoted. Run /fs-code when you approve the shapes, or add guidance to the command.


    Labels: The needs-design label no longer fits: the API shapes were proposed and the maintainer's answers resolve the open design points.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
    Previous run

    This re-triage responds to the request to propose the API shapes. These are proposals for maintainer approval, not decisions. The earlier points still apply, and #8329 should own the shared resolver contract.

    1. Forge-neutral resolver contract. Put it in a small package that does not import mintcore, so the dispatch path and pkg/behaviourtest can both use it:

    type BotRoleResolver interface {
        ResolveBotRole(ctx context.Context, q BotRoleQuery) (BotRoleResult, error)
    }
    type BotRoleQuery  struct { Forge, Target string; Login string } // Target = owner/repo; identity comes from the verified adapter, never from payload content
    type BotRoleResult struct { Role string }                         // "" = successful no-match
    // err != nil (typed ErrLookup) = lookup failure; callers must fail closed

    A single helper maps the three outcomes onto the actor fields from ADR 0107:

    Outcome kind role bot_role role_verified
    recognized bot none canonical role true
    no-match bot none absent true
    error bot none absent false

    Add BotRole string (omitempty) and RoleVerified *bool to normevent.Actor. The pointer keeps "not applicable" distinct from false. IsAuthorized then gets a non-label bot branch that requires a non-empty BotRole, and the label exception stays untouched.

    2. Mint lookup surface (GitHub). Add an OIDC-authenticated POST /v1/bot-role to mintcore, next to /v1/token:

    • Request: {"actor_login": "<slug>[bot]", "repo": "owner/repo"}. The mint binds repo to the OIDC repository claim, so a caller cannot ask about another target.
    • Response: {"outcome": "recognized", "role": "review"} or {"outcome": "no_match"}. Any 401/5xx or transport error is a lookup failure.
    • Matching: resolve the login's slug to an App ID through GitHub's public app endpoint, then compare it exactly against ROLE_APP_IDS. This avoids hardcoded bot names. Target scoping should reuse the mint's existing installation and foreign-grant checks.
    • It returns only role names, never tokens. A resolver client can live in internal/, like internal/mintclient.

    3. Behavior-test surface. Extend the mint-probe harness (same leased repo, probe workflow and control request) with these steps:

    Given a "github" bot-role lookup probe
    When the lookup resolves identity "<identity>" for the leased repository
    Then the lookup outcome is "<outcome>"
    And the actor is kind "<kind>" role "<role>" bot_role "<bot_role>" role_verified "<verified>"
    And non-label dispatch is "<allowed|denied-before-cel>"
    

    <identity> is a symbolic name (registered:review, unregistered-e2e, other-target, forced-failure, claimed-in-event) that the step resolves to real logins at runtime. Discover the e2e login at runtime instead of hardcoding it. For the forced-failure row, send a subject request with deliberately invalid credentials while the control request in the same run still succeeds. That keeps it distinct from an infrastructure error, which fails the scenario.

    Open points for maintainers:

    • The e2e-testing guide says there is no e2e test App and that the installed one is the production-named App. That conflicts with the no-production-names requirement, so confirm the discovery approach.
    • The meaning of "registered for a different target" on a mint with no per-repo role registry (installation coverage versus foreign grants) needs a decision.
    • Whether pkg/behaviourtest may import the dispatch gate without pulling mintcore into its graph must be checked against TestBehaviourtestDepsExcludeMintcore.
    • Mintcore changes need the .embed sync and must respect the WASM size limit.
    • Update the normalized-event projection table, harness-fields.md and the Authorization v1 banner.

    This feature is not auto-promoted. Please confirm or adjust the shapes before dispatching the code agent.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
    Previous run (2)

    Triage assessment: the expected outcomes are already pinned down by ADR 0107 and the Authorization v1 decision table (recognized role, successful no-match with role_verified true, lookup failure with role_verified false, both denied before CEL on non-label paths), and the mint-probe feature and steps give a clear pattern to follow. No open PR currently addresses this issue.

    Points for whoever picks it up:

    • Open design point: no bot-role resolver or mint lookup surface exists yet, and actor.bot_role / actor.role_verified exist only in the normative docs, not in Go. The shape of the lookup API (and how the behavior test reaches the mint's registered set across the pkg/behaviourtest vs internal/mintcore module boundary) should be confirmed by a maintainer before large-scale coding. This matches the existing needs-design status, and this is a feature, so it is not auto-promoted to ready-to-code.
    • Relationship to Implement ADR 0107 bot identity resolution before dispatch authorization #8329: this is the GitHub lookup/test slice of that tracking issue. It is not blocked by it, but the resolver interface should be designed once and shared with the rest of that work, so non-GitHub providers can later implement the same contract.
    • Failure handling: keep the control-request pattern from mint_probe so provider/infrastructure errors fail the scenario rather than passing as expected denials. The deliberate lookup-failure row must be injected in a way that is clearly distinct from an accidental infra failure.
    • Docs: if the new API or fields change documented behavior, update the normative docs and docs/contributing/harness-fields.md per AGENTS.md.

    Proposed test matrix:

    Scenario Outline: bot-role lookup for <identity>
      registered app identity          -> bot_role=<canonical role>, role=none, role_verified=true, dispatch allowed
      e2e App (not in mint role set)   -> bot_role absent, role_verified=true, denied before CEL
      identity registered elsewhere    -> no match for this repo, denied before CEL
      provider/API lookup failure      -> bot_role absent, role_verified=false, denied before CEL
      role claimed in event content    -> ignored
      infra error (OIDC/transport)     -> scenario fails, never a pass-as-denial
    

    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  5. ifireball commented on Oct 14, 2026

    @ifireball
    MemberAuthor

    /fs-triage suggest the shapes of the APIs that need to be designed, I will inovke the code agent upon approval, or request fixes in further comments

  6. fullsend-ai-triage commented on Oct 14, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 8:01 AM UTC · Completed 8:04 AM UTC

    Commit: f75a156 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.37

  7. added
    feature
    triaged
    and removed
    feature
    triaged
    on Oct 14, 2026
  8. 14 remaining items

  9. added 2 commits that reference this issue on Oct 15, 2026
  10. ifireball commented on Oct 20, 2026

    @ifireball
    MemberAuthor

    Scope update for PR #8415: I requested reset-aware recovery after BT exhausted the shared GitHub installation quota in this /fs-fix instruction. Keep the resulting internal/forge/github primary-limit wait in this PR, with its production-wide effect on GitHub forge calls and its caller-context/65-minute bound. The BT repo-allocation quota pacing is also in scope. The PR description now discloses both changes. This scope decision does not waive the required BT check or remaining review fixes.

  11. added 9 commits that reference this issue on Oct 20, 2026
  12. added a commit that references this issue on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featuretriaged

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions