Skip to content

feat(server): focused neighborhood mode on workspace graph endpoint (TASK-1781) - #718

Merged
xarmian merged 2 commits into
mainfrom
feat/graph-focus-neighborhood
Jun 8, 2026
Merged

feat(server): focused neighborhood mode on workspace graph endpoint (TASK-1781)#718
xarmian merged 2 commits into
mainfrom
feat/graph-focus-neighborhood

Conversation

@xarmian

@xarmian xarmian commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds ?focus=REF&depth=N to GET /api/v1/workspaces/{ws}/graph. In focus mode the endpoint BFS-traverses typed edges (undirected) out from the given item up to depth hops (default 2, clamped to [1,5]) and returns just that neighborhood's nodes + edges. Without focus, the whole-workspace behavior is byte-for-byte unchanged.

This is the backend foundation for the per-item dependency graph view (PLAN-1780).

Details

  • Focus node always included, even when terminal — you explicitly asked to view it. Neighbors honor the existing include_terminal filter.
  • Visibility-safe: the neighborhood is intersected with the visibility-filtered item set, so a guest can't infer hidden items from dangling edges (same posture as the whole-workspace path).
  • Truncation: node-count cap (maxFocusNodes=200) stops BFS expansion early (closest nodes first) and sets a new GraphResponse.Truncated flag. The flag is omitempty, so the whole-workspace payload shape is unchanged for the existing 3D view.
  • Unknown/invisible focus ref → 404.
  • depth clamped server-side; a huge value resolves the full reachable chain rather than erroring.

Context

Implements TASK-1781 under PLAN-1780 (per-item dependency graph view). TS types + client params are the follow-up TASK-1782.

Test plan

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./... — all pass
  • New tests: depth bounds + clamping, both-direction traversal, terminal focus inclusion, terminal-neighbor filtering, cross-collection typed edges, unknown-ref 404, truncation
  • [n/a] web build — backend-only change

xarmian added 2 commits June 8, 2026 22:06
…TASK-1781)

Add ?focus=REF&depth=N to GET /workspaces/{ws}/graph. When focus is set,
BFS-traverse typed edges (undirected) out from the ref up to depth hops
(default 2, clamped to [1,5]) and return only that neighborhood's nodes +
edges. Without focus the whole-workspace behavior is unchanged.

- The focused item is always included, even when terminal (you asked to
  view it); neighbors honor the existing include_terminal filter.
- Neighborhood is intersected with the visibility-filtered item set, so a
  guest can't infer hidden items from dangling edges.
- Node-count cap (maxFocusNodes=200) stops BFS expansion early and sets a
  new GraphResponse.Truncated flag (omitempty — whole-workspace payload
  shape unchanged) so the client can offer expand-on-click.
- An unknown/invisible focus ref returns 404.

Tests: depth bounds + clamping, both-direction traversal, terminal focus
node inclusion, terminal-neighbor filtering, cross-collection typed edges,
unknown ref 404, and truncation.

Parent: PLAN-1780.
… (round 1)

In focus mode child_count was derived from the depth/cap-filtered edge
set, so a boundary parent whose children fell outside the neighborhood
reported child_count=0. The web UI gates hub-label and children-pill
visibility on child_count > 0, so those would wrongly hide.

Count children over the full visible item set instead (terminal filter
on the child preserved), independent of the focus subgraph. This also
reproduces the whole-workspace semantics exactly. Added a regression
test (focused parent with a child beyond depth still reports count=1).

Parent: PLAN-1780.
@xarmian
xarmian merged commit 3c3016a into main Jun 8, 2026
4 checks passed
@xarmian
xarmian deleted the feat/graph-focus-neighborhood branch June 8, 2026 22:13
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