Skip to content

feat(schema-compiler): scaffolding emits drill_members so generated models can drill - #11472

Closed
igorlukanin wants to merge 7 commits into
masterfrom
igor/core-725-scaffolding-drill-members
Closed

igorlukanin wants to merge 7 commits into
masterfrom
igor/core-725-scaffolding-drill-members

Conversation

@igorlukanin

@igorlukanin igorlukanin commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Scaffolding declared drillMembers on TableSchema and never assigned it — the only reference to that field in the whole package. So data models generated from a warehouse schema came out with no drill members, and every measure in them was a dead end: clicking a chart point or a table cell couldn't open the underlying rows.

This makes the scaffolding formatters emit drill_members on each measure, including the generated count.

measures:
  - name: count
    type: count
    drill_members: [id, order_status, shipping_note, carrier_ref, is_expedited, created_at, shipped_at]
measures: {
  count: {
    type: `count`,
    drillMembers: [id, orderStatus, shippingNote, carrierRef, isExpedited, createdAt, shippedAt]
  }
}

The drill set is every scalar dimension the cube defines

Ordered primary key first, then the rest, then the time dimensions. Nothing is capped, and nothing is filtered by name — only non-scalar columns are left out, by their warehouse type.

An earlier revision of this branch chose a few "describing" attributes by matching member names against a ten-word dictionary (name, status, category, …). That was rejected in review, and rightly: which columns are meaningful to drill into isn't recoverable from a warehouse schema, and a column name is not evidence of meaning. Once name-based inference is off the table, no signal remains that separates a describing column from any other — cardinality and nullability are the same guess wearing a structural costume, and neither is available at generation time without extra warehouse queries.

So the set isn't narrowed by meaning. The asymmetry settles it: a member you don't want is one you delete from generated output you were going to review anyway, whereas one that was never emitted is one you have to know to add.

Ordering is the only editorial judgement left, and a cheap one to get wrong — key first because it identifies the row, time last because it reads as "when".

Non-scalar columns are excluded by their raw warehouse type. columnType() returns string for anything it doesn't recognise as numeric, boolean or time, so JSON documents, arrays, maps and structs, binary data and geometries all become string dimensions. They stay dimensions of the cube, but they don't read as a value in a drill-down table, so they are left out of drill_members. isNonScalarColumnType decides from the type name the driver reports (jsonb, VARIANT, text[], ARRAY<STRING>, Map(String, UInt8), row(x varchar), bytea, geography, point, …) and never from the column name. Quoted literals are stripped first, so an enum such as Enum8('record' = 1) stays scalar. The primary key is always kept, whatever its type (a binary(16) UUID key still identifies the row).

The raw type is read from the table definition in the formatter rather than carried on the member, because cube descriptors round-trip through the caller without it. Numeric columns still never reach the drill set, as ScaffoldingSchema.dimensionColumns routes them to measures.

Known limit: Postgres reports both PostGIS types and enums as USER-DEFINED, so that type is treated as scalar and PostGIS columns stay in the drill set.

All time dimensions are kept. Picking a single "main" timestamp would mean delegating the choice to ScaffoldingSchema.timeColumnIndex, which ranks time columns by whether their names contain create or update — reintroducing the rejected mechanism, and dropping every other timestamp on the strength of a two-word list. That sort still runs, so created_at renders before deleted_at, but it now affects display order only, never membership.

The list is deduped by rendered member name, last-wins. Dimensions render into an object built with a spread-reduce, so on a collision the cube keeps the later definition. Deduping first-wins would classify the drill member (isPrimaryKey / isTime) off the definition the cube discarded — a user_name varchar followed by a USER NAME timestamp would be filed as an attribute while the cube defines it as time.

Why the formatter and not ScaffoldingSchema

The declared field is left unused and the set is derived where the model is rendered, for two reasons:

  1. The final member list isn't known until then. generateFilesByCubeDescriptors spreads the caller's members over the generated descriptor, so the dimensions actually emitted can be a subset chosen elsewhere — the onboarding screen where members get deselected. A set computed upstream could name a dimension the cube no longer defines: the same click-time dead end, from the other direction.
  2. Drill members must name the rendered member, not the column. memberName() derives the emitted name from the title and re-cases it, so ORDER_STATUS renders as orderStatus / order_status. Only the formatter knows that name.

Deriving there also gives the synthetic count its drill set — it exists only as the formatter's reduce seed and never appears in tableSchema.measures, yet it's the measure most likely to be drilled.

Note the descriptor path has no type filter at all, since dimensionColumns never runs on caller-supplied members: a numeric dimension the caller sends does become a drill member. Deliberate and tested — the caller called it a dimension.

The emitted form is a bare list, not a function

Worth recording because the validator misleads: CubeValidator.ts has drillMembers: Joi.func(), which reads as though the generator should emit a function wrapper. It shouldn't — the authored form is a bare bracket list of identifiers in JS and a plain list in YAML, and CubePropContextTranspiler wraps it into the function the validator sees.

Tests

Scaffolding unit tests green (99 tests), lint clean.

The decisive test generates a model, compiles it with the real compiler, and asserts every drill member resolves to a dimension of the generated cube. Text assertions alone would happily pass on output that dead-ends at click time.

Every assertion was re-verified against deliberately wrong implementations: reinstating a lexical filter (13 tests red), first-wins dedupe (1), capping to one timestamp (5), time-before-attributes (9), dropping the primary-key guard on the time filter (1), removing the non-scalar filter (2), dropping the primary-key exemption from it (1), and not stripping quoted enum labels (3).

