Skip to content

Implement stateful Notifications domain for @counterfact/github#41

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/implement-next-task-another-one
Draft

Implement stateful Notifications domain for @counterfact/github#41
Copilot wants to merge 4 commits into
mainfrom
copilot/implement-next-task-another-one

Conversation

Copilot AI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Implemented the Notifications domain in the GitHub simulator by replacing random responses with stateful thread/subscription behavior and wiring it through a dedicated domain context. This adds realistic global and repo-scoped notification flows (list, mark read, mark done, manage subscription).

Original Prompt

Implement the next task from .github/todo in counterfact/apis: complete .github/todo/notifications-v2.md by adding a dedicated routes/notifications/_.context.ts, wiring it into root context and test harness, implementing all notifications/thread/subscription/repo-notifications route handlers, seeding notification scenario data, adding unit and route tests, deleting the completed todo file, and creating a PR.

Manual acceptance tests

  • GET /notifications returns seeded unread threads.
  • PUT /notifications returns 202 and subsequent GET /notifications excludes those threads by default.
  • GET /notifications/threads/:id returns thread data for existing IDs and 404 for unknown IDs.
  • PATCH /notifications/threads/:id returns 205 and the thread is no longer unread.
  • DELETE /notifications/threads/:id/subscription returns 204, and subsequent GET for that subscription returns 404.
  • PUT /repos/:owner/:repo/notifications marks only that repo’s threads as read (other repos remain unread).

Tasks

  • Notifications domain context

    • Added github/routes/notifications/_.context.ts with notification + subscription state stores and methods:
      • save/get/list notifications
      • mark thread read/done
      • mark all read (optionally scoped by owner/repo)
      • get/set/delete thread subscription
    • Implemented unread-by-default listing semantics (all=false behavior), repo scoping, pagination, and participating filter behavior.
  • Root context + harness wiring

    • Added notifications delegation methods to github/routes/_.context.ts.
    • Registered /notifications in github/test-support/create-context.ts.
  • Route implementations

    • Replaced random responses with context-backed behavior in:
      • routes/notifications.ts
      • routes/notifications/threads/{thread_id}.ts
      • routes/notifications/threads/{thread_id}/subscription.ts
      • routes/repos/{owner}/{repo}/notifications.ts
    • Normalized thread_id handling via String($.path.thread_id) before lookup/mutation.
  • Scenario seeding

    • Added notifications scenario in github/scenarios/index.ts and included it in seedGitHub.
    • Seeded multiple unread threads for counterfact/platform-api and initial thread subscription state.
  • Tests

    • Added github/test/notifications.context.test.ts for direct domain-context unit coverage.
    • Extended github/test/routes.test.ts with notification HTTP-route coverage (global, thread, subscription, repo-scoped flows).
  • Example behavior

    // thread_id is normalized before lookup
    const threadId = String($.path.thread_id);
    const thread = $.context.getNotification(threadId);
    if (!thread) return $.response[404].empty();
    return $.response[200].json(thread);
  • Task cleanup

    • Removed completed todo file: .github/todo/notifications-v2.md.

Copilot AI self-assigned this Jun 8, 2026
Copilot AI review requested due to automatic review settings June 8, 2026 23:40
Copilot AI review requested due to automatic review settings June 8, 2026 23:40
Copilot AI changed the title Implement notifications domain in GitHub simulator Implement stateful Notifications domain for @counterfact/github Jun 8, 2026
Copilot AI requested a review from pmcelhaney June 8, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants