Skip to content

fix: preserve integrated delivery during Project events - #10971

Closed
he-yufeng wants to merge 3 commits into
AstrBotDevs:masterfrom
he-yufeng:fix/project-merged-event-delivery
Closed

he-yufeng wants to merge 3 commits into
AstrBotDevs:masterfrom
he-yufeng:fix/project-merged-event-delivery

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10970

Summary

Keep bounded Issue/PR event reconciliation consistent with delivery() when calculating 交付进度.

The previous event-only override had two failure modes:

  • A merged PR subject became 尚未合入 because the linked-PR map is keyed by issue number and does not include the PR itself.
  • An Issue became 已合入待发布 whenever any linked PR was merged, even if its merge commit was unreachable from the trusted default branch.

Event runs now retain the integrated delivery result, including all associated PR and ancestry checks. Stable-release lookup remains deferred to full scans, and stale release fields are still cleared when implementation links change.

Tests

  • Added a merged PR event regression: the old code returns 尚未合入, while the fix returns 已合入待发布.
  • Added an Issue event regression with an unreachable merge commit: the old code returns 已合入待发布, while the fix returns 尚未合入.
  • python3 -I tests/test_sync_github_project.py -v: 16 passed.
  • python3 -I tests/test_project_delivery.py -v: 28 passed.
  • python3 -I tests/test_project_events.py -v: 10 passed.
  • Ruff format and lint checks pass on the changed Python files. git diff --check passes.

No live Project mutation was attempted.

Summary by Sourcery

Preserve accurate integrated delivery status during Project event reconciliation while continuing to defer release verification to full scans.

Bug Fixes:

  • Preserve integrated delivery results during Project event reconciliation by applying the same merge and ancestry checks as full delivery scans.
  • Prevent merged PRs from being reported as not integrated and prevent unreachable merged commits from being reported as integrated.

Enhancements:

  • Clarify that event reconciliation requires associated merge commits to be reachable from the trusted default branch before reporting pending release status.

Documentation:

  • Document the trusted-branch reachability requirement for event-based delivery status.

Tests:

  • Add regressions covering merged PR events and issues linked to unreachable merge commits.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Linked issues

#10970 Project event sync misreports merged delivery progress · 3 of 3 met

# Requirement Status Notes
1 A merged PR event uses the PR subject and merge-commit ancestry when calculating delivery progress. ✅ Met Event reconciliation now keeps the result from delivery(), which evaluates a PullRequest subject itself and checks its merge commit against the trusted mainline.
2 An Issue event reports integrated delivery only when all associated merged PR commits are reachable from the trusted default branch. ✅ Met The event-only any(MERGED) override is removed; delivery() checks the associated PRs and their merge-commit ancestry.
3 Event runs defer stable-release lookup and clear stale release fields when implementation links change. ✅ Met Release lookup remains limited to full scans; event reconciliation preserves existing published fields only when the implementation links are unchanged, otherwise it clears them.

Sourcery assessment

Needs a human reviewer. A faulty event reconciliation could leave a Project item showing the wrong delivery progress, because the field is stored on the item. A later sync can recompute and correct it, so the error is bounded and repairable.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@Soulter Soulter moved this to In Progress in AstrBot Roadmap Nov 3, 2026
@he-yufeng

Copy link
Copy Markdown
Contributor Author

The Windows failure is isolated to tests/unit/test_trace_store.py::test_capacity_prunes_complete_traces_with_cascade: persisted.flush() returned False at line 594, with 5,283 tests passing and this as the only failure. This PR does not touch the trace store; the changed files are scripts/sync_github_project.py, its tests, and .github/PROJECT_SYNC.md. The same Windows suite passed on #10965 today.

I attempted to rerun only the failed job, but GitHub returned Must have admin rights to Repository. Could a maintainer rerun the failed Windows job? No Project event assertion failed in this run.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The conflict was in .github/PROJECT_SYNC.md, which upstream restructured from
a bullet list into numbered setup steps plus a rules table. Took the upstream
structure and re-applied this branch's sentence to the corresponding rule, so
the doc keeps upstream's organization rather than reverting it:

  Event runs preserve an existing release result while implementation links
  are unchanged. They still require every associated merge commit to be
  reachable from the trusted default branch before reporting 已合入待发布;
  a merged state alone is not integration evidence.

scripts/sync_github_project.py merged without conflict and the deletion this
PR makes is intact: the event-run branch no longer overwrites 交付进度 from
pr["state"] == "MERGED" alone, so the value computed by delivery(), which
already checks ancestor(commit, mainline), is what gets written.

Offline suites on the merged tree, no credentials:

  tests/test_project_events.py        10 tests OK
  tests/test_sync_github_project.py   16 tests OK
  tests/test_project_delivery.py      28 tests OK

Red-green through the merged tree: restoring the upstream
sync_github_project.py fails
test_issue_event_keeps_unreachable_merge_out_of_integrated_delivery
('已合入待发布' != '尚未合入') and
test_merged_pr_event_marks_integrated_delivery_pending_release
('尚未合入' != '已合入待发布'); restoring this branch's file passes all 10.
The file is byte-identical to its pre-probe state afterwards.
@sourcery-ai

sourcery-ai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 2b44bc9

#10970 Project event sync misreports merged delivery progress · 3 of 3 met

# Requirement Status Notes
1 A merged PR event must use the PR’s integrated delivery result, including checking whether its merge commit is reachable from the trusted default branch. ✅ Met The event-only progress override is removed, so delivery() evaluates the PR subject and its merge commit.
2 An Issue event must not report 已合入待发布 for a linked merged PR whose merge commit is unreachable from the trusted default branch. ✅ Met delivery() checks ancestry for each associated merged PR before reporting 已合入待发布.
3 Event runs must defer stable-release lookup and clear stale release fields when implementation links change. ✅ Met Release lookup remains limited to full scans; event reconciliation preserves an existing release when links are unchanged and clears release fields otherwise.

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Merged current master (133dd9f86); the branch is now 2b44bc90e and GitHub reports it mergeable.

The conflict was in .github/PROJECT_SYNC.md, which upstream restructured from a bullet list into numbered setup steps plus a rules table. I took the upstream structure and re-applied this branch's sentence to the corresponding rule rather than reverting the reorganization:

Event runs preserve an existing release result while implementation links are unchanged. They still require every associated merge commit to be reachable from the trusted default branch before reporting 已合入待发布; a merged state alone is not integration evidence.

scripts/sync_github_project.py merged without conflict and the deletion is intact. The event-run branch no longer overwrites 交付进度 from pr["state"] == "MERGED" alone, so the value computed by delivery() is what gets written, and that function already gates on ancestor(commit, mainline).

Offline suites on the merged tree, no credentials:

tests/test_project_events.py        10 tests OK
tests/test_sync_github_project.py   16 tests OK
tests/test_project_delivery.py      28 tests OK

Red-green through the merged tree, not just the original base: restoring the upstream sync_github_project.py fails two cases with the exact inversions this PR is about,

test_issue_event_keeps_unreachable_merge_out_of_integrated_delivery
  AssertionError: '已合入待发布' != '尚未合入'
test_merged_pr_event_marks_integrated_delivery_pending_release
  AssertionError: '尚未合入' != '已合入待发布'

and restoring this branch's file passes all 10. The file is byte-identical to its pre-probe state afterwards (sha256 47d6f24a0385…).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Project event sync misreports merged delivery progress

3 participants