Skip to content

chore(claude): encode model-naming convention + AsSpan-on-hot-paths rule - #48

Merged
emeraldleaf merged 2 commits into
mainfrom
chore/encode-asspan-and-model-naming
Jun 3, 2026
Merged

chore(claude): encode model-naming convention + AsSpan-on-hot-paths rule#48
emeraldleaf merged 2 commits into
mainfrom
chore/encode-asspan-and-model-naming

Conversation

@emeraldleaf

@emeraldleaf emeraldleaf commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Encodes two rules (requested), both framed to fit NextAurora's actual context rather than as blanket assertions that would contradict existing rules.

1. Model naming (intent-based, by role)

Source tip: "prefer Request/Response over Dto." Encoded as the convention NextAurora already follows — which is more intent-based than the suggestion:

  • CQRS messages: *Command (writes) / *Query (reads) — more specific than a generic *Request (says write-vs-read + flows the Wolverine pipeline)
  • gRPC contracts: *Request / *Response pairs (gRPC idiom, already used in CatalogService)
  • Read projections: *Dto — acceptable only here (query-result shape, not HTTP-coupled, so not renamed to *Response)

Rule in one line: generic *Dto on a request model hides intent — name it by what it does; reserve *Dto for read projections. Deliberately does not mandate "Request/Response everywhere" — that would downgrade the write side from the more-specific Command/Query.

Encoded in CLAUDE.md "Coding Standards" + a .coderabbit.yaml **/*.cs naming line (flag a generic *Dto on a new command/query; don't recommend renaming existing read-projection DTOs).

2. AsSpan over Substring (profiled hot paths only)

Zero-allocation slicing — real win in synchronous, hot, string-heavy loops. Encoded with two guardrails so it's a narrow tool, not a default:

  • Governed by "Measure before optimizing" — apply where profiling shows allocation pressure, not reflexively.
  • Span<T> is a ref struct — can't cross an await boundary, so it's rarely usable in NextAurora's async-everywhere handlers (the compiler stops you).

No such hot path exists today (string work is incidental; the bottleneck is always I/O), so the rule is explicitly preventative. CLAUDE.md "Performance Rules" only — no .coderabbit.yaml/reviewer surface (it's a judgment-on-profiling call, not a code-shape check), same scoping as the streams rule.

Paraphrase-drift audit (per CLAUDE.md change)

Run /check-rules locally to audit paraphrases against this diff. Done — both rules are net-new; no existing See CLAUDE.md marker covers model-naming or AsSpan, so nothing to realign. The naming rule codifies the de-facto convention already visible in the type names; AsSpan has no existing usage to conflict with. No drift.

Note on the framing

I'd originally recommended against encoding both (the AsSpan tip is a micro-opt that doesn't fit an I/O-bound async app; the naming tip is superseded by NextAurora's CQRS naming). Per direction to add them, they're encoded as the NextAurora-accurate versions — capturing the real nuance (when AsSpan actually applies; why Command/Query beats generic Request) rather than blanket assertions that would conflict with "Measure before optimizing" and the CQRS naming already in use.

Test plan

  • Paraphrase-drift audit run — no drift
  • Both rules consistent with existing CLAUDE.md ("Measure before optimizing", CQRS conventions)
  • CodeRabbit applies the new MODEL NAMING line on next PR touching **/*.cs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added intent-based model naming guidance distinguishing command/query, gRPC request/response, and read-projection roles; cautions against using generic DTO names for requests.
    • Added performance guidance recommending measured use of zero-allocation string slicing (AsSpan vs Substring) with async/escaping guardrails.
  • Chores

    • Updated review/configuration guidance to enforce the new naming conventions.

Two rules requested for encoding. Both framed to fit NextAurora's actual
context rather than as blanket assertions that would contradict existing
rules.

1. MODEL NAMING (intent-based, by role) — CLAUDE.md "Coding Standards" +
   .coderabbit.yaml **/*.cs naming guidance.
   The source tip was "prefer Request/Response over Dto." Encoded as the
   convention NextAurora already follows, which is *more* intent-based:
   - CQRS messages: *Command (writes) / *Query (reads) — more specific
     than *Request (says write-vs-read + flows the Wolverine pipeline).
   - gRPC contracts: *Request / *Response pairs (gRPC idiom).
   - Read projections: *Dto — acceptable ONLY here (query-result shape;
     not HTTP-coupled, so don't rename to *Response).
   Rule in one line: generic *Dto on a REQUEST model hides intent — name
   it by what it does; reserve *Dto for read projections. Deliberately
   does NOT mandate "Request/Response everywhere" (that would downgrade
   the write side from the more-specific Command/Query).

2. AsSpan over Substring — CLAUDE.md "Performance Rules" (right after
   "Measure before optimizing", which governs it).
   Zero-allocation slicing, real win in synchronous hot string loops.
   Encoded with two guardrails so it's a narrow tool, not a default:
   (a) governed by measure-before-optimizing — apply on profiled hot
   paths, not reflexively; (b) Span<T> is a ref struct — can't cross an
   await boundary, so rarely usable in NextAurora's async-everywhere
   handlers. No such hot path exists today (string work is incidental;
   bottleneck is always I/O), so the rule is explicitly preventative.
   CLAUDE.md-only — no .coderabbit.yaml/reviewer surface (it's a
   judgment-on-profiling call, not a code-shape check), same as the
   streams rule.

Paraphrase-drift audit: run /check-rules locally to audit paraphrases
against this diff. Done — both rules are net-new; no existing
See-CLAUDE.md marker covers model-naming or AsSpan, so nothing to
realign. (The naming rule codifies the de-facto convention already
visible in the type names; AsSpan has no existing usage to conflict.)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Adds intent-based model naming guidance (CQRS, gRPC, read projections) to reviewer config and docs, and a performance guideline advising AsSpan over Substring for profiled synchronous hot paths.

Changes

Coding Standards and Performance Guidelines

Layer / File(s) Summary
Intent-based Model Naming Conventions
.coderabbit.yaml, CLAUDE.md
Defines intent-based naming patterns: *Command/*Query for CQRS, *Request/*Response for gRPC, and reserves *Dto for read-side projections; warns against generic *Dto on request models.
Performance Guidelines for String Slicing
CLAUDE.md
Recommends AsSpan over Substring for zero-allocation slicing on profiled synchronous hot paths and documents Span<T>/ReadOnlySpan<T> ref struct async/escape constraints.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the two main changes: encoding model-naming convention and adding the AsSpan-on-hot-paths rule into documentation and tooling.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/encode-asspan-and-model-naming

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

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

@emeraldleaf
emeraldleaf merged commit 4fb8c6a into main Jun 3, 2026
6 of 7 checks passed
@emeraldleaf
emeraldleaf deleted the chore/encode-asspan-and-model-naming branch June 3, 2026 00:21
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