Skip to content

Finalize closed issue sessions so vigilante status stops reporting them as active stale/completed work #271

@nicobistolfi

Description

@nicobistolfi

Summary

vigilante status is still reporting stale sessions and completed/failed sessions for work that should already be finalized and no longer watched. Sessions associated with issues that are already closed, and sessions whose lifecycle has otherwise finished cleanup/monitoring, should be cleared out of the active watch/status views and marked as closed so Vigilante stops continuing to watch them.

Problem

  • vigilante status currently includes sessions in Stale sessions and Completed / failed even when those sessions correspond to work that should already be finalized.
  • This makes the status output misleading because it suggests Vigilante is still tracking or watching items that should be out of the active lifecycle.
  • It also inflates session counts and obscures the actual work that still needs operator attention.
  • In practice, closed/finalized work should not remain in the same buckets as active stale sessions, paused sessions, or live completed/failed sessions.

Context

  • Repository: aliengiraffe/vigilante
  • The codebase already has cleanup/finalization paths for closed issues and closed pull requests, using fields such as CleanupCompletedAt, MonitoringStoppedAt, and cleanup sources like issue_closed and pull_request_closed.
  • There is already an open request to introduce a distinct closed session status for issue-finalized work.
  • The status output below shows the current incorrect behavior, where finalized or no-longer-relevant sessions are still listed in active status buckets:
vigilante status

Service
  state: running
  manager: systemd
  service: vigilante.service
  path: /home/zantez/.config/systemd/user/vigilante.service
  installed: yes
  running: yes

Sessions: 32 total

Stale sessions (10)
  Issue #106 in aliengiraffe/vigilante: blocked, PR #138 OPEN, stage pr_maintenance
  Issue #122 in aliengiraffe/vigilante: blocked, stage issue_execution
  Issue #58 in teros-dev/platform: blocked, PR #62 OPEN, stage pr_maintenance
  Issue #59 in teros-dev/platform: blocked, PR #63 OPEN, stage pr_maintenance
  Issue #68 in teros-dev/platform: blocked, PR #69 OPEN, stage pr_maintenance
  Issue #67 in teros-dev/platform: blocked, stage issue_execution
  Issue #70 in teros-dev/platform: blocked, stage issue_execution
  Issue #204 in aliengiraffe/vigilante: blocked, PR #205 OPEN, stage pr_maintenance
  Issue #266 in aliengiraffe/vigilante: blocked, stage issue_execution
  Issue #133 in teros-dev/platform: blocked, PR #134 OPEN, stage pr_maintenance

Completed / failed (22)
  Issue #163 in aliengiraffe/vigilante: success
  Issue #114 in teros-dev/platform: success, PR #116 MERGED
  Issue #224 in aliengiraffe/vigilante: success, PR #225 MERGED
  Issue #117 in teros-dev/platform: success, PR #118 OPEN
  Issue #119 in teros-dev/platform: success, PR #122 MERGED
  Issue #233 in aliengiraffe/vigilante: success, PR #235 MERGED
  Issue #239 in aliengiraffe/vigilante: success, PR #240 MERGED
  Issue #242 in aliengiraffe/vigilante: success, PR #243 MERGED
  Issue #241 in aliengiraffe/vigilante: success, PR #245 MERGED
  Issue #250 in aliengiraffe/vigilante: success, PR #253 MERGED
  Issue #251 in aliengiraffe/vigilante: success, PR #254 MERGED
  Issue #129 in teros-dev/platform: success, PR #130 MERGED
  Issue #256 in aliengiraffe/vigilante: success, PR #259 OPEN
  Issue #257 in aliengiraffe/vigilante: success, PR #261 OPEN
  Issue #255 in aliengiraffe/vigilante: success, PR #260 OPEN
  Issue #258 in aliengiraffe/vigilante: success, PR #265 OPEN
  Issue #262 in aliengiraffe/vigilante: success, PR #267 MERGED
  Issue #264 in aliengiraffe/vigilante: success, PR #268 MERGED
  Issue #263 in aliengiraffe/vigilante: success, PR #269 MERGED
  Issue #126 in teros-dev/platform: failed, PR #128 OPEN
  Issue #247 in aliengiraffe/vigilante: failed
  Issue #249 in aliengiraffe/vigilante: failed, PR #252 OPEN

