Skip to content

feat: introduce Workbench service with backend CEL filtering and on-demand struct loading - #892

Merged
kyasbal merged 9 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-oowykxsvnlsx
Aug 20, 2026
Merged

kyasbal merged 9 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-oowykxsvnlsx

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

This PR introduces the Workbench Service backend architecture and migrates data filtering, CEL query evaluation, and interned struct decoding from the browser frontend to the Go backend.

Background & Motivation

Previously, KHI parsed all interned structs and body buffers into the browser memory upon loading .khi files, and executed CEL-based timeline/log filtering within frontend Web Workers. For large inspection datasets, this resulted in excessive browser memory consumption (often leading to tab OOM crashes), slow initial load times, and duplicated CEL evaluation logic across Go and TypeScript.

Solution Overview

  1. Workbench Service & Session Lifecycle: Added an in-memory session manager with automatic idle session sweeping and heartbeat support to manage active inspection datasets on the server.
  2. On-Demand Struct YAML Loading: Eliminated upfront frontend struct deserialization. The browser now fetches YAML representations on demand via ReadStructYAML RPC only when a user selects a diff or log entry.
  3. Backend CEL Filtering & Indexing: Implemented a Go-based CEL engine, hierarchical filtering pipeline, metadata indexing, and trigram text search (QueryTimeline, QueryLog).
  4. CEL Validation Service: Added CELValidationService RPC to perform real-time syntax and type validation for CEL queries.
  5. Frontend Modernization & Memory Optimization: Replaced the client-side search Web Workers, frontend CEL evaluation engine, and struct decoders with BackendFilter and debounced validation.

Key Changes

1. In-Memory Session Management (WorkbenchService)

  • Added proto/api/v1/workbench.proto and Connect-RPC endpoints (OpenSession, CloseSession, HeartbeatSession, GetSessionStatus).
  • Implemented SessionManager, Sweeper, and Reader in pkg/server/workbench/ to track and cache loaded inspection datasets per client.
  • Integrated session creation and heartbeat lifecycle with frontend DataLoaderService and WorkbenchClientService.

2. Server-Side Struct YAML Decoding (ReadStructYAML)

  • Added ReadStructYAML RPC endpoint to decode interned struct objects to YAML on demand.
  • Updated pkg/model/khifile/v6/intern.go to support decoding InternedStruct directly to YAML/maps on the server.
  • Updated frontend DiffSmartComponent, LogSmartComponent, DiffContentComponent, and LogContentComponent to load YAML asynchronously on selection.

3. Server-Side CEL-Based Filtering Pipeline & Indexing

  • Implemented backend CEL evaluation engine in pkg/server/workbench/cel/:
    • Defined CEL environments and standard variables for Timeline and Log models.
    • Implemented custom CEL functions and type bindings.
  • Created pkg/server/workbench/index.go with metadata indexing and trigram substring matching for high-performance log and timeline querying.
  • Implemented filtering pipeline (FilterHierarchy, FilterTimelineCEL, FilterLogCEL) exposed through QueryTimeline and QueryLog RPC methods.

4. CEL Validation Service (CELValidationService)

  • Added proto/api/v1/cel_validation.proto and CELValidationService RPC to validate syntax and types of user-defined CEL queries without needing a client-side CEL parser.
  • Introduced CELValidationClientService on the frontend with debounced validation and real-time error reporting in the toolbar UI.

5. Frontend Refactoring & Memory Optimization

  • Introduced BackendFilter (web/src/app/store/domain/filter/backend-filter.ts) to synchronize filter parameters and query results with the backend.
  • Removed unused client-side struct deserializers (struct-decoder.ts) and body buffers, drastically reducing the browser memory footprint.
  • Removed the deprecated Web Worker search engine (web/src/app/worker/search/) and client-side CEL evaluation runtime (cel-env.ts, cel-filter.ts, etc.).
  • Updated TimelineToolbarSmartComponent to map both standard filter controls and advanced CEL text inputs to BackendFilter.

Included Commits

  1. feat(api): add WorkbenchService and in-memory session lifecycle
    • Protobuf definition, Go server session manager, sweeper, and frontend Connect-RPC client integration.
  2. feat(workbench): add ReadStructYAML API to WorkbenchService
    • Added ReadStructYAML RPC and backend YAML decoding logic.
  3. feat(workbench): implement CEL-based timeline and log filtering in backend
    • Go-based CEL engine, trigram indexing, and hierarchical timeline/log filtering pipeline.
  4. feat(web): switch diff and log viewing to on-demand struct YAML loading
    • Switched diff and log components to fetch YAML on demand with loading states.
  5. refactor(web): remove unused frontend struct deserialization and body buffers
    • Removed client-side struct decoding and pruned intern pool / timeline stores.
  6. feat(filter): introduce CELValidationService and migrate frontend filter to BackendFilter
    • Added CEL validation RPC, introduced BackendFilter, and removed frontend search Web Workers and CEL evaluator.
  7. feat(filter): move CEL filter evaluation and validation to backend
    • Connected timeline toolbar UI with debounced CEL validation and backend filter synchronization.

Verification

  • Backend: Ran all Go unit tests including session lifecycle, sweeper, CEL evaluation, trigram indexing, and RPC handlers:
    make test-go
  • Frontend: Ran all Angular component and store unit tests:
    make test-web
  • Linters & Code Style:
    make lint-go && make lint-web

@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 new CEL-based validation service and a workbench management system to handle inspection datasets. It includes necessary dependency updates, server initialization logic, and new services for CEL query validation and workbench session handling. The reviewer provided actionable feedback regarding a potential integer wrap-around issue in severity comparisons, a race condition in the GetOrOpen method that could lead to redundant resource loading, and a recommendation to reuse existing utility methods for timeline path resolution instead of duplicating them.

Comment thread pkg/server/workbench/cel/env.go Resolved
Comment thread pkg/server/workbench/manager.go Resolved
Comment thread pkg/server/workbench/index.go Resolved
@kyasbal kyasbal added the type:feature New feature or request label Aug 20, 2026
@kyasbal
kyasbal merged commit 7a7de4b into GoogleCloudPlatform:main Aug 20, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-oowykxsvnlsx branch August 20, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New feature or request

1 participant