Skip to content

fix(preset): refuse two inner-graph output bindings and derive ownership structurally (I-000391) - #695

Open
auto-wood wants to merge 6 commits into
mainfrom
fix/i-000391-inner-binding-owner-collision
Open

auto-wood wants to merge 6 commits into
mainfrom
fix/i-000391-inner-binding-owner-collision

Conversation

@auto-wood

Copy link
Copy Markdown
Contributor

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):

  • export: a second output_binding for the same inner graph now refuses, naming the graph and both bindings (inner graph work_graph carries two output bindings (review.textanddraft.text); a graph exports exactly one);
  • import: document_from_manifest resolves each graph's owner once (the step whose id prefixes the binding) and passes owns_output: bool into inner_step_node; the rsplit_once('.') derivation is gone (it turned review.output.text into owner review.output and dropped the binding silently);
  • three tests: single owner exports, two owners refused (message names graph and both bindings), dotted field path still belongs to its step.

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 -- --check clean; cargo clippy -p nexus-preset --all-targets -- -D warnings clean.
  • Negative control: removing the export refusal fails export_refuses_a_second_output_binding_for_one_inner_graph; the failure output shows the exported output_binding: Some("review.text") (the later claim won, draft.text lost). 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 (a and a.b) would still take the first without an ambiguity error — kept inside workflow_ir.rs so the refusal is not misreported as preset.id IdMismatch by validation.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.

- 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.
devin-ai-integration[bot]

This comment was marked as resolved.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · Fix the loss of bare step-ID output bindings before merging.RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P1 Bare output bindings disappear ▶
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.

Summary

The PR rejects a second output binding within one inner graph and changes import to preserve dotted field paths.

  • Inner graph bindings stay with the step named at the start.
  • Export refuses inner graphs with two output bindings.

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

greptile-apps[bot]

This comment was marked as resolved.

@m-inspector

m-inspector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ Verdict: needs fixes · Score 82% (good)

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 NotProjectable refusal onto its own diagnostic carrier

    • Evidence: crates/nexus-preset/src/workflow_ir.rs:309-312 — the added guard in document_from_manifest returns refuse(...), i.e. WorkflowIrError::NotProjectable (the new test at workflow_ir.rs:2065 asserts exactly that). document_from_manifest is the projection used by the validation entrypoint (import_preset_manifest, documented at workflow_ir.rs:293-301 as 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) maps NotProjectable to either inner_graphs.<graph>.output_binding/Structural — but only when unknown_output_owner(manifest) is Some — or the fallback ("preset.id", DiagnosticCategory::IdMismatch). For a manifest whose only defect is a slashed inner-step id, unknown_output_owner is None, so the diagnostic lands on preset.id with category IdMismatch. validate_preset_semantic, validate_assets_in_bundle and validate_path_safety all 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_refusal keyed on the new refusal; other NotProjectable causes 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…
  • 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:
    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_node builds id: 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_graphs sources the graph identity solely from node.enter InnerGraph references.
    • crates/nexus-preset/src/workflow_ir.rs:1024-1039 — refuse_slashed_step only 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 inside project_nodes before 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_bundle accepts it and emits node ids g/x and g/a/b (:510).
    • export_preset derives referenced_inner_graphs == ["g"] (:1004-1015), matches g/a/b against g, reads step a/b, sees the remaining /, and returns NotProjectable (: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_graph is 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 &lt;graph>/&lt;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.

Review 6 · commit 8b93e1a · since 4b668e1

m-inspector[bot]

This comment was marked as resolved.

…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.
devin-ai-integration[bot]

This comment was marked as resolved.

m-inspector[bot]

This comment was marked as resolved.

…(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.
devin-ai-integration[bot]

This comment was marked as resolved.

m-inspector[bot]

This comment was marked as resolved.

…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.
devin-ai-integration[bot]

This comment was marked as resolved.

m-inspector[bot]

This comment was marked as resolved.

- `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.
devin-ai-integration[bot]

This comment was marked as resolved.

- 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`.

@m-inspector m-inspector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mstar-inspector line comments · round 5 · 4b668e1

Comment on lines +472 to 481
// 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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_references now derives defined graph names with node.id.rsplit_once('/') and states the justification in a line comment: "the step is the last segment: a graph name may contain /". Same change at validation.rs:540 (check_inner_output_bindings) and validation.rs:904 (collect_ir_asset_references). The mirror assumption is in crates/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-868 checks only cycles, depends_on refs, agent refs and the binding owner; crates/nexus-contracts/src/local/orchestration/preset.rs:555-575 declares graph-name keys as bare BTreeMap<String, _> and GraphNode.id: String with 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 entering g, now yields graph name g/a: check_inner_graph_references emits a false Error "referenced inner graph 'g' is not defined" for the real reference plus a spurious orphan_inner_graph warning for g/a, and the projection path refuses the document outright (phantom "names owner" defect). The preset still runs, because the runtime resolves manifest.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…

Comment on lines 188 to 196
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
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_semantic still enters projection_refusal(manifest, &error) on Err, and the new WorkflowIrError::NotProjectable arm at validation.rs:275-286 turns 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) and validation.rs:246-250 (validate_path_safety) have the same Err => projection_refusal collapse, so with an unbound owner they return only the binding error, never MissingAsset/path diagnostics. The diff deletes the test that pinned the opposite property — unknown_owner_does_not_hide_missing_assets (/workspace/pr.diff hunk @@ -1868,47 +1891,44 @@) asserted that validate_assets_in_bundle still reports judge.md while the owner defect is present; its replacement (every_graph_with_an_unbound_owner_is_reported) asserts only the graph-name list from validate_preset_semantic. The new bundle-side test covers import_preset_bundle (which reads asset bytes before projecting), not validate_assets_in_bundle, which checks existence after projection.
  • Impact: A bundle with both a bad output_binding and a missing/escaping template_file now reports only the binding error through every YAML entry point, and crates/nexus-preset/src/loader.rs:261-262 (which calls validate_path_safety + validate_assets_in_bundle alongside the semantic result) loses the asset/path problems for that load. Likewise validate_preset_semantic no longer produces reachability, merge-integrity or capability-drift diagnostics in that state, so nexus42 preset validate and the daemon validate …

Comment on lines +307 to +311
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"
)));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 of document_from_manifest, before the header/id projection and before anything else, so import_preset_manifest returns Err for it. crates/nexus-preset/src/validation.rs:227 (validate_assets_in_bundle) and :247 (validate_path_safety) both route through import_preset_manifest and on Err return only projection_refusal(...); crates/nexus-preset/src/loader.rs:261-262 calls both as the A3 loader checks. crates/nexus-preset/src/loader.rs:456-486 shows the loader's own template scan only collects paths for assert_template_file_safe, never file existence.
  • Impact: For a bundle that has both an unbound inner-graph output_binding and a missing template (e.g. prompts/judge.md), asset existence is no longer checked at all: validate_assets_in_bundle and validate_path_safety now 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 diagnostic validate_preset_semantic used to report alongside the owner, and the loader path now emits the same binding diagnostic 2-3 times (two A3 calls plus loader.rs:861). This diff deleted the guard test unknown_owner_does_not_hide_missing_assets, which pinned exactly the first behaviour; the replacement test exercises only validate_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(|| {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with rsplit_once('/'), taking the last segment as the step; :994 builds the per-graph step set the same way. Import joins with format!("{graph_name}/{step.id}") at :482 and :331 with no separator check, and crates/nexus-preset/src/loader.rs:819-866 accepts any GraphNode.id string (exact-string compare only), so a step id containing / is a legal manifest.
  • Impact: For a user-authored preset with graph g and step id a/b, import produces node g/a/b; export now derives graph g/a and step b. With a binding for a/b the owner check at :1018 refuses a document that import_preset_manifest just 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 previous split_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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

4 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +1024 to +1036
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"
)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@m-inspector m-inspector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mstar-inspector line comments · round 6 · 8b93e1a

Comment on lines +309 to +312
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"
)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in document_from_manifest returns refuse(...), i.e. WorkflowIrError::NotProjectable (the new test at workflow_ir.rs:2065 asserts exactly that). document_from_manifest is the projection used by the validation entrypoint (import_preset_manifest, documented at workflow_ir.rs:293-301 as 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) maps NotProjectable to either inner_graphs.<graph>.output_binding/Structural — but only when unknown_output_owner(manifest) is Some — or the fallback ("preset.id", DiagnosticCategory::IdMismatch). For a manifest whose only defect is a slashed inner-step id, unknown_output_owner is None, so the diagnostic lands on preset.id with category IdMismatch. validate_preset_semantic, validate_assets_in_bundle and validate_path_safety all 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_refusal keyed on the new refusal; other NotProjectable causes 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)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_node builds id: 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_graphs sources the graph identity solely from node.enter InnerGraph references.
  • crates/nexus-preset/src/workflow_ir.rs:1024-1039 — refuse_slashed_step only 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 inside project_nodes before 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_bundle accepts it and emits node ids g/x and g/a/b (:510).
  • export_preset derives referenced_inner_graphs == ["g"] (:1004-1015), matches g/a/b against g, reads step a/b, sees the remaining /, and returns NotProjectable (: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…

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.

2 participants