From 40fc35f1766c6fe898dd56af42448a516f7eb8a3 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 23 Feb 2026 16:46:20 -0500 Subject: [PATCH] chore(conductor): Archive track 'event_driven_metrics_20260223' --- .../event_driven_metrics_20260223/index.md | 5 ++++ .../metadata.json | 8 +++++ .../event_driven_metrics_20260223/plan.md | 28 ++++++++++++++++++ .../event_driven_metrics_20260223/spec.md | 29 +++++++++++++++++++ conductor/tracks.md | 4 --- 5 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 conductor/archive/event_driven_metrics_20260223/index.md create mode 100644 conductor/archive/event_driven_metrics_20260223/metadata.json create mode 100644 conductor/archive/event_driven_metrics_20260223/plan.md create mode 100644 conductor/archive/event_driven_metrics_20260223/spec.md diff --git a/conductor/archive/event_driven_metrics_20260223/index.md b/conductor/archive/event_driven_metrics_20260223/index.md new file mode 100644 index 0000000..df60da8 --- /dev/null +++ b/conductor/archive/event_driven_metrics_20260223/index.md @@ -0,0 +1,5 @@ +# Track event_driven_metrics_20260223 Context + +- [Specification](./spec.md) +- [Implementation Plan](./plan.md) +- [Metadata](./metadata.json) diff --git a/conductor/archive/event_driven_metrics_20260223/metadata.json b/conductor/archive/event_driven_metrics_20260223/metadata.json new file mode 100644 index 0000000..4723113 --- /dev/null +++ b/conductor/archive/event_driven_metrics_20260223/metadata.json @@ -0,0 +1,8 @@ +{ + "track_id": "event_driven_metrics_20260223", + "type": "refactor", + "status": "new", + "created_at": "2026-02-23T15:46:00Z", + "updated_at": "2026-02-23T15:46:00Z", + "description": "Fix client api metrics to use event driven updates, they shouldn't happen based on ui main thread graphical updates. Only when the program actually does significant client api calls or responses." +} diff --git a/conductor/archive/event_driven_metrics_20260223/plan.md b/conductor/archive/event_driven_metrics_20260223/plan.md new file mode 100644 index 0000000..49fdc6e --- /dev/null +++ b/conductor/archive/event_driven_metrics_20260223/plan.md @@ -0,0 +1,28 @@ +# Implementation Plan: Event-Driven API Metrics Updates + +## Phase 1: Event Infrastructure & Test Setup [checkpoint: 776f4e4] +Define the event mechanism and create baseline tests to ensure we don't break data accuracy. + +- [x] Task: Create `tests/test_api_events.py` to verify the new event emission logic in isolation. cd3f3c8 +- [x] Task: Implement a simple `EventEmitter` or `Signal` class (if not already present) to handle decoupled communication. cd3f3c8 +- [x] Task: Instrument `ai_client.py` with the event system, adding placeholders for the key lifecycle events. cd3f3c8 +- [ ] Task: Conductor - User Manual Verification 'Phase 1: Event Infrastructure & Test Setup' (Protocol in workflow.md) + +## Phase 2: Client Instrumentation (API Lifecycle) [checkpoint: e24664c] +Update the AI client to emit events during actual API interactions. + +- [x] Task: Implement event emission for Gemini and Anthropic request/response cycles in `ai_client.py`. 20ebab5 +- [x] Task: Implement event emission for tool/function calls and stream processing. 20ebab5 +- [x] Task: Verify via tests that events carry the correct payload (token counts, session metadata). 20ebab5 +- [x] Task: Conductor - User Manual Verification 'Phase 2: Client Instrumentation (API Lifecycle)' (Protocol in workflow.md) e24664c + +## Phase 3: GUI Integration & Decoupling [checkpoint: 8caebbd] +Connect the UI to the event system and remove polling logic. + +- [x] Task: Update `gui.py` to subscribe to API events and trigger metrics UI refreshes only upon event receipt. 2dd6145 +- [x] Task: Audit the `gui.py` render loop and remove all per-frame metrics calculations or display updates. 2dd6145 +- [x] Task: Verify that UI performance improves (reduced CPU/frame time) while metrics remain accurate. 2dd6145 +- [x] Task: Conductor - User Manual Verification 'Phase 3: GUI Integration & Decoupling' (Protocol in workflow.md) 8caebbd + +## Phase: Review Fixes +- [x] Task: Apply review suggestions 66f728e diff --git a/conductor/archive/event_driven_metrics_20260223/spec.md b/conductor/archive/event_driven_metrics_20260223/spec.md new file mode 100644 index 0000000..91acead --- /dev/null +++ b/conductor/archive/event_driven_metrics_20260223/spec.md @@ -0,0 +1,29 @@ +# Specification: Event-Driven API Metrics Updates + +## Overview +Refactor the API metrics update mechanism to be event-driven. Currently, the UI likely polls or recalculates metrics on every frame. This track will implement a signal/event system where `ai_client.py` broadcasts updates only when significant API activities (requests, responses, tool calls, or stream chunks) occur. + +## Functional Requirements +- **Event System:** Implement a robust event/signal mechanism (e.g., using a queue or a simple observer pattern) to communicate API lifecycle events. +- **Client Instrumentation:** Update `ai_client.py` to emit events at key points: + - **Request Start:** When a call is sent to the provider. + - **Response Received:** When a full or final response is received. + - **Tool Execution:** When a tool call is processed or a result is returned. + - **Stream Update:** When a chunk of a streaming response is processed. +- **UI Listener:** Update the GUI components (in `gui.py` or associated panels) to subscribe to these events and update metrics displays only when notified. +- **Decoupling:** Remove any metrics calculation or display logic that is triggered by the UI's main graphical update loop (per-frame). + +## Non-Functional Requirements +- **Efficiency:** Significant reduction in UI main thread CPU usage related to metrics. +- **Integrity:** Maintain 100% accuracy of token counts and usage data. +- **Responsiveness:** Metrics should update immediately following the corresponding API event. + +## Acceptance Criteria +- [ ] UI metrics for token usage, costs, and session state do NOT recalculate on every frame (can be verified by adding logging to the recalculation logic). +- [ ] Metrics update precisely when API calls are made or responses are received. +- [ ] Automated tests confirm that events are emitted correctly by the `ai_client`. +- [ ] The application remains stable and metrics accuracy is verified against the existing polling implementation. + +## Out of Scope +- Adding new metrics or visual components. +- Refactoring the core AI logic beyond the event/metrics hook. diff --git a/conductor/tracks.md b/conductor/tracks.md index dd5c0b8..538e200 100644 --- a/conductor/tracks.md +++ b/conductor/tracks.md @@ -17,10 +17,6 @@ This file tracks all major tracks for the project. Each track has its own detail - [x] **Track: Live GUI Testing Infrastructure** *Link: [./tracks/live_gui_testing_20260223/](./tracks/live_gui_testing_20260223/)* ---- - -- [x] **Track: Event-Driven API Metrics Updates** -*Link: [./tracks/event_driven_metrics_20260223/](./tracks/event_driven_metrics_20260223/)*