Repository navigation
Description
Context
run_ultrafix, review_pull_request, fix_review_findings and comment_on_pull_request (all in packages/api/mcp/toolsPullRequests.ts) post a GitHub comment and return { state: 'posted', commentId }. The existing trackExecution in packages/api/mcp/operationTracking.ts links the receipt to a task by the triggering comment id and follows it, but the receipt never says:
- whether the command was actually picked up (a worker task exists for this comment),
- for ultrafix: which cycle the loop is on, the latest review score, the goal, and whether it ended because it reached its goal, exhausted its cycles, was stopped (label removed via
stop_ultrafixor by a human), or failed.
The user story from the request: "having fired three ultrafix runs in a row, the caller could not afterwards confirm whether any of them had actually started, were still cycling, had completed, or had quietly given up." With the lifecycle from the previous issue, this issue fills in lifecycle.state, lifecycle.artifacts and lifecycle.progress for PR commands.
Requirements
- Pick-up detection for all four PR command tools: once a task whose persisted job data references the receipt's
commentIdexists, the receipt moves torunning(markStarted) andartifacts.taskIdis recorded. If no task appears within 10 minutes of posting (configurable constantPICKUP_DEADLINE_MS),lifecycle.failureis set to{ code: 'COMMAND_NOT_PICKED_UP', stage: 'queue', retryable: true, message: 'No worker picked up the command comment. Check that event intake is running (get_setup_status) and that the PR carries a processing label or the author is allowed.' }and the lifecycle becomesunknown(not failed — the webhook may still arrive). - Ultrafix progress (
run_ultrafixonly): compute from the tasks belonging to this loop's work epoch (the existing epoch logic intrackExecution) and theirtask_history.metadata:Recorded with{ "kind": "ultrafix", "goal": 9, "maxCycles": 3, "cycle": 2, "lastScore": 7, "phase": "review" | "fix" | "waiting_for_ci" | "paused" | "done", "outcome": null | "goal_reached" | "cycles_exhausted" | "stopped" | "failed", "cycles": [{ "cycle": 1, "reviewTaskId": "...", "fixTaskId": "...", "score": 5 }] }operations.recordProgress.cyclesbounded to the last 10. - Ultrafix terminal outcome is persisted durably by the worker (not inferred from absence): when the ultrafix loop ends, the worker appends a
task_historyentry (or metadata on the final state entry) with{ ultrafixOutcome, ultrafixCycle, ultrafixScore, ultrafixGoal, ultrafixMaxCycles }. The MCP tracker maps it:goal_reached→completed;cycles_exhausted→completedwithprogress.outcome = 'cycles_exhausted'(the loop behaved correctly; the goal was not met — this must be visible, not hidden as success);stopped→cancelled;failed→failedwith failure envelope{ code: 'ULTRAFIX_CYCLE_FAILED', stage: 'workflow' }and the failing task id in details. - Review / fix / comment receipts:
completedwhen the linked task is terminal-successful;artifactsinclude the posted review comment id (review) or the new head SHA (fix), whichtrackExecutionalready discovers. - The receipt text should be self-explanatory: add
lifecycle.summary— a one-line human sentence, e.g. "Ultrafix cycle 2 of 3 is reviewing; last score 7/10 (goal 9)." or "Ultrafix stopped after exhausting 3 cycles; last score 7/10 did not reach goal 9." stop_ultrafixreceipts, when they cleared the label on a PR that has an openrun_ultrafixreceipt from the same grant, mark that loop's progressphase: 'stopping'so the caller sees the relationship.
Implementation Specification
- New module
packages/api/mcp/commandProgress.tswithultrafixProgress(db, { repository, pullRequest, sinceMs, goal, maxCycles }),summarizeLifecycle(tool, lifecycle),detectPickup(...). - Edit
packages/api/mcp/operationTracking.ts(trackExecution): call intocommandProgressfor the four PR tools, thenoperations.recordProgress/markStarted/finish. - Worker side: locate the ultrafix loop continuation/termination code in
src/(search forultrafixand for the "max cycles exhausted" warning comment and the code that removes theultrafixlabel when the goal is reached). At each terminal branch, write the outcome metadata described above through the existing worker state manager (packages/core/src/utils/workerStateManager*) so it lands intask_history.metadata. When the label is found missing before starting the next cycle, recordstopped. - Tests:
packages/api/test/mcpCommandProgress.test.tswith seededtasks/task_historyrows for each outcome.
Acceptance Criteria
- A
run_ultrafixreceipt with no linked task after 10 minutes showsCOMMAND_NOT_PICKED_UPandretryable: true. - With seeded history for cycle 2 in review,
get_operationreturnsprogress.cycle === 2,phase === 'review',lifecycle.state === 'running'. - Seeded
ultrafixOutcome: 'cycles_exhausted'yieldslifecycle.state === 'completed',progress.outcome === 'cycles_exhausted', and a summary stating the goal was not reached. - Seeded
ultrafixOutcome: 'stopped'yieldscancelled. - Three ultrafix receipts on the same PR resolve to their own epochs (an earlier receipt cannot be satisfied by a later loop — existing guarantee preserved).
-
list_operations({ tool: 'run_ultrafix' })shows progress for each without extra GitHub calls.
Created by ProPR AI Planner
Activity
propr-dev commentedon Sep 28, 2026
Suggested Implementation:
Implementation Approach
We compute progress from ProPR's own persisted task history rather than from GitHub comments. Parsing PR comments on every poll was rejected: it costs GitHub API quota, comment prose is untrusted, and comments can be edited or deleted. Task history already records each review/fix task of the loop; the only missing fact is why the loop ended, which today only exists as a GitHub warning comment. We therefore make the worker write an explicit, durable
ultrafixOutcomemarker — cheap to add and removes all guessing ("quietly gave up") from the MCP side.Progress is written back through
recordProgress(from the lifecycle issue), solist_operationscan show it without re-polling.File:
packages/api/mcp/commandProgress.ts(new file)Why this file: Isolates the ultrafix/PR-command interpretation of task history from the generic tracker, keeping
operationTracking.tsreadable and the logic unit-testable with plain DB fixtures.File:
packages/api/mcp/operationTracking.tsWhy this file:
trackExecutionalready resolves which tasks belong to a PR command receipt (by exact comment id and work epoch). We extend it rather than re-implementing that association.Inside
trackExecution, after the existing code has determined the linked task ids for a PR command receipt (call that listepochTaskIds), add:In
stop_ultrafix, after removing the label, mark any activerun_ultrafixreceipt for the same PR and grant as stopping (progress only — the worker'sstoppedmarker finalises it):File: worker ultrafix loop (in
src/, locate by searching forultrafixand the "max cycles" warning comment)Why this file: Only the worker knows why the loop ended. Persisting an explicit marker turns "quietly gave up" into an observable fact.
At each loop exit point, record a history entry through the existing worker state manager (the same API that writes
ultrafixCycle/commandModemetadata today):If the state manager has no metadata-append helper, add the outcome to the metadata of the terminal state update that already happens at these points; do not add a new table.
File:
packages/api/test/mcpCommandProgress.test.ts(new file)Why this file: Verifies each outcome mapping and the summary text against seeded history, independent of GitHub.
propr-dev commentedon Sep 29, 2026
🤖 AI processing has started for this issue using codex agent with gpt-5.6-sol model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
codexgpt-5.6-sol2595/gpt-5.6-sol-mcp-track-pr-command-rece-20260929-0951-b2i2593-epic-mcp-observability-cf6issue-2595-20260929-0951-gpt-5.6-sol-b2i🔍 Track Task Execution
fix(ai): Resolve issue #2595 - MCP: track PR command receipts to comp…
fix(ai): Resolve issue #2595 - MCP: track PR command receipts to comp…