Skip to content

feat: add FULLSEND_PER_REPO_INSTALL guard variable - #967

Merged
waynesun09 merged 7 commits into
mainfrom
per-repo-install-guard
May 14, 2026
Merged

waynesun09 merged 7 commits into
mainfrom
per-repo-install-guard

Conversation

@waynesun09

Copy link
Copy Markdown
Member

Summary

  • Adds FULLSEND_PER_REPO_INSTALL repo variable as a guard to prevent per-org enrollment from overriding per-repo installations
  • Per-repo install (fullsend admin install <owner/repo>) sets the guard to true
  • Per-org enrollment (interactive CLI + reconcile-repos.sh) checks the guard and skips repos with active per-repo installation
  • Adds GetRepoVariable to forge.Client interface for reading variable values (not just existence)

Three-state guard logic

Guard value Per-org behavior Per-repo behavior
true Skip enrollment Log "updating installation", proceed
false Prompt user to confirm Log "re-enabling", proceed
not found Normal enrollment Log "new installation", proceed

Changes

  1. internal/forge/forge.go — add GetRepoVariable(ctx, owner, repo, name) (string, bool, error) to Client interface
  2. internal/forge/github/github.go — implement GetRepoVariable using Actions variables API
  3. internal/forge/fake.go — add VariableValues map + GetRepoVariable to FakeClient
  4. internal/cli/admin.go — set guard in per-repo install, filter per-repo repos in per-org enrollment with interactive prompt
  5. internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh — skip repos with FULLSEND_PER_REPO_INSTALL=true (both enrollment and shim updates, since per-repo uses a different shim template)
  6. internal/layers/enrollment.go — detect guard in Analyze, report as "per-repo install, skipped"
  7. internal/layers/enrollment_test.go — 3 new tests for guard skip, mixed mode, and error propagation

Test plan

  • go test ./internal/layers/ -run TestEnrollment -v — 18/18 pass
  • go test ./internal/... — all 19 packages pass
  • go vet ./internal/... — clean
  • Manual: set FULLSEND_PER_REPO_INSTALL=true on a test repo, run reconcile-repos.sh, confirm skip
  • Manual: run fullsend admin install <org> with a per-repo repo present, confirm skip message

Prevent per-org enrollment from overriding per-repo installations.
Per-repo install sets FULLSEND_PER_REPO_INSTALL=true as a repo variable;
per-org enrollment (both CLI and reconcile-repos.sh) checks it and skips
repos with the guard active.

Three-state logic:
- true: per-repo active, skip enrollment
- false: admin cleared guard, confirm before enrolling (interactive)
- not found: normal enrollment

Add GetRepoVariable to forge.Client for reading variable values.

Signed-off-by: Wayne Sun <gsun@redhat.com>
@github-actions

Copy link
Copy Markdown

fullsend review is working on this — view logs

@github-actions

github-actions Bot commented May 14, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://60c4d1ce-site.fullsend-ai.workers.dev

Commit: de5877f49132166d35e2bc9c4c8d5bf5c5f220ef

@fullsend-ai-review

fullsend-ai-review Bot commented May 14, 2026 •

Copy link
Copy Markdown

Review: #967

Head SHA: de5877f
Timestamp: 2026-05-14T00:00:00Z
Outcome: request-changes

Summary

The Go code for the guard variable feature is well-structured — the interface extension, fake client, enrollment layer, CLI integration, and tests are all solid. However, the shell script's check_per_repo_guard function has a critical bug in its 404 detection logic that would cause all repos without the guard variable to be skipped during enrollment and unenrollment, effectively breaking reconcile-repos.sh for any org that hasn't explicitly set the variable on every repo.

Findings

Critical

  • [Correctness] internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh:83-93 — check_per_repo_guard detects 404 (variable-not-found) by checking .status == "404" in the JSON response body. The GitHub REST API's 404 response for the Actions variables endpoint returns {"message":"Not Found","documentation_url":"..."} — there is no .status field. This means the jq -e '.status == "404"' check always evaluates to false, causing the function to fall through to the "Non-404 error" branch and return 0 (skip). Every repo without FULLSEND_PER_REPO_INSTALL set will be silently skipped — blocking all normal enrollment and unenrollment.
    Remediation: Replace the .status == "404" check with a reliable 404 detection. Options: (1) check $resp for "message":"Not Found" via jq -e '.message == "Not Found"', (2) use the gh api exit code (exit code 4 for HTTP 4xx in newer gh versions), or (3) use gh api --jq ... 2>&1 and parse the HTTP status from stderr. The most robust option is to check .message == "Not Found" since it matches the documented GitHub API 404 response format.

Medium

  • [Platform security] docs/guides/admin/installation.md:182-197 — The WIF attribute condition change from assertion.repository == '$ORG_NAME/.fullsend' to assertion.repository_owner == '$ORG_NAME' broadens the WIF trust boundary from a single config repo to all repositories in the org. While the PR adds a warning and documents the tighter alternative, the default guidance now leads users to the broader configuration. Consider making the per-org-only (tighter) condition the default in the guide and presenting the broader condition as an opt-in for orgs using per-repo mode.

  • [Correctness] internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh:80-82 — The safe_var sanitization strips only \n and \r but does not sanitize characters that could inject into GitHub Actions ::notice:: workflow commands (e.g., %0A or %0D URL-encoded sequences, or :: delimiters). A malicious variable value could inject annotation parameters. Low exploitability since setting the variable requires repo write access, but defense-in-depth suggests sanitizing :: and % as well.

Low

  • [Style/conventions] internal/layers/enrollment.go:195-204 — The checkGuard closure declares err error as a return value but always returns nil. The callers use skip, _ := checkGuard(repo) discarding the always-nil error. Simplify the signature to func(repo string) bool to match actual behavior.

Info

  • [Correctness] The PR test plan shows manual tests as unchecked ([ ]). The shell script bug above would be caught by the manual reconcile-repos.sh test — recommend completing manual testing before merge.

  • [Intent alignment] No linked issue. The feature is well-scoped to the per-repo guard mechanism described in ADR-0033, and the three enforcement points (CLI, reconcile script, Analyze) provide defense-in-depth.

Footer

Outcome: request-changes
This review applies to SHA de5877f49132166d35e2bc9c4c8d5bf5c5f220ef. Any push to the PR head clears this review and requires a new evaluation.

Previous run

Review: #967

Head SHA: dd66120
Timestamp: 2026-05-14T00:00:00Z
Outcome: approve

Summary

This PR adds a well-designed guard mechanism (FULLSEND_PER_REPO_INSTALL repo variable) to prevent per-org enrollment from overriding per-repo installations. The implementation is consistent across all three enforcement points (CLI, reconcile-repos.sh, enrollment Analyze), uses correct fail-closed behavior on errors, and includes thorough test coverage. The WIF trust boundary change in installation docs is appropriately documented with a prominent security warning. No critical or high findings.

Findings

Medium

None

Low

  • [Correctness] internal/layers/enrollment.go:193 — The checkGuard closure returns (skip bool, err error) but error is always nil and all callers discard it with _. The error return is dead code.
    Remediation: Simplify to func(repo string) bool or document intent for future use.

Info

  • [Style] internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh:87 — The safe_var sanitization strips `

but not GitHub Actions annotation control sequences (e.g.,%0A). Risk is negligible since the variable is admin-controlled, but tr -cd '[:print:]'` would be more thorough.

  • [Platform security] docs/guides/admin/installation.md:184 — The WIF attribute condition broadens from assertion.repository == '$ORG_NAME/.fullsend' to assertion.repository_owner == '$ORG_NAME', granting WIF access to all org repos. This is required for per-repo mode and is clearly documented with a warning admonition and a fallback recommendation for per-org-only setups. No action needed — noting for awareness.

Footer

Outcome: approve
This review applies to SHA dd66120656ec532876718e3b67e1f9aee4b05b16. Any push to the PR head clears this review and requires a new evaluation.

Previous run (2)

Review: #967

Head SHA: bb9cfdb
Timestamp: 2026-05-14T00:00:00Z
Outcome: request-changes

Summary

The guard variable mechanism is well-designed with proper fail-closed semantics in Go code, good test coverage, and clean three-state logic. However, the check_per_repo_guard() function in reconcile-repos.sh has a broken 404 detection path that would cause it to skip enrollment/unenrollment for all repos that don't have the guard variable set — effectively breaking the core reconciliation flow for normal repos. Additionally, the WIF attribute condition change in the installation guide widens GCP access from a single repo to all org repos, which is a significant security relaxation that warrants more prominent documentation.

Findings

High

  • [Correctness] internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh:85-97 — The 404 detection in check_per_repo_guard() uses jq -e '.status == "404"' to identify when the guard variable doesn't exist. GitHub's REST API 404 responses return {"message": "Not Found", "documentation_url": "..."} — there is no .status field. This means the jq check always evaluates to false for 404s, causing the function to fall through to the "Non-404 error" branch and return 0 (skip). Every repo without FULLSEND_PER_REPO_INSTALL set would be incorrectly skipped from both enrollment and unenrollment, breaking the normal reconciliation flow.

    Remediation: Replace the .status == "404" check with a .message == "Not Found" check, or better yet, restructure to use gh api --silent with exit code inspection. Alternatively, pass --jq '.value' to gh api directly and branch on exit code + empty output to distinguish 404 from other errors. For example:

    var=$(gh api "repos/$ORG/$repo/actions/variables/$PER_REPO_GUARD_VAR" --jq '.value' 2>/dev/null) && rc=0 || rc=$?
    if [[ $rc -ne 0 && -z "$var" ]]; then
      # Could be 404 or real error — check more specifically or just return 1 (proceed)
    fi

    A reliable approach: use --include to capture HTTP status, or capture stderr which gh api writes the status to.

Medium

  • [Platform security] docs/guides/admin/installation.md:184,192 — The WIF attribute condition was changed from assertion.repository == '$ORG_NAME/.fullsend' (single-repo scope) to assertion.repository_owner == '$ORG_NAME' (org-wide scope). This grants every repo in the org the ability to authenticate to GCP via WIF and obtain roles/aiplatform.user permissions. While a security note was added, this is a significant privilege escalation from the previous guidance. The auto-provisioning path uses BuildRepoProviderID to create per-repo WIF providers, creating a discrepancy between manual and automated setup — manual setup is now much broader.

    Remediation: Consider keeping the manual guide scoped to specific repos (e.g., .fullsend + any per-repo repos) and providing the org-wide condition as an explicit opt-in alternative. At minimum, elevate the security note to a warning/caution callout and mention the discrepancy with auto-provisioned per-repo providers.

  • [Correctness] internal/layers/enrollment.go:190-210 — The guard-check error handling changes the previous behavior: GetFileContent errors (non-ErrNotFound) previously returned an error from Analyze, halting analysis. Now, GetRepoVariable errors are soft-failed into guardFailed and the repo is silently skipped. If the token lacks actions:read scope, all repos will be skipped with only Details entries (no WouldInstall), and the report may show StatusDegraded without actionable remediation items. The CLI's --enroll-all path has a dedicated "all repos skipped" error, but Analyze does not.

    Remediation: Consider adding a threshold or explicit warning when all repos fail the guard check in Analyze, similar to the eligibleCount == skippedErrors check in admin.go.

Low

  • [Style/conventions] internal/layers/enrollment.go:190-230 — The guard-check logic is duplicated between the enabledRepos loop and the disabledRepos loop. A helper like checkGuard(ctx, repo) (isPerRepo bool, err error) would reduce duplication and make the two loops more readable.

Info

  • [Correctness] internal/layers/enrollment_test.go:327-345 — TestEnrollmentLayer_Analyze_MixedPerRepoAndOrg and TestEnrollmentLayer_Analyze_DisabledWithPerRepoGuard create FakeClient via struct literal instead of NewFakeClient(), leaving Errors, Secrets, WorkflowRuns, and VariablesExist maps nil. This works because the code nil-checks these maps, but it's inconsistent with other tests and fragile if future methods are added that don't nil-check. Consider using NewFakeClient() and then setting the needed fields.

Footer

Outcome: request-changes
This review applies to SHA bb9cfdb6a564fd98c37f6d9aed04ab0d8b626c52. Any push to the PR head clears this review and requires a new evaluation.

Previous run (3)

Review: #967

Head SHA: 468b048
Timestamp: 2026-05-14T00:00:00Z
Outcome: request-changes

Summary

The PR adds a FULLSEND_PER_REPO_INSTALL guard variable to prevent per-org enrollment from overriding per-repo installations. The Go code (interface addition, CLI logic, enrollment layer, tests) is well-structured and the three-state guard logic is sound. However, the check_per_repo_guard function in reconcile-repos.sh has a broken 404 detection mechanism that would cause the script to skip ALL repos without the guard variable — effectively breaking enrollment and unenrollment for every normal per-org repo.

Findings

High

  • [Correctness] internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh:74-97 — check_per_repo_guard 404 detection is broken due to 2>&1 mixing stderr into the JSON response. When gh api returns a non-2xx status, it writes the JSON response body to stdout and an error message (e.g., gh: Not Found (HTTP 404)) to stderr. With 2>&1, both are captured into $resp and concatenated — confirmed by testing in this environment. When this mixed string is piped to jq -e '.status == "404"', jq encounters invalid characters after the JSON object, hits a parse error, and exits non-zero regardless of the actual HTTP status. This means the 404 check ALWAYS fails, and check_per_repo_guard returns 0 (skip) for every repo where the variable doesn't exist. Since most repos won't have the guard variable, this would silently skip enrollment and unenrollment for all normal per-org repos.
    Remediation: Change 2>&1 to 2>/dev/null so only the JSON response body (stdout) is captured, and jq can parse it cleanly. Alternatively, use gh api --jq '.value // empty' with separate error handling for the exit code.

Medium

  • [Platform security] docs/guides/admin/installation.md:184,192 — WIF attribute-condition widened from assertion.repository == '$ORG_NAME/.fullsend' (single repo) to assertion.repository_owner == '$ORG_NAME' (entire org). This grants WIF-based GCP access to workflows running in ANY repo in the organization, not just the .fullsend config repo. The added security note is helpful, but the default guidance is now significantly more permissive. Consider whether the docs should default to the tighter per-repo condition and present the org-wide condition as an alternative for orgs using per-repo mode.
    Remediation: Consider defaulting to the tighter assertion.repository condition in the guide and presenting the assertion.repository_owner alternative in a "Per-repo mode" section, so admins make an explicit choice to widen the scope.

Low

  • [Style/conventions] internal/layers/enrollment.go:190-231 — The guard-check pattern (call GetRepoVariable, handle error → guardFailed, check value → perRepo, else continue) is duplicated verbatim in both the enabled-repos and disabled-repos loops. Extracting a small helper like classifyRepo(ctx, repo) (kind, error) would reduce duplication and make the logic easier to test in isolation.
    Remediation: Extract the guard-check logic into a helper method on EnrollmentLayer.

  • [Correctness] internal/layers/enrollment.go:235 — perRepo and guardFailed detail lines are appended to report.Details before the switch statement, while enrolled details are appended inside the hasDrift case. This means per-repo/guard-failed details appear in the report regardless of which switch branch executes, creating an ordering inconsistency (per-repo details appear before enrolled details). Not a functional bug, but could confuse consumers parsing the details list.

Footer

Outcome: request-changes
This review applies to SHA 468b048dac6b29e740830bcff951dcdbc32ed04a. Any push to the PR head clears this review and requires a new evaluation.

Previous run (4)

Review: #967

Head SHA: 90605f1
Timestamp: 2026-05-14T00:00:00Z
Outcome: comment-only

Summary

This PR implements a FULLSEND_PER_REPO_INSTALL guard variable to prevent per-org enrollment from overriding per-repo installations. The guard is enforced at three points: the CLI (--enroll-all), reconcile-repos.sh, and the enrollment Analyze layer. The implementation is consistent, well-tested (5 new test cases covering skip, false-guard, mixed mode, disabled repos, and error propagation), and uses fail-closed semantics throughout — API errors cause repos to be skipped rather than risked. One documentation change widens a WIF attribute condition from repo-scoped to org-scoped, which is a security trade-off worth noting.

