Principles distiller: re-runs on adopted branches discard reviewer hand-fixes
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
When a run reuses an open MR's branch, it rebuilds the branch from origin/master and force-pushes over it. Any reviewer hand-fixes on that branch are lost, and the review loop flags the same findings again.
Mechanism
commit_and_push force-pushes the regenerated branch. prefetch_adopted_branches! only logs a warning when the branch tip was authored by someone other than the service account.
Confirmed instance
In job 16894183788, the run logged adopted branch docs-sync/principles-20261001-qa tip 44966d996386 was authored by Pedro Pombeiro ...; the generated force-push will discard that commit. The force-push dropped two hand-fixes that Duo had already confirmed on !259075 (merged) (5ed75e7c, 44966d99). Duo then flagged the regression, and I restored the fixes by hand in 58f43fa9.
Proposal
When an adopted branch has commits that the service account did not author, choose one of these:
- Skip re-distilling that slug and leave the MR untouched.
- Rebase the human commits onto the regenerated commit, and fail the slug if they conflict.
Implementation status
Draft MR: Preserve reviewer fixes on distillation branches implements the overwrite-prevention fix. It skips publication of adopted branches containing reviewer commits or unverifiable ownership, stops publication when account or MR discovery fails, uses explicit push leases, and leaves existing MRs open when regeneration produces no changes. Local verification passed: 693 gem specs, targeted RuboCop, and whitespace checks.
The MR does not restore the four content gaps below. They remain outstanding and must be delivered separately; merging the overwrite-prevention fix alone does not complete this issue.
Remaining content restorations from the 20261027 review
Quintasan approved the QA sync head 3bcdc985 and requested these non-blocking restorations in this follow-up. All four remain supported at the output's source revision, 8f7fe15d:
-
workers.md: restore the instance-configurableconcurrency_limitbacked byApplicationSetting.current, with a Self-Managed default and a GitLab.com-only migration in the same MR when different limits are needed. Source. -
backend-architecture.md: restore that omitted ornilrate-limit characteristics use LabKit's_unknown_sentinel. Do not require every characteristic to be supplied. Source. -
backend-architecture.md: restore the documentation destinations for plan/instance limits and rate limits configurable through the Admin area, API/Rails console, or not configurable. Source. -
testing-rspec.md: restore the missing half of thebuild_stubbedcaveat: custom factory attributes and callbacks can still access the database. Preserve the existing exception for code that persists the object or requires real association records. Source.
Validate these restorations against the source revision used by the follow-up, preserve tool-generated front matter, and verify that a subsequent adopted-branch run does not discard them again.