Skip to content

Cut: around one resource or root, by depth and direction #1067

Closed

Description

@lex00

A cut that keeps one resource, or every resource in one root, plus its neighbours to a given depth, upstream, downstream or both. The Backstage tab, the MCP tool and the Grafana recipe all need it. Part of #1049, phase 2.

Today

  • chant has the lens blast:<id> with --up and --down (packages/core/src/graph-lens.ts in chant), a transitive closure with no depth limit. On the scoping slice it kept 13 of 342 nodes around one GKE cluster. The generic walk is packages/core/src/graph-walk.ts.
  • chant workspace graph has no --lens, and behold sends lens reads to the member's own chant graph (workspaceGraphTakes, src/workspace.ts:297).
  • A static export draws only views captured at export time.
  • Cut: changed between two revisions, plus neighbours #1059 adds the other cut, changed between two revisions.

Change

  • cutAround(doc, ids, { depth = 1, up = true, down = true }) over a behold-graph/1 document: a walk bounded by depth, keeping every kept node's box, marking the seeds, and setting cut: { kind: "around", ids, depth, direction }.
  • An id may name a box (a Terraform root). That seeds the cut with every node in the box, which is the slice the Backstage tab asks for.
  • Keep an edge only when both ends are kept. Count dropped neighbours per box in notes.
  • The module imports nothing from node:*, so a browser host can call it on a fetched document. A test checks its module graph, as Move the graph pipeline out of server.ts into a library with no Hono and no global state #1057 does for Hono.
  • behold graph --around <id>[,<id>...] [--depth n] [--up | --down]. An unknown id exits non-zero and names it.

Done when

  • On example-terraform-estate, behold graph --around <resource id> --depth 1 --json | jq '.nodes | length' prints the count a test fixes by hand for that resource and its direct neighbours.
  • On a three-node chain, --up keeps only what the seed depends on and --down only what depends on it (test).
  • --around <root box id> keeps every node of that root.
  • --around no-such-id exits non-zero and prints the id.
  • The no-node: import test passes.

Depends on

"behold-graph/1 document and schema". The --around flag waits on #1058. The function itself can be written against the document types before #1057 applies.

Not in this issue

The changed cut (#1059). A cut inside today's exported app, which reads captured snapshots only.

Activity

  1. added
    wave:2
    epic:surfaces
    on Nov 15, 2026
  2. lex00 commented on Nov 15, 2026

    @lex00
    ContributorAuthor

    The browser cut keyed by Kubernetes identity is filed separately for phase 4 and can start with no dependencies. The two share one walk: whichever applies second wraps the first, so there is one cutAround in the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic:surfaceswave:2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions