Skip to content

Read and wait on repository change events over REST, MCP and CLI #3484

Closed

Description

@integry

Problem

With the journal from the previous issue in place, a coordinator still needs a way to consume it: list events after a cursor, and block until something relevant happens instead of polling six reads.

What to build

Follow the wait_goal design (packages/api/services/goalWait.ts, packages/api/mcp/toolsGoalWait.ts, packages/shared/src/goalWait.ts).

  • MCP list_repository_events (scope read): args repository, afterCursor?, domains?, types?, pullRequest?, planId?, limit (max 100). Returns {events, cursor, truncated}.
  • MCP wait_repository_events (scope read, blocking read that receives the abort signal): same filters plus timeoutSeconds (default 15, max 30). Returns {outcome: events|timeout, events, cursor, waitedMs, timeoutSeconds}. Returns immediately when matching events already exist after the cursor.
  • REST GET /api/repository-events and GET /api/repository-events/wait with the same parameters, registered, documented and schema'd.
  • CLI propr events list and propr events wait (--json, --follow loops on the cursor).

Cursor

Opaque string (rec1. + base64url of {r: repository, s: seq}). Errors: CURSOR_INVALID, CURSOR_WRONG_REPOSITORY, CURSOR_EXPIRED (cursor below the retention floor), WAIT_LIMIT, WAIT_ABORTED, INVALID_INPUT. A call without a cursor starts at the current end of the journal (it returns the current cursor and no history) unless fromStart: true is passed.

Behaviour

  • At-least-once, ordered by seq; a client resumes with the last cursor it processed.
  • Limit concurrent waits per owner per API process (same order of magnitude as goal waits) and reuse the in-process wake hub idea so an append in the same process wakes waiters at once; other processes are covered by the poll interval.
  • Authorisation: the caller must have read access to the repository, the same check list_pull_requests applies. Events of other repositories are never returned.
  • Event shape returned: {cursor, domain, type, repository, pullRequest?, issueNumber?, planId?, entityId, head?, payload, occurredAt}.

Acceptance criteria

  • Listing after a cursor returns exactly the later events in order; filters by domain, type, pull request and plan work.
  • Wait returns immediately on existing events, wakes on a new matching event, ignores non-matching events, and times out with the unchanged cursor.
  • Every cursor error is covered by a test; an expired cursor is distinguishable from an empty result.
  • Wait limit and abort are covered.
  • A caller without repository access gets the standard authorisation error.
  • npm run gen:openapi output committed; OpenAPI coverage/conformance, mcpObservableSurface, mcpDocs, mcpToolInputBudget tests pass.
  • docs/mcp.md, docs/mcp-coverage.md and the API reference document both tools, the cursor contract, at-least-once delivery and a short "coordinator loop" example (wait for events, then read get_pull_request_readiness).

Implementation

  1. Shared constants and cursor codec in packages/shared.
  2. packages/api/services/repositoryEventWait.ts modelled on goalWait.ts (poll interval, wake hub, per-owner limit, abort).
  3. REST handlers + registry + route docs + schemas; MCP tools in a new packages/api/mcp/toolsRepositoryEvents.ts registered in the catalog.
  4. CLI commands.
  5. Tests modelled on packages/api/test/goalWait.test.ts, mcpGoalWait.test.ts and the goal wait harness.
  6. Regenerate OpenAPI/client types; docs and allow-list updates.

Notes

Depends on the journal issue (table and listRepositoryEvents). The readiness tool from the first issue may not be on this branch's base if work is reordered; the docs example can reference it by name only if it exists in the catalog, otherwise leave the example to the readiness read's own docs (the mcpObservableSurface test rejects unknown tool names in docs/mcp.md).

Activity

  1. propr-dev commented on Nov 12, 2026

    @propr-dev
    Contributor

    🤖 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:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3484/claude-opus-5-5-read-and-wait-on-reposito-20261112-2048-wgw
    • Base Branch: 3482-epic-integration-signals-100
    • Worktree: issue-3484-20261112-2048-claude-opus-5-5-wgw

    🔍 Track Task Execution

  2. added a commit that references this issue on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions