Repository navigation
[3547 by Claude Opus 5.5] Repository event journal: add the task domain - #3572
Conversation
… the issue lists records `queued`, `started` and one terminal event (`completed`, `failed` or `cancelled`), and a failed append doesn't change how the task ends. All the new tests and the related existing suites pass, along with lint (zero warnings), typecheck and the OpenAPI check. Where events are written. All task status changes already go through one state manager in core, so I added the appends there rather than in each job file. `queued` is written when the task is created; `started` and the terminal events are written right after the state change is saved to the task history. This covers issue tasks, pull request follow-ups, reviews, merge-conflict tasks and automation runs. The event-building code is in `packages/core/src/services/taskJournalEvents.ts`. Behaviour you might not assume: - Not journaled: goal tasks, task imports and agent runs with no repository. They don't fit the issue's five kinds. - Queue handoffs: when a job is requeued or rescheduled, the task is briefly marked `cancelled` but continues later. That appends no `cancelled` event, and resuming it appends no second `started`. - Retries: a retried task appends `started` and a new terminal event again, so one task can have several runs in the journal. - Failure category: this is a short code such as `timed_out`, `git_operation` or `worker`. Anything that looks like free text becomes `unknown`. - Pull request outcome: `opened` when the task opened a pull request (including a continuation one), `updated` when it pushed a commit to an existing one, otherwise empty. - Realtime: task events publish no extra activity update, because task state changes already send their own. Migration you should know about. The journal table only allowed the three existing domains, and SQLite can't change that rule in place. The new migration (`20261114120000_add_task_repository_event_domain.js`) rebuilds the table. It keeps every row, its sequence number and the sequence counter, so existing cursors stay valid and deleted numbers are never reused. Rolling it back deletes the `task` events. Readers. The API, MCP tools and CLI accept the new domain because they build their domain list from the shared one. I updated the MCP tool description and the API docs text, and regenerated the OpenAPI spec and client types. Automations have no event triggers built from the journal's domains, so I left them unchanged, as the issue says to. Acceptance criteria - AC1: met — `packages/core/test/taskJournalEvents.test.ts` checks `queued` → `started` → `completed` with the full payload for an implementation task and a pull request follow-up; `test/taskJournalFinalizers.test.ts` checks the same through the follow-up job completion path in `src/jobs`. - AC2: met — cancelled tasks (user-cancelled and pull-request-closed) append `cancelled`; failed tasks append `failed` with `git_operation`, `timed_out` or `worker` as the category, in both of those test files. - AC3: met — the sentinel test in `packages/core/test/taskJournalEvents.test.ts` puts marker strings into the task's prompt fields, reasons, tool output, results, error messages and logs, then checks no stored `task` event contains them and only the documented payload fields appear; `test/taskJournalFinalizers.test.ts` checks the same for follow-ups. - AC4: met — with the journal table removed, the task still finishes `completed` with its full history and the failure is logged (`packages/core/test/taskJournalEvents.test.ts`), and the follow-up finalizer still reports `finalized` (`test/taskJournalFinalizers.test.ts`). - AC5: met — `packages/api/test/repositoryEventTaskDomain.test.ts` covers list, filters, wait and 30-day retention; `packages/api/test/mcpRepositoryEvents.test.ts` covers the MCP tool and REST route; `packages/shared/test/repositoryEvents.test.ts` covers the domain list; docs are in `docs/docs/architecture/repository-event-journal.md` (domain, payloads, dedupe keys, retention) and `docs/docs/operations/api-reference.md`.
|
/ultrafix goal=8 max=10 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
CI failed: Packaged Connect (darwin-x64) Please investigate and fix this CI failure.
Failure evidence
|
|
ℹ️ Analyzed the follow-up request by @propr-dev[bot] Analysis SummaryI didn't change any code, because this failure isn't caused by the PR. A rerun of the failed jobs should fix it. What failed: the darwin-x64 job never got past its first install step ( Why it's not the PR:
Next step: rerun the failed and cancelled jobs in run 43618307573 (for example No code changes were necessary based on the current state of the branch. 🤖 Analysis Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds task lifecycle events through the shared state manager, with corresponding reader contracts, documentation, and tests. It needs a localized correction before merge: queue handoffs produce an incorrect run duration. ✅ Failure isolation — Event construction and append failures are caught without changing the task’s outcome. ✅ Migration preservation — The migration preserves existing sequence numbers and the AUTOINCREMENT high-water mark, with regression coverage for deleted sequence numbers. ✅ Reader integration — Shared domain declarations propagate to API and MCP filters, with tests covering task events and retention. This review used static analysis of the supplied code; no commands were run. Current-head checks report 35 passed, 31 neutral/skipped, and no failures. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Preserve run duration across handoffs
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Exercise waits before task appendsThe new API wait test starts waiting after matching task events already exist. An additional test that starts the wait first and then appends through the task state manager would cover notification delivery for a domain without an activity mapping. This is optional because the shared append notification path remains in use. ScoreThe implementation is focused and has substantial coverage with passing current-head checks. The incorrect duration across supported queue handoffs requires a small correction before merge. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 7950ec6
Summary of ChangesI fixed F1: when a run is paused for a queue handoff and later resumes, The fix (
Tests (
Docs: I updated the No other code works out where a run starts, so there were no other copies of this bug to fix. The change isn't visible in the UI, so I didn't create any previews. Review digestRisk-tiered paths
Validation evidence
Diff size: 3 files changed, +59/−11 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…ter resumes, `durationMs` now counts from the run's original `started` event instead of from the resumption. A retry after a real failure still counts as a new run with its own duration. The core test file passes (12 tests), as do `test/taskJournalFinalizers.test.ts` (5 tests), the core typecheck and a zero-warning lint of the changed source file. I removed the fix temporarily and both new duration checks failed, so they do catch the bug. I fixed F1: when a run is paused for a queue handoff and later resumes, `durationMs` now counts from the run's original `started` event instead of from the resumption. A retry after a real failure still counts as a new run with its own duration. The core test file passes (12 tests), as do `test/taskJournalFinalizers.test.ts` (5 tests), the core typecheck and a zero-warning lint of the changed source file. I removed the fix temporarily and both new duration checks failed, so they do catch the bug. **The fix** (`packages/core/src/services/taskJournalEvents.ts`): when the duration code walks back through the task history looking for the start of the run, it now steps past a handoff `cancelled` entry as if the run never stopped. It recognises a handoff by reusing `isBookkeepingCancellation`, the same check that stops a resumed handoff from journaling a second `started`. So both decisions now follow one rule: - **Handoff** (`requeued` or `rescheduled`, no terminal reason): the run continues. - **Real terminal state:** the run ends, and the next running state starts a new run. **Tests** (`packages/core/test/taskJournalEvents.test.ts`): the tests now fix the clock at chosen times, so the durations can be checked exactly. - **The finding's case:** start at 00:00, handoff at 00:05, resume at 00:10, complete at 00:11. The test asserts `durationMs` is 11 minutes and that the journal still records only `queued`, `started`, `completed`. - **New test with two handoffs and a retry:** a `rescheduled` handoff (recognised by its reason text) and a `requeued` handoff (recognised by its metadata), then a real failure at 7 minutes. The `failed` event reports 7 minutes. A retry from 00:20 to 00:23 then reports 3 minutes. **Docs:** I updated the `durationMs` row in `docs/docs/architecture/repository-event-journal.md` to say the time runs from the run's `started` event, across any queue handoffs in between. No other code works out where a run starts, so there were no other copies of this bug to fix. The change isn't visible in the UI, so I didn't create any previews. PR: #3572 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds task lifecycle events through the shared state manager, extends existing readers, and documents the payload contract. The implementation appears merge-ready within the supplied scope, conditional on the two pending checks completing successfully. ✅ Centralized lifecycle recording — Creation and state transitions share one event builder, with explicit handling for retries and bookkeeping cancellations. ✅ Cursor-preserving migration — The table rebuild preserves sequence numbers, indexes, and the AUTOINCREMENT high-water mark, including sequence numbers removed by retention. ✅ Isolated journal failures — Event construction and append failures are contained; the added tests exercise task completion with the journal table unavailable. This assessment is a static review of the supplied diff and surrounding context. No commands or tests were run, as requested. The authoritative check summary reports no failures. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S2: 🟢 Test transition replay deduplicationAdd a regression that appends the same transition twice, then appends a subsequent retry transition. The version-based key in S3: 🟢 Exercise a pending task-event waitThe wait test in ScoreThe change is focused, includes substantial lifecycle and migration coverage, and has no verified merge blockers. Two checks remain pending, and runtime validation was not independently performed during this review. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
ℹ️ GitHub auto-merge is turned off for this repository, so ProPR merges this PR itself once it is ready (checks passed or no CI configured, and the review goal met). To let GitHub merge it the moment required checks pass, enable Settings → General → Pull Requests → Allow auto-merge. |
AI Implementation Summary
Closes #3547
Branch:
3547/claude-opus-5-5-repository-event-journal--20261114-1634-rv2Commits: ✅ Changes committed (5aabbab)
AI Processing Completed
Execution Details:
Summary:
The repository event journal now has a
taskdomain. Every task type the issue lists recordsqueued,startedand one terminal event (completed,failedorcancelled), and a failed append doesn't change how the task ends. All the new tests and the related existing suites pass, along with lint (zero warnings), typecheck and the OpenAPI check.Where events are written. All task status changes already go through one state manager in core, so I added the appends there rather than in each job file.
queuedis written when the task is created;startedand the terminal events are written right after the state change is saved to the task history. This covers issue tasks, pull request follow-ups, reviews, merge-conflict tasks and automation runs. The event-building code is inpackages/core/src/services/taskJournalEvents.ts.Behaviour you might not assume:
cancelledbut continues later. That appends nocancelledevent, and resuming it appends no secondstarted.startedand a new terminal event again, so one task can have several runs in the journal.timed_out,git_operationorworker. Anything that looks like free text becomesunknown.openedwhen the task opened a pull request (including a continuation one),updatedwhen it pushed a commit to an existing one, otherwise empty.Migration you should know about. The journal table only allowed the three existing domains, and SQLite can't change that rule in place. The new migration (
20261114120000_add_task_repository_event_domain.js) rebuilds the table. It keeps every row, its sequence number and the sequence counter, so existing cursors stay valid and deleted numbers are never reused. Rolling it back deletes thetaskevents.Readers. The API, MCP tools and CLI accept the new domain because they build their domain list from the shared one. I updated the MCP tool description and the API docs text, and regenerated the OpenAPI spec and client types. Automations have no event triggers built from the journal's domains, so I left them unchanged, as the issue says to.
Acceptance criteria
packages/core/test/taskJournalEvents.test.tschecksqueued→started→completedwith the full payload for an implementation task and a pull request follow-up;test/taskJournalFinalizers.test.tschecks the same through the follow-up job completion path insrc/jobs.cancelled; failed tasks appendfailedwithgit_operation,timed_outorworkeras the category, in both of those test files.packages/core/test/taskJournalEvents.test.tsputs marker strings into the task's prompt fields, reasons, tool output, results, error messages and logs, then checks no storedtaskevent contains them and only the documented payload fields appear;test/taskJournalFinalizers.test.tschecks the same for follow-ups.completedwith its full history and the failure is logged (packages/core/test/taskJournalEvents.test.ts), and the follow-up finalizer still reportsfinalized(test/taskJournalFinalizers.test.ts).packages/api/test/repositoryEventTaskDomain.test.tscovers list, filters, wait and 30-day retention;packages/api/test/mcpRepositoryEvents.test.tscovers the MCP tool and REST route;packages/shared/test/repositoryEvents.test.tscovers the domain list; docs are indocs/docs/architecture/repository-event-journal.md(domain, payloads, dedupe keys, retention) anddocs/docs/operations/api-reference.md.Review digest
Acceptance criteria (5 of 5 met, as stated by the agent)
For an implementation task and a pull request follow-up: `queued`, `started` and one terminal event are appended in order with the documented payload.—`packages/core/test/taskJournalEvents.test.ts` checks `queued` → `started` → `completed` with the full payload for an implementation task and a pull request follow-up; `test/taskJournalFinalizers.test.ts` checks the same through the follow-up job completion path in `src/jobs`.A cancelled task appends `cancelled`; a failed task appends `failed` with a failure category.—cancelled tasks (user-cancelled and pull-request-closed) append `cancelled`; failed tasks append `failed` with `git_operation`, `timed_out` or `worker` as the category, in both of those test files.Sentinel test: prompt text and tool output never appear in a `task` event.—the sentinel test in `packages/core/test/taskJournalEvents.test.ts` puts marker strings into the task's prompt fields, reasons, tool output, results, error messages and logs, then checks no stored `task` event contains them and only the documented payload fields appear; `test/taskJournalFinalizers.…A journal append failure does not change the task's outcome.—with the journal table removed, the task still finishes `completed` with its full history and the failure is logged (`packages/core/test/taskJournalEvents.test.ts`), and the follow-up finalizer still reports `finalized` (`test/taskJournalFinalizers.test.ts`).Journal retention, API and MCP read paths return the new events; docs list the domain and payloads where the other domains are documented.—`packages/api/test/repositoryEventTaskDomain.test.ts` covers list, filters, wait and 30-day retention; `packages/api/test/mcpRepositoryEvents.test.ts` covers the MCP tool and REST route; `packages/shared/test/repositoryEvents.test.ts` covers the domain list; docs are in `docs/docs/architecture/repo…Risk-tiered paths
packages/core/src/db/migrations/20261114120000_add_task_repository_event_domain.js(added, +59/−0): database migrationpackages/api/mcp/toolsRepositoryEvents.ts(+1/−1)packages/api/openapi/routeDocsTasks.ts(+1/−1)packages/api/openapi/schemasRepositoryEvents.ts(+3/−3)packages/client/src/generated/apiTypes.ts(+8/−8)packages/core/src/services/taskJournalEvents.ts(added, +177/−0)packages/core/src/utils/workerStateManager.ts(+3/−3)packages/core/src/utils/workerStateTransition.ts(+13/−1)packages/shared/src/repositoryEvents.ts(+60/−5)docs/docs/architecture/repository-event-journal.md(+42/−6)docs/docs/operations/api-reference.md(+1/−1)docs/static/openapi/propr-api.yaml(+9/−8)packages/api/test/mcpRepositoryEvents.test.ts(+15/−0)packages/api/test/repositoryEventTaskDomain.test.ts(added, +66/−0)packages/core/test/taskJournalEvents.test.ts(added, +254/−0)packages/shared/test/repositoryEvents.test.ts(added, +31/−0)test/taskJournalFinalizers.test.ts(added, +116/−0)Validation evidence
Diff size: 17 files changed, +859/−37 lines
Detailed Logs:
3b859df1-da51-443d-a635-9112767f4308Log files stored at:
/usr/src/app/logs/executions/issue-3547-2026-11-14T16-56-03-545Z-conversation.json/usr/src/app/logs/executions/issue-3547-2026-11-14T16-56-03-545Z-output.txtLatest Conversation Messages
This PR was created automatically by ProPR after processing issue #3547.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!