adding-a-rollup-aware-collectionlisted
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