Skip to content

refactor(front): validate consolidations — projection-subclause driver, operand spelling, static_arithmetic split (LABS-1345, LABS-810, LABS-759) - #280

Merged
jexp merged 1 commit into
mainfrom
b-front-1
Nov 13, 2026
Merged

jexp merged 1 commit into
mainfrom
b-front-1

Conversation

@jexp

@jexp jexp commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactor (no behavior change) of relate-front validators, from three review-tasks tickets.

  • check_projection_subclauses: one driver for a projection's ORDER BY and WITH WHERE (classifies once, resolves the restatable set once) replaces the two entry points.
  • StaticOperand::Value becomes Literal; BoundOperand::Value becomes Bound, so fold form and bound form read distinctly at each match site.
  • static_types.rs (964 lines) sheds the quantifier-arithmetic walker into static_arithmetic.rs; validate_static_operator_types narrows to pub(crate) (no consumer outside relate-front).
Ticket Item Disposition Note
LABS-1345 Rename operand arms fixed Literal / Bound
LABS-810 One check_projection_subclauses driver fixed other mediums were already landed (shared Restatable)
LABS-759 static_types split; pub scope of the validator fixed is_cypher5 premise gone; remaining items (executor test dedup, PointValue::is_3d, quantifier doc) are outside relate-front, left open
LABS-728 call-scope / IN TRANSACTIONS extraction done in planner already ON ERROR RETRY needs an ADR; ticket stays open
LABS-589 star-position split done walk-arm tagging remains (call_scope.rs), ticket stays open
LABS-523 front validators done clients-loadtests half remains, ticket stays open

Verification

cargo fmt --all --check, cargo clippy --workspace --all-targets --exclude relate-python -- -D warnings, cargo test -p relate-front -p relate-planner all clean; full local stellar round: two nits (pre-existing BoundOperand mirror enum, one wrapper fn), no findings above nit.

🤖 Generated with Claude Code

…river, Literal operand spelling, static_arithmetic split (LABS-1345, LABS-810, LABS-759)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

/// The arithmetic operators that raise a type error for *every* non-numeric,
/// non-null operand. `+` is deliberately excluded from the
/// [`ARITHMETIC_OPS`] set here: it is also string concatenation (`'a' + 1` →

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Low] Idiomatic Rust: the moved doc comment links to ARITHMETIC_OPS, which stayed private in static_types; the mirror case is static_types.rs:236, whose doc now links to is_failing_arithmetic_op after that item moved here.

Why this matters: both links resolved before the split, and rustdoc now reports unresolved link warnings for them (no CI job builds docs, so they land silently).
Suggested fix: reword to a plain reference (e.g. "the arithmetic-operator set in static_types"), or pub(super) the const and import it at the new home.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Rust review (rust-reviewer skill, full review)

Full review of the relate-front validate-module consolidation: the merged post-projection subclause driver (ORDER BY + WITH WHERE, projection classified once and the restatable set resolved once), the static_arithmetic module extraction, the StaticOperand/BoundOperand variant renames, and the pub → pub(crate) narrowing of validate_static_operator_types.

The merged driver is behaviour-preserving: Plain mode still returns early for both subclauses, the empty-ORDER-BY/no-WHERE fast path is equivalent, and ORDER BY errors still precede WHERE errors. The moved helpers are verbatim, borrow only (&Expr, &ProjectionParts), and their narrowed pub(super) visibility has no out-of-module breakage; validate_static_operator_types has no users outside relate-front. No ownership, lifetime, error-handling, unsafe, or idiom issues found.

No issues found.

Rust review: ✅ no issues found

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Security review (security-review skill)

Analysed the relate-front validator refactor: the fused check_projection_subclauses driver, the StaticOperand/BoundOperand arm renames, and the static_arithmetic extraction. The fusion is equivalent to the two prior entry points across every Plain/Distinct/Aggregating and empty/non-empty ORDER BY / WHERE combination (same checks, same error precedence), and the moved predicates are unchanged. No auth, secrets, network, filesystem, dependency, or CI surfaces are touched.

No issues found.

Security review: ✅ no issues found

@jexp
jexp marked this pull request as ready for review November 13, 2026 01:24
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Stellar review (stellar-review skill)

Round 1 · head bac49646 · scope: 20/208 units (188 sealed from earlier rounds).

New findings

  • [Medium] structure (std-6) F-1-1: relate/relate-front/src/validate/static_arithmetic.rs:43-47 — The new module borrows its literal-type vocabulary from static_types (its use super::static_types::{is_arithmetic_op, non_numeric_leaf_class, static_literal_type, unparen, StaticLitType} at lines Fix: Make the family one directional: move the shared literal-type vocabulary (StaticLitType, static_literal_type, unparen, non_numeric_leaf_class, is_arithmetic_op) into a base static_literals module that static_types, static_arithmetic, static_calls, static_reduce and dynamic impo
  • [Medium] boundaries (std-5) F-1-2: relate/relate-front/src/validate/static_arithmetic.rs:128-133 — This is a silent fallback over an invariant-bound Result: walk_expr_scoped's only error is the nesting-depth cap (every visitor method here returns Ok), and the battery that reaches this helper alre Fix: Mirror the sibling walks: let result = walk_expr_scoped(expr, &mut search); debug_assert!(result.is_ok(), "applies_arithmetic_to_var runs after the depth guard"); search.found (or propagate the typed error if the precondition cannot be guaranteed). Drop the 'over-deep defers to runtime' comment, w
Low findings — collapsed, no inline threads (ADR-0354); superseded by the next round's list
  • [Low] branching (std-3) F-1-3: relate/relate-front/src/validate/aggregation/order_by/projection.rs:45-50 — The merge kept the union of the two old per-function gates: once the Plain disjunct returns, the emptiness disjunct only saves work the loop and the if let below already no-op on, so the clause's Fix: Keep the single policy gate (if matches!(mode, ProjectionMode::Plain) { return Ok(()); }) and let an empty order_by slice / None where-expr fall through as the natural no-op; the only thing the second disjunct buys is one small set allocation on a per-statement validation path.
  • [Low] boundaries (std-5) F-1-4: relate/relate-front/src/validate/static_arithmetic.rs:25-27 — This operator predicate is consumed only by predicate_applies_arithmetic_to_var in the same file, yet it is pub(super), widening the arithmetic-policy surface to the whole validate module with n Fix: Make it a private fn until a second module needs the quantifier-excluded operator policy.
  • [Low] comparison (std-6) F-1-5: relate/relate-front/src/validate/static_arithmetic.rs:19-24 — This doc moved verbatim out of static_types.rs, where ARITHMETIC_OPS lives; in the new module the set is neither defined nor imported, so "set here" is now false and the intra-doc link cannot reso Fix: Keep the rationale on the owner: leave the "set minus +" explanation on ARITHMETIC_OPS in static_types.rs and make this doc name is_arithmetic_op/the owner without claiming locality - or move ARITHMETIC_OPS and is_arithmetic_op into static_arithmetic.rs so the vocabulary and its exclus
  • [Low] comparison (flag-visibility-leak) F-1-6: relate/relate-front/src/validate/static_arithmetic.rs:25-25 — Five of the six new pub items are exactly as visible as their callers require (check_projection_subclauses → pub(in crate::validate::aggregation); expr_is_bare_var, applies_arithmetic_to_var, Fix: Drop the pub(super) and keep it a private fn; re-widen only when a call site outside static_arithmetic actually passes it to applies_arithmetic_to_var.

Stellar review: ⚠️ 6 issue(s) open (2 + 4 anchored new (fail/low) + 0 carried)

@oplane-bot

oplane-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

Oplane Security Review

Oplane reviewed this PR and did not identify any security requirements that need attention. Review the generated threat model.


Change comment settings · Set up Oplane in your agent · Workflow guidance

@github-actions

Copy link
Copy Markdown

Spec-harness coverage — 🟡

  • 🟡 spec coverage 99.43% — 193 genuine failures (0.57% of the executed scenarios)
  • scenarios run: 33642 (passed 33449, failed 193)
  • bands: 🟢 zero failures · 🟡 failure share ≤ 10% · 🔴 beyond (ADR-0482 §4 — the light never fails the build)
  • suite runtime: 52s
  • neo4j_expected_fail (not counted): 411
  • nondeterministic (not counted): 3
  • skipped (not counted): 2323
  • harness ref: 1022d60ed6c582f0cf72a75e14e571026feb888e
failure category count
syntax-error 48
result-mismatch 32
error-class-mismatch 31
missing-validation 27
notification-missing 19
semantic-error 10
type-error 10
other 9
setup-failed-syntax 5
result-temporal-fidelity 2

Rerun spec-harness to refresh. Coverage below 100% never fails the build (ADR-0482 §4).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stellar review round 1: 2 inline finding(s); see summary comment.

!items.is_empty()
&& items
.iter()
.all(|e| static_literal_type(e).is_some_and(non_numeric_leaf_class))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Medium] structure (std-6): The new module borrows its literal-type vocabulary from static_types (its use super::static_types::{is_arithmetic_op, non_numeric_leaf_class, static_literal_type, unparen, StaticLitType} at lines

Suggested fix: Make the family one directional: move the shared literal-type vocabulary (StaticLitType, static_literal_type, unparen, non_numeric_leaf_class, is_arithmetic_op) into a base static_literals module that static_types, static_arithmetic, static_calls, static_reduce and dynamic impo

finding F-1-1

// exactly as the self-capping walker this replaces did.
Err(_) => false,
Ok(()) => search.found,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Medium] boundaries (std-5): This is a silent fallback over an invariant-bound Result: walk_expr_scoped's only error is the nesting-depth cap (every visitor method here returns Ok), and the battery that reaches this helper alre

Suggested fix: Mirror the sibling walks: let result = walk_expr_scoped(expr, &mut search); debug_assert!(result.is_ok(), "applies_arithmetic_to_var runs after the depth guard"); search.found (or propagate the typed error if the precondition cannot be guaranteed). Drop the 'over-deep defers to runtime' comment, w

finding F-1-2

@github-actions

Copy link
Copy Markdown

Loadtest baselines comparison

Warning: loadtest comparison reported problems — see the flagged pairs below.


Loadtest baseline comparison

Frozen baselines vs current reports; bands match the compare-loadtests gate.

Status: warning

Pairs: fraud-loadtest: compared (failing rows) · identity-loadtest: compared (failing rows)

fraud-loadtest

baselines/fraud-loadtest.json → target/fraud-loadtest.json

Metric Baseline PR Δ Status
environment relate-loadtest-baseline/v1 relate-loadtest-baseline/v1 — match
errors 0 1 +1 fail (1 errors)
ops/s 3938.56 3866.98 -71.58 (-1.8%) ok
p99 (worst: reverse_last_out) 8.04 ms 7.95 ms -0.10 ms (-1.2%) ok
logical bytes 17,344,481 16,321,470 -1,023,011 (-5.9%) ok
Per-use-case p99 latency
Use case ops Baseline p99 PR p99 Δ Status
p2p_transfer 3,862 8.04 ms 7.73 ms -0.31 ms (-3.9%) ok
payroll_scatter 1,097 17.85 ms 15.96 ms -1.89 ms (-10.6%) ok
onboard_customer 770 8.53 ms 7.44 ms -1.10 ms (-12.9%) ok
mule_scatter 829 14.80 ms 13.03 ms -1.77 ms (-12.0%) ok
layering_cycle 810 15.10 ms 11.85 ms -3.25 ms (-21.5%) ok
recent_transfers 2,257 7.65 ms 6.79 ms -0.86 ms (-11.2%) ok
customer_portfolio 1,428 7.37 ms 6.43 ms -0.94 ms (-12.8%) ok
outgoing_volume 1,128 7.48 ms 6.54 ms -0.94 ms (-12.5%) ok
detect_fanout 882 25.78 ms 15.61 ms -10.17 ms (-39.5%) ok
detect_cycle 854 7.55 ms 6.69 ms -0.86 ms (-11.4%) ok
activity_page 1,070 7.48 ms 6.93 ms -0.55 ms (-7.4%) ok
search_customer 862 7.84 ms 7.37 ms -0.47 ms (-6.0%) ok
counterparties 1,137 7.45 ms 7.12 ms -0.33 ms (-4.4%) ok
payment_path 837 7.47 ms 7.05 ms -0.42 ms (-5.6%) ok
amount_band 848 7.30 ms 6.83 ms -0.47 ms (-6.4%) ok
flag_account 682 8.21 ms 7.38 ms -0.83 ms (-10.1%) ok
reverse_last_out 647 8.04 ms 7.95 ms -0.10 ms (-1.2%) ok

identity-loadtest

baselines/identity-loadtest.json → target/identity-loadtest.json

Metric Baseline PR Δ Status
environment relate-loadtest-baseline/v1 relate-loadtest-baseline/v1 — match
errors 0 2 +2 fail (2 errors)
ops/s 573.51 702.67 +129.16 (+22.5%) ok
p99 (worst: group_roster) 7.72 ms 7.79 ms +0.08 ms (+1.0%) ok
logical bytes 7,167,614 7,396,069 +228,455 (+3.2%) ok
Per-use-case p99 latency
Use case ops Baseline p99 PR p99 Δ Status
provision_user 1,373 11.00 ms 10.14 ms -0.86 ms (-7.8%) ok
add_to_group 1,775 18.57 ms 16.53 ms -2.03 ms (-10.9%) ok
grant_role 1,079 18.52 ms 14.82 ms -3.70 ms (-20.0%) ok
attach_device 907 18.88 ms 16.65 ms -2.23 ms (-11.8%) ok
nested_grant 736 19.41 ms 16.58 ms -2.83 ms (-14.6%) ok
effective_access 2,173 25.25 ms 19.42 ms -5.83 ms (-23.1%) ok
org_walk 1,387 19.94 ms 16.60 ms -3.34 ms (-16.8%) ok
optional_manager 1,312 20.00 ms 16.57 ms -3.43 ms (-17.2%) ok
detect_nested_admin 810 19.97 ms 16.99 ms -2.98 ms (-14.9%) ok
detect_sod 817 19.60 ms 16.55 ms -3.05 ms (-15.6%) ok
stale_grants 827 15.06 ms 12.69 ms -2.37 ms (-15.8%) ok
search_directory 1,147 10.91 ms 10.47 ms -0.44 ms (-4.1%) ok
group_roster 1,047 7.72 ms 7.79 ms +0.08 ms (+1.0%) ok
access_review 801 20.02 ms 15.99 ms -4.03 ms (-20.1%) ok
reporting_path 794 30.98 ms 22.06 ms -8.92 ms (-28.8%) ok
disable_user 644 19.50 ms 14.53 ms -4.97 ms (-25.5%) ok
add_alias 710 19.99 ms 16.71 ms -3.28 ms (-16.4%) ok
revoke_membership 674 8.10 ms 7.73 ms -0.37 ms (-4.6%) ok
detach_device 538 14.79 ms 11.14 ms -3.66 ms (-24.7%) ok
clear_expiry 449 17.39 ms 11.41 ms -5.98 ms (-34.4%) ok

@github-actions

Copy link
Copy Markdown

Memory shape

Note: loadtest comparison completed with no failing rows.


Memory shape

Status: ok

All memory shapes held. 🟢

base

Given: an empty relate serve, 1 integer properties on every node, text indexes 0, point indexes 0, range indexes 0, and a 32.00 MB logical ceiling.

When: the base shape is loaded to 0 nodes and 0 relationships, then checkpointed. The child RSS is sampled.

Then: the database holds those counts. The load finishes under the ceiling. Logical bytes, disk, attributed RSS, and the ratio stay inside the frozen boundaries.

Baseline: logical 0.00 MB – 0.00 MB, disk 0.00 MB – 0.00 MB, attributed RSS 0.00 MB – 0.00 MB, ratio 0.000x–0.000x. A reading may sit 5% outside the ratio, and 15% or 1.00 MB outside the sizes.

Validated: logical 0.00 MB, disk 0.00 MB, attributed RSS 0.00 MB, ratio 0.000x.

Report: logical, disk, attributed RSS, and the ratio held.

flat

Given: an empty relate serve, 1 integer properties on every node, text indexes 0, point indexes 0, range indexes 0, and a 32.00 MB logical ceiling.

When: the flat shape is loaded to 120000 nodes and 0 relationships, then checkpointed. The child RSS is sampled.

Then: the database holds those counts. The load finishes under the ceiling. Logical bytes, disk, attributed RSS, and the ratio stay inside the frozen boundaries.

Baseline: logical 26.02 MB – 26.02 MB, disk 1.95 MB – 1.95 MB, attributed RSS 36.49 MB – 36.93 MB, ratio 1.402x–1.419x. A reading may sit 5% outside the ratio, and 15% or 1.00 MB outside the sizes.

Validated: logical 26.02 MB, disk 1.26 MB, attributed RSS 37.05 MB, ratio 1.424x.

Report: logical, disk, attributed RSS, and the ratio held.

fanout

Given: an empty relate serve, 1 integer properties on every node, text indexes 0, point indexes 0, range indexes 0, and a 32.00 MB logical ceiling.

When: the fanout shape is loaded to 52016 nodes and 52000 relationships, then checkpointed. The child RSS is sampled.

Then: the database holds those counts. The load finishes under the ceiling. Logical bytes, disk, attributed RSS, and the ratio stay inside the frozen boundaries.

Baseline: logical 28.62 MB – 28.62 MB, disk 1.75 MB – 1.75 MB, attributed RSS 34.93 MB – 36.61 MB, ratio 1.220x–1.279x. A reading may sit 5% outside the ratio, and 15% or 1.00 MB outside the sizes.

Validated: logical 27.43 MB, disk 1.10 MB, attributed RSS 35.97 MB, ratio 1.311x.

Report: logical, disk, attributed RSS, and the ratio held.

ring

Given: an empty relate serve, 1 integer properties on every node, text indexes 0, point indexes 0, range indexes 0, and a 32.00 MB logical ceiling.

When: the ring shape is loaded to 46000 nodes and 46000 relationships, then checkpointed. The child RSS is sampled.

Then: the database holds those counts. The load finishes under the ceiling. Logical bytes, disk, attributed RSS, and the ratio stay inside the frozen boundaries.

Baseline: logical 29.99 MB – 29.99 MB, disk 1.77 MB – 1.77 MB, attributed RSS 35.30 MB – 35.89 MB, ratio 1.177x–1.197x. A reading may sit 5% outside the ratio, and 15% or 1.00 MB outside the sizes.

Validated: logical 29.99 MB, disk 1.20 MB, attributed RSS 35.64 MB, ratio 1.188x.

Report: logical, disk, attributed RSS, and the ratio held.

dense ring

Given: an empty relate serve, 1 integer properties on every node, text indexes 0, point indexes 0, range indexes 0, and a 32.00 MB logical ceiling.

When: the dense ring shape is loaded to 5000 nodes and 100000 relationships, then checkpointed. The child RSS is sampled.

Then: the database holds those counts. The load finishes under the ceiling. Logical bytes, disk, attributed RSS, and the ratio stay inside the frozen boundaries.

Baseline: logical 31.41 MB – 31.41 MB, disk 1.62 MB – 1.62 MB, attributed RSS 31.27 MB – 32.46 MB, ratio 0.996x–1.034x. A reading may sit 5% outside the ratio, and 15% or 1.00 MB outside the sizes.

Validated: logical 31.11 MB, disk 0.73 MB, attributed RSS 31.73 MB, ratio 1.020x.

Report: logical, disk, attributed RSS, and the ratio held.

@github-actions

Copy link
Copy Markdown

Memory controls and workspace memory calibration

Warning: the comparison document target/memory-controls.md is missing — the render step produced nothing this run.


(comparison document unavailable)

@jexp
jexp merged commit 25d9301 into main Nov 13, 2026
88 of 91 checks passed
@jexp
jexp deleted the b-front-1 branch November 13, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant