Repository navigation
feat(python): add bounded control-stream reliability state - #38
Merged
austinchennn merged 1 commit intoOct 17, 2026
Merged
austinchennn merged 1 commit into
austinchennn merged 1 commit into
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.
Description:
Refs #18 — Python control-stream reliability foundation only; no issue closed.
Adds direction-local Python
OutboxandInboxstate on top of the merged protocol codecs. They provide continuous control-message numbering, cumulative ACK deletion, bounded replay storage and receive deduplication. They do not implement sockets, session lifecycle, reconnect orchestration, tools or audio.Behaviours Completed
Outbox(direction, limit=1024).stamp(message)validates an unenveloped message, snapshots its payload and assigns a continuous seq. Transients use 0 and do not consume counter/cache space. Caller-provided v/seq are rejected rather than allowed to overwrite the generated envelope.errormessages require an explicitsessionless=True/Falsechoice. Binding is not inferred from earlier messages or guessed by this transport-independent helper.resend_from(cursor)returns independent ordered snapshots, [] when current, or None when a complete requested replay is unavailable/a valid uint32 cursor is ahead.Inbox(direction).accept(message)validates full structure before updating its receive cursor. Seq 0 never advances/deduplicates; valid seq <= cursor is duplicate; larger seq advances per §4.3, including a gap. Integral JSON numeric values normalize to Python ints internally.Files Changed
python/src/vrealtime/sequence.py: two small synchronous state objects, local replay-capacity policy and argument checks; standard library only.python/src/vrealtime/protocol.py: exposes the existing immutable transient-type set asTRANSIENT_MESSAGE_TYPESso codecs and sequence state share classification; wire rules unchanged.python/src/vrealtime/__init__.py: public reliability helpers/constants.python/tests/test_sequence.py: independent message/state trajectories, ACK/eviction boundaries, ownership, atomic failure and uint32 exhaustion coverage.python/tests/check_install.py: checks new exports/state behavior in default installed artifacts without extras.python/README.md,python/pyproject.toml: API, normative/local policy distinctions, limitations, discrepancies, aggregate budget and package description.Brief Explanation
Outgoing retention and incoming receipt have different responsibilities and remain separate. Existing structural validation is reused; no transport/provider/tool dependency or framework is introduced. An ordered dictionary provides FIFO eviction/pruning without shifting a list. Deep copies isolate caller mutations; their cost is proportional to control-message payload size and is documented rather than presented as zero-copy real-time performance.
The invariant is a contiguous retained suffix after the highest actually removed seq, with a monotonic allocated counter. This prevents reporting a partial replay as successful when an old cursor refers to already acknowledged/deleted messages. The TypeScript helper currently tracks only unacknowledged eviction and can miss this case; this PR neither copies that behavior nor changes TypeScript/spec files.
A uint32 ahead ACK is impossible for a conforming peer that obeys the receive bound, but §4.2 explicitly defines its sender-side effect. The local helper honors that tolerant effect without storing credit for future sends. Session-level peer-error policy remains outside this API. Gaps follow §4.3's accept/advance rule without claiming missing-message recovery.
Testing
npm run check:spec: 23 schemas, 156 control vectors, 9 audio vectors passed. Shared schemas/vector expectations are unchanged.git diff --check: passed.Unsure About
Implementation Order and Acceptance — #18 progress
This records verified merged substeps, not completion of the full issue. The upstream issue body is unchanged because this contributor has read-only repository access.