Add schema, handler, and proxy infrastructure for channel request details (#4541)#4610
Draft
Add schema, handler, and proxy infrastructure for channel request details (#4541)#4610
Conversation
Define the target interface for schema, handler, and proxy plug changes needed by the channel request detail page. These tests fail until Phase 1b implements the backing code. Test contracts cover: - ChannelEvent new fields: request_query_string, request_body_size, response_body_size, request_send_us, response_duration_us - ChannelEvent headers as native jsonb (round-trip without Jason.decode!) - ChannelRequest auth tracking: client_webhook_auth_method_id (FK with on_delete nilify_all) and client_auth_type (denormalized snapshot) - Handler persist_completion adapted to Philter 0.3.0: timing.total_us, timing.send_us, timing.recv_us, observation sizes - Proxy plug: query string and client auth method pass-through
…ge (#4541) Add new columns to channel_events (body sizes, per-direction durations, query string), migrate headers from text to native jsonb, add client auth tracking to channel_requests, adapt handler to Philter 0.3.0 timing structure, and pass collect_timing/query_string/auth method through the proxy plug pipeline.
Define failing test contracts for the detail LiveView, error humanization helpers, and get_channel_request_for_project context function. Enrich channel_event/channel_error_event factories and migrate hand-rolled Repo.insert! calls across channel tests.
Implement the detail LiveView, context function, error humanization, route, and navigation wiring to make all Phase 3a test contracts pass.
Store Finch telemetry values as-is in microseconds instead of truncating to milliseconds in the handler. Adds queue_us, connect_us, and reused_connection columns for full Finch phase visibility.
… UI polish (#4541) Reorder layout (summary → timing → request/response side-by-side → context), implement nested timeline showing Finch phases within proxy overhead using crosshatch pattern, add foldable disclosure sections for headers/body, improve body viewer with content-type badges and no-body indicators.
…4541) Split the 1158-line show.ex into four focused files to improve maintainability: helpers.ex (shared pure functions), components.ex (reusable display components), timing.ex (timing visualization), and show.ex (LiveView lifecycle + section composition).
3b1045c to
0d65edd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the backend infrastructure needed for the channel request detail page. It extends the data model and proxy pipeline to capture richer request/response metadata that was previously discarded.
Schema changes:
channel_events:request_query_string,request_body_size,response_body_size,request_send_us,response_duration_usrequest_headersandresponse_headersfromtextto nativejsonb(withUSINGclause for in-place data conversion, handling NULL and malformed JSON)channel_requests:client_webhook_auth_method_id(FK withnilify_all) andclient_auth_type(denormalized snapshot that survives auth method deletion)Handler + proxy plug changes:
result.timing.total_usreplacesresult.duration_us)send_us,recv_us) and body sizes from Philter observationscollect_timing: trueto Philter for per-phase timing breakdownconn.query_stringthrough handler state to persist on eventsCloses #4541
Validation steps
mix test test/lightning/channels/— 75 tests, 0 failuresmix test test/lightning_web/plugs/channel_proxy_plug_test.exs— 49 tests, 0 failuresmix verify— 4713 tests, 0 failuresAdditional notes for the reviewer
CASE/USINGclause to convert existing text data in-place. NULL values stay NULL; malformed JSON falls back to NULL.empty_values: []was added to the ChannelEvent changeset becauserequest_query_stringneeds to preserve empty strings (""means "no query params"). Since all ChannelEvent fields are machine-written by the handler, not user input, this is safe.authenticate_clientwas refactored from boolean pass/fail to identifying the specific matched method, reusingAuth.valid_key?/Auth.valid_user?per-method to preserve constant-time comparison.TODO
channel_events(body sizes, durations, query string)request_headersandresponse_headersfrom text to jsonbclient_webhook_auth_method_idandclient_auth_typetochannel_requestsChannelEventschema and changeset for new fields + jsonb headersChannelRequestschema with client auth method associationJason.encode!)collect_timing: trueto Philterconn.query_stringinto handler stateChannelRequestLive.Show) with summary card, request/response sections, timing visualization, and context sectionChannels.get_channel_request_for_project/2with project-scoped queryAI Usage
Pre-submission checklist
/reviewwith Claude Code)