Repository navigation
Description
Problem
The only subscribable stream is Socket.IO fed by Redis pub/sub: fire-and-forget, no cursor, no replay, and MCP tokens cannot connect. The only durable journal with a cursor is goal_events. Pull request changes (opened, new head, review scored, Ultrafix ended, merged, closed) and epic queue changes (advanced, blocked, completed) are not published anywhere, so a coordinator has to poll many reads and diff them.
What to build
A durable, append-only journal in the database, written at the points where these changes are already persisted. This issue adds the table, the writer and the call sites only; the read/wait interface is the next issue.
Table repository_events
seq (INTEGER PRIMARY KEY AUTOINCREMENT, the cursor), repository (owner/repo), domain (pull_request | epic_queue | plan_issue), type, entity_id (PR number, epic execution id, or plan issue id as text), pr_number (nullable), issue_number (nullable), plan_id (nullable), head_sha (nullable), payload (JSON, small), dedupe_key (nullable, unique per repository), occurred_at. Indexes on (repository, seq) and (repository, domain, entity_id, seq).
Event types
pull_request:opened,head_changed,review_scored(payload: score, goal, goalReached, source, cycle, reviewerModel),ultrafix_started,ultrafix_ended(payload: outcomegoal_reached|cycles_exhausted|stopped|failed, finalScore, reason),auto_merge_decision(payload: the existingautoMergeDecisionmetadata),merged,closed.epic_queue:started,advanced(payload: from issue, to issue, cursor),blocked(payload: head issue, blockedReason),completed.plan_issue:status_changed(payload: from, to).
Payloads carry identifiers and small scalars only: no PR bodies, comment text, diffs or log excerpts.
Writer
appendRepositoryEvent(db, event) in core. It must:
- be idempotent through
dedupe_key(for examplepr:{n}:review_scored:{review_scores.id},pr:{n}:merged,pr:{n}:head:{sha}), so webhook redelivery and retries do not duplicate events; - never throw into its caller: a failed append is logged and counted, and the underlying operation proceeds;
- when the triggering change is itself a database write, append in the same transaction where that is practical.
Call sites (use the existing persistence points)
- review score recorded:
recordReviewScores(packages/core/src/services/reviewScoreStore.ts); - merged / closed:
recordPullRequestOutcome(same file) and thenotification_pull_request_statewriter innotificationService.ts; - Ultrafix start and end:
ultrafixOrchestrationService.ts(completeLoop,stopLoop), mapping the free-text completion reason to the coded outcome already defined inpackages/api/mcp/commandProgress.ts(move the outcome type to shared/core rather than duplicating it); - auto-merge decision:
recordAutoMergeDecisionEvent(packages/core/src/services/autoMergeGate.ts); - PR opened / head changed: the pull_request webhook handling for
openedandsynchronize; - epic queue:
advanceEpicQueueand the blocked/complete transitions inpackages/core/src/services/taskPlanning/epicExecutionQueue.ts; - plan issue status:
packages/core/src/config/planIssueManager.tswhere it already publishes the plan activity event.
If another change has already introduced an epic-queue blocked event or per-issue queue state (issues #3472, #3474), emit the journal event from that same code path instead of adding a parallel one.
Retention
Prune rows older than 30 days in the existing daemon maintenance sweep. Record the lowest retained seq so a reader can tell an expired cursor from an empty result.
Realtime
Add a pull_request domain to the activity envelope (packages/shared/src/activityEvents.ts) and publish a bare activity event after each append so the web UI can react. The journal, not pub/sub, is the source of truth.
Acceptance criteria
- Migration creates the table and indexes; down migration drops them.
- Each event type above is appended by a test that drives the real call site.
- Replaying the same trigger twice yields one row.
- A forced append failure does not fail the review-score write, the merge handling or the queue advance.
- Events are ordered by
seqand scoped by repository. - Retention prunes old rows and records the floor.
- Architecture docs gain a short page describing the journal, the event types and payloads.
Implementation
- Migration +
packages/core/src/services/repositoryEventJournal.ts(types,appendRepositoryEvent,listRepositoryEvents(db, {repository, afterSeq, domains?, entityId?, limit}),pruneRepositoryEvents). Export from the core index and put the shared event type definitions inpackages/shared. - Wire the call sites listed in the issue, each behind the non-throwing wrapper.
- Activity envelope: add the
pull_requestdomain and publish after append. - Daemon sweep: retention.
- Tests in
packages/core/test/for the journal (ordering, dedupe, failure isolation, pruning) and per call site next to the existing tests (reviewScorePersistence.test.ts,epicExecutionQueue.test.ts,ultrafixOrchestrationService.test.ts,autoMergeGate.test.ts). - Docs page under
docs/docs/architecture/.
Notes
goal_events (packages/core/src/db/migrations/20261004000000_create_goal_events.js) is the model for a cursor journal, but it uses SQLite triggers that must be recreated on table rebuilds. Use explicit application-level appends here, not triggers.
Activity
propr-dev commentedon Nov 12, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-53483/claude-opus-5-5-durable-change-event-jour-20261112-1601-vhp3482-epic-integration-signals-100issue-3483-20261112-1601-claude-opus-5-5-vhp🔍 Track Task Execution