fix(graph): auto-merge only schema-declared keys from llm output
state_updates::apply merged EVERY top-level key of an llm/agent node's JSON
output into graph state whenever the node had an output_schema, and
structured::extract never validated the output against that schema. Any
prompt text able to steer the model — including plan/diff text pasted from a
repo under review — could therefore plant an undeclared key (e.g.
verification_commands) into state and overwrite a caller-declared value
before a downstream script consumed it.
- apply() now takes the node's output_schema and merges only keys present in
schema.properties; undeclared keys are dropped. No schema, or a schema
without an object properties map, merges nothing.
- Nodes without output_schema are unchanged (None == the old false path);
explicit state_updates are unchanged and still see the full output via
{{output.<key>}}, which remains the author-controlled way to lift a key.
- Callers: llm.rs, agent.rs (x2), rag.rs (None).
- Sweep test bundled_graph_output_schemas_declare_every_key_relied_on: for
every bundled graph, every consumed state key has a declared writer
(initial_state, variable, state_updates target, map key, script-emitted key,
or an output_schema property), and no schema node's field list names a key
its schema omits — so this restriction cannot silently break a shipped
graph. It passes with no graph.yaml changes.
- graph.example.yaml documents the declared-keys-only merge; the residual
disclosed in 665fee9's README/docstring notes is now recorded as closed.
This commit is contained in:
1 parent
300c7aeff0
commit
27101909e0
9 files changed
+370
-43
No files matched your search
@@ -133,9 +133,10 @@ final report verbatim.
|
||||
and never extracted by `parse`. The adversary's `run_checks` stage executes
|
||||
those commands with a shell, which makes the declaration a trust boundary:
|
||||
the prompt also carries plan text pasted from the repo under review, so
|
||||
commands must never be inferred from it (residual: the engine still merges
|
||||
every top-level key of `parse`'s output into state, so an extra
|
||||
`verification_commands` key emitted by the LLM is not yet blocked).
|
||||
commands must never be inferred from it, and the engine merges only the keys
|
||||
`parse`'s `output_schema.properties` declares, so an extra
|
||||
`verification_commands` key emitted by the LLM is dropped before it reaches
|
||||
state.
|
||||
Undeclared stays undeclared
|
||||
(`'[]'` ⇒ "none declared"); a declaration that is not a JSON array of
|
||||
strings executes nothing and records a `PIPELINE-FAULT`, which the
|
||||
|
||||
Reference in new issue
Block a user