Skip to content

feat(provider-github): reopened issues and PRs reopen their closed work item - #287

Open
ccf-lisa[bot] wants to merge 1 commit into
fx/reopen-1-events-contractfrom
fx/reopen-2-provider-rule
Open

ccf-lisa[bot] wants to merge 1 commit into
fx/reopen-1-events-contractfrom
fx/reopen-2-provider-rule

Conversation

@ccf-lisa

@ccf-lisa ccf-lisa Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Task: reopen-2 (reopen events, provider and rule)

Summary

If you reopen a work item's primary issue or PR, the item now reopens too. When the primary link is closed, close-on-primary-closed sets lifecycle: closed on the item, and from then on closed-gate suppresses every rule. The factory never mapped GitHub's reopened action, so reopening the primary link didn't undo that. Real case: compliance-framework/docs#220 was closed and reopened. Its implement run then opened docs#229, but the review was never dispatched.

Stack: this is PR 2 of 2. It is based on #286 (fx/reopen-1-events-contract), which adds the issue.reopened / pr.reopened event types.

Provider (internal/provider/github/normalise.go)

  • issues.reopened maps to issue.reopened, and pull_request.reopened maps to pr.reopened. Each one gets the same object ref, facts (issue{title, labels, body} / pr{draft, head, base}) and contentRef as issue.closed / pr.closed.
  • There is no train extraction for reopened events. Only issue.closed in a train repo reads the train state.
  • New table rows and fixtures, with goldens in testdata/golden/, all in testdata/webhooks/:
    • issues.reopened
    • issues.reopened-train: a train issue in workflows, which carries no train fact
    • pull_request.reopened

Catalog

  • New rule catalog/rules/shared/reopen-on-primary-reopened.yaml:
    • Listens on [issue.reopened, pr.reopened].
    • Its where is close-on-primary-closed's, without the train clause: item.links.exists(l, l.primary == true && l.ref == event.object.ref).
    • Its action is set: { lifecycle: open }.
    • It is labelled pack: shared. Every RuleSet selects the shared pack by label (matchExpressions … values: [<pack>, shared]), so the rule is included wherever close-on-primary-closed is, and no RuleSet changes.
  • closed-gate still does not listen on the reopened types; this is the one deliberate exception, and its header comment now says so. TestClosedGate exempts those two types, and fails if closed-gate ever lists one of them.
  • Cancelled tasks are not restored when an item reopens. The rule's header says that an operator redispatches what the item still needs.
  • catalog_test.go: the new rule is added to the rule list and to sharedRules, which covers the expected RuleSet overlap.
  • New factory rules test fixtures:
    • catalog/testdata/reopened-epic-issue: a closed item whose primary issue is reopened ends with lifecycle: open, with one decision.
    • catalog/testdata/reopened-non-primary-pr: a closed item whose non-primary PR is reopened has no decisions and stays closed.

GitHub App subscription

The App already subscribes to Issues and Pull request (deploy/poc/README.md, Events row), and GitHub delivers the reopened action as part of those events. No manifest in the repo lists actions, so nothing changes there.

Verification

  • go test ./internal/provider/github/ -run 'TestNormalise': the new rows and goldens pass, and no existing golden changed.
  • go run ./cmd/factory rules test --catalog catalog --coverage: 68 cases, 68 ok, 0 differ, and 22 of 22 selected rules fire in some case.
  • make reviewable: check-generated, lint (0 issues), catalog and openapi-lint (100/100) pass. All tests pass except TestBaseScriptRuns (internal/agent/host/provision). That test fails the same way on main on macOS, because it needs /etc/os-release. It is unrelated to this PR, and CI runs it on Linux.

Notes

  • Not changed: the Tests bullet in github-provider.md still says there are 35 payloads. That count was already out of date before this PR.
  • Deploying this needs a factory release with both PRs, and the catalog synced.

🤖 Generated with Claude Code

@gusfcarvalho gusfcarvalho 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.

ccf-review: APPROVE

no findings.

Stack (base-chain): #286 → #287

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant