Skip to content

feat(flows): the flow engine, its fake kit, and scale tests - #78

Merged
futrime merged 1 commit into
feat/new-flow-apifrom
flow-api/u2-engine
Sep 25, 2026
Merged

futrime merged 1 commit into
feat/new-flow-apifrom
flow-api/u2-engine

Conversation

@futrime

@futrime futrime commented Sep 25, 2026

Copy link
Copy Markdown
Member

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).
  • ~330 new unit tests + tests/integration/flows/test_engine_flowverse.py (end-to-end over a real on-disk flowverse incl. a git+file:// ref, budget exhaustion, journal resume).
  • Fixes a race in spi.HookBridge._waited that 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

…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
futrime merged commit f8be621 into feat/new-flow-api Sep 25, 2026
2 checks passed
@futrime
futrime deleted the flow-api/u2-engine branch September 25, 2026 10:59
futrime pushed a commit that referenced this pull request Sep 25, 2026
feat(flows): the flow engine, its fake kit, and scale tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant