Skip to content

feat(core): add the domain service layer - #4

Merged
pulkitxm merged 10 commits into
mainfrom
feat/core-services
Jul 22, 2026
Merged

pulkitxm merged 10 commits into
mainfrom
feat/core-services

Conversation

@pulkitxm

Copy link
Copy Markdown
Member

Adds @orbit/core: permission-checked org, team, invite, issue, project, milestone, cycle, label, workflow state, view, and activity services that write in a transaction, allocate a sync id, and return SyncAction deltas.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f9bc40e2-1d2f-411c-8aa0-902b879663bb

📥 Commits

Reviewing files that changed from the base of the PR and between 7f1ee35 and a0d8a27.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (31)
  • biome.json
  • packages/core/package.json
  • packages/core/src/activity/activity-service.test.ts
  • packages/core/src/activity/activity-service.ts
  • packages/core/src/index.ts
  • packages/core/src/internal.ts
  • packages/core/src/org/invite-service.test.ts
  • packages/core/src/org/invite-service.ts
  • packages/core/src/org/member-service.test.ts
  • packages/core/src/org/member-service.ts
  • packages/core/src/org/organization-service.test.ts
  • packages/core/src/org/organization-service.ts
  • packages/core/src/org/team-service.ts
  • packages/core/src/realtime/publisher.test.ts
  • packages/core/src/realtime/publisher.ts
  • packages/core/src/sync/sync-id.ts
  • packages/core/src/test-support.ts
  • packages/core/src/work/cycle-service.test.ts
  • packages/core/src/work/cycle-service.ts
  • packages/core/src/work/issue-service.test.ts
  • packages/core/src/work/issue-service.ts
  • packages/core/src/work/label-service.ts
  • packages/core/src/work/milestone-service.ts
  • packages/core/src/work/project-service.test.ts
  • packages/core/src/work/project-service.ts
  • packages/core/src/work/view-service.ts
  • packages/core/src/work/workflow-state-service.test.ts
  • packages/core/src/work/workflow-state-service.ts
  • packages/core/tsconfig.json
  • packages/core/vitest.config.ts
  • packages/shared/src/events/index.ts

📝 Walkthrough

Walkthrough

Adds the @orbit/core package and a broad service layer for organizations, teams, memberships, invitations, workflow states, cycles, issues, projects, labels, milestones, views, activity trails, realtime sync actions, and database-backed integration tests.

Changes

Core service foundation

Layer / File(s) Summary
Package and shared runtime foundation
biome.json, packages/core/package.json, packages/core/src/index.ts, packages/core/src/internal.ts, packages/core/src/sync/sync-id.ts, packages/shared/src/events/index.ts
Defines the core package entry point, shared ID/date helpers, sync ID allocation, and organization sync model support.
Activity and realtime synchronization
packages/core/src/activity/*, packages/core/src/realtime/*
Persists and renders issue activity, builds synchronization actions, and publishes deltas through Redis when configured.

Organization and work services

Layer / File(s) Summary
Organization, membership, invitation, and team workflows
packages/core/src/org/*
Implements organization bootstrap, member role management, member removal, invitations, team lifecycle, team membership, authorization, and sync actions.
Workflow states and cycle lifecycle
packages/core/src/work/workflow-state-service.*, packages/core/src/work/cycle-service.*
Implements workflow-state CRUD/reordering and cycle creation, progress reporting, completion, and issue rollover.
Issue workflow, activity, ordering, and relations
packages/core/src/work/issue-service.*
Implements issue CRUD, state transitions, ordering, pagination, filters, relations, subscriptions, bulk updates, archiving, and activity effects.
Projects, labels, milestones, and views
packages/core/src/work/project-service.*, packages/core/src/work/label-service.ts, packages/core/src/work/milestone-service.ts, packages/core/src/work/view-service.ts
Implements project management and progress reporting plus label, milestone, and view lifecycle operations with scoped synchronization actions.
Database test harness and package configuration
packages/core/src/test-support.ts, packages/core/tsconfig.json, packages/core/vitest.config.ts, packages/core/src/**/*test.ts
Adds test database reset/workspace fixtures, Vitest configuration, TypeScript configuration, and integration coverage across the new services.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
biome.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

packages/core/package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

packages/core/tsconfig.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Comment @coderabbitai help to get the list of available commands.

@pulkitxm
pulkitxm force-pushed the feat/core-services branch 3 times, most recently from f3c7fd2 to 3c0825b Compare July 22, 2026 18:21
@pulkitxm
pulkitxm force-pushed the feat/core-services branch from 3c0825b to a06cd05 Compare July 22, 2026 18:31
@pulkitxm

Copy link
Copy Markdown
Member Author

Visual evidence

@orbit/core is a service layer with no UI, so here is a throwaway script driving the real exported API against the test Postgres, printing each step. Every value below is captured output, not hand-written.

End-to-end demo run
──────────────────────────────────────────────────────────────────────────────
1. createOrganization  bootstraps org + admin member + team + states + labels
──────────────────────────────────────────────────────────────────────────────
  organizationId             cfb9aea9-e88e-424f-ae0c-007aa291b0cf
  default team               1a139798…
  admin role                 admin
  workflow states            Triage(triage) → Backlog(backlog) → Todo(unstarted) → In Progress(started) → In Review(review) → Done(completed) → Canceled(canceled)
  starter labels             Bug, Feature, Improvement, Design, Documentation, Chore
  first cycle                #1 Cycle 1

──────────────────────────────────────────────────────────────────────────────
2. createInvite / acceptInvite  creates the member row and team memberships
──────────────────────────────────────────────────────────────────────────────
  invited                    [email protected]
  token                      c318c805f33f4c62…
  expires in days            14
  member role                member
  team memberships           1
  sync action scopes         ["org:cfb9aea9-e88e-424f-ae0c-007aa291b0cf","user:b55d4d03-e122-4ad7-a13c-440e8138204b","team:1a139798-c099-42a8-8941-c8e308d58b6d"]
  replayed token             alreadyAccepted=true actions=0

──────────────────────────────────────────────────────────────────────────────
3. createIssue  identifier, default state, sort order, activity, subscribers
──────────────────────────────────────────────────────────────────────────────
  identifier                 NOVA-1
  state                      Todo
  sortOrder                  1024
  startedAt                  null
  second identifier          NOVA-2
  stacked on top             0 < 1024

──────────────────────────────────────────────────────────────────────────────
4. updateIssue  state category drives startedAt / completedAt / canceledAt
──────────────────────────────────────────────────────────────────────────────
  state                      In Progress
  startedAt                  2026-07-22T18:33:01.004Z
  completedAt                null
  state                      Done
  startedAt (preserved)      2026-07-22T18:33:01.004Z
  completedAt                2026-07-22T18:33:01.008Z
  state                      Backlog
  startedAt (cleared)        null
  completedAt (cleared)      null

──────────────────────────────────────────────────────────────────────────────
5. issue_activity  one row per changed field, rendered by describeActivity
──────────────────────────────────────────────────────────────────────────────
  Ada Admin    created the issue
  Ada Admin    moved from Todo to In Progress
  Ada Admin    moved from In Progress to Done
  Ada Admin    moved from Done to Backlog

──────────────────────────────────────────────────────────────────────────────
6. moveIssue across teams  reallocates number and identifier
──────────────────────────────────────────────────────────────────────────────
  new team key               DSGN
  before                     NOVA-1
  after                      DSGN-1
  number                     1
  resolves by identifier     Wire up the realtime publisher

──────────────────────────────────────────────────────────────────────────────
7. concurrent createIssue  20 in parallel, all identifiers distinct
──────────────────────────────────────────────────────────────────────────────
  created                    20
  distinct identifiers       20
  numbers                    3..22 contiguous=true

──────────────────────────────────────────────────────────────────────────────
8. every mutation returns SyncAction[] with scopes for the realtime fan out
──────────────────────────────────────────────────────────────────────────────
  syncId                     31
  model / action             issue / insert
  scopes                     ["org:cfb9aea9-e88e-424f-ae0c-007aa291b0cf","team:1a139798-c099-42a8-8941-c8e308d58b6d","issue:0c279cf4-f69f-4b33-9d56-85193c3677c9"]
  actor                      user:Ada Admin
  at                         2026-07-22T18:33:01.098Z

──────────────────────────────────────────────────────────────────────────────
9. listIssues  filters, ordering, keyset pagination
──────────────────────────────────────────────────────────────────────────────
  orderBy=priority           DSGN-1(p1) NOVA-23(p0) NOVA-4(p0)
  nextCursor                 WzUsIjIwOTM2MjhlLWJm…
  page 2                     NOVA-19 NOVA-17 NOVA-8
  overlap between pages      0
  filter teamId=DSGN         DSGN-1

──────────────────────────────────────────────────────────────────────────────
10. permissions  guest cannot create, contributor cannot delete
──────────────────────────────────────────────────────────────────────────────
  guest createIssue          rejected: Your role cannot issue create.

What each step proves

Step Claim
1 createOrganization bootstraps org, admin member, default team, all 7 state categories, starter labels, and cycle 1 in one transaction
2 acceptInvite creates the member + team rows; replaying a used token is idempotent (alreadyAccepted=true, 0 actions)
3 Per-team issue numbering, default state resolution, and top-of-column sortOrder
4 State category drives the timestamps: startedAt set on entry, preserved through completion, both cleared on return to backlog
5 One issue_activity row per changed field, rendered by describeActivity
6 Cross-team moveIssue reallocates number and identifier (NOVA-1 → DSGN-1), so it cannot collide with the target team's issue_team_number_unique
7 20 concurrent createIssue calls yield 20 distinct, contiguous identifiers
8 Every mutation returns SyncAction[] carrying syncId, org/team/issue scopes, actor, and ISO at
9 Keyset pagination with zero overlap between pages; no-priority sorts last
10 Policy is enforced server side, not just in the UI
Test run
RUN  v4.1.10 /Volumes/Sandisk SSD/career/3. MagicAPI/orbit/.claude/worktrees/agent-a2a35d09d838b3f64/packages/core
 ✓ src/work/issue-service.test.ts (30 tests) 1440ms
 ✓ src/org/invite-service.test.ts (11 tests) 515ms
 ✓ src/org/member-service.test.ts (10 tests) 436ms
 ✓ src/work/project-service.test.ts (9 tests) 442ms
 ✓ src/work/workflow-state-service.test.ts (8 tests) 340ms
 ✓ src/work/cycle-service.test.ts (7 tests) 342ms
 ✓ src/org/organization-service.test.ts (7 tests) 304ms
 ✓ src/activity/activity-service.test.ts (3 tests) 155ms
 ✓ src/realtime/publisher.test.ts (3 tests) 3ms
 Test Files  9 passed (9)
      Tests  88 passed (88)
   Start at  00:03:05
   Duration  6.53s (transform 138ms, setup 0ms, import 1.92s, tests 3.98s, environment 0ms)

pnpm verify (lint + comment policy + typecheck + tests) is green across the workspace.

@pulkitxm

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@pulkitxm
pulkitxm merged commit 80d594e into main Jul 22, 2026
3 of 4 checks passed
@pulkitxm

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

1 participant