GitHub rate limits
  core: 46/60 remaining, resets in 41m56s
  search: 10/10 remaining, resets in 59s
  • The user expectation is that once an issue is actually closed, the session should move into a finalized closed state and stop being treated as an actively watched session.
  • This is especially important for status output, because the operator should be able to trust that listed sessions still matter.

Desired Outcome

  • Sessions for issues that are already closed are finalized automatically and marked as closed instead of remaining in stale/completed/failed buckets.
  • Finalized sessions are excluded from the active operational status sections that imply continued monitoring or intervention.
  • Vigilante stops continuing to watch issues and PRs whose relevant session lifecycle is already over.
  • Status output reflects only the sessions that still require active watching, monitoring, maintenance, or attention.
  • Non-goals:
  • hiding legitimately open blocked/failed sessions that still require operator attention
  • treating PR merge alone as the universal signal for issue finalization if the issue is still open
  • deleting useful historical session data outright instead of modeling it correctly as finalized/closed

Implementation Notes

  • Treat this as a bug in session finalization and status classification.
  • Required behavior:
  • when an issue is detected as closed and session finalization succeeds, the session should move into a finalized closed state
  • finalized sessions should no longer appear in active Stale sessions or Completed / failed sections of vigilante status
  • status counts should exclude or separately classify finalized/closed sessions so active operational views are not polluted by completed lifecycle entries
  • open sessions with open PRs or open issues should continue to appear when they truly remain active, blocked, or failed
  • Plausible implementation areas:
  • session finalization paths in internal/app/app.go
  • session status model in internal/state/state.go
  • any status rendering/grouping code used by vigilante status
  • selection/filtering logic that determines whether a session is still considered actively watched
  • Required constraints:
  • issue closure should remain the authoritative signal for marking an issue session closed
  • a merged PR alone should not cause issue-level finalization if the issue remains open
  • if cleanup/finalization fails, the session should not be silently hidden from status in a way that masks the failure
  • Flexible details:
  • whether finalized sessions disappear entirely from the default status output or move to a separate compact Closed / finalized summary, as long as they are clearly not treated as still-watched active sessions
  • whether PR-only cleanup and issue-closure cleanup need distinct status semantics, as long as the operator-facing status view is accurate
  • Tradeoffs to consider:
  • some failed sessions may still be relevant if their issue remains open, so the filtering logic must distinguish finalized historical failures from open failures that still matter
  • the status command should optimize for current operational truth, while preserving enough state for audits/debugging elsewhere

Acceptance Criteria

  • When a session's GitHub issue is closed and finalization succeeds, the session is marked closed and no longer treated as actively watched.
  • Finalized/closed sessions do not appear in the active Stale sessions section of vigilante status.
  • Finalized/closed sessions do not appear in the active Completed / failed section of vigilante status.
  • Sessions for issues that remain open continue to appear in status when they are legitimately running, blocked, stale, successful-but-still-open, or failed.
  • Status counts reflect active sessions accurately and are not inflated by already-finalized closed work.
  • If finalization/cleanup fails, the session remains visible in a way that surfaces the problem instead of incorrectly hiding it as closed.

Testing Expectations

  • Add tests covering vigilante status output when sessions correspond to already-closed issues and verify they are excluded from active status buckets.
  • Add tests showing that finalized sessions transition to closed after successful issue-closure finalization.
  • Add tests ensuring merged PRs for still-open issues do not prematurely remove or close sessions.
  • Add tests for failed open sessions vs failed finalized sessions so only the still-relevant failures remain in active status sections.
  • Add regression coverage for session counts so finalized closed sessions do not inflate active totals.
  • Add tests for cleanup/finalization failure paths to ensure those sessions remain visible for operator follow-up.

Operational / UX Considerations

  • vigilante status should present current operational truth, not a mixture of current work and historical leftovers.
  • Closed/finalized sessions may still be valuable historically, but they should not be shown as if Vigilante is still watching them.
  • Operators should be able to trust that items listed under Stale sessions or Completed / failed still matter now.
  • If historical visibility is still useful, keep it in a separate summary or another command instead of mixing it into active status sections.

Metadata

Metadata

Assignees

Labels

vigilante:doneVigilante completed its work on the issue and no further automation is expected.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions