Skip to content

chore(#7381): delete poll-state branches; bot PAT Developer(30) - #7400

Merged
ggallen merged 3 commits into
mainfrom
agent/7381-gitlab-pat-developer-uninstall
Sep 17, 2026
Merged

ggallen merged 3 commits into
mainfrom
agent/7381-gitlab-pat-developer-uninstall

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Complete GitLab poller-state phase 3c: uninstall deletes the two poll-state branches, and the created bot PAT is lowered from Maintainer(40) to Developer(30) with a UTC expiry.

Related Issue

#7381 (part of #7343; follows #7379 / #7380)

Changes

  • repos uninstall deletes fullsend-poll-state-slash and fullsend-poll-state-events via DeleteRef (missing branches are ignored so older installs still uninstall cleanly). Legacy CI/CD variable deletion is unchanged.
  • The bot PAT created at install is now Developer (30) instead of Maintainer (40), which is sufficient now that poller state lives on unprotected branches.
  • PAT expires_at is computed from UTC so a local-timezone date cannot produce a token GitLab already considers expired (active: false).
  • Docs (docs/cli/repos.md, uninstall guides, infrastructure reference, architecture) and a minor annotation on ADR 0067 match the new behavior.

Testing

  • go test -race ./internal/repos/ — uninstall branch deletion, not-found, and hard-error paths (deleteGitLabPollStateBranches 100%, uninstallRepoResources 100%).
  • go test -race ./internal/cli/ -run 'GitLabBot|SetupGitLabBot' — Developer(30) PAT creation and UTC vs local expiry (gitlabBotPATExpiresAt 100%, setupGitLabBotToken 96.8%).
  • go vet ./internal/repos/ ./internal/cli/ ./internal/forge/gitlab/
  • Direct hook execution (pre-commit could not fetch remotes): gofmt, gitleaks, lychee, ADR lint scripts.

Checklist

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

Closes #7381

Post-script verification

  • Branch is not main/master (agent/7381-gitlab-pat-developer-uninstall)
  • Secret scan passed (gitleaks — 1e22c35bcbe38f08a8fedb6f2b4253f9476fbfaa..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

GitLab uninstall now deletes the two poll-state branches
(fullsend-poll-state-slash / fullsend-poll-state-events) via
DeleteRef, treating a missing branch as success so older
installs still uninstall cleanly. Legacy CI/CD variable
deletion is unchanged.

The created bot PAT is lowered from Maintainer(40) to
Developer(30) now that poller state no longer requires
Maintainer-only CI/CD variable writes. Expiry is computed
from UTC so a local-timezone date cannot produce a token
that GitLab already considers expired.

Tests cover uninstall branch deletion (including not-found
and hard-error paths) and Developer(30)/UTC-expiry PAT
creation. Docs and ADR 0067 are annotated to match.

Note: pre-commit could not fetch remote hook repos (git
fetch origin --tags returned HTTP 403). Hooks were run
directly: gofmt, go vet, gitleaks, lychee, ADR lint
scripts. golangci-lint is not installed in this sandbox.

Closes #7381
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team September 17, 2026 12:14
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Sep 17, 2026
@fullsend-ai-review

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

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:17 PM UTC · Completed 12:38 PM UTC

Commit: a9f09b4 · View workflow run →

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

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://3ecbae23-site.fullsend-ai.workers.dev

Commit: 5ac9bf2b107c39ecf631bb829416f84c05086e65

@codecov

codecov Bot commented Sep 17, 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 17, 2026
@fullsend-ai-review

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

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Re-review: Tier 1 signals are identical to the prior assessment (bot author, medium blast radius, zero protected/security/CI/dependency paths) and Tier 2 shows the same high-churn, actively-maintained files with no new fix/revert pattern; the single new commit since the prior review is a docs-only wording fix to docs/cli/repos.md with no code or behavior change, so per re-review anchoring the score is preserved at 2 (moderate).

Previous run

Risk Assessment: moderate (2/5)

Details

Re-review: Tier 1 and Tier 2 signals are unchanged from the prior assessment (bot author, no protected/security/CI/dependency paths, medium blast radius, high historical churn on the touched files); the one additional commit since the prior review is a small, non-functional follow-up (doc annotation + reusing an existing package var) that does not change risk characteristics, so per re-review anchoring the score is preserved at 2 (moderate).

Previous run (2)

Risk Assessment: moderate (2/5)

Details

Tier 1 is low (bot author, no protected/security/CI/dependency paths, modest size) but touched docs/Go files show high historical churn and the PR modifies existing uninstall/PAT-permission behavior with no feature flag, while tightly matching a well-scoped linked issue; composite rounds to 2 (moderate).

@fullsend-ai-review

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

Copy link
Copy Markdown

Looks good to me

Previous run

Review

Findings

Medium

  • [api-contract] docs/cli/repos.md:133 — The GitLab bot-token paragraph added for the residual Replace GitLab bridge job with API-triggered dispatch #5556 CreatePipeline case tells operators on a Maintainers-only merge+push default branch to "pass a Maintainer-level --gitlab-bot-token." That flag is not an access-level override: setupGitLabBotToken always calls CreateProjectAccessToken at gitlabAccessLevelDeveloper (30) when the API succeeds (internal/cli/repos_gitlab.go:67-79), and only uses fallbackToken when creation fails or glClient is nil (the free-tier path). On Premium/Ultimate — the path this PR's Developer(30) PAT is actually created on — --gitlab-bot-token is ignored, FULLSEND_FORGE_TOKEN stays Developer(30), and pipeline dispatch still 403s on a strict, Maintainers-only branch-protection configuration. The docs recommend a no-op workaround for exactly the scenario they're trying to help operators avoid.
    Remediation: Drop the --gitlab-bot-token workaround from docs/cli/repos.md:133. Document only the options that actually work: grant Developers merge or push access to the default branch, or replace FULLSEND_FORGE_TOKEN manually in GitLab after install (converge does not rotate an existing token). Alternatively, change setupGitLabBotToken to honor --gitlab-bot-token as an override even when project-access-token creation succeeds. (Prior review's residual-permission and inline-slice findings: not observed in the current diff.)

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
Previous run (2)

Review

Findings

Medium

  • [logic-error] internal/cli/repos_gitlab.go:60 — Lowering the created bot PAT from Maintainer (40) to Developer (30) removes the CI/CD-variable justification for Maintainer (the original reason recorded in ADR 0067's "Credential model" section), but that ADR separately records an independent requirement from the Replace GitLab bridge job with API-triggered dispatch #5556 API-triggered-pipeline change: "The bot PAT must have merge or push access to the protected branch to create pipelines via the API endpoint." internal/poll/dispatch.go still calls CreatePipeline on PipelineRef (the protected default branch), and neither this PR nor the surrounding code queries or sets allowed_to_merge/allowed_to_push for that branch. Under GitLab's common default "Protected" preset (Developers + Maintainers can merge, Maintainers can push), a Developer-role PAT likely still satisfies the "merge access" half of that OR condition, so dispatch probably keeps working in the default case — but a project with a stricter branch-protection configuration (merge and push both Maintainers-only) would get a 403 on pipeline creation and agent dispatch would silently stop working after this change ships. Neither the ADR annotation in this PR nor the updated docs mention this residual dependency; they only address the CI/CD-variable rationale.
    Remediation: Document explicitly that Developer(30) depends on the target repo's branch protection granting Developers merge (or push) access to the default branch, and call out that a Maintainers-only merge+push configuration will break pipeline dispatch. Consider having install/converge verify or grant that access via the operator client, or fall back to Maintainer(40) when it can't be confirmed. Update the ADR 0067 annotation so the Replace GitLab bridge job with API-triggered dispatch #5556 CreatePipeline permission requirement isn't implied to be resolved by this change.

Low

  • [commit-message-type-mismatch] PR title — The title chore(#7381): delete poll-state branches; bot PAT Developer(30) may undersell the operator-visible behavior changes bundled here: repos uninstall for GitLab now deletes two branches it previously left behind, and the PAT expires_at computation is corrected from local-time to UTC (a real bug — a token could previously be born active:false). Per COMMITS.md, fix is for user-visible bug fixes; this PR arguably qualifies. That said, COMMITS.md also says "when in doubt, prefer refactor or chore over feat or fix," and this PR is largely completing a planned, multi-phase internal migration (gitlab: reduce bot PAT from Maintainer to Developer via branch-backed poller state #7343), so chore is a defensible reading too.
    Remediation: Optional — retitle to fix(#7381): delete poll-state branches; bot PAT Developer(30) if you want the UTC-expiry fix and uninstall cleanup to appear under Bug Fixes in the release notes.

  • [code-organization] internal/repos/uninstall.go:306 — deleteGitLabPollStateBranches builds an inline slice literal []string{poll.PollStateBranchSlash, poll.PollStateBranchEvents} instead of reusing the existing package-level gitlabPollStateBranches var already defined in internal/repos/install.go (same package, already reused by drift_test.go and status_test.go) for the identical branch pair.
    Remediation: Replace the inline slice with gitlabPollStateBranches.


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[bot]

This comment was marked as outdated.

@fullsend-ai-coder

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

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 12:40 PM UTC · Completed 12:51 PM UTC

Commit: a9f09b4 · View workflow run →

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

…se poll-state branch list

Address review feedback on PR #7400:

ADR 0067 and docs/cli/repos.md now call out that the Developer 30 bot
PAT still depends on the target repo's branch protection granting
Developers merge or push access to the default branch, since the
poller creates pipelines via CreatePipeline on that protected branch.
The number 5556 permission requirement is independent of the CI/CD
variable rationale this PR resolves. A Maintainers-only merge and push
configuration will 403 on pipeline creation; operators in that
situation need to grant Developer merge or push access, or keep the
PAT at Maintainer 40.

internal/repos/uninstall.go: deleteGitLabPollStateBranches now reuses
the existing package-level gitlabPollStateBranches var from
install.go instead of a duplicate inline slice literal, dropping the
now-unused internal/poll import.

Addresses #7400
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (bot-triggered)

Fixed the medium logic-error finding by documenting, in ADR 0067, docs/cli/repos.md, and a code comment, that the Developer(30) bot PAT still depends on branch protection granting Developers merge/push access to the default branch for pipeline dispatch to keep working. Fixed the low code-organization finding by reusing the existing gitlabPollStateBranches var instead of a duplicate inline slice in uninstall.go. Recorded reasoned disagreements on the optional verify/fallback code suggestion and the optional PR retitle suggestion, both explicitly framed as optional by the reviewer.

Fixed (2):

  1. logic-error: Developer(30) PAT drop doesn't address Replace GitLab bridge job with API-triggered dispatch #5556 CreatePipeline branch-access requirement (docs/ADRs/0067-gitlab-cron-polling-event-dispatch.md): Verified the concern against ADR 0067's Replace GitLab bridge job with API-triggered dispatch #5556 'New permission requirement' section and internal/poll/dispatch.go (still calls CreatePipeline on the protected default branch). Updated the ADR's gitlab poller state (3c/3): uninstall branch deletion + bot PAT -> Developer(30) #7381 annotation so it no longer implies the Replace GitLab bridge job with API-triggered dispatch #5556 requirement is resolved, explicitly stating that Developer(30) works under GitLab's default 'Protected' preset but a Maintainers-only merge+push config will break pipeline dispatch, and that this PR does not verify or grant that access. Added the same caveat to docs/cli/repos.md's 'GitLab bot token' section (with a link to the ADR) and expanded the code comment in internal/cli/repos_gitlab.go above the CreateProjectAccessToken call to flag the residual dependency. Did not implement the remediation's optional 'Consider having install/converge verify or grant that access ... or fall back to Maintainer(40)' suggestion — that is a larger behavioral change explicitly framed as optional, and is recorded as a separate disagreement below to keep this fix scoped to the documentation gap the finding centers on.
  2. code-organization: inline branch slice in uninstall.go should reuse gitlabPollStateBranches (internal/repos/uninstall.go): Confirmed gitlabPollStateBranches is already defined in internal/repos/install.go and reused by drift_test.go/status_test.go. Replaced the inline slice literal in deleteGitLabPollStateBranches with gitlabPollStateBranches and removed the now-unused internal/poll import from uninstall.go. go build, go vet, and go test -race ./internal/repos/ all pass.

Disagreed (2):

  1. logic-error remediation (optional): auto-verify/grant branch access or fall back to Maintainer(40): This is explicitly phrased as an optional suggestion beyond the finding's core ask (which was to document the residual dependency and correct the ADR annotation, both addressed above). Adding automatic branch-protection verification/grant or a conditional Maintainer fallback is a larger design decision — it changes install/converge behavior and API surface — and is out of scope for a targeted review-feedback fix. Left for a maintainer to decide as a follow-up if the documented caveat isn't sufficient.
  2. commit-message-type-mismatch: PR title chore(gitlab poller state (3c/3): uninstall branch deletion + bot PAT -> Developer(30) #7381) may undersell bug-fix content: The finding itself flags this as optional ('That said... chore is a defensible reading too'; remediation says 'Optional'). Per COMMITS.md, 'when in doubt, prefer refactor or chore over feat or fix', and this PR is completing a planned multi-phase migration (gitlab: reduce bot PAT from Maintainer to Developer via branch-backed poller state #7343), so chore remains a defensible choice. Retitling the PR is also a PR-metadata mutation outside the fix agent's scope (branches/PRs/titles are handled by the post-script or a human), so left unchanged.

Tests: passed

Decision points
  • Chose to address the logic-error finding purely via documentation (ADR annotation, docs/cli/repos.md, code comment) rather than implementing automatic branch-protection verification or a Maintainer fallback. (alternatives: Implement operator-client verification of branch protection and auto-grant Developer merge/push access, Fall back to Maintainer(40) whenever branch-protection access can't be confirmed, Document the residual dependency explicitly (chosen); rationale: The finding's mandatory remediation was documentation ('Document explicitly...', 'Update the ADR 0067 annotation...'); the verification/fallback behavior change was explicitly marked as an optional 'Consider' suggestion and would expand scope well beyond the review's core ask.)

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-review

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

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:53 PM UTC · Completed 1:12 PM UTC

Commit: ffb773e · View workflow run →

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

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

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

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 1:14 PM UTC · Completed 1:22 PM UTC

Commit: ffb773e · View workflow run →

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

Review found docs/cli/repos.md told operators facing a Maintainers-only
merge+push branch-protection setup to "pass a Maintainer-level
--gitlab-bot-token" to work around the Developer(30) pipeline-dispatch
403. That flag is not an access-level override: setupGitLabBotToken
always creates its own Developer(30) project access token when
CreateProjectAccessToken succeeds and only falls back to the provided
token when creation fails or no GitLab client is available
(internal/cli/repos_gitlab.go). On Premium/Ultimate the docs were
recommending a no-op.

Replace the workaround with options that actually work: grant
Developers merge/push access to the default branch, or manually
replace FULLSEND_FORGE_TOKEN in GitLab after install (converge never
re-touches an existing bot PAT on already-enrolled repos).

Addresses #7400
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 2 (bot-triggered)

Fixed the one active review finding: the GitLab bot-token doc section recommended passing a Maintainer-level --gitlab-bot-token to work around strict branch protection, but that flag is ignored whenever the automatic Developer(30) project-access-token creation succeeds (the common Premium/Ultimate path this PR ships). Replaced it with the two options that actually work and explained why the flag doesn't help. No code changes were needed or made; verified via secret scan, direct-execution pre-commit hook equivalents (docs-link lint, markdown-link lint via lychee, broken-symlink lint, EOF/whitespace checks), and a Go build sanity check of the touched packages.

Fixed (1):

  1. docs/cli/repos.md:133 recommends a non-functional --gitlab-bot-token workaround for strict branch protection (docs/cli/repos.md): Replaced the non-functional '--gitlab-bot-token' workaround sentence with the options that actually work: grant Developers merge/push access to the default branch, or manually replace FULLSEND_FORGE_TOKEN in GitLab after install (converge never re-touches an existing bot PAT on already-enrolled repos). Added a note explaining why --gitlab-bot-token doesn't help here (it's only a fallback for when project-access-token creation is unavailable).

Tests: passed

Decision points
  • Chose a docs-only fix over changing setupGitLabBotToken to honor --gitlab-bot-token as an override (alternatives: Fix the docs to remove the non-functional workaround and document real options, Change setupGitLabBotToken to accept --gitlab-bot-token as an override even when project-access-token creation succeeds; rationale: The review offered both remediations. Changing the token-creation logic would alter runtime behavior (which token gets minted and stored) beyond what this review finding required, and risks interacting with the existing revoke-then-create flow for the 'fullsend-bot' token name. The docs fix is minimal, addresses the reviewer's core complaint (docs recommend a no-op), and matches the reviewer's first-listed remediation option.)

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-review

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

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 1:24 PM UTC · Completed 1:35 PM UTC

Commit: 5ac9bf2 · View workflow run →

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

@fullsend-ai-review
fullsend-ai-review Bot dismissed stale reviews from themself September 17, 2026 13:35

Superseded by updated review

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Sep 17, 2026
@ggallen
ggallen added this pull request to the merge queue Sep 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 17, 2026
@ggallen
ggallen added this pull request to the merge queue Sep 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 17, 2026
@ggallen
ggallen added this pull request to the merge queue Sep 17, 2026
Merged via the queue into main with commit f596fd6 Sep 17, 2026
54 checks passed
@ggallen
ggallen deleted the agent/7381-gitlab-pat-developer-uninstall branch September 17, 2026 14:38
@fullsend-ai-retro

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

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 2:40 PM UTC · Completed 2:47 PM UTC

Commit: 5ac9bf2 · View workflow run →

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

@fullsend-ai-retro

Copy link
Copy Markdown

PR #7400 (GitLab poller-state phase 3c: delete poll-state branches on uninstall, lower bot PAT to Developer(30)) is part of a 3-phase sequence under parent #7343 (preceded by #7383/phase 3a and #7395/phase 3b). The workflow ran 9 agent dispatches (3 triage, 1 code, 3 review, 2 fix, ~$27 total, ~3h13m active elapsed from unblock to merge). Review quality was strong: Review #1 caught a real medium-severity gap (Developer(30) PAT may still lack merge/push rights under strict branch protection) plus a minor code-organization nit; the fix agent addressed both but its own documentation edit introduced a non-functional workaround (--gitlab-bot-token, which is a no-op on this PAT-creation path); Review #2 caught that self-inflicted regression; the fix agent corrected it; Review #3 approved clean. The review/fix loop resolved everything autonomously before human review. ggallen (human, MEMBER) approved with no comments on all three phase PRs (#7383, #7395, #7400) — per autonomy-readiness analysis, a silent approval is inconclusive (absence of comments isn't evidence the agent matched or exceeded human review, nor is it evidence of a rubber stamp), so this does not by itself support an autonomy-increasing proposal. Two efficiency patterns observed here are already tracked: (1) Review #3 cost $2.86 to re-verify a one-line docs-only correction (the fix agent's own prior doc mistake) — this is new evidence for fullsend#1900 ('fast path for trivial docs/prompt-only changes'), which already proposes skipping full-cost review for exactly this class of trivial-but-changed diff; adjacent issues fullsend#6891 and agents#301 cover related trivial-change fast-path work. (2) The fix agent documented a CLI flag's behavior without verifying it against the source, producing incorrect guidance that a later review caught — this is new evidence for fullsend#1322 ('Code agent should validate CLI flag semantics in documentation against source code'), an open near-exact match. The parent-tracking-issue/sequential-sub-PR autonomy pattern (clean agent review + silent human approval across all three phase PRs) matches the framing already tracked in fullsend#4627 and the consolidation meta-issue fullsend#7339; no new proposal is warranted since (per the autonomy-readiness skill) silent approvals don't independently strengthen that case. No new proposals are filed this run — the workflow performed well and the identifiable improvement opportunities are already captured by open issues.

This branch was successfully deployed

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

Labels

ready-for-merge All reviewers approved — ready to merge 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.

gitlab poller state (3c/3): uninstall branch deletion + bot PAT -> Developer(30)

1 participant