Repository navigation
feat(dash): opt-in lifecycle signals (thread, wait cause inputs, gaps, granted TTL) - #447
Conversation
|
Reviewer: approved. CI all pass; go test ./dash (full, 64 s) and the proxy lifecycle tests green; gofmt clean. Checked:
Non-blocking:
|
Release sync: #447 is in this release, after #453Result: please wait before you start on this PR. It is blocked on #453 (the record half of #424). Start the rework below after #453 merges. I will post on this PR when it does. Why it is blocked
Proposed rework, after #453 merges
Also:
Merge order for this release#431 (merged) → #414 → #456 → #425 → #453 → #447 (reworked) → #444 → integration check → release. #444 does not conflict with #453 and is in this release too. |
Unblocked: #453 is merged#453 (the record half of #424) is on main. You can start the rework of #447 now. The plan is the one in my earlier comment above. What is on main now:
Please keep only the new signals in #447: the gap since the previous response ended, the granted TTL tier, the incoming Merge order: #447 (reworked) → #444 → integration check → release. |
Behind --dashboard-lifecycle-signals (default off), a request_lifecycle side table stores the gap from the previous response end on the same thread, the granted cache TTL tier, the incoming tool_result count/bytes/error flag, and the keep-alive ping ordinal. The thread id, previous stop reason and tool names are the requests columns from #426 and #453 and are no longer duplicated. The body is read through apply.NormalizeMessages on the dashboard writer goroutine; stale thread state is evicted by age, amortised to once a minute; Lifecycles is scoped by tenant. Signed-off-by: Osher-Elhadad <[email protected]>
db49994 to
d83bfcc
Compare
Results: reworked on top of #453 as requestedWhat it does. With What changed since review (following the release-sync plan).
Evidence. Not deployed; deployment is for the owners. |
|
Reviewer: APPROVAL UPDATED for the reworked head d83bfcc (earlier approval was for the old head and no longer applies). CI all pass; full go test ./dash -count=1 (67 s) green; proxy lifecycle/wait tests green; gofmt clean. Checked: privacy - the row holds only counts, byte lengths, an is_error flag, the gap and a tier label; no names, no tool input or result text (thread id, stop reason, tool names now come from main's own columns). Flag off - LifecycleFn is only set when the flag is on, ObserveLifecycle/PingLifecycle return nil, and TestLifecycleOffWritesNoRows plus TestLifecycleOffAndPing assert no rows. Additive DDL - CREATE TABLE IF NOT EXISTS via additiveDDL, ON DELETE CASCADE from requests (foreign_keys on), empty table, no version bump. Hot path - scanning runs on the dashboard writer goroutine through apply.NormalizeMessages, not on the request path; recover() fails open. Memory - one int64 per live thread, age-based sweep at most once a minute (O(n) amortised, a live thread is never evicted). Scoping - DB.Lifecycles(tenant) joins requests on tenant_id. Tests: end-to-end with secret-bearing tool inputs, gap/TTL, age eviction. Note (non-blocking): the end time is stamped when the proxy finishes the response and the writer applies events in finish order, so for concurrent requests on one thread the gap can be measured against the later-finishing one; fine for the keep-alive analysis it serves. |
Refs #424, #427. Default OFF (
--dashboard-lifecycle-signals); flag off writes nothing.Adds side table
request_lifecycle(additive DDL, FK cascade to requests):Privacy: no tool inputs, no tool_result text, only names/counts/sizes/hashes.
Limits: thread state is in memory (first request after restart has gap -1); ping rows link to the session's latest thread on that model because the keeper is per session on this base (per thread comes with #426); identical-prefix forks interleaving in one session share a thread; wake_cause string markers from #424 are not included.
Tests: unit (scan, redaction, nonce, thread/gap/ttl/parent, store round trip) and an end-to-end two-turn request through the test proxy, plus flag-off. Live: real
claude -psession running Bash through a separate proxy on :4180 recorded the expected rows (turn 2: prev_stop tool_use, Bash x1, 1 result, gap 6514 ms, since-end 882 ms).