Skip to content

refactor(batch)!: remove allow_replacement_accounting - #1035

Merged
QuantumExplorer merged 1 commit into
developfrom
claude/drop-replacement-accounting-option
Nov 9, 2026
Merged

QuantumExplorer merged 1 commit into
developfrom
claude/drop-replacement-accounting-option

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: Removes the allow_replacement_accounting batch option added in #1033. A flags update can still answer AccountAsReplacement, and GroveDB accepts that from GROVE_V5 as before. A caller no longer has to set a second switch to allow it.

Value: One less thing to keep in step. The option was a second opt-in for something the callback already opts into, and its only other job was raising estimates that Platform does not need. About 2,200 lines go, nearly all of them tests of that raise.

Risks: Low. GROVE_V5 is not released, and every cost, estimate, stored element and hash is what it was for a batch that did not set the option. A caller that estimates real replace operations and also answers AccountAsReplacement would now get too low an estimate. Platform does not estimate that way: Drive estimates a document update as the insertion of everything it writes, so turning the option on made no difference to its estimates.

Issue being fixed or feature implemented

Follow-up to #1033. While adopting it in Platform, the option turned out to change nothing Drive's estimates needed, and to duplicate checks that already exist.

What was done?

// Before: the callback answers, and the batch must also opt in
db.apply_batch_with_element_flags_update(
    ops,
    Some(BatchApplyOptions { allow_replacement_accounting: true, ..Default::default() }),
    flags_update,
    split_removal_bytes,
    transaction,
    grove_version,
);

// After: the callback's answer is enough
db.apply_batch_with_element_flags_update(
    ops,
    None,
    flags_update,
    split_removal_bytes,
    transaction,
    grove_version,
);
Situation Before After
Callback answers AccountAsReplacement on GROVE_V5 Accepted only with the option Accepted
Same answer below GROVE_V5 Refused by the batch Refused by Merk's version gate
Same answer on a write whose flags equal the stored flags Refused Refused
Estimate of a flagged replace Raised only with the option Not raised, as without the option

Public interface

  • Removed: the field BatchApplyOptions::allow_replacement_accounting. Code that names it must delete that line.
  • Removed: the version slot GroveDBApplyBatchVersions::replacement_accounting.
  • Changed: answering AccountAsReplacement below GROVE_V5 now fails with Merk's refusal (a client corruption error naming just-in-time value update version 2) instead of Error::InvalidBatchOperation. It is refused either way.
  • Unchanged: ElementFlagsUpdate, the flags helpers and the callback signatures.

In-place changes to shipped generations

The estimators are back to their code from before #1033, which is what they computed with the option off. The replacement_accounting slot was 0 on GROVE_V1..GROVE_V4 and nothing else read it. The byte-equal check only acts on an AccountAsReplacement answer, which those versions refuse anyway, so no shipped generation changes behaviour.

How Has This Been Tested?

  • cargo test -p grovedb-version (60), cargo test -p grovedb-epoch-based-storage-flags --lib (67) and cargo test -p grovedb-merk --lib just_in_time (5).
  • cargo test -p grovedb --lib --features full,estimated_costs filtered to batch:: and backward_references (320), and cargo test -p grovedb --test written_owner_flags_update (4).
  • cargo clippy with -D warnings on grovedb, grovedb-version and grovedb-merk; cargo check of the minimal-only and verify-only builds; cargo fmt --all --check.
  • No full suite was run locally.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if needed

🤖 Generated with Claude Code

PR Hygiene · 3efa3ef

  • Bots — coderabbitai not yet · thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

The option did two things. It refused an AccountAsReplacement answer when
off, which the callback's own answer and Merk's version gate already
cover. And it raised estimates, which Platform does not need: Drive
estimates a document update as the insertion of everything it writes.

Removes BatchApplyOptions::allow_replacement_accounting, the
apply_batch.replacement_accounting version slot and the estimators' raise.
A write whose flags are byte-equal to the stored ones is still refused.

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

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 9, 2026
@QuantumExplorer
QuantumExplorer merged commit fa92511 into develop Nov 9, 2026
4 of 5 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/drop-replacement-accounting-option branch November 9, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant