feat(facts): add PairwiseLinkMatrix for directional network topology - #266
Merged
Conversation
Fills the 1B gap from the v0.14.7 optimization spec audit: the spec
described a PairwiseLinkMatrix / LinkMetric data structure that did not
exist anywhere in the codebase. This adds it for real.
Types (internal/models/types.go):
- PairwiseLinkMatrix{ Links []LinkMetric }
- LinkMetric{ SourceNode, TargetNode, OverlayType, RTTLatencyP95, ThroughputMBps }
- ClusterSnapshot gains an optional Topology *PairwiseLinkMatrix field.
Builder (internal/facts/pairwise.go):
- BuildPairwiseLinkMatrix probes directional RTT from the local node to
each remote node's ResolvedDialTarget (fallback SSHTarget) via ICMP ping,
parses the max RTT from the ping summary as a P95 stand-in, and infers
the overlay from the address shape (100.* → tailscale, 169.254.* →
thunderbolt, else lan).
- Single-vantage model: only local→remote is probed; cross-remote edges
are not measured. Throughput left at 0 (unmeasured) in this first cut.
- Best-effort: unreachable nodes or missing ping are omitted, not fatal.
- TopologySummary helper for logging.
Verified:
- Unit tests: parseRTTP95 (3 cases), inferOverlay (5 cases), no-local-node
edge case, skip-local-self + skip-empty-target, TopologySummary empty/
non-empty. All pass.
- Live smoke test on cranium: cranium→loopback-target lan 27µs captured
end-to-end via real ping.
- Full facts + models suites pass; go build ./... clean.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Summary
Fills the 1B gap from the v0.14.7 optimization spec audit: the spec described a `PairwiseLinkMatrix` / `LinkMetric` data structure that did not exist anywhere in the codebase. This adds it for real — a first cut that measures what's actually measurable from a single vantage.
Types (`internal/models/types.go`)
```go
type PairwiseLinkMatrix struct {
Links []LinkMetric
}
type LinkMetric struct {
SourceNode string
TargetNode string
OverlayType string // lan | tailscale | thunderbolt
RTTLatencyP95 time.Duration
ThroughputMBps float64 // 0 = unmeasured in this cut
}
```
`ClusterSnapshot` gains an optional `Topology *PairwiseLinkMatrix` field (zero-value-safe; existing consumers unaffected).
Builder (`internal/facts/pairwise.go`)
`BuildPairwiseLinkMatrix(ctx, localName, nodes)`:
`TopologySummary(m)` helper for logging.
Verification
Scope notes
Related
Follows #264 (MCP tools, 4B) and #265 (local VRAM sampling, 1A). Completes the three real gaps flagged in the spec audit.