Skip to content

feat: Track PR outcomes end-to-end in task history#363

Open
whitmo wants to merge 1 commit intodlorenc:mainfrom
whitmo:work/zealous-hawk
Open

feat: Track PR outcomes end-to-end in task history#363
whitmo wants to merge 1 commit intodlorenc:mainfrom
whitmo:work/zealous-hawk

Conversation

@whitmo
Copy link

@whitmo whitmo commented Mar 3, 2026

Summary

  • Add --pr-url flag to agent complete so workers can report which PR they created when signaling completion
  • Record PR URL/number in task history during worker cleanup (previously PRURL and PRNumber fields were always empty)
  • Add PR outcome tracking daemon loop (every 5 min) that polls GitHub for open/unknown task history entries and updates their stored status to merged/closed/open via the previously-unused UpdateTaskHistoryStatus method
  • Use stored terminal statuses (merged/closed/failed) in CLI display to avoid redundant GitHub API calls
  • Add GetPendingTaskHistory state method to efficiently query entries needing outcome checks
  • Add parsePRNumber and ghStateToTaskStatus helpers with comprehensive tests
  • Update Socket API and State File extension documentation

What was broken before

The task history system had the infrastructure but wasn't wiring it together:

  • UpdateTaskHistoryStatus() and UpdateTaskHistorySummary() existed but were never called in production (dead code)
  • PR URL/number were never captured - fields were always empty
  • Status was always "unknown" (unless failure) - outcomes were only queried at display time via GitHub API with no persistent record

Data flow (after)

Worker creates PR → agent complete --pr-url <url> → handleCompleteAgent stores PRURL on agent → recordTaskHistory extracts PR number, sets status=open → PR outcome loop (5 min) polls GitHub for open/unknown entries → UpdateTaskHistoryStatus persists merged/closed/open → repo history uses stored status for terminal states 

Test plan

  • TestGetPendingTaskHistory - returns only open/unknown entries with branches
  • TestGetPendingTaskHistoryNonExistentRepo - error handling
  • TestRecordTaskHistoryWithPRURL - PR URL/number captured, status set to open
  • TestRecordTaskHistoryWithPRURLAndFailure - failure status takes precedence over PR
  • TestParsePRNumber - URL parsing edge cases
  • TestGhStateToTaskStatus - GitHub state mapping
  • All existing tests pass (go test ./...)
  • verify-docs state schema check passes

🤖 Generated with Claude Code

Workers can now report their PR URL via `agent complete --pr-url <url>`, which gets persisted in task history with parsed PR number. A new daemon loop (every 5 min) polls GitHub for open/unknown task history entries and updates their status (merged/closed/open) via the existing but previously unused UpdateTaskHistoryStatus method. The CLI also uses stored terminal statuses (merged/closed) to avoid redundant GitHub API calls at display time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@whitmo
Copy link
Author

whitmo commented Mar 7, 2026

Triage Review

Priority: P1 (Task history - roadmap item)
Build: Pass
Tests: Pass (all internal packages)
Merge conflicts: None - merges cleanly with main and all other open PRs
Roadmap alignment: Directly addresses P1 "Task history" item

Changes:

  • Adds pr_url field to Agent state and complete_agent socket API
  • Live PR status queries via gh pr view in history display
  • Supports merged/closed/open status tracking
  • Updates Socket API and State File extension docs

Recommendation: Safe to merge anytime - no conflicts with any other PR.

@whitmo
Copy link
Author

whitmo commented Mar 12, 2026

Local CI Verification (2026-03-12)

Check Result
go build PASS
go vet PASS
go test ./... PASS (all packages)

CI Status: No GitHub Actions checks are running — this is expected for first-time fork PRs. GitHub requires a maintainer to approve workflow runs for PRs from forks.

Branch is rebased on upstream/main (0 commits behind). Ready for maintainer review and CI approval.

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

Labels

None yet

1 participant