Skip to content

Commit d299e7b

Browse files
committed
revert(audit): keep a run's rollup window at two seconds
Reverts 03ca9c5. A rollup holds entries in process memory until its window closes, so a minute-long window widens what a crashed process loses from the audit trail thirty-fold. Platforms that aggregate audit events summarize records already written durably; keep the short window.
1 parent 6e714dc commit d299e7b

2 files changed

Lines changed: 2 additions & 112 deletions

File tree

‎packages/audit/src/rollup.test.ts‎

Lines changed: 0 additions & 99 deletions
This file was deleted.

‎packages/audit/src/rollup.ts‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ const logger = createLogger('AuditRollup')
77
/** How long the first entry of a rollup waits for repeats before it is written. */
88
const ROLLUP_WINDOW_MS = 2_000
99

10-
/**
11-
* The window inside a {@link withAuditRollupScope}, whose end writes the row
12-
* anyway: long enough that a run's repeats share one row however far apart
13-
* they fall, short enough that a run whose process dies loses at most this much.
14-
*/
15-
const SCOPED_ROLLUP_WINDOW_MS = 60_000
16-
1710
/** Entries merged into one row; bounds the identifier arrays its metadata collects. */
1811
const ROLLUP_MAX_ENTRIES = 100
1912

@@ -33,8 +26,7 @@ export interface AuditRollupSummary {
3326

3427
/**
3528
* One occurrence of a repetitive audit event. Occurrences sharing a rollup key
36-
* within {@link ROLLUP_WINDOW_MS} ({@link SCOPED_ROLLUP_WINDOW_MS} inside a
37-
* scope) become one row, and nothing an occurrence
29+
* within {@link ROLLUP_WINDOW_MS} become one row, and nothing an occurrence
3830
* carried is dropped: a lone occurrence is written exactly as `params`, and a
3931
* merged row sums every counter, collects every identifier, and records how
4032
* many occurrences it stands for and when the first and last happened.
@@ -127,10 +119,7 @@ export function recordAuditRollup(entry: AuditRollupEntry): void {
127119
entries: 1,
128120
counters: { ...entry.counters },
129121
identifiers: new Map(),
130-
timer: setTimeout(
131-
() => startWrite([take(key)]),
132-
scope ? SCOPED_ROLLUP_WINDOW_MS : ROLLUP_WINDOW_MS
133-
),
122+
timer: setTimeout(() => startWrite([take(key)]), ROLLUP_WINDOW_MS),
134123
}
135124
collectIdentifiers(rollup, entry)
136125
pending.set(key, rollup)

0 commit comments

Comments
 (0)