Skip to content

feat: add Project delivery synchronization - #10905

Merged
zouyonghe merged 5 commits into
AstrBotDevs:masterfrom
zouyonghe:feature/project-delivery-sync
Oct 31, 2026
Merged

zouyonghe merged 5 commits into
AstrBotDevs:masterfrom
zouyonghe:feature/project-delivery-sync

Conversation

@zouyonghe

@zouyonghe zouyonghe commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Reconcile GitHub Issues and PRs into Projects with separate status and delivery tracking.
  • Add event-driven sync, six-hour reconciliation, and manual dry-run/apply.
  • Link implementation PRs and verify merged commits against the default branch and stable releases.
  • Document required Project fields, variables, and secret setup.

Verification

  • 30 focused offline tests pass.
  • Full repository Ruff checks and Actionlint pass.
  • Fork GitHub Actions Unit Tests pass on macOS, Ubuntu, and Windows (run 41202194647).

Live Project/API behavior still requires maintainer configuration and preview.

Summary by Sourcery

Add secure GitHub Project synchronization for issue and pull request lifecycle and delivery tracking.

New Features:

  • Synchronize GitHub Issues and pull requests with GitHub Projects using lifecycle status and delivery progress tracking.
  • Verify implementation delivery through merged commits, default-branch ancestry, and stable release ancestry.
  • Support event-driven reconciliation, scheduled full scans, and explicit manual preview or apply modes.],
  • bug_fixesต้อง? []
  • enhancements בט?
  • build []
  • ci [

Enhancements:

  • Validate Project schema, paginate API results, serialize runs, and report mutation outcomes safely.
  • Restrict privileged synchronization to trusted default-branch code and environment-scoped credentials.

CI:

  • Add a network-free regression workflow for synchronization tests.

Documentation:

  • Document Project fields, configuration variables, credential setup, operational boundaries, and rollout guidance.

Tests:

  • Add comprehensive offline coverage for delivery logic, event scoping, pagination, failure handling, security, and workflow configuration.

@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 found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/project-sync.yml" line_range="27-28" />
<code_context>
+
+# Every run reconciles the whole project; serialize snapshots, not just items.
+concurrency:
+  group: project-sync-${{ github.repository }}
+  cancel-in-progress: false
+
+jobs:
</code_context>
<issue_to_address>
**Closed items never reach the Project**

When overlapping event runs replace a pending run whose subject is an untracked item that has closed, the replacement run scans only its own event subject, and scheduled scans also omit untracked closed items, so the replaced item is never imported into the Project.

Ensure reconciliation discovers untracked closed items independently of the event subject, or otherwise guarantees every event subject is processed.

Also at `scripts/sync_github_project.py:442-456`.
</issue_to_address>

### Comment 2
<location path="scripts/sync_github_project.py" line_range="131-133" />
<code_context>
+    elif state == "CLOSED":
+        status = "Cancelled" if content.get("stateReason") == "NOT_PLANNED" else "Done"
+    elif "status:needs-verification" in content.get("labels", []):
+        status = "Needs verification"
+    elif "status:needs-info" in content.get("labels", []):
+        status = "Todo"
+    elif linked and all(pr["state"] == "MERGED" for pr in linked):
+        status = "Needs verification"
+    elif linked:
+        status = "In progress"
+    elif status not in STATUS_OPTIONS or status in {
+        "Done",
</code_context>
<issue_to_address>
**Reopened issues skip Todo**

When a terminal issue is reopened while it still has linked active or merged PRs, `decide` evaluates linked PRs before resetting terminal statuses, so a reopened issue previously marked Done, Cancelled, or Closed unmerged becomes In progress or Needs verification when it still has linked PRs. The Project status does not return to Todo as documented.

Apply the reopened-terminal reset before linked-PR status inference.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and a mistaken reconciliation can write incorrect Status, delivery progress, links, or release details that remain in the GitHub Project after this workflow is reverted. Those changes are bounded and can be corrected by rerunning a fixed sync or editing the fields; the workflow does not modify or delete source issues or pull requests.

Blocking findings: .github/workflows/project-sync.yml:28, scripts/sync_github_project.py:133


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

Comment thread .github/workflows/project-sync.yml Resolved
Comment thread scripts/sync_github_project.py Resolved
@zouyonghe

Copy link
Copy Markdown
Member Author

@sourcery-ai review

@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 found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/project-sync.yml" line_range="38" />
<code_context>
+    timeout-minutes: 30
+    steps:
+      - name: Validate manual branch
+        if: github.event_name == 'workflow_dispatch' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
+        run: |
+          echo 'Manual sync must run from the default branch.'
</code_context>
<issue_to_address>
**Non-default dispatch can expose token**

When a repository writer dispatches the workflow from a branch containing a modified workflow file, the branch check is part of the workflow definition selected for `workflow_dispatch`, so a writer can dispatch a modified non-default-branch copy that removes the check and runs attacker-controlled steps with `ASTRBOT_PROJECT_TOKEN`; the Project credential is exposed.

Restrict the credential to a protected environment that only permits the default branch, and require that environment before any job can access the token.
</issue_to_address>

### Comment 2
<location path=".github/workflows/project-sync.yml" line_range="44" />
<code_context>
+    runs-on: ubuntu-latest
+    timeout-minutes: 5
+    steps:
+      - uses: actions/checkout@v7
+        with:
+          persist-credentials: false
</code_context>
<issue_to_address>
**Mutable actions can expose sync token**

When an upstream action tag is moved to or compromised with malicious code, the action references resolve mutable upstream tags before the token-bearing step. Compromised action code can replace the checked-out sync script, which then runs with `ASTRBOT_PROJECT_TOKEN` and can exfiltrate it.

Pin both actions to verified full commit SHAs and update them through reviewed SHA changes.

Also at `.github/workflows/project-sync.yml:54`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and if the reconciliation logic is wrong, it can write incorrect status, implementation links, or release details to Project items. Those values persist after a revert, but a later sync can recalculate and repair them.

Blocking findings: .github/workflows/project-sync.yml:38, .github/workflows/project-sync.yml:44


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

Comment thread .github/workflows/project-sync.yml Resolved
Comment thread .github/workflows/project-sync.yml Resolved
@zouyonghe

Copy link
Copy Markdown
Member Author

@sourcery-ai review

@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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="scripts/sync_github_project.py" line_range="49-50" />
<code_context>
+            for key in path:
+                data = (data or {}).get(key)
+        if not isinstance(data, dict):
+            raise RuntimeError("GitHub connection is inaccessible")
+        nodes.extend(node for node in data["nodes"] if node)
+        page = data["pageInfo"]
+        if not page["hasNextPage"]:
</code_context>
<issue_to_address>
**Error handling sits outside main**

When the new synchronization encounters inaccessible or stalled pages, ancestry errors, or GraphQL failures, when GitHub pages are inaccessible or stalled, ancestry checks fail, or GraphQL requests return errors, `connection`, `ancestor`, and `graphql` handle those cases outside `main`, contrary to the repository guidance.

Handle these edge cases and errors directly in the main function block instead of in helper functions.

Also at `scripts/sync_github_project.py:55-56`, `scripts/sync_github_project.py:159-160`, `scripts/sync_github_project.py:167-169`, `scripts/sync_github_project.py:309-312`, `scripts/sync_github_project.py:314-320`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. If the reconciliation logic misclassifies an issue or release, it writes incorrect status and delivery values into the Project; reverting stops future writes but does not restore those values, though they can be corrected by a later sync or manual repair. The workflow also introduces a Project-write credential, so its default-branch and environment protections are part of the security boundary.


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

Comment thread scripts/sync_github_project.py Resolved
@zouyonghe

Copy link
Copy Markdown
Member Author

@sourcery-ai review

@zouyonghe

Copy link
Copy Markdown
Member Author

@cubic-ai review

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

Sourcery assessment

Needs a human reviewer. A defect in the reconciliation logic could write incorrect statuses, implementation links, or release details to Project items; those values outlive a revert, but a corrected full sync can recompute and repair them. The workflow also handles a Project-write token, so its trusted-branch and environment protections need to be configured as documented.


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

@zouyonghe

Copy link
Copy Markdown
Member Author

@sourcery-ai review

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

Sourcery assessment

Needs a human reviewer. A bad reconciliation can add Project items or store incorrect status, implementation links, or release details. Those changes persist in the Project, but a corrected run can recompute them; the workflow does not modify or delete the source Issues or PRs.


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

@zouyonghe
zouyonghe merged commit 3bebdd3 into AstrBotDevs:master Oct 31, 2026
24 checks passed
@Soulter Soulter moved this to Done in AstrBot Roadmap Nov 2, 2026
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.

1 participant