Fix SCAN Limit wire-width mismatch with the fitz broker - #33
Merged
Merged
Conversation
KvScanQuery.Limit was declared ulong? and written on the wire with WriteU64 (8 bytes), but the fitz broker's SCAN decoder (read_optional_limit) only reads a u32 (4 bytes) -- matching MAX_SCAN_ITEMS and every other broker-side limit. The extra 4 bytes shifted every subsequent field (reverse, optional start_exclusive), which the broker's decoder correctly flagged as trailing data: Cntryl.Fitz.KvException: SCAN failed: Invalid request: Trailing data in SCAN payload This meant every KvDirectory<T,TKey>.QueryAsync/ScanAllAsync call against a real broker failed -- point reads/writes were unaffected, only Scan. Root-caused by rebuilding the fitz broker from its own current main and reproducing the identical error locally, confirming this is a genuine field-width bug rather than a stale broker image. Fixes it by changing KvScanQuery.Limit to uint?/WriteU32 to match the broker's u32, updating the three (ulong) call sites in KvDirectory that constructed it, and the two tests that asserted on the old type.
smiggleworth
force-pushed
the
fix/scan-limit-wire-width
branch
from
September 17, 2026 23:32
96901e5 to
fb1e864
Compare
5 tasks
smiggleworth
added a commit
to bdgrz/compliance
that referenced
this pull request
Sep 19, 2026
* Add Role management: backend CRUD, read models, and UI
Team management shipped without Role management alongside it -- the
backend had DefineRole/AssignRolePermission/AssignTeamRole aggregate
handlers but no HTTP/MCP routes, no DeleteRole, no RemoveRolePermission
or RemoveTeamRole, and no read model, so "can I manage roles" was
still no. This closes that gap, mirroring the Team management slice's
pattern throughout:
- New RolePermissionRemoved/TeamRoleRemoved events and
DeleteRole/RemoveRolePermission/RemoveTeamRole commands, wired into
PermissionProjectionState and PermissionProjector so revoking a
permission or unassigning a role from a team actually takes effect
in materialized grants (previously only additive assignment was
reachable).
- Three new KvDirectory-backed read models: RoleDirectory (list/get
roles by name), RolePermissionDirectory (list a role's permissions),
and RoleTeamDirectory (list the teams holding a role, materialized
role-first from the same TeamRoleAssigned/Removed events
rbac-team-roles already emits, so a role's detail page doesn't need
a substring-search fallback over an unrelated index).
- RoleCleanupReactor, mirroring TeamCleanupReactor: deleting a role
removes its orphaned permission and team assignments instead of
leaving them to rot.
- Full HTTP + MCP surface for all of the above, and a /roles,
/roles/{roleId} UI (create/delete roles; add/remove permissions and
team grants) following the same pages/routing pattern as Teams.
Verified end to end against a real Fitz broker: DefineRole, GetRole,
and AssignRolePermission (all point reads/writes) work correctly.
ListRoles/ListRolePermissions/ListRoleTeams hit the same already-
tracked SCAN wire-protocol bug (cntryl/fitz-dotnet#33) that blocked
ListTeams before that fix -- not a new regression, the identical
pre-existing upstream limitation surfacing on a new read path.
* Fix MCP tool-list regression from Role management
Adding Role's MCP tools in Program.cs broke
TeamMcpScenarioTests.ShouldListTeamToolsAndDenyAnUnprivilegedCall,
which asserted an exact tool list scoped to Team alone. Renamed to
RbacMcpScenarioTests and updated the expected list to the full RBAC
surface (Team + Role); the exact-match style is kept deliberately so
future tool registrations force a visible review here rather than
silently drifting.
* Align broker integration test namespace with folder
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.
Summary
KvScanQuery.Limitwasulong?, written on the wire withWriteU8+WriteU64(8 bytes) inKvTransaction.ScanAsync. Thefitzbroker's SCAN decoder (read_optional_limitinsrc/protocol/kv_codec/mutation_parsers.rs) only reads au32(4 bytes) for that field -- consistent with every other broker-side limit (MAX_SCAN_ITEMS: usize = 1_024).reverse, optionalstart_exclusive), which the broker'sensure_completecheck correctly flagged asTrailing data in SCAN payload.KvDirectory<T,TKey>.QueryAsync/ScanAllAsynccall against a real broker failed withCntryl.Fitz.KvException: SCAN failed: Invalid request: Trailing data in SCAN payload. Point reads/writes (GetAsync/InsertAsync) were unaffected -- onlyScan.KvDirectory) against a live broker -- never caught byInMemoryKvClient-backed tests, since that double doesn't encode wire bytes at all.Root cause confirmation
Rebuilt the
fitzbroker from its own currentmain(07eb3a23) via its Dockerfile and reproduced the identical error against the freshly built broker, ruling out a stale Docker image -- this is a genuine field-width mismatch betweenfitzHEAD andfitz-dotnetHEAD.Fix
Fitz.Abstractions/Domains/Kv/KvTypes.cs:KvScanQuery.Limit->uint?Fitz.Core/Domains/Kv/KvTransaction.cs:WriteU64->WriteU32Fitz.Extensions/KvDirectory.cs: three(ulong)(limit + 1)casts ->(uint)(limit + 1)25UL/(ulong)3/(ulong)4->25U/(uint)3/(uint)4)PackageVersionbumped 1.3.0 -> 1.3.1Test plan
dotnet buildclean, 0 warningsdotnet testonFitz.Extensions.Tests(23/23),Fitz.Testing.Tests(32/32),Fitz.Analyzers.Tests(16/16) -- all passinglistTeams/listTeamMembers(SCAN-backed reads) went from500 Trailing data in SCAN payloadto200with real data, then reverted the downstream app back to the published 1.3.0 packages since that verification was local-only