Findings

Medium

  • [Platform security] docs/guides/admin/installation.md:184 — WIF attribute condition widened from assertion.repository == '$ORG_NAME/.fullsend' to assertion.repository_owner == '$ORG_NAME'. This expands the trust boundary: previously only GitHub Actions in the .fullsend repo could federate into GCP via this WIF pool; now any repo in the org can. This is likely intentional to support per-repo mode sharing a WIF pool, but it significantly increases blast radius if any repo's workflow is compromised. The guide should document this trade-off and recommend repo-scoped conditions for orgs that don't need per-repo mode.
    Remediation: Add a note explaining the security trade-off. Consider offering both configurations: the original repo-scoped condition for per-org-only setups, and the org-scoped condition for orgs using per-repo mode.

  • [Platform security] docs/guides/admin/installation.md:192 — The WIF principal is correspondingly widened from attribute.repository/$ORG_NAME/.fullsend to attribute.repository_owner/$ORG_NAME, granting roles/aiplatform.user to all repos in the org rather than just .fullsend. Same blast-radius concern as above.
    Remediation: Same as above — document the trade-off and offer a repo-scoped alternative.

Low

  • [Style/conventions] internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh:266-280,387-401 — The per-repo guard check logic is duplicated verbatim between the enabled-repos (enrollment) and disabled-repos (unenrollment) phases. A helper function (e.g., check_per_repo_guard) would reduce duplication and make future changes easier.
    Remediation: Extract the guard check into a shell function that returns 0 if the repo should be skipped.

  • [Correctness] internal/layers/enrollment_test.go:327,349 — Tests TestEnrollmentLayer_Analyze_MixedPerRepoAndOrg and TestEnrollmentLayer_Analyze_DisabledWithPerRepoGuard use struct literal initialization of FakeClient instead of NewFakeClient(). While this is currently safe (all accessed maps are either set or nil-read-safe), it's inconsistent with other tests in the file and fragile if new FakeClient methods later write to maps that weren't initialized. Using NewFakeClient() and then setting the needed fields would be more robust.
    Remediation: Use forge.NewFakeClient() and then set client.FileContents and client.VariableValues on the returned value.

Info

  • [Correctness] internal/cli/admin.go:306-319 — The interactive prompt for repos with guard != "true" reads from os.Stdin via bufio.NewReader. This is correct for CLI use but makes the --enroll-all path untestable without stdin injection. Not a bug, just noting the test gap — the enrollment layer tests cover the Analyze path but the CLI guard-check path has no unit test coverage.

  • [Intent alignment] The PR body accurately describes the three-state guard logic and the changes are consistent with that description. No scope creep detected — the WIF doc changes are a natural consequence of per-repo support needing org-wide WIF access.

Footer

Outcome: comment-only
This review applies to SHA 90605f1733fcc6a33950d2c3708508ae8ba8f57b. Any push to the PR head clears this review and requires a new evaluation.

Previous run (5)

Review: #967

Head SHA: 210ee36
Timestamp: 2026-05-14T00:00:00Z
Outcome: approve

Summary

This PR introduces a well-designed guard variable (FULLSEND_PER_REPO_INSTALL) that prevents per-org enrollment from overriding per-repo installations. The implementation is consistent across all three enforcement points (CLI per-org enrollment, CLI per-repo install, and the reconcile-repos.sh script), with a correct fail-closed posture on errors. The Analyze layer correctly accounts for per-repo repos in status determination. Tests cover the key scenarios including guard skip, guard-false passthrough, mixed mode, disabled-repo guard, and error propagation. No critical or high findings.

Findings

Medium

  • [Correctness] internal/cli/admin.go:340 — The eligibleCount calculation assumes .fullsend is always present in allRepos (len(allRepos) - 1). If .fullsend is private (excluded by ListOrgRepos), the count is off by one, which could prevent the all-errors safety check from triggering. In practice this is unlikely since per-org install requires a public .fullsend repo.
    Remediation: Count repos that pass the .fullsend name filter instead of subtracting 1 from the total.

Low

  • [Style/conventions] internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh — The per-repo guard check block (API call + jq parse + skip logic) is duplicated nearly verbatim in both the enabled-repos and disabled-repos sections (~15 lines each). Consider extracting to a shell function like the existing validate_repo_name and close_pr_on_branch helpers.
    Remediation: Extract a check_per_repo_guard function returning 0 if the repo should be skipped.

Info

  • [Correctness] internal/forge/fake.go — GetRepoVariable reads from VariableValues while RepoVariableExists reads from VariablesExist. These are independent maps, so a test could set one without the other and get inconsistent behavior. The current tests are correct, but future test authors may be surprised.
    Remediation: Consider having GetRepoVariable also update VariablesExist (or vice versa) for consistency, or document the separation.

  • [Correctness] internal/cli/admin.go — The per-org enrollment guard-check logic (lines 297–341) is not covered by unit tests. The enrollment_test.go tests cover the layers/enrollment.go changes but not the CLI-level filtering. Per CLAUDE.md, CLI code is typically tested via e2e tests, so this is expected but worth noting.

Footer

Outcome: approve
This review applies to SHA 210ee369f2ccd65afcccb8b30e7eba0aa00ff63c. Any push to the PR head clears this review and requires a new evaluation.

Previous run (6)

Review: #967

Head SHA: 722b2d0
Timestamp: 2026-05-14T00:00:00Z
Outcome: request-changes

Summary

This PR adds a FULLSEND_PER_REPO_INSTALL guard variable to prevent per-org enrollment from overriding per-repo installations. The implementation spans the CLI, forge interface, enrollment layer, and reconcile script consistently. The design is sound — the three-state guard logic (true/false/absent) is well thought out and the fail-safe behavior (skip on API error) is correct. However, there is one high-severity correctness issue: the per-repo install path sets the guard variable in repoVars before checking it, meaning the guard-state log messages reference a value that may be stale or overwritten. More critically, the repoVars map unconditionally includes perRepoGuardVar: "true" even when the user's intent might be to inspect or re-evaluate. There are also medium-severity issues around duplicate perRepoGuardVar constants and missing test coverage for the interactive prompt path in the CLI.

Findings

High

  • [correctness] internal/cli/admin.go:463-480 — The guard variable is unconditionally added to repoVars (line 463) before the guard-state check (lines 465-480). This means the status messages ("updating installation" vs "new installation") are cosmetic — the guard is always set to "true" regardless. More importantly, if the guard was previously set to "false" (indicating a deliberate disable), the per-repo install silently overrides it without confirmation. The per-org path prompts the user in this case (lines 318-326), but per-repo does not.
    Remediation: Move the guard check before adding it to repoVars, and prompt or warn when re-enabling a previously-disabled per-repo install (guardVal == "false").

Medium

  • [correctness] internal/cli/admin.go:300-305 — When GetRepoVariable returns an error, the repo is silently skipped with a warning. For --enroll-all this is a reasonable fail-safe, but there is no way for the user to override this behavior (e.g., --force). If the token lacks actions:read scope, every repo will be skipped and the enrollment will silently do nothing. Consider logging a summary or failing if ALL repos were skipped due to guard-check errors.

  • [style/conventions] internal/cli/admin.go:103 and internal/layers/enrollment.go:20 — The constant perRepoGuardVar is defined in two separate packages with identical values ("FULLSEND_PER_REPO_INSTALL"). If the variable name ever changes, both must be updated in lockstep. Consider exporting the constant from a shared location (e.g., forge package where the other variable/secret names live) or adding a comment cross-referencing the other definition.

  • [correctness] internal/layers/enrollment.go:197-200 — When a per-repo guarded repo is in the enabledRepos list, the guard check short-circuits before the GetFileContent call. This means Analyze no longer detects whether the per-repo shim is actually present — it trusts the guard variable alone. If someone sets FULLSEND_PER_REPO_INSTALL=true but never actually installs the shim, Analyze would report the repo as "per-repo install, skipped" with no drift detected, masking a misconfiguration.

  • [correctness] internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh:261-267 — The gh api call to check the guard variable does not validate the response format. If the API returns an unexpected JSON structure (e.g., permissions error with 200 status), --jq '.value' returns empty and the || true swallows the error, so the repo proceeds with normal enrollment. This is fail-open, which is the opposite of the Go code's fail-closed approach (skip on error). The two implementations should have consistent failure semantics.
    Remediation: Check the exit code of gh api separately from the value, or use 2>&1 and inspect for error messages before proceeding.

Low

  • [style/conventions] internal/cli/admin.go:301 — bufio.NewReader(os.Stdin) is created inside the enrollAll block but the reader is only used in a specific guard-value case. This is fine functionally, but the reader creation could be deferred to where it's actually needed to make the code clearer.

  • [correctness] internal/layers/enrollment_test.go:297-303 — TestEnrollmentLayer_Analyze_PerRepoGuardSkips creates a FakeClient with only VariableValues set (via struct literal, not NewFakeClient()). Other maps like FileContents are nil. This works because GetRepoVariable short-circuits before GetFileContent is called, but it makes the test brittle — if the guard-check order ever changes, the test would panic on nil map access rather than fail gracefully.

Footer

Outcome: request-changes
This review applies to SHA 722b2d0d51d06e582350cbb650b36f43d61d2aaa. Any push to the PR head clears this review and requires a new evaluation.

Previous run (7)

Review: #967

Head SHA: e8183e6
Timestamp: 2026-05-14T00:00:00Z
Outcome: request-changes

Summary

The PR introduces a FULLSEND_PER_REPO_INSTALL guard variable to prevent per-org enrollment from overriding per-repo installations. The overall design is sound and the test coverage for the enrollment layer is good. However, two GetRepoVariable calls in admin.go silently discard API errors, creating a fail-open pattern where network or permission failures cause the guard to be bypassed — repos would be enrolled in per-org mode (or per-repo install would proceed without accurate state logging) when the API call fails. Additionally, the enrollment layer's Analyze function uses RepoVariableExists (existence-only check) rather than GetRepoVariable, which makes it inconsistent with the three-state guard logic documented in the PR description: a variable set to "false" would still cause the repo to be skipped.

Findings

High

  • [Correctness / Platform security] internal/cli/admin.go:303 — GetRepoVariable error is silently discarded (guardVal, guardExists, _ := client.GetRepoVariable(...)). If the API call fails, guardExists is false and the repo is silently enrolled in per-org mode, bypassing the guard. This is a fail-open pattern that defeats the purpose of the guard when the API is unreachable or returns an auth error.
    Remediation: Handle the error. At minimum log a warning; ideally fail closed by skipping the repo on error, or prompt the operator.

  • [Correctness / Platform security] internal/cli/admin.go:487 — Same silent error discard in runPerRepoInstall. The guard state log messages will be wrong (shows "new installation" when the API failed rather than when the variable truly doesn't exist).
    Remediation: Handle the error — at least log it, or return it to the caller.

Medium

  • [Correctness] internal/layers/enrollment.go:197 — Analyze uses RepoVariableExists (checks existence only) instead of GetRepoVariable (reads the value). Per the PR's three-state table, guard=false should have different semantics than guard=true, but Analyze treats any existing variable as "per-repo install, skipped". This is inconsistent with the documented design.
    Remediation: Use GetRepoVariable and only skip when the value is "true", or update the three-state table in the PR description to reflect that Analyze intentionally treats any existing guard as a skip.

Low

  • [Correctness] internal/layers/enrollment_test.go — Tests for the per-repo guard in Analyze only cover the RepoVariableExists path. There is no test verifying behavior when the guard variable exists but has a value other than "true" (e.g., "false"). This gap maps directly to the medium finding above.
    Remediation: Add a test case with VariableValues set to "false" to verify the intended behavior.

  • [Style] internal/cli/admin.go:296 — bufio.NewReader(os.Stdin) is created inside the enrollAll branch but os.Stdin is already used elsewhere via promptEnrollment. If both paths run in the same invocation, two readers on the same os.Stdin could cause buffering issues (one reader consumes bytes intended for the other). Low risk since enrollAll=true means the prompt was already answered, but worth noting.
    Remediation: Consider reusing the reader or using a consistent stdin-reading approach.

Footer

Outcome: request-changes
This review applies to SHA e8183e621d0711f7bb29db3d0c5c9a58271fa5c9. Any push to the PR head clears this review and requires a new evaluation.

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

@github-actions

Copy link
Copy Markdown

fullsend fix is working on this — view logs

- Switch Analyze from RepoVariableExists (boolean) to GetRepoVariable
  (value-aware) so guard=false is not treated as per-repo active
- Handle GetRepoVariable errors fail-closed in per-org enrollment
  instead of silently ignoring with _
- Log warning on guard check error in per-repo install path
- Add guard check to reconcile-repos.sh Phase 2 (unenrollment) to
  prevent removal PRs for per-repo managed repos
- Move Phase 1 guard check after stale PR cleanup so per-repo repos
  still get stale unenrollment PRs cleaned up
- Add guard check for disabled repos in Analyze
- Use constant for guard variable name in admin.go
- Initialize VariableValues in NewFakeClient
- Add tests: guard=false, disabled repos with guard

Signed-off-by: Wayne Sun <gsun@redhat.com>
@github-actions

Copy link
Copy Markdown

fullsend review is working on this — view logs

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

@github-actions

Copy link
Copy Markdown

fullsend fix is working on this — view logs

- Move guard variable check before adding to repoVars in per-repo install,
  so status messages reflect actual state. Add warning when overriding a
  previously-disabled guard (guard="false").
- Export perRepoGuardVar as forge.PerRepoGuardVar to eliminate duplicate
  constant definitions in admin.go and enrollment.go.
- Fail loudly when all repos are skipped due to guard-check errors in
  per-org enrollment (likely missing actions:read scope).
- Defer bufio.NewReader creation to where it's actually needed.
- Make reconcile-repos.sh fail-closed on guard-check API errors,
  consistent with Go code's behavior.
- Use NewFakeClient() in enrollment tests to avoid nil map panics.

Addresses review feedback on #967

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: fullsend-fix <fullsend-code@users.noreply.github.com>
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

🔧 Fix agent — iteration 1 (bot-triggered)

Addressed 6 of 7 review findings. Fixed guard-check ordering in per-repo install, exported shared constant, added all-skipped error detection, deferred bufio.NewReader, made reconcile-repos.sh fail-closed, and hardened tests. Disagreed with 1 finding (Analyze guard-trust) because per-repo repos intentionally use a different shim template.

Fixed (6):

  1. guard variable added to repoVars before checking it in per-repo install (internal/cli/admin.go): Moved guard check before repoVars construction so status messages reflect actual guard state. Added explicit warning when overriding a 'false' guard value and when overriding unexpected values.
  2. all repos silently skipped when guard-check errors occur in per-org enrollment (internal/cli/admin.go): Added skippedErrors counter and fail-loudly check: if every eligible repo was skipped due to guard-check errors, return an error suggesting the token may lack actions:read scope.
  3. duplicate perRepoGuardVar constant in admin.go and enrollment.go (internal/forge/forge.go): Exported the constant as forge.PerRepoGuardVar in the forge package (alongside ConfigRepoName). Removed duplicate definitions from admin.go and enrollment.go, both now reference forge.PerRepoGuardVar.
  4. reconcile-repos.sh fail-open on guard-check API errors (internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh): Rewrote both guard checks (enrollment and unenrollment) to capture the gh api exit code separately. Non-404 errors now cause the repo to be skipped (fail-closed), consistent with the Go code. Only 404 (variable not found) proceeds with normal enrollment/unenrollment.
  5. bufio.NewReader created early in enrollAll block (internal/cli/admin.go): Deferred bufio.NewReader creation to the point where it's actually needed (when a guard value other than 'true' is found and the user needs to be prompted).
  6. tests use struct literal instead of NewFakeClient() (internal/layers/enrollment_test.go): Changed PerRepoGuardSkips, PerRepoGuardFalse, and PerRepoGuardCheckError tests to use forge.NewFakeClient() and then set fields, ensuring all maps are initialized and avoiding potential nil map panics if guard-check order changes.

Disagreed (1):

  1. Analyze trusts guard variable alone without verifying shim exists: Per-repo repos use a different shim template than per-org repos. Checking for the org-style shim in a per-repo repo would be incorrect — it may legitimately not exist (per-repo uses its own scaffold template). The guard variable IS the authoritative signal for per-repo mode. Additionally, the guard is only set by the per-repo install command which always writes the shim as part of installation, so a guard=true without shim would require manual tampering with the variable.

Tests: passed

Decision points
  • Chose to disagree with enrollment.go guard-trust finding (alternatives: Add shim existence check after guard check, Add a comment noting the trust assumption; rationale: Per-repo repos use a different shim template, so checking the org-style shim would produce false positives. The guard variable is set atomically with the shim during per-repo install.)
  • Chose to fail on all-repos-skipped rather than just warn (alternatives: Log a warning and continue with zero repos, Prompt the user to continue; rationale: If every repo is skipped due to API errors, enrollment silently does nothing — a hard error is more helpful since the user needs to fix their token.)

Updated by fullsend fix agent

@github-actions

Copy link
Copy Markdown

fullsend review is working on this — view logs

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

LGTM. Three minor notes inline — all deferred.

Comment thread internal/layers/enrollment.go Outdated
_, err := l.client.GetFileContent(ctx, l.org, repo, shimWorkflowPath)
guardVal, guardExists, err := l.client.GetRepoVariable(ctx, l.org, repo, forge.PerRepoGuardVar)
if err != nil {
return nil, fmt.Errorf("checking per-repo guard for %s: %w", repo, err)

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.

[moderate] Analyze returns a hard error here, but admin.go and reconcile-repos.sh both degrade gracefully on the same failure (log + skip). If one repo out of 50 has a permissions quirk, Analyze aborts entirely. Worth aligning in a follow-up — e.g., add the error to report.Details and continue. Deferred.

echo "::warning::Skipping $REPO — per-repo installation active (FULLSEND_PER_REPO_INSTALL=true)"
SKIPPED=$((SKIPPED + 1))
continue
fi

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.

[moderate] When the guard exists but isn't "true" (e.g., "false"), the script falls through silently. An info log like echo " Per-repo guard exists but value is '$PER_REPO_VAR' — proceeding" would help debugging. Same in the unenrollment block. Deferred.

- ADR 0033: document FULLSEND_PER_REPO_INSTALL guard variable in
  coexistence section, update migration steps, fix stale CLI flags
  (--gcp-auth-mode removed in PR #905), update repo variables list
- Installation guide: fix WIF attribute condition from
  assertion.repository == 'org/.fullsend' to
  assertion.repository_owner == 'org' (PR #920 fix), fix WIF
  principal from attribute.repository/org/.fullsend to
  attribute.repository_owner/org

Signed-off-by: Wayne Sun <gsun@redhat.com>
@github-actions

Copy link
Copy Markdown

fullsend review is working on this — view logs

- Extract check_per_repo_guard() helper in reconcile-repos.sh to DRY
  enrollment/unenrollment guard checks with fail-closed error handling
- Use jq JSON parsing instead of grep for 404 detection in shell
- Log notice when guard variable exists but is not "true"
- Soft-fail on guard API errors in enrollment Analyze (skip repo instead
  of aborting entire analysis)
- Fix eligibleCount to use actual filtered count instead of allRepos-1
- Remove stale --gcp-auth-mode reference from ADR 0033
- Add WIF org-wide scope security callout to installation guide

Signed-off-by: Wayne Sun <gsun@redhat.com>
@github-actions

Copy link
Copy Markdown

fullsend review is working on this — view logs

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

@github-actions

Copy link
Copy Markdown

fullsend fix is working on this — view logs

- Change `2>&1` to `2>/dev/null` in check_per_repo_guard so $resp
  contains clean JSON, fixing jq 404 detection that was broken by
  stderr contamination (would incorrectly skip all repos without the
  guard variable)
- Sanitize variable values before echoing into GitHub Actions workflow
  command annotations to prevent command injection via crafted values
- Split skip count reporting to distinguish per-repo installed repos
  from guard-check errors in enrollment summary message

Signed-off-by: Wayne Sun <gsun@redhat.com>
@github-actions

Copy link
Copy Markdown

fullsend review is working on this — view logs

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

@github-actions

Copy link
Copy Markdown

fullsend fix is working on this — view logs

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

🔧 Fix agent — iteration 2 (bot-triggered)

Addressed all 5 review findings: fixed broken 404 detection in reconcile-repos.sh (HIGH), elevated WIF docs security warning (MEDIUM), added all-repos-failed threshold in enrollment Analyze (MEDIUM), extracted checkGuard helper (LOW), fixed test initialization (INFO). All 20 enrollment tests pass.

Fixed (5):

  1. broken 404 detection in check_per_repo_guard() (internal/scaffold/fullsend-repo/scripts/reconcile-repos.sh): Changed .status == "404" to .message == "Not Found" — GitHub REST API 404 responses use {"message": "Not Found"}, not {"status": "404"}. Without this fix, all repos without the guard variable would be incorrectly skipped.
  2. WIF attribute condition widened without sufficient warning (docs/guides/admin/installation.md): Elevated security note to a warning callout. Added explicit guidance for per-org-only setups to use the tighter assertion.repository condition. Documented the discrepancy between manual (org-wide) and auto-provisioned (per-repo) WIF providers.
  3. Analyze missing threshold check for all-repos-failed (internal/layers/enrollment.go): Added all-repos-failed threshold warning in Analyze(), surfacing a message when every repo fails the guard check — similar to the eligibleCount == skippedErrors check in admin.go.
  4. guard-check logic duplicated between enabled/disabled loops (internal/layers/enrollment.go): Extracted checkGuard closure to deduplicate the guard-check pattern between the enabledRepos and disabledRepos loops.
  5. tests use struct literal instead of NewFakeClient() (internal/layers/enrollment_test.go): Changed MixedPerRepoAndOrg and DisabledWithPerRepoGuard tests to use forge.NewFakeClient() and set fields on the returned value, ensuring all internal maps are properly initialized.

Tests: passed

Decision points
  • Chose .message == "Not Found" for 404 detection rather than restructuring to use --jq with exit code inspection (alternatives: Restructure to use gh api --jq with exit code inspection, Use --include to capture HTTP status; rationale: Minimal change that fixes the bug. The existing function structure is clear and the .message field is a stable part of GitHub's API error responses.)

Updated by fullsend fix agent

fullsend-ai-coder Bot pushed a commit that referenced this pull request May 14, 2026
- Fix broken 404 detection in check_per_repo_guard(): GitHub's REST API
  404 responses use {"message": "Not Found"}, not {"status": "404"}.
  Without this fix, all repos without the guard variable would be
  incorrectly skipped from enrollment/unenrollment.
- Elevate WIF security note to a warning callout with explicit guidance
  for per-org-only setups to use the tighter assertion.repository
  condition, and document the discrepancy with auto-provisioned providers.
- Add all-repos-failed threshold warning in enrollment Analyze(), similar
  to the eligibleCount == skippedErrors check in admin.go CLI path.
- Extract checkGuard helper in enrollment.go to reduce duplication
  between enabled-repos and disabled-repos loops.
- Use NewFakeClient() instead of struct literals in tests for
  MixedPerRepoAndOrg and DisabledWithPerRepoGuard to initialize all maps.

Addresses review feedback on #967

Signed-off-by: fullsend-fix <fullsend-code@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

fullsend review is working on this — view logs

- Fix broken 404 detection in check_per_repo_guard(): GitHub's REST API
  404 responses use {"message": "Not Found"}, not {"status": "404"}.
  Without this fix, all repos without the guard variable would be
  incorrectly skipped from enrollment/unenrollment.
- Elevate WIF security note to a warning callout with explicit guidance
  for per-org-only setups to use the tighter assertion.repository
  condition, and document the discrepancy with auto-provisioned providers.
- Add all-repos-failed threshold warning in enrollment Analyze(), similar
  to the eligibleCount == skippedErrors check in admin.go CLI path.
- Extract checkGuard helper in enrollment.go to reduce duplication
  between enabled-repos and disabled-repos loops.
- Use NewFakeClient() instead of struct literals in tests for
  MixedPerRepoAndOrg and DisabledWithPerRepoGuard to initialize all maps.

Addresses review feedback on #967

Signed-off-by: fullsend-fix <fullsend-code@users.noreply.github.com>
Signed-off-by: Wayne Sun <gsun@redhat.com>
@waynesun09
waynesun09 force-pushed the per-repo-install-guard branch from dd66120 to de5877f Compare May 14, 2026 23:31
@github-actions

Copy link
Copy Markdown

fullsend review is working on this — view logs

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

@github-actions

Copy link
Copy Markdown

fullsend fix is working on this — view logs

@waynesun09 waynesun09 added the fullsend-no-fix Skip bot-triggered fix agent runs label May 14, 2026
@waynesun09
waynesun09 added this pull request to the merge queue May 14, 2026
Merged via the queue into main with commit 02c6a15 May 14, 2026
25 of 26 checks passed
@waynesun09
waynesun09 deleted the per-repo-install-guard branch May 14, 2026 23:39
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

🔧 Fix agent — iteration 3 (bot-triggered)

PR #967 is in MERGED state. No fixes can be applied to a merged PR. The review feedback would need to be addressed in a follow-up PR.

Disagreed (1):

  1. all review findings: PR feat: add FULLSEND_PER_REPO_INSTALL guard variable #967 is already merged. Cannot apply fixes to a merged PR.

Tests: passed

Updated by fullsend fix agent

ben-alkov pushed a commit to ben-alkov/fullsend that referenced this pull request May 15, 2026
The FULLSEND_PER_REPO_INSTALL guard (PR fullsend-ai#967) fails in reconcile
workflows because the fullsend role token lacks the variables:read
fine-grained permission. The GET /repos/{owner}/{repo}/actions/variables
endpoint returns 403, causing all repos to be skipped.

- Add Variables field to AppPermissions struct and fullsend App manifest
- Add variables:read to fullsend role in mint rolePermissions
- Fix misleading "actions:read" error message in enrollment analyzer
- Include API error message in reconcile-repos.sh warning output

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

This branch was successfully deployed

1 active deployment
site-preview — de5877f4 Deployed May 14, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fullsend-no-fix Skip bot-triggered fix agent runs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants