refactor(db): one renderer for the container-path sentence - #1092
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
8464574 to
b132509
Compare
cevheri
left a comment
There was a problem hiding this comment.
Thanks. I checked the old conditions against the shared check on all fifteen engines and found no disagreement. Keeping Druid's containerSchema as its reader is the right call. One more round before I merge:
requireLevelis a PostgreSQL-only rule in the shared type, and the hoist dropped theundefinedcheck incontainerSchema, so anundefinedschema segment now binds as$1. Please drop the field and give PostgreSQL a local reader like Druid'scontainerSegment(druid/objects.ts:371) that names the missing level and refusesundefined, and point the test at postgres-provider.test.ts:5056 at it.- The only-producer test misses a quoted-string throw, and
>= 14lets one engine leave. Please match the phrase in any string literal after stripping comments, pin the fifteen files, and drop the deadobject-kinds.tsskip. - Leftovers: the unreachable empty arm and "shapes above" docblocks on
shapeList()in trino and duckdb, the docblock at mssql.ts:1037,{@link containerShapes}at trino/objects.ts:553, and the rename in prose at sqlite.ts:1490. - Eight files import object-kinds twice, and seven declare the descriptor between imports. Moving it below them lets cassandra, clickhouse, druid and trino use their
PROVIDER/TYPE_ID.
|
Rebased onto I let the test that pins those citations settle it instead of picking a side. Nothing else changed in the rebase. 14 provider suites plus the citation and renderer unit files (2728 tests) pass under bun 1.4.2, and all checks are green on the new head (SonarCloud and Image Scan skip on forks as usual). |
|
@sloemo01 , we wrote comment, same-time :) please check it: #1092 (review) |
Just saw this lol |
@sloemo01 :) One more round before I merge |
|
Also: big news > we now support Apache Kafka, Prometheus, and MCP Server in the new 0.17.0 release. I want to share this great news with you. thanks for your contributions. your name is in here: https://lnkd.in/p/dZ2C4dgn |
) Fifteen provider files built their own `container path is [...]` refusal, eleven deriving the level list locally and four carrying a private `shapeList()`, two of which had already drifted. `assertContainerPathShape` now produces all of them, the way `assertObjectPathShape` does for object paths since libredb#1023. Reading the fifteen showed they were not one shape. Three policies were hiding in them and the descriptor carries each one rather than collapsing them: - `shapes`: most engines accept exactly the declared depth; Couchbase, Trino, DuckDB and SQL Server accept every prefix up to it, because naming only the outer levels is a real address there. - `shapeNames`: Trino and PostgreSQL spell the shape from `level.id`, not the label, which only a varied declaration shows. Every other engine prints the label, which is the engine's own word for a person reading a refusal. - `emptyShapes`: an engine declaring no container level says why in its own words rather than printing an empty join that reads as a formatting bug. PostgreSQL's readers look the `schema` level up rather than reading by position, so a declaration that names none is refused by `containerSchema` itself, next to the reads it protects, and not by a field on the shared type that no other engine would ever set. `object-route.ts` cited line numbers in two of the shifted files, and the test that pins every citation is updated to the lines its anchors now sit on. Four `containerShapes()` helpers, two `declaredLevels()` copies and the imports they orphaned are gone. `tests/unit/db/container-path-renderer.test.ts` is the mechanical half of the acceptance criterion: it reads the provider tree and fails if any provider builds the sentence itself, matches the phrase in any quote style after comments are stripped, pins the fifteen engine files by name rather than behind a floor, or keeps a private container shape helper. Each descriptor field is pinned by a provider test, and ignoring one reddens exactly its own engine.
b132509 to
6063e18
Compare
|
All four addressed in
The detector is tightened. It strips both comment forms first (including a docblock whose continuation lines carry no marker), then matches the phrase inside any string literal in any quote style, so the double-quoted throw the old backtick-only matcher read as clean is caught. I proved that by injecting one: the file goes red with the line in the message, and green again after restore. The fifteen files are pinned by name instead of The leftovers are cleaned. Trino's and DuckDB's Imports and descriptor placement. Eight files were importing Verified on the rebased head under the pinned Bun 1.4.2: format (idempotent), lint 0 errors, typecheck, knip, security:check, readme:check, chart:check all clean; all fifteen provider integration suites green (2799 tests); the full suite runs 648 of 649 files, the one red file being |
The line scanner stripped `//` without knowing about strings, so a throw carrying a URL before the phrase read as clean. The detector now walks the string and template nodes of the parsed file, the way the seam guards read a provider, so comments never reach it. Also drops the blank line the descriptor move left inside seven import blocks, and a double space in Oracle's descriptor docblock.
What
Fifteen provider files built their own
container path is [...]refusal. Eleven derived the level list locally, four carried a privateshapeList(), and two of those four had already drifted: SQL Server's had lost the guard for a declaration naming no level, so an empty one printedA SQL Server container path is , received [...].assertContainerPathShapeinobject-kinds.tsis now the only producer, the wayassertObjectPathShapehas been for object paths since #1023.Closes #1065.
The fifteen were not one shape
Reading all of them showed policies hiding in the duplication, so the descriptor carries each one instead of collapsing them.
shapesshapeNameslevel.id, not the label. On their own declarations the two are the same word, so only a varied declaration shows it, and Trino has a test that varies one to prove it. Every other engine prints the label, which is the engine's word for a person reading a refusal.emptyShapesThe object-path renderer took no such fields because its nine copies agreed on all of these. These three do not.
PostgreSQL's readers look the
schemalevel up rather than reading by position, so a declaration that names none is refused bycontainerSchemaitself, next to the reads it protects. An earlier revision tried arequireLevelfield on the shared type; it is gone, because a rule only one engine's readers need does not belong in a type fourteen others set nothing on.Tests
tests/unit/db/container-path-renderer.test.tsis the mechanical half of the acceptance criterion the issue names, in the same spirit asobject-surface-conformance.test.tsfor the object family. It reads the provider tree rather than exercising a provider, because the claim is about where the sentence is built: a behavioural test can only show that one engine's message is right, and the defect was that fifteen engines each built their own.The detector strips both comment forms first and then matches the phrase inside any string literal, in any quote style. A backtick-only matcher missed a quoted throw; that is pinned by a mutation check now. The fifteen engine files are listed by name rather than behind a floor, because a floor cannot see the case it exists to notice: an engine that stops reaching the renderer takes the count down, and
>= 14still passes for fifteen minus one.Each descriptor field is pinned by a provider test, and a mutation reddens exactly its own engine:
shapeNamesfails only the Trino test that varies the declarationprefixestoexactfails 37 tests across Trino and SQL ServercontainerSchemafails only the new PostgreSQL testThe PostgreSQL test is new, because nothing covered a declaration whose depth matches but which names no schema level. A first draft of this change let a
prefixesengine accept the empty path for an empty declaration, which Trino's and DuckDB's tests caught immediately: every prefix of an empty list is a shape the engine never declared.object-route.tscites line numbers in two of the shifted files and a test pins every citation, so those five are updated to the lines their anchors now sit on. Worth knowing for anyone moving code in these files: running the formatter after fixing them moved the lines a second time, and the citations had to be re-measured.Also removed
Four
containerShapes()helpers, Couchbase'sshapeList(), the dead empty arms on the Trino and DuckDBshapeList()s (their only caller builds the shapes from a declaration, so the empty case is unreachable there and the shared renderer owns it), two provider-localdeclaredLevels()copies, and the imports they orphaned. Eight files were importingobject-kindstwice; the descriptors that sat between the imports moved below them, so Cassandra, ClickHouse, Druid and Trino now build theirs from their ownPROVIDER/TYPE_ID.Verification
format(idempotent),lint(0 errors),typecheck,knip,chart:check,readme:check,security:checkall pass. Fullbun run testunder the pinned Bun 1.4.2: 648 of 649 files pass, and the one red file,tests/unit/launcher-utils.test.ts, is not in this diff. It passes standalone both before and after this branch, so it is a local-machine flake around the ambientnodeits floor check probes. All fifteen provider integration suites re-run green here.