Skip to content

fix(shard-engine): correct the RELATION_EXISTS_KEY reservation claim - #386

Merged
prisis merged 1 commit into
alphafrom
fix/where-types-comment
Aug 9, 2026
Merged

prisis merged 1 commit into
alphafrom
fix/where-types-comment

Conversation

@prisis

@prisis prisis commented Aug 9, 2026 •

Copy link
Copy Markdown
Member

Closes the small findings left after #375, and files the one worth its own plan.

The last false comment from that thread

packages/shard-engine/src/where-types.ts claimed:

The __-prefix keeps it disjoint from user field names (the codegen reserved-name guard blocks __-prefixed columns).

There is no such guard. Codegen's FIELD_NAME_RE is /^[A-Za-z_$][\w$]*$/u, which admits _ and therefore admits __relationExists itself, and WhereInput's index signature treats every unrecognised key as a field — so a table declaring that exact column would have a filter on it read as the EXISTS marker.

This was the ninth such comment found across the plan-265/313 work and the only one left standing, kept back at the time because RELATION_EXISTS_KEY is a where-tree key rather than a stored field, so the failure mode differs from the ones being fixed. The comment now states the real situation and says where a guard would belong (codegen's field-name validation, next to the other reserved names) rather than asserting one exists. No behaviour change.

was generating stale code

@lunora/payment added usageEvents.mode (v.optional(v.string())) and the example's _generated files were never regenerated — verified: no mode in either dataModel.ts or drizzle.shard.ts. Surfaced during the plan-265 work and deliberately kept out of that diff to keep it honest. Regenerated here: 3 insertions, exactly the missing column.

Examples are what people copy, so a shipped example that disagrees with its own schema is worth the one command.

Two plan updates

313 §4.4 amended. It read "Retention is explicit, not clever … No silent deletion of anything", and that is not what shipped — backupRetain still deletes inside the cron run. It is safe (it prunes only snapshots carrying its own cron expression and keeps anything ambiguous) but narrower rather than explicit. The decision now says so, points at §10 for the reasoning, and names WS4 as the work that would make it true. Better than leaving a plan that promises a verb the code does not provide.

314 filed. Every Lunora Worker ships compromise, an English NLP library, because @visulima/redact hard-depends on it and observability/src/request-log.ts imports redact for redactArgs — which database-telemetry.ts and context-telemetry.ts both call, so it is reachable from any app that logs. Wave 20 measured ~606 KiB raw, larger than any first-party package. It had been living as prose in a README notes section, which is exactly how the Wave-13 rows rotted.

The plan's STOP condition is that redaction must not get weaker — it is a security path, so characterisation tests come first and the gate is the byte count in bundle-meta.json, not the shape of the source.

Verification

@lunora/shard-engine 1040 tests, lint:types and lint:eslint --max-warnings=0 clean, Prettier clean across the touched files and plans/. The code change is comment-only; the example change is generated output.

🤖 Generated with Claude Code

https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP

Summary by CodeRabbit

  • Documentation
    • Clarified the naming convention and validation behavior for relation-existence fields.
    • Documented the possibility of naming collisions with user-defined columns.
    • Noted that collisions are not currently prevented.

The comment said the codegen reserved-name guard blocks __-prefixed
columns. It does not: FIELD_NAME_RE is /^[A-Za-z_$][\w$]*$/u, which
admits _ and so admits __relationExists itself, and WhereInput's index
signature treats every unrecognised key as a field. A table declaring
that column would have a filter on it read as the marker.

Also regenerates examples/payment-demo, which had been missing the
usageEvents.mode column @lunora/payment added, and records two plan
updates: 313's retention decision is amended to say what shipped, and
314 files the NLP library every Worker carries.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011sk9BLaUZDkPVAZ1sKhuDP
@netlify

netlify Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for lunorash ready!

Name Link
🔨 Latest commit a143655
🔍 Latest deploy log https://app.netlify.com/projects/lunorash/deploys/6a7834b3e8abd40008c26608
😎 Deploy Preview https://deploy-preview-386--lunorash.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for confirming the Contributor License Agreement! 🙏

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 57191d73-6453-4551-8f70-f53dcbd124e9

📥 Commits

Reviewing files that changed from the base of the PR and between da1b2b8 and a143655.

⛔ Files ignored due to path filters (5)
  • examples/payment-demo/lunora/_generated/dataModel.ts is excluded by !**/_generated/** and included by none
  • examples/payment-demo/lunora/_generated/drizzle.shard.ts is excluded by !**/_generated/** and included by none
  • plans/313-r2-backup-tier.md is excluded by none and included by none
  • plans/314-compromise-in-every-worker.md is excluded by none and included by none
  • plans/README.md is excluded by none and included by none
📒 Files selected for processing (1)
  • packages/shard-engine/src/where-types.ts

Walkthrough

The PR updates RELATION_EXISTS_KEY documentation. It clarifies that the __ prefix is a convention, documents possible field-name collisions, and assigns validation changes to codegen.

Changes

Relation exists field documentation

Layer / File(s) Summary
Document field validation and collision behavior
packages/shard-engine/src/where-types.ts
The documentation describes the actual field-name validation rule, the possible __relationExists collision, and the lack of validation enforcement in this module.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: correcting the inaccurate RELATION_EXISTS_KEY reservation claim.
Description check ✅ Passed The description provides detailed rationale, scope, linked issue context, and verification, but it omits the template headings, checklist, and CLA statement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/where-types-comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@prisis
prisis merged commit 1762097 into alpha Aug 9, 2026
44 checks passed
@prisis
prisis deleted the fix/where-types-comment branch August 9, 2026 08:20
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.09%. Comparing base (95d33d6) to head (a143655).
⚠️ Report is 55 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff            @@
##            alpha     #386    +/-   ##
========================================
  Coverage   87.09%   87.09%            
========================================
  Files        1172     1177     +5     
  Lines       63383    63567   +184     
  Branches    15447    15330   -117     
========================================
+ Hits        55202    55365   +163     
- Misses       7654     7680    +26     
+ Partials      527      522     -5     
Files with missing lines Coverage Δ
packages/shard-engine/src/where-types.ts 100.00% <ø> (ø)

... and 5 files with indirect coverage changes

🚀 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.

@codspeed

codspeed Bot commented Aug 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 253 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing fix/where-types-comment (a143655) with alpha (9f29744)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on alpha (55838a6) during the generation of this report, so 9f29744 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using our GitHub Discussions tab for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 8, 2026

This branch was previously deployed

1 inactive deployment
benchmarks — a143655a Deployed Aug 9, 2026 by prisis via Benchmarks #1600
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants