← ClaudeAtlas

adding-a-rollup-aware-collectionlisted

Use when the user wants to add a new household-level collection that has owner-keyed members (e.g. life insurance policies, future trust distributions, custodial accounts, side businesses). The include-in-rollup flag must cascade through the new collection just like it does for accounts, liabilities, budget items, and income streams. There's a failure-driven checklist test (lib/rollupContract.test.ts) that catches new collections that ignore the flag — this skill walks through adding to it.
vsriram11/wealthtrajectory · ★ 7 · Web & Frontend · score 65
Install: claude install-skill vsriram11/wealthtrajectory
# Adding a rollup-aware collection The rollup-include flag (`Member.includeInRollup`) is the system's single switch for "include this member in household-aggregate views." Setting it to `false` cascades through every collection keyed by `ownerId`: accounts, liabilities, budget items, income streams. Any NEW collection you add that's similarly owner-keyed MUST cascade too. Otherwise the flag has an invisible blind spot. `lib/rollupContract.test.ts` is the failure-driven checklist that catches this. **Add an assertion there for every new collection.** ## What "rollup-aware" means A collection is rollup-aware if: - Each entry has an `ownerId` pointing to a `Member` - Household-level rollups (NW, projection, MC, savings rate, etc.) include the entry's contribution If both are true, the collection MUST honor the include-in-rollup flag. ## The composition pattern Existing rollup-aware collections follow ONE pattern. Mirror it for the new collection: 1. **Add the data type** in `lib/<subsystem>/<collection>.ts` with an `ownerId: MemberId` field. 2. **Add a filter helper** alongside it: ```ts export function filter<Collection>ForRollups( items: readonly Item[], memberId: MemberId | null, activeOwnerIds: ReadonlySet<string>, ): Item[] { if (memberId) return items.filter((i) => i.ownerId === memberId); return items.filter((i) => activeOwnerIds.has(i.ownerId)); } ``` The signature is consistent across collections — explicit memberId pi