Repository navigation
Expose circuit path device refs + the rendered diagram in JSON - #69
Merged
Merged
Conversation
Each cable-path hop now serializes a `device` ref (`{id, name}`) so an agent can
navigate straight to the device (nbox_get kind=device), instead of parsing it out
of the display label. And the rendered A↔Z `diagram` (array of lines) is now
serialized too — so an agent or script can show the art to a user verbatim rather
than rebuilding it from the structured terminations.
Flows through every JSON surface (CLI -o json, MCP nbox_get, the
nbox://circuit/{ref} resource), since they share the one CircuitView
serialization. Introduces a small DeviceRef view type (replaces the skipped
BriefObject on PathHop). Tests: JSON serialization of device refs + diagram, and
the integration walker asserts the resolved hop's device ref.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two agent-facing additions to the circuit cable-path JSON (follow-up to #68):
terminations[].pathnow serializes adeviceref ({id, name}), so an agent can navigate straight to the device (nbox_get kind=device ref=<id|name>) instead of parsing it out of thetodisplay label.diagram(array of lines) is now serialized too, so an agent or script can show the art to a user verbatim rather than rebuilding it from the structured terminations.Example (
nbox circuit <cid> -o json):{ "cid": "ACME-1001", "terminations": [ { "side": "A", "endpoint": "DC1", "endpoint_kind": "site", "path": [ { "to": "edge-1 xe-0/0/0", "cable": "#200", "endpoint": true, "device": { "id": 8, "name": "edge-1" } }, { "to": "panel-1 7", "cable": "#100", "endpoint": false, "device": { "id": 9, "name": "panel-1" } } ] }, { "side": "Z", "endpoint": "ACME Cloud", "endpoint_kind": "provider network" } ], "diagram": [ " A DC1 (site)", " ↳ edge-1 xe-0/0/0 · #200", " ↳ panel-1 7 · #100", " │", " ┿ Wave · 10 Gbps · Active", " │", " Z ACME Cloud (provider network)" ] }How
Replaces the skipped
BriefObjectonPathHopwith a small serializableDeviceRef { id, name }, and un-skipsCircuitView.diagram(skip-when-empty). Both flow through every JSON surface for free — CLI-o json, MCPnbox_get, and thenbox://circuit/{ref}resource — since they share the oneCircuitViewserialization. The structuredterminationsstay the navigation form; thediagramis the render-for-humans form.Tests
serializes_device_refs_and_the_diagram— assertspath[].device.{id,name}and a non-emptydiagramarray in the serialized view.deviceref.Gate
cargo fmt --check,clippy --all-targets --all-features -D warnings,clippy --no-default-features, andcargo testin both feature modes — all green.