24 Commits
Author SHA1 Message Date
ErfanandClaude Opus 4.8 6e108c8cd6 feat: 5s configurable metrics refresh + per-context auth resilience (#27)
Two robustness fixes from real-cluster use.

Metrics refresh: was hardcoded to 15s. Now `runtime.metrics_interval_secs`
(default 5s — k9s polls every 2s; ours is bounded by metrics-server's ~15s
sample resolution, so 5s is live without hammering the API on large fleets).
Threaded through run()/App::new.

Per-context auth resilience: a context that can't authenticate (expired SSO /
exec-auth failure) no longer aborts the whole app at startup. Provider client
warmup is best-effort (logs a warning, doesn't propagate), and replace_watch_plan
records a per-context StateDelta::Error — surfaced as [XX] with the auth
message — instead of failing the call. Other clusters stay fully usable, and the
broken context recovers on a later watch tick once credentials refresh.

Tests: bad-context watch plan records an error delta and returns Ok.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 02:24:09 +02:00
ErfanandClaude Opus 4.8 b4620a78b3 refactor(ui): title/header/sort consistency + graduated right-sizing colors (#25)
* refactor(ui): unify panel titles, column-header casing, and sort order

Naming-convention consistency pass across the whole UI.

Panel/overlay titles → one convention: `[TAG] subject (count) · meta… · hints…`
- single `·` separator everywhere (drop `|` and `(parenthetical, lists)`)
- full-word uppercase tags: table uses the kind ([PODS]/[DEPLOYMENTS]/…), plus
  [DRILL] [XRAY] [TRIAGE] [TEXT] [CONTEXTS] [CONTAINERS] [SOURCES] [LOGS]
  [DESCRIBE]/[DECODE]/[EVENTS] [PULSE]
- counts in (n); meta as lowercase `key: value`; hints lowercase, `esc close` last
- dropped the now-unused `title` field from the Contexts/LogSources overlays

Column headers → one casing rule across every table (main, pods, per-kind,
triage, events pane, overlays, :dump export): plain words use Title case
(Namespace, Node, Ready, Restarts, Reason), acronyms stay uppercase (CPU, MEM,
IP), formula columns kept as-is (%CPU/R). Fixes NODE→Node, RST→Restarts, the
ALL-CAPS per-kind columns, the triage and events headers (CNT→Count), and the
lowercase dump export.

Sort: `s` now advances in left-to-right table-column order
(Namespace→Name→Status→Age→Namespace) instead of an arbitrary jump.

Tests updated for the new title/header strings; added a cycle_sort order test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(ui): graduated severity coloring for right-sizing % columns

The %R/%L pod columns each used a single color — %R only ever went yellow (never
red, even at 400% of request), and %L jumped straight to red at ≥90% with no
"approaching" warning. Make both a green→yellow→red gradient:

- %CPU/R, %MEM/R (vs request): ok <100 · yellow ≥100 (under-requested) ·
  red ≥200 (severely under-requested — QoS/scheduling risk)
- %CPU/L, %MEM/L (vs limit): ok <75 · yellow ≥75 (approaching) ·
  red ≥90 (throttle/OOM risk)

Test: pod_usage_cells severity thresholds for both columns.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: record deferred over-provisioned right-sizing signal (5.7)

Capture the decision to defer the low-%R (over-provisioned) coloring until we
track per-pod usage history (p95/max); a snapshot-based waste flag would
false-alarm on momentary idle dips.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 00:37:30 +02:00
ErfanandClaude Opus 4.8 dadb18d10c feat(ui): operator triage board + richer pods table columns (#24)
Triage board (`:triage`/`:issues [namespace|all]`): a live, worst-first board of
only the pods needing an operator's attention — CrashLoopBackOff/OOMKilled/
ImagePullBackOff/Error (critical), Pending/NotReady/restart-hot ≥3 (warning).
Healthy pods are omitted; the title summarizes `N critical · M warning`; capped
at 500 rows worst-first. Rebuilt from store state each frame; navigate j/k+g/G,
esc closes. This is the daily-driver "is anything wrong, and where" view.

Pods table gained the columns operators expect:
RST · CPU · %CPU/R · %CPU/L · MEM · %MEM/R · %MEM/L · IP · NODE. RST (container
restarts) colors yellow at ≥3, red at ≥10. Metric headers are the explicit
%CPU/R-style form.

Model: add `restarts`, `ready`, and `pod_ip` to the lean `Extracted` (the
crashloop/readiness/IP signals the status string and prior columns lacked).
Also fixed `classify_status_severity` to flag `*BackOff`/`ImagePullBackOff` as
critical (was silently Ok) — corrects table coloring too.

Tests: restart/readiness/IP extraction; triage selection + worst-first ordering
+ counts; pods table renders RST/IP/NODE and the percentage columns.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 00:06:06 +02:00
ErfanandClaude Opus 4.8 fce242df7c feat(ui): xray cluster ownership graph (#23)
`:xray [namespace|all]` opens a live ownership graph, replacing the old stub
and closing gap #3 from the k9s parity audit (4.7). Rather than a per-kind tree,
it's a single namespace-rooted forest of the workload topology:

  ns/<name>
  ├─ deploy → rs → pod → container
  ├─ sts / ds → pod → container
  ├─ cronjob → job → pod
  ├─ job / bare rs → pod
  └─ standalone pods (no controller)

`:xray` defaults to the current namespace; `:xray all` spans the cluster grouped
by namespace.

Rendering is a real tree, not indented text: box-drawing connectors
(├──/└──/│), ▾/▸ expand markers, severity-colored per-node status, and a
selectable cursor. Navigate j/k (+ g/G); →/← expand/collapse the node under the
cursor, Enter toggles, esc closes. Collapse state is keyed by stable node id so
it survives the per-frame rebuild.

The graph rebuilds from store state every frame so it tracks the cluster live;
opening it adds the workload kinds it draws to the active watch plan so it fills
in within a moment. Large graphs truncate with `… N more` nodes (no silent
caps). Cross-cutting relations (Service/PVC/ConfigMap/Node — non-ownership,
multi-parent edges that don't fit a tree) are intentionally left to the Enter
drill-down and describe views.

Reuses the existing owner-chain helpers (the log fan-in's
deployment/replicaset/pod key lookups).

Tests: namespace-rooted tree structure + connectors + expand marker; collapse
hides a subtree; arrow-key directed collapse/expand.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 23:05:21 +02:00
ErfanandClaude Opus 4.8 08f1dc5f7f feat(ui): previous-instance logs toggle (P) (#22)
In the logs pane, `P` (shift+p) toggles between the current and the previous
(terminated) container instance's logs — `kubectl logs -p`, for debugging
crashlooping containers. Closes gap #2 from the k9s parity audit (4.7).

- One-shot fetch: previous logs don't follow and don't auto-reconnect (the
  container is gone), so the reconnect loop is skipped while previous is active.
- Refetches on toggle (clears the buffer); a fresh log view always starts on the
  current instance.
- Status line shows `instance:current|previous`.

The PodLogRequest.previous plumbing already existed; this wires the UI to it.

Test: toggle flips the flag, resets the buffer, and the title reflects the
instance.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 18:02:08 +02:00
ErfanandClaude Opus 4.8 3b0992bc36 feat(ui): Enter drill-down from owners to their pods (#21)
* feat(ui): Enter drill-down from owners to their pods

Enter on a Deployment/ReplicaSet/StatefulSet/DaemonSet now opens a Pods view
scoped to that owner's pods; Enter on a Node shows the pods scheduled on it.
Closes the top gap from the k9s readonly parity audit (4.7).

- Live filter, not a snapshot: a DrillFilter on ViewRequest is applied in the
  projector, so rollouts/new pods appear/disappear in real time. Deployment
  ownership is resolved transitively through the pod's ReplicaSet (reusing the
  owner chain the log fan-in relies on); other workloads and Node match directly
  (ownerReferences / scheduled node).
- The Pods title shows `[DRILL] <owner> → Pods`; `esc` pops back to the owner's
  list (krust has no view stack). Drill clears on any kind/namespace change.
- Leaf kinds keep the previous behavior (Enter → describe; namespace → its
  resources).

svc→endpoints drill deferred (needs the service selector, not currently
extracted) — noted in the audit/ROADMAP.

Tests: projector owner-chain/node filtering, and an Enter→drill render
integration test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(ui): resolve deployment drill-down showing zero pods

The deployment→pod chain resolves transitively through each pod's ReplicaSet,
but ReplicaSets were only watched in the Logs pane — during a drill the active
kind is Pods (Table pane), so the RS were never loaded and every pod was
filtered out (zero pods).

Two-part fix:
- Watch ReplicaSets for the drilled namespace while a Deployment drill is active,
  so the chain resolves authoritatively from store state.
- Add a name-convention fallback in DrillFilter: a deployment's RS is always
  named `<deploy>-<pod-template-hash>` (hash has no `-`), so pods match
  immediately even before the RS watch populates or if RS are RBAC-denied. The
  no-`-` check keeps `web` from matching `web-api`'s ReplicaSets.

Test: projector deployment drill now covers a pod whose RS is absent from the
store (name-fallback path).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 17:47:08 +02:00
ErfanandClaude Opus 4.8 be20e8edfb docs: k9s readonly parity audit (4.7) (#20)
Enumerate the full k9s readonly surface (keybindings + colon commands, grounded
in the k9s README/docs) against krust, marking each present / partial / missing
/ scoped-out. Mutations are explicitly out of scope for the readonly-first v1.

Identifies the prioritized gaps to close, highest value first: Enter
drill-down (deploy/node/svc → children), previous logs, xray tree view; then
jump-to-owner, UsedBy, log timestamps, metric-column sort. popeye and the
pulses dashboard flagged as decide/likely-scope-out.

ROADMAP 4.7 updated with the findings and next-step ordering.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 15:20:33 +02:00
ErfanandClaude Opus 4.8 8e9f425e32 feat(ui): hide Helm release secrets by default, with toggle (#19)
Helm 3 stores release state as Secrets (type helm.sh/release.v1, names
sh.helm.release.v1.<release>.v<n>). These dominate the Secrets list and are
rarely what an operator wants to see.

- Hidden by default at the projection layer (Secrets view only).
- Toggle per-context-tab with `H` (Action::ToggleHelmSecrets, remappable) or
  `:helm`; `:helm show` / `:helm hide` set state explicitly.
- The Secrets table title advertises current state and the toggle key, so the
  hidden rows are never a surprise.

Detection lives in ResourceEntity::is_helm_release() (matches the helm type
column or the sh.helm.release.v1. name prefix), keeping the projector clean.

Tests: model detection (type/name/negative/non-secret), projector hide-by-
default + show-on-request, and a render+toggle integration test.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 13:36:19 +02:00
ErfanandClaude Opus 4.8 8cbe27e7f3 feat(ui): per-kind table columns for non-pod resources (#18)
* feat(ui): per-kind table columns for non-pod resources

Non-pod views collapsed every resource to a single loose "Summary" string
(label count / service type / "-"). Replace it with meaningful, fixed-width,
kubectl-style columns per kind, rendered after the universal
Namespace/Name/Status/Age:

- deploy UP-TO-DATE/AVAILABLE, rs DESIRED/CURRENT/READY, sts READY,
  ds DESIRED/READY/AVAIL
- svc TYPE/CLUSTER-IP/PORTS, ing CLASS/HOSTS/ADDRESS
- job COMPLETIONS/DURATION, cronjob SCHEDULE/SUSPEND/ACTIVE
- cm DATA, secret TYPE/DATA, sa SECRETS
- node ROLES/VERSION
- pvc VOLUME/CAPACITY/ACCESS/STORAGECLASS, pv adds RECLAIM/CLAIM
- hpa REFERENCE/MINPODS/MAXPODS/REPLICAS, pdb MIN-AVAIL/MAX-UNAVAIL/ALLOWED

ResourceKind::extra_columns() is the single source of truth for header labels
and widths; extract_columns() in the provider emits the matching row values.
A contract test asserts the two stay in lockstep for all 24 kinds.

Entity model: summary: String -> columns: Vec<String>. Pods now carry an empty
vec, dropping the previously-unused per-pod "node=" string on the 10k-pod hot
path. Filtering and :dump/copy span all columns; kinds without distinctive
columns render just the four universal ones.

Tests: contract count check, deployment/service/pvc extraction, non-pod render
snapshot (kind headers replace generic Summary).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(ui): richer ServiceAccount and RoleBinding columns

ServiceAccounts showed only a SECRETS count (often 0 on k8s ≥1.24);
RoleBindings/ClusterRoleBindings had no kind-specific columns at all (empty
fallback). Add meaningful columns:

- ServiceAccounts: SECRETS, PULL-SECRETS (imagePullSecrets count)
- RoleBindings / ClusterRoleBindings: ROLE (roleRef kind/name, e.g.
  ClusterRole/view) and SUBJECTS (abbreviated kind:name list, e.g.
  sa:build,u:alice)

Test: rolebinding role/subjects extraction; the all-kinds column-count
contract test covers the new headers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 11:06:37 +02:00
ErfanandClaude Opus 4.8 75a72158fd feat(ui): sort indicator and pods-table metric column redesign (#17)
Sort visibility:
- mark the active sort column in the table header with a direction arrow
  (Name ↑ / Status ↓) and add a [SORT] <col><dir> field to the top status bar
- add `:sort <name|namespace|status|age> [asc|desc]` command (with autocomplete)

Pods-table readability:
- reorder columns to Namespace | Name | Status | Age, then split the combined
  CPU/MEM right-sizing cell into six fixed-width, right-aligned, normalized
  columns: CPU CR CL | MEM MR ML (CR/CL = cpu %req/%lim, MR/ML = mem %req/%lim)
- per-cell severity coloring (a hot %limit reddens its own cell, not the row)
- column_spacing(2) and a flexible Name column so metrics stay aligned and
  always visible regardless of terminal width

Docs/roadmap: operator-guide updated for the new columns and :sort; ROADMAP
records the sort indicator and marks 4.4 (rendered describe) as skipped.

Tests: header-arrow render snapshot, :sort parsing, and updated pod usage
percentage assertions.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:54:48 +02:00
Erfan YousefiandClaude Opus 4.8 f0440feb57 feat(events): resource-correlated events in the Events pane (Phase 4.3)
Pressing E on any non-Event resource now shows that resource's events instead
of a "planned" placeholder.

- ResourceProvider::events_for lists core/v1 Events filtered by
  involvedObject.name (namespace-scoped), newest first.
- App caches them per selected key (events_cache), fetched on demand in
  ensure_active_watch — same lazy model as detail; the object fetch is skipped
  for this case.
- detail_text renders them kubectl-describe-style (LAST/TYPE/REASON/CNT/SOURCE/
  MESSAGE); selecting an Event resource itself still shows its manifest.
- Hidden `--events <ns>/<name>` probe for verification.

Verified against a real cluster (correlated a live Warning/PolicyViolation
event for a pod); unit-tested the render path.

Validation: fmt, check, test (88 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 01:51:05 +02:00
Erfan YousefiandClaude Opus 4.8 2c17eca7b5 feat(metrics): show per-pod right-sizing (usage vs request and limit)
The Pods CPU/MEM columns now show actual usage AND how it compares to the pod's
request and limit, so you can spot mis-sized pods at a glance:

  CPU/MEM cell = `<used> R<%req> L<%limit>`   e.g.  1.50c R150 L75
    R% = used / request  (low → over-provisioned, >=100 → under-requested)
    L% = used / limit    (risk: throttle/OOM as it approaches 100%)

Cells color by the worse signal: yellow at >=100% of request, red at >=90% of
limit. Missing request/limit render as R-/L-; no metrics renders as `-`. The
table title carries a one-line legend. Uses the request/limit already extracted
into the lean entity (1.1) plus the live pod metrics (4.2) — no new fetch.

Validation: fmt, check, test (87 passed / 4 ignored, +right-sizing render test),
release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 01:22:31 +02:00
Erfan YousefiandClaude Opus 4.8 1389b060ca feat(metrics): per-pod CPU/MEM usage columns in the Pods table (Phase 4.2)
Builds on the cluster [USE] pulse row with the per-pod view operators actually
want: live usage per pod, not just the aggregate.

- ResourceProvider::pod_metrics reads metrics.k8s.io PodMetrics (scoped to the
  active namespace or cluster-wide), summing usage across each pod's containers.
- App caches it as (namespace,name) -> (cpu_m, mem_b) per context+namespace,
  refreshed lazily alongside node metrics (15s TTL).
- The Pods table swaps its Summary column for CPU and MEM (live usage), looked
  up per visible row (O(viewport)); other kinds are unchanged. When no
  metrics-server: cells show "-" and the title flags "metrics-server n/a".
- `--metrics` probe now also reports pod-metrics counts.

Verified on a real metrics-server cluster: 45 nodes / 821 pods reporting live
usage; graceful fallback on kwok. Tests: columns render with seeded usage, and
the unavailable note.

Validation: fmt, check, test (87 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 00:54:08 +02:00
Erfan YousefiandClaude Opus 4.8 93c9288abc feat(metrics): live cluster usage from metrics.k8s.io in the pulse (Phase 4.2)
The pulse showed CPU/mem from pod spec requests/limits, not actual usage.

- ResourceProvider::node_metrics reads live per-node usage from metrics.k8s.io
  (Api<DynamicObject> on NodeMetrics), parsed via the shared quantity parsers
  (handles nanocores `n` and `Ki`, the real metrics-server units).
- App caches the cluster aggregate per active context (15s TTL, fetched lazily
  in ensure_active_watch); never blocks the UI.
- Pulse gains a [USE] row: actual cpu/mem used vs allocatable + util%, with
  severity. When no metrics-server is present the cache is None and the row
  notes that the request/limit rows above apply (graceful degradation).
- Hidden `--metrics` probe prints the cluster aggregate for verification.

Verified: a real metrics-server-backed cluster (45 nodes -> 15.0 cores /
537 GiB actual usage) and graceful 404 fallback on the kwok lab. Unit test
covers the real unit formats.

Deferred: per-pod usage column (needs pod-metrics fetch + table column work).

Validation: fmt, check, test (85 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 23:28:17 +02:00
Erfan YousefiandClaude Opus 4.8 273b2572a8 test(soak): add headless soak harness; validate no leak under churn (Phase 5.1)
Adds `--soak-secs N [--soak-sample-secs S]` to the headless harness: runs the
real watch→store pipeline under live churn for N seconds, sampling RSS, entity
count, and open fd count to surface leaks or unbounded growth, then reports
baseline vs final/max with a stable/INVESTIGATE verdict.

Representative run (210s, churn at 3 rollout-restarts/s on 100-replica
deployments, periodic watcher relists):
  RSS 64.3 -> 62.0 MB (-3.6%, stable), max 64.5
  fds flat at 16 (no stream/reconnect descriptor leak)
  entity count tracks the churning workload without affecting RSS (lean entities)

No memory or fd leak; relist reconciliation runs repeatedly under load without
growth. The harness is reusable for the multi-hour final-gate run.

Validation: fmt, check, test (84 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 22:48:08 +02:00
Erfan YousefiandClaude Opus 4.8 adfa11c384 feat(view): label-selector and inverse table filters (Phase 4.5)
The table filter only did plain substring matching, so `:<kind> -l app=foo`
(which the command parser feeds in as the filter `app=foo`) silently
substring-matched the literal text instead of matching labels.

Parse the filter k9s-style (compiled once per projection):
- `!term`                       inverse (exclude matches)
- `key=value` / `key==value`    label equals
- `key!=value`                  label not-equals (holds if absent or different)
- comma-separated requirements  all must hold (`app=api,tier=backend`)
- anything else                 case-insensitive substring (unchanged default)

Label matching uses the entity's cached labels. A stray `=` in a search term
won't masquerade as a selector (label keys are validated).

Tests: label eq/neq/absent, multi-requirement, inverse, substring fallback.
Deferred (no new deps): fuzzy + regex; detail/log search stays substring.

Validation: fmt, check, test (84 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:25:20 +02:00
Erfan YousefiandClaude Opus 4.8 11945628a1 perf(state): evict cached entities for dropped contexts (Phase 1.3)
Entities for a context persisted in the store after its watchers stopped, so
store memory (and RSS) grew with every context an operator visited — a problem
at the 20-cluster target.

- replace_watch_plan now detects contexts that lost all watchers (dropped from
  the active + warm set) and emits StateDelta::EvictContext for each.
- The store drops that context's entities, indexes, and relist generations.

Store memory is now bounded to the active + warm_contexts, regardless of how
many contexts have been browsed.

Measured on the kwok lab (--bench --bench-contexts 20): after warming all 20
contexts the store plateaus at 1,048 entities (~active + 1 warm × 524) instead
of growing to ~10,480; RSS 55 MB. Bench gained --bench-contexts N.

Validation: fmt, check, test (81 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 16:50:48 +02:00
Erfan YousefiandClaude Opus 4.8 8b1c78f025 fix(ui): make per-view help accurate and keymap-aware
The on-screen help line drifted from actual behavior and hardcoded default
keys, so it misled operators (especially with a customized keymap).

- Help key hints are now derived from the active keymap (`Keymap::hint`), so they
  reflect remapped bindings instead of hardcoded defaults.
- Table pane: removed the bogus `ctrl+d/u page` (paging is detail-only; `ctrl+d`
  is delete here) and `gg` (table uses a single `g`); added the bindings that
  were missing — namespace cycle, sort, reverse, events, help toggle, clear-filter.
- Detail/Logs panes: advertise `t table` and `esc close` (both worked, unlisted);
  clarified `gg/G`, `ctrl+d/u half-page`, `n/N match`, `/ search`.
- Docs reconciled: operator-guide navigation + commands (incl. `:api` / dynamic
  resource browse), README scope note for dynamic discovery.

Tests: keymap hint rendering (default + remapped), and per-pane help accuracy
(table excludes paging/gg and includes namespace/sort/delete; detail includes
close/table/edit).

Validation: fmt, check, test (80 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 16:23:03 +02:00
Erfan YousefiandClaude Opus 4.8 eb471a957a feat(ui): browse and describe any resource/CRD via commands (Phase 4.1a-2)
Wires the dynamic discovery layer into the UI (read-only):

- `:api [filter]` lists the discovered API resource catalog for the context
  (name/kind/scope), optionally filtered.
- `:<resource>` for any discovered resource/CRD not in the curated 24 lists its
  objects with generic columns (namespace/name/age/best-effort status).
- `:<resource> <name>` describes a single dynamic object (YAML).

Resolution matches plural, kind, or kind.group; the `:<unknown>` command
fallback now routes to this path instead of "not implemented". Discovery is
cached per context. Reuses the existing Overlay::Text (no new interactive
overlay) to keep the change low-risk; a selectable dynamic-list overlay is
deferred to 4.1c.

Verified: unit test dynamic_browse_catalog_list_and_describe (catalog + list +
describe + unknown), and --discover against the lab still resolves 68 resources
incl. the sample CRD.

Validation: fmt, check, test (76 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 15:16:10 +02:00
Erfan YousefiandClaude Opus 4.8 e19cca315a feat(cluster): dynamic resource discovery + list/describe (Phase 4.1a)
First slice of readonly parity for arbitrary resources/CRDs (ROADMAP 4.1).
Hybrid design: keep the curated 24 kinds; add a dynamic path for any discovered
GVK. This commit lands the provider layer + a headless verification mode.

- ResourceProvider::discover -> all API resources on a context via kube::discovery
- ResourceProvider::list_dynamic -> bounded one-shot list of any resource as
  generic rows (namespace/name/age/best-effort status) via Api<DynamicObject>
- ResourceProvider::get_dynamic -> full manifest for describe
- DiscoveredResource / DynamicRow types (cluster module)
- hidden `--discover [--discover-resource <plural|kind>]` mode prints the catalog
  and optionally lists+describes one resource (verifies the path end-to-end)
- scripts/scale/crds.sh installs a sample CRD (widgets.demo.krust.io) + CRs

Verified against the kwok lab: discovered 68 resources incl. the CRD and core
kinds outside the curated set (endpoints, endpointslices); listed and described
the Widgets. The interactive UI (:api catalog + dynamic browse overlay) lands
next in 4.1a-2.

Validation: fmt, check, test (75 passed / 4 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 14:49:43 +02:00
Erfan YousefiandClaude Opus 4.8 8b1feaba31 perf(ui): bound per-cycle delta drain and cap log fan-out
Stability hardening for churn/scale (ROADMAP 3.2-3.4).

3.2 Bounded delta drain: the main loop drained every available delta each
cycle, so a 10k initial-list flood could run before input/render was serviced.
Cap at DELTA_MAX_PER_CYCLE (4096); the bounded channel back-pressures producers
so nothing is lost and the remainder drains next cycle — input stays responsive.

3.3 Log fan-out cap: a Deployment/ReplicaSet log selection opened one stream
per replica pod x container (hundreds of follow connections for a large
deployment). Cap multi-pod selections at LOG_MAX_STREAMS (50) via
capped_multi_pod_selection; the scope label notes "N of M streams, capped".

3.4 Watcher ceiling/auth: assessed, no change needed. Watcher count is already
bounded by the warm-context policy (active + warm_contexts only); 401/token
expiry on watch streams is handled by kube auth refresh on reconnect plus the
existing bounded backoff. A redundant cap would risk dropping the active
context's essential watchers.

Validation: fmt, check, test (75 passed / 4 ignored), release build all green.
Bench: no data-plane regression (sync 2.05s, RSS 64.7MB).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 13:51:35 +02:00
Erfan YousefiandClaude Opus 4.8 697998f39a fix(state): keep list visible during relist; drop blank-window on reconnect
On every watcher reconnect, Event::Init emitted StateDelta::Reset which wiped
the entire kind from the store, so the table blanked for ~2s while 10k pods
re-populated from the fresh list.

Replace the wipe with reflector-style generation reconciliation:
- per-(context, kind) generation counter in StateStore
- RelistStart (Event::Init) bumps the generation; the existing set stays visible
- each apply stamps the current generation (refreshing still-present objects)
- RelistEnd (Event::InitDone) sweeps only entities left at an older generation
  (objects that disappeared while disconnected and were absent from the relist)

The previous list now stays fully visible throughout a relist and reconciles
atomically at the end — no blank window. Also adds a perf micro-benchmark
(perf_to_value_vs_dynamic_parse) that measured per-event to_value at ~5% of
initial sync, deprioritizing the metadata-watch rewrite (ROADMAP 1.2).

Validation: fmt, check, test (72 passed / 4 ignored), release build all green.
Bench: no regression (sync 2.03s, RSS 64.6MB).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 13:33:28 +02:00
Erfan YousefiandClaude Opus 4.8 c360723c46 perf(view): window projection/render to the visible rows
The table renderer built a ratatui Row for all rows every frame and the
projection cloned a full display ViewRow for each — O(total), ~5.9 ms/frame at
10k pods even though only ~45 are visible.

- ViewModel now holds the ordered, filtered keys (order: Vec<ResourceKey>),
  not materialized rows.
- Display rows are built on demand via view::materialize_row only for the
  visible window (table render) or the selected row (detail/copy/delete).
- detail_text takes the selected key directly instead of the full row slice.
- Filter match avoids allocating a combined haystack string per row.

Measured on the kwok 10k-pod lab (1 context, release build):
  frame render (cached)  5.92 ms -> 0.47 ms  (12.5x)
  projection (recompute) 1.92 ms -> 1.20 ms
  RSS                    85.5 MB -> 64.8 MB
Per-frame-under-churn now ~2.0 ms (was 15.5 ms before this refactor series).

Validation: fmt, check, test (71 passed / 3 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 11:41:39 +02:00
Erfan YousefiandClaude Opus 4.8 45175410fb perf(state): lean entity model — fetch full objects on demand
Stop retaining the full object JSON for every cached entity. At 10k pods in
one context the store held ~482 MB (~48 KB/pod) because ResourceEntity.raw
kept the entire serialized object.

- Replace ResourceEntity.raw with a compact Extracted payload (node name,
  container names, ownerReferences, pod resource req/lim, node capacity),
  computed once at ingest in cluster/extract.rs and dropped.
- Fetch the full object on demand for detail/describe/decode/edit via the new
  ResourceProvider::get_object, cached single-slot (detail_cache).
- Pulse aggregate and log fan-in owner mapping now read extracted fields
  instead of walking raw JSON for every pod.

Also adds a hidden headless benchmark mode (--bench, src/ui/app/bench.rs) that
boots the real data plane against a cluster and times the project/render/pulse
hot paths + RSS, plus the stable-release ROADMAP and the 1.1 design note.

Measured on the kwok 10k-pod lab (1 context, release build):
  RSS              482 MB -> 85.5 MB  (5.6x smaller)
  pulse aggregate  7.62 ms -> 0.36 ms (21x faster)
projection/render unchanged (Phase 2.1); initial sync unchanged — per-event
to_value remains, addressed in Phase 1.2.

Validation: fmt, check, test (71 passed / 3 ignored), release build all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 11:11:30 +02:00