diff --git a/pm-stack/aggregator/report-records-c7.md b/pm-stack/aggregator/report-records-c7.md index ac22946db3..3cf28ce86d 100644 --- a/pm-stack/aggregator/report-records-c7.md +++ b/pm-stack/aggregator/report-records-c7.md @@ -63,24 +63,29 @@ selected. ## Period composition and generation -`src/report-composer.ts` composes an explicit target period from current -canonical lower-grain records. Daily reports use source records; weekly reports -use daily records and separately label the prior Friday as reach-back context; -monthly, quarterly, and annual reports prefer composed records at the next -smaller grain, falling back to source records for a child period when no -composed version exists. Stable source-time and record-ID ordering makes the -result independent of record arrival order. Blocks bubble upward according to -their `importance` grains (or the default path from their source grain), and -classified activity carries linked members into the summary. The template -sections and composer identity are versioned as `c7-rollup-v1`. +`src/report-composer.ts` composes an explicit target period from the latest +retained lower-grain records available at `asOf`, and excludes blocks after +that instant or outside the target period. Daily reports use source records; +weekly reports use daily records and separately label only the prior Friday as +reach-back context; monthly, quarterly, and annual reports prefer composed +records at the next smaller grain, falling back to source records for a child +period when no composed version exists. Stable source-time and record-ID +ordering makes the result independent of record arrival order. Blocks bubble +upward according to their `importance` grains (or the default path from their +source grain). Non-visible `bubblingCandidates` preserve explicitly selected +higher grains across an excluded intermediate grain. Classified activity +carries only explicit member links; source attribution remains in `sources`. +The template sections and composer identity are versioned as `c7-rollup-v1`. Generate a record with `bun run report:generate --kind --period --as-of [--store ]`. Period identities are explicit: `YYYY-MM-DD` (daily), Monday `YYYY-MM-DD` (weekly), `YYYY-MM` (monthly), `YYYY-QN` (quarterly), and `YYYY` (annual). -The command validates its complete argument list and period identity before -store I/O, reads the selected retained records, and appends the result -idempotently. It follows `PM_AGG_STORE_BACKEND`: file mode uses the local +The command validates its complete argument list, period identity, and +half-open `asOf` bounds before store I/O, selects retained records available at +that point in time, and appends the result idempotently. A changed `asOf` is +part of the derived source cursor so distinct point-in-time views cannot +conflict under one immutable record ID. It follows `PM_AGG_STORE_BACKEND`: file mode uses the local report-record JSONL file (`PM_AGG_REPORT_RECORDS_FILE` or the default path), and `--store` selects another JSONL path in file mode. Turso mode uses the existing durable document adapter and never silently falls back to a file; diff --git a/pm-stack/aggregator/scripts/generate-report.ts b/pm-stack/aggregator/scripts/generate-report.ts index 59d5f59429..518c164814 100644 --- a/pm-stack/aggregator/scripts/generate-report.ts +++ b/pm-stack/aggregator/scripts/generate-report.ts @@ -42,7 +42,10 @@ export function parseArgs(args: string[]): Command { throw new Error("--as-of must be a canonical ISO-8601 timestamp"); } // Resolve now so bad/implicit period identities fail before any store I/O. - reportPeriod(kind, identity); + const period = reportPeriod(kind, identity); + if (Date.parse(asOf) < Date.parse(period.periodStart) || Date.parse(asOf) >= Date.parse(period.periodEnd)) { + throw new Error("--as-of must fall within the report period"); + } const store = values.get("--store")?.trim(); if (values.has("--store") && !store) throw new Error("--store must not be empty"); return { kind, identity, asOf, ...(store ? { store } : {}) }; diff --git a/pm-stack/aggregator/src/report-composer.ts b/pm-stack/aggregator/src/report-composer.ts index cbc925865d..846753df8b 100644 --- a/pm-stack/aggregator/src/report-composer.ts +++ b/pm-stack/aggregator/src/report-composer.ts @@ -1,7 +1,7 @@ // Deterministic C7 period rollups over canonical, persisted lower-grain records. import { dailyReportPeriod, type ReportPeriod, type ReportPeriodKind } from "./report-periods.ts"; import type { ReportRecord, ReportRecordBlock, ReportRecordSource, ReportRecordLocation } from "./report-records.ts"; -import { appendReportRecord, makeReportRecord, readCurrentReportRecords } from "./report-records.ts"; +import { appendReportRecord, makeReportRecord, readReportRecords } from "./report-records.ts"; export const REPORT_TEMPLATE_VERSION = "c7-rollup-v1"; @@ -42,6 +42,7 @@ export interface ComposedReport { sourceCursor: string; sources: ReportRecordSource[]; blocks: ReportRecordBlock[]; + bubblingCandidates: ReportRecordBlock[]; classifiedActivity: ClassifiedActivity; } @@ -74,11 +75,12 @@ function lowerGrainRecords( period: ReportPeriod, records: ReportRecord[], ): { record: ReportRecord; reachBack: boolean }[] { - const daily = preferComposedChildren(records, "daily"); + const daily = + period.kind === "daily" + ? records.filter((record) => record.period.kind === "daily" && record.templateVersion !== REPORT_TEMPLATE_VERSION) + : preferComposedChildren(records, "daily"); if (period.kind === "daily") - return daily - .filter((record) => record.templateVersion !== REPORT_TEMPLATE_VERSION && inPeriod(record, period)) - .map((record) => ({ record, reachBack: false })); + return daily.filter((record) => inPeriod(record, period)).map((record) => ({ record, reachBack: false })); const current = daily.filter((record) => inPeriod(record, period)).map((record) => ({ record, reachBack: false })); // Weekly reports carry the prior week's Friday as explicit context. It is @@ -89,13 +91,9 @@ function lowerGrainRecords( const mondayDate = new Date(`${monday}T00:00:00.000Z`); mondayDate.setUTCDate(mondayDate.getUTCDate() - 3); const friday = mondayDate.toISOString().slice(0, 10); - const fridayStart = Date.parse(dailyReportPeriod(friday).periodStart); - const mondayStart = Date.parse(period.periodStart); + const fridayPeriod = dailyReportPeriod(friday); const reachBack = daily - .filter( - (record) => - Date.parse(record.period.periodStart) >= fridayStart && Date.parse(record.period.periodStart) < mondayStart, - ) + .filter((record) => record.period.id === fridayPeriod.id) .map((record) => ({ record, reachBack: true })); return [...current, ...reachBack]; } @@ -135,20 +133,49 @@ export function composeReport( throw new Error("asOf must fall within the report period"); } - const rows = stableSourceRows(period, records); - const orderedBlocks = rows - .flatMap(({ record, reachBack }) => - record.blocks - .filter((block) => !block.importance || block.importance.includes(period.kind)) - .map((block) => ({ - ...structuredClone(block), - id: `${record.id}:${block.id}`, + const rows = stableSourceRows( + period, + records.filter((record) => Date.parse(record.asOf) <= Date.parse(options.asOf)), + ); + if (!rows.length) throw new Error("cannot compose a report without canonical source records"); + const orderedBlocks: ReportRecordBlock[] = []; + const bubblingCandidates: ReportRecordBlock[] = []; + const orderedByIdentity = new Map(); + const grainOrder: ReportPeriodKind[] = ["daily", "weekly", "monthly", "quarterly", "annual"]; + const targetGrain = grainOrder.indexOf(period.kind); + for (const { record, reachBack } of rows) { + const composedInput = record.templateVersion === REPORT_TEMPLATE_VERSION; + const sourceBlocks = [ + ...new Map([...record.blocks, ...(record.bubblingCandidates ?? [])].map((block) => [block.id, block])).values(), + ]; + for (const block of sourceBlocks) { + // Templates and summaries describe their source report, not source + // activity. Rebuild them at the target grain instead of rolling them up. + if (composedInput && (block.id.startsWith("template:") || block.id.startsWith("activity:"))) continue; + const relatedAt = Date.parse(block.relatedAt); + const inRequestedPeriod = relatedAt >= Date.parse(period.periodStart) && relatedAt < Date.parse(period.periodEnd); + if (relatedAt > Date.parse(options.asOf) || (!inRequestedPeriod && !reachBack)) continue; + const importance = block.importance ?? defaultImportance(record.period.kind); + const normalized = { ...structuredClone(block), importance }; + const id = composedInput ? block.id : `${record.id}:${block.id}`; + if (importance.includes(period.kind)) { + const ordered = { + ...normalized, + id, text: reachBack ? `[Prior-Friday reach-back] ${block.text}` : block.text, - links: [...new Set([...(block.links ?? []), ...record.sources.map((source) => source.uri)])].sort(), - importance: block.importance ?? defaultImportance(record.period.kind), - })), - ) - .sort((left, right) => left.relatedAt.localeCompare(right.relatedAt) || left.id.localeCompare(right.id)); + links: block.links ? [...new Set(block.links)].sort() : undefined, + }; + const previous = orderedByIdentity.get(id); + if (!previous || (previous.reachBack && !reachBack)) orderedByIdentity.set(id, { block: ordered, reachBack }); + } + if (!reachBack && importance.some((kind) => grainOrder.indexOf(kind) > targetGrain)) { + bubblingCandidates.push({ ...normalized, id }); + } + } + } + orderedBlocks.push(...[...orderedByIdentity.values()].map(({ block }) => block)); + const uniqueCandidates = [...new Map(bubblingCandidates.map((block) => [block.id, block])).values()]; + orderedBlocks.sort((left, right) => left.relatedAt.localeCompare(right.relatedAt) || left.id.localeCompare(right.id)); const activity: ClassifiedActivity = { implemented: [], @@ -158,9 +185,22 @@ export function composeReport( blocked: [], queued: [], }; + const latestClassification = new Map(); for (const block of orderedBlocks) { - if (block.classification) activity[classificationKeys[block.classification]].push(...(block.links ?? [])); + if (!block.classification) continue; + const key = classificationKeys[block.classification]; + for (const member of block.links ?? []) { + const previous = latestClassification.get(member); + if ( + !previous || + block.relatedAt.localeCompare(previous.relatedAt) > 0 || + (block.relatedAt === previous.relatedAt && block.id.localeCompare(previous.id) > 0) + ) { + latestClassification.set(member, { relatedAt: block.relatedAt, id: block.id, key }); + } + } } + for (const [member, latest] of latestClassification) activity[latest.key].push(member); for (const key of Object.keys(activity) as (keyof ClassifiedActivity)[]) activity[key] = [...new Set(activity[key])].sort(); @@ -174,14 +214,19 @@ export function composeReport( importance: defaultImportance(period.kind), })); const sources = [ - ...new Map(rows.flatMap(({ record }) => record.sources).map((source) => [source.id, source])).values(), + ...new Map( + rows + .flatMap(({ record }) => record.sources) + .filter((source) => Date.parse(source.observedAt) <= Date.parse(options.asOf)) + .map((source) => [source.id, source]), + ).values(), ].sort((left, right) => left.observedAt.localeCompare(right.observedAt) || left.id.localeCompare(right.id)); const sourceCursor = options.sourceCursor ?? - rows + `${rows .map(({ record }) => record.id) .sort() - .join(","); + .join(",")};asOf:${options.asOf}`; if (!sourceCursor.trim()) throw new Error("cannot compose a report without canonical source records"); const templateBlocks: ReportRecordBlock[] = REPORT_TEMPLATES[period.kind].map((title, index) => ({ id: `template:section:${String(index + 1).padStart(2, "0")}`, @@ -197,6 +242,7 @@ export function composeReport( sourceCursor, sources, blocks: [...templateBlocks, ...summaryBlocks, ...orderedBlocks], + bubblingCandidates: uniqueCandidates, classifiedActivity: activity, }; } @@ -207,7 +253,21 @@ export async function generateReportFromStoredRecords( period: ReportPeriod, options: ComposeReportOptions, ): Promise<{ record: ReportRecord; inserted: boolean }> { - const stored = await readCurrentReportRecords(location); + const allStored = await readReportRecords(location); + const latestAsOf = new Map(); + for (const record of allStored) { + if (Date.parse(record.asOf) > Date.parse(options.asOf)) continue; + const key = `${record.period.id}\n${record.templateVersion}`; + const previous = latestAsOf.get(key); + if ( + !previous || + record.asOf > previous.asOf || + (record.asOf === previous.asOf && record.generatedAt > previous.generatedAt) + ) { + latestAsOf.set(key, record); + } + } + const stored = [...latestAsOf.values()]; const composed = composeReport(period, stored, options); const record = makeReportRecord(composed, options.generatedAt); const result = await appendReportRecord(location, record); diff --git a/pm-stack/aggregator/src/report-records.ts b/pm-stack/aggregator/src/report-records.ts index d70ca257e7..2a4115e61e 100644 --- a/pm-stack/aggregator/src/report-records.ts +++ b/pm-stack/aggregator/src/report-records.ts @@ -30,6 +30,8 @@ export interface ReportRecordInput { sourceCursor: string; sources: ReportRecordSource[]; blocks: ReportRecordBlock[]; + /** Non-visible blocks retained for explicitly requested higher-grain rollups. */ + bubblingCandidates?: ReportRecordBlock[]; } export interface ReportRecord extends ReportRecordInput { @@ -162,6 +164,24 @@ export function makeReportRecord(input: ReportRecordInput, generatedAt = new Dat throw new Error(`report block ${block.id} has invalid links`); } } + for (const block of input.bubblingCandidates ?? []) { + if (!block.id.trim() || !block.text.trim()) throw new Error("each bubbling candidate requires an id and text"); + requireIsoDate(block.relatedAt, "bubbling candidate relatedAt"); + if ( + block.importance && + (!Array.isArray(block.importance) || + block.importance.some((kind) => !(REPORT_PERIOD_KINDS as readonly string[]).includes(kind)) || + new Set(block.importance).size !== block.importance.length) + ) { + throw new Error(`bubbling candidate ${block.id} has invalid importance levels`); + } + if ( + block.links && + (!Array.isArray(block.links) || block.links.some((link) => typeof link !== "string" || !link.trim())) + ) { + throw new Error(`bubbling candidate ${block.id} has invalid links`); + } + } return { ...structuredClone(input), id: reportRecordId(input), generatedAt }; } diff --git a/pm-stack/aggregator/test/report-composer-c7.test.ts b/pm-stack/aggregator/test/report-composer-c7.test.ts index 639baf7199..5b7df02d24 100644 --- a/pm-stack/aggregator/test/report-composer-c7.test.ts +++ b/pm-stack/aggregator/test/report-composer-c7.test.ts @@ -2,7 +2,13 @@ import { access, mkdtemp, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { afterEach, describe, expect, test } from "bun:test"; -import { weeklyReportPeriod, dailyReportPeriod } from "../src/report-periods.ts"; +import { + annualReportPeriod, + monthlyReportPeriod, + quarterlyReportPeriod, + weeklyReportPeriod, + dailyReportPeriod, +} from "../src/report-periods.ts"; import { composeReport, generateReportFromStoredRecords, MODAL_LIVING_ITEM_FIXTURE } from "../src/report-composer.ts"; import { appendReportRecord, @@ -89,6 +95,9 @@ describe("C7 report composition", () => { "weekly", ]), ).toThrow(/duplicate argument/); + expect(() => + parseArgs(["--kind", "daily", "--period", "2026-11-21", "--as-of", "2026-11-22T12:00:00.000Z"]), + ).toThrow(/within the report period/); }); test("report CLI does not silently use a file when the configured backend is Turso", async () => { @@ -171,6 +180,19 @@ describe("C7 report composition", () => { }); expect(rerun.inserted).toBe(false); expect(rerun.record.id).toBe(generated.record.id); + + const dailyRerun = await generateReportFromStoredRecords(file, dailyReportPeriod("2026-11-21"), { + asOf: "2026-11-21T18:00:00.000Z", + generatedAt: "2026-11-21T18:02:00.000Z", + }); + expect(dailyRerun.inserted).toBe(false); + expect(dailyRerun.record.id).toBe(daily.record.id); + const dailyRefresh = await generateReportFromStoredRecords(file, dailyReportPeriod("2026-11-21"), { + asOf: "2026-11-21T19:00:00.000Z", + generatedAt: "2026-11-21T19:01:00.000Z", + }); + expect(dailyRefresh.inserted).toBe(true); + expect(dailyRefresh.record.id).not.toBe(daily.record.id); }); test("keeps generation dependent on explicit period identity and uses the amendment's Modal example", () => { @@ -183,7 +205,193 @@ describe("C7 report composition", () => { test("includes prior Friday through calendar boundaries across a DST transition", () => { const friday = dailyRecord("2026-03-06", "Friday before the spring DST transition."); - const result = composeReport(weeklyReportPeriod("2026-03-09"), [friday], { asOf: "2026-03-10T12:00:00.000Z" }); + const saturday = dailyRecord("2026-03-07", "Saturday must not be reach-back context."); + const sunday = dailyRecord("2026-03-08", "Sunday must not be reach-back context."); + const result = composeReport(weeklyReportPeriod("2026-03-09"), [friday, saturday, sunday], { + asOf: "2026-03-10T12:00:00.000Z", + }); expect(result.blocks.some((block) => block.text.startsWith("[Prior-Friday reach-back] Friday before"))).toBe(true); + expect(result.blocks.some((block) => block.text.includes("Saturday must not"))).toBe(false); + expect(result.blocks.some((block) => block.text.includes("Sunday must not"))).toBe(false); + }); + + test("keeps source provenance separate from classified member links", () => { + const period = dailyReportPeriod("2026-11-21"); + const at = "2026-11-21T18:00:00.000Z"; + const source = makeReportRecord( + { + period, + asOf: at, + templateVersion: "daily-source-v1", + sourceCursor: "member-and-evidence", + sources: [{ id: "evidence", uri: "doc:evidence", observedAt: at }], + blocks: [ + { + id: "done", + text: "Implemented one issue.", + relatedAt: at, + links: ["issue:one"], + classification: "implemented", + }, + ], + }, + at, + ); + const report = composeReport(period, [source], { asOf: at }); + expect(report.classifiedActivity.implemented).toEqual(["issue:one"]); + expect(report.sources.map((item) => item.uri)).toEqual(["doc:evidence"]); + }); + + test("carries explicit higher-grain candidates without showing them at excluded grains", () => { + const source = makeReportRecord( + { + period: dailyReportPeriod("2026-01-05"), + asOf: "2026-01-05T18:00:00.000Z", + templateVersion: "daily-source-v1", + sourceCursor: "annual-only-candidate", + sources: [{ id: "event", uri: "event:annual", observedAt: "2026-01-05T18:00:00.000Z" }], + blocks: [ + { + id: "candidate", + text: "This item is explicitly annual.", + relatedAt: "2026-01-05T18:00:00.000Z", + importance: ["daily", "weekly", "annual"], + }, + ], + }, + "2026-01-05T18:01:00.000Z", + ); + const daily = makeReportRecord( + composeReport(dailyReportPeriod("2026-01-05"), [source], { asOf: "2026-01-05T18:00:00.000Z" }), + "2026-01-05T18:02:00.000Z", + ); + const weekly = makeReportRecord( + composeReport(weeklyReportPeriod("2026-01-05"), [source, daily], { asOf: "2026-01-11T18:00:00.000Z" }), + "2026-01-11T18:01:00.000Z", + ); + const monthly = makeReportRecord( + composeReport(monthlyReportPeriod("2026-01"), [weekly], { asOf: "2026-01-31T18:00:00.000Z" }), + "2026-01-31T18:01:00.000Z", + ); + const quarterly = makeReportRecord( + composeReport(quarterlyReportPeriod("2026-Q1"), [monthly], { asOf: "2026-03-31T18:00:00.000Z" }), + "2026-03-31T18:01:00.000Z", + ); + const annual = composeReport(annualReportPeriod("2026"), [quarterly], { asOf: "2026-12-31T18:00:00.000Z" }); + + expect(weekly.blocks.some((block) => block.text === "This item is explicitly annual.")).toBe(true); + expect(monthly.blocks.some((block) => block.text === "This item is explicitly annual.")).toBe(false); + expect(monthly.bubblingCandidates?.some((block) => block.text === "This item is explicitly annual.")).toBe(true); + expect(annual.blocks.some((block) => block.text === "This item is explicitly annual.")).toBe(true); + }); + + test("excludes future records and activity from an earlier as-of view", () => { + const monday = dailyRecord("2026-11-16", "Occurred before the requested point.", "implemented"); + const saturday = dailyRecord("2026-11-21", "Occurred after the requested point.", "implemented"); + const result = composeReport(weeklyReportPeriod("2026-11-16"), [monday, saturday], { + asOf: "2026-11-19T12:00:00.000Z", + }); + expect(result.blocks.some((block) => block.text.includes("Occurred before"))).toBe(true); + expect(result.blocks.some((block) => block.text.includes("Occurred after"))).toBe(false); + expect(result.classifiedActivity.implemented).toEqual(["gh:developing-today/code/issues/2026-11-16"]); + }); + + test("excludes prior-month activity from a weekly record used in a monthly rollup", () => { + const start = dailyRecord("2026-10-27", "October activity in a cross-month week.", "implemented"); + const november = dailyRecord("2026-11-01", "November activity in a cross-month week.", "implemented"); + const weekPeriod = weeklyReportPeriod("2026-10-26"); + const weekly = makeReportRecord( + composeReport(weekPeriod, [start, november], { asOf: "2026-11-01T18:00:00.000Z" }), + "2026-11-01T18:01:00.000Z", + ); + const monthly = composeReport(monthlyReportPeriod("2026-11"), [weekly], { asOf: "2026-11-30T18:00:00.000Z" }); + expect(monthly.blocks.some((block) => block.text.includes("October activity"))).toBe(false); + expect(monthly.blocks.some((block) => block.text.includes("November activity"))).toBe(true); + expect(monthly.classifiedActivity.implemented).toEqual(["gh:developing-today/code/issues/2026-11-01"]); + }); + + test("preserves source identity across Friday reach-back and does not bubble the context copy", () => { + const friday = dailyRecord("2026-11-06", "Friday living-item update.", "implemented"); + const weekOnePeriod = weeklyReportPeriod("2026-11-02"); + const weekOne = makeReportRecord( + composeReport(weekOnePeriod, [friday], { asOf: "2026-11-08T18:00:00.000Z" }), + "2026-11-08T19:00:00.000Z", + ); + const weekTwoPeriod = weeklyReportPeriod("2026-11-09"); + const weekTwo = makeReportRecord( + composeReport(weekTwoPeriod, [friday], { asOf: "2026-11-10T18:00:00.000Z" }), + "2026-11-10T19:00:00.000Z", + ); + const monthly = composeReport(monthlyReportPeriod("2026-11"), [weekOne, weekTwo], { + asOf: "2026-11-30T18:00:00.000Z", + }); + + expect(weekTwo.bubblingCandidates?.some((block) => block.text.includes("Friday living-item update."))).toBe(false); + expect(monthly.blocks.filter((block) => block.text.includes("Friday living-item update."))).toHaveLength(1); + }); + + test("regenerates activity summaries at the target grain instead of carrying weekly summaries upward", () => { + const october = dailyRecord("2026-10-27", "October implementation.", "implemented"); + const november = dailyRecord("2026-11-01", "November implementation.", "implemented"); + const weekly = makeReportRecord( + composeReport(weeklyReportPeriod("2026-10-26"), [october, november], { + asOf: "2026-11-01T18:00:00.000Z", + }), + "2026-11-01T19:00:00.000Z", + ); + const monthly = composeReport(monthlyReportPeriod("2026-11"), [weekly], { asOf: "2026-11-30T18:00:00.000Z" }); + + const summaries = monthly.blocks.filter((block) => block.id === "activity:implemented"); + const implementedSummary = summaries[0]; + expect(implementedSummary?.text).toBe("implemented: 1 linked member"); + expect(implementedSummary?.links).toEqual(["gh:developing-today/code/issues/2026-11-01"]); + expect(summaries).toHaveLength(1); + }); + + test("counts each linked member only in its latest classification as of the report time", () => { + const mondayAt = "2026-11-16T18:00:00.000Z"; + const tuesdayAt = "2026-11-17T18:00:00.000Z"; + const member = "gh:developing-today/code/issues/12345"; + const monday = makeReportRecord( + { + period: dailyReportPeriod("2026-11-16"), + asOf: mondayAt, + templateVersion: "daily-source-v1", + sourceCursor: "monday-progress", + sources: [{ id: "monday-source", uri: "issue:12345", observedAt: mondayAt }], + blocks: [ + { id: "started", text: "Started work.", relatedAt: mondayAt, links: [member], classification: "in-progress" }, + ], + }, + mondayAt, + ); + const tuesday = makeReportRecord( + { + period: dailyReportPeriod("2026-11-17"), + asOf: tuesdayAt, + templateVersion: "daily-source-v1", + sourceCursor: "tuesday-implemented", + sources: [{ id: "tuesday-source", uri: "issue:12345", observedAt: tuesdayAt }], + blocks: [ + { + id: "finished", + text: "Finished work.", + relatedAt: tuesdayAt, + links: [member], + classification: "implemented", + }, + ], + }, + tuesdayAt, + ); + const period = weeklyReportPeriod("2026-11-16"); + const mondayView = composeReport(period, [monday, tuesday], { asOf: "2026-11-16T23:00:00.000Z" }); + const tuesdayView = composeReport(period, [monday, tuesday], { asOf: "2026-11-17T23:00:00.000Z" }); + + expect(mondayView.classifiedActivity.inProgress).toEqual([member]); + expect(tuesdayView.classifiedActivity.implemented).toEqual([member]); + expect(tuesdayView.classifiedActivity.inProgress).toEqual([]); + expect(tuesdayView.blocks.some((block) => block.text === "Started work.")).toBe(true); + expect(tuesdayView.blocks.some((block) => block.text === "Finished work.")).toBe(true); }); });