Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:07:22Z"
-->
# AGENTS

Expand Down
30 changes: 19 additions & 11 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:21:46Z"
-->
# Architecture

Expand Down Expand Up @@ -113,8 +113,13 @@ maintaining a view from commit events.
sets `run_id` to the persisted root entry execution ID, so it survives
pause/restore and distinguishes separate runs with the same `workflow_id`.

Pause leaves unfinished frames open. Resume publishes new baselines with the
resumption reason and existing execution IDs before resumed body events.
Pause leaves unfinished frames open. After active worker tasks settle,
[`GraphRunPausedEvent`](src/graphon/engine_events/graph.py) lists the accumulated
`reasons` unless failure or abort takes precedence. The host decides when to
resume a [node-initiated wait](docs/development.md#integrate-host-services).
On resume with frame events enabled, the engine publishes `FrameStartedEvent`
baselines with `reason=WorkflowStartReason.RESUMPTION` and the existing
execution IDs before running queued work, including nodes that requested a pause.
[Persisted container state](src/graphon/runtime/container_state.py) preserves pending frame failures across pause and snapshot restore even when frame events are disabled.
Terminal failure or abort closes each remaining frame once, before the graph's terminal event.
An `Exception` thrown into `Engine.run()` during execution or at the paused event
Expand Down Expand Up @@ -149,14 +154,16 @@ consumer, so activation uses the events already consumed in that frame. See
[response gating regressions](docs/development.md#response-gating-regressions).

Root replies forward unread node-output chunks with the producer's execution ID,
selector, and `is_final` value. After the source closes and the filter reads its
chunks, a repeated reference emits the buffered text with the reply node's
execution ID and streaming text selector. When a repeated reference or literal
ends the template, its chunk has `is_final=True`.
selector, and `is_final` value. Within the same reply, a repeated reference to
a consumed stream emits the buffered text with the reply node's execution ID
and streaming text selector. When a repeated reference or literal ends the
template, its chunk has `is_final=True`.
See the [response filter tests](tests/engine/test_response_stream_filter.py).

When a branch skips a node and its output is absent, the root Answer omits that reference and keeps the surrounding text in both the saved and streamed reply.
See the [Answer node](src/graphon/nodes/answer/answer_node.py) and [branch workflow test](tests/workflows/test_full_engine_events.py).
The [Answer node](src/graphon/nodes/answer/answer_node.py) renders absent
references as empty text in its output. If a branch skips the producer of a
reference, the filtered root reply also keeps the surrounding text. See the
[branch workflow test](tests/workflows/test_full_engine_events.py).

[Template assembly](src/graphon/engine/filter/builtin/response_stream/template_stream.py)
keeps child source streams distinct by frame, execution, attempt, and selector.
Expand Down Expand Up @@ -268,8 +275,9 @@ Iteration keeps matching array types when flattening outputs and uses
`array[any]` for mixed array types. See [workflow tests](tests/workflows/test_full_engine_events.py)
for empty, serial, and parallel container behavior.

Stored outputs remain typed; container node-result inputs and Loop/Iteration
presentation events expose plain values. The
Node outputs stored in the variable pool retain their segment types.
Container node-result inputs and Loop/Iteration presentation events expose
plain values. The
[runtime JSON converter](src/graphon/workflow_type_encoder.py) masks typed
secrets using their log representation. Hosts must redact plain values separately,
including exports from [dumps_with_segments](src/graphon/variables/utils.py).
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:07:22Z"
-->
# Contributing to Graphon

Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:07:22Z"
-->
# Graphon

Graphon is a Python graph execution engine for agentic AI workflows.

The repository is still evolving, but it already contains a working execution
engine, built-in workflow nodes, model runtime abstractions, integration
protocols, and a runnable end-to-end example.

## Highlights

- Queue-based `Engine` orchestration with event-driven execution
Expand Down
10 changes: 2 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:14:21Z"
-->
# Repository knowledge

Expand All @@ -11,7 +11,7 @@ implementation or establish new public contracts.

| Question | Start here |
| --- | --- |
| What is Graphon and how do I run it? | [Project README](../README.md), [Slim example](../examples/slim_llm/README.md) |
| What is Graphon and how do I run it from DSL or Python? | [Project README](../README.md), [Slim example](../examples/slim_llm/README.md) |
| Where does execution happen, and who owns state? | [Architecture](../ARCHITECTURE.md) |
| How should runtime dependencies and mutable state be owned? | [Explicit state ownership](../CONTRIBUTING.md#explicit-state-ownership) |
| Which files and tests should I change? | [Development guide](development.md) |
Expand All @@ -31,12 +31,6 @@ Keep detailed component knowledge next to its implementation and link it here.
| Pause, abort, variable updates | [Commands](../src/graphon/engine/command/README.md) |
| Execution and host file rendering | [State ownership](../ARCHITECTURE.md#state-and-execution-invariants) |
| Model capabilities and providers | [Model runtime](../src/graphon/model_runtime/README.md) |
| DSL and direct Python construction | [Slim example setup](../examples/slim_llm/README.md) |

## Evidence and review

Follow [maintenance guidance](maintenance.md) for review evidence, validation,
and the lifecycle of active and archived knowledge.

## Related work

Expand Down
18 changes: 7 additions & 11 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<!-- knowledge
last_checked: "2026-11-27T03:17:49Z"
last_checked: "2026-12-03T01:16:39Z"
-->
# Development navigation

At the start of every development workflow, read and follow
[Development Style](../CONTRIBUTING.md#development-style).

Read [CONTRIBUTING.md](../CONTRIBUTING.md) for setup, validation commands, CI,
and contribution rules. This page connects changes to the code and tests that
define their behavior; it does not replace those rules.
Follow [CONTRIBUTING.md](../CONTRIBUTING.md) for setup, validation, and
contribution rules, starting with [Development Style](../CONTRIBUTING.md#development-style).
Use the source and tests below to find where to make a change.

## Find the change surface

Expand Down Expand Up @@ -115,10 +112,9 @@ and the [independent review sequence](../CONTRIBUTING.md#context-free-reviews).
### Response gating regressions

- [Complexity tests](../tests/engine/test_response_stream_filter_complexity.py)
bound adjacency calls, retained state, and snapshot size on chains of diamonds.
The `4VE` call budget allows two `V`-node traversals for each of up to `V`
responses on a connected graph with `E` edges. Doubling the stages approaches
four times that budget because nodes and edges both grow linearly with stages.
bound adjacency calls, retained state, and snapshot size on chains of diamonds
to catch exponential path enumeration. The adjacency budget grows with the
product of nodes and edges, so doubling stages approaches four times the budget.
The size checks cover one response without buffered source text and exclude
the caller-supplied context and the objects it references.
- [Differential tests](../tests/engine/test_response_stream_filter_differential.py)
Expand Down
2 changes: 1 addition & 1 deletion docs/maintenance.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:07:22Z"
-->
# Maintaining repository knowledge

Expand Down
8 changes: 3 additions & 5 deletions docs/technical-debt.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:07:22Z"
-->
# Technical debt

Expand Down Expand Up @@ -52,9 +52,6 @@ and [the extractor](../src/graphon/nodes/document_extractor/node.py) imports sev
eagerly. Minimal engine consumers inherit these dependencies. Measure installation
size and startup cost before claiming a benefit from optional dependencies.

The required [unstructured dependency](https://pypi.org/project/unstructured/0.27.37/#meta)
limits Graphon's [Python support](../pyproject.toml) to versions below 3.14.

Consider one document-extraction extra within the existing distribution. Isolate
its imports, provide an actionable missing-extra error, retain a fully equipped
development environment, and document the installation transition. Evaluate the
Expand All @@ -63,7 +60,8 @@ separately if needed.

**Completion:** a clean base-only installation executes a minimal graph; the full
extra passes [extractor tests](../tests/nodes/document_extractor/) and package/lockfile
checks. Verify clean dependency resolution for the supported Python versions.
checks. Verify clean dependency resolution for both installations across the
[supported Python versions](../pyproject.toml).

## TD-08 — Offline execution example

Expand Down
8 changes: 6 additions & 2 deletions examples/slim_llm/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:16:39Z"
-->
# Slim LLM Example

Expand All @@ -25,7 +25,7 @@ cd examples/slim_llm
cp credentials.example.json credentials.json
```

Fill in the model credentials in `credentials.json`. For a remote daemon,
Fill in the OpenAI model credentials in `credentials.json`. For a remote daemon,
set `slim.mode` to `remote` and supply `slim.daemon_addr` and
`slim.daemon_key`. The example defaults to local mode. See the
[Git ignore rule](../../.gitignore) and
Expand All @@ -37,13 +37,17 @@ and remote modes require this executable.

## DSL Import

This script displays filtered response chunks as they arrive.

```bash
uv run python dsl.py
uv run python dsl.py "Reply with only the word Graphon."
```

## Code Construction

This script prints the completed answer.

```bash
uv run python code.py
uv run python code.py "Reply with only the word Graphon."
Expand Down
2 changes: 1 addition & 1 deletion src/graphon/engine/command/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:07:22Z"
-->
# Commands

Expand Down
10 changes: 5 additions & 5 deletions src/graphon/engine/layer/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:20:48Z"
-->
# Layers

Expand All @@ -20,9 +20,9 @@ See [raw frame observations](../../../../ARCHITECTURE.md#raw-frame-observations)

Register a layer with [Engine.add_layer](../engine.py) before consuming
`engine.run()`. Registration binds read-only runtime access and a command channel
for execution controls.
Key execution metrics by the event's `id`; a node can execute in
multiple container frames with the same `node_id`.
for execution controls. The engine calls [`Layer.on_graph_start`](base.py) on
initial execution and on resumption. Key metrics by `NodeEvent.id` because a
node can execute in multiple container frames with the same `node_id`.

```python
from graphon.engine.layer import Layer
Expand All @@ -36,7 +36,7 @@ class MetricsLayer(Layer):
self.metrics: dict[str, float] = {}

def on_graph_start(self) -> None:
"""Reset collected metrics before the engine starts a new graph run."""
"""Reset collected metrics for this call to engine.run()."""
self.metrics.clear()

def on_event(self, event: EngineEvent) -> None:
Expand Down
29 changes: 16 additions & 13 deletions src/graphon/model_runtime/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-26T01:12:45Z"
last_checked: "2026-12-03T01:20:48Z"
-->
# Model Runtime

Expand All @@ -12,15 +12,14 @@ For graph-facing nodes, use the

## Choose a runtime surface

Implement only the [capability protocols](protocols/) your adapter needs. The
[aggregate runtime protocol](protocols/runtime.py) is for adapters that
intentionally provide every model capability.
[ModelProviderRuntime](protocols/provider_runtime.py) defines provider discovery.

Use [ModelProviderFactory](model_providers/model_provider_factory.py) for provider
discovery and credential validation; use [capability wrappers](model_providers/)
for invocation. [Entities](entities/) describe model parameters and credential
forms for host UIs. The
Use [ModelProviderFactory](model_providers/model_provider_factory.py) with an
adapter that implements [ModelProviderRuntime](protocols/provider_runtime.py)
to discover providers, validate credentials, and look up model schemas. To
invoke a model, use its [model wrapper](model_providers/) and implement its
[capability protocol](protocols/) in your adapter. Each capability protocol
extends `ModelProviderRuntime`. [ModelRuntime](protocols/runtime.py) combines
all model capability protocols.
[Entities](entities/) describe model parameters and credential forms for host UIs. The
[model dispatch tests](../../../tests/model_runtime/test_model_dispatch.py)
verify that provider discovery and individual capabilities remain independent.

Expand All @@ -40,9 +39,13 @@ blocks retain their order and block state; see the
[SlimLLM](../dsl/slim/llm.py) shares this aggregation for blocking ordinary and
structured output calls, covered by the [Slim tests](../../../tests/dsl/test_slim_llm.py).

[LLMResultChunkDelta](entities/llm_entities.py) tool calls with a nonempty function name carry the current argument snapshot, replacing earlier arguments for that ID, including with an empty string.
Updates with an empty name append arguments to their ID, or to the most recently created call when the ID is empty; the latter requires a preceding call.
Calls keep their first-seen order, and a named call without an ID starts a new call with a generated ID; see the [tool call tests](../../../tests/model_runtime/test_large_language_model_tool_calls.py) and [dispatch tests](../../../tests/model_runtime/test_model_dispatch.py).
In [`LLMResultChunkDelta`](entities/llm_entities.py), `message.tool_calls` carries
argument snapshots and fragments. A nonempty function name marks a full snapshot
that replaces the arguments for its ID, including with an empty string. An
empty function name marks an argument fragment to append by ID. A fragment with
an empty ID appends to the most recently created call and requires one to exist.
Named calls with empty IDs receive generated IDs. Calls keep their first-seen
order. See the [tool call tests](../../../tests/model_runtime/test_large_language_model_tool_calls.py).

After a `LargeLanguageModel.invoke` stream is fully consumed without errors, `on_after_invoke` receives a result containing all tool calls, assembled with the same merging rules as blocking results.
Iteration failures, including before the first chunk, notify `on_invoke_error` once with the original exception before normal exception conversion and propagation, and skip `on_after_invoke`.
Expand Down
Loading