Skip to content

chore(types): derive the event-loop histogram type from monitorEventLoopDelay - #874

Merged
RonenMars merged 1 commit into
mainfrom
fix/interval-histogram-type
Sep 12, 2026
Merged

chore(types): derive the event-loop histogram type from monitorEventLoopDelay#874
RonenMars merged 1 commit into
mainfrom
fix/interval-histogram-type

Conversation

@RonenMars

Copy link
Copy Markdown
Owner

What is wrong

@types/node 26.5.0 renames the perf_hooks interface IntervalHistogram to ELDHistogram.
src/services/host-pressure/hostPressure.ts imports it by name, so the bump in #853 fails both Lint and Build:

src/services/host-pressure/hostPressure.ts(3,15): error TS2305:
Module '"perf_hooks"' has no exported member 'IntervalHistogram'.

Why not just rename it

The two versions share neither name — 26.4.0 has only IntervalHistogram, 26.5.0 has only ELDHistogram.
Swapping one for the other moves the breakage to the other side of the bump rather than removing it, and leaves the same trap for the next rename.

The fix

Derive the type from the function that produces it:

type EventLoopHistogram = ReturnType<typeof monitorEventLoopDelay>;

That is whatever the installed @types/node calls it, so no future rename can break it.
There was one annotation site (HostPressureMonitorOpts.histogram); the monitorEventLoopDelay call site needed no change.

Type-only — erased at runtime, no behaviour change.

Verified state

Check Result
tsc against @types/node 26.4.0 (current pin) exit 0
tsc against @types/node 26.5.0 (the bump) exit 0
tsc against 26.5.0 with this change reverted reproduces the TS2305 above
biome check clean
__tests__/host-pressure.test.ts 42 passed

Checked 2026-09-12 against acc7d3fa.

Unblocks #853.

…oopDelay

@types/node 26.5.0 renames IntervalHistogram to ELDHistogram.
The two versions share neither name, so importing either one pins the repo to one side of that bump and breaks Lint and Build on the other.
Deriving the type with ReturnType tracks whatever the installed @types/node calls it.

Unblocks #853.
@RonenMars
RonenMars force-pushed the fix/interval-histogram-type branch from 5461fdb to d5a4a9e Compare September 12, 2026 01:03
@RonenMars
RonenMars merged commit 8714dd8 into main Sep 12, 2026
10 checks passed
@RonenMars
RonenMars deleted the fix/interval-histogram-type branch September 12, 2026 01:13
@RonenMars

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 1.90.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

RonenMars added a commit that referenced this pull request Sep 12, 2026
…ndency notes [skip-ci]

A @types/* type imported by name couples the repo to one version of that package.
@types/node 26.5.0 renamed IntervalHistogram to ELDHistogram with neither version declaring both, which failed Lint and Build on TS2305 while runtime behaviour was unchanged (#853, fixed by #874).
Deriving the type from the value is the fix and the general rule.

vitest 5.0.0 (#855) landed green on every check, which is strong evidence because CI runs the suite under the new runner — but not proof over config resolution, reporters, worker pooling or timeouts.

AGENTS.md's "Dependencies and build" section described vendor/scanner and vendor/agent-types as submodules with file: deps and claimed recursive CI checkouts.
None of that is true: menubar is the only submodule, scanner and agent-types are published @threadbase-sh npm packages, and every build/test checkout sets submodules: false.
It also understated the externals and the migration copies — the CLI externalizes better-sqlite3 as well as node-pty, and the build copies three migration directories, not two.
CLAUDE.md carried the same externals error and is corrected with it.

Pointers from CLAUDE.md, AGENTS.md and a new .cursor/rules/dependency-bumps.mdc so claude-code, codex and cursor all reach it.
RonenMars added a commit that referenced this pull request Sep 12, 2026
…ndency notes [skip-ci] (#877)

Two lessons from the dependabot batch that landed today, plus the stale
notes they exposed.

## 1. A `@types/*` type imported by name is a version coupling

`@types/node` 26.5.0 renamed the `perf_hooks` histogram
`IntervalHistogram` to `ELDHistogram`, and **neither version declares
both names**.
So #853 failed `Lint` and `Build` on `TS2305: … has no exported member`
while nothing was wrong at runtime.

Renaming the import moves the break to the other side of the bump and
leaves the same trap for the next rename.
Deriving the type from the value that produces it — `ReturnType<typeof
monitorEventLoopDelay>` — tracks whatever the installed types call it
(#874).

Recorded with the verify-both-versions procedure, the revert-to-red
check, and the sequencing constraint: the derived-type fix lands on
`main` first, then the dependabot PR rebases green.

## 2. A green suite does not fully clear a major test-runner bump

vitest 5.0.0 (#855) passed every check across two independent CI cycles.
That is strong evidence, because CI runs the suite *under* the new
runner — but it covers only what the suite exercises, not config
resolution, reporters, worker pooling or default timeouts.
Recorded as "suspect the runner first when tooling output turns odd".

## 3. `AGENTS.md` "Dependencies and build" was substantially wrong

Found while adding the above. Every claim below was checked against the
tree, not copied from `CLAUDE.md`:

| Claim | Reality |
|---|---|
| `vendor/scanner`, `vendor/agent-types`, `vendor/menubar` are
submodules | `.gitmodules` has only `vendor/menubar` |
| CI checkouts "remain recursive" | every `ci.yml`/`release.yml`
checkout sets `submodules: false`; only `update-menubar.yml` is
recursive |
| `@threadbase/scanner` are `file:` deps built by `postinstall` |
`@threadbase-sh/scanner@^0.17.2` and
`@threadbase-sh/agent-types@^1.0.0`, normal npm semver deps — the scope
was wrong too |
| "only `node-pty` is external" for the CLI | the CLI entry externalizes
`node-pty` **and `better-sqlite3`**; the library entry externalizes
`node-pty` and `pg` |
| "both SQLite and Postgres migration copies" | the build copies
**three** dirs: `migrations/`, `runtime-migrations/`, `pg-migrations/` |
| preserve `prepare` / `postinstall` | correct — kept, and noted that
`prepare` also sets `core.hooksPath` |

`CLAUDE.md` carried the same CLI-externals error and is corrected with
it.

## Reaching all three tools

Canonical text lives in `docs/troubleshooting.md`.
`CLAUDE.md` and `AGENTS.md` point at it; Cursor reads `AGENTS.md`
natively and additionally gets `.cursor/rules/dependency-bumps.mdc`,
scoped by `globs` to TS and dependency files rather than `alwaysApply`.

The `.mdc` is a short form plus a pointer, not a third copy — three
hand-maintained copies of one paragraph is how `AGENTS.md` drifted in
the first place.
Adding it falsified `docs/agents/tooling.md`'s "Cursor … read none of
the files above", which is updated here.

## Verified state

- `npx vitest --version` → `vitest/5.0.0 darwin-arm64 node-v24.15.0`,
confirming the runner claim.
- `@types/node` on `main` is `26.5.0` (#853 merged).
- `../../docs/troubleshooting.md` resolves from `.cursor/rules/`;
`.cursor/` is not gitignored.
- Code fences balanced; `biome check` clean.

Checked 2026-09-12 against `32a7977d`.

Docs-only, hence `[skip-ci]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant