Skip to content

feat(#6042): support Prow OWNERS file authorization for slash commands - #6051

Merged
waynesun09 merged 21 commits into
fullsend-ai:mainfrom
RaphaelBut:feat/owners-file-authorization
Sep 23, 2026
Merged

waynesun09 merged 21 commits into
fullsend-ai:mainfrom
RaphaelBut:feat/owners-file-authorization

Conversation

@RaphaelBut

@RaphaelBut RaphaelBut commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds opt-in Prow OWNERS file authorization for slash command dispatch. Repos that use Prow/OWNERS instead of GitHub collaborator roles can add owners_file to the authorization providers list in .fullsend/config.yaml to let
OWNERS-listed users trigger fullsend agents without needing GitHub write/triage collaborator access. Approvers get write-equivalent access; reviewers get triage-equivalent only. OWNERS is checked first; if it authorizes the user,
the collaborator API is not consulted. If the user isn't in OWNERS, it falls through to the collaborator API.

authorization:
  - provider: owners_file

Changes

  • Provider-list config schema: authorization is a []AuthorizationProvider with validation for unknown/duplicate providers. Overlay-only — intentionally no base-layer fallback
  • OWNERS authorization path in has_repo_permission (reusable-dispatch.yml): opt-in gate via config, case-insensitive username matching (lc_user), direct + alias membership checks, ::notice:: audit logging, case guard with ;;&
    fallthrough mapping the role hierarchy
  • Checkout ref pin extended to pull_request_review events on all 9 checkout refs — PR authors cannot self-authorize on any path (base branch SHA for PR-scoped events, default-branch head otherwise)
  • Sparse-checkout anchoring: /OWNERS and /OWNERS_ALIASES anchored to repo root to avoid pulling nested per-directory OWNERS files on Prow-style repos
  • Scaffold parity: _owners_has_user and OWNERS auth block mirrored into internal/scaffold/fullsend-repo/.github/workflows/dispatch.yml
  • Harness dispatch wiring (core.go): owners.Resolve computes an effective role for the IsAuthorized gate without mutating the caller's event — downstream CEL evaluation sees the original collaborator-API role. OWNERS resolved via
    filepath.Dir(ConfigDir), not bare working-directory paths
  • Slot-health check: ValidateSlotClean runs before every behaviour scenario to catch stale config state (kill switch, OWNERS auth) from failed cleanups — prevents silent false positives in auth tests
  • Unit tests: Dispatch() integration tests for OWNERS role upgrade/denial/disabled, config round-trip tests, provider validation tests
  • E2E scenarios: outsider-driven issue-opened scenarios proving OWNERS approver/reviewer/alias paths, write-denial scenario proving reviewer cannot escalate, collaborator-fallthrough scenario, opt-out scenario
  • Documentation: ADR 0054 updated for harness dispatch scope, non-mutation semantics, v1 limitation, and checkout ref semantics; layered-config reference expanded with provider list, overlay-only behavior, fail-closed behavior;
    workflow contracts documents the OWNERS sync contract and parity test coverage

Known limitations

  • v1 OWNERS schema: only repo-root flat approvers/reviewers lists are read. Prow filters: blocks and nested per-directory OWNERS files are not supported
  • OWNERS-authorized users without GitHub collaborator write access use the fork PR path

Related

Testing

  • make lint passes (stage changes first, then run)
  • Tests added/updated for new or modified logic

Checklist

  • PR title follows Conventional Commits (correct type, ! for breaking changes)
  • Commits are signed off (DCO) — human and human-directed agent sessions only
  • I wrote this contribution myself and can explain all changes in it

@RaphaelBut
RaphaelBut requested a review from a team August 10, 2026 18:06
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

E2E tests are running

Authorization passed for this commit. See the E2E Tests workflow for results.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Support opt-in Prow OWNERS authorization for slash-command dispatch

✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Add opt-in OWNERS/OWNERS_ALIASES authorization for dispatch slash commands via
 authorization.owners_file.
• Grant approvers write-equivalent access and reviewers triage-equivalent, with audit notices.
• Add e2e scenarios, step definitions, and docs describing the new authorization backend.
Diagram

graph TD
  IC(["Issue comment / label"]) --> WD["Dispatch workflow"] --> AB{"Auth backend?"}
  AB -->|"owners_file=true"| OC["OWNERS check"] --> AL["Allow stage"]
  AB -->|"fallback"| GH{{"GitHub collaborator API"}} --> AL
  T["Godog e2e tests"] --> IC
  OC --> F1[/".fullsend/config.yaml"/] --> F2[/"OWNERS"/] --> F3[/"OWNERS_ALIASES"/]

  subgraph Legend
    direction LR
    _wf["Workflow/Test"] ~~~ _file[/"Repo file"/] ~~~ _ext{{"External"}} ~~~ _dec{"Decision"}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Implement OWNERS authorization as a Go helper invoked by the workflow
  • ➕ Typed parsing/validation of OWNERS and OWNERS_ALIASES with explicit errors
  • ➕ Unit-testable without relying on live GitHub Actions logs
  • ➕ Easier to evolve permission mapping and alias resolution safely
  • ➖ Requires CLI/build pipeline integration and caching changes
  • ➖ More moving parts for a first increment compared to inline bash/yq
2. Precompute authorization via a GitHub App/service and store results
  • ➕ Moves security logic out of bash and into a controlled runtime
  • ➕ Centralized policy with better observability and auditing
  • ➖ Introduces new infrastructure/service dependencies
  • ➖ More complex deployment and maintenance footprint
3. Rely on GitHub-native roles/teams instead of OWNERS
  • ➕ Simpler, already supported by existing collaborator API logic
  • ➕ Avoids parsing YAML files and alias semantics
  • ➖ Does not work for Prow-centric repos where OWNERS is the source of truth
  • ➖ May force repos to duplicate permission data in GitHub roles

Recommendation: The PR’s approach (opt-in OWNERS-file check with a safe fallback to the collaborator API) is a reasonable incremental step for Prow-based repos, especially given the base-SHA pinning and username/alias validation to reduce self-authorization and injection risk. If merged, it should be treated as a stepping stone: follow up by migrating the OWNERS parsing/decision logic into a Go helper with unit tests and explicit error handling, keeping the workflow as a thin caller.

Files changed (8) +459 / -1

Enhancement (1) +55 / -1
reusable-dispatch.ymlAdd opt-in OWNERS/alias authorization in has_repo_permission +55/-1

Add opt-in OWNERS/alias authorization in has_repo_permission

• Extends sparse-checkout to include OWNERS and OWNERS_ALIASES. Adds bash helpers to resolve direct and alias membership and gates the new authorization path behind 'authorization.owners_file' in '.fullsend/config.yaml', mapping approvers to write/triage and reviewers to triage only with audit notices.

.github/workflows/reusable-dispatch.yml

Tests (5) +365 / -0
owners-auth.featureAdd e2e feature scenarios for OWNERS authorization behavior +65/-0

Add e2e feature scenarios for OWNERS authorization behavior

• Introduces behaviour tests covering: approver authorization, alias resolution, reviewer triage grant, reviewer write denial, and opt-in gating. Asserts expected audit log messages in workflow/dispatch logs to confirm the OWNERS path is exercised.

e2e/behaviour/features/dispatch/owners-auth.feature

cleanup.goCleanup OWNERS auth artifacts after scenarios +5/-0

Cleanup OWNERS auth artifacts after scenarios

• Hooks scenario cleanup to remove/neutralize OWNERS auth test changes when activated. Ensures subsequent scenarios in the same repo slot are not impacted.

pkg/behaviourtest/steps/cleanup.go

owners.goAdd Godog step definitions to manage OWNERS/config and assert logs +289/-0

Add Godog step definitions to manage OWNERS/config and assert logs

• Adds steps to commit OWNERS and OWNERS_ALIASES fixtures, enable 'authorization.owners_file', post slash commands, and assert workflow/dispatch logs. Includes polling logic to find issue_comment-triggered dispatch runs and cleanup logic to revert config and clear OWNERS files.

pkg/behaviourtest/steps/owners.go

registry.goRegister OWNERS authorization step definitions +1/-0

Register OWNERS authorization step definitions

• Registers the new OWNERS-related Godog steps so the feature scenarios execute.

pkg/behaviourtest/steps/registry.go

world.goTrack OWNERS auth activation in test world state +5/-0

Track OWNERS auth activation in test world state

• Adds an 'OwnersAuthActivated' flag to the shared scenario state so cleanup can reliably revert OWNERS/config mutations.

pkg/behaviourtest/world/world.go

Documentation (2) +39 / -0
0054-require-authorization-on-all-agent-dispatch-paths.mdDocument OWNERS-file authorization extension in ADR 0054 +15/-0

Document OWNERS-file authorization extension in ADR 0054

• Amends ADR 0054 to describe the new opt-in OWNERS/OWNERS_ALIASES authorization backend, its permission mapping, and the base-SHA pinning rationale. Notes the scope limitation that harness agents are unaffected.

docs/ADRs/0054-require-authorization-on-all-agent-dispatch-paths.md

layered-config-reference.mdAdd 'authorization.owners_file' to layered config reference +24/-0

Add 'authorization.owners_file' to layered config reference

• Documents a new 'authorization' object and the 'owners_file' boolean flag, including an example configuration. Clarifies that this field is consumed by workflow bash/yq rather than the Go config package.

docs/guides/infrastructure/layered-config-reference.md

@qodo-code-review

qodo-code-review Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Guide file in infrastructure/ ✗ Dismissed 📜 Skill insight ⌂ Architecture
Description
A modified guide lives at docs/guides/infrastructure/... instead of being placed under either
docs/guides/admin/ or docs/guides/user/, which violates the required guides directory structure.
This makes the guide set inconsistent and harder to navigate/enforce uniformly.
Code

docs/guides/infrastructure/layered-config-reference.md[82]

+| `authorization` | `object` | Replace whole object if set | `nil` |
Relevance

●● Moderate

Infrastructure guides have been modified/accepted before; unclear if admin/user-only structure is
enforced.

PR-#5763

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1062077 requires guide files under docs/guides/ to be placed in either the
admin/ or user/ subdirectory. This PR modifies
docs/guides/infrastructure/layered-config-reference.md, which is neither, so it violates the
directory requirement.

docs/guides/infrastructure/layered-config-reference.md[1-15]
Skill: writing-user-docs

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docs/guides/infrastructure/layered-config-reference.md` is a documentation guide but it is not located under either `docs/guides/admin/` or `docs/guides/user/`, which is required.

## Issue Context
This PR modifies the guide, so its placement is in-scope for compliance.

## Fix Focus Areas
- docs/guides/infrastructure/layered-config-reference.md[1-20]
- docs/guides/admin/layered-config-reference.md[1-20]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. owners.go lacks unit tests ✗ Dismissed 📘 Rule violation ▣ Testability
Description
New Go logic was added in pkg/behaviourtest/steps/owners.go without adding or updating any
corresponding _test.go coverage for the new behaviors. This increases regression risk for the
OWNERS auth behaviour-test helpers.
Code

pkg/behaviourtest/steps/owners.go[R119-122]

+func givenOwnersAuthEnabled(w *world.World) error {
+	cfgPath := ".fullsend/config.yaml"
+	cfgData, err := w.SCM.GetFileContent(context.Background(),
+		w.Install.ConfigOwner(), w.Install.ConfigRepo(), cfgPath)
Relevance

●●● Strong

Repo often accepts adding/updating tests to cover new Go behavior and meet coverage expectations.

PR-#5225

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1062049 requires that new or modified Go logic be accompanied by tests updated in
the same change. This PR adds substantial new logic in pkg/behaviourtest/steps/owners.go but does
not add/modify any _test.go files for these new behaviors.

Rule 1062049: Require tests for new or modified Go logic
pkg/behaviourtest/steps/owners.go[1-140]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New non-test Go logic was added in `pkg/behaviourtest/steps/owners.go` without adding/updating unit tests that exercise it.

## Issue Context
The compliance rule requires tests for new or modified Go logic (typically via `_test.go` files updated in the same change).

## Fix Focus Areas
- pkg/behaviourtest/steps/owners.go[119-205]
- pkg/behaviourtest/steps/owners_test.go[1-200]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Scaffold dispatch missing OWNERS ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The new OWNERS-file authorization logic was added to .github/workflows/reusable-dispatch.yml but
not mirrored into the scaffolded internal/scaffold/fullsend-repo/.github/workflows/dispatch.yml,
creating divergent stage-routing/authorization behavior. This violates the requirement to keep
dispatch workflow routing logic in sync.
Code

.github/workflows/reusable-dispatch.yml[R160-163]

+            # OWNERS-file authorization (opt-in via authorization.owners_file in config.yaml).
+            # Approvers get write-equivalent access; reviewers get triage-equivalent.
+            # Safe: sparse-checkout pins to base branch SHA, so PR authors cannot
+            # self-authorize by adding themselves to OWNERS.
Relevance

●●● Strong

Team has accepted keeping reusable+scaffold dispatch logic in sync via mirrored changes.

PR-#1688

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1062045 requires dispatch workflow stage routing and related logic to be kept in
sync between the scaffold dispatch workflow and the reusable dispatch workflow. The reusable
workflow now implements OWNERS-file authorization, while the scaffold workflow’s corresponding
has_repo_permission implementation lacks that logic, so they diverge.

Rule 1062045: Keep jq payload, stage routing, and secret threading logic in dispatch workflows in sync
.github/workflows/reusable-dispatch.yml[131-186]
internal/scaffold/fullsend-repo/.github/workflows/dispatch.yml[58-90]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Dispatch stage-routing/authorization logic is now inconsistent between `.github/workflows/reusable-dispatch.yml` and the scaffold workflow `internal/scaffold/fullsend-repo/.github/workflows/dispatch.yml`.

## Issue Context
This PR adds an opt-in OWNERS-file auth path (and sparse-checkout of `OWNERS` files) in the reusable workflow, but the scaffold workflow’s `has_repo_permission` still only uses the collaborator API.

## Fix Focus Areas
- .github/workflows/reusable-dispatch.yml[131-186]
- internal/scaffold/fullsend-repo/.github/workflows/dispatch.yml[58-90]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Aliases cleanup flag missing ✓ Resolved 🐞 Bug ☼ Reliability
Description
givenOwnersAliasesFile commits OWNERS_ALIASES but never sets w.OwnersAuthActivated, so using
that step without an OWNERS/config step can skip cleanupOwnersAuth and leave repo state modified
for later scenarios.
Code

pkg/behaviourtest/steps/owners.go[R93-96]

+		[]byte(aliases)); err != nil {
+		return fmt.Errorf("committing OWNERS_ALIASES file: %w", err)
+	}
+	return nil
Relevance

●●● Strong

They’ve accepted ensuring cleanup triggers are set when repo state is mutated to avoid leaks.

PR-#5309

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The alias step commits OWNERS_ALIASES but returns without setting the cleanup flag, while
CleanupScenario only runs OWNERS cleanup when OwnersAuthActivated is true.

pkg/behaviourtest/steps/owners.go[80-97]
pkg/behaviourtest/steps/cleanup.go[90-93]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`givenOwnersAliasesFile` mutates the repo by committing `OWNERS_ALIASES`, but it does not set `w.OwnersAuthActivated = true`. Cleanup is gated on that flag, so this step is not self-contained and can leave the repository dirty if used alone or reordered.

### Issue Context
Cleanup for OWNERS auth runs only when `w.OwnersAuthActivated` is true.

### Fix Focus Areas
- pkg/behaviourtest/steps/owners.go[80-97]
- pkg/behaviourtest/steps/cleanup.go[90-93]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (1)
5. OWNERS flag not reset ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
OwnersAuthActivated is scenario state that gates repo-mutating cleanup, but resetScenarioWorld
does not clear it; this makes cleanup behavior depend on template/cloned state and risks stale-state
test flakiness if the template ever becomes non-zero.
Code

pkg/behaviourtest/steps/cleanup.go[R90-93]

+	// --- OWNERS auth cleanup ---
+	if w.OwnersAuthActivated {
+		cleanupOwnersAuth(w)
+	}
Relevance

●●● Strong

Resetting scenario/world fields to prevent stale-state flakiness matches previously accepted fixes.

PR-#4901

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
CleanupScenario newly uses OwnersAuthActivated to decide whether to run cleanupOwnersAuth.
World.Clone() copies scenario fields verbatim and resetScenarioWorld is responsible for clearing
scenario state, but it does not reset this new field (unlike similar flags such as
KillSwitchActivated). This matches a previously-accepted stale-state failure pattern in the
behaviour suite.

pkg/behaviourtest/steps/cleanup.go[90-93]
pkg/behaviourtest/world/world.go[83-100]
pkg/behaviourtest/suite/init.go[81-103]
PR-#4901

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
A new scenario-level boolean (`OwnersAuthActivated`) controls whether cleanup commits repo changes. The suite’s standard scenario reset helper should clear all scenario fields, but it currently does not clear this new flag.

### Issue Context
`World.Clone()` is a shallow copy; scenario fields are copied verbatim and are expected to be zeroed by `resetScenarioWorld`.

### Fix Focus Areas
- pkg/behaviourtest/suite/init.go[81-103]
- pkg/behaviourtest/world/world.go[83-100]
- pkg/behaviourtest/steps/cleanup.go[90-93]
- pkg/behaviourtest/suite/init_test.go[79-104]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 54 rules

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Finding overflow, which tucks the rest behind 'View more'

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread .github/workflows/reusable-dispatch.yml Resolved
Comment thread pkg/behaviourtest/steps/owners.go Resolved
Comment thread pkg/behaviourtest/steps/owners.go Resolved
Comment thread pkg/behaviourtest/steps/cleanup.go Resolved
@ralphbean ralphbean self-assigned this Aug 10, 2026
@ralphbean

Copy link
Copy Markdown
Member

Adding more bash is always technical debt (we're on a journey to move much of it into the go binary), but - that said, the cli entrypoint you'd need to use here (imagine - a new fullsend authz check-permission ... command) doesn't exist yet, and adding one significantly expands the scope of this PR. Notably, we'd need to reason about how that should work in the presence of a NormalizedEvent coming from JIRA, rather than from a GH issue or PR.

I think we should file a backlog issue to centralize that in a new subcommand and replace this - meaning that, I think I'm ok with moving forwards with adding more bash here for now. I'd love to hear from others in @fullsend-ai/core before moving forwards though.

@waynesun09 waynesun09 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.

Multi-model review (Claude ×2 + Grok, with maintainer verification). Review-only — no approve/request-changes action. Posting the unique MEDIUM-and-above findings inline; qodo's #4 (givenOwnersAliasesFile missing OwnersAuthActivated) and #5 (resetScenarioWorld doesn't reset it) are confirmed and deepened — a stale/true flag makes later scenarios commit empty OWNERS files to their leased slot — so they're not re-posted here. qodo #1 (guide placement) is a false positive: there is no docs/guides/admin/ and the file pre-dates this PR.

The gate itself is sound

The has_repo_permission / _owners_has_user bash was traced by all three reviewers and executed against yq v4 with injection probes: username (^[a-zA-Z0-9-]+$) and alias-entry (^[a-zA-Z0-9_-]+$) are validated before any yq interpolation, key is always a literal, it fails closed on every malformed input, and the ;;& fallthrough correctly gives approvers write+triage while reviewers can never reach write. The inline-bash choice is not itself a defect — @RaphaelBut, your instinct to ask was right, and the answer is that the logic is safe as written.

Must-fix before merge

  • H1 — the pull_request_review checkout ref makes the "cannot self-authorize" invariant false on that path (workflow-level; not fixed by any refactor). One-line pin fix inline.
  • H2 — the OWNERS-auth e2e scenarios exercise the auth path in zero cases and have never run on this fork PR. Inline.
  • M1 — case-sensitive matching silently denies the non-collaborator Prow users this feature targets. Inline.

Direction — bash vs. Go package vs. CEL

This is the real decision, and it needs a core-team call (see @ifireball below). Summary of the analysis:

  • CEL is not reachable for this feature yet. CEL authorization runs host-side in Go, but only in the harness-dispatch job for custom agents, and its env exposes only event (no OWNERS data / API). The built-in stages this PR targets (triage/code/fix/review) are routed by the bash Route job, which is checkout + one bash step and has no fullsend binary. Routing OWNERS auth through CEL would first require migrating built-in stages onto harness-dispatch — the "default agents not on CEL" gap.
  • The Go package is the right home for the logic (parsing, alias resolution, actor→role, policy): typed, unit-testable, and it makes M1 and the M5/typo gap correct by construction. Its durable consumer is the IsAuthorized / normalized-event layer that already runs Go — after the built-in-stages migration.
  • But wiring a fullsend owners-check subcommand into the Route job now would add a binary install/build step to the highest-frequency path (every comment/label/review across all repos), and it's throwaway once the migration lands — the exact cost @RaphaelBut flagged in the PR description.

Recommended sequencing: land this as the reviewed bash interim after H1 + H2 + M1; extract internal/owners/ (logic + tests) as the immediate follow-up so the resolver exists and is reusable; let the built-in-stages→harness-dispatch/CEL migration — not this PR — be what moves the call site into Go. That path fixes the review's real concerns without gating a first contribution behind a core dispatch-path migration.

@ifireball — flagging you as fullsend core / CEL owner

The substantive open question here isn't the bash correctness (verified) but the direction above: whether OWNERS authorization should be built toward the CEL / harness-dispatch authorization path — and whether/when built-in stages migrate onto it — or ship as the interim bash gate and be revisited during that migration. That's your call as CEL feature owner; the recommendation above is a proposal, not a decision. H1 (the security-invariant/checkout-ref fix) also warrants a core-team eye since it touches the dispatch trust boundary.

Comment thread .github/workflows/reusable-dispatch.yml Resolved
Comment thread .github/workflows/reusable-dispatch.yml Resolved
Comment thread pkg/behaviourtest/steps/owners.go Resolved

@ralphbean ralphbean 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.

A few notes inline, and replies on a couple of the existing qodo comments. Filed #6072 to track the bash→Go follow-up from the PR description and my earlier comment.

Comment thread pkg/behaviourtest/steps/owners.go Resolved
Comment thread pkg/behaviourtest/steps/owners.go Resolved
@RaphaelBut
RaphaelBut force-pushed the feat/owners-file-authorization branch from 7621199 to 4c93fe3 Compare August 11, 2026 11:58
@RaphaelBut

Copy link
Copy Markdown
Contributor Author

Thanks @waynesun09 and @ralphbean for the thorough review!
I tried to address all the feedback and rebased onto current main to resolve the conflicts.

Highlights beyond what's visible in the diff:

  • Removed the write-denial E2E scenario (was scenario 4). It was vacuous — the bot's COMMENT_USER_TYPE is "Bot" which short-circuits before auth, and the bot has collaborator access so the API fallback always grants. The
    ;;& security invariant (reviewer can't escalate to write) is now covered by string assertions in TestDispatchPerStageAuthorization against both workflow files instead.

  • Went further than yaml.Node on M4 — rather than the bespoke tree walker I originally had, added AuthorizationConfig and SetAuthorizationOwnersFile(bool) to the config package. givenOwnersAuthEnabled and
    cleanupOwnersAuth now follow the exact SetKillSwitch pattern from dispatch.go. This also makes cleanup idempotent and parse-based as requested.

  • M6 (clock skew buffer) resolved structurally — waitForDispatchRunAnyConclusion no longer exists since the scenarios now trigger via issues.opened and use ensureTriageWorkflowComplete, which already handles retries
    with issueOpenDrainSkewBuffer.

  • lc_user instead of mutating username — the lowercased form is used only for OWNERS matching, so the API fallback and ::notice:: logs preserve the original casing.

@waynesun09 waynesun09 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.

Review-only sweep — no approve/request-changes action taken. Posting one additional finding not already covered by existing review threads; the OWNERS-auth CI-coverage gap I'd flagged is already tracked in more depth by the existing HIGH comment on e2e/behaviour/features/dispatch/owners-auth.feature (skipped as a substantive duplicate).

Comment thread internal/config/interfaces.go Resolved
@RaphaelBut

Copy link
Copy Markdown
Contributor Author

im working on the OWNERS-auth CI-coverage gap

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://014006ed-site.fullsend-ai.workers.dev

Commit: 406063df2d72c9e85cf83d5368b790f16a08500f

@codecov

codecov Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.69767% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/forge/fake.go 0.00% 9 Missing ⚠️
internal/harnessdispatch/core.go 78.57% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@waynesun09 waynesun09 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.

Approving. Re-reviewed at 62efb214: H1 (pull_request_review checkout ref) is fixed in both workflow files, and M1/M3/M4/M5 plus the config-setter finding are all resolved — with scaffold parity and unit tests added on top.

I also verified the OWNERS grant/deny logic executes correctly against the shipped bash locally: approver→write, reviewer→triage-only (no escalation), alias resolution, case-insensitive matching, and injection blocked. The ;;& privilege boundary is now pinned by a running test across both workflow files.

Only remaining item is live behaviour/e2e coverage, which is fail-closed and non-blocking — fine as a follow-up alongside the CI-coverage work you're already on. Nice work for a first contribution.

@ifireball ifireball 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.

Needs to add an implementation of this to the custom agent dispatch path as well (inside the Go binary)

To @waynesun09 about wither CEL expressions should come into play - wither the hard-wired auth will be replaced by the expressions is an open question (has to do with wither we ever want to allow agent use by less privileged actors). I do not think it is in scope for this.

Comment thread pkg/behaviourtest/steps/owners.go Resolved
Comment thread internal/config/config.go Resolved
@RaphaelBut

Copy link
Copy Markdown
Contributor Author

Thank you so much for all of your reviews <3

Pushed 659e568 to adress review comments and add a denial test, although I am not quite sure if we should go a bit further still with adding more tests around this.

  • Harness dispatch wiring: OWNERS resolution in harnessdispatch.Dispatch so custom agents get the same authorization as built-in stages. harness-dispatch checkout ref pinned to base SHA for pull_request_review events (same gap as H1, introduced when wiring OWNERS into the Go path). Added TestOwnersCheckoutRefPin to prevent recurrence.
  • E2E denial test: outsider-driven scenario proving OWNERS reviewer cannot escalate to write — uses fstest-outsider, ActorLogin filtering, dual assertion (no OWNERS grant + no stage matched)

If you decide this PR is far enough to let the CI run, we can take a look at how my tests break :D
Thank you all anyway!

@ralphbean ralphbean added the ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) label Aug 12, 2026

@waynesun09 waynesun09 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.

Review-only sweep (multi-agent, verified against the live PR head and CI). No approve/request-changes action taken. Findings below are all newly introduced or newly-relevant as of the final commit (659e568c) and were checked for overlap with existing review threads before posting; the write-denial CI failure was reproduced live against the exact head SHA.

Comment thread internal/harnessdispatch/core.go Resolved
Comment thread .github/workflows/reusable-dispatch.yml Resolved
Comment thread internal/owners/owners.go Resolved
Comment thread pkg/behaviourtest/steps/owners.go Resolved
Comment thread internal/config/interfaces.go Resolved
@waynesun09

Copy link
Copy Markdown
Member

@RaphaelBut rebase is needed to resolve conflicts

@ralphbean ralphbean 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.

Nice work carrying this through so many rounds of review — the OWNERS/alias resolution logic and the new Go package are solid, and the earlier H1/H2/M1 findings all look genuinely fixed.

One thing I noticed poking around outside the diff: route and harness-dispatch now pin their config checkout to the base SHA for pull_request_review events, but fix (and triage/code/review/retro/prioritize/harness-run) still only pin for pull_request_target. fix is the one stage pull_request_review actually dispatches, so its kill-switch/config checks can still read from the PR head there. It's not part of this diff so I can't point at a line directly, but it'd be worth fixing.

A couple more notes inline.

Comment thread internal/harnessdispatch/core.go Resolved
@RaphaelBut
RaphaelBut force-pushed the feat/owners-file-authorization branch from 659e568 to 75cb622 Compare August 13, 2026 16:57
@github-actions github-actions Bot removed the ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) label Aug 13, 2026
@RaphaelBut

Copy link
Copy Markdown
Contributor Author

Thanks again! Rebased on main and addressed all review comments in a single commit. I humbly request another CI run :D

Summary of changes:

Security fixes:

  • Pin all 9 checkout refs for pull_request_review events to base SHA (pre-existing gap, not introduced by this PR)
  • Anchor sparse-checkout patterns to /OWNERS and /OWNERS_ALIASES to avoid pulling nested OWNERS files on Prow-style repos

Test hardening:

  • Switch scenarios 1-3 from the bot to the outsider identity -- authorization now succeeds only through OWNERS, not the collaborator API fallback
  • Add a collaborator-fallthrough scenario (unlisted collaborator authorized via API)
  • Rewrite the denial test to use WaitForWorkflow with the standard retry pattern (was a custom polling loop with a 30s upfront buffer that could match stale runs)
  • Parameterize step definitions by actor (bot|outsider) per ifireball's feedback
  • Avoid mutating the caller's event in Dispatch() -- OWNERS role upgrade is used only for the IsAuthorized gate, not leaked to downstream CEL

Code:

  • Resolve OWNERS via filepath.Dir(ConfigDir) instead of bare working-directory paths
  • Add Dispatch() integration tests for OWNERS role upgrade (per ralphbean)
  • Add AuthorizationOwnersFile no-parent-fallback unit test (per waynesun09)

Docs:

  • ADR 0054: fix stale "harness agents are unaffected" claim
  • Layered config reference: fix footnote, expand authorization section with OWNERS_ALIASES, fail-closed behavior, v1 limitation
  • Workflow contracts: add OWNERS authorization paragraph

Deferred: Provider-list config schema tracked in #6072.

@waynesun09 waynesun09 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.

Review-only pass (no approve/request-changes action) — one additional MEDIUM finding not covered by the existing threads on this PR.

Comment thread internal/forge/forge.go Resolved

@waynesun09 waynesun09 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.

Review-only pass (no approve/request-changes action taken) — 2 findings not covered by existing threads on this PR.

Comment thread docs/contributing/workflow-contracts.md Resolved
Comment thread internal/harnessdispatch/core.go Resolved
@ralphbean ralphbean added the ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) label Aug 17, 2026
@waynesun09

Copy link
Copy Markdown
Member

/fs-review

@waynesun09
waynesun09 dismissed fullsend-ai-review[bot]’s stale review September 22, 2026 23:34

Both Medium findings on cb6202a are fixed in ff2132e: ValidateSlotClean now runs after the repo is leased, and the opt-out scenario uses the outsider and asserts no triage artifact. The remaining Medium is the standard protected-path notice; the Low (interface placement) is answered in its thread.

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:35 PM UTC · Completed 11:56 PM UTC

Commit: ff2132e · View workflow run →

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

fullsend-ai-review[bot]

This comment was marked as outdated.

A login equal to a nested alias key still matched: with
`team-b: [team-a, carol]`, a GitHub user named team-a was treated as a
member of team-b and got its role. Both the Go resolver and the bash
matcher now return no match for any login that equals an
OWNERS_ALIASES key, wherever the key appears. Nested aliases are not
expanded, as before.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
…nterfaces

OWNERS-file authorization is per-repo only, so move the accessor and
setter from the shared ConfigReader/ConfigWriter to
PerRepoConfigReader/PerRepoConfigWriter and drop the orgConfig stubs.
Rename them to IsOwnersFileAuthEnabled/SetOwnersFileAuthEnabled to
match the package's predicate names. ParsePerRepoConfigWriter now
returns PerRepoConfigWriter; existing callers are unaffected.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
@github-actions github-actions Bot removed the ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) label Sep 23, 2026
@waynesun09 waynesun09 added the ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) label Sep 23, 2026
@waynesun09

Copy link
Copy Markdown
Member

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:05 AM UTC · Completed 12:29 AM UTC

Commit: 3556722 · View workflow run →

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

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See the review comment for full details.

Comment thread docs/reference/config-reference.md Resolved
…pplies

The Go harness-dispatch path admits write-level roles only, so an
OWNERS reviewer's triage-level grant covers /fs-triage and /fs-review
but not custom agents. Say so in the config reference and the layered
config reference instead of implying both paths behave the same.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
@github-actions github-actions Bot removed the ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) label Sep 23, 2026
@waynesun09 waynesun09 added the ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) label Sep 23, 2026
@waynesun09
waynesun09 dismissed fullsend-ai-review[bot]’s stale review September 23, 2026 00:33

No High findings on 3556722. The documentation-coherence Medium is fixed in f416a91 (doc-only); the remaining Medium is the standard protected-path human-approval notice.

@waynesun09
waynesun09 added this pull request to the merge queue Sep 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 23, 2026
…gates

The merge queue's behaviour run failed one scenario because the
collaborator API answered 404 for halfsend-03/test-repo-10 right after
the repo was recreated; a later ensure of the same repo granted it
without error. Retry AddCollaborator on 404 with exponential backoff
(six attempts, about 30 seconds) before failing the allocation.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>

This branch was successfully deployed

1 active and 1 inactive deployments
site-preview — 406063df Deployed Sep 23, 2026 by github-actions[bot]
dev — 406063df Deployed Sep 23, 2026 by waynesun09 via run / behaviour #3086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/dispatch Workflow dispatch and triggers fullsend-no-fix Skip bot-triggered fix agent runs ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) risk/elevated PR risk: elevated security Security threat model and related concerns

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Prow/OWNERS file permission model for slash command authorization

5 participants