Skip to content

feat(habit): add tenant-safe PostgreSQL repository - #40

Merged
seonghobae merged 21 commits into
mainfrom
feat/habit-postgres-repository
Aug 3, 2026
Merged

feat(habit): add tenant-safe PostgreSQL repository#40
seonghobae merged 21 commits into
mainfrom
feat/habit-postgres-repository

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements #39 as the next reviewable slice of #36.

  • adds a parameterized PostgreSQL implementation of the asynchronous Habit repository contract
  • encodes normalized ISO weekdays into the persisted seven-bit mask and validates recurrence invariants on reads
  • validates UUIDv4 identifiers, IANA timezones, local dates, RFC 3339 timestamps, titles, tenant ownership, expected lookup identifiers, and result cardinality
  • scopes every lookup by workspace_id and aligns deterministic reads with the migration indexes
  • inserts completion history append-only and recovers exact retries only after the named idempotency constraint reports a unique violation
  • rejects an idempotency-key replay whose scheduled date or completion timestamp differs from the original event
  • maps unrelated driver and transport failures to a credential-free HabitPersistenceError without misclassifying them as retries
  • adds unit evidence for SQL binding, recurrence encoding/decoding, malformed persistence rows, tenant crossover, missing/duplicate lookups, new completions, exact retries, conflicting retries, safe database failures, and completion ordering
  • executes the Habit migration against CI PostgreSQL and proves restart durability, tenant isolation, concurrent duplicate serialization, conflicting replay rejection, and database-enforced UPDATE/DELETE/TRUNCATE protection
  • documents the exact slice, deferred runtime work, and validation gates

Deferred

Validated production pool configuration, NestJS lifecycle wiring, HTTP endpoints, RFC 9457 persistence errors, and higher-level habit workflows remain separate reviewable slices.

Validation gate

Merge only when CI, AppGuardrail, Semgrep, Security Scan, Commercial Readiness, CodeRabbit, and all human/security review requirements pass on the exact head with no unresolved actionable findings.

Closes #39

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e3d25ced-b5ca-496b-a8b0-087e0191f072

📥 Commits

Reviewing files that changed from the base of the PR and between f3ea399 and beb0000.

📒 Files selected for processing (9)
  • .github/workflows/ci.yml
  • apps/habit-service/migrations/README.md
  • apps/habit-service/package.json
  • apps/habit-service/src/postgres-habit-repository.integration.test.ts
  • apps/habit-service/src/postgres-habit-repository.test.ts
  • apps/habit-service/src/postgres-habit-repository.ts
  • docs/superpowers/plans/2026-08-04-habit-postgres-repository-slice.md
  • package.json
  • turbo.json

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

@seonghobae
seonghobae merged commit cab995e into main Aug 3, 2026
32 checks passed
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.

Add tenant-safe PostgreSQL repository for recurring habits

1 participant