feat: support event driven for sequences#56
Open
kerthcet wants to merge 13 commits into
Open
Conversation
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces an event-driven, FSM-based sequence lifecycle manager backed by a block allocator/manager, along with documentation and an example demonstrating basic usage. This appears to be foundational infrastructure for managing sequence scheduling, token append, forking, preemption, and completion in a structured way.
Changes:
- Added a
block_managersubsystem (allocator + manager + types/errors) to allocate/refcount/free KV-cache-like blocks. - Added a
sequence_managersubsystem implementing an event-driven FSM with typed states and transition events, plus a thread-safeSequenceIdGenerator. - Added developer-facing documentation (
docs/fsm_architecture.md) and an executable example (examples/fsm_usage.rs), and introducedthiserrorfor error derivations.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
src/sequence_manager/states.rs |
Defines FSM state types/variants and helper methods for sequence lifecycle tracking. |
src/sequence_manager/mod.rs |
Declares the sequence_manager module (and should expose a usable public API surface). |
src/sequence_manager/id_generator.rs |
Adds a thread-safe sequential SequenceId generator with unit tests. |
src/sequence_manager/fsm_manager.rs |
Implements the event loop and handlers for applying FSM transitions per sequence. |
src/sequence_manager/fsm_events.rs |
Defines the event/transition types that transform SequenceState with resource ownership semantics. |
src/sequence_manager/events.rs |
Defines the event protocol and stats payload used to drive/query the manager. |
src/main.rs |
Wires new modules into the binary crate. |
src/lib.rs |
Introduces a library surface re-exporting modules for external use (examples depend on this). |
src/block_manager/types.rs |
Adds block/sequence IDs, block stats, and thiserror-based error types. |
src/block_manager/mod.rs |
Declares the block_manager module (and should expose a usable public API surface). |
src/block_manager/manager.rs |
Implements block allocation, refcounting, free pooling, and stats reporting. |
src/block_manager/allocator.rs |
Defines the allocator trait and a simple CPU allocator implementation. |
examples/fsm_usage.rs |
Demonstrates end-to-end usage of the FSM sequence manager via async event sending. |
docs/fsm_architecture.md |
Documents the FSM approach, state diagram, and usage patterns for contributors. |
Cargo.toml |
Adds thiserror dependency. |
Cargo.lock |
Locks thiserror dependency version. |
Comments suppressed due to low confidence (1)
src/block_manager/mod.rs:4
- This module is used from the example as
puma::block_manager::{BlockManager, CpuAllocator}, butblock_manager/mod.rscurrently only declares submodules and doesn't re-export those types. As a result, the example (and any downstream crate using the same import style) will not compile.
pub mod allocator;
pub mod manager;
pub mod types;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+5
| pub mod events; | ||
| pub mod fsm_events; | ||
| pub mod fsm_manager; | ||
| pub mod id_generator; | ||
| pub mod states; |
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Member
Author
|
/kind feature |
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
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.
What this PR does / why we need it
Which issue(s) this PR fixes
Fixes #
Special notes for your reviewer
Does this PR introduce a user-facing change?