Skip to content

feat: support event driven for sequences#56

Open
kerthcet wants to merge 13 commits into
InftyAI:mainfrom
kerthcet:feat/support-event-driven
Open

feat: support event driven for sequences#56
kerthcet wants to merge 13 commits into
InftyAI:mainfrom
kerthcet:feat/support-event-driven

Conversation

@kerthcet

@kerthcet kerthcet commented Jul 5, 2026

Copy link
Copy Markdown
Member

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?


kerthcet added 2 commits July 5, 2026 17:40
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings July 5, 2026 16:44
@InftyAI-Agent InftyAI-Agent added needs-triage Indicates an issue or PR lacks a label and requires one. needs-priority Indicates a PR lacks a label and requires one. do-not-merge/needs-kind Indicates a PR lacks a label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 5, 2026
Signed-off-by: kerthcet <kerthcet@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_manager subsystem (allocator + manager + types/errors) to allocate/refcount/free KV-cache-like blocks.
  • Added a sequence_manager subsystem implementing an event-driven FSM with typed states and transition events, plus a thread-safe SequenceIdGenerator.
  • Added developer-facing documentation (docs/fsm_architecture.md) and an executable example (examples/fsm_usage.rs), and introduced thiserror for 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}, but block_manager/mod.rs currently 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 thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread docs/fsm_architecture.md
Comment thread src/block_manager/manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread docs/fsm_architecture.md Outdated
Comment thread src/sequence_manager/states.rs
Copilot AI review requested due to automatic review settings July 5, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 11 comments.

Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_events.rs
Comment thread src/block_manager/mod.rs
Comment on lines +1 to +5
pub mod events;
pub mod fsm_events;
pub mod fsm_manager;
pub mod id_generator;
pub mod states;
Comment thread src/sequence_manager/states.rs
Comment thread docs/fsm_architecture.md
Comment thread docs/fsm_architecture.md
Comment thread docs/fsm_architecture.md Outdated
Comment thread src/block_manager/allocator.rs
kerthcet added 5 commits July 6, 2026 00:05
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>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 19:39
@kerthcet

kerthcet commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

/kind feature

@InftyAI-Agent InftyAI-Agent added feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Jul 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 23 changed files in this pull request and generated 6 comments.

Comment thread src/block_manager/mod.rs
Comment thread src/sequence_manager/mod.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
kerthcet added 2 commits July 6, 2026 20:53
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 20:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 23 changed files in this pull request and generated 7 comments.

Comment thread src/cli/chat.rs Outdated
Comment thread src/block_manager/allocator.rs
Comment thread src/block_manager/mod.rs
Comment thread src/sequence_manager/mod.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread docs/fsm_architecture.md Outdated
Comment thread docs/fsm_architecture.md
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 20:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 23 changed files in this pull request and generated 6 comments.

Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_manager.rs
Comment thread src/sequence_manager/fsm_events.rs
Comment thread src/sequence_manager/fsm_events.rs
Comment thread src/cli/chat.rs
Comment thread src/sequence_manager/fsm_events.rs
Signed-off-by: kerthcet <kerthcet@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. feature Categorizes issue or PR as related to a new feature. needs-priority Indicates a PR lacks a label and requires one. needs-triage Indicates an issue or PR lacks a label and requires one.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants