Skip to content

test(provider-docs): derive the named citations and assert them in declaration order (#641) - #1194

Merged
cevheri merged 2 commits into
libredb:mainfrom
Retsumdk:fix/641-derive-named-citations
Sep 28, 2026
Merged

cevheri merged 2 commits into
libredb:mainfrom
Retsumdk:fix/641-derive-named-citations

Conversation

@Retsumdk

Copy link
Copy Markdown
Contributor

Description

NAMED_CITATIONS was a hand-written literal, and nothing measured that it still held every name the doc cites. Adding a citation to a guarded doc changed nothing; the guard was only as wide as whoever last edited the array. This derives the population inside the test and asserts the checked-in list equals it, then widens the array to what the derivation returns.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

Related Issue

Closes #641

Changes Made

  • Added citedNames() (every `name( a doc cites, in document order), declaredMembers() (the class members declarationLine can match, in declaration order, deduplicated) and derivedCitation() (their intersection).
  • Added one test per NAMED_CITATIONS entry: assert the derived set is non-empty first — a guard over nothing passes, the way tests: the factory-citation guard can go vacuous, and 7 provider docs still cite a line inside factory.ts #620 shed four assertions and stayed green — then toEqual the literal against it.
  • Ordered comparison, as you asked: it is also what measures the "in declaration order" claim in the clickhouse/druid/couchbase comments, which four entries did not honour. Inline notes (mssql.md §12 above queryReadOnly, redis.md object surface above listContainers) moved with their names.
  • Widened all eleven entries, not the seven subsets: measured on today's main, the three "tracks the doc" entries are subsets too, so the assertion went red on all eleven regardless of scope. sqlite 7 -> 24, mssql 13 -> 30, trino 2 -> 20, mysql 11 -> 29, oracle 13 -> 32, mongodb 10 -> 24, redis 14 -> 36, postgres 9 -> 36, clickhouse 20 -> 23, druid 18 -> 19, couchbase 24 -> 26.
  • Read every added name in its own doc before pasting it, as you flagged: no name is cited while the doc is talking about a different file. The names are the monitoring surface the issue called out (getHealth, getOverview, getPerformanceMetrics, getSlowQueries, getActiveSessions, getTableStats, getIndexStats, getStorageStats) plus the object surface (readObjectSource, describeObjects, buildObjectEdit/applyObjectEdit, scanKeyGroups/scanKeysPage, objectDetailFrom, keyspaceDetail, readDatabaseSizeBytes, getDatabaseName, getPgStatActivity, buildQueryResult) and the transaction surface (commitTransaction, rollbackTransaction, isInTransaction, endOpenQueryTransaction, expireTransaction, queryReadOnly, queryWithMaterializedFallback).
  • Policy unchanged. The header comment's pinned policy and the deliberately narrow SCOPE paragraph still describe the guard; only the width of the list moved.

Testing

  • I have tested this locally
  • I have added/updated tests
  • All existing tests pass

bun test tests/unit/provider-docs-monitoring-citations.test.ts — 76 pass, 0 fail, expect() calls 480 -> 818 (+338), which is the delta the issue asks to report. 65 tests before, 76 after (the 11 new per-entry assertions); the widened literals account for the rest.

Mutation-checked in both directions, so the new assertion is doing work:

  • Dropping a cited name from docs/providers/trino.md fails both the entry's existing assertion and the new one.
  • Citing a name the entry's source declares but the list does not hold (describeConnectFailure() in trino.md) leaves "names methods that ... really declares" green and fails only the new assertion — which is the gap in the issue, reproduced and then closed.

Also run: bun run typecheck clean, bunx biome format reports no changes.

Test Environment

  • LibreDB Studio Version: main at 9d9d1ee
  • Node.js/Bun Version: Bun 1.2.21
  • OS: Debian 12 (linux-x64)

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The required CI test job passes the 100% line-coverage gate (bun run test:coverage and bun run coverage:check)
  • If I changed src/lib/db/providers/, I updated the matching docs/providers/ documentation and tests/integration/db/ tests in the same PR (provider triad)
  • Any dependent changes have been merged and published

Additional Notes

No src/ change, so the provider triad does not apply. The coverage checkbox is left unmarked because I did not run the full coverage gate locally; this diff adds test-file lines only.

…libredb#641)

`NAMED_CITATIONS` was a hand-written literal and nothing measured that it
still held every name the doc cites. Add a citation to a guarded doc and
the guard said nothing.

Derive the population inside the test — the names the doc cites as
`` `name( `` intersected with the members `declarationLine` can match —
and assert the checked-in list equals it. The literal stays the reviewed
expectation; the derivation is what goes red when a doc changes what it
cites. A guard over nothing passes, so the derived set is asserted
non-empty first (libredb#620).

Compared with `toEqual`, which also measures the "in declaration order"
claim the clickhouse, druid and couchbase comments make and which four
entries did not honour. Inline notes moved with their names.

Widened every entry to the derivation, not just the seven subsets: the
three "tracks the doc" entries are subsets, so all eleven were red
regardless of scope. Each added name was read in its own doc first — no
name is cited while talking about another file.

Verified: `bun test tests/unit/provider-docs-monitoring-citations.test.ts`
76 pass, `expect() calls` 480 -> 818 (+338). Mutation-checked both
directions: dropping a citation from `trino.md` fails the entry, and
citing a declared-but-unlisted member fails only the new assertion while
"names methods that ... really declares" stays green.
…g citations

TypeScript accepts only `public override async`, and the derivation expected
`async` before `override`, so a member declared that way was dropped: a
legal refactor of a guarded source went red, and a newly cited name would
have gone unmeasured. None of the eleven sources declares one today.
@cevheri

cevheri commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Thanks @Retsumdk, nice work and welcome LibreDB Studio team :)
I checked it, everything works as you described.
I pushed one small fix on top (d1e9ddb) so the regex also catches override async members.
Will merge once CI is green.

@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cevheri
cevheri merged commit 930de9d into libredb:main Sep 28, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seven of eight NAMED_CITATIONS entries are hand-picked subsets, so a doc can add a citation nothing measures

2 participants