Skip to content

Project sidecar writer registry#1058

Open
bootjp wants to merge 3 commits into
mainfrom
design/encryption-stage7-projection
Open

Project sidecar writer registry#1058
bootjp wants to merge 3 commits into
mainfrom
design/encryption-stage7-projection

Conversation

@bootjp

@bootjp bootjp commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • project WriterRegistryForCaller from the writer registry in GetSidecarState and ResyncSidecar
  • wire the writer registry into each shard's EncryptionAdmin server
  • mark Stage 7 writer-registry projection shipped in the encryption design docs

Validation

  • git diff --check
  • go test ./adapter -run 'TestEncryptionAdmin_(GetSidecarState|ResyncSidecar)' -count=1 -timeout=240s
  • go test ./adapter -run TestEncryptionAdmin -count=1 -timeout=300s
  • go test ./cmd/elastickv-admin -run 'TestEncryption(Status|Endpoint|Sidecar)' -count=1 -timeout=180s
  • go test ./store ./internal/encryption . -count=1 -timeout=180s
  • golangci-lint run ./adapter ./store ./internal/encryption . --timeout=5m

Author: bootjp

Summary by CodeRabbit

  • 新機能

    • サイドカー状態取得・再同期時に、呼び出し元ごとの Writer Registry 情報を返すようになりました。
    • DEK に対応するレジストリ情報がない場合は、誤ったゼロ値を返さず除外します。
    • 不正なノード ID の衝突を検出し、エラーとして扱います。
    • Writer Registry 未設定時も、空のマップを返すようになりました。
  • ドキュメント

    • 部分暗号化およびサイドカーのレジストリ投影機能の実装状況を更新しました。

bootjp commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@bootjp, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 484ee810-e9f1-4afc-91a1-8ef7cf305e0a

📥 Commits

Reviewing files that changed from the base of the PR and between 101ca68 and cbc93a7.

📒 Files selected for processing (4)
  • adapter/encryption_admin.go
  • adapter/encryption_admin_test.go
  • main.go
  • main_encryption_admin_test.go
📝 Walkthrough

Walkthrough

EncryptionAdminServer が writer registry を受け取り、GetSidecarStateResyncSidecar で caller 別の WriterRegistryForCaller を返すようになりました。ランタイム配線、テスト、Stage 7 の設計文書も更新されています。

Changes

Writer registry projection

Layer / File(s) Summary
投影契約と実装
adapter/encryption_admin.go
WriterRegistryStore を保持・設定し、サイドカーの DEK と caller node ID に対応する registry 行から LastSeenLocalEpoch を投影する。欠損行は省略し、無効な caller ID、取得・デコード失敗、node collision はエラーにする。
ランタイム配線
multiraft_runtime.go, main.go
raftGroupRuntime に writer registry を保持し、EncryptionAdminServer 登録時に WithEncryptionAdminWriterRegistry で渡す。
投影動作の検証
adapter/encryption_admin_test.go
ローカル caller と Resync caller の投影、欠損 DEK の省略、未配線時の非 nil 空 map、node collision の拒否を検証する。
Stage 7 実装記録
docs/design/...
Stage 7 の出荷状況と sidecar registry projection の実装内容を更新する。

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Sidecar
  participant EncryptionAdminServer
  participant WriterRegistryStore
  Sidecar->>EncryptionAdminServer: GetSidecarState または ResyncSidecar を呼び出す
  EncryptionAdminServer->>WriterRegistryStore: DEK と caller node ID で registry 行を取得する
  WriterRegistryStore-->>EncryptionAdminServer: registry 行を返す
  EncryptionAdminServer-->>Sidecar: WriterRegistryForCaller を返す
Loading

Possibly related PRs

  • bootjp/elastickv#754: 同じ EncryptionAdmin RPC の空 map 応答を実装しており、本変更が実データ投影へ拡張している。
  • bootjp/elastickv#760: EncryptionAdminServer の登録経路を追加しており、本変更が registry オプションを同経路へ渡している。
  • bootjp/elastickv#765: 本変更が利用する WriterRegistryStoreGetRegistryRow の実装を追加している。
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed サイドカーの writer registry 投影と配線という主要変更を概ね表しており、タイトルとして十分に関連しています。
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.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request implements the remaining Stage 7 §5.5 recovery surface for WriterRegistryForCaller by wiring the WriterRegistryStore into EncryptionAdminServer. Both GetSidecarState and ResyncSidecar now project the writer registry for the caller, returning the decoded LastSeenLocalEpoch for each DEK present in the sidecar. The review feedback correctly points out that returning codes.InvalidArgument when fullNodeID == 0 is misleading for GetSidecarState since it uses the local node's ID, and recommends returning codes.FailedPrecondition or codes.Internal instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread adapter/encryption_admin.go
@bootjp

bootjp commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

Addressed latest-head review finding:

  • GetSidecarState now reports missing local fullNodeID as a server-side Internal error when the writer registry is wired
  • ResyncSidecar keeps returning InvalidArgument for a missing caller-supplied caller_full_node_id

Caller audit:

  • production GetSidecarState caller is cmd/elastickv-admin/encryption.go; Internal bubbles up as a non-zero CLI error instead of being treated as soft unavailable
  • no production ResyncSidecar caller was found

Validation:

  • go test ./adapter -run 'TestEncryptionAdmin_(GetSidecarState|ResyncSidecar)' -count=1 -timeout=240s\n- go test ./adapter -run TestEncryptionAdmin -count=1 -timeout=300s\n- go test ./cmd/elastickv-admin -run 'TestEncryption(Status|Endpoint|Sidecar)' -count=1 -timeout=180s\n- golangci-lint run ./adapter ./store ./internal/encryption . --timeout=5m\n- git diff --check\n- git verify-commit HEAD\n\n@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8c99a0a8c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread main.go Outdated
enableMutators,
rt.engine,
encryptionCapabilityFanout,
adapter.WithEncryptionAdminWriterRegistry(rt.writerRegistry),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Wire sidecar projection to the default registry

When a node runs multiple shard groups, this passes each per-shard admin listener its own Pebble registry, but the rest of the encryption path treats the default group store as the authoritative registry: process-start/runtime registration read store.WriterRegistryFor(defaultGroup.Store), and the startup guard documents that only the default group's FSM carries encryption entries. Calling GetSidecarState/ResyncSidecar on a non-default shard endpoint will therefore project from an empty or stale registry and silently omit writer_registry_for_caller rows, which defeats the monotonic-epoch recovery data this change is adding. Please share the default-group registry with all EncryptionAdmin servers or route these RPCs to that group.

Useful? React with 👍 / 👎.

@bootjp

bootjp commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

Addressed latest-head P2 review finding:

  • EncryptionAdmin sidecar projection now uses the default group writer registry for every shard listener, matching the startup/runtime registration authority.
  • Added coverage that non-default runtimes do not supply their per-shard registry to sidecar projection.

Validation:

  • go test ./adapter -run TestEncryptionAdmin -count=1 -timeout=300s
  • go test ./cmd/elastickv-admin -run 'TestEncryption(Status|Endpoint|Sidecar)' -count=1 -timeout=180s\n- go test . -run 'Test(WriterRegistryForEncryptionAdmin|EncryptionAdmin)' -count=1 -timeout=180s\n- go test ./store ./internal/encryption . -count=1 -timeout=180s\n- git diff --check\n- golangci-lint run ./adapter ./store ./internal/encryption . --timeout=5m\n- git verify-commit HEAD\n\n@codex review

@bootjp

bootjp commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

Current head is green and the latest sidecar projection findings have been addressed with tests. @codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: cbc93a7bd7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bootjp

bootjp commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

Current head already handles the remaining sidecar projection thread:

  • GetSidecarState passes codes.Internal for missing local fullNodeID, treating it as server configuration state.
  • ResyncSidecar still passes codes.InvalidArgument for missing caller-supplied caller_full_node_id.

Verification:

  • go test ./adapter -run 'TestEncryptionAdmin_GetSidecarState_(ProjectsWriterRegistryForLocalNode|RejectsMissingLocalNodeIDAsInternal)|TestEncryptionAdmin_ResyncSidecar_(ProjectsWriterRegistryForCaller|RejectsMissingCallerNodeIDAsInvalidArgument)' -count=1 -timeout=120s

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: cbc93a7bd7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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