Skip to content

[3484 by Claude Opus 5.5] Read and wait on repository change events over REST, MCP and CLI - #3508

Merged
integry merged 6 commits into
3482-epic-integration-signals-100from
3484/claude-opus-5-5-read-and-wait-on-reposito-20261112-2048-wgw
Nov 13, 2026
Merged

integry merged 6 commits into
3482-epic-integration-signals-100from
3484/claude-opus-5-5-read-and-wait-on-reposito-20261112-2048-wgw

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3484

Branch: 3484/claude-opus-5-5-read-and-wait-on-reposito-20261112-2048-wgw
Commits: ✅ Changes committed (ff4dea3)


AI Processing Completed

Execution Details:

Summary:
I've implemented #3484: coordinators can now list and wait on a repository's change events over MCP, REST and the CLI, using the same cursor and error rules everywhere. The new tests pass, along with the OpenAPI, mcpObservableSurface, mcpDocs, mcpToolInputBudget, goal-wait, readiness, socket and core journal suites. The full npm run test:mcp run had 460 of 467 passing. All 7 failures are in relevanceServiceCommit and fail with EROFS because /tmp/git-processor is read-only in this container; that suite has nothing to do with this change.

What was added

  • MCP: list_repository_events and wait_repository_events (read scope, in a new toolsRepositoryEvents.ts). Repository access is checked the same way as for list_pull_requests. The wait receives the request's abort signal, so cancelling the call releases it, and the grant is re-checked before each further read.
  • REST: GET /api/repository-events and GET /api/repository-events/wait, registered with documented schemas and the standard error format. npm run gen:openapi output is regenerated and the up-to-date check passes.
  • CLI: propr events list and propr events wait with filter options, --json and --follow. In follow mode, --json prints one JSON line per event, and Ctrl-C prints the cursor to resume from.
  • Docs: docs/mcp.md has a new section with the cursor contract, at-least-once delivery, an error table and a coordinator loop that waits for events, then calls get_pull_request_readiness (which is in the catalog). docs/mcp-coverage.md, the API reference and the CLI page are updated, and the new tokens are in the mcpObservableSurface allow-list.

How it behaves

  • The cursor is rec1. + base64url of {r, s}, as specified. A call without a cursor returns the current cursor and no history unless fromStart is set.
  • Cursor errors:
    • CURSOR_INVALID (400): malformed, or a position this instance never issued.
    • CURSOR_WRONG_REPOSITORY (400).
    • CURSOR_EXPIRED (410): below the repository's retention floor. It is never returned as an empty result.
  • A wait returns at once if matching events already exist, ignores non-matching ones, and on timeout returns the cursor it started from, unchanged.
  • Each owner can have at most 16 waits open per API process, counted across REST and MCP (the same limit as goal waits).
  • Waking waiters:
    • An append in the same process wakes them at once. This needed a small new hook in core, subscribeRepositoryEventAppends.
    • An append in another process wakes them through the socket relay, which wakes any message naming a repository.
    • The 2.5 s poll interval catches anything else.

Decisions to check in review

  • Cursor after non-matching events: the returned cursor is the last event actually returned, or the starting point if none were returned. It never skips ahead past non-matching events. That gives the literal "times out with the unchanged cursor" and keeps resuming safe if you change filters. The cost is that a filtered read can re-scan the same non-matching events each time.
  • REST access check: REST has no list_pull_requests route to copy, so it uses the existing GitHub access check. The repository must be configured and enabled, and the caller must be able to read it on GitHub. Otherwise the answer is the usual REPOSITORY_NOT_ACCESSIBLE (404). MCP returns REPOSITORY_FORBIDDEN (403) from its normal grant check.
  • Repository spelling: queries use the configured spelling of the repository, matched case-insensitively. Events written under a different capitalisation than the configuration would not be found.
  • Defaults: limit defaults to 50 (max 100). types must be a known event type, with at most 20 per request.
  • Two things I moved or exported: the new OpenAPI schemas are in their own file, openapi/schemasRepositoryEvents.ts, because schemas.ts is close to the 400-line lint limit. To support that, schemas.ts now exports its component and querySet helpers.

There's nothing visual to preview.

Detailed Logs:

  • Conversation: 262 messages
  • Session: e73ecab9-a01f-4a65-af76-a61fb6de4942

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3484-2026-11-12T21-15-23-178Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3484-2026-11-12T21-15-23-178Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: I've implemented #3484: coordinators can now list and wait on a repository's change events over MCP, REST and the CLI, using the same cursor and error rules everywhere. The new tests pass, along with ...


This PR was created automatically by ProPR after processing issue #3484.


💡 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!

…itory's change events over MCP, REST and the CLI, using the same cursor and error rules everywhere. The new tests pass, along with the OpenAPI, `mcpObservableSurface`, `mcpDocs`, `mcpToolInputBudget`, goal-wait, readiness, socket and core journal suites. The full `npm run test:mcp` run had 460 of 467 passing. All 7 failures are in `relevanceServiceCommit` and fail with `EROFS` because `/tmp/git-processor` is read-only in this container; that suite has nothing to do with this change.

What was added
- MCP: `list_repository_events` and `wait_repository_events` (read scope, in a new `toolsRepositoryEvents.ts`). Repository access is checked the same way as for `list_pull_requests`. The wait receives the request's abort signal, so cancelling the call releases it, and the grant is re-checked before each further read.
- REST: `GET /api/repository-events` and `GET /api/repository-events/wait`, registered with documented schemas and the standard error format. `npm run gen:openapi` output is regenerated and the up-to-date check passes.
- CLI: `propr events list` and `propr events wait` with filter options, `--json` and `--follow`. In follow mode, `--json` prints one JSON line per event, and Ctrl-C prints the cursor to resume from.
- Docs: `docs/mcp.md` has a new section with the cursor contract, at-least-once delivery, an error table and a coordinator loop that waits for events, then calls `get_pull_request_readiness` (which is in the catalog). `docs/mcp-coverage.md`, the API reference and the CLI page are updated, and the new tokens are in the `mcpObservableSurface` allow-list.

How it behaves
- The cursor is `rec1.` + base64url of `{r, s}`, as specified. A call without a cursor returns the current cursor and no history unless `fromStart` is set.
- Cursor errors:
  - `CURSOR_INVALID` (400): malformed, or a position this instance never issued.
  - `CURSOR_WRONG_REPOSITORY` (400).
  - `CURSOR_EXPIRED` (410): below the repository's retention floor. It is never returned as an empty result.
- A wait returns at once if matching events already exist, ignores non-matching ones, and on timeout returns the cursor it started from, unchanged.
- Each owner can have at most 16 waits open per API process, counted across REST and MCP (the same limit as goal waits).
- Waking waiters:
  - An append in the same process wakes them at once. This needed a small new hook in core, `subscribeRepositoryEventAppends`.
  - An append in another process wakes them through the socket relay, which wakes any message naming a repository.
  - The 2.5 s poll interval catches anything else.

Decisions to check in review
- Cursor after non-matching events: the returned cursor is the last event actually returned, or the starting point if none were returned. It never skips ahead past non-matching events. That gives the literal "times out with the unchanged cursor" and keeps resuming safe if you change filters. The cost is that a filtered read can re-scan the same non-matching events each time.
- REST access check: REST has no `list_pull_requests` route to copy, so it uses the existing GitHub access check. The repository must be configured and enabled, and the caller must be able to read it on GitHub. Otherwise the answer is the usual `REPOSITORY_NOT_ACCESSIBLE` (404). MCP returns `REPOSITORY_FORBIDDEN` (403) from its normal grant check.
- Repository spelling: queries use the configured spelling of the repository, matched case-insensitively. Events written under a different capitalisation than the configuration would not be found.
- Defaults: `limit` defaults to 50 (max 100). `types` must be a known event type, with at most 20 per request.
- Two things I moved or exported: the new OpenAPI schemas are in their own file, `openapi/schemasRepositoryEvents.ts`, because `schemas.ts` is close to the 400-line lint limit. To support that, `schemas.ts` now exports its `component` and `querySet` helpers.

There's nothing visual to preview.
@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=10
Triggered automatically by the requested execution settings.

@propr-dev propr-dev Bot added the ultrafix label Nov 12, 2026
@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 10)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds a coherent shared implementation for repository event reads across MCP, REST, and CLI, but needs changes before merge because several paths can silently omit events or issue unusable cursors.

✅ Shared behavior — REST and MCP use the same pagination, filtering, cursor decoding, and wait service.

✅ Wait cleanup — Waiters release subscriptions and owner slots in finally, with tests covering cancellation and grant revocation.

✅ Broad integration coverage — The changes include schemas, generated client types, documentation, and transport tests. Current checks report 34 passed, none failed, and one pending.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Fresh reads can issue expired cursors

  • Required behavior: A read without a cursor must return a usable current cursor, including after retention removes all events.

  • Evidence: packages/api/services/repositoryEventWait.ts, journalBound, resolveStart, and pageResult.

    1. A repository accumulates events, then retention deletes all of them and records a retention floor greater than 1.
    2. A client lists without afterCursor. journalBound finds no retained rows and returns 0; the response therefore issues a cursor at 0.
    3. The client resumes using that returned cursor. resolveStart rejects it as CURSOR_EXPIRED because 0 is below floor_seq - 1.

    The documented recovery—omit the cursor—issues the same expired cursor again. An empty fromStart read and a cursorless wait timeout also produce this problem. The no-cursor branch bypasses retention validation, and existing tests do not cover a completely pruned repository. Verification provenance: static trace.

  • Minimum fix: Include the repository’s retention watermark when establishing its current position, and ensure empty fromStart responses also return a valid resume point. Add coverage for a completely pruned repository.

F2: 🔴 Retention can silently remove unread events

  • Required behavior: Retention that removes events after a supplied cursor must produce CURSOR_EXPIRED, rather than a successful response that silently skips them.

  • Evidence: packages/api/services/repositoryEventWait.ts, listRepositoryEventsAfterCursor and waitForRepositoryEvents.

    1. A client supplies a valid cursor before an unread event that is eligible for retention.
    2. resolveStart reads the old retention floor and accepts the cursor.
    3. Between that awaited validation and readPage, the retention process deletes the unread event and advances the floor. These reads are separate statements without a transaction holding a consistent snapshot.
    4. readPage returns an empty result, or later retained events whose returned cursor advances past the deleted event, without reporting expiration.

    Waits have an additional instance of the same problem: they validate the floor only once, so pruning during their timer wait is never checked on subsequent reads. The upper sequence bound prevents including newer appends; it does not protect against deletion. Verification provenance: static trace over the new service and supplied retention tests.

  • Minimum fix: Validate the retention floor and retrieve each page from a consistent database snapshot, including every wait iteration. Preserve the intentional initial fromStart behavior while detecting loss after the wait establishes its starting position.

F3: 🔴 Repository casing hides valid events

  • Required behavior: Authorized reads must return the target repository’s journal events consistently with case-insensitive repository identity.

  • Evidence: packages/api/mcp/toolsRepositoryEvents.ts, journalRepository; packages/api/routes/repositoryEventRoutes.ts, authorize; packages/api/services/repositoryEventWait.ts, repository equality queries.

    1. A configured repository is spelled acme/app, while GitHub supplies Acme/App in a webhook.
    2. The supplied webhook producer writes payload.repository.full_name directly into the journal, producing a row under Acme/App.
    3. Both new transports resolve the requested repository to configured spelling, acme/app.
    4. The service queries SQLite with case-sensitive where({ repository }), so even fromStart omits the webhook event; waits likewise never return it.

    Cursor decoding, authorization, and wake notifications are case-insensitive, but none changes the journal query. The existing capitalization test changes only the request spelling, not the stored event spelling. Verification provenance: static trace using the supplied producer and SQLite schema.

  • Minimum fix: Apply consistent case-insensitive repository identity to event bounds, page reads, and retention-floor lookup, accounting for existing mixed-case rows. Add a test with configured spelling differing from the stored webhook spelling.

F4: 🔴 Cursorless list retries can skip changes

  • Required behavior: Establishing a follow cursor must not silently move the starting boundary across events because of an automatic transport retry.

  • Evidence: packages/cli/src/api/repositoryEvents.ts, listRepositoryEvents; packages/cli/src/commands/eventCommands.ts, run.

    1. Run propr events list --follow without a cursor or --from-start.
    2. Its initial list request establishes boundary A, but the response is lost through a retryable network failure.
    3. An event is appended after A.
    4. ApiClient automatically retries the list GET because the helper leaves retry at its default. The retry establishes boundary B after that event and returns no history.
    5. The follow loop begins waiting after B, permanently omitting the intervening event without reporting an error.

    The wait helper explicitly disables retries without an existing cursor for this reason, but the list helper used to initialize follow mode does not. Verification provenance: static trace through the supplied ApiClient retry implementation.

  • Minimum fix: Disable automatic retries for cursorless list requests that establish the current boundary, as the wait helper already does. Surface failure if no boundary was received; retain retries for replayable requests.

Suggestions

These are optional follow-ups and are not sent to /fix.

No suggestions.

Score

The shared implementation and coverage are strong, but retention, repository identity, and retry handling still violate the central reliable-resumption contract. These require localized corrections despite the passing current checks.

Score: 5/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 51s
  • Tokens: 77,482 (75,851 in / 1,631 out)
  • Cost: $0.73

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 F2 F3 F4

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 9169cd6

Addressed 1 AI review comment (IDs: 6836600295)

Addressed findings F1, F2, F3, F4

Summary of Changes

I've fixed F1–F4. Each fix has a regression test, and every new test fails on the previous code and passes now: 16/16 in repositoryEventWait.test.ts and 5/5 in eventCommands.test.ts.

F1 – fresh reads issued expired cursors (packages/api/services/repositoryEventWait.ts)

  • The current position is now the newest seq or floor − 1 (the retention watermark), whichever is higher. A repository whose events were all pruned no longer issues cursor 0.
  • If a page isn't truncated, its cursor is never below floor − 1. This covers empty fromStart reads, fromStart reads that only return old events still kept below the floor, and cursorless wait timeouts.
  • A wait that started with a cursor still times out returning that same cursor; for any valid cursor the new rule changes nothing.

F2 – retention could silently remove unread events

  • Each read now runs in one transaction. The cursor check, the retention-floor lookup, the bound and the page all come from the same database snapshot.
  • Every wait iteration does this again. Before it sleeps, the wait sets its starting position to the cursor it would return. A fromStart wait still reads from 0 on its first pass, as intended. Pruning past that position during the wait now gives CURSOR_EXPIRED.
  • The regression test runs retention exactly between the floor lookup and the page read. Before the fix the page silently skipped the deleted event; now it doesn't.

F3 – repository casing hid valid events

  • The bound, the page reads, the retention-floor lookup and the "never issued" check now all match the repository name case-insensitively (COLLATE NOCASE).
  • The floor is the highest one recorded under any spelling, because retention keeps a separate floor for each stored spelling.
  • Returned events now show the configured spelling of the repository rather than the stored one.
  • I added a migration, 20261113000000_add_repository_events_nocase_index.js, with a case-insensitive (repository, seq) index. Without it, the existing index can't be used for these lookups and every wait poll would scan the whole table. I checked with EXPLAIN QUERY PLAN that both queries now use the index.
  • I also corrected the MCP comment that claimed the journal stores the configured spelling.

F4 – cursorless list retries could skip changes (packages/cli/src/api/repositoryEvents.ts)

  • listRepositoryEvents now sends a list with neither a cursor nor --from-start exactly once, so a failure is reported instead of a retry quietly moving the starting point. Lists with a cursor or --from-start still retry (3 attempts); the test checks both cases.
  • In follow mode, both page continuations and wait iterations always pass a cursor, so they keep their retries.

Other checks: ESLint with zero warnings passes on the changed packages/api files; the CLI files aren't covered by any ESLint config. tsc --noEmit passes for packages/api and packages/cli. mcpRepositoryEvents, the core journal, OpenAPI route coverage and the migration-gate tests pass. No docs mention the old casing or cursor behaviour, so none needed changes.

Separate findings, not changed:

  • Pre-existing test failure: mcpObservableSurface.test.ts fails here with Cannot read properties of undefined (reading 'stage'). It fails the same way with my changes reverted, so it predates this work. The original PR summary reported it passing, so it may depend on a stale build of @propr/core.
  • Remaining expired-cursor case: a truncated fromStart page can still issue an expired cursor. It needs events still kept below the floor that are more than limit in number. The cursor format can't tell "nothing after this was pruned" from "events after this were pruned" in that range, so I didn't widen F1 to cover it.
  • Conservative retry setting: the CLI wait helper also disables retries for cursorless fromStart waits, which could safely be retried. I left it as is.

There's nothing visual to preview.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 12m 59s
  • Tokens: 2,837,388 (2,814,224 in / 23,164 out)
  • Cost: $1.49

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

… new test fails on the previous code and passes now: 16/16 in `repositoryEventWait.test.ts` and 5/5 in `eventCommands.test.ts`.

I've fixed F1–F4. Each fix has a regression test, and every new test fails on the previous code and passes now: 16/16 in `repositoryEventWait.test.ts` and 5/5 in `eventCommands.test.ts`.

**F1 – fresh reads issued expired cursors** (`packages/api/services/repositoryEventWait.ts`)
- The current position is now the newest `seq` or `floor − 1` (the retention watermark), whichever is higher. A repository whose events were all pruned no longer issues cursor 0.
- If a page isn't truncated, its cursor is never below `floor − 1`. This covers empty `fromStart` reads, `fromStart` reads that only return old events still kept below the floor, and cursorless wait timeouts.
- A wait that started with a cursor still times out returning that same cursor; for any valid cursor the new rule changes nothing.

**F2 – retention could silently remove unread events**
- Each read now runs in one transaction. The cursor check, the retention-floor lookup, the bound and the page all come from the same database snapshot.
- Every wait iteration does this again. Before it sleeps, the wait sets its starting position to the cursor it would return. A `fromStart` wait still reads from 0 on its first pass, as intended. Pruning past that position during the wait now gives `CURSOR_EXPIRED`.
- The regression test runs retention exactly between the floor lookup and the page read. Before the fix the page silently skipped the deleted event; now it doesn't.

**F3 – repository casing hid valid events**
- The bound, the page reads, the retention-floor lookup and the "never issued" check now all match the repository name case-insensitively (`COLLATE NOCASE`).
- The floor is the highest one recorded under any spelling, because retention keeps a separate floor for each stored spelling.
- Returned events now show the configured spelling of the repository rather than the stored one.
- I added a migration, `20261113000000_add_repository_events_nocase_index.js`, with a case-insensitive `(repository, seq)` index. Without it, the existing index can't be used for these lookups and every wait poll would scan the whole table. I checked with `EXPLAIN QUERY PLAN` that both queries now use the index.
- I also corrected the MCP comment that claimed the journal stores the configured spelling.

**F4 – cursorless list retries could skip changes** (`packages/cli/src/api/repositoryEvents.ts`)
- `listRepositoryEvents` now sends a list with neither a cursor nor `--from-start` exactly once, so a failure is reported instead of a retry quietly moving the starting point. Lists with a cursor or `--from-start` still retry (3 attempts); the test checks both cases.
- In follow mode, both page continuations and wait iterations always pass a cursor, so they keep their retries.

**Other checks:** ESLint with zero warnings passes on the changed `packages/api` files; the CLI files aren't covered by any ESLint config. `tsc --noEmit` passes for `packages/api` and `packages/cli`. `mcpRepositoryEvents`, the core journal, OpenAPI route coverage and the migration-gate tests pass. No docs mention the old casing or cursor behaviour, so none needed changes.

**Separate findings, not changed:**
- **Pre-existing test failure:** `mcpObservableSurface.test.ts` fails here with `Cannot read properties of undefined (reading 'stage')`. It fails the same way with my changes reverted, so it predates this work. The original PR summary reported it passing, so it may depend on a stale build of `@propr/core`.
- **Remaining expired-cursor case:** a truncated `fromStart` page can still issue an expired cursor. It needs events still kept below the floor that are more than `limit` in number. The cursor format can't tell "nothing after this was pruned" from "events after this were pruned" in that range, so I didn't widen F1 to cover it.
- **Conservative retry setting:** the CLI wait helper also disables retries for cursorless `fromStart` waits, which could safely be retried. I left it as is.

There's nothing visual to preview.

PR: #3508
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR provides a well-integrated repository event API across MCP, REST, and CLI, but needs changes before merge. Two cursor recovery paths can prevent coordinators from consuming retained history or observing state changes.

✅ Consistent read implementation — MCP and REST share filtering, pagination, cursor validation, and wait behavior.

✅ Snapshot consistency — Retention checks and event reads occur in one transaction, preventing pruning between validation and page retrieval.

✅ Wait lifecycle coverage — Added tests cover cancellation, owner limits, grant revocation, wakeups, and retention during waits.

The supplied current checks show 31 passed, none failed, and three pending. This review is based on static tracing; no commands were run.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F5: 🔴 Retained-history pagination returns expired cursors

  • Required behavior: fromStart must allow clients to consume retained history through bounded pages, using the returned cursor to retrieve subsequent pages.

  • Evidence: packages/api/services/repositoryEventWait.ts, readSnapshot and resumeSeq.

    1. Append three recent events at sequences 1–3, then a delayed, old-stamped event at sequence 4.
    2. Retention deletes sequence 4 and raises the floor to 5, while retaining sequences 1–3. This retention behavior is explicitly established by the supplied core tests.
    3. Call list_repository_events with fromStart: true and limit: 1. The read returns sequence 1 with truncated: true.
    4. Because the page is truncated, resumeSeq returns sequence 1 unchanged.
    5. Request the next page using that cursor. readSnapshot rejects it because 1 < floor - 1, returning CURSOR_EXPIRED. Restarting with the same parameters repeats the first page indefinitely.

    The remaining retained events cannot be paginated. This also breaks REST pagination and the CLI’s list --from-start --follow loop. The transaction protects snapshot consistency but does not make the emitted continuation valid. The existing below-floor test covers only a complete page, where the floor adjustment conceals this failure.

    static trace: verified against the changed pagination code and supplied retention implementation tests; not executed.

  • Minimum fix: Provide a valid continuation mechanism for explicit retained-history reads below the retention floor, preserving ordinary stale-cursor expiry detection. Do not simply advance a truncated page to the floor, which would skip retained events. Add coverage with multiple retained events below the floor and a limit smaller than their count.

F6: 🔴 Expiry recovery can silently miss changes

  • Required behavior: Cursor expiry recovery must restore a coordinator’s state and establish a continuation boundary without silently losing changes between those operations.

  • Evidence: packages/shared/src/repositoryEventWait.ts, REPOSITORY_EVENT_ERRORS.CURSOR_EXPIRED; packages/api/mcp/toolsRepositoryEvents.ts, CURSOR_CONTRACT; docs/mcp.md, cursor error table.

    1. A coordinator receives CURSOR_EXPIRED and follows the supplied recovery instruction: re-read the state, then continue without a cursor.
    2. The state read completes with state A.
    3. Before the subsequent cursorless request establishes its boundary, another operation changes the repository to state B and appends an event.
    4. The cursorless request starts at the current journal end, placing its boundary after that event. It returns no history and subsequent waits never return the event for B.

    The coordinator remains on state A until some unrelated later event prompts another read. This window exists between two separate client requests; the server’s snapshot transaction cannot cover it, and at-least-once delivery only applies after the new boundary. The same unsafe ordering is emitted as REST recovery hints and MCP error details and repeated in tool descriptions and documentation.

    static trace: verified by combining the changed recovery instructions with readSnapshot’s cursorless end behavior; not executed.

  • Minimum fix: Consistently instruct clients to obtain a fresh boundary first using a cursorless list, then re-read authoritative state, then resume after that saved boundary. Update the shared error hint, MCP description, and documentation together.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Handle errors in coordinator examples

The REST shell example assigns .cursor without checking whether the response is successful. An authorization or transport error can therefore replace the cursor with null and produce repeated invalid requests. Explicit error handling would make this illustrative example more useful; production-grade scripting is an optional documentation improvement.

Score

The shared implementation and focused tests are strong, but retained-history pagination and expiry recovery need correction before merge. Pending checks alone do not lower this assessment.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 7s
  • Tokens: 78,866 (77,333 in / 1,533 out)
  • Cost: $0.74

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F5 F6 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 68b2f58

Addressed 1 AI review comment (IDs: 6837276613)

Addressed findings F5, F6

Summary of Changes

I've fixed F5 and F6. Each has a regression test that fails on the previous code and passes now.

F5: paging through retained history below the floor

  • A cursor inside retained history below the retention floor now also records a short "retention generation". That generation is a digest of the repository's repository_event_floors rows (floor and pruned_at) under every spelling of its name, read in the same transaction as the page (packages/api/services/repositoryEventWait.ts). Such a cursor stays valid below the floor while the generation is unchanged.
  • Expiry detection still works:
    • A plain cursor below floor - 1, or one with a forged generation, still gets CURSOR_EXPIRED.
    • Any later prune of the repository rewrites pruned_at, even one that only deletes events below the floor without moving it. So the history cursor then expires instead of silently skipping an event that aged out.
    • This errs on the safe side: a prune that only deleted events before the cursor also expires it, and the client starts the fromStart read again.
  • Same problem fixed in related paths:
    • The per-event cursors in a page had the same problem; they now carry the generation too, so resuming from the last event processed works.
    • A wait's internal position keeps the generation between re-reads.
    • The REST routes and the CLI list --from-start --follow loop treat the cursor as opaque, so they work without changes.
  • The shared cursor codec (packages/shared/src/repositoryEventWait.ts) accepts an optional, length- and character-checked g field.
  • New tests (repositoryEventWait.test.ts):
    • three retained events below the floor, paged with limit: 1
    • a per-event cursor resumes, while a cursor with no generation or a forged one expires
    • a prune that leaves the floor where it is still expires a history cursor, and starting over works
    • a truncated fromStart wait resumes

F6: recovery order

  • The CURSOR_EXPIRED hint (sent as REST hint and in MCP error details), the MCP CURSOR_CONTRACT in both tool descriptions, docs/mcp.md and the API reference now give the same order: list without afterCursor and save that cursor, then re-read the state, then resume from the saved cursor.
  • CURSOR_INVALID had the same ambiguous "omit, then read" wording, so its hint and docs row now point to the same steps.
  • The new assertion in mcpRepositoryEvents.test.ts checks this order in the REST hint and both tool descriptions.
  • The docs now also explain paging retained history with truncated and when a history cursor expires (docs/mcp.md, api-reference.md, repository-event-journal.md).

Verification: these all pass:

  • repositoryEventWait 19/19
  • mcpRepositoryEvents
  • mcpDocs
  • mcpObservableSurface
  • mcpToolInputBudget
  • CLI eventCommands 5/5
  • the packages/api typecheck and ESLint with zero warnings
  • gen:openapi:check

Something I noticed but didn't change: when a wait that started from a history cursor times out, the cursor it returns has been moved up to floor - 1, so it isn't strictly "unchanged". Nothing is skipped by this, because a page that isn't truncated has already covered everything up to there. It isn't part of F5 or F6.

There's nothing visual to preview.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 10m 14s
  • Tokens: 2,711,244 (2,691,646 in / 19,598 out)
  • Cost: $1.35

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

… on the previous code and passes now.

I've fixed F5 and F6. Each has a regression test that fails on the previous code and passes now.

**F5: paging through retained history below the floor**
- A cursor inside retained history below the retention floor now also records a short "retention generation". That generation is a digest of the repository's `repository_event_floors` rows (floor and `pruned_at`) under every spelling of its name, read in the same transaction as the page (`packages/api/services/repositoryEventWait.ts`). Such a cursor stays valid below the floor while the generation is unchanged.
- **Expiry detection still works:**
  - A plain cursor below `floor - 1`, or one with a forged generation, still gets `CURSOR_EXPIRED`.
  - Any later prune of the repository rewrites `pruned_at`, even one that only deletes events below the floor without moving it. So the history cursor then expires instead of silently skipping an event that aged out.
  - This errs on the safe side: a prune that only deleted events before the cursor also expires it, and the client starts the `fromStart` read again.
- **Same problem fixed in related paths:**
  - The per-event cursors in a page had the same problem; they now carry the generation too, so resuming from the last event processed works.
  - A wait's internal position keeps the generation between re-reads.
  - The REST routes and the CLI `list --from-start --follow` loop treat the cursor as opaque, so they work without changes.
- The shared cursor codec (`packages/shared/src/repositoryEventWait.ts`) accepts an optional, length- and character-checked `g` field.
- **New tests** (`repositoryEventWait.test.ts`):
  - three retained events below the floor, paged with `limit: 1`
  - a per-event cursor resumes, while a cursor with no generation or a forged one expires
  - a prune that leaves the floor where it is still expires a history cursor, and starting over works
  - a truncated `fromStart` wait resumes

**F6: recovery order**
- The `CURSOR_EXPIRED` hint (sent as REST `hint` and in MCP error details), the MCP `CURSOR_CONTRACT` in both tool descriptions, `docs/mcp.md` and the API reference now give the same order: list without `afterCursor` and save that cursor, then re-read the state, then resume from the saved cursor.
- `CURSOR_INVALID` had the same ambiguous "omit, then read" wording, so its hint and docs row now point to the same steps.
- The new assertion in `mcpRepositoryEvents.test.ts` checks this order in the REST hint and both tool descriptions.
- The docs now also explain paging retained history with `truncated` and when a history cursor expires (`docs/mcp.md`, `api-reference.md`, `repository-event-journal.md`).

**Verification:** these all pass:
- `repositoryEventWait` 19/19
- `mcpRepositoryEvents`
- `mcpDocs`
- `mcpObservableSurface`
- `mcpToolInputBudget`
- CLI `eventCommands` 5/5
- the `packages/api` typecheck and ESLint with zero warnings
- `gen:openapi:check`

**Something I noticed but didn't change:** when a wait that started from a history cursor times out, the cursor it returns has been moved up to `floor - 1`, so it isn't strictly "unchanged". Nothing is skipped by this, because a page that isn't truncated has already covered everything up to there. It isn't part of F5 or F6.

There's nothing visual to preview.

PR: #3508
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds a shared repository-event reader across MCP, REST, and CLI, with substantial coverage of pagination, retention, authorization, and wakeups. It needs localized corrections before merge.

✅ Consistent read snapshots — Cursor validation, retention checks, bounds, and page reads share a transaction, preventing retention from deleting unread rows between those operations.

✅ Useful regression coverage — Tests cover case-insensitive repository identity, retained history below the floor, grant revocation, and waiter cleanup.

The supplied current checks show 34 passed, none failed, and one pending. This review used static analysis only; no commands were run.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F7: 🔴 Filtered history advances past unreturned events

  • Required behavior: The returned cursor must stop at the last returned event, or remain at the starting position when nothing matches, preserving safe resumption when filters change.

  • Evidence: packages/api/services/repositoryEventWait.ts, resumeSeq and pageResult.

    1. A repository contains retained opened event at sequence 1 and retained merged event at sequence 2. An older-stamped event at sequence 3 is pruned, making the retention floor 4.
    2. A client lists with fromStart: true and types: ['opened']. The page returns sequence 1 and is not truncated because no further events match that filter.
    3. resumeSeq applies Math.max(seq, snapshot.floor - 1) and returns a response cursor at sequence 3.
    4. Resuming with that response cursor and types: ['merged'] silently skips the retained event at sequence 2.

    static trace: The same promotion occurs for an empty filtered page and affects both list and wait responses. truncated describes matching events only, so it cannot establish that all retained events below the floor were consumed. The existing generation-aware cursors already permit resumption below the floor, but this branch discards that position. Existing tests verify unfiltered floor promotion rather than this filter-change sequence.

  • Minimum fix: Preserve the last returned or starting sequence for filtered reads, using generation-aware cursors below the floor. Add a regression covering resumption with changed filters after a complete or empty filtered page.

F8: 🔴 Ctrl-C does not stop CLI history draining

  • Required behavior: CLI follow mode must stop on interruption and provide the cursor needed to resume.

  • Evidence: packages/cli/src/commands/eventCommands.ts, run history-pagination loop; packages/cli/src/api/repositoryEvents.ts, listRepositoryEvents.

    1. Run propr events list --from-start --follow against history spanning multiple pages.
    2. Press Ctrl-C while a list request is awaiting its response. The installed handler only aborts the controller.
    3. List requests receive no abort signal, and the pagination loop never checks controller.signal.aborted; it continues fetching and printing every remaining page.
    4. Once history is drained, follow sees the aborted signal and returns normally. run returns exit code 130 without printing the resume cursor.

    static trace: Cancellation reporting exists only in the RequestCancelledError catch branch, which this path does not enter. Large histories therefore continue processing after interruption, and human-readable output provides no cursor for the last printed event. Single-page list requests likewise suppress the normal SIGINT exit while their request remains pending.

  • Minimum fix: Pass the abort signal through list requests, stop pagination when aborted, and centralize interruption reporting so every interrupted exit prints the last processed cursor.

F9: 🔴 Disconnect during authorization leaves a waiter running

  • Required behavior: Disconnecting a REST request must release its repository-event wait.

  • Evidence: packages/api/routes/repositoryEventRoutes.ts, waitEvents.

    1. An authenticated client requests /api/repository-events/wait; waitEvents awaits authorize, including the asynchronous GitHub access check.
    2. The client disconnects while that check is pending. The response emits close before the route attaches its listener.
    3. Authorization succeeds. The route attaches a listener to the already-closed response and starts waitForRepositoryEvents with an unaborted signal.
    4. The abandoned request consumes an owner wait slot and performs journal reads until an event arrives or the timeout expires. Sixteen such abandoned requests exhaust the owner's allowance and cause subsequent live requests to receive WAIT_LIMIT.

    static trace: The listener is registered only after await authorize(...), and there is no check for an already-destroyed response. The service's pre-aborted-signal guard cannot help because the missed close event never aborts this controller. The timeout eventually cleans up, but does not provide disconnect cancellation.

  • Minimum fix: Establish disconnect tracking before awaiting authorization, check whether the connection has already closed before allocating a waiter, and remove the listener on every exit path.

Suggestions

These are optional follow-ups and are not sent to /fix.

S2: 🟢 Refresh the architecture introduction

docs/docs/architecture/repository-event-journal.md still says the client read/wait interface will arrive in a follow-up change. Update that sentence to link to the newly added interfaces. This is optional documentation cleanup.

Score

The shared implementation and regression coverage are strong, but cursor advancement and cancellation defects remain in the new behavior. These require localized fixes before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 1s
  • Tokens: 84,136 (82,552 in / 1,584 out)
  • Cost: $0.80

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F7 F8 F9 S2

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 90a586a

Addressed 1 AI review comment (IDs: 6837968042)

Addressed findings F7, F8, F9

Summary of Changes

I fixed F7, F8 and F9. Each one has a regression test that fails on the previous code and passes now.

F7 – filtered reads skipped retained events (packages/api/services/repositoryEventWait.ts)

  • The returned cursor used to jump to the retention floor whenever a page wasn't truncated. But "truncated" only counts events that match the filter, so a read filtered to opened could skip a retained merged event.
  • Now, in the same database snapshot as the read, the cursor moves up to the floor only when no retained event of the repository (matching the filter or not) lies between the last returned position and the floor. Otherwise it stays at the last returned event, or at the starting position if nothing matched. A cursor left below the floor carries the retention generation.
  • List and wait both use this one position, including the position a wait keeps between its reads.
  • New test: your scenario (opened at 1, merged at 2, pruned event at 3). It covers a complete filtered page, an empty filtered page, the same reads as waits, and resuming with a different filter. On the old code the cursor came back as 3 instead of 1.

F8 – Ctrl-C didn't stop the CLI while it read history (packages/cli/src/commands/eventCommands.ts, packages/cli/src/api/repositoryEvents.ts)

  • listRepositoryEvents now takes { client, signal } and passes the abort signal to the request.
  • The paging loop stops as soon as Ctrl-C is pressed.
  • One interrupted() helper now handles every interrupted exit: a cancelled request, --follow ending, or a response that arrives just as Ctrl-C is pressed. Each prints Resume with --after-cursor <last processed cursor> and exits with 130.
  • The command body is exported as runEventsCommand so tests can pass in a client and configuration.
  • New tests cover Ctrl-C:
    • during the second history page: no further requests are sent, and the cursor of the page already printed is shown.
    • during a single list.
    • during a followed wait.
  • With the old behaviour, the first case hangs on the request that never gets cancelled.

F9 – a disconnect during the access check left a wait running (packages/api/routes/repositoryEventRoutes.ts)

  • The route now attaches its close listener before it awaits authorization.
  • After authorization, it checks whether the connection is already gone and, if so, returns without starting a wait.
  • The listener is removed in finally, so every exit path cleans it up.
  • New file packages/api/test/repositoryEventRoutes.test.ts, added to test:mcp in package.json. It checks that:
    • a disconnect while the access check is pending starts no wait and leaves the owner's only wait slot free for the next request.
    • a connection already closed starts no wait.
    • a disconnect during the wait releases it.
    • the listener is removed after a denied request and after an unexpected error.
  • The first two fail on the old route.

Checks: typecheck passes for packages/api and packages/cli, and ESLint with zero warnings passes on the changed API files (packages/cli has no ESLint setup). These suites all pass: repositoryEventWait (20 tests), repositoryEventRoutes (3), mcpRepositoryEvents, the OpenAPI tests and eventCommands (8).

Found separately, not changed: in the service's wait loop, if the wait is cancelled while the grant re-check (authorize) is running, it still makes one more journal read before it notices. If events exist, it returns them to a caller that has already gone. That costs one wasted read and loses nothing.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 12m 17s
  • Tokens: 2,924,255 (2,902,340 in / 21,915 out)
  • Cost: $1.50

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…fails on the previous code and passes now.

I fixed F7, F8 and F9. Each one has a regression test that fails on the previous code and passes now.

**F7 – filtered reads skipped retained events** (`packages/api/services/repositoryEventWait.ts`)
- The returned cursor used to jump to the retention floor whenever a page wasn't truncated. But "truncated" only counts events that match the filter, so a read filtered to `opened` could skip a retained `merged` event.
- Now, in the same database snapshot as the read, the cursor moves up to the floor only when no retained event of the repository (matching the filter or not) lies between the last returned position and the floor. Otherwise it stays at the last returned event, or at the starting position if nothing matched. A cursor left below the floor carries the retention generation.
- List and wait both use this one position, including the position a wait keeps between its reads.
- New test: your scenario (opened at 1, merged at 2, pruned event at 3). It covers a complete filtered page, an empty filtered page, the same reads as waits, and resuming with a different filter. On the old code the cursor came back as 3 instead of 1.

**F8 – Ctrl-C didn't stop the CLI while it read history** (`packages/cli/src/commands/eventCommands.ts`, `packages/cli/src/api/repositoryEvents.ts`)
- `listRepositoryEvents` now takes `{ client, signal }` and passes the abort signal to the request.
- The paging loop stops as soon as Ctrl-C is pressed.
- One `interrupted()` helper now handles every interrupted exit: a cancelled request, `--follow` ending, or a response that arrives just as Ctrl-C is pressed. Each prints `Resume with --after-cursor <last processed cursor>` and exits with 130.
- The command body is exported as `runEventsCommand` so tests can pass in a client and configuration.
- New tests cover Ctrl-C:
  - during the second history page: no further requests are sent, and the cursor of the page already printed is shown.
  - during a single `list`.
  - during a followed `wait`.
- With the old behaviour, the first case hangs on the request that never gets cancelled.

**F9 – a disconnect during the access check left a wait running** (`packages/api/routes/repositoryEventRoutes.ts`)
- The route now attaches its `close` listener before it awaits authorization.
- After authorization, it checks whether the connection is already gone and, if so, returns without starting a wait.
- The listener is removed in `finally`, so every exit path cleans it up.
- New file `packages/api/test/repositoryEventRoutes.test.ts`, added to `test:mcp` in `package.json`. It checks that:
  - a disconnect while the access check is pending starts no wait and leaves the owner's only wait slot free for the next request.
  - a connection already closed starts no wait.
  - a disconnect during the wait releases it.
  - the listener is removed after a denied request and after an unexpected error.
- The first two fail on the old route.

**Checks:** typecheck passes for `packages/api` and `packages/cli`, and ESLint with zero warnings passes on the changed API files (`packages/cli` has no ESLint setup). These suites all pass: `repositoryEventWait` (20 tests), `repositoryEventRoutes` (3), `mcpRepositoryEvents`, the OpenAPI tests and `eventCommands` (8).

**Found separately, not changed:** in the service's wait loop, if the wait is cancelled while the grant re-check (`authorize`) is running, it still makes one more journal read before it notices. If events exist, it returns them to a caller that has already gone. That costs one wasted read and loses nothing.

PR: #3508
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds a coherent shared implementation for repository event reads across MCP, REST, and CLI. It needs a localized input-validation correction before merge.

✅ Snapshot consistency — Cursor validation, retention metadata, and event pagination run within one transaction, preventing retention from deleting unread rows between validation and retrieval.

✅ Wait cleanup — Waiters release subscriptions and owner slots in finally; REST also tracks disconnects during authorization.

✅ Focused coverage — Added tests cover retained-history pagination, case-insensitive repository identity, cancellation, grant revocation, and CLI retry behavior.

The supplied current checks show 31 passed, three pending, and no failures. This review uses static analysis only; no commands were run.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F10: 🔴 Reject empty REST cursors

  • Required behavior: Malformed cursors must produce an explicit cursor error rather than silently establish a new boundary that omits unread events.

  • Evidence: packages/api/routes/repositoryEventRoutes.ts:single, parseQuery

    1. A caller sends GET /api/repository-events?repository=acme/app&afterCursor= while the repository contains events it has not processed.
    2. single() converts the explicitly supplied empty string to undefined. parseQuery() consequently passes no cursor to the journal service.
    3. parseStart() selects end, and the response successfully returns the newest cursor with no history. Persisting that response cursor skips the unread events instead of alerting the caller to its malformed input.
    4. The wait endpoint uses the same parser and silently establishes the same later boundary.

    The shared cursor decoder would reject an empty string, and MCP explicitly requires a nonempty cursor, but REST removes the value before either protection can apply. The added REST tests exercise a nonempty malformed cursor, which takes a different path. Verification provenance: static trace of the supplied parser and journal service; proposed regression: send an explicit empty cursor to both REST handlers and assert an error without a replacement cursor.

  • Minimum fix: Distinguish an absent afterCursor from an explicitly empty or incorrectly shaped value. Preserve the empty string for cursor validation, or reject it explicitly; apply the correction to both REST endpoints.

Suggestions

These are optional follow-ups and are not sent to /fix.

S3: 🟢 Handle errors in coordinator example

The new shell loop in docs/docs/operations/api-reference.md unconditionally replaces its cursor with .cursor, including on error responses. A CURSOR_EXPIRED response therefore changes it to null and leads to repeated invalid-cursor requests. Adding explicit error handling and the documented recovery sequence would make this illustrative example more useful; it is optional documentation improvement.

S4: 🟢 Refresh journal overview

docs/docs/architecture/repository-event-journal.md still says the read and wait interface comes in a follow-up change. Replace that sentence with links to the newly added interfaces. This is a small documentation cleanup.

Score

The implementation has substantial focused coverage and careful retention handling, but REST currently turns malformed cursor input into a successful boundary reset. The correction is localized; remaining checks are pending rather than failing.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 21s
  • Tokens: 85,881 (84,155 in / 1,726 out)
  • Cost: $0.82

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F10 S3 S4

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit cb9e4dd

Addressed 1 AI review comment (IDs: 6838657567)

Addressed finding F10

Summary of Changes

I fixed F10: an explicitly empty or wrongly shaped afterCursor now gets a cursor error on both REST endpoints. Before, it was quietly treated as "no cursor" and returned the newest cursor, which would skip unread events.

The fix (packages/api/routes/repositoryEventRoutes.ts)

  • afterCursor no longer goes through single(), which turns empty values into "absent". A new cursor() helper only treats the cursor as absent when the key is actually missing from the query.
  • If the key is present but holds an empty string (?afterCursor= or a bare ?afterCursor) or something that isn't a string (?afterCursor[x]=y), the request gets 400 CURSOR_INVALID with the usual hint and no cursor. This uses the same error and recovery text as the journal's own cursor decoder.
  • The check runs while the query is parsed, before any read or wait starts. So the wait endpoint never opens a waiter, and the response handler's close listener is still removed on this path.
  • Two existing behaviours are unchanged: a repeated cursor still gets "may be given once", and one over 512 characters still gets "too long" (both INVALID_INPUT).

Regression test (packages/api/test/repositoryEventRoutes.test.ts)

  • The test adds an unread event, then sends '', [''], {x:'y'} and [{x:'y'}] as afterCursor to both endpoints.
  • For each, it checks for a 400 CURSOR_INVALID with a hint, no replacement cursor, the journal never being read, and no close listener left behind. It then repeats the empty-cursor case against the real journal service.
  • Finally, it checks that leaving afterCursor out entirely still starts at the current end.
  • The test fails on the previous route code and passes now.

Checks: repositoryEventRoutes, repositoryEventWait and mcpRepositoryEvents pass 25/25. ESLint with --max-warnings 0 is clean on both changed files, and the packages/api typecheck shows no errors in these files. That typecheck doesn't cover test files, so the new test is only checked by running it.

Other paths I checked, which needed no change:

  • MCP: it already rejects an empty cursor (z.string().min(1)).
  • CLI: it sends --after-cursor "" to the server as afterCursor= instead of dropping it, so the fix covers it.
  • Other REST parameters: single() still treats empty planId, limit and similar values as absent. That doesn't lose events, so I left it alone.

This change has nothing visual, so there's no preview.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 6m 32s
  • Tokens: 1,128,006 (1,119,640 in / 8,366 out)
  • Cost: $0.67

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…rsor` now gets a cursor error on both REST endpoints. Before, it was quietly treated as "no cursor" and returned the newest cursor, which would skip unread events.

I fixed F10: an explicitly empty or wrongly shaped `afterCursor` now gets a cursor error on both REST endpoints. Before, it was quietly treated as "no cursor" and returned the newest cursor, which would skip unread events.

**The fix** (`packages/api/routes/repositoryEventRoutes.ts`)
- `afterCursor` no longer goes through `single()`, which turns empty values into "absent". A new `cursor()` helper only treats the cursor as absent when the key is actually missing from the query.
- If the key is present but holds an empty string (`?afterCursor=` or a bare `?afterCursor`) or something that isn't a string (`?afterCursor[x]=y`), the request gets `400 CURSOR_INVALID` with the usual hint and no cursor. This uses the same error and recovery text as the journal's own cursor decoder.
- The check runs while the query is parsed, before any read or wait starts. So the wait endpoint never opens a waiter, and the response handler's close listener is still removed on this path.
- Two existing behaviours are unchanged: a repeated cursor still gets "may be given once", and one over 512 characters still gets "too long" (both `INVALID_INPUT`).

**Regression test** (`packages/api/test/repositoryEventRoutes.test.ts`)
- The test adds an unread event, then sends `''`, `['']`, `{x:'y'}` and `[{x:'y'}]` as `afterCursor` to both endpoints.
- For each, it checks for a 400 `CURSOR_INVALID` with a hint, no replacement cursor, the journal never being read, and no close listener left behind. It then repeats the empty-cursor case against the real journal service.
- Finally, it checks that leaving `afterCursor` out entirely still starts at the current end.
- The test fails on the previous route code and passes now.

**Checks:** `repositoryEventRoutes`, `repositoryEventWait` and `mcpRepositoryEvents` pass 25/25. ESLint with `--max-warnings 0` is clean on both changed files, and the `packages/api` typecheck shows no errors in these files. That typecheck doesn't cover test files, so the new test is only checked by running it.

**Other paths I checked, which needed no change:**
- **MCP:** it already rejects an empty cursor (`z.string().min(1)`).
- **CLI:** it sends `--after-cursor ""` to the server as `afterCursor=` instead of dropping it, so the fix covers it.
- **Other REST parameters:** `single()` still treats empty `planId`, `limit` and similar values as absent. That doesn't lose events, so I left it alone.

This change has nothing visual, so there's no preview.

PR: #3508
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

CI failed: Validate unsigned linux-x64 package

Please investigate and fix this CI failure.

  • Check: Validate unsigned linux-x64 package
  • Result: failure
  • Commit: cb9e4ddad2da (cb9e4ddad2da5566d2616c8cb553efedb2241d03)
  • Details: View CI failure

Failure evidence

.github:82
Process completed with exit code 1.

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 341672e

Summary of Changes

I fixed the failing check, and the two audits it runs now pass locally. Nothing in this PR's code caused the failure.

Cause: The failing step was "Audit committed dependency resolution", which runs npm run audit:runtime and then npm run desktop:audit:packaging. It failed with Blocking vulnerabilities: @hono/node-server because two moderate advisories were published recently: GHSA-qv5m-9pm6-hqp3 and GHSA-jpvv-r467-5p4w. Both cover versions 2.0.0 to 2.1.5. The lockfile pinned 2.1.5, which is the same version main has, so main will fail this check too.

Fix: I changed only package-lock.json, moving @hono/node-server from 2.1.5 to 2.1.8. That version is already allowed by the ranges that @modelcontextprotocol/node and @modelcontextprotocol/sdk declare, so no package.json changed and no other package moved. I didn't add any audit exceptions.

Checks:

  • npm run audit:runtime and npm run desktop:audit:packaging both pass.
  • Running npm install --package-lock-only with npm 10, the version CI uses, leaves the new lockfile exactly as it is.
  • Regenerating the third-party license notices changed nothing except the generated date, so I left THIRD_PARTY_LICENSES.md as it was.

Other PRs will keep failing this check until main gets the same lockfile bump.

There's nothing visual to preview.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-dev[bot]
  • Time: 5m 41s
  • Tokens: 835,640 (832,450 in / 3,190 out)
  • Cost: $0.44

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 6838882742✓

…ass locally. Nothing in this PR's code caused the failure.

I fixed the failing check, and the two audits it runs now pass locally. Nothing in this PR's code caused the failure.

**Cause:** The failing step was "Audit committed dependency resolution", which runs `npm run audit:runtime` and then `npm run desktop:audit:packaging`. It failed with `Blocking vulnerabilities: @hono/node-server` because two moderate advisories were published recently: GHSA-qv5m-9pm6-hqp3 and GHSA-jpvv-r467-5p4w. Both cover versions 2.0.0 to 2.1.5. The lockfile pinned 2.1.5, which is the same version `main` has, so `main` will fail this check too.

**Fix:** I changed only `package-lock.json`, moving `@hono/node-server` from 2.1.5 to 2.1.8. That version is already allowed by the ranges that `@modelcontextprotocol/node` and `@modelcontextprotocol/sdk` declare, so no `package.json` changed and no other package moved. I didn't add any audit exceptions.

**Checks:**
- `npm run audit:runtime` and `npm run desktop:audit:packaging` both pass.
- Running `npm install --package-lock-only` with npm 10, the version CI uses, leaves the new lockfile exactly as it is.
- Regenerating the third-party license notices changed nothing except the generated date, so I left `THIRD_PARTY_LICENSES.md` as it was.

Other PRs will keep failing this check until `main` gets the same lockfile bump.

There's nothing visual to preview.

PR: #3508
Comment by: @propr-dev[bot] (ID: 6838882742)
Model: Claude Opus 5.5
propr-dev Bot pushed a commit that referenced this pull request Nov 12, 2026
… nothing in this PR's own code caused them.

I fixed both failing CI checks with a lockfile-only update; nothing in this PR's own code caused them.

**Cause:** both package jobs failed at the "Audit committed dependency resolution" step. The audit flagged `@hono/node-server` 2.1.5, which two advisories published since the last green run cover (GHSA-qv5m-9pm6-hqp3 and GHSA-jpvv-r467-5p4w, both for versions below 2.1.6). Main's lockfile still has 2.1.5, so the failure isn't specific to this PR. Open PR #3508 has the same fix but isn't merged yet.

**Fix:** in `package-lock.json`, `@hono/node-server` goes from 2.1.5 to 2.1.8. That's inside the range the project already allows, so no `package.json` change was needed and nothing else in the lockfile moved. I made the update with npm 11.

**Checks:**
- Re-running `npm install --package-lock-only` with npm 10 (the version CI uses on Node 22) leaves the lockfile byte-identical.
- `npm run audit:runtime` and `npm run desktop:audit:packaging` both pass. Together these are the step that failed in CI.

Whichever of this PR or #3508 merges second will either conflict on this one line or merge cleanly, since both make the same change.

There is no visual change, so I didn't create a preview.

PR: #3513
Comment by: @propr-dev[bot] (ID: 6839148834)
Comment by: @propr-dev[bot] (ID: 6839149152)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds a shared repository-event reader and bounded waiter across MCP, REST, and CLI. The implementation appears merge-ready within scope, conditional on the two pending checks completing successfully. This review was static; no commands were run or files modified.

✅ Consistent journal snapshots — Cursor validation, retention state, bounds, and page reads share a transaction, preventing retention from silently removing unread events between validation and retrieval.

✅ Careful waiter lifecycle — Waiters subscribe before reading, retain wake-ups during reads, support cancellation, and release listeners and owner slots in finally. REST also tracks disconnection during authorization.

✅ Targeted regression coverage — Added tests cover pagination below retention floors, mixed repository capitalization, grant revocation, cancellation, and non-replayable cursorless CLI requests.

The supplied current-head status reports 32 passing checks, no failures, and two pending checks.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S5: 🟢 Initialize coordinator state explicitly

The coordinator examples in docs/mcp.md and docs/docs/operations/api-reference.md begin by waiting without a cursor and read readiness only after an event arrives. A PR already ready before the loop starts may therefore remain unnoticed until another journal event occurs. Consider demonstrating initialization as: list without a cursor, save that boundary, read current readiness, then wait from the saved cursor. This improves the examples’ usefulness; the implemented future-event waiting behavior is consistent with its contract.

S6: 🟢 Refresh the journal architecture introduction

docs/docs/architecture/repository-event-journal.md still says the client read-and-wait interface will arrive in a follow-up change. Update that sentence to link to the interfaces introduced here, and include the new case-insensitive index in its index inventory. These are optional documentation corrections and do not affect runtime behavior.

Score

The implementation has strong coverage of cursor retention and asynchronous cleanup, with no verified merge blocker in the supplied diff. Final merge readiness remains conditional on the pending checks.

Score: 8/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 3s
  • Tokens: 86,278 (85,149 in / 1,129 out)
  • Cost: $0.80

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S5 S6

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 12, 2026
@integry
integry merged commit 79c60f6 into 3482-epic-integration-signals-100 Nov 13, 2026
50 checks passed
@propr-dev propr-dev Bot mentioned this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant