Skip to content

Custom per-user valuations (override editorial cents-per-point) - #8

Merged
jckail merged 1 commit into
masterfrom
feature/custom-valuations
Jul 9, 2026
Merged

Custom per-user valuations (override editorial cents-per-point)#8
jckail merged 1 commit into
masterfrom
feature/custom-valuations

Conversation

@jckail

@jckail jckail commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

The Phase 1 headline intelligence feature: users can override a program's cents-per-point, and portfolio value everywhere it flows — summary, dashboard, weekly digest, proactive alerts — reflects it, because they all consume estimatedValueCents from the read model.

  • DB — new user_provider_valuation table (composite PK user+provider; value stored as integer milli-cents to avoid float drift) + migration 0005 (additive only — no changes to existing tables).
  • DomainCustomValuation + CustomValuationRepository port + assertValidCentsPerPoint (0 < v ≤ 100) + InvalidValuationError.
  • ApplicationListCustomValuations / SetCustomValuation (validates provider and range) / DeleteCustomValuation. The read-model mapper takes an overrides map; ListLoyaltyAccounts and GetLoyaltyAccount thread the optional valuation repo, so estimatedValueCents uses the override and a new customCentsPerPoint field surfaces it. Backward compatible — no repo wired ⇒ editorial rate (the digest/worker/bot containers keep working unchanged).
  • InfraDrizzleCustomValuationRepository (upsert via onConflictDoUpdate).
  • Contracts + OpenAPI — new DTO field, request/response schemas, INVALID_VALUATION (422), /api/v1/valuations paths (the spec regenerates from the schemas, so it stays accurate).
  • WebGET /api/v1/valuations, PUT/DELETE /api/v1/valuations/{providerId}.
  • api-client — list/set/delete methods.
  • Docsdocs/api.md.

Verification

  • 112 tests pass (92 core incl. 5 new + 20 bot); typecheck + eslint clean.
  • New tests cover validation (unknown provider, out-of-range) and that the read model's value switches to the override and reverts on delete.

⚠️ Migration note

This adds migration 0005 (new table only). CI has no database, so it can't exercise the migration — it's validated by drizzle-kit generate producing a clean additive diff and the offline snapshot. It applies on deploy via the worker migrate task. Nothing destructive.

🤖 Generated with Claude Code

Phase 1 headline intelligence feature. Users can override a program's
cents-per-point; portfolio value everywhere it flows (summary, dashboard,
digests, alerts) reflects the override.

- db: new `user_provider_valuation` table (composite PK user+provider, value
  stored as integer milli-cents to avoid float drift) + migration 0005
  (additive only — no changes to existing tables).
- domain: `CustomValuation` + `CustomValuationRepository` port +
  `assertValidCentsPerPoint` (0 < v ≤ 100) + `InvalidValuationError`.
- application: ListCustomValuations / SetCustomValuation (validates provider +
  range) / DeleteCustomValuation. Read-model mapper takes an overrides map;
  ListLoyaltyAccounts + GetLoyaltyAccount thread the (optional) valuation repo
  so `estimatedValueCents` uses the override and a new `customCentsPerPoint`
  field surfaces it. Backward compatible — no repo wired ⇒ editorial rate.
- infra: DrizzleCustomValuationRepository (upsert via onConflictDoUpdate).
- contracts + OpenAPI: DTO field, request/DTO schemas, INVALID_VALUATION=422,
  /api/v1/valuations paths.
- web: GET /api/v1/valuations, PUT/DELETE /api/v1/valuations/{providerId}.
- api-client: list/set/delete methods.
- docs/api.md. Tests: +5 core (validation + read-model reflects override).

Verification: 112 tests pass (92 core + 20 bot); typecheck + lint clean;
migration generated offline via drizzle-kit (additive, safe).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@jckail
jckail merged commit 6063710 into master Jul 9, 2026
2 checks passed
@jckail
jckail deleted the feature/custom-valuations branch July 9, 2026 07:32
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