Skip to content

feat(mcp): show compressed revision state transitions in search_timelines - #1201

Merged
kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-kttlkvlnuvtl
Oct 30, 2026
Merged

kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-kttlkvlnuvtl

Conversation

@kyasbal

@kyasbal kyasbal commented Oct 30, 2026

Copy link
Copy Markdown
Member

Background

Previously, the MCP search_timelines tool only reported raw revision counts (rev=N) and event severity totals per timeline node. Because revision state labels were only visible through get_resource_revisions, troubleshooting agents could not tell from the timeline tree whether rev=33 meant benign metadata updates, readiness flapping, or an active crash loop without issuing follow-up RPCs for each candidate timeline.

Approach

Append a compressed revision state transition summary (states="...") to each timeline node in search_timelines when the timeline carries styled revision states within the queried [startTime, endTime] window:

  • Window slicing & consecutive deduplication: Retain the revision already in effect at startTime alongside revisions occurring up to endTime, skip revisions without styled state labels, and collapse consecutive revisions whose human-readable state label is unchanged.
  • Tandem cycle folding: Detect and fold contiguous repeating state sequences of period 2 through 8 into (State A -> State B -> ...) xN, selecting candidates that maximize saved display slots while preferring shorter primitive periods. This keeps common multi-step Kubernetes loops (such as 3–6 step container crash loops and endpoint readiness flapping) readable in a single line.
  • Bounded middle elision with unseen-state preservation: Cap rendered summaries at 14 state slots (up to 8 leading slots and 4 trailing slots). If a non-periodic sequence still exceeds the cap after cycle folding, elide the middle as ...[omitted: State X, State Y (+K more)], surfacing up to 5 distinct states that do not already appear in the prefix or suffix so transient intermediate failures remain visible.
  • Zero noise on stateless rows: Grouping rows (core/v1#pod, namespace headers) and event-only timelines omit the states attribute entirely.

Validated against 3 real GKE cluster inspections (9,110 timeline nodes; 8,218 stateful timelines), 8,217 of 8,218 stateful timelines (99.99%) fit within the 14-slot budget after cycle folding without requiring middle elision.

UI / Output Changes

Sample search_timelines tree output on a GKE inspection:

core/v1#pod
  1-1-pod-phase-and-conditions
    [pod] non-zero-exit-code id=102 ev=59 rev=36 info=39 08:22:30..08:48:05 states="Pod is pending -> Pod has containers not ready -> Pod is running -> (Pod has containers not ready -> Pod is running) x2 -> Pod has containers not ready -> Pod is terminating -> Resource is deleted"
      [container] non-zero-exit-code id=104 ev=59 rev=33 warning=30 info=52 08:22:30..08:48:05 states="Container status is unavailable -> Container is waiting -> Container is started, readiness unknown -> Container exited with error -> Container is ready -> (Container is started, readiness unknown -> Container exited with error -> Container is waiting) x9 -> Resource is deleted"
  1-4-basic-ingresses
    [service] ig-ready-repeat-svc id=1531 ev=2 rev=2 info=12 07:56:54..08:26:52 states="Resource exists"
      [endpoint] ig-ready-repeat-svc-5j2wr(1-4-basic-ingresses) id=1533 ev=0 rev=62 info=39 07:56:55..08:26:56 states="(Endpoint is not ready -> Endpoint is ready) x7 -> (Endpoint is being terminated -> Resource is deleted) x24"
@kyasbal kyasbal added type:feature New feature or request area:backend-core Core backend frameworks, DAG task runner, and server API labels Oct 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to summarize and compress revision state transitions for timeline tree nodes within a specified time window. It adds a new RevisionStateSummary utility that deduplicates consecutive identical states, folds tandem repeat cycles (such as container crash loops), and truncates long sequences using middle elision while preserving omitted distinct states. These summaries are integrated into the MCP timeline search tool and formatted for output. Comprehensive unit tests have been added to verify the folding, truncation, and integration logic. I have no feedback to provide as there are no review comments.

@kyasbal
kyasbal added this pull request to the merge queue Oct 30, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 7fae18f Oct 30, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-kttlkvlnuvtl branch October 30, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API type:feature New feature or request

1 participant