Skip to content

fix(#7378): set per-repo guard during shared GitHub install - #7382

Closed
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/7378-migrate-per-repo-guard
Closed

fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/7378-migrate-per-repo-guard

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

repos migrate (and every other caller of repos.Install) now writes FULLSEND_PER_REPO_INSTALL=true on GitHub repos. Migrating a repo to per-repo install no longer leaves it unprotected against still-live per-org reconcile, which was opening offboard PRs that deleted the freshly installed shim.

Related Issue

#7378

Changes

  • Add FULLSEND_PER_REPO_INSTALL=true to the GitHub managed-variable list in managedVarsForForge, the shared source of truth used by install, migrate, converge, and status.
  • Stop treating the guard as an orphan variable during drift detection.
  • Document the guard on the per-repo GitHub variable lists and in the migrate flow.

Testing

  • go test -race -count=1 -coverprofile=coverage.out ./internal/repos/ — pass (90.0% package coverage; managedVarsForForge 100%).
  • go vet ./internal/repos/ — pass.
  • Direct hook execution (gofmt, gitleaks, lychee, trailing-whitespace, lint-docs-links) — pass.
  • pre-commit run could not fetch remote hook repos (HTTP 403); golangci-lint is not installed in this sandbox.

Checklist

  • PR title follows Conventional Commits (fix(#7378): ...)
  • Autonomous agent commit (no DCO sign-off)
  • Changes are limited to the shared managed-var list, tests, and docs for this bug

Closes #7378

Post-script verification

  • Branch is not main/master (agent/7378-migrate-per-repo-guard)
  • Secret scan passed (gitleaks — 6aa078bc7dc2a5f0dcf2aea8e78e604e380cb2ff..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

managedVarsForForge omitted FULLSEND_PER_REPO_INSTALL, so
repos.Install (used by repos migrate) never wrote the ADR-0033
guard. After migrate set enabled: false, per-org reconcile opened
offboard PRs that deleted the freshly installed shim.

Include the guard in the GitHub managed-var list so every shared
install path (migrate, repos install, admin install) writes it.

Note: pre-commit could not fetch remote hook repos (HTTP 403).
Hooks were run directly (gofmt, go vet, gitleaks, lychee,
trailing-whitespace). golangci-lint is not installed in this
sandbox; go vet ./internal/repos passed.

Closes #7378
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team September 16, 2026 18:53
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Sep 16, 2026
@fullsend-ai-review

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

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:55 PM UTC · Completed 7:12 PM UTC

Commit: 9070080 · View workflow run →

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

@github-actions

Copy link
Copy Markdown

Site preview

Preview: https://aceaefa4-site.fullsend-ai.workers.dev

Commit: 907008001e97e568cdf75ef7c0dc2d2b714612c2

@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Sep 16, 2026
@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Tier 1 is low risk (small, non-protected, non-security, bot-authored bugfix with moderate test coverage); Tier 2 is elevated by high historical churn/fix-revert rates in the touched package; Tier 3 is low risk given an exact, well-scoped, high-priority bugfix matching a same-day issue with no open discussion, offset only by the lack of a rollback flag for the behavior change; weighted composite rounds to a moderate score of 2.

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Medium

  • [logic-error] internal/repos/install.go:519 — FULLSEND_PER_REPO_INSTALL was added to managedVarsForForge (so Install/migrate/admin install now write the guard), but it was not added to the GitHub requiredVariables list, which remains only FULLSEND_MINT_URL. ProbeComponents (internal/repos/probe.go) presence-checks only names in requiredVarsForForge; the guard now appears in expectedVarValues via staticExpectedVarValues, so it falls into the "extra variables" loop, which explicitly skips reporting absence ("these are optional, so absence is not a problem"). That means a repo that was already migrated/installed before this fix — i.e. the exact konflux-ci production incident described in repos migrate leaves migrated repos as enabled: false, triggering offboard PRs that delete their per-repo shim #7378 — has FULLSEND_MINT_URL present but the guard missing, and neither repos status nor repos converge will detect or repair it, since convergeVariables only acts on components ProbeComponents already returned. The fix protects future installs/migrates but does not close the gap for repos already affected by the bug it's meant to fix.
    Remediation: Add forge.PerRepoGuardVar to the GitHub requiredVariables list in internal/repos/install.go (not to gitlabRequiredVariables) so ProbeComponents treats its absence as drift. Add a test where FULLSEND_MINT_URL is present and the guard is absent, asserting repos converge/repos status add/report it.

Low

  • [docs-correctness] docs/guides/dev/cli-internals.md:316 — The new line FULLSEND_PER_REPO_INSTALL=true (GitHub) was added under "Both modes write the same credential set" in the Phase 6 diagram, but the guard is per-repo-only by design (per-org must not write it, or it would defeat its purpose). The diagram's existing per-repo-only sub-box still references the variable under a stale name, FULLSEND_PER_REPO_GUARD=true, so the new line duplicates/conflicts with that entry rather than correcting it.
    Remediation: Move FULLSEND_PER_REPO_INSTALL=true (GitHub) out of the shared credential list and into the per-repo-only sub-box, replacing FULLSEND_PER_REPO_GUARD=true so the diagram reflects the correct variable name in the correct scope.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

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

Note: The following review comments could not be posted on the diff (GitHub returned 422) and are included here instead:

  • internal/repos/install.go (file-level): Line 519 · [medium] logic-error

FULLSEND_PER_REPO_INSTALL was added to managedVarsForForge (so Install/migrate/admin install write it on new/refreshed installs), but it was not added to the GitHub requiredVariables list, which remains only FULLSEND_MINT_URL. ProbeComponents presence-checks only names in requiredVarsForForge; the guard now appears in expectedVarValues via staticExpectedVarValues, so it falls into the 'extra variables' loop, which explicitly skips reporting absence ('these are optional, so absence is not a problem'). A repo already migrated/installed before this fix -- the exact konflux-ci production incident described in #7378 -- has FULLSEND_MINT_URL present but the guard missing, and neither repos status nor repos converge will detect or repair it, since convergeVariables only acts on components ProbeComponents already returned. The fix protects future installs/migrates but does not close the gap for repos already affected by the bug it targets.

Suggested fix: Add forge.PerRepoGuardVar to the GitHub requiredVariables list in internal/repos/install.go (not to gitlabRequiredVariables) so ProbeComponents treats its absence as drift, enabling repos converge to backfill it and repos status to report it. Add a test where FULLSEND_MINT_URL is present and the guard is absent, asserting converge/status add/report it.

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

│ │ FULLSEND_GCP_REGION │ │
│ │ FULLSEND_MINT_URL │ │
│ │ FULLSEND_REVIEW_CLIENT_ID (best-effort) │ │
│ │ FULLSEND_PER_REPO_INSTALL=true (GitHub) │ │

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] docs-correctness

The new line FULLSEND_PER_REPO_INSTALL=true (GitHub) was added under 'Both modes write the same credential set' in the Phase 6 diagram, but the guard is per-repo-only by design (per-org must not write it). The diagram's existing per-repo-only sub-box still references the variable under a stale name, FULLSEND_PER_REPO_GUARD=true, so the new line duplicates/conflicts with that entry rather than correcting it.

Suggested fix: Move FULLSEND_PER_REPO_INSTALL=true (GitHub) out of the shared credential list and into the per-repo-only sub-box, replacing FULLSEND_PER_REPO_GUARD=true so the diagram reflects the correct variable name in the correct scope.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 7:14 PM UTC · Completed 7:27 PM UTC

Commit: 9070080 · View workflow run →

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

@ggallen

ggallen commented Sep 16, 2026

Copy link
Copy Markdown
Member

Closing this PR because the guard-only fix does not implement the intended solution for #7378. After successful migration, repos migrate should remove the repository's entire entry from the source <org>/.fullsend/config.yaml, rather than leaving it with enabled: false. Entries for failed migrations and unrelated repositories must be preserved, and cleanup must remain retryable for repositories already migrated.

The issue description is being corrected to make those acceptance criteria explicit. The missing guard identified in the original report led triage and implementation toward a different solution; setting the guard alone does not satisfy the requested source-config cleanup.

@fullsend-ai-retro

fullsend-ai-retro Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 7:25 PM UTC · Completed 7:33 PM UTC

Commit: 9070080 · View workflow run →

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

fullsend-ai-coder Bot added a commit that referenced this pull request Sep 16, 2026
Address review feedback on PR #7382:

- Add forge.PerRepoGuardVar to the GitHub requiredVariables list so
  ProbeComponents (and therefore repos status/converge) reports its
  absence as drift instead of silently skipping it as an optional
  extra variable. This closes the gap left by the original fix: repos
  installed/migrated before the guard existed (e.g. the konflux-ci
  incident in #7378) now get detected and repaired, not just future
  installs. uninstall.go's explicit PerRepoGuardVar entry is dropped
  since it's now pulled in via requiredVariables, avoiding a double
  delete. Added converge/status tests reproducing the pre-existing
  install scenario and updated shared "fully installed" test fixtures
  to include the guard.
- Fix docs/guides/dev/cli-internals.md: move
  FULLSEND_PER_REPO_INSTALL=true out of the "both modes" shared
  credential list (it's per-repo-only by design) and into the
  per-repo-only sub-box, replacing the stale FULLSEND_PER_REPO_GUARD
  name.

Addresses #7382
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (bot-triggered)

Fixed the drift-detection gap: FULLSEND_PER_REPO_INSTALL is now in the GitHub requiredVariables list so repos status/converge detect and repair it on repos migrated before the guard existed (the exact konflux-ci scenario from #7378), with new tests covering that case. Fixed uninstall.go's now-redundant explicit guard entry. Corrected the cli-internals.md diagram to place the guard variable in the per-repo-only scope with the correct name.

Fixed (2):

  1. install.go:519 guard var missing from GitHub requiredVariables, so drift on already-migrated repos is never flagged (internal/repos/install.go): Added forge.PerRepoGuardVar to the GitHub requiredVariables list (not gitlabRequiredVariables) so ProbeComponents presence-checks it and treats absence as drift. Also fixed internal/repos/uninstall.go, which previously prepended forge.PerRepoGuardVar separately into uninstallVariables and would have double-deleted it now that it's included via requiredVariables. Added TestConverge_MissingGuardVar_Repaired (internal/repos/converge_test.go) and TestStatus_MissingGuardVar_ReportedAsDrift (internal/repos/status_test.go) covering the exact scenario from the review: FULLSEND_MINT_URL present, guard absent, asserting repos converge adds it and repos status reports it as drift. Updated shared 'fully installed' test fixtures (markFullyInstalled, populateInstalledRepo, and two standalone fixtures in install_test.go/probe_test.go) to include the guard variable so they still represent complete installs under the new requirement.
  2. cli-internals.md:316 added the guard var to the shared credential list, but it is per-repo-only and the sub-box still used the stale name FULLSEND_PER_REPO_GUARD (docs/guides/dev/cli-internals.md): Removed FULLSEND_PER_REPO_INSTALL=true (GitHub) from the shared credential list and replaced the stale FULLSEND_PER_REPO_GUARD=true entry in the per-repo-only sub-box with the correct FULLSEND_PER_REPO_INSTALL=true, preserving the diagram's fixed-width ASCII box alignment.

Tests: passed

Decision points
  • uninstall.go previously listed forge.PerRepoGuardVar explicitly in uninstallVariables in addition to requiredVariables; adding the guard to requiredVariables would have created a duplicate entry (confirmed by a failing test expecting 4 deleted variables, got 5) (alternatives: Leave the duplicate in place (harmless since DeleteRepoVariable treats a second delete of an already-deleted variable as a no-op via 404), Remove the separate explicit entry now that requiredVariables includes it; rationale: Removed the separate explicit entry to keep the variable list accurate and avoid relying on delete-idempotency to mask a redundant entry; this was necessary to keep internal/repos/uninstall_test.go passing without weakening its assertions.)

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-retro

Copy link
Copy Markdown

PR #7382 fixed issue #7378 exactly as the issue's original diagnosis suggested (add the FULLSEND_PER_REPO_INSTALL guard var to managedVarsForForge), and the pipeline ran cleanly: triage ($0.40) correctly traced the reported code path, code ($9.70) implemented it with passing tests/coverage, and review ($4.96) caught a real medium-severity gap (guard var missing from requiredVariables, so drift detection wouldn't backfill already-migrated repos) plus a real docs inconsistency. But the maintainer (ggallen) closed the PR: the guard alone doesn't satisfy the actual intended fix — repos migrate should remove a migrated repo's entry from the source config.yaml, not merely guard/disable it. The issue was rewritten with explicit acceptance criteria and reopened as work. I traced internal/repos/migrate.go Step 4 and confirmed it only flips Enabled = false (never removes the entry) — and found that ADR-0044's 'Migration plan for existing per-org users' section already documents the equivalent manual operation (admin disable repos) as one that 'removes the repo from .fullsend/config.yaml.' That authoritative doc existed but wasn't cross-checked at triage time; triage instead reasoned from current code alone that 'the fix belongs in managedVarsForForge ... rather than in migrate.go,' ruling out the file that actually needed to change. This is a well-matched, concrete new data point for the already-open triage/ADR-verification cluster: evidence for #2251 (triage should validate root-cause hypotheses by tracing code — it traced code but not governing ADRs), #3158 (agents should check relevant ADRs during planning), #2812 (review should verify implementation against ADR alternatives), and especially #2284 (pipeline should re-evaluate in-flight PRs when a human questions the linked issue's diagnosis) — this run is essentially #2284's scenario taken one step further: the human didn't just comment, they closed the PR and rewrote the issue outright, after ~$15 of triage+code+review spend. Separately, the fix agent dispatched by the review's change-request (run 35139128672, started 19:14 UTC) kept running for 13 more minutes after ggallen closed the PR at 19:23:57 UTC, and at 19:27:27 UTC pushed a new commit onto the now-closed PR's dead branch before its post-script realized nothing more could be done — $2.49 fully wasted, no PR-state check anywhere in the run. This is strong new evidence for the already-open in-flight-cancellation cluster: #2388 (cancel in-flight review/fix workflow when PR closes/merges during the run — the closest mechanism match), plus #1870, #6725, #4070, and the consolidation meta-issue #5817. Finally, this same review run (35137263250) hit the same GitHub 422 inline-comment-posting failure already tracked by #6039 and #7346 — its findings fell back to a whole-PR comment instead of posting inline, another data point for that cluster. Given all four gaps are already tracked by open issues with strong mechanism matches, I am not filing new proposals — the evidence above is meant to corroborate those existing tickets rather than duplicate them. Review quality at the implementation level was genuinely good here (the requiredVariables catch and the docs catch were both correct, useful finds); the miss was entirely at the requirements/architecture-verification layer, which is exactly the class of gap the cited open issues already target.

This branch was successfully deployed

1 active and 1 inactive deployments
site-preview — 90700800 Deployed Sep 16, 2026 by github-actions[bot]
dev — 90700800 Deployed Sep 16, 2026 by fullsend-ai-coder[bot] via behaviour #12998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Triggers review agent dispatch risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repos migrate leaves migrated repos as enabled: false, triggering offboard PRs that delete their per-repo shim

1 participant