feat(flows): the flow engine, its fake kit, and scale tests - #78
Merged
Merged
Conversation
…ke kit Implements `define_flow`, `load_flow`, `new_outworlder` and `run_flow` for the new flow API, with the pieces they stand on: - engine: `FlowImpl` (awaited directly: no task, two frames a level, no filesystem work per call), `Call` as the `FlowContext`, the run and its running tree, budgets rolled up eagerly under one lock with per-call deadlines, refcounted cleanup through a shielded reaper, `full_view` for chat. - declaring: roles resolved lazily from the collections' annotations, one interned `Grant` per kind, and `describe()`'s `Declaration`. - viewing: `AgentView`, `SessionView`, `EnvView`, `OutworlderView`, gating every capability a role did not declare; hooks bound per flow call. - journaling: the resume journal (append-only JSONL, batched, compacted on resume) and `FlowState`. - loading: every ref form, the bare-ref rule, flow directories imported under their own name with their siblings importable, modules pinned per run with `FlowLoadConflict`, and `git+` refs pinned to a commit. - fakes: in-memory drivers and `run_fake`, held to the driver contract. Also fixes a race in `HookBridge._waited` that dropped a hook's answer when it arrived between the bridge's two checks, and rewrites specs/runtime/flowing.md for the new engine, marking the old API's modules as legacy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
futrime
pushed a commit
that referenced
this pull request
Sep 25, 2026
feat(flows): the flow engine, its fake kit, and scale tests
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.
Unit 2 of the new flow API (specs/flows.md): the runtime engine behind
hmz.flows.engine.py(define_flow / load_flow / new_outworlder / run_flow, call node = ctx),declaring.py(role/env requirements, Declaration),viewing.py(Agent/Session/Env/Outworlder views with capability gating),journaling.py(append-only resume journal, FlowState),loading.py(refs, module cache, git+url fetches),fakes.py(public in-memory fake kit).tests/integration/flows/test_engine_flowverse.py(end-to-end over a real on-disk flowverse incl. agit+file://ref, budget exhaustion, journal resume).spi.HookBridge._waitedthat could drop a hook's answer.Perf (flow layer only, fakes): 1.91 µs per sequential subflow call, 6.21 µs journaled; 16,402-node depth-10 tree in 0.042 s CPU; 29,524-node gathered tree 1.6× raw asyncio; 0.1 KiB retained after 100k calls; 0 Tasks and 2 frames per level; FlowDepthExceeded at 64.
🤖 Generated with Claude Code