diff --git a/AGENTS.md b/AGENTS.md index 7f8db3df..c5d93418 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,5 @@ # AGENTS diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 02e40fe8..d5a46680 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -1,5 +1,5 @@ # Architecture @@ -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 @@ -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. @@ -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). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27ddb1ed..2ddf126e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ # Contributing to Graphon diff --git a/README.md b/README.md index c9ff2665..13ff07e9 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,10 @@ # 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 diff --git a/docs/README.md b/docs/README.md index b1050761..c81ca45e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,5 @@ # Repository knowledge @@ -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) | @@ -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 diff --git a/docs/development.md b/docs/development.md index c552ccf6..8f246117 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,14 +1,11 @@ # 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 @@ -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) diff --git a/docs/maintenance.md b/docs/maintenance.md index d56539fd..2b6874e3 100644 --- a/docs/maintenance.md +++ b/docs/maintenance.md @@ -1,5 +1,5 @@ # Maintaining repository knowledge diff --git a/docs/technical-debt.md b/docs/technical-debt.md index 92230fc5..71d02a9b 100644 --- a/docs/technical-debt.md +++ b/docs/technical-debt.md @@ -1,5 +1,5 @@ # Technical debt @@ -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 @@ -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 diff --git a/examples/slim_llm/README.md b/examples/slim_llm/README.md index 4c2020ba..96be7063 100644 --- a/examples/slim_llm/README.md +++ b/examples/slim_llm/README.md @@ -1,5 +1,5 @@ # Slim LLM Example @@ -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 @@ -37,6 +37,8 @@ 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." @@ -44,6 +46,8 @@ 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." diff --git a/src/graphon/engine/command/README.md b/src/graphon/engine/command/README.md index 04eb68e1..1ca61eb6 100644 --- a/src/graphon/engine/command/README.md +++ b/src/graphon/engine/command/README.md @@ -1,5 +1,5 @@ # Commands diff --git a/src/graphon/engine/layer/README.md b/src/graphon/engine/layer/README.md index fd060324..f96ae229 100644 --- a/src/graphon/engine/layer/README.md +++ b/src/graphon/engine/layer/README.md @@ -1,5 +1,5 @@ # Layers @@ -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 @@ -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: diff --git a/src/graphon/model_runtime/README.md b/src/graphon/model_runtime/README.md index 4943eeb2..8d72477e 100644 --- a/src/graphon/model_runtime/README.md +++ b/src/graphon/model_runtime/README.md @@ -1,5 +1,5 @@ # Model Runtime @@ -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. @@ -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`.