You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
- add materialized archive generation for best post monthly/yearly periods with GraphQL reads
- tighten archive eligibility to public, feed-visible content from active public sources
- add a standalone retroactive backfill bin that reuses the same period materialization path as the cron
## Verification
- pnpm run lint
- NODE_ENV=test npx jest __tests__/archive.ts --testEnvironment=node --runInBand
- pnpm run build
Copy file name to clipboardExpand all lines: AGENTS.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,7 @@ The migration generator compares entities against the local database schema. Ens
115
115
-`z.literal([...])` in Zod 4.x supports arrays and validates that the value matches one of the array elements
116
116
- For enum-like validation of string literals, both `z.literal([...])` and `z.enum([...])` work in Zod 4.x
117
117
- Always consult the [Zod 4.x documentation](https://zod.dev) for the latest API
118
+
- For TypeScript string enums used in Zod schemas, derive the tuple from the shared helper in `src/common/schema/utils.ts` instead of duplicating arrays or hand-written type guards. Keep the enum as the single source of truth.
118
119
- When possible, prefer Zod schemas over manual validation as they provide type safety, better error messages, and can be inferred to TypeScript types.
119
120
-**Connect RPC handlers must return typed proto message classes** from `@dailydotdev/schema`, not plain objects. Use `new ResponseType({...})` instead of returning `{...}` directly. **This applies to mock/`isMockEnabled` returns too** — when mocking RPC transport, always use actual proto message class instances, not raw JSON objects.
120
121
-**Never create wrapper types around `@dailydotdev/schema` classes** (e.g., `UserBriefingRequest & { extraField }`) — if a field exists in the proto, use it directly. If it doesn't exist yet, update the schema package first.
@@ -576,6 +577,7 @@ The migration generator compares entities against the local database schema. Ens
576
577
```
577
578
578
579
-**For cron jobs and batch operations**: Keep read-only queries outside the transaction, then wrap all writes in a single transaction.
580
+
- For materialization/backfill jobs, make the cron rerunnable and idempotent. Prefer a deterministic unique key plus an atomic per-scope write step so retries can safely continue after partial progress without leaving half-written rows.
579
581
580
582
**Using queryReadReplica Helper:**
581
583
@@ -598,6 +600,11 @@ The migration generator compares entities against the local database schema. Ens
598
600
- For integration tests that depend on materialized views, assume schema setup is handled by migrations (`db:migrate:latest` / test reset flow).
599
601
- In tests, refresh the materialized view before assertions; do not recreate the materialized view definition inside test files.
600
602
603
+
**Immutable Materialized Tables:**
604
+
605
+
- For immutable or period-closed materialized data, prefer the smallest persisted schema that supports lookup and joins. Avoid `updatedAt`, `generatedAt`, counters, or snapshot columns unless there is a concrete read-path need for them.
606
+
- For archive/materialization tables keyed by business dimensions, keep a surrogate `id` for relations but also enforce the real unique business key in the database.
607
+
601
608
**State Checking Patterns:**
602
609
603
610
-**Prefer negative checks over listing states** when checking for "non-draft" or similar conditions.
0 commit comments