Repository navigation
fix(preset): refuse two inner-graph output bindings and derive ownership structurally (I-000391) - #695
fix(preset): refuse two inner-graph output bindings and derive ownership structurally (I-000391)#695auto-wood wants to merge 6 commits into
Conversation
- Export now refuses two inner-step nodes claiming one graph's output_binding instead of letting the later claim silently win. - Import resolves the binding's owner from the step ids in the graph, so a dotted field path no longer drops the binding.
[Medium impact] The changes affect preset and workflow conversion used by validation, core, and orchestration. Fix the loss of bare step-ID output bindings before merging. Findings
Fix with agent prompt### Issue 1
crates/nexus-preset/src/workflow_ir.rs:317-320
A binding such as `output_binding: review` now disappears during import, even though the loader still accepts it. `strip_prefix` leaves an empty string, which fails the dot check, so no step keeps the binding. Export then writes `output_binding: None`, silently changing the manifest.
Preserve exact step-ID matches alongside dotted paths, and add a bare-binding round-trip test.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe PR rejects a second output binding within one inner graph and changes import to preserve dotted field paths.
Acknowledged limitation: auto-wood deferred ambiguous ownership when step IDs overlap as dotted prefixes. Reviews (1) · Last reviewed commit: "fix(nexus-preset): refuse a second inner..." · Reviewed by Greptile |
|
| Findings | Count |
|---|---|
| 🔴 must-fix | 0 |
| 🟠 should-fix | 1 |
| 🟡 may-fix | 1 |
| 🔵 nit | 0 |
📋 Review
What this PR does: Closes I-000391 by making inner-graph output_binding ownership single-valued and agreed in both directions: export now refuses a second binding claim for the same inner graph (naming the graph and both bindings), and import resolves each graph's owner once (the step whose id prefixes the binding) instead of deriving it with rsplit_once('.'), which used to misattribute review.output.text and drop the binding. The diff also adds reverse-direction guards for slashed inner-step ids: document_from_manifest refuses a step id containing /, and export refuses a document whose inner-step id still contains a slashed step, with a test for each. No IR schema change; the remaining risk is in how the export guard identifies graph boundaries.
Findings
🟡 New slashed-step refusal is unmapped in projection_refusal, so validation reports it at preset.id as IdMismatch
-
Evidence:
[BUG-01] Map the new slashed-step
NotProjectablerefusal onto its own diagnostic carrier- Evidence:
crates/nexus-preset/src/workflow_ir.rs:309-312— the added guard indocument_from_manifestreturnsrefuse(...), i.e.WorkflowIrError::NotProjectable(the new test atworkflow_ir.rs:2065asserts exactly that).document_from_manifestis the projection used by the validation entrypoint (import_preset_manifest, documented atworkflow_ir.rs:293-301as the projection that lets validation report defects on the document).crates/nexus-preset/src/validation.rs:288-296(projection_refusal, read only as the caller contract of the changed refusal) mapsNotProjectableto eitherinner_graphs.<graph>.output_binding/Structural— but only whenunknown_output_owner(manifest)isSome— or the fallback("preset.id", DiagnosticCategory::IdMismatch). For a manifest whose only defect is a slashed inner-step id,unknown_output_ownerisNone, so the diagnostic lands onpreset.idwith categoryIdMismatch.validate_preset_semantic,validate_assets_in_bundleandvalidate_path_safetyall route through that mapper. - Impact: for a manifest with a slashed step id, validation emits
preset.id: inner graph \work_graph` step id `a/b` contains '/'— thepathnames the preset id and the category claims an id mismatch, while the fault isinner_graphs..nodes[i].id`. A reader following the diagnostic edits the wrong field first, and category-based consumers see an id-mismatch where there is none. It also pre-empts the document-level diagnostics the validation projection exists to produce. - Effort: XS
- Risk: LOW — one arm in
projection_refusalkeyed on the new refusal; otherNotProjectablecauses keep their existing mapping. - Confidence: MED — read the refusal site, the validation call sites and the mapper; did not verify whether a slashed step id is loader-rejectable (see seat note), so the validation path ma…
- Evidence:
-
Location:
crates/nexus-preset/src/workflow_ir.rs:309-312 -
Category: BUG
-
Merge class: may-fix
🟠 Export's slashed-step guard is enter-reference-scoped, so a manifest the adapter imports can fail to export
-
Evidence:
Evidencecrates/nexus-preset/src/workflow_ir.rs:307-314— import refuses only a slashed step id; it accepts every graph name verbatim, including a graph name that contains/and that no state ever enters.crates/nexus-preset/src/workflow_ir.rs:510—inner_step_nodebuildsid: format!("{graph_name}/{}", step.id)unconditionally; nothing requires a state to enter the graph.crates/nexus-preset/src/workflow_ir.rs:1004-1015—referenced_inner_graphssources the graph identity solely fromnode.enterInnerGraphreferences.crates/nexus-preset/src/workflow_ir.rs:1024-1039—refuse_slashed_steponly splits on a referenced graph prefix; with a prefix match it reads the remainder as the step and refuses when that remainder still contains/.crates/nexus-preset/src/workflow_ir.rs:1069-1078— the guard runs insideproject_nodesbefore the last-/projection, so the refusal is final for export.
Concrete failure (static, from the code above): manifest with
inner_graphs: { g: {nodes: [x]}, g/a: {nodes: [b]} }and one stateenter: {kind: inner_graph, name: g}.import_preset_bundleaccepts it and emits node idsg/xandg/a/b(:510).export_presetderivesreferenced_inner_graphs == ["g"](:1004-1015), matchesg/a/bagainstg, reads stepa/b, sees the remaining/, and returnsNotProjectable(:1024-1039, called at:1072).
So a document produced by this module's own importer cannot be exported by the same module — the reverse direction of the round-trip invariant the module doc states ("[
export_preset] rebuilds the manifest from those fields alone") and of the guarantee the new export test relies on ("A document built outside the adapter can carry a slashed step id; export refuses it rather than filing the step under a different graph",:2071-2074). The existing slashed-graph test (:2025-2053) only exercises a graph that is entered, which is exactly why it passes:lane/work_graphis prese… -
Location:
crates/nexus-preset/src/workflow_ir.rs:1072 -
Category: bug
-
Merge class: should-fix
Revalidated findings
Reassessed 5/15 prior finding(s) this round · 1 invalid-output · 9 omitted · 0 over cap · 15 recheckable · context coverage: truncated
| finding | disposition | evidence | thread |
|---|---|---|---|
Last-/ step rule silently renames a graph when a step id itself contains / |
addressed (verified-fix) | current-code | - |
Import silently drops an output_binding that names a whole node (no .field segment) |
addressed (verified-fix) | current-code | - |
| Export accepts an inner-step binding whose owner is no sibling step, emitting a manifest the new import path refuses | addressed (verified-fix) | current-code | - |
Last-segment split silently re-attributes valid inner-step ids that contain / |
unverifiable (invalid-output) | - | - |
| Import owner resolution is declaration-order dependent for nested dotted node ids and disagrees with the loader | addressed (verified-fix) | current-code | - |
Collision check silently skips binding claims on inner-step ids that are not <graph>/<step> |
addressed (verified-fix) | current-code | - |
| Unknown binding owner now refuses projection and suppresses A2/A3/A4 diagnostics, contradicting the deleted guarantee | unverifiable (budget) | - | - |
| Owner-defect reporting is limited to the first unknown-owner graph | unverifiable (budget) | - | - |
| Projection refusal moved into document_from_manifest hides asset/path diagnostics for every import_preset_manifest caller | unverifiable (budget) | - | - |
| Owner check derives the graph name from the node-id prefix, so an inner graph whose name contains '/' reports a phantom owner error | unverifiable (budget) | - | - |
| Scope declaration — not a defect (must not be tallied or posted) | unverifiable (no-evidence) | - | - |
Import drops a dotless output_binding that validation accepts, so export silently loses it |
unverifiable (budget) | - | - |
| New malformed-inner-step diagnostic uses a node-id dot path outside the document addressing convention | unverifiable (no-evidence) | - | - |
| New doc comment states the opposite of export behaviour: export.py refuses, it does not silently overwrite | unverifiable (budget) | - | - |
[BUG-01] Unowned inner-graph output_binding is now silently dropped by the non-validation projection path |
unverifiable (budget) | - | - |
Linked-issue AC
- I-000391 (Closes I-000391) — cut: the payload carries no issue body or acceptance criteria, so no individual criterion can be checked; only the PR-stated intent (one owner per inner-graph binding, a second claim is a named refusal) is reviewable against the diff.
✅ Verified
- Read the new import guard at crates/nexus-preset/src/workflow_ir.rs:307-314 (slashed_inner_step → WorkflowIrError::NotProjectable) and its tests import_refuses_a_step_id_with_a_slash and export_refuses_a_step_id_with_a_slash.
- Read export's refuse_slashed_step (:1024-1039) and its call site at project_nodes (:1069-1078), confirming the guard runs before the last-/ projection and is keyed on referenced_inner_graphs.
- Read referenced_inner_graphs (:1004-1015, sources only node.enter refs) and inner_step_node's unconditional format!("{graph_name}/{}", step.id) (:510), which together establish the should-fix failure input.
- Read the single-binding export refusal and the graph_steps pre-pass in project_nodes, plus the export_refuses_an_output_binding_whose_owner_is_no_step test.
- Read validation.rs:288-296 (projection_refusal) as the caller contract that maps the new NotProjectable to preset.id/IdMismatch when unknown_output_owner is None.
- ❓ cargo test -p nexus-preset, cargo fmt --check, cargo clippy -D warnings and the stated negative control are PR-body claims; the review document shows no command output.
- ❓ Whether a slashed inner-step id can pass loader.rs validation (i.e. whether the unmapped diagnostic is reachable from preset loading) was not traced.
- ❓ Whether export_preset callers outside crates/nexus-preset validate before exporting was not traced.
🗑️ Considered & rejected
- Export using referenced-graph prefixes instead of project_nodes' documented last-/-segment rule can refuse a hand-authored document whose graph names are path-prefixes (g referenced, g/a defined) even though the rsplit projection round-trips losslessly — rejected as a bounded, explicitly documented tradeoff: the rationale is stated on refuse_slashed_step and the IR encoding is genuinely ambiguous.
- Import and export guards being separate rules (manifest step ids vs document node ids) — rejected as duplication, since the inputs are genuinely different.
- The two # Errors doc blocks omitting the new refusal cause — rejected as documentation completeness, outside the review's defect bar.
🛠️ Plan to fix
Expand fix plan
1. **Fix the should-fix export guard** — `crates/nexus-preset/src/workflow_ir.rs` (`project_nodes` / `refuse_slashed_step`). Derive the graph-name candidate set from the projection itself (the `graph_steps` keys already built at `:1049-1056`) unioned with `referenced_inner_graphs`, longest name first, and pass that set to `refuse_slashed_step`; alternatively fall back to refusing a node id with a `/` past its last segment when no graph candidate matches. Keep the currently passing entered-graph behaviour.
2. **Add the regression test** — a manifest with `inner_graphs: { g: …, g/a: … }` and one state entering only `g` must import and then export back to the same manifest. Place it beside `import_and_export_round_trip_a_graph_name_with_a_slash`.
3. **Give the new refusal an attributable carrier** (may-fix BUG-01) — in `workflow_ir.rs`, add a dedicated `WorkflowIrError` variant carrying `(graph, step)` (or a slashed-step lookup analogous to `unknown_output_owner`) for the import guard.
4. **Map it in validation** — `crates/nexus-preset/src/validation.rs` `projection_refusal`: add an arm for the new variant reporting `inner_graphs.<graph>.nodes[i].id` with `DiagnosticCategory::Structural`, leaving other `NotProjectable` causes on their existing arms. Add a validation test asserting the path and category for a slashed-step manifest.
5. **Gates** — `cargo test -p nexus-preset`, `cargo fmt -p nexus-preset -- --check`, `cargo clippy -p nexus-preset --all-targets -- -D warnings`; re-run the stated negative control (remove the export guard → `export_refuses_a_second_output_binding_for_one_inner_graph` fails, restore, green); run the orchestration/core IR-consumer suites the PR body leaves to CI.…000391)
- One owner rule: `output_binding_owner` (the loader's `split('.').next()`) is shared by loader, import and validation; a dotless binding keeps its node.
- `validate_workflow_ir` reports two `output_binding` claims on one inner graph as a structural error, matching the export refusal.
- Tests: dotless import/export, owner segment, export collision, validation collision; each fix verified with a red negative control.
…(I-000391) - `document_from_manifest` refuses an `output_binding` whose loader-derived owner segment is no node (e.g. step `review.v2`, binding `review.v2.text`) instead of dropping the binding; `projection_refusal` reports it at that graph. - `check_inner_output_bindings` reports an inner step id that is not `<graph>/<step>` as a structural error, so a claim can no longer be skipped, and its doc states the export refusal instead of an overwrite. - Tests: dotted-id refusal, owner refusal at its graph, malformed inner step id; negative control on the refusal shows the binding dropped.
…s (I-000391) - Bundle import refuses an output binding whose owner names no step only after asset reads and the terminal count, so a missing or unsafe asset is reported first. - The manifest projection no longer refuses that shape: validate_preset_semantic reports it at its graph next to every other diagnostic, and document validation reports a claim whose owner is no sibling step. - Export refuses a binding whose owner names no step, the same shape import refuses, so a document cannot round-trip outward and fail inward. - Tests: unknown owner does not hide missing assets, binding owner with no node, export refusal; negative controls restore the early refusal and drop the export guard.
- `document_from_manifest` refuses an `output_binding` whose owner names no step again, so programmatic projections (nexus-core strategy candidates) fail closed; `import_preset_bundle` still reads assets and counts terminals before projecting, so a missing asset is reported first. - Inner graph/step split uses the last `/` segment, so a graph name containing `/` no longer turns the real owner into a phantom in export, validation or asset-reference paths. - Validation reports every graph with an unbound owner, in graph-name order, without duplicating the projection refusal's path. - Tests: projection refusal, bundle asset-before-owner ordering, slashed graph round trip, all-graphs collection; negative controls for each.
- Import refuses an inner step whose id contains '/', naming the graph and step id, so a document cannot enter the IR with an id that export would re-file under a graph no state enters. - Export refuses a projected id whose step segment still contains '/', using the graph names the document's states enter (longest prefix first) as the boundary; a programmatic document cannot leave with the step under the wrong graph. - Both use the existing Projectable refusal (no new WorkflowIrError variant, which nexus-core matches exhaustively). - Tests: import and export refusals; negative controls show the slashed id entering the IR and leaving as graph `work_graph/a`.
| // An inner graph exists as the `<graph>/<node>` prefix of its inner-step nodes, and the step is | ||
| // the last segment: a graph name may contain `/`. | ||
| // shortcut: a graph with zero nodes has no IR carrier and a reference to it reads as missing, | ||
| // upgrade: when the IR gains a graph record. | ||
| let inner_graph_names: BTreeSet<&str> = document | ||
| .nodes | ||
| .iter() | ||
| .filter(|node| node.kind == WorkflowNodeKind::InnerStep) | ||
| .filter_map(|node| node.id.split_once('/').map(|(graph, _)| graph)) | ||
| .filter_map(|node| node.id.rsplit_once('/').map(|(graph, _)| graph)) | ||
| .collect(); |
There was a problem hiding this comment.
Last-segment split silently re-attributes valid inner-step ids that contain / · 🟠 should-fix
[BUG-01] Last-segment split silently re-attributes valid inner-step ids that contain /
- Evidence:
crates/nexus-preset/src/validation.rs:472-481—check_inner_graph_referencesnow derives defined graph names withnode.id.rsplit_once('/')and states the justification in a line comment: "the step is the last segment: a graph name may contain/". Same change atvalidation.rs:540(check_inner_output_bindings) andvalidation.rs:904(collect_ir_asset_references). The mirror assumption is incrates/nexus-preset/src/workflow_ir.rs:988-996/:1009(other seat's file, context only). No validator anywhere restricts either half of the<graph>/<step>encoding:crates/nexus-preset/src/loader.rs:819-868checks only cycles,depends_onrefs,agentrefs and the binding owner;crates/nexus-contracts/src/local/orchestration/preset.rs:555-575declares graph-name keys as bareBTreeMap<String, _>andGraphNode.id: Stringwith the doc comment "Unique node ID within this inner graph" and no charset rule. - Impact: The encoding
<graph>/<step>is ambiguous and the diff resolves it for graph names by breaking step ids. A manifest that was accepted and validated before this change, e.g.inner_graphs: { g: { nodes: [{ id: "a/b", kind: acp_prompt }] } }with a state enteringg, now yields graph nameg/a:check_inner_graph_referencesemits a falseError"referenced inner graph 'g' is not defined" for the real reference plus a spuriousorphan_inner_graphwarning forg/a, and the projection path refuses the document outright (phantom "names owner" defect). The preset still runs, because the runtime resolvesmanifest.inner_graphs.get(name)directly (crates/nexus-preset/src/lib.rs:213), so validation now rejects a preset the executor accepts. Before the diff the opposite class (graph names containing/) was broken; the change moves…
| Err(error) => projection_refusal(manifest, &error), | ||
| } | ||
| }; | ||
| // A binding whose owner names no node has no document carrier, so the manifest scan reports | ||
| // every affected graph: the projection refusal names the first one, and a graph it did not | ||
| // reach is still reported once here. | ||
| check_manifest_output_bindings(manifest, &mut result); | ||
| result | ||
| } | ||
|
|
There was a problem hiding this comment.
Unknown binding owner now refuses projection and suppresses A2/A3/A4 diagnostics, contradicting the deleted guarantee · 🟠 should-fix
[BUG-02] Unknown binding owner now refuses projection and suppresses A2/A3/A4 diagnostics
- Evidence:
crates/nexus-preset/src/validation.rs:188-196—validate_preset_semanticstill entersprojection_refusal(manifest, &error)onErr, and the newWorkflowIrError::NotProjectablearm atvalidation.rs:275-286turns that into a single diagnostic;check_manifest_output_bindings(validation.rs:606-624) then only appends the other unbound graphs.crates/nexus-preset/src/validation.rs:218-229(validate_assets_in_bundle) andvalidation.rs:246-250(validate_path_safety) have the sameErr => projection_refusalcollapse, so with an unbound owner they return only the binding error, neverMissingAsset/path diagnostics. The diff deletes the test that pinned the opposite property —unknown_owner_does_not_hide_missing_assets(/workspace/pr.diffhunk@@ -1868,47 +1891,44 @@) asserted thatvalidate_assets_in_bundlestill reportsjudge.mdwhile the owner defect is present; its replacement (every_graph_with_an_unbound_owner_is_reported) asserts only the graph-name list fromvalidate_preset_semantic. The new bundle-side test coversimport_preset_bundle(which reads asset bytes before projecting), notvalidate_assets_in_bundle, which checks existence after projection. - Impact: A bundle with both a bad
output_bindingand a missing/escapingtemplate_filenow reports only the binding error through every YAML entry point, andcrates/nexus-preset/src/loader.rs:261-262(which callsvalidate_path_safety+validate_assets_in_bundlealongside the semantic result) loses the asset/path problems for that load. Likewisevalidate_preset_semanticno longer produces reachability, merge-integrity or capability-drift diagnostics in that state, sonexus42 preset validateand the daemon validate …
| if let Some((graph_name, binding, owner)) = unknown_output_owner(manifest) { | ||
| return Err(refuse(format!( | ||
| "inner graph `{graph_name}` output binding `{binding}` names owner `{owner}`, which is no node in the graph" | ||
| ))); | ||
| } |
There was a problem hiding this comment.
Projection refusal moved into document_from_manifest hides asset/path diagnostics for every import_preset_manifest caller · 🟠 should-fix
- Evidence:
crates/nexus-preset/src/workflow_ir.rs:307-311— the unknown-owner refusal now runs at the top ofdocument_from_manifest, before the header/id projection and before anything else, soimport_preset_manifestreturnsErrfor it.crates/nexus-preset/src/validation.rs:227(validate_assets_in_bundle) and:247(validate_path_safety) both route throughimport_preset_manifestand onErrreturn onlyprojection_refusal(...);crates/nexus-preset/src/loader.rs:261-262calls both as the A3 loader checks.crates/nexus-preset/src/loader.rs:456-486shows the loader's own template scan only collects paths forassert_template_file_safe, never file existence. - Impact: For a bundle that has both an unbound inner-graph
output_bindingand a missing template (e.g.prompts/judge.md), asset existence is no longer checked at all:validate_assets_in_bundleandvalidate_path_safetynow short-circuit to the binding refusal, so the loader path reports the missing asset only after the user fixes the binding and re-runs. The same short-circuit drops the invalid-preset.id/ judged-zero-rule diagnosticvalidate_preset_semanticused to report alongside the owner, and the loader path now emits the same binding diagnostic 2-3 times (two A3 calls plusloader.rs:861). This diff deleted the guard testunknown_owner_does_not_hide_missing_assets, which pinned exactly the first behaviour; the replacement test exercises onlyvalidate_preset_semantic, which never reads assets. - Effort: S
- Risk: LOW — keeping the owner refusal on the bundle-import path only (or having the A3 entry points report the refusal and still run the document-independent checks) restores the previous diagnostics without changing which presets are rejected.
- Confidence: HIGH (call graph and both entry points read dire…
| } | ||
| WorkflowNodeKind::InnerStep => { | ||
| let (graph, step_id) = node.id.split_once('/').ok_or_else(|| { | ||
| let (graph, step_id) = node.id.rsplit_once('/').ok_or_else(|| { |
There was a problem hiding this comment.
Last-/ step rule silently renames a graph when a step id itself contains / · 🟠 should-fix
- Evidence:
crates/nexus-preset/src/workflow_ir.rs:1009— export splits an inner-step node id withrsplit_once('/'), taking the last segment as the step;:994builds the per-graph step set the same way. Import joins withformat!("{graph_name}/{step.id}")at:482and:331with no separator check, andcrates/nexus-preset/src/loader.rs:819-866accepts anyGraphNode.idstring (exact-string compare only), so a step id containing/is a legal manifest. - Impact: For a user-authored preset with graph
gand step ida/b, import produces nodeg/a/b; export now derives graphg/aand stepb. With a binding fora/bthe owner check at:1018refuses a document thatimport_preset_manifestjust produced; without a binding, export silently emits a manifest naming a different graph (g/a) and a renamed step — a corrupt import→export round trip. The previoussplit_once('/')handled this shape correctly, so the diff trades one unsupported shape for another instead of rejecting the ambiguity. - Effort: S
- Risk: LOW — refusing an inner-graph step id (or graph name) that contains
/, or checking the joined id for separator collisions, only rejects manifests that currently round-trip wrong. - Confidence: HIGH (both split sites and the loader read; reachability needs a step id containing
/, absent from the in-repo presets) - Merge class: should-fix
- Fix sketch: Make the boundary unambiguous rather than picking a side: have validation/import refuse a step id containing
/with a named carrier, or keep the graph boundary outside the joined id; at minimum add a validation check so no accepted manifest can reach export with an ambiguous id.
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
4 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| fn refuse_slashed_step(node_id: &str, referenced_graphs: &[&str]) -> Result<(), WorkflowIrError> { | ||
| let Some((graph, step)) = referenced_graphs.iter().find_map(|graph| { | ||
| node_id | ||
| .strip_prefix(*graph) | ||
| .and_then(|rest| rest.strip_prefix('/')) | ||
| .map(|step| (*graph, step)) | ||
| }) else { | ||
| return Ok(()); | ||
| }; | ||
| if step.contains('/') { | ||
| return Err(refuse(format!( | ||
| "inner graph `{graph}` step id `{step}` contains '/'; an inner step id is a single segment" | ||
| ))); |
There was a problem hiding this comment.
🟡 Preset export rejects unused nested graphs
When a state enters work but not work/review, refuse_slashed_step misreads work/review/draft as a step in work. Graph validation recognizes work/review as a separate graph, but preset export rejects the entire bundle.
Learn more
The importer encodes inner steps as <graph>/<step>, and graph validation uses the last slash to find the graph name. Validation allows graphs that no state enters and reports them as warnings. The export guard instead guesses ownership using only graph names from enter actions, so a referenced prefix beats an unreferenced exact graph name. preset export aborts before writing YAML.
Example: Define work with step plan and work/review with step draft. Have a state enter only work. Exporting the imported document rejects work/review/draft as the supposed step review/draft in work, rather than restoring the work/review graph.
Recommended fix: Use the canonical last-slash split on export and retain the slash prohibition on manifest step IDs at import. If export must reject a missing entered graph, check that separately against the projected graph names rather than using a prefix to infer step ownership. Add a round-trip test with an entered graph and an unused graph whose name extends it.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if let Some((graph_name, step_id)) = slashed_inner_step(manifest) { | ||
| return Err(refuse(format!( | ||
| "inner graph `{graph_name}` step id `{step_id}` contains '/'; an inner step id is a single segment" | ||
| ))); |
There was a problem hiding this comment.
New slashed-step refusal is unmapped in projection_refusal, so validation reports it at preset.id as IdMismatch · 🟡 may-fix
[BUG-01] Map the new slashed-step NotProjectable refusal onto its own diagnostic carrier
- Evidence:
crates/nexus-preset/src/workflow_ir.rs:309-312— the added guard indocument_from_manifestreturnsrefuse(...), i.e.WorkflowIrError::NotProjectable(the new test atworkflow_ir.rs:2065asserts exactly that).document_from_manifestis the projection used by the validation entrypoint (import_preset_manifest, documented atworkflow_ir.rs:293-301as the projection that lets validation report defects on the document).crates/nexus-preset/src/validation.rs:288-296(projection_refusal, read only as the caller contract of the changed refusal) mapsNotProjectableto eitherinner_graphs.<graph>.output_binding/Structural— but only whenunknown_output_owner(manifest)isSome— or the fallback("preset.id", DiagnosticCategory::IdMismatch). For a manifest whose only defect is a slashed inner-step id,unknown_output_ownerisNone, so the diagnostic lands onpreset.idwith categoryIdMismatch.validate_preset_semantic,validate_assets_in_bundleandvalidate_path_safetyall route through that mapper. - Impact: for a manifest with a slashed step id, validation emits
preset.id: inner graph \work_graph` step id `a/b` contains '/'— thepathnames the preset id and the category claims an id mismatch, while the fault isinner_graphs..nodes[i].id`. A reader following the diagnostic edits the wrong field first, and category-based consumers see an id-mismatch where there is none. It also pre-empts the document-level diagnostics the validation projection exists to produce. - Effort: XS
- Risk: LOW — one arm in
projection_refusalkeyed on the new refusal; otherNotProjectablecauses keep their existing mapping. - Confidence: MED — read the refusal site, the valida…
| } | ||
| WorkflowNodeKind::InnerStep => { | ||
| let (graph, step_id) = node.id.split_once('/').ok_or_else(|| { | ||
| refuse_slashed_step(&node.id, &referenced_graphs)?; |
There was a problem hiding this comment.
Export's slashed-step guard is enter-reference-scoped, so a manifest the adapter imports can fail to export · 🟠 should-fix
Evidence
crates/nexus-preset/src/workflow_ir.rs:307-314— import refuses only a slashed step id; it accepts every graph name verbatim, including a graph name that contains/and that no state ever enters.crates/nexus-preset/src/workflow_ir.rs:510—inner_step_nodebuildsid: format!("{graph_name}/{}", step.id)unconditionally; nothing requires a state to enter the graph.crates/nexus-preset/src/workflow_ir.rs:1004-1015—referenced_inner_graphssources the graph identity solely fromnode.enterInnerGraphreferences.crates/nexus-preset/src/workflow_ir.rs:1024-1039—refuse_slashed_steponly splits on a referenced graph prefix; with a prefix match it reads the remainder as the step and refuses when that remainder still contains/.crates/nexus-preset/src/workflow_ir.rs:1069-1078— the guard runs insideproject_nodesbefore the last-/projection, so the refusal is final for export.
Concrete failure (static, from the code above): manifest with inner_graphs: { g: {nodes: [x]}, g/a: {nodes: [b]} } and one state enter: {kind: inner_graph, name: g}.
import_preset_bundleaccepts it and emits node idsg/xandg/a/b(:510).export_presetderivesreferenced_inner_graphs == ["g"](:1004-1015), matchesg/a/bagainstg, reads stepa/b, sees the remaining/, and returnsNotProjectable(:1024-1039, called at:1072).
So a document produced by this module's own importer cannot be exported by the same module — the reverse direction of the round-trip invariant the module doc states ("[export_preset] rebuilds the manifest from those fields alone") and of the guarantee the new export test relies on ("A document built outside the adapter can carry a slashed step id; export refuses it rather than filing the step under a different graph", :2071-2074). The existing slash…
Intent
Inner-graph output binding ownership was inferred by string reversal (
binding.rsplit_once('.')) and the reverse path inserted into a map, so two owners in one inner graph silently overwrote each other. Both directions now agree on one owner, and a second claim is a named refusal.Surface
crates/nexus-preset/src/workflow_ir.rs(+107 −5):output_bindingfor the same inner graph nowrefuses, naming the graph and both bindings (inner graphwork_graphcarries two output bindings (review.textanddraft.text); a graph exports exactly one);document_from_manifestresolves each graph's owner once (the step whose id prefixes the binding) and passesowns_output: boolintoinner_step_node; thersplit_once('.')derivation is gone (it turnedreview.output.textinto ownerreview.outputand dropped the binding silently);No IR schema change.
Verification
cargo test -p nexus-preset-> 249 lib + 2/4/2/2 targets, 0 failed; 1 doc-test ignored by convention.cargo fmt -p nexus-preset -- --checkclean;cargo clippy -p nexus-preset --all-targets -- -D warningsclean.export_refuses_a_second_output_binding_for_one_inner_graph; the failure output shows the exportedoutput_binding: Some("review.text")(the later claim won,draft.textlost). Restored byte-identically (sha256 checked), all green.Residual: the import-side owner is "the first step whose id prefixes the binding"; two step ids that are prefixes of each other (
aanda.b) would still take the first without an ambiguity error — kept insideworkflow_ir.rsso the refusal is not misreported aspreset.id IdMismatchbyvalidation.rs::projection_refusal. The new export refusal turns a previously-silent IR into an error on the orchestration/core IR consumption paths; those suites are left to CI.Closes I-000391.