briefing-payload.test.ts
Language TypeScript27.6 KB638 lines
/*** The payload is a CONTRACT, not an output. Something downstream (a Python* analysis service, a local model, a person) reads it and writes sentences that* get shown to the team. These tests pin the properties that make those* sentences safe.** The two that matter most:* 1. null never becomes 0. A dead source and an empty queue are opposite in* meaning and identical in shape.* 2. the interpretation rules ship INSIDE the payload. A consumer that has the* numbers but not the rules is more dangerous than one with no data.*/import { describe, expect, it } from 'vitest'import { FIXTURE_SNAPSHOT } from '../src/fixtures.js'import { orderQueue, orderQueueByDesigner, headline, todoLoad } from '../src/collect.js'import { queueView, sourceStatuses } from '../src/view-model.js'import {KNOWN_NON_ROSTER_NINETY,MERIDIAN_PEOPLE,personFromNinety,resolveNinety,unmappedNinetyOwners,} from '../../../config/meridian-people.js'import {buildBriefingPayload,EXEC_RULES,INTERPRETATION_RULES,LIST_CAP,PAYLOAD_SCHEMA_VERSION,UNMEASURABLE,} from '../src/briefing-payload.js'import { displayOrderNumber, isDisplayOrderNumber } from '@meridian/plinth-client'const snap = FIXTURE_SNAPSHOTdescribe('displayOrderNumber', () => {it('builds the number people actually say out loud', () => {expect(displayOrderNumber(39582, '2026-03-04T00:00:00Z')).toBe('MD2639582')})it('pads a single-digit year', () => {expect(displayOrderNumber(39582, '2009-03-04T00:00:00Z')).toBe('MD0939582')})it('returns the bare id rather than guessing a year', () => {// A wrong order number is worse than an obviously partial one: it looks// searchable and silently is not.expect(displayOrderNumber(39582, null)).toBe('39582')expect(isDisplayOrderNumber('39582')).toBe(false)})})describe('orderQueue', () => {const rows = orderQueue(snap.orderLines.data)it('only lists work this team owes', () => {// Waiting-on-client is a follow-up list, not a queue. Including it is how a// dashboard makes the team look behind when it is not.expect(rows.length).toBeGreaterThan(0)expect(rows.length).toBeLessThan(snap.orderLines.data.length)})it('gives every row a pasteable order number', () => {for (const r of rows) expect(isDisplayOrderNumber(r.orderNumber)).toBe(true)})it('sorts oldest first, because the top of the list is what is rotting', () => {const ages = rows.map((r) => r.ageDays ?? -1)expect([...ages].sort((a, b) => b - a)).toEqual(ages)})it('never echoes the order number back as a product name', () => {// An order-level export puts the order number in the title slot. Repeating// it in the column beside it is noise wearing the costume of data.for (const r of rows) {expect(r.product).not.toBe(r.orderNumber)expect(r.product).not.toBe(String(r.orderId))expect(r.product === null || r.product.length > 0).toBe(true)}})it('groups under the holder, with unassigned last', () => {const groups = orderQueueByDesigner(snap.orderLines.data)expect(groups.length).toBeGreaterThan(0)const nullAt = groups.findIndex((g) => g.designer === null)if (nullAt !== -1) expect(nullAt).toBe(groups.length - 1)expect(groups.flatMap((g) => g.rows)).toHaveLength(rows.length)})})describe('Ninety owners resolve through the roster, not by name equality', () => {// The failure this guards: Ninety spells names as someone typed them// ("Samuel Whitaker", "Marco Ibanez", "Rafael Monterro") against a roster// reading "Sam Whitaker", "Marco Ibáñez", "Rafael Montero". A name-equality// join matches nothing for those people, and their briefings report zero// to-dos, indistinguishable from being idle.//// Every ninetyId is pinned, so these tests assert the id join. What matters// is that every owner resolves, not how; a test that pinned a particular// workaround would make it read as a requirement.// The Ninety directory: id, and the spelling Ninety sends.const DIRECTORY: [string, string, string][] = [['8326a8602530a97b5afd91ae', 'Nora Lindqvist', 'Nora Lindqvist'],['6d8c1631dc0c3eda4c26b839', 'Theo Bassett', 'Theo Bassett'],['4e77bc9877e856992de26b64', 'Ines Carvalho', 'Ines Carvalho'],['3e894807d73d5a39b03fb411', 'Samuel Whitaker', 'Sam Whitaker'],['8466ef547c9f9a6ee92fe8a0', 'Marco Ibanez', 'Marco Ibáñez'],['05b7014d82e5b5ed5e68b309', 'Rafael Monterro', 'Rafael Montero'],]it('resolves every id in the live directory to the right person', () => {for (const [id, ninetyName, rosterName] of DIRECTORY) {expect(personFromNinety(id, ninetyName)?.name, `${ninetyName} must resolve`).toBe(rosterName)}})it('resolves a DEPARTED person’s id to nobody, rather than to their successor', () => {// Hazel's Ninety account. Rosa took her mailbox, her Plinth assignment and// her seat, and deliberately not her Ninety id: that id is an account, and// reusing it would put Hazel's commitments on Rosa's briefing as though she// had agreed to them. Anything still open under it is held by nobody on// this roster; the fix for that is in Ninety.expect(personFromNinety('a568c7b30679efe19e6ed3a1', 'Hazel Okafor')).toBeNull()})it('resolves a drifted spelling by id, which is the point of pinning them', () => {// The name Ninety sends for these three does not match the roster; the id// does, so the spelling does not matter.expect(personFromNinety('3e894807d73d5a39b03fb411', 'Samuel Whitaker')?.name).toBe('Sam Whitaker')expect(personFromNinety('8466ef547c9f9a6ee92fe8a0', 'Marco Ibanez')?.name).toBe('Marco Ibáñez')expect(personFromNinety('05b7014d82e5b5ed5e68b309', 'Rafael Monterro')?.name).toBe('Rafael Montero')})it('survives a name Ninety has never sent before', () => {// The failure mode pinning exists to prevent: someone retypes a name in// Ninety and the person keeps resolving because the id did not change.expect(personFromNinety('8326a8602530a97b5afd91ae', 'V. Lindqvist')?.name).toBe('Nora Lindqvist')expect(personFromNinety('8326a8602530a97b5afd91ae', null)?.name).toBe('Nora Lindqvist')})it('prefers the id over the name when the two disagree', () => {// Ids are authoritative. A name that belongs to somebody else must not win.const match = personFromNinety('8326a8602530a97b5afd91ae', 'Sam Whitaker')expect(match?.name).toBe('Nora Lindqvist')})it('every person the board says Ninety COVERS carries an id', () => {// Scoped to people the board claims Ninety covers. A new hire genuinely// has no id until someone runs `pnpm roster` with credentials, and is// simply not claimed as covered (see the test below, and the coverageNote).// The property is that a covered person never resolves by spelling// instead of by id, since the spelling drifts and their to-dos would// silently read as zero.for (const p of MERIDIAN_PEOPLE.filter((x) => x.coveredBy.includes('ninety-todos'))) {expect(p.ninetyId, `${p.name} is marked ninety-todos with no ninetyId`).toBeTruthy()}})it('never claims Ninety coverage for somebody it cannot resolve', () => {// The prime invariant, applied to a person instead of a number. A new hire// with no id and `ninety-todos` in coveredBy would render as zero to-dos// (free capacity) when the truth is that no source can see them at all.for (const p of MERIDIAN_PEOPLE.filter((x) => !x.ninetyId)) {expect(p.coveredBy, `${p.name} has no ninetyId but claims Ninety`).not.toContain('ninety-todos')expect(p.coverageNote, `${p.name} has no ninetyId and no coverage note`).toBeTruthy()}})it('keeps no aliases, now that ids do the work', () => {// They were a fallback for exactly the gap that pinning closed. Left in// place they become a second, staler source of truth for the same question.for (const p of MERIDIAN_PEOPLE) {expect(p.aliases ?? [], `${p.name} still has aliases`).toEqual([])}})it('reports how a match was made, so a name-only match is not silent', () => {// A fallback standing in for knowledge must be surfaced. Every id is pinned,// so a name match means the id Ninety sent is one this roster has never// seen: attributed correctly today, and// silently attributed to nobody the moment the spelling also changes.expect(resolveNinety('8326a8602530a97b5afd91ae', 'Nora Lindqvist').via).toBe('id')expect(resolveNinety('an-id-nobody-pinned', 'Nora Lindqvist').via).toBe('name')expect(resolveNinety('an-id-nobody-pinned', 'Nobody At All').via).toBeNull()})it('returns null rather than guessing at an unknown person', () => {expect(personFromNinety(null, 'Someone Not On The Roster')).toBeNull()expect(personFromNinety(null, '')).toBeNull()expect(personFromNinety('an-id-nobody-pinned', null)).toBeNull()})it('reports unmapped owners instead of swallowing them', () => {// Non-empty means somebody's to-dos exist in the company total but appear on// no per-person view, and missing looks exactly like finished.const unmapped = unmappedNinetyOwners([{ id: '3e894807d73d5a39b03fb411', name: 'Samuel Whitaker' },{ id: 'u2', name: 'Someone Nobody Declared' },])expect(unmapped).toHaveLength(1)expect(unmapped[0]!.name).toBe('Someone Nobody Declared')})it('does not flag people declared known-external', () => {// The Ninety directory is not the Meridian team: it holds former staff and// outside collaborators too. Grant Holloway is a former business coach;// undeclared, his absence from the roster reads as a coverage gap worth// chasing. Declaring it is the answer, written down.expect(unmappedNinetyOwners([{ id: '3609ad68b5259524e92470f5', name: 'Grant Holloway' }])).toEqual([])expect(KNOWN_NON_ROSTER_NINETY).toContain('Grant Holloway')})it('attributes every owner seen in the live sweep', () => {// Every owner must resolve: an unresolved one puts their share of company// work on no per-person view while it still counts in every company total.const owners = DIRECTORY.map(([id, name]) => ({ id, name }))expect(unmappedNinetyOwners(owners)).toEqual([])})it('surfaces unmapped owners in dataHealth', () => {const p = buildBriefingPayload(snap)expect(Array.isArray(p.dataHealth.unmappedTodoOwners)).toBe(true)})it('gives every to-do an ownerKey or an explicit null', () => {const p = buildBriefingPayload(snap)for (const t of p.people.flatMap((x) => x.todos)) {expect(t.ownerKey === null || typeof t.ownerKey === 'string').toBe(true)}})})describe('the all-hands brief cannot be built from Leadership to-dos', () => {/*** `brief.py`'s `without_restricted()` filters rows carrying `restricted`. If* `PayloadTodo` did not set the field, the filter would run, match nothing,* report `_restrictedTodosRemoved: 0`, and assemble the all-hands prompt from* every Leadership to-do title: fail-open on a confidentiality boundary, and* invisible from either side alone, since the TypeScript compiles and the* Python passes its own tests. These tests assert the two halves agree.*/const payload = buildBriefingPayload(FIXTURE_SNAPSHOT)// Every list of to-do TITLES in the payload. `company.lateTodos` is a count,// not a list. Mistaking the two is what pointed the Python filter at nothing.const allTodos = [...payload.people.flatMap((p) => p.todos), ...payload.queues.lateTodos]it('marks every to-do as restricted or not, never leaves it undefined', () => {expect(allTodos.length).toBeGreaterThan(0)for (const t of allTodos) expect(typeof t.restricted).toBe('boolean')})it('marks Leadership Team to-dos restricted', () => {const hiring = allTodos.filter((t) => t.title.startsWith('Hire a client success associate'))expect(hiring.length).toBeGreaterThan(0)for (const t of hiring) expect(t.restricted).toBe(true)})it('marks a to-do with no team restricted, because it could be anything', () => {const untagged = allTodos.filter((t) => t.title === 'Coordinate backdrop images')expect(untagged.length).toBeGreaterThan(0)for (const t of untagged) expect(t.restricted).toBe(true)})it('leaves All Hands to-dos readable, so the all-hands brief is not empty', () => {// Failing closed on everything would be safe and useless: the rule is that// All Hands work stays visible so the whole team can see where the company// stands.const allHands = allTodos.filter((t) => t.title === 'Weekly product photo refresh')expect(allHands.length).toBeGreaterThan(0)for (const t of allHands) expect(t.restricted).toBe(false)})it('gives the all-hands filter something to actually remove', () => {// The assertion that would have caught the original bug: a payload where// nothing is restricted is indistinguishable from a broken flag.expect(allTodos.some((t) => t.restricted)).toBe(true)expect(allTodos.some((t) => !t.restricted)).toBe(true)})})describe('the leadership view reports capacity, never performance', () => {const p = buildBriefingPayload(snap)it('ships the exec rules separately so a consumer can put them first', () => {expect(p.execRules).toEqual(EXEC_RULES)expect(p.execRules.length).toBeGreaterThanOrEqual(6)})it('states plainly that speed and effort are not in the data', () => {const joined = p.execRules.join(' ').toLowerCase()for (const forbidden of ['slow', 'fast', 'behind', 'productive']) {expect(joined).toContain(forbidden) // named in order to be forbidden}expect(joined).toContain('cannot say anyone was')expect(joined).toContain('do not rank or compare people')})it('warns that age is not time on someone\'s desk', () => {// The single number most likely to be misread as a person's fault. Plinth// records no status-change timestamps, so this is a fact, not a hedge.expect(p.execRules.join(' ')).toMatch(/AGE IS NOT TIME ON SOMEONE'S DESK/)})it('carries the unmeasurable list, not just the measurable one', () => {expect(p.exec.unmeasurable).toEqual(UNMEASURABLE)const joined = p.exec.unmeasurable.join(' ').toLowerCase()expect(joined).toContain('no status-change timestamps')expect(joined).toContain('client reply latency is not recorded')expect(joined).toContain('phone calls, chats, walk-ups')})it('separates what the team owes from what is parked elsewhere', () => {// Only ourMove is team load. Rolling the others in is how a capacity view// starts describing a team as behind when it is not.expect(p.exec.ourMove).toBeGreaterThan(0)expect(p.exec.waitingOnClient).toBeGreaterThan(0)for (const l of p.exec.load) {if (l.holding !== null && l.parked !== null) {expect(l.holding + l.parked).toBeGreaterThanOrEqual(l.holding)}}})it('counts handoffs, because coordination is the small-team constraint', () => {expect(p.exec.handoffPoints).toBeGreaterThan(0)for (const l of p.exec.load) {if (l.handoffs !== null && l.holding !== null) {expect(l.handoffs).toBeLessThanOrEqual(l.holding)}}})it('gives team size as context for every count', () => {expect(p.exec.teamSize).toBe(p.people.length)})it('reports an uncovered person as null, never as an idle zero', () => {const uncovered = p.exec.load.filter((l) => l.holding === null)expect(uncovered.length).toBeGreaterThan(0)for (const l of uncovered) expect(l.holding).not.toBe(0)})it('exposes no rate, throughput, or completion FIELD', () => {// Checks field names, not prose: `unmeasurable` names throughput on// purpose, to rule it out. What must never appear is a per-person number// that could be read as a rate, because it will be reported as performance// within a week of existing.const banned = ['throughput', 'velocity', 'rate', 'perday', 'efficiency', 'completed', 'closed']const keys = new Set<string>()const walk = (v: unknown): void => {if (Array.isArray(v)) return v.forEach(walk)if (v && typeof v === 'object') {for (const [k, val] of Object.entries(v)) {keys.add(k.toLowerCase())walk(val)}}}walk({ ...p.exec, unmeasurable: undefined })for (const key of keys) {for (const b of banned) expect(key).not.toContain(b)}// And every per-person field is a count of things HELD, never a rate.for (const l of p.exec.load) {expect(Object.keys(l).sort()).toEqual(['commitments', 'handoffs', 'holding', 'name', 'parked', 'role', 'shared'],)}})})describe('a fixture run never claims to be live', () => {// A fixture run must not render "live" pills over a frozen export: the board// that exists to stop sources asserting unearned status must not do it about// itself.it('marks every source as sample data, never live', () => {for (const s of sourceStatuses(snap)) {expect(s.status).toBe('sample data')expect(s.tone).not.toBe('live')}})it('says when the frozen data was captured', () => {expect(snap.mode).toBe('fixtures')expect(snap.fixtureCapturedAt).toBeTruthy()const ops = sourceStatuses(snap).find((s) => s.name === 'Plinth')!expect(ops.note).toContain('2026-08-09')expect(ops.note.toLowerCase()).toContain('already be shipped')})it('warns the model first, before any other rule', () => {// A model handed this with no marker writes a confident briefing about// orders that shipped two weeks ago and names people as holding finished// work. The warning has to be rule one, not a footnote.const p = buildBriefingPayload(snap)expect(p.mode).toBe('fixtures')expect(p.capturedAt).toBeTruthy()expect(p.rules[0]).toMatch(/SAMPLE DATA/)expect(p.rules.length).toBe(INTERPRETATION_RULES.length + 1)})it('a live snapshot carries no such warning', () => {const live = buildBriefingPayload({ ...snap, mode: 'live', fixtureCapturedAt: null })expect(live.mode).toBe('live')expect(live.capturedAt).toBeNull()expect(live.rules).toEqual(INTERPRETATION_RULES)})})describe('the fixture clock is pinned to the export, not to today', () => {// `placedAt` is frozen, so an age computed from Date.now() would grow one day// per real day, until every row tripped the aging threshold and a reviewer// learned to ignore the one flag that matters. A frozen snapshot must have// frozen ages.it('gives order 39511 the age it actually had, forever', () => {const line = snap.orderLines.data.find((l) => l.orderId === 39511)expect(line).toBeDefined()expect(line!.ageDays).toBe(30)})it('has no order older than the export window, however long the seed sits', () => {// Placed 01 Jul-07 Aug, exported 09 Aug. Nothing can legitimately exceed ~40// days. If this fails, something is measuring against a live clock again.for (const l of snap.orderLines.data) {if (l.ageDays !== null) expect(l.ageDays).toBeLessThan(45)}})})describe('no column echoes the column beside it', () => {// An order number echoed into productTitle and customer would make three// columns in a row say the same thing. Repetition reads as data.it('never renders the order number as a product or a client', () => {const q = queueView(snap)for (const g of q.groups) {for (const r of g.rows) {expect(r.product).not.toBe(r.orderNumber)expect(r.customer).not.toBe(r.orderNumber)}}})it('prints the absence as words, never as a blank cell', () => {const q = queueView(snap)for (const g of q.groups) {for (const r of g.rows) {expect(r.product.trim().length).toBeGreaterThan(0)expect(r.customer.trim().length).toBeGreaterThan(0)}}})})describe('an aging flag that fires on everything is suppressed', () => {it('replaces saturated badges with one sentence', () => {const q = queueView(snap)// The seed queue is genuinely mostly old, so this is the saturated path.expect(q.everythingIsOld).toBeTruthy()expect(q.everythingIsOld).toMatch(/median/)// and no row carries a badge, because a badge on everything is wallpaper.for (const g of q.groups) for (const r of g.rows) expect(r.aging).toBe(false)})it('names the unassigned group rather than leaving it blank', () => {const q = queueView(snap)const un = q.groups.find((g) => g.unassigned)if (un) expect(un.designer).toBe('Unassigned')for (const g of q.groups) expect(g.designer.trim().length).toBeGreaterThan(0)})})describe('headline treats a dead source as unknown, not empty', () => {it('reports commitments when Ninety is up', () => {const h = headline(snap)expect(h.commitments).toBeGreaterThan(0)expect(h.assignments).toBeGreaterThanOrEqual(h.commitments!)})it('reports null, NEVER 0, when Ninety is down', () => {const dead = {...snap,ninety: { ok: false, data: [], error: '403 Forbidden' },ninetySpread: null,}const h = headline(dead)expect(h.commitments).toBeNull()expect(h.assignments).toBeNull()expect(h.lateTodos).toBeNull()// 0 would read as "everything is done". null reads as "we cannot see".expect(h.commitments).not.toBe(0)})})describe('todoLoad uses review gates, not raw overdue', () => {it('counts late only when a review has actually passed', () => {const loads = todoLoad(snap.ninety.data)for (const l of loads) expect(l.late).toBeLessThanOrEqual(l.open)expect(loads.some((l) => l.late > 0)).toBe(true)})})describe('buildBriefingPayload', () => {const p = buildBriefingPayload(snap)it('is versioned so a consumer can fail loudly on a breaking change', () => {expect(p.schemaVersion).toBe(PAYLOAD_SCHEMA_VERSION)expect(p.schemaVersion).toMatch(/^\d+\.\d+\.\d+$/)})it('ships the interpretation rules inside the payload', () => {// Fixture payloads prepend a sample-data warning, so this asserts every// standing rule survives rather than asserting an exact array.for (const rule of INTERPRETATION_RULES) expect(p.rules).toContain(rule)expect(p.rules.length).toBeGreaterThanOrEqual(6)})it('warns the consumer about the open-does-not-mean-unfinished trap', () => {// The single most dangerous sentence this system could generate is// "Sam is 15 days overdue" about work that is finished and awaiting// Monday sign-off. The rule that prevents it must be present.const joined = p.rules.join(' ').toLowerCase()expect(joined).toContain('does not mean unfinished')expect(joined).toContain('review')})it('warns the consumer not to conflate commitments with assignments', () => {expect(p.rules.join(' ').toLowerCase()).toContain('commitments and assignments are different')})it('stays small enough to run daily: this is the whole point of the seam', () => {// A model reasoning over raw payloads reads 200k-500k tokens per run. This// is the distilled version. If this assertion ever fails, the aggregation// has leaked back across the seam.const approxTokens = JSON.stringify(p).length / 4expect(approxTokens).toBeLessThan(12_000)})it('reports every source with its own ok flag and error', () => {expect(p.sources).toHaveLength(5)for (const s of p.sources) {expect(typeof s.ok).toBe('boolean')expect(s.covers.length).toBeGreaterThan(0)}expect(p.sources.map((s) => s.name)).toContain('Ninety to-dos')// With several keys, "some of the meetings were read" is a state the// payload can reach. Each person's `meetings` array is gated to what they// attended, so a short one looks completely normal. Without a source row there is nothing in the// payload that distinguishes a quiet fortnight from an unreadable key.expect(p.sources.map((s) => s.name)).toContain('Fathom meetings')})it('marks Fathom not-ok and says NOT ZERO when no key is configured', () => {const unset = buildBriefingPayload({ ...snap, fathomConfigured: false, fathomSources: [] })const fathom = unset.sources.find((s) => s.name === 'Fathom meetings')!expect(fathom.ok).toBe(false)expect(fathom.error).toMatch(/Not zero meetings/)for (const person of unset.people) expect(person.meetings).toBeNull()})it('marks Fathom not-ok when one key of three is dark, and names the owner', () => {// ok:false on a PARTIAL read is deliberate. The question this flag answers// for the model is "may I describe these meeting lists as complete", and// with a key dark the answer is no. brief.py turns it into a warning.const partial = buildBriefingPayload({...snap,fathomSources: [{ owner: 'Sam Whitaker', ok: true, error: null, returned: 8, truncated: false },{ owner: 'Ines Carvalho', ok: false, error: 'HTTP 401', returned: 0, truncated: false },{ owner: 'Theo Bassett', ok: true, error: null, returned: 2, truncated: false },],})const fathom = partial.sources.find((s) => s.name === 'Fathom meetings')!expect(fathom.ok).toBe(false)expect(fathom.error).toContain('Ines Carvalho')expect(fathom.error).toContain('HTTP 401')// The working keys' meetings are still on the payload. A dark key degrades// the claim of completeness; it does not delete two other people's data.expect(partial.people.some((x) => (x.meetings?.length ?? 0) > 0)).toBe(true)})it('is ok and silent when every key read cleanly', () => {const fathom = p.sources.find((s) => s.name === 'Fathom meetings')!expect(fathom.ok).toBe(true)expect(fathom.error).toBeNull()})it('carries the failure reason through when a source dies', () => {const dead = buildBriefingPayload({...snap,ninety: { ok: false, data: [], error: '403 Forbidden: Owner/Admin only' },ninetySpread: null,})const ninety = dead.sources.find((s) => s.name === 'Ninety to-dos')!expect(ninety.ok).toBe(false)expect(ninety.error).toContain('403')expect(dead.company.commitments).toBeNull()for (const person of dead.people) expect(person.todosOpen).toBeNull()})it('names the people carrying a shared commitment', () => {// Without this, the same item appears on three lists as if it were three// separate jobs and the briefing triple-counts the work.const shared = p.people.flatMap((x) => x.todos).find((t) => t.sharedWith.length > 0)expect(shared).toBeDefined()expect(shared!.sharedWith.length).toBeGreaterThanOrEqual(1)expect(shared!.sharedWith).not.toContain(shared!.owner)})it('distinguishes uncovered people from idle ones', () => {for (const person of p.people) {if (person.ordersOwed === null) expect(person.coverage.join(' ')).not.toMatch(/Plinth/i)}})it('caps lists and admits when it truncated', () => {for (const person of p.people) expect(person.orders.length).toBeLessThanOrEqual(LIST_CAP)expect(p.queues.oldestOrders.length).toBeLessThanOrEqual(LIST_CAP)expect(typeof p.queues.truncated).toBe('boolean')})it('counts orders with no designer as a data gap, not a queue', () => {expect(p.dataHealth.ordersMissingDesigner).toBe(p.queues.unassignedOrders.length)for (const o of p.queues.unassignedOrders) expect(o.designer).toBeNull()})it('groups on the Meridian calendar day, not UTC', () => {expect(p.timezone).toBe('America/Chicago')expect(p.day).toMatch(/^\d{4}-\d{2}-\d{2}$/)})it('never leaks raw HTML into a model context', () => {for (const t of p.people.flatMap((x) => x.todos)) {expect(t.title).not.toMatch(/<[a-z][^>]*>/i)}})})