Skip to content

Add ADR 0107 bot account authorization for GitLab events #9059

Open
0 of 3 issues completed
Open

Description

@ifireball

What happens

GitLab source events enter through two built-in drivers:

  • The scheduled/event polling path runs Poller.Run.
  • The native webhook fast path runs Poller.RunWebhook.

Both use Poller.toNormalizedEvent and the same poll dispatch spine. This issue covers both. Jira events sent to GitLab with jira-poll --target-forge gitlab have Jira as their source and are outside this scope.

The shared converter classifies bot actors but resolves every actor's actor.role through GitLab project membership. It does not carry ADR 0107's actor.bot_role or actor.role_verified in the GitLab dispatch event. Bot events that pass the existing GitLab filtering rules therefore still rely on project membership instead of exact registered bot identity. The GitLab path currently routes through dispatch.HarnessRouter, not the CEL dispatch adapter.

What should happen

Implement ADR 0107 bot authorization in the shared GitLab event path:

  • Resolve positively identified GitLab bots against a trusted, project-scoped registration of exact account identity to canonical role. Keep this registration in administrator-controlled installation state, not repository or event content.
  • Carry the lookup result in the GitLab dispatch event: bots retain actor.role: none and include actor.bot_role and actor.role_verified as appropriate.
  • Deny non-label bot events with a successful no-match or lookup failure before dispatch.EventRouter (currently HarnessRouter) and pipeline dispatch. Do not fall back to project-membership authorization for bots. Distinguish no-match from lookup failure; both deny.
  • Preserve the existing human permission mapping and the current bot-event loop filters. Registration must not admit every bot-authored comment or transition by itself.
  • Preserve label-added authorization only when GitLab provides the authoritative actor-to-transition evidence required by ADR 0107; otherwise use the ordinary authorization gate.
  • Cover both polling and webhook entry paths, including registered bots, unregistered bots, lookup failure, human controls, and the label case. Denied rows must prove no agent dispatch; positive controls must prove the harness ran.
  • Update the authorization and normalized-event documentation. If GitLab later moves to the CEL dispatch adapter, keep bot authorization ahead of CEL evaluation.

Context

This is a child of #8329 and implements the non-mint provider requirement in ADR 0107 for GitLab. GitLab role credential lifecycle work in #7496 is related but separate.

Sub-issues

Sub-issues

0 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. fullsend-ai-triage commented on Nov 3, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 7:24 AM UTC · Completed 7:26 AM UTC

    Commit: f6e35de · View workflow run →

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

  2. added
    feature
    triaged
    on Nov 3, 2026
  3. fullsend-ai-triage commented on Nov 3, 2026

    @fullsend-ai-triage

    Re-triage after the added implementation guidance. No open PR addresses this issue, and nothing new blocks it. The earlier findings still hold: the shared converter in internal/poll/convert.go resolves every actor through project membership, and the normalized-event schema already supports and validates bot_role / role_verified, so the poller is the missing producer.

    How the new guidance maps onto the code

    • The role registry and rotation variables are already defined (VarGitLabRoleRegistry, VarGitLabRoleRotation). The registry code is in internal/gitlabroles, while rotation state with ManagedUserID / SuppliedUserID lives in internal/repos. The implementation will likely need a small shared reader that turns these into an exact numeric-ID → role map, covering current and overlapping IDs during rotation.
    • Bot verification has to happen before bot_role is assigned, because a supplied credential can belong to a human. Bots stay at actor.role: none.
    • With analyst == review, events from the shared Analyst account (used by review, triage and retro) are treated as review.
    • Open design point for the implementer: the legacy project-access-token fallback needs its bot user ID persisted or resolved to a registered role. Where no canonical role is defined, treat the credential as ambiguous and deny.
    • Lookup failure (role_verified: false) must stay distinguishable from no-match (verified, empty bot_role). Both deny non-label dispatch before routing, with no membership fallback.
    • Existing bot-loop filters, human permission mapping and the label-added exception (only with authoritative actor-to-transition evidence) stay as they are.
    • This is a child of Implement ADR 0107 bot identity resolution before dispatch authorization #8329. Implement extensible GitLab role identity model with backward-compatible migration #7496 is related credential-lifecycle work and does not block it.

    Proposed test case

    For each of: registered bot (Analyst ID => review), bot during rotation (old/new IDs),
    unregistered bot who is a project member, human-owned supplied credential,
    legacy project-access-token bot, lookup failure, human writer,
    bot label with authoritative evidence, bot label without it:
      run through both polling and webhook paths
      assert actor.role / bot_role / role_verified match ADR 0107
      assert dispatch only for registered bots, human writer, evidenced label case
      denied rows assert zero agent dispatches; positive controls prove harness ran
    

    This issue is categorized as a feature, so it is not auto-promoted. A maintainer can start implementation with /fs-code.


    Next steps:

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

    Re-triage found no new blockers, and no open PR addresses this issue. The earlier triage findings still hold:

    • Code confirmation: the shared converter resolves every actor through project membership and produces only ID, kind and role. The normalized-event schema already supports and validates bot_role / role_verified, so the poller is the missing producer.
    • Design point: the existing GitLab roles package maps role names to credentials, not exact bot identity to role. The registration may need a small extension, and it must stay in administrator-controlled installation state.
    • Behavior to preserve: lookup failure must stay distinguishable from no-match, and both deny non-label dispatch before routing. Label-added authorization stays only where the actor is bound to the transition.
    • Related work: this is a child of Implement ADR 0107 bot identity resolution before dispatch authorization #8329. Implement extensible GitLab role identity model with backward-compatible migration #7496 is related credential-lifecycle work and is not blocking.

    Proposed test case:

    For each of: registered bot, unregistered bot (project member), lookup failure,
    human writer, bot label with authoritative evidence, bot label without it:
      run through both polling and webhook paths
      assert actor.role / bot_role / role_verified match ADR 0107
      assert dispatch only for registered bot, human writer, evidenced label case
      denied rows assert zero agent dispatches; positive controls prove harness ran
    

    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 notes (net-new context only):

    • Confirmed in code: internal/poll/convert.go resolves every actor, bot or human, via project membership (resolveActorRole) and builds the actor with only ID, kind and role. internal/normevent already defines and validates bot_role / role_verified (a set bot_role requires role_verified: true), so the poller is the missing producer.
    • Related work: this is a child of Implement ADR 0107 bot identity resolution before dispatch authorization #8329. Implement extensible GitLab role identity model with backward-compatible migration #7496 (GitLab role identity model) is open but is credential-lifecycle work; it is treated as related rather than blocking. No open PR currently addresses this issue.
    • Design point for the implementer: internal/gitlabroles today maps role names to credential references, not exact bot account identity to role. The trusted registration may need a small extension. It must stay administrator-controlled installation state (not .fullsend/config.yaml, harness files or MR content), per the existing registry trust rules.
    • Behavior to preserve: a lookup failure should be distinguishable from a no-match (role_verified: false vs true with empty bot_role), and both deny non-label dispatch before CEL. Label-added authorization stays only where the actor is bound to the label transition, which the webhook builder and poll label-event snapshot already do.

    Proposed test case:

    For each of: registered bot, unregistered bot (project member), lookup failure,
    human writer, bot label with authoritative evidence, bot label without it:
      run an event through poller normalization + dispatch gate
      assert actor.role / bot_role / role_verified match ADR 0107
      assert dispatch happens only for registered bot, human writer, and the
      evidenced label case
      denied rows assert zero agent dispatches; positive-control rows prove the
      harness executed
    

    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  4. fullsend-ai-triage commented on Nov 3, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 8:10 AM UTC · Completed 8:12 AM UTC

    Commit: 438c5de · View workflow run →

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

  5. added
    feature
    triaged
    and removed
    feature
    triaged
    on Nov 3, 2026
  6. ifireball commented on Nov 3, 2026

    @ifireball
    MemberAuthor

    /fs-triage Please make the implementation approach in this issue more concrete:

    • For this scope, assume the GitLab Analyst credential identity maps to the ADR 0107 bot role review.
    • Resolve a GitLab event actor by exact numeric user ID against trusted installation state. Reuse FULLSEND_GITLAB_ROLE_REGISTRY for role policy and FULLSEND_GITLAB_ROLE_ROTATION for account IDs (managed_user_id / supplied_user_id), including current and overlapping identities during rotation. Prefer this recorded mapping over runtime account enumeration.
    • Verify the actor is a bot or service account before assigning actor.bot_role. A supplied credential can belong to a human, so its owner ID alone must not grant bot authorization. Keep bots at actor.role: none; deny unknown bots and lookup failures without falling back to project-membership authorization.
    • The Analyst credential is currently shared by review, triage, and retro. Under the analyst == review assumption, treat those events as review; GitLab account identity alone cannot distinguish which agent acted.
    • Account for the legacy project-access-token fallback: persist or otherwise resolve its bot user ID to the registered credential role. Treat credential reuse as ambiguous unless there is a defined canonical role.
    • Retain coverage for both polling and webhook paths, existing bot-loop filters, human authorization, and the label-added exception.
  7. fullsend-ai-triage commented on Nov 3, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 9:37 AM UTC · Completed 9:39 AM UTC

    Commit: c7652ad · View workflow run →

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

  8. added
    feature
    triaged
    and removed
    feature
    triaged
    on Nov 3, 2026
  9. ifireball commented on Nov 3, 2026

    @ifireball
    MemberAuthor

    /fs-triage consider if this can be implemented in one agent run or should be split to sub issues

  10. fullsend-ai-triage commented on Nov 3, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 9:43 AM UTC · Completed 9:46 AM UTC

    Commit: c7652ad · View workflow run →

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

  11. removed
    feature
    on Nov 3, 2026
  12. self-assigned this
    on Nov 3, 2026
  13. removed
    triaged
    on Nov 3, 2026
  14. fullsend-ai-triage commented on Nov 3, 2026

    @fullsend-ai-triage

    This issue bundles three pieces of work that are too large for one agent run and span different areas of the code: install-time state, a trusted identity resolver, and the dispatch-path enforcement with its test matrix and docs. The implementation guidance from the earlier comments has been carried into the sub-issues.

    Sub-issues:

    • Legacy project-access-token bot identity: persist or resolve that bot's numeric user ID in administrator-controlled state (touches the internal/repos rotation state), and flag ambiguous credential reuse for denial.
    • Trusted actor-ID to role resolver: build the exact numeric-ID to role map from the role registry and rotation state, covering current and overlapping IDs during rotation. It verifies the actor is a bot, treats the Analyst identity as review, and distinguishes no-match from lookup failure. One open point is flagged for the implementer: confirming the poller and dispatcher jobs can read the rotation variable at runtime.
    • Poll and webhook enforcement: populate bot_role and role_verified in the shared converter, deny non-label bot events before routing with no membership fallback, keep the label-added exception and existing loop filters, run the full test matrix on both paths, and update docs. This depends on the other two.

    The first two are independent of each other and can proceed in parallel. This remains a child of the #8329 effort, and the related GitLab role credential lifecycle work does not block any of them. No open PR currently addresses this issue.

    Split into:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions