Skip to content

Conversation

@Akshat8510
Copy link
Contributor

Description

This PR fixes the bug where the inactivity bot crashed on cross-repo references
and unifies Phase 1 + Phase 2 into a single script with DRY_RUN support.

fixes #1022

What changed

  • Replaced separate scripts with a single unified bot:
    • .github/scripts/inactivity_unassign.sh
    • Removed:
      • dry_run_inactivity_unassign_phase1.sh
      • dry_run_inactivity_unassign_phase2.sh
      • inactivity_unassign_phase1.sh
      • inactivity_unassign_phase2.sh
  • Added DRY_RUN mode:
    • DRY_RUN=1 → log actions only, no unassign/close/comment
    • DRY_RUN=0 → perform real actions (default in workflow)
  • Fixed cross-repo bug:
    • Timeline now filters cross-references to only include PRs from hiero-ledger/hiero-sdk-python
    • gh pr view is wrapped with a safe check; invalid or foreign PRs are skipped
  • Updated workflow:
    • bot-inactivity-unassign-phase1.yml now calls the unified script for both Phase 1 and Phase 2.

Testing

Locally ran the bot with:

chmod +x .github/scripts/inactivity_unassign.sh

export REPO=hiero-ledger/hiero-sdk-python
export DAYS=21
export DRY_RUN=1

bash .github/scripts/inactivity_unassign.sh

@Akshat8510
Copy link
Contributor Author

Hi @exploreriii , I’ve:

  • Renamed the workflow file to bot-inactivity-unassign-phase.yml
  • Added a workflow_dispatch input dry_run that:
    • Defaults to true for manual runs
    • Controls the DRY_RUN env passed to the unified bot

So scheduled runs still operate in real mode, and manual runs start in dry-run mode unless explicitly turned off.

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

Hi @Akshat8510 great!
Please note to be consistent!
Some of the script is passing true
but some of the script is expecting 0 or 1!
This can cause some runtime issues

@exploreriii exploreriii marked this pull request as draft December 10, 2025 11:01
@github-actions
Copy link

Hi, this is MergeConflictBot.
Your pull request cannot be merged because it contains merge conflicts.

Please resolve these conflicts locally and push the changes.

To assist you, please read:

Thank you for contributing!

From the Hiero Python SDK Team

@Akshat8510 Akshat8510 marked this pull request as ready for review December 10, 2025 11:56
@Akshat8510 Akshat8510 marked this pull request as draft December 10, 2025 11:57
@github-actions
Copy link

[commit-verification-bot]
Hi, this is VerificationBot.
Your pull request cannot be merged as it has unverified commits.
View your commit verification status: Commits Tab.

To achieve verified status, please read:

Remember, you require a GPG key and each commit must be signed with:
git commit -S -s -m "Your message here"

Thank you for contributing!

From the Hiero Python SDK Team

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@Akshat8510
Copy link
Contributor Author

Hi @exploreriii , thanks for calling this out, that was a good catch.

I’ve updated the bot so that:

  • Assignment age is now based on the assignee’s latest assigned event for that issue.
    • Only if there’s no explicit assignment event do we fall back to issue.created_at.
    • This means: if an issue was opened 200 days ago but assigned yesterday, the logs show
      Assigned at: <yesterday> (~1 days ago) rather than 200 days.
  • The bot now logs, for each assignee:
    • Issue creation time
    • Assignment source (assignment_event vs issue_created_at) and timestamp
    • “Assigned at … (~N days ago)”
    • Whether any PRs are linked for that user
    • For each linked PR: state (OPEN/CLOSED/MERGED) and last commit timestamp + age
    • A final RESULT line for Phase 1 / Phase 2 (KEEP / stale → action)

Example from a dry-run:

ISSUE #760
  [INFO] Issue created at: 2025-11-10T09:49:20Z

  → Checking assignee: Raja-89
    [INFO] Assignment source: issue_created_at (no explicit assignment event)
    [INFO] Assigned at:      2025-11-10T09:49:20Z (~30 days ago)
    [INFO] Linked PRs: 763
    [INFO] PR #763 state: OPEN
    [INFO] PR #763 last commit: 2025-11-12T10:57:31Z (~28 days ago)
    [RESULT] Phase 2 → PR #763 is stale (>= 21 days since last commit)
    [DRY RUN] Would close PR #763 and unassign @Raja-89 from issue #760

And for a Phase 1 case with no PR:

ISSUE #903
  [INFO] Issue created at: 2025-11-27T12:31:15Z

  → Checking assignee: Om7035
    [INFO] Assignment source: issue_created_at (no explicit assignment event)
    [INFO] Assigned at:      2025-11-27T12:31:15Z (~13 days ago)
    [INFO] Linked PRs: none
    [RESULT] Phase 1 → no PR linked but not stale (< 21 days) → KEEP

@Akshat8510
Copy link
Contributor Author

This makes the behaviour much easier to trust when reviewing logs: you can see when the user was assigned, whether a PR exists, when it was last touched, and exactly why the bot decided to KEEP or (in non–dry run) close/unassign.

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

@Akshat8510
Please be careful when you refactor all the content -
its much better to keep things that are working and layer on additions or fixes

You have removed the posting functionality
Users that are removed from issues or PRs closed need to have a helpful message

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
Signed-off-by: Akshat8510 <akshat230405@gmail.com>
@Akshat8510
Copy link
Contributor Author

Hi @exploreriii , I’ve updated the bot to make the behaviour much more transparent and to restore the user-facing messages.

What changed in the script:

  • Phase 1 now uses the actual assignment timestamp per assignee:
    • Looks up the last assigned event for that user from the issue timeline
    • Falls back to issue.created_at only when there’s no explicit assignment event
  • For each assignee, the bot now logs:
    • Issue creation time
    • Assignment source (assignment_event vs issue_created_at)
    • Assignment timestamp and “~N days ago”
    • Whether there are linked PRs
    • For each linked PR: state, last commit timestamp, and age in days
    • Final outcome (KEEP, Phase 1 stale, or Phase 2 stale)

Example from the latest dry run (DRY_RUN=1):

User-facing messages restored:

  • Phase 1 (no PR + stale assignment)
    • Adds a friendly comment on the issue explaining that there’s been no linked PR for $ASSIGNED_AGE_DAYS days and the user is being unassigned to free the backlog.
  • Phase 2 (stale PR)
    • Comments on the PR before closing it, explaining that there have been no commits for $PR_AGE_DAYS days and that they’re welcome to open a new PR or get re-assigned later.

In DRY_RUN=1 we only log the “Would comment / close / unassign” actions; in DRY_RUN=0 the bot performs the real actions.

Let me know if you’d like to tweak any of the log lines or the wording of the messages, I’m happy to adjust. 🙂

@exploreriii
Copy link
Contributor

Have you been able to run this successfully? Is it tested?

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
@exploreriii
Copy link
Contributor

exploreriii commented Dec 11, 2025

your commits are not verified please

recommend soft revert if difficult

@Akshat8510 Akshat8510 force-pushed the inactivity-unify-bot branch 2 times, most recently from 695ba04 to 037ca62 Compare December 11, 2025 11:55
… signed

Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
Signed-off-by: Akshat8510 <akshat230405@gmail.com>
Signed-off-by: Akshat8510 <akshat230405@gmail.com>
Signed-off-by: Akshat8510 <akshat230405@gmail.com>
Signed-off-by: Akshat8510 <akshat230405@gmail.com>
@Akshat8510 Akshat8510 closed this Dec 11, 2025
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.

[Bug]: Activity Unassign Bot

2 participants