Skip to content

[CR-2][P1] Add a main-owned, revision-aware GitHub PR read service #321

Closed

Description

@BunsDev

Outcome

A signed-in Modex user can retrieve a PR inbox, PR overview/activity/checks and revision-bound changed files through one narrow main-process service. Loading, partial, stale, denied and offline outcomes remain distinguishable. This is read-only: no checkout, comment, review submission, merge or provider inference.

Parent: #319. Blocked by: #320's accepted placement, source map, shared PrKey/PrRevision/ReadResult contract and synthetic fixtures. CR-3 may build UI against that contract in parallel. Produces the live read adapter consumed by CR-4/5/6/7; parent closure is not a prerequisite.

Current context / entry points

Audit baseline cb33db5df00e235f68d36b5fac556dc30e0851f2; verify latest main before work. Read AGENTS.md, apps/desktop/package.json, docs/status.md, the accepted #320 source map, apps/desktop/src/shared/types.ts, and the existing main/preload/renderer bridge and GitHub identity code found there. Existing engine/git.ts and ChangesPanel.tsx own local working-tree operations and must remain separate.

Proposed additions, only if not already represented by smaller existing modules: apps/desktop/src/main/engine/code-review/read-service.ts, apps/desktop/test/code-review-read-service.test.ts. Extend the accepted shared contract rather than duplicating it. The exact existing IPC registration and auth owner must come from source inspection, not guessed filenames.

Items to do

  • Trace the current GitHub connection and credential owner end to end. Document supported principal/host/scope and missing permissions. Reuse that path; Modex/WorkOS identity, model-provider sign-in and GitHub authority are different. Do not introduce another sign-in system or ask for unnecessarily broad tokens.
  • Write failing tests for narrow operations: list/search authored and review-requested PRs; resolve a canonical PR locator; get detail/activity/reviews/checks; list files; fetch patch or bounded context at the requested revision. Define concrete method signatures in the [CR-1][P1] Establish the Code Review reference contract and deterministic fixtures #320 contract before consumers bind to them.
  • Validate IPC sender/session, request schema, account association, host, canonical repository identity, positive PR number, supported operation and size limits in main. Use fixed GitHub endpoints/validated path segments; never execute shell strings or accept arbitrary network URLs from the renderer.
  • Bind response/cache keys to authenticated account, stable repo ID, PR number and where relevant base/head SHA. Use a request generation/cancellation ID so an old response cannot overwrite a newly selected PR/account. Main owns transport cancellation, timeouts and bounded concurrency.
  • Implement pagination and explicit completeness metadata for inbox, comments/reviews/checks and changed files. Respect provider caps, omitted patches, rate-limit responses, retry-after/backoff and conditional requests where supported. Deduplicate pages by stable IDs without claiming that a truncated result is complete.
  • Preserve provider status/conclusion distinctions and source commit IDs. Pending, cancelled, neutral, skipped, failed and unavailable are not one boolean. A check on another head is stale evidence, not current success. Do not calculate merge authority from green check counts.
  • Keep private response caches memory-bounded by default. Account switch/sign-out invalidates visibility and active requests; persisted drafts belong to the later write issue and cannot leak across accounts. Redact diagnostic payloads; tokens never reach renderer state, logs, snapshots, Notes or AI context.
  • Expose capabilities with unavailable reasons; a missing connection is not an empty inbox. Add explicit Refresh and safe retry behavior for reads. Avoid per-PR background polling when views are hidden; document a bounded refresh/cache strategy and measure it.

Acceptance criteria

  • AC1: synthetic list→detail→files workflow uses the real main/IPC path with account/repository isolation and no local filesystem mutation.
  • AC2: switching between identical PR numbers in different repositories/accounts never displays the old response. Switching accounts during a delayed request rejects its result.
  • AC3: expired/revoked credentials, inaccessible repository, malformed URL, timeout, rate limiting, partial pagination and omitted patch fixtures produce accurate recoverable states without secret leakage.
  • AC4: head changes invalidate or label old diff/check data; no mixed-revision snapshot is silently presented as coherent. A read without a stable revision is visibly provisional.
  • AC5: authenticated read-only smoke evidence against a user-authorized repository is recorded separately from mocks, including account/host, PR and head SHA without credentials. If unavailable, this gate remains open.
  • AC6: existing local Changes, GitHub connection and unrelated provider login tests remain green; no new broad permissions, cloud service or write endpoint is introduced.

Validation / handoff

Add table-driven Node tests for each failure and race above, plus an IPC integration test. Run pnpm build && pnpm test; any renderer changes also pnpm test:e2e. Record selected transport/API version, relevant official API limits, exact commands, artifact SHA, request-count/cache evidence and unresolved live-auth gates. Update the accepted contract/status only with observed behavior. Test credentials are supplied through authorized local configuration, never committed.

Sources: #319; GitHub REST practices, PR endpoints, Electron security. Validate specific endpoint contracts against current primary documentation when implementing.

Long-running goal prompt

Implement CR-2 for #319 in TypeSafeAI/modex. Read #320's accepted contract/source map, this issue, current source and scoped AGENTS.md first. Verify the actual GitHub credential owner and your worktree; never edit the primary checkout. Build only the main-owned read path, with narrow validated operations, explicit account/repository/revision keys and truthful partial/stale/error states. Write tests first for account switching, delayed responses, pagination/caps, revoked credentials, changed heads and malformed paths. Reuse the existing auth and IPC architecture; do not create a second login, generic proxy, shell command bridge or backend service. Remote PR reads must not invoke local Changes/discard, checkout code, publish anything or call an AI provider. Keep credentials and private payloads out of renderer/logs/Notes. Work in small tested slices within the caller's limits and checkpoint full SHA, changed files, exact results, limits and the next action. Finish with a signed reviewable PR and separate mock versus authenticated evidence; leave unavailable live validation explicit. Do not merge, deploy or expand permissions to make a failing test pass.

Follow-up / resume prompt

Resume CR-2 from live issues/PRs and the actual worktree, not a remembered summary. Confirm owner, current main, head SHA and the accepted #320 contract; rerun the smallest read-path regression. Inspect whether an auth/account generation changed before reusing any cache or request state. Continue one missing acceptance item and test it through main/IPC. Do not retry unknown external mutations; none belongs in this slice. Preserve other agents' changes and record transport/capability gaps precisely. Update the checkpoint and producer-artifact links, then hand off without merge.

Independent review prompt

Review the real PR for account isolation, IPC sender validation, arbitrary host/path injection, cache leakage, mixed revisions, silent truncation and rate-limit behavior. Verify no local write or credential-bearing renderer/provider path was added. Exercise delayed-response and sign-out cases independently. Separate fixture results from authenticated evidence and report findings by acceptance ID.

Landed acceptance audit — 2026-10-21

Completed by #366 at main eb93287371cdcdb6f78a8dca5fca4752e200327e, preserving the #349/#354/#361 work. Required PR CI 39535651708 and protected merge-group CI 39539101402 passed. All 18 producer implementation/test/design/evidence paths are byte-identical to reviewed head e5ce4236e4df4771047d0ebd6b1775602f501087; the nineteenth path, status.md, additionally retains the separately landed Note-ownership repair.

  • AC1: e2e/code-review-ipc.spec.ts exercises production preload/IPC registration/service/subprocess transport with synthetic gh, repository/account isolation, revision-bound files and unchanged checkout. Registration-removal mutation failed as expected; see docs/reviews/2026-10-21-cr2-electron-ipc.md.
  • AC2: service tests cover identical PR numbers, delayed account changes, identity confirmation failure and switch-away-and-back. Renderer race acceptance belongs separately to [CR-3][P1] Build the PR inbox and resizable Code Review workspace #322.
  • AC3: service tests cover revoked/denied/offline/timeout/rate-limit states, partial pagination, omitted patches, redaction and concurrent cache invalidation after denial; see the cache-denial evidence.
  • AC4: files and checks reject or label revision changes before/during reads; unknown revisions and recreated repository identities are covered.
  • AC5: separately recorded authenticated read-only BunsDev/github.com smoke against authorized TypeSafeAI/modex PR334 and PR330 includes exact heads, requests and conditional responses in docs/reviews/2026-10-20-cr2-read-smoke.md. This historical live evidence does not claim a real account-switch exercise.
  • AC6: full protected unit/E2E validation passed; source/handler guards retain read-only fixed endpoints with no local write, checkout, model invocation or new broad authorization path.

This closes the producer service scope. #322–#327 and tracker #319 retain their content, visual, human, AI/write and integration gates. Stack presentation/read support remains explicitly assigned to #323; no remote diff UI or overall Gate A acceptance is claimed here.

Activity

  1. added
    enhancement
    on Oct 19, 2026
  2. BunsDev commented on Oct 20, 2026

    @BunsDev
    ContributorAuthor

    The CR-1 contract is on main as 43d5b9c (#334). Bind to these files at that commit:

    • apps/desktop/src/shared/code-review.ts (the contract)
    • apps/desktop/test/fixtures/code-review.ts (synthetic fixtures)
    • docs/design/code-review.md (source map, references, inventory, open decisions)

    For CR-2:

    AC5 (authenticated read-only smoke test): Val authorized TypeSafeAI/modex as its repository on 2026-10-20. It reads through Val's gh login, GET only. The evidence will record the account, host, PR and head SHA, and no credentials.

    Coven-Harness: Claude Code / claude-opus-5-5

  3. BunsDev commented on Oct 20, 2026

    @BunsDev
    ContributorAuthor

    CR-2 is up for review as #349 (head 197276e, base 43d5b9c).

    Coven-Harness: Claude Code / claude-opus-5-5

  4. self-assigned this
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions