Commit Graph
19 Commits
Author SHA1 Message Date
Aleksei Sviridkin 50959ccca2 chore(backport): discard temp-file cleanup errors explicitly
A temporary file or directory that cannot be removed, or closed after
its write already failed, leaves nothing to act on: the run's result is
the same, and the primary error is the one returned. The test that
unsets an environment variable now fails if it cannot.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 12:35:02 +03:00
Aleksei Sviridkin f99e511eea fix(backport): fail a run whose output could not be written
Every report, check and verify result goes to stdout, and every write
error there was dropped, so a run whose output never reached its
reader still exited 0. The terminal writer now keeps the first stdout
error, and the run fails with it unless it already failed. Only stdout
is tracked; a write error on stderr is still discarded.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 12:34:57 +03:00
Aleksei Sviridkin 2cda7d692e test(backport): drop an unused fixture helper
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 11:37:43 +03:00
Aleksei Sviridkin 4c3a4b42cc style: clear unused code and style findings reported by staticcheck
Remove helpers and constants nothing references, escape format
characters in test literals, and take the simplifications staticcheck
suggests where they read the same. Error strings no longer start with a
capital: they keep their meaning, with the kind or component name moved
out of first position. Callers match errors by type, not text; the one
test that matches text, for Kafka, keeps the phrase it looks for.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 11:37:41 +03:00
myasnikovdaniil 0f169540a1 feat(release): withhold partial backports and park those that build on code their line lacks (#5269)
## What this PR does

Stacked on #5264, that one merges first.

Clean cherry-pick doesn't mean the original landed. On release-1.6 the
batch carried a fix whose two deletions hit files the line never had, so
only its test arrived. Other originals conflicted on every run because
they change code that never reaches the line. Batch now tells these
cases apart instead of picking half a fix or retrying a conflict nobody
can resolve.

- Every file an original modifies or deletes is checked at its
counterpart on the line, renames followed on both sides. If part of the
original has no effect there (change to a file the line lacks, deletion
of a file it never had, deleted file the unit keeps), the original is
parked as partial and its release note stays out. A file that already
matches what the original makes counts as there (same blob, binary too,
or clean `git merge-file`). This runs in the picker, `fold`, `verify`
and over units already on the open batch, so such a unit fails `check
--cut` whatever its label until `run --defer` takes it out.
- Pick that differs from its original keeps its release note under
"Check these notes" with a `git range-diff` command to compare, record
and report mark it `changed`.
- Run names what an original builds on that the line lacks: the commit
on `main` that added a file the fix modifies or deletes, and blame of
removed lines whose text is still missing on the line. Generated files
and generated keys of ApplicationDefinitions are skipped. Lines a fix
only adds are not checked, a dependency that lives only there still
needs `--drop`.
- If a prerequisite never reaches the line (`feat`, direct push,
excluded or itself parked) the original is parked and not tried. If it
is still to come, the original waits for it and is retried later.
Prerequisites the line or open batch already carry, or this run picked,
count as there. `run`, `check` and record-only commands decide in the
same order. On scheduled run a workflow original whose only missing
dependency is in tests or docs waits for a maintainer instead of
parking. `backport/include` lifts neither park, wait nor partial.
- `notify` announces each park once on the open batch and marks it in
the record, nothing is announced while no batch is open.

Record moves to version 3 and report to format 2, format 1 reports still
read. I ran the new tool next to the previous one without `--push` on
today's history. On release-1.7 nothing changes category and `check`
prints the same. On release-1.6 #5071 is parked on the two features it
builds on, #5088 already on the open batch now fails the cut as a
partial unit, and #5142 on scheduled run still waits for a maintainer
with a note that only its tests depend on what 1.6 lacks. Rule 6 holds
twelve originals on 1.6 right now, run over them directly flags the
seven that change code 1.6 never got and none of the other five.
Detection adds under 2 s per line.

After this merges, CI on the open 1.6 batch goes red at its next push
since `verify` refuses #5088 there. `run --line release-1.6 --defer 5088
--reason ... --push` takes it out.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
feat(release): backport batch holds back a pick that applies only part of its original and fails the cut on such unit already on a batch, sets apart the note of a changed pick, parks an original that builds on code its line never gets, waits for one whose prerequisite is still to come, and announces each park once.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Backport batches now identify partial picks and missing prerequisites,
and can park affected originals or leave them waiting.
* Batch reports and notifications provide details about parked, partial,
changed, and waiting picks.
* Release notes for picks that differ from their originals are set apart
for review.
* **Bug Fixes**
* Verification, folding, and batch checks reject picks that omit effects
from the original; renamed paths are supported.
* **Documentation**
* Updated backport guidance to explain parking, prerequisites, partial
picks, and release-note checks.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-13 13:14:12 +05:00
Aleksei Sviridkin 9fe06a874b test(release): isolate report deduplication from workflow attempts
CI reruns expose GITHUB_RUN_ATTEMPT to a test that expects a URL for
the first attempt. Keep its synthetic run identity independent of the
surrounding workflow.

Fixes: 5a997fb7d4 ("feat(release): post an immutable report of every classification and write record version 2")
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-11 15:35:18 +03:00
Myasnikov Daniil 885752eb5a feat(release): announce a parked original once on the open batch
A park is a decision a maintainer has to act on: port what applies as
a pull request of its own, or drop the original. Listing every park in
every notify comment would make that list noise within a week, and a
park nobody hears about is a fix that silently never ships.

notify now names each park the open batch's record holds that is not
yet marked announced, and once its comment is written marks those parks
in the record with gh pr edit --body-file. It writes only while the
pull request is open and its body still carries the record notify read,
so a run that rewrote the body in between loses nothing; a mark that
fails exits 2 and the next notify names the park once more. run carries
the mark into the next record, a merged or closed carrier's too, only
while the park is the same event: merge, kind, prerequisites, commits
and files. A park that changed is news and is named again. With no
batch open nothing is named (M2); the next batch's first notify does
it.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-10 11:11:15 +00:00
Myasnikov Daniil ce4ab1fd2c feat(release): park an original whose dependency never reaches its line, and hold one whose dependency is pending
On 1.6, the fix in #5071 conflicts on every run: it modifies files
that the feat in #3940 added on main, and that feat never reaches the
line. The fix in #5082 builds on #5071 and on code that never comes
either. Trying them on each run says nothing a maintainer can act on,
and a conflict reads as work to do.

Edges come from the dependencies the previous commit reads. One whose
prerequisite the line or the open batch carries, whatever its rule or
label, that this run picked or found empty, or whose evidence is
present at the branch head once earlier picks moved it, is satisfied
and dropped first. A direct push, an original rules 2-4, the start, a
skip label or a drop keep out, or one itself parked never comes and
parks the original. A prerequisite still to come (a conflict, a
deferral, a workflow wait, rule 6) holds it as deferred{needs}, the
strongest kind deciding: missing, workflow, deferred, rule 6; a chain
inherits.

run, check and the metadata operations share one order: partial unit
on the batch, a direct reason, an unpicked partial, the workflow
exception, a dependency park, a wait, then the original's own state.
In the scheduled mode a workflow original whose remaining
never-dependencies are only tests or docs waits for a maintainer
instead of parking, which is the case of the release fix in #5142.
check takes the mode the open record saved, and the scheduled one
with no batch open, where a closed record's workflow waits wait on
nothing any more and the original is judged as the scheduled run
judges it. check and the record-only operations keep a partial park
the open record holds while the batch head still shows it, since only
the run's picker sees it after the picks before it. Records refuse
waits and parks that form cycles, point at later merges or contradict
each other. notify lists a wait after what decides it, from the
record alone. backport/include lifts neither park nor wait.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-10 11:11:15 +00:00
Myasnikov Daniil 4a909818e4 feat(release): name what an original builds on that its line lacks
On 1.6, seven of the twelve originals rule 6 holds back build on code
the line never got: #5071 changes files #3940 added on main, #4974
reads a variable only #4386 defines. Each conflicts on every run, and
nothing tells a maintainer which missing pull request the conflict
comes from, which every human backport so far had to work out by hand.

For each original the policy takes and nothing carries, run now reads
what it builds on from git alone. A modified or deleted file the line
lacks is named by the first-parent commit on main that added it (V1).
A removed or changed line is blamed at M^1, mapped to the first-parent
commit that brought the blamed commit, and kept only while its text,
edges trimmed, is absent from the line's file (V2c), so a hand backport
under another SHA clears it. Generated files and the keys
update-crd.sh writes into an ApplicationDefinition are not blamed.

Paths go to git literally, blame gets a validated full SHA and no
--end-of-options, which git refuses there, and every call has a
two-minute deadline. Caps, deadlines, binary files, symlinks,
submodules, unmapped commits and skipped rename detection become
diagnostics shown with the original on every outcome and in the
report; malformed git output stops the run. This commit only
annotates; nothing is parked yet.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-10 10:58:42 +00:00
Myasnikov Daniil 6696953d26 fix(release): set aside the note of a pick that differs from its original
A release note describes what the original does on main. A pick git had
to fit to a line that already had part of the change, a resolution, or
a unit whose first commit came out empty no longer does the same thing,
yet its note went into the batch's release-note block with the rest,
and the changelog took it from there.

A unit now counts as changed when a surviving pick's patch-id differs
from its source or the unit's net patch-id differs from the original
merge's; the latter catches an empty first commit, which leaves no pick
to compare. A changed original's note moves under "Check these notes",
fenced and neutralised as before, with a range-diff per differing pick
and the two diffs to compare. The range-diff uses a creation factor of
999 because the default leaves a pick that lost most of its change,
#5088's test-only pick for one, unpaired. The record and the report
list such originals as changed.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-10 10:58:32 +00:00
Myasnikov Daniil c617a99453 fix(release): withhold or refuse a unit that does only part of its original on the line
A clean cherry-pick says nothing about whether the original landed
whole: git deletes a file the line never had without a conflict and
leaves a file the line lacks untouched. #5088 reached the 1.6 batch
that way, carrying only its test while the two deletions that are the
fix had no effect.

Every M and D path of an original is now judged at its counterpart on
the line, followed through renames on main, on the line, or both. A
modified path missing before and after, or left unchanged when the line
holds neither the original's blob nor a clean git merge-file result, is
omitted; a deleted path absent before is omitted. Content merge-file
refuses, mode changes and skipped rename detection become diagnostics
and never count as omissions; I/O failures stop the command.

The same guard runs in four places: the picker, which resets a partial
pick and parks the original; a check-time pass over every unit on the
open batch at its own first parent, whatever its label, which fails
check --cut and verify; the same pass over every unpicked original's
clean net merge, which parks a partial one with no record needed; and
fold. contained accepts the renamed path, so a fix of a renamed file
passes verify and fold. The unit mapping also closes the found() gap: a
merged original whose first pick came out empty is on the batch, not
missing.

The record moves to version 3 with parked entries and partial units,
and reports to format 2 with typed parked entries; format 1 reports
still read.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-10 10:58:32 +00:00
Myasnikov Daniil 2c1cb2f41c feat(release): drop an original from one line with run --drop
A fix the rules take for every line can still be wrong for one of
them, typically because it builds on code that line does not have.
The only ways to keep it out were backport/skip, which keeps it off
every line, and --defer, which holds it out of one batch: the next
batch tried it again, and a conflict that would never resolve came
back every run.

run --drop N --reason R records a drop in the line's record, bound to
the original's merge commit on main, and every later record carries
it, a new batch's included. What the open batch carries of a dropped
original comes off it the way --defer takes one off; any other drop
changes only the record, so a batch on a line that moved since stays
where it is. --undrop withdraws one. Both need an open batch, as every
write to the record does.

A drop comes after the rules and the carries: backport/skip, rules 2
to 4 or the line itself decide first and the drop stays on record,
and backport/include does not lift it. check notes a dropped original,
the body lists it, fold refuses it, and a record whose drop names
another original's merge stops every command. Each report keeps the
record's drops with the merge commit each is bound to and its reason,
held on read to the same rules, so an earlier report still says why
after an undrop.

A reason now travels from a body to terminals, bodies and comments, so
a reason or a file name in a record is believed only in the form a run
writes it, one clean line, and so is a report's diagnostic. Output
that repeats a reason, file names, a report ID or a state GitHub
reports escapes it.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-10 07:20:32 +00:00
Myasnikov Daniil 79b335e461 fix(release): close the batch --defer leaves empty, recording why while it is open
docs/release/backport-tasks/failed-ci.md says to defer the culprit with
run --defer --push. When the culprit was all the batch carried, the
push stopped with "close batch pull request #N instead", and closing
it by hand left nothing that said why: once closed, the deferred
original was simply missing.

The run now closes the batch itself, and does every write while the
pull request is open: the report, then the body, whose record keeps
the deferrals and says the batch is closing, at the head the rebuild
started from. The close and the deletion of the branch go only while
GitHub and the remote still show that head, and the deletion is
leased on it.

A close that stops part way is finished by the next run --push, before
anything else, and by no other command; a head the close did not
freeze is refused, never adopted. The run that finishes it stops
there, and fails when it was asked for --defer, since no open batch
is left to defer on. Recovery never writes the closed
pull request. A same-day batch that reuses the branch name and fails
to open its pull request leaves a branch the next run names for a
person to delete.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-10 07:20:00 +00:00
Myasnikov Daniil 5a997fb7d4 feat(release): post an immutable report of every classification and write record version 2
Each run rewrote the batch body whole, so the only account of what a
run found was gone at the next run, and a merged batch kept only its
last one. Nothing said what a classification was made of either: not
the heads it read, the policy, the tool or the flags.

A run now makes a report: every original merged into main since the
line branched, in exactly one category, with what the run read. Its
ID hashes the classification and names no pull request, so a new
batch's report is whole before GitHub numbers the pull request, and a
run that finds the same as the last one makes the same report, which
is posted once and keeps its first bytes. The body carries the latest
report under the record; a comment the tool never edits keeps each
one, so report reads any of them back, from merged batches too.

The comment goes up before the push and the body edit on an open
batch, and after the pull request a new batch opens with the report in
its body; a later run posts a report the body kept but no comment did,
byte for byte, before its own. Every write is preceded by a read of
the pull request, and nothing is written once it is merged or closed.
Both the comment and the body are rendered and measured before the
first write, so an oversized one stops the run with nothing written.

The record becomes version 2: what it was built from, with the run's
--no-workflow-files, which --defer keeps rather than resets, and the
report it goes with.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-10 07:20:00 +00:00
Myasnikov Daniil 5945d2ddd1 feat(release): read a line's record from its newest batch pull request in any state
The deferrals a batch recorded were read only from the open batch pull
request. Once it merged, a conflict it had deferred showed as missing
and failed check and the cut, until some later run picked something
else and opened a new batch; a run that picked nothing opened none.

run, check, fold and notify now find the line's record in the newest
batch pull request whatever its state: one opened from a batch branch
of this repository by an author the batch trusts. A record that is in
doubt stops the command instead of letting it fall back to an older
one: a block by an author no longer trusted, a bot's batch whose block
was removed, a record that does not read whole, a closed record newer
than the open batch, or no record within the pages read.

The record is still written only to the open batch, and a merged or
closed batch is never written again, so a run that picks nothing with
no batch open keeps nothing and says so. The reader takes the version
2 record the next change writes; the writer stays at version 1.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-09 15:03:43 +00:00
Myasnikov Daniil 3fc444874e fix(release): print the batch pull request's URL when --push publishes it
run --push opened or updated the batch pull request and said nothing
about which one, so the scheduled job's log and a maintainer's
terminal had no link to follow. gh pr create prints the URL; the run
now passes it on, on stderr, so stdout stays the body alone, which the
scheduled script saves as it is. An update prints the open pull
request's URL.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-09 14:54:47 +00:00
Myasnikov Daniil 015fc51c0d fix(release): name policy rules instead of internal numbers in output
fold, run --defer and the run's own stderr printed "rule 101" for an
original merged before its line started under the policy, and "rule
100" for backport/skip. Those numbers exist only inside the tool; the
policy has six rules, so a reader looking for rule 101 finds nothing.
Output now names such a rule in words, and the policy's own rules by
their number.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-09 14:53:29 +00:00
Myasnikov Daniil 35c47f20c1 fix(release): fail check --cut while a workflow original waits alone
check --cut returned 0 whenever nothing was missing and nothing was
only on the batch, so a workflow original waiting for a maintainer
passed the cut once the pick beside it was labelled backport/skip or
reached the line by hand. The waiting original was not even printed:
the case that held it swallowed the warning the plain check gives.

check now sorts every original into one disposition and exits once,
so a wait fails the cut on its own. A backport/skip original the open
batch still carries is named with the run --defer that takes it out.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-09 14:52:13 +00:00
Myasnikov Daniil 9f8c88b4f1 feat(release): build the backport batch with backport-batch
The rules need a tool that applies them the same way on every run and
shows what it did. backport-batch reads main's first-parent history,
judges each pull request by the policy block it reads from the page on
main, and picks what qualifies onto one batch branch per line. Each
original lands as its own commits under a merge that names it, so
authors and sign-offs survive and the line's own history shows what it
carries.

check is the gate before a cut. fold holds a hand resolution of a
conflict to the batch's shape, verify holds a whole batch to it, and
notify reports what waits on the batch for a maintainer.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-06 12:33:36 +00:00