Skip to content

fix(kg): bound the fence list before the writer transaction opens - #2560

Merged
oceanwaves630 merged 1 commit into
mainfrom
codex/fence-list-bound
Sep 11, 2026
Merged

fix(kg): bound the fence list before the writer transaction opens#2560
oceanwaves630 merged 1 commit into
mainfrom
codex/fence-list-bound

Conversation

@oceanwaves630

Copy link
Copy Markdown
Collaborator

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:

fence list admits at most 100 entries; this call sent 4096: each fence is a read
taken while holding the writer

The bound is enforced twice, on purpose. Deserialize checks the array length before any entry is parsed into a NoteFence, so an oversized list costs one length read rather than four thousand struct parses, and validate checks 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 --check clean, cargo clippy -p khive-runtime -p khive-pack-kg --all-targets -D warnings clean, cargo test -p khive-runtime -p khive-pack-kg --no-fail-fast green, 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.

@oceanwaves630
oceanwaves630 merged commit db46304 into main Sep 11, 2026
29 of 30 checks passed
@oceanwaves630
oceanwaves630 deleted the codex/fence-list-bound branch September 11, 2026 00:58
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.

Bound the length of a fence list before the writer transaction opens

2 participants