fix(kg): bound the fence list before the writer transaction opens - #2560
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2507.
A fence list ran unbounded inside the writer transaction. Each fence is a keyed read taken while the writer is held, which is the same shape the batch observation cap bounds in #2546, and nothing bounded it here.
A fence list now admits at most 100 entries. The refusal names the cap and the count that was sent:
The bound is enforced twice, on purpose.
Deserializechecks the array length before any entry is parsed into aNoteFence, so an oversized list costs one length read rather than four thousand struct parses, andvalidatechecks it again for any caller that builds the list in Rust rather than off the wire. The single-fence form is unaffected.The number matches the observation cap from ADR-174 Amendment 7 because the cost being bounded is the same: a read held against the writer. ADR-172 carries the amendment.
Acceptance
Host gate on the pinned toolchain:
cargo fmt --all --checkclean,cargo clippy -p khive-runtime -p khive-pack-kg --all-targets -D warningsclean,cargo test -p khive-runtime -p khive-pack-kg --no-fail-fastgreen, 1575 runtime unit tests and the kg suites, plus the new fence-count arms at the boundary, one over it, and through both the wire and the Rust path.Note for review: this amends an accepted ADR, so it merges after sign-off rather than on CI alone.