The snapshot churn is itself the evidence for the change — fixtures that previously emitted drill_members: [id] now emit [id, username, password], and [id, test] becomes [id, test, customerkey]. Those columns were always dimensions of the generated cube; the dictionary was silently dropping them.

Backward compatibility

Additive to generated output only. Scaffolding runs at generation time, so nothing already in a user's repo changes — the new key appears in newly generated cube files, which is the point.

One incidental fix: YamlSchemaFormatter's inline-array branch dropped its trailing newline, which had been doubling the blank line after any array-valued key. The same expression also passed array indices into render as its level/parent arguments; now bound properly.

@igorlukanin
igorlukanin requested a review from a team as a code owner August 4, 2026 14:37
@github-actions github-actions Bot added the javascript Pull requests that update Javascript code label Aug 4, 2026
@claude

claude Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 4m 22s —— View job


Reviewed — no blockers. 1 medium, 3 low (all inline)

Full review
  • Gather context (diff, changed files)
  • Review BaseSchemaFormatter drill-member derivation
  • Review YamlSchemaFormatter change
  • Review test coverage
  • Post review

Summary

Solid, well-reasoned change. The rationale for deriving the set in the formatter rather than in ScaffoldingSchema holds up against the code: tableSchemasByCubeDescriptors really does replace dimensions wholesale (BaseSchemaFormatter.ts:354-358), and memberName() really is the only place the emitted name exists. Deriving from sortedDimensions — the exact array that gets rendered — is the right coupling.

The strongest thing here is the new test file: generating a model, running it through prepareCompiler, and asserting each drill member appears in cube.config.dimensions is what makes this verifiable rather than a text-shape assertion. It also transitively confirms the compiler accepts drill_members in all three emitted variants (YAML, JS snake_case, JS camelCase), which was the non-obvious risk.

Dedupe-before-cap is subtle and correct to have handled, and the Math.max(0, …) guard means the composite-key case can't produce a negative slice.

Findings

# Severity Where Issue
1 Medium BaseSchemaFormatter.ts:172 "Already sorted by ScaffoldingSchema" holds only on the table-name path; the cube-descriptor path passes dimensions through in caller order, so deleted_at can win the timestamp slot over created_at. Suggested fix inline.
2 Low BaseSchemaFormatter.ts:195 Dedupe keeps the first colliding dimension; the rendering it mirrors keeps the last, so classification can read the discarded definition.
3 Low BaseSchemaFormatter.ts:179 Composite key ≥6 parts loses the timestamp and keeps a truncated key. Judgment call, not a bug.
4 Low YamlSchemaFormatter.ts:60 The newline removal also hits the empty-joins case, so joins: [] and non-empty joins: now render with inconsistent spacing. Cosmetic.

Other areas checked, no findings

  • Security — no input reaches SQL or a shell; memberName() collapses everything outside [A-Za-z0-9] before emitting, so drill member names can't inject YAML/JS syntax. No auth surface.
  • Performance — one extra pass per table over an already-small dimension list; drillMembersProp is computed once per cube rather than per measure. Nothing to note.
  • Error handling — type ?? types?.[0] and Math.max(0, …) cover the descriptor-shaped inputs and the over-cap arithmetic; no path throws on an empty dimension list (the key is omitted, and that's tested).
  • Docs — internal scaffolding behaviour, no user-facing docs surface. The comments carry the reasoning well; ReferenceError: self is not defined - Issue with whatwg-fetch when using the core lib with Node.js #1 is the one place a comment overstates an invariant.

Not verified

I couldn't run the test suite — yarn jest needs approval in this environment, so the "692 tests green" claim rests on your run, not mine. The findings above come from reading the code and the regenerated snapshots (which are internally consistent with the diff, including the joins: [] blank-line removal).

· branch `igor/core-725-scaffolding-drill-members`

@claude

claude Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 2m 37s —— View job


Re-reviewed after a293d04 — no blockers. 1 new low; 3 prior threads still apply

Full review
  • Gather context (new commit a293d04, current diff)
  • Review the cap-removal change
  • Re-check prior findings against current code
  • Resolve stale threads / post review

What changed since the last review

a293d04 removes MAX_DRILL_MEMBERS and the two slice calls, so the set is now primary key + every dictionary attribute + the main time dimension, unbounded. Four tests were rewritten to match.

The reasoning in the new doc comment holds up: the dictionary is already the bound that matters (a table only has so many name/status/category-shaped columns), and truncation was the more user-hostile failure — a drill list that silently omits a member the user then has to add by hand. It also removes the awkward case the old code had, where a wide composite key ate the timestamp slot and left a truncated key that identified nothing. Net simplification, and the Math.max(0, …) arithmetic that existed to paper over that case is gone with it.

Checked that the existing snapshots are unaffected: the widest drill set in scaffolding-template.test.ts.snap is two members ([id, name], [id, test]), all well under the old cap, so no snapshot needed regenerating and none was — consistent.

Findings

# Severity Where Issue Status
new Low scaffolding-template.test.ts:589-594 The rewritten composite-key test now asserts [k6, k5, k4, k3, k2, k1, …], pinning an order the comment itself declines to vouch for. It comes from the inconsistent comparator sort((a) => a.isPrimaryKey ? -1 : 0) — implementation-defined, not a contract. Suggested an order-insensitive assertion inline. New inline comment
1 Medium BaseSchemaFormatter.ts:171-173 "Already sorted by ScaffoldingSchema" still only holds on the table-name path; the cube-descriptor path passes dimensions through in caller order, so deleted_at can take the timestamp slot. Untouched by this commit. Prior thread, still applies
2 Low BaseSchemaFormatter.ts:183-194 Dedupe keeps the first colliding dimension; the rendering it mirrors keeps the last, so classification can read the discarded definition. Untouched. Prior thread, still applies
3 Low YamlSchemaFormatter.ts:60 Dropping the trailing newline also hits empty joins: [], so it now spaces differently from non-empty joins:. Cosmetic. Untouched. Prior thread, still applies

Resolved my own now-moot thread about the composite-key cap trading away both the timestamp and key integrity — the cap it was about no longer exists.

Also worth a note, not a finding

With the cap gone, a genuinely wide table (many dictionary-matching columns, or a description column) can render a long inline drill_members: [...] line. Valid YAML/JS, and arguably the correct trade against silent truncation — flagging only so the line-length consequence is a known one rather than a surprise.

Areas checked, nothing new

  • Security — unchanged surface; memberName() still collapses everything outside [A-Za-z0-9] before emitting, so member names can't inject YAML/JS syntax.
  • Performance — removing the slices makes the pass marginally cheaper; drillMembersProp is still computed once per cube, not per measure.
  • Error handling — the empty-list path (key omitted entirely) is still covered and tested; nothing throws on a dimension list with no key and no timestamp.
  • Testing — scaffolding-drill-members.test.ts is unchanged and still the strongest assertion here: it compiles each of the three emitted variants with the real compiler and checks every drill member resolves to a dimension of cube.config, plus that the aggregate measure and count agree. That's what makes the cap removal safe to take on faith.
  • Docs — internal scaffolding behaviour, no user-facing surface.

Not verified

Couldn't run the suite — node_modules isn't installed in this checkout and yarn/jest need approval here, so the green-suite claim rests on your run. Findings come from reading the code, the rewritten tests, and the snapshots.

· branch `igor/core-725-scaffolding-drill-members`

@codecov

codecov Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.88%. Comparing base (b42a9c2) to head (8d79c19).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
.../src/scaffolding/formatters/YamlSchemaFormatter.ts 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11472      +/-   ##
==========================================
+ Coverage   63.63%   63.88%   +0.25%     
==========================================
  Files         248      248              
  Lines       20051    20081      +30     
  Branches     4099     4108       +9     
==========================================
+ Hits        12759    12829      +70     
+ Misses       6701     6662      -39     
+ Partials      591      590       -1     
Flag Coverage Δ
cube-backend 63.88% <94.44%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claude

claude Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 3m 17s —— View job


Re-reviewed after 45d4ae1 — no blockers, no new findings. 1 prior low still open; 3 of my threads resolved as addressed

Full review
  • Gather context (new commit 45d4ae1, current diff)
  • Review the dictionary-removal change in BaseSchemaFormatter
  • Re-check prior findings against current code
  • Resolve stale threads / post review

What changed since the last review

45d4ae1 deletes DRILL_ATTRIBUTE_DICTIONARY and isDrillAttribute(). The drill set is now every deduped dimension, partitioned into primary keys → everything else → time dimensions. This is the right answer to @igorlukanin's thread: the objection was that name matching guesses at meaning, and the fix removes the guess rather than tuning the word list. The doc comment's asymmetry argument holds — an unwanted member is a deletion from output the user is already reviewing, a missing one is something they have to know to add.

Two things the commit fixes that were open findings of mine, both now resolved:

  • dedupeByMemberName is last-wins, matching the spread-reduce that renders dimensions. The new test (classifies a collapsed member off the definition the cube keeps) is a good one: user_name varchar followed by USER NAME timestamp, asserting both that the cube emits type: time and that the drill list groups it with the timestamps rather than ahead of zebra. That's the assertion that distinguishes the two dedupe strategies — first-wins would put it before zebra.
  • The "main time dimension" selection is gone, so the cube-descriptor path can no longer hand the "when" slot to deleted_at. The keeps the caller's members and order on the descriptor path test pins that: deleted_at and created_at both survive, in caller order.
  • The composite-key test no longer pins k6…k1, so it doesn't depend on the inconsistent sort((a) => a.isPrimaryKey ? -1 : 0) comparator.

Correctness spot-checks

  • No duplicate members. attributes and timeDimensions both filter !d.isPrimaryKey, so a primary key that is also a time column lands in primaryKeys only. Covered by the snapshots descriptor test, which is the only path that can produce that shape (ScaffoldingSchema never marks a time column as a key).
  • Drill set == dimension set. Both sides go through this.memberName(m) over the same sortedDimensions, and both collapse collisions the same way now. The drills into every dimension the cube defines, and only those test asserts set equality against the parsed dimensions: block, which is stronger than the previous per-member assertions.
  • Ordering on the table-name path. ScaffoldingSchema.dimensionColumns returns dimensionColumns.concat(timeColumns), so the regrouping is nearly a no-op there; it earns its keep on the descriptor path, where caller order is arbitrary. Traced the classifies a collapsed member expectation by hand — [id, zebra, user_name, created_at] — and it follows from Map keeping the first insertion position with the last value. Correct.
  • No stale references. toSnakeCase is still used elsewhere in the file (lines 112, 280), so the import isn't orphaned by removing isDrillAttribute.

Open finding

# Severity Where Issue Status
4 Low YamlSchemaFormatter.ts:60 Dropping the trailing newline also hits the empty-joins case, so joins: [] and non-empty joins: now space differently. Cosmetic; still visible in the snapshot (lines 477, 514, 621, 658). Prior thread, still applies

Resolved my three now-moot threads (main-time-dimension ordering, first-wins dedupe, pinned composite-key order). Left @igorlukanin's thread alone — that's the reviewer's to close.

Consequences worth knowing about, not findings

Both follow directly from the decision the commit makes deliberately, and neither is fixable without reintroducing name-based guessing — flagging so they're known rather than discovered later:

  • Sensitive columns drill by default. The regenerated snapshot has drill_members: [id, username, password]. The column was already emitted as a dimension, so nothing is newly exposed in the model — but it does become part of the default drill-down result set, where before the dictionary happened to exclude it. Detecting it would mean reading the column name, which is exactly what this commit removes, so the honest answer is that it's the user's edit to make on generated output.
  • Unbounded inline arrays. With both the cap and the dictionary gone, a wide table renders every dimension on one drill_members: [...] line. Valid YAML and JS; just a long line.

Areas checked, nothing new

  • Security — unchanged surface; memberName() still collapses everything outside [A-Za-z0-9] to _ before emitting, so member names can't inject YAML/JS syntax. Member names that aren't valid bare JS identifiers would break the generated file, but the dimensions block already emits unquoted keys, so that constraint is pre-existing and not widened here.
  • Performance — one filter pass more than before over a small list; drillMembersProp still computed once per cube, not per measure.
  • Error handling — d.type ?? d.types?.[0] covers both descriptor shapes; a dimension with neither classifies as a non-time attribute rather than throwing. Empty dimension list still omits the key entirely, still tested.
  • Testing — the added tests are the strongest part: deliberately opaque column names (zzz_top, qux, blorb) so selection can't pass by recognising anything, and the jsonb/bytea/text[] case documenting that columnType calls everything non-numeric/boolean/time a string. scaffolding-drill-members.test.ts is unchanged and still compiles all three variants with the real compiler.
  • Docs — internal scaffolding behaviour, no user-facing surface.

Not verified

node_modules isn't installed in this checkout and yarn/jest need approval here, so I couldn't run the suite — the green-suite claim rests on your run. Findings come from reading the code, the tests, and the regenerated snapshots (which are internally consistent with the diff).

· branch `igor/core-725-scaffolding-drill-members`

@claude

claude Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 2m 15s —— View job


Re-reviewed after 8512125 — no blockers. 1 new low; all prior threads resolved

Full review
  • Gather context (new commit 8512125, current diff)
  • Review the YAML blank-line fix
  • Re-check prior findings against current code
  • Resolve stale threads / post review

What changed since the last review

8512125 restores the blank line after an empty joins block — the last open finding from my previous pass. The fix hoists Object.entries(value[key] || {}) into a local and appends '\n' when it's empty, so the empty case (joins: [], which renders through the inline-array branch and ends without a newline) now separates from the next key the same way the non-empty case does (which ends with the object branch's own newline at line 74).

Traced both shapes through render and confirmed against the snapshot:

  • empty → [] + '\n' + the .join('\n') at line 106 → one blank line (.snap lines 477, 514, 622, 660)
  • non-empty → array branch → object-with-parent branch, which already ends in \n, + the join → one blank line (.snap lines 553-558, 590-595)

Consistent, and the fix is placed at the caller rather than in the array branch, which is where the separator belongs — the array branch has no idea whether a key follows.

Also checked that the '\n' can't misfire on other keys: it only guards the isPlainObject branch, whose members are joins / dimensions / measures. measures is never empty (the count seed), an empty dimensions would get the same correct treatment, and the last key is always pre_aggregations (a ValueWithComments, different branch), so there's no trailing-newline case at the end of a file.

New finding

# Severity Where Issue
5 Low YamlSchemaFormatter.ts:60 Binding this in the inline-array branch also made a second latent case live: elements are rendered with no parent, so a scalar element takes the Array.isArray(parent) ? '' : ' ' branch at line 111 and comes back with a leading space — key: [ a, b]. Not visible today (drill members are all MemberReferences, which return early), but reachable from an array-valued schemaContext prop, which previously threw instead. Suggested passing the array as parent inline.

Test-precision note, not a finding

The new test's expect(content).toMatch(/\n\s+joins: \[\]\n\n\s+dimensions:/) uses \s+ for the indent, which also matches newlines — so it would still pass if the separator regressed to two blank lines, the exact failure mode the commit is about. /\n\s+joins: \[\]\n\n {4}dimensions:/ pins it. The snapshots catch it either way, so this is belt-and-braces.

Prior findings

All four are now resolved — the three from earlier passes were closed by 45d4ae1, and #4 (the empty-joins spacing) by this commit. No unresolved threads of mine remain on the branch; @igorlukanin's thread is theirs to close.

Areas checked, nothing new

  • Security — unchanged surface. The new code touches whitespace only; memberName() still collapses everything outside [A-Za-z0-9] before emitting, so member names can't inject YAML syntax.
  • Performance — Object.entries was already being computed on this path; hoisting it into a local means it's computed once instead of once, no change.
  • Error handling — value[key] || {} still guards the null case, now before the .map rather than inside it.
  • Testing — the drill-member coverage is unchanged from the last pass and still the strongest part: scaffolding-drill-members.test.ts compiles all three emitted variants with the real compiler and asserts every drill member resolves to a dimension of cube.config.
  • Docs — internal scaffolding behaviour, no user-facing surface.

Not verified

node_modules isn't installed in this checkout and yarn/jest need approval here, so I couldn't run the suite — the green-suite claim rests on your run. Findings come from reading the code and the snapshots, which are internally consistent with the diff.

· branch `igor/core-725-scaffolding-drill-members`

@claude

claude Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 1m 21s —— View job


Re-reviewed after a620480 — no blockers. 1 new low; all prior threads resolved

Full review
  • Gather context (new commit a620480, current diff)
  • Review the inline-array padding fix
  • Review the new test
  • Re-check prior findings
  • Post review

What changed since the last review

a620480 passes the array as parent in the inline-array branch (YamlSchemaFormatter.ts:62-64), which was my previous finding #5. Traced it: a scalar element now reaches line 115 with Array.isArray(parent) true, so it takes the '' branch instead of ' ', and key: [ a, b] becomes key: [a, b]. MemberReference elements still return early at line 45, so nothing about drill-member output changes — consistent with the commit touching no snapshots.

Checked the extra arguments can't misfire elsewhere in the branch: the every guard above it admits only non-objects and MemberReferences, so no nested object or ValueWithComments can reach the new level + 1 / parent, and level is unused on the scalar path anyway.

The new test is the right shape — it asserts tags: [alpha, beta] via toContain, which the pre-fix output (tags: [ alpha, beta]) fails on, and the comment is honest that the as any cast is the point since SchemaContext only declares dataSource. This is a genuinely awkward thing to test and the cast is better than widening the type to make a test reachable.

New finding

# Severity Where Issue
6 Low YamlSchemaFormatter.ts:64 This branch emits a YAML flow sequence, but escapedValue quotes only on /[{}"]/ — so an element containing , or ] is emitted unquoted and splits the sequence (['a, b', 'c'] → three items). Same reachability as the padding case just fixed, and the same regression shape: it used to throw before the this binding, now it produces wrong output. Inline, with a suggested direction.

Prior findings

All six earlier threads are resolved — the three from the first pass by 45d4ae1, the empty-joins spacing by 8512125, the pinned composite-key order by 45d4ae1, and the element padding by this commit. @igorlukanin's thread is theirs to close.

Areas checked, nothing new

  • Security — unchanged surface. memberName() still collapses everything outside [A-Za-z0-9] before emitting, so member names can't inject YAML syntax; finding ResultSet.normalizePivotConfig() fix #6 is about caller-supplied context values, not member names.
  • Performance — one extra argument per element; nothing measurable.
  • Error handling — the array branch has no throwing path left on scalars; ValueWithComments and nested objects are excluded by the every guard above.
  • Testing — drill-member coverage is unchanged from the last pass and still the strongest part: scaffolding-drill-members.test.ts compiles all three emitted variants with the real compiler and asserts every drill member resolves to a dimension of cube.config. The three YAML-formatter tests added across the last two commits (empty joins spacing, element padding, drill set == dimension set) each pin a distinct invariant of the shared inline-array branch, which is what makes changes there safe to make.
  • Docs — internal scaffolding behaviour, no user-facing surface.

Not verified

node_modules isn't installed in this checkout and yarn/jest need approval here, so I couldn't run the suite — the green-suite claim rests on your run. Findings come from reading the code, the new test, and the snapshots (unchanged by this commit, correctly).

· branch `igor/core-725-scaffolding-drill-members`

@claude

claude Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 1m 31s —— View job


Re-reviewed after 3d6ecad — no blockers. 1 new low; all prior threads resolved

Full review
  • Gather context (new commit 3d6ecad, current diff)
  • Review the flow-sequence quoting fix
  • Review the new test
  • Re-check prior threads
  • Post review

What changed since the last review

3d6ecad threads a flow flag from the inline-array branch (YamlSchemaFormatter.ts:65) down through render's value branch into escapedValue, which now quotes on /[{}",[\]]/ in flow context instead of /[{}"]/. This is my previous finding #6, and the flag approach is the better of the two directions I suggested — the block path keeps its exact prior behaviour, so the widened set can't affect anything outside the one branch that emits a flow sequence.

Traced the reachability of the new argument:

  • MemberReference returns at line 47 before flow is ever read, so every drill member and every joins reference is untouched — consistent with the commit changing no snapshots.
  • The every guard at 56-58 admits only non-objects and MemberReferences, so no ValueWithComments or nested object can reach the value branch with flow true. The block-sequence branch at line 70 still calls render with three arguments, so flow defaults false there. Both correct.
  • escapedValue's non-string early return is before the regex, so numbers and booleans are unaffected by the widening.

Checked the test drives the branch it claims: tags is an array, so isPlainObject is false at line 86 and it renders through line 88 → array branch → flow. The three cases are well chosen — a comma changes the item count (the worst failure), a bracket truncates, and the third pins that ordinary values stay unquoted, which is what stops the fix from over-quoting into snapshot churn.

New finding

# Severity Where Issue
7 Low YamlSchemaFormatter.ts:133 needsQuotes covers "ends an item" but not : (turns the element into a single-pair flow mapping, [a: b] → [{a: b}]) or # (starts a comment). Pre-existing in the block path too and strictly less bad than the comma case this fixes, so flagged as a note on the line that now owns the decision. Inline.

Prior threads

All seven earlier threads are resolved — nothing of mine is still open on the branch. Nothing to re-affirm.

Areas checked, nothing new

  • Security — unchanged surface. The widening only ever adds quoting, never removes it, so no previously-escaped value becomes bare. memberName() still collapses everything outside [A-Za-z0-9], so drill member names remain unable to carry YAML syntax; this whole branch is about caller-supplied context values.
  • Performance — one boolean argument and a regex chosen by a ternary per scalar element. Nothing measurable.
  • Error handling — no new throwing path; the non-string early return still short-circuits before either regex.
  • Testing — the YAML branch now has four tests pinning four distinct invariants (empty-joins separator, element padding, flow escaping, drill set == dimension set), which is what makes this shared branch safe to keep editing. scaffolding-drill-members.test.ts is unchanged and still the strongest assertion in the PR: it compiles all three emitted variants with the real compiler and checks every drill member resolves to a dimension of cube.config.
  • Docs — internal scaffolding behaviour, no user-facing surface.

Not verified

node_modules isn't installed in this checkout and yarn/jest need approval here, so I couldn't run the suite — the green-suite claim rests on your run. Findings come from reading the code, the new test, and the snapshots (unchanged by this commit, correctly).

· branch `igor/core-725-scaffolding-drill-members`

@claude

claude Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 1m 5s —— View job


Re-reviewed after 845ad08 — no blockers, no new findings. This push is a rebase, not a content change; 1 prior low still open

Full review

  • Gather context (new head 845ad08, current diff)
  • Determine what changed vs. the last reviewed head
  • Re-check the open finding against current code
  • Post review

What changed since the last review

Nothing in the code. This synchronize is a rebase: HEAD is now a descendant of the current origin/master tip, and the six commits carry the same subjects and the same trees as the ones reviewed after 3d6ecad (the old SHAs are no longer reachable in this checkout, which is what a force-push rebase looks like from here).

Verified the rebase is clean rather than silently reshaped:

  • git diff origin/master...HEAD on BaseSchemaFormatter.ts and YamlSchemaFormatter.ts is byte-identical to what I reviewed last pass — drillMembers() / dedupeByMemberName() unchanged, and escapedValue's flow flag with /[{}",[\]]/ unchanged.
  • Master contributed nothing to packages/cubejs-schema-compiler/src/scaffolding/ in the interval (its last touch there predates the branch), so there was no semantic conflict for the rebase to resolve incorrectly — no risk that a fix landed upstream and got dropped, or vice versa.
  • Diffstat still 692/-27 across the same 5 files.

So the substance of the last four passes stands as reviewed. Recapping only the load-bearing part: the drill set is every deduped dimension, keys → attributes → time, derived from sortedDimensions — the same array that renders — so drill set and dimension set can't diverge; and scaffolding-drill-members.test.ts compiles all three emitted variants with the real compiler and asserts each drill member resolves to a dimension of cube.config, which is what makes that equality checked rather than argued.

Open finding

# Severity Where Issue Status
7 Low YamlSchemaFormatter.ts:133 The flow escape set covers "ends an item" (, ]) but not : (turns the element into a single-pair flow mapping, [a: b] → [{a: b}]) or # (starts a comment). Pre-existing in the block path too, and strictly less bad than the comma case this branch fixes. Prior thread, still applies

No prior thread of mine has become stale as a result of this push — the six earlier ones were already resolved, and #7's line still exists at the same place with the same code, so there's nothing to resolve and nothing to re-post.

Areas checked, nothing new

  • Security — unchanged surface. memberName() still collapses everything outside [A-Za-z0-9] before emitting, so drill member names can't carry YAML or JS syntax; the flow-quoting question is about caller-supplied context values, not member names.
  • Performance — unchanged.
  • Error handling — unchanged: d.type ?? d.types?.[0] covers both descriptor shapes, an empty dimension list omits the key, escapedValue's non-string early return still short-circuits before either regex.
  • Testing — unchanged from the last pass; the YAML branch has four tests pinning four distinct invariants, plus the real-compiler drill-member test.
  • Docs — internal scaffolding behaviour, no user-facing surface.

Not verified

node_modules isn't installed in this checkout (confirmed: packages/cubejs-schema-compiler/node_modules absent) and yarn/jest need approval here, so I could not run the suite on the rebased head. The green-suite claim rests on your run. Since the trees are identical to the previously reviewed ones and master didn't touch this package, a rebase-induced test failure would have to come from elsewhere in master — worth letting CI confirm rather than taking from me.

· branch `igor/core-725-scaffolding-drill-members`

@igorlukanin
igorlukanin force-pushed the igor/core-725-scaffolding-drill-members branch from 845ad08 to aca6b3d Compare August 8, 2026 05:29
@claude

claude Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 1m 6s —— View job


Re-reviewed after aca6b3d — no blockers, no new findings. This push is a rebase; no threads open

Full review

  • Gather context (new head aca6b3d, current diff)
  • Determine what changed vs. the last reviewed head
  • Re-check prior threads against current code
  • Post review

What changed since the last review

Nothing in the code. This synchronize is another rebase — HEAD is a descendant of the current origin/master tip (843f56d, client-core timezone option), and the six commits carry the same subjects and the same trees as the ones reviewed after 845ad08.

Verified rather than assumed:

  • git diff origin/master...HEAD on both source files is byte-identical to the last reviewed state — drillMembers() / dedupeByMemberName() unchanged, and escapedValue's flow flag with /[{}",[\]]/ unchanged.
  • Diffstat still 692/-27 across the same 5 files; test side still 595/-19 across the same 3.
  • Master contributed nothing to packages/cubejs-schema-compiler/src/scaffolding/ in the interval — its tip is a client-core change. (git log -- <scaffolding> appears to show it only because this is a shallow checkout where the grafted root reports every file as added; git show --stat 843f56d confirms the 974 "insertions" there are the graft, not an edit.)

So the substance of the previous passes stands as reviewed. Recapping the load-bearing part only: the drill set is every deduped dimension, keys → attributes → time, derived from sortedDimensions — the same array that renders — so the drill set and the dimension set can't diverge; and scaffolding-drill-members.test.ts compiles all three emitted variants with the real compiler and asserts each drill member resolves to a dimension of cube.config, which is what makes that equality checked rather than argued.

Threads

All eight earlier threads are resolved, including #7 (: / # in flow context), which @igorlukanin scoped out and filed as CORE-747. That scoping is right: those two characters are equally unquoted in the block branches, so they're pre-existing rather than made live by this branch, and unlike the comma they don't change an item count. Nothing of mine is open, and nothing has become stale as a result of this push — no threads to resolve and none to re-post.

Areas checked, nothing new

  • Security — unchanged surface. memberName() still collapses everything outside [A-Za-z0-9] before emitting, so drill member names can't carry YAML or JS syntax; the remaining flow-quoting question is about caller-supplied context values, which SchemaContext doesn't admit today.
  • Performance — unchanged. drillMembersProp is still computed once per cube, not once per measure; sortedDimensions is hoisted rather than re-sorted.
  • Error handling — unchanged: d.type ?? d.types?.[0] covers both descriptor shapes, an empty dimension list omits the key entirely, and escapedValue's non-string early return still short-circuits before either regex.
  • Testing — unchanged from the last pass. The YAML branch has four tests pinning four distinct invariants (empty-joins separator, element padding, flow escaping, drill set == dimension set), plus the real-compiler drill-member test.
  • Docs — internal scaffolding behaviour, no user-facing docs surface.

Not verified

node_modules isn't installed in this checkout (confirmed absent at both the root and the package), and yarn/jest need approval here, so I could not run the suite on the rebased head. The green-suite claim rests on your run. Since the trees are identical to the previously reviewed ones and master didn't touch this package, a rebase-induced failure would have to originate elsewhere in master — worth letting CI confirm rather than taking from me.

· branch `igor/core-725-scaffolding-drill-members`

@claude

claude Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 57s —— View job


Re-reviewed after 48c1740 — no blockers, no new findings. This push is a rebase; no threads open

Full review

  • Gather context (new head 48c1740, current diff)
  • Determine what changed vs. the last reviewed head
  • Re-check prior threads against current code
  • Post review

What changed since the last review

Nothing in the code. This synchronize is another rebase — git merge-base origin/master HEAD is the current master tip (748d522, a dashboards docs change), so the six commits sit directly on top of it, carrying the same subjects and the same trees as the ones reviewed after aca6b3d (which is no longer reachable in this checkout — the shape of a force-push rebase).

Verified rather than assumed:

  • git diff origin/master...HEAD on both source files is byte-identical to the last reviewed state — drillMembers() / dedupeByMemberName() unchanged, YamlSchemaFormatter's flow flag and escapedValue's /[{}",[\]]/ unchanged, scaffolding-drill-members.test.ts unchanged.
  • Diffstat still 692/-27 across the same 5 files; test side still 595/-19 across the same 3.
  • Master contributed nothing to packages/cubejs-schema-compiler/src/scaffolding/ in the interval — its tip is a docs commit. (git log -- <scaffolding> lists it only because this is a shallow checkout where the grafted root reports every file as added.)

So the substance of the earlier passes stands as reviewed. Recapping the load-bearing part only: the drill set is every deduped dimension, keys → attributes → time, derived from sortedDimensions — the same array that renders — so the drill set and the dimension set can't diverge; and scaffolding-drill-members.test.ts compiles all three emitted variants with the real compiler and asserts each drill member resolves to a dimension of cube.config, which is what makes that equality checked rather than argued.

Threads

All ten threads on the PR are resolved, including #7 (: / # in flow context, scoped out as CORE-747) and the CodeQL backslash-escaping alert (pre-existing, identical escaper on master, fixed in #11495). Nothing of mine is open, nothing has become stale as a result of this push — no threads to resolve and none to re-post.

Areas checked, nothing new

  • Security — unchanged surface. memberName() still collapses everything outside [A-Za-z0-9] before emitting, so drill member names can't carry YAML or JS syntax; the remaining escaping questions are about caller-supplied context values, which SchemaContext doesn't admit today.
  • Performance — unchanged. drillMembersProp is computed once per cube, not once per measure; sortedDimensions is hoisted rather than re-sorted.
  • Error handling — unchanged: d.type ?? d.types?.[0] covers both descriptor shapes, an empty dimension list omits the key entirely, and escapedValue's non-string early return still short-circuits before either regex.
  • Testing — unchanged from the last pass. The YAML branch has four tests pinning four distinct invariants (empty-joins separator, element padding, flow escaping, drill set == dimension set), plus the real-compiler drill-member test.
  • Docs — internal scaffolding behaviour, no user-facing docs surface.

Not verified

node_modules isn't installed in this checkout (confirmed absent at the package), and yarn/jest need approval here, so I could not run the suite on the rebased head. The green-suite claim rests on your run. Since the trees are identical to the previously reviewed ones and master didn't touch this package, a rebase-induced failure would have to originate elsewhere in master — worth letting CI confirm rather than taking from me.

· branch `igor/core-725-scaffolding-drill-members`

@igorlukanin
igorlukanin force-pushed the igor/core-725-scaffolding-drill-members branch from 48c1740 to 8d79c19 Compare September 30, 2026 15:04
@claude

claude Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @igorlukanin's task in 2m 37s —— View job


No correctness bugs found. 1 medium issue (the PR description is out of date), 4 low (comments). Tests were not run: dependencies aren't installed and this job isn't allowed to run node.

Review details
  • Read the diff and the changed files in full
  • Checked the non-scalar type lookup on the descriptor path
  • Run tests: skipped. node_modules is missing and the job's permissions block node and jest.
  • Review threads
  • Post review

Medium

The PR description no longer matches the code. The body says jsonb, bytea, text[] and geometry columns "are dimensions and therefore drill members", and that a test pins this "rather than a special case excluding them". 8d79c19 does the opposite. It adds isNonScalarColumnType (src/scaffolding/utils.ts:52) and filters those types out in drillMembers. The test leaves non-scalar columns out of the drill set but keeps them as dimensions now asserts the reverse of what the body describes.

The body also argues that dropping a JSON column "is the same class of guess as reading its name". That argument needs a rewrite, not just a flip. The new filter reads the warehouse type, not the column name, so it falls outside the objection from the first review. The body should say why that difference matters. It will feed the squash commit body.

Checked, no issue

  • Descriptor path doesn't gain a new throw. drillMembers now calls resolveTableDefinition(resolveTableName(...)) (BaseSchemaFormatter.ts:149-152). tableSchemasByCubeDescriptors (:303-305) already resolves every descriptor's table the same way, so a missing table failed before this change too.
  • Last-wins dedupe and the type filter work together. Dedupe runs first, so if two columns render to the same member name and the surviving definition is jsonb, that name is dropped from the drill set. This matches the dimension the cube actually keeps.
  • Descriptor members that don't match a column. dbTypes.get(d.name) returns undefined, which counts as scalar, so the member is kept. That fails safe.
  • Type classifier gaps are recall-only. ClickHouse Nested(...), Dynamic, and Postgres hstore / tsvector aren't matched, so they stay drill members, which is the behaviour before this commit. I found no false positive in the scalar list; sql_variant and rowversion are handled correctly because \b doesn't split on _ or inside a word.

Low (inline)

  • BaseSchemaFormatter.ts:129-145: the drillMembers JSDoc is 16 lines of design argument. Cut it to the two sentences that protect the code.
  • BaseSchemaFormatter.ts:169-177: the dedupeByMemberName JSDoc repeats the inline "Deduped because…" comment. Keep only the last-wins sentence.
  • YamlSchemaFormatter.ts:60-63: 4-line comment, one over the limit.
  • scaffolding-drill-members.test.ts:70: "main time dimension last" is left over from the .slice(0, 1) version.

Review threads

The listing returned 0 of my own threads. I resolved none and re-affirmed none.

Comment on lines +129 to +145
/**
* The members that identify one source row: every dimension the cube defines, with the
* primary key first and the time dimensions last.
*
* Every dimension, except non-scalar ones. Which columns are meaningful to drill into
* is not recoverable from a warehouse schema — the generator would have to guess from
* column names, and a name is not evidence of meaning. So the set is narrowed only by
* the raw column type: a JSON document, an array, binary data or a geometry doesn't
* read as a value in a drill-down table. The primary key stays whatever its type,
* since it is what identifies the row. Ordering is the only other judgement, and it
* costs nothing to be wrong about — key first because it identifies the row, time last
* because it reads as "when".
*
* Derived from the dimensions actually being rendered rather than from the ones
* ScaffoldingSchema computed: the cube-descriptor path lets the caller drop members,
* and a drill member the cube doesn't define dead-ends at click time.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This JSDoc runs to 16 lines. Most of it argues the design ("not recoverable from a warehouse schema", "costs nothing to be wrong about"), and that argument belongs in the PR or commit message. Two sentences would stop a later edit from breaking something:

  /**
   * Every rendered dimension except non-scalar-typed ones (the primary key always stays), ordered key → rest → time.
   * Derived from the dimensions being rendered: the descriptor path can drop members, and a drill member the cube doesn't define dead-ends at click time.
   */

The ordering rule is already carried by primaryKeys / attributes / timeDimensions in the return statement.

Comment on lines +169 to +177
/**
* Dimensions are rendered into an object keyed by member name, so columns that
* collapse to the same name yield one dimension — the drill list must collapse too,
* or the drill-down repeats a column.
*
* Last-wins, matching the spread-reduce that renders `dimensions`: on a collision the
* cube keeps the later definition, so classifying off the earlier one would read
* `isPrimaryKey` / `isTime` from a definition the cube discarded.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first paragraph says the same thing as the // Deduped because… comment in drillMembers a few lines up. Only the last-wins sentence is needed here, because it is the one a later edit could break:

Suggested change
/**
* Dimensions are rendered into an object keyed by member name, so columns that
* collapse to the same name yield one dimension — the drill list must collapse too,
* or the drill-down repeats a column.
*
* Last-wins, matching the spread-reduce that renders `dimensions`: on a collision the
* cube keeps the later definition, so classifying off the earlier one would read
* `isPrimaryKey` / `isTime` from a definition the cube discarded.
*/
/** Last-wins, like the spread-reduce that renders `dimensions` — the cube keeps the later definition on a name collision. */

Comment on lines +60 to +63
// The caller separates keys itself — a newline here doubles the blank line.
// Pass the array as parent so scalar elements skip the leading-space branch
// that indents a value after its key, and `flow` so they quote on the
// characters that would otherwise end an item in a flow sequence.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is four lines, one over the limit. The flow argument is already explained at escapedValue, so this site only needs the two facts the call itself doesn't show:

Suggested change
// The caller separates keys itself — a newline here doubles the blank line.
// Pass the array as parent so scalar elements skip the leading-space branch
// that indents a value after its key, and `flow` so they quote on the
// characters that would otherwise end an item in a flow sequence.
// No trailing newline: the caller separates keys. `value` as parent skips the
// leading space a scalar gets after its key; `flow` quotes item-ending chars.

expect(dimensionNames).toContain(member);
});

// Primary key first, main time dimension last.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is left over from the .slice(0, 1) version. There is no "main" time dimension any more, since a9e27f1 keeps all of them. The fixture has a single timestamp, so the assertion passes, but the comment describes a rule that no longer exists.

Suggested change
// Primary key first, main time dimension last.
// Primary key first, time dimensions last.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants