AGENT SKILL

review-scalardb

Design-review perspective for ScalarDB projects: transaction scope, OCC contention and schema compatibility.

License 许可
MIT
最近更新
2026-11-14
Stars
★ 13
Forks
1

01 前言 Front Matter

model
sonnet
description
Design-review perspective for ScalarDB projects: transaction scope, OCC contention and schema compatibility.

03 SKILL.md 正文

ScalarDB Constraint Review

Shared files: a path written @rules/…, @skills/…, @templates/… or @docs/… is relative to the plugin root, ${CLAUDE_PLUGIN_ROOT} — not to the project being worked on. Read it from there.

Knowledge Grounding

Constraint claims (version-specific limits, config keys, edition-gated features) are verified against the project's pinned ScalarDB release in the OKF knowledge bundle (@rules/okf-knowledge-bundle.md), not against memory. Cite the concept's resource URL as evidence when a finding depends on documented behavior.

Review Dimensions

1. Cross-Service Transaction Mechanism (weight: 0.40)

  • Whether the design names a mechanism per cross-service transaction rather than defaulting to 2PC
  • Whether a simpler mechanism was available and skipped (shared-cluster one-phase commit; the Microservice Transaction API on ScalarDB 3.19+ Cluster)
  • Whether a new design adopts the deprecated 2PC interface without an ADR-recorded deviation
  • Whether hand-written 2PC transactions are contained within a maximum of 2-3 services
  • Whether a PostgreSQL wire protocol or Native JDBC access path relies on semantics it does not provide (enforced constraints, locks) or on a mismatched isolation level
  • Detection of transactions spanning 4+ services
  • Application points for ScalarDB Saga, whether compensations are defined and idempotent, and whether every external participant's readiness (idempotency, duplicate response, compensation deadline, outcome query) is assessed with a disposition per gap

2. OCC Contention Analysis (weight: 0.35)

  • Identification of write hotspots
  • Whether the design can achieve an OCC conflict rate below 5%
  • Contention mitigation strategies (partitioning, CQRS, etc.)

3. Schema and API Compatibility (weight: 0.25)

  • Validity of partition/clustering key design
  • Necessity of secondary indexes and their performance impact
  • Compliance with the constraints of the release the project pinned
  • Whether edition-gated features are within the project's contracted edition (SQL/JDBC and GraphQL are Enterprise Premium; Analytics is an Enterprise Option; ABAC is an Enterprise Premium Option and in Private Preview) — see @rules/scalardb-edition-profiles.md
  • Whether the pinned version line is still under maintenance support

Execution

Step 1: Collect Input File Paths

Glob for all available ScalarDB design documents:

  • reports/03_design/scalardb-*.md
  • reports/03_design/target-architecture.md
  • reports/03_design/transformation-plan.md
  • reports/03_design/api-specifications/**/*.md (if exists)

Record the full list of found file paths — these will be passed to sub-agents.

Step 2: Spawn Three Parallel Dimension Reviewers

In a single message, issue all three Agent() calls simultaneously so they run in parallel:

Task A — Cross-Service Transaction Mechanism (SDB-1xx)

Agent(
  subagent_type: "general-purpose",
  model: "sonnet",
  description: "Cross-service transaction mechanism dimension review",
  prompt: """
You are a ScalarDB architect reviewing designs for the CROSS-SERVICE TRANSACTION MECHANISM.

Read all of the following files using the Read tool:
<FILE_LIST>
[Insert the full list of file paths found in Step 1, one per line]
</FILE_LIST>

ScalarDB offers four mechanisms for a transaction that spans services, in order of preference:
1. Shared-cluster pattern with the one-phase commit interface — every service uses one ScalarDB
   Cluster instance. This is the documented recommendation "whenever possible".
2. Microservice Transaction API (`GlobalTransactionManager` / `BranchTransaction`, ScalarDB 3.19+
   Cluster; SQL `GLOBAL_TRANSACTION` on 3.20+) — separated Cluster instances with a Transaction
   Coordinator node driving 2PC underneath; application code stays one-phase and is identical to
   option 1. Available only if the project pins 3.19 or later on an Enterprise edition.
3. Application-driven two-phase commit interface — **deprecated as of ScalarDB 3.19** ("will be
   removed in a future release"; 3.20 removed `join()` / `resume()`). Acceptable only pre-3.19, on
   Core (Community) only, or with Spring Data JDBC, and only as an ADR-recorded deviation with a
   migration path. ScalarDB recommends such transactions span at most 2-3 services.
4. ScalarDB Saga (3.20 GA, Apache-2.0) — eventual consistency with compensations (SAGA) or
   reservations (TCC), for cases where a single ACID transaction is not possible or not wanted.
   Its store must run Consensus Commit.

Evaluate ONLY the Cross-Service Transaction Mechanism dimension:
- Does the design name a mechanism for each cross-service transaction, with a recorded reason?
- Was a simpler mechanism available and skipped (shared cluster, or the Microservice Transaction
  API when the pinned version and edition allow it)?
- Does any new design adopt the deprecated 2PC interface without an ADR and a migration path?
- Are hand-written 2PC transactions contained within 2-3 services maximum?
- Are there transactions spanning 4+ services that should use Saga instead?
- Where Saga is used, is a compensation defined for every step, and are the steps idempotent?
- Where a saga step calls an external API, does the Participant Readiness table state the provider's
  idempotency mechanism, duplicate response, compensation deadline against the saga horizon, outcome
  query and evidence URL, and does every gap carry a disposition? (An unassessed external participant
  is a blocker — @rules/scalardb-saga-patterns.md § External Participants)
- Where the PostgreSQL wire protocol or a standalone frontend is an access path, does any invariant
  rely on `UNIQUE` / `CHECK` / `REFERENCES` being enforced, or on `FOR UPDATE` locking? (It is not —
  @rules/scalardb-postgres-frontend-patterns.md)
- Where ScalarDB Native JDBC is used, do every ScalarDB application and the driver pin the same
  isolation level, and are the refused statement shapes absent? (@rules/scalardb-native-jdbc-patterns.md)

Score 1-5: 5=Exemplary (mechanism chosen and justified per transaction, simplest viable option
used), 4=Good, 3=Acceptable, 2=Concerning, 1=Critical (wide hand-written 2PC scope, or no
mechanism stated)

Return ONLY this JSON (no markdown fences, no explanation):
{
  "name": "Cross-Service Transaction Mechanism",
  "weight": 0.40,
  "score": <integer 1-5>,
  "findings": [
    {
      "id": "SDB-1<NN>",
      "severity": "critical|major|minor|info",
      "location": "<file:section>",
      "title": "<finding title>",
      "description": "<mechanism or scope issue and its impact on transaction reliability and complexity>",
      "recommendation": "<the mechanism to switch to, or the scope reduction to make>"
    }
  ]
}
"""
)

Task B — OCC Contention Analysis (SDB-2xx)

Agent(
  subagent_type: "general-purpose",
  model: "sonnet",
  description: "OCC contention analysis dimension review",
  prompt: """
You are a ScalarDB architect reviewing designs for OCC CONTENTION ANALYSIS.

Read all of the following files using the Read tool:
<FILE_LIST>
[Insert the full list of file paths found in Step 1, one per line]
</FILE_LIST>

ScalarDB uses Optimistic Concurrency Control (OCC). Conflict rates above 5% degrade performance significantly.

Evaluate ONLY the OCC Contention Analysis dimension:
- Which tables/partitions are write hotspots (multiple concurrent writes to the same partition key)?
- Can the design achieve an OCC conflict rate below 5% under expected load?
- Are contention mitigation strategies applied (partitioning, CQRS, event sourcing, etc.)? Read the design's "Read Model, CQRS and Event Sourcing Decisions" table: an aggregate with a hot partition and `none` / `no` there is a finding, and an aggregate absent from the table is *undecided* — a finding too, not "not needed"

Score 1-5: 5=Exemplary (minimal hotspots, clear mitigation), 4=Good, 3=Acceptable, 2=Concerning, 1=Critical (high contention)

Return ONLY this JSON (no markdown fences, no explanation):
{
  "name": "OCC Contention Analysis",
  "weight": 0.35,
  "score": <integer 1-5>,
  "findings": [
    {
      "id": "SDB-2<NN>",
      "severity": "critical|major|minor|info",
      "location": "<file:section>",
      "title": "<finding title>",
      "description": "<hotspot or contention pattern and its performance impact>",
      "recommendation": "<specific partitioning or design change>"
    }
  ]
}
"""
)

Task C — Schema and API Compatibility (SDB-3xx)

Agent(
  subagent_type: "general-purpose",
  model: "sonnet",
  description: "Schema and API compatibility dimension review",
  prompt: """
You are a ScalarDB architect reviewing designs for SCHEMA AND API COMPATIBILITY.

Read all of the following files using the Read tool:
<FILE_LIST>
[Insert the full list of file paths found in Step 1, one per line]
</FILE_LIST>

Evaluate ONLY the Schema and API Compatibility dimension, against the constraints of the ScalarDB
release the design pins (state the version you assumed if the design does not name one):
- Partition key design (even distribution, no hot partitions, no monotonically increasing sole partition keys)
- Clustering key design (appropriate sort order for access patterns)
- Secondary indexes (only where necessary; avoid high-cardinality indexes on some backends)
- API usage (Put is deprecated since 3.13; use Insert/Upsert/Update instead)
- Exception handling (specific conflict exceptions caught before parent classes). The 3.19 recovery
  APIs — finishTransaction(), recoverRecord() — are low-level operational APIs; flag any design
  that calls them from application error handling
- Edition fit: SQL / JDBC / Spring Data JDBC / GraphQL require Enterprise **Premium** (not
  Standard); ScalarDB Analytics is a separately contracted Enterprise **Option**; ABAC is an
  Enterprise Premium **Option** and in Private Preview. Flag any feature used outside the
  project's stated edition
- Version support: flag a design pinned to ScalarDB 3.15 or 3.14, which are past maintenance support

Score 1-5: 5=Exemplary, 4=Good, 3=Acceptable, 2=Concerning, 1=Critical

Return ONLY this JSON (no markdown fences, no explanation):
{
  "name": "Schema and API Compatibility",
  "weight": 0.25,
  "score": <integer 1-5>,
  "findings": [
    {
      "id": "SDB-3<NN>",
      "severity": "critical|major|minor|info",
      "location": "<file:section>",
      "title": "<finding title>",
      "description": "<schema or API issue and its constraint violation>",
      "recommendation": "<specific fix per ScalarDB constraints>"
    }
  ]
}
"""
)

Step 3: Merge and Write Output

After all three Tasks complete, compute the weighted score and write output:

weighted_score = round(0.40 × scoreA + 0.35 × scoreB + 0.25 × scoreC, 2)

Write reports/review/individual/review-scalardb.json:

{
  "perspective": "scalardb",
  "reviewer": "review-scalardb",
  "timestamp": "<ISO-8601 now>",
  "dimensions": [<Task A result>, <Task B result>, <Task C result>],
  "weighted_score": <computed>,
  "summary": "<2-3 sentences synthesizing ScalarDB constraint compliance and key risks>"
}

Output Format

Finding ID prefix: SDB-

  • SDB-1xx: Cross-Service Transaction Mechanism
  • SDB-2xx: OCC Contention Analysis
  • SDB-3xx: Schema and API Compatibility

04 同仓库更多 Skills