Skip to content

Expose circuit path device refs + the rendered diagram in JSON - #69

Merged
lance0 merged 1 commit into
masterfrom
feat/circuit-json-device-refs
Jun 23, 2026
Merged

lance0 merged 1 commit into
masterfrom
feat/circuit-json-device-refs

Conversation

@lance0

@lance0 lance0 commented Jun 23, 2026

Copy link
Copy Markdown
Owner

What

Two agent-facing additions to the circuit cable-path JSON (follow-up to #68):

  1. Device refs in the path — each hop in terminations[].path now serializes a device ref ({id, name}), so an agent can navigate straight to the device (nbox_get kind=device ref=<id|name>) instead of parsing it out of the to display label.
  2. The rendered diagram — the A↔Z ASCII 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 BriefObject on PathHop with a small serializable DeviceRef { id, name }, and un-skips CircuitView.diagram (skip-when-empty). Both flow through every JSON surface for free — CLI -o json, MCP nbox_get, and the nbox://circuit/{ref} resource — since they share the one CircuitView serialization. The structured terminations stay the navigation form; the diagram is the render-for-humans form.

Tests

  • serializes_device_refs_and_the_diagram — asserts path[].device.{id,name} and a non-empty diagram array in the serialized view.
  • The walker integration test now asserts the resolved hop carries the device ref.

Gate

cargo fmt --check, clippy --all-targets --all-features -D warnings, clippy --no-default-features, and cargo test in both feature modes — all green.

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.
@lance0
lance0 merged commit 27b312a into master Jun 23, 2026
4 checks passed
@lance0
lance0 deleted the feat/circuit-json-device-refs branch June 23, 2026 17:41
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.

1 participant