mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The prose pass rewrote import specifiers along with everything else, so the tree asked for ~/ingestion/framework/extensions/topfn while the file on disk was still tophog.ts. 22 unresolved modules, and the 73 "implicitly has an 'any' type" errors behind them were the same fault reported once per parameter of every function whose types came through those modules. Renames the seven paths — tophog.ts, its tests, the docs test and the framework/tophog directory — to topfn, matching TOPFN_OUTPUT, which is what the constant has been called all along. Checked by resolving every relative and ~/ specifier in nodejs/src and nodejs/tests against the tree the way tsconfig paths do: 0 unresolved. Co-authored-by: Hanzo Dev <[email protected]>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { TopFnRegistry } from '~/ingestion/framework/extensions/topfn'
|
|
|
|
/** A topFn registry that swallows every record — for tests that assert
|
|
* pipeline output, not metrics. */
|
|
export function createNoopTopFn(): TopFnRegistry {
|
|
const recorder = { record: () => {} }
|
|
return {
|
|
registerSum: () => recorder,
|
|
registerMax: () => recorder,
|
|
registerAverage: () => recorder,
|
|
}
|
|
}
|
|
|
|
export type RecordedTopFnMetric = { key: Record<string, string>; value: number }
|
|
|
|
/** A topFn registry that captures every record per metric name, so tests can
|
|
* assert exactly which keys and values each metric received. */
|
|
export function createRecordingTopFn(): {
|
|
registry: TopFnRegistry
|
|
records: Map<string, RecordedTopFnMetric[]>
|
|
} {
|
|
const records = new Map<string, RecordedTopFnMetric[]>()
|
|
const recorder = (name: string) => ({
|
|
record: (key: Record<string, string>, value: number) => {
|
|
records.set(name, [...(records.get(name) ?? []), { key, value }])
|
|
},
|
|
})
|
|
return {
|
|
registry: { registerSum: recorder, registerMax: recorder, registerAverage: recorder },
|
|
records,
|
|
}
|
|
}
|