Summary
index_router converts a committed count from std::size_t to int when it sends an indexed_end_token. Counts greater than INT_MAX can narrow to an implementation-defined value. A negative value can then cause incorrect subtraction in flush-token handling.
Required changes
- Change
indexed_end_token::count and the corresponding flush-token handling to use std::ptrdiff_t.
- Update
repeater_node::handle_flush_token and related code to preserve the widened count type.
- Remove the
static_cast<int>(count) conversion in the index_router::route flush callback.
- Preserve the existing count propagation behavior.
Rationale
A fold partition can accumulate more than INT_MAX cells. The current narrowing conversion can silently corrupt the committed count before repeater_node::handle_flush_token processes it.
Affected areas
phlex/core/index_router.cpp
- The
indexed_end_token declaration and its producers/consumers
repeater_node::handle_flush_token
Acceptance criteria
- No committed count is narrowed from
std::size_t to int during end-token creation.
indexed_end_token and all flush-token consumers use std::ptrdiff_t consistently.
- Existing flush-token count propagation semantics remain unchanged.
- Add or update tests for counts above
INT_MAX, where practical.
Backlinks
Summary
index_routerconverts a committed count fromstd::size_ttointwhen it sends anindexed_end_token. Counts greater thanINT_MAXcan narrow to an implementation-defined value. A negative value can then cause incorrect subtraction in flush-token handling.Required changes
indexed_end_token::countand the corresponding flush-token handling to usestd::ptrdiff_t.repeater_node::handle_flush_tokenand related code to preserve the widened count type.static_cast<int>(count)conversion in theindex_router::routeflush callback.Rationale
A fold partition can accumulate more than
INT_MAXcells. The current narrowing conversion can silently corrupt the committed count beforerepeater_node::handle_flush_tokenprocesses it.Affected areas
phlex/core/index_router.cppindexed_end_tokendeclaration and its producers/consumersrepeater_node::handle_flush_tokenAcceptance criteria
std::size_ttointduring end-token creation.indexed_end_tokenand all flush-token consumers usestd::ptrdiff_tconsistently.INT_MAX, where practical.Backlinks