Feed recording, sessions and cost through one input that does not depend on the Go listeners
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with core/listener/internal/sessionevent, core/session/store.go, core/cost/settle/settle.go, and core/sessionapi/server.go; trace how events reach the recorder and how cost uses response headers. The proposal spans event construction, sink interfaces, cost calculation, ingestion, and schema versioning, with several open design questions. Done means meeting the listed parity and pricing tests and, if ingestion is included, matching replayed /v1/sessions and /v1/usage results.
由索引模型根据 Issue 内容生成。
描述
Part of #1437 (assessment: laptop data plane on Praxis) · prep work, useful to Cortex on its own
Status: there is no Cortex–Praxis integration today, and the interim path is not decided (LLM traffic to praxis-ai as an inference server, or all traffic through Praxis via #1491). Nothing here depends on that choice: each item is useful to Cortex now, and makes an eventual move to Praxis easier whichever path is taken.
Problem
If Cortex's data plane ever moves to Praxis, the session store, archive, cost ledger, usage aggregator and agentop must keep working unchanged. Today they are fed only from inside Cortex's Go listeners, so nothing outside those listeners, Praxis included, has anything to plug into. Three things tie recording to the Go proxy:
- Events are built in 11 places. Each listener builds
pipeline.SessionEventliterals by hand, and they have drifted. - Cost is computed inside a plugin, from data the event does not carry.
- There is no way to feed events from outside the process.
What Cortex does today
Event construction — 11 literals plus the Deny helpers:
- forward proxy:
server.go:1234,:1523;transparent.go:246,:296 - reverse proxy:
server.go:457,:634,:827 - ext_proc:
server.go:355,:442,:478,:532 - shared:
sessionevent.Deny,DenyResponse
Drift this has caused:
- ext_proc never sets
requestedHost. - Only the forward proxy's request row sets
upgradeStripped. - The forward proxy's request row carries no
tls.
The back end is already clean. Every event goes through one choke point, Store.append → appendLocked, which then calls the Recorders (usage, ledger, archive). Each of those reads only the event.
Calls outside Append. Listeners also call the store directly:
Rekey:reverseproxy:617,extproc:520Claim/ClaimProcess/TouchProcessAppendTrailing/AppendPair, which take an in-process*session.Bucketto pair a tunnel's open and close rows (transparent.go:296,server.go:2633)
Cost.
- Computed by
settle.Settle(pctx, rates), called frominference-parser. - It reads
pctx.ResponseHeaders(LiteLLM cost headers),pctx.Hostand the parsed inference. Publishputs the result inExtensions.Custom, which reaches the event asplugins["cost"].- Response headers are not in the event, so cost can't be computed from an event alone.
No ingestion. The session API registers GET routes and two DELETEs only (sessionapi/server.go:199-209).
envoy-sidecar mode shows the cost of this.
cortex-envoybuilds a store but no ledger, usage aggregator or archive (warnCostLedgerInert).- So
/v1/usageanswers 404 there.
Proposal
- One set of event builders in
core/listener/internal/sessionevent:Request,Response,TunnelOpen,TunnelClose, each taking(pctx, ListenerFacts{status, failure, bytes, reason, duration}). Replace all 11 literals. Fixes the drift above. - One sink interface the listeners write through —
Append,AppendTrailing(requestID),Rekey,Claim*— so "feed the control plane" is one interface, not a struct and its methods. Pair tunnel rows byrequestIdinstead of*Bucket. - Make cost computable from the event. Narrow
settle.Settleto{host, inference, responseHeaders, isSSE}and record the cost-relevant response headers on the response event. - A loopback-only event-ingestion endpoint (e.g.
POST /v1/events, NDJSON) into the same sink. Use the same guards asDELETE /v1/sessions: loopbackHost, noOrigin, gated likeWithClearAllowed. - Version the event schema.
sessionEventWire(session.go:493) has no version, and its JSON is already persisted by the archive. Add a version, plus golden fixtures. State indocs/session-api.mdwhich fields only the store sets (sessionId,seq).
Items 1–3 and 5 benefit Cortex today. Item 4 can wait until a second producer exists (replay, tests, or another proxy).
Design questions
- Does ingestion live on the session API port, or on a separate loopback-only listener?
- Should the ingesting side recompute cost from the event, or trust a producer-supplied cost record?
- Is ext_proc's lack of
requestedHosta bug to fix in this change or separately?
Done when
- No
pipeline.SessionEvent{literal remains outsidesessionevent. core/listener/parityasserts identical event fields across forward proxy, reverse proxy and ext_proc for the same exchange.settlehas a unit test that prices from an event alone, with nopipeline.Context.- (Item 4) A replayed NDJSON capture through the ingestion endpoint produces the same
/v1/sessionsand/v1/usageas the live run.
Evidence read at main @ e455a04 (2026-10-25); not built or run.
- 主要语言
- Go
- 星标
- 18
- 派生
- 42
- 平均合并
- 12 小时 20 分钟
- 30 天内合并 PR
- 229
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rossoctl/cortex 的其他 Issue
-
UI shows costs for all sessions even when drilled into a session可能已有人在做 @esnible 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
rossoctl/cortex#1116 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
enhancement laptop
难度 5/5 一周以上 新手友好度 40/100
维护者通常 1 天内回复
-
Decouple plugins from Go pipeline internals: parser test data, session facts, serializable records未关闭enhancement laptop
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
-
enhancement laptop
难度 5/5 一周以上 新手友好度 38/100
维护者通常 1 天内回复
-
enhancement laptop
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
相似的 Issue
-
[flaky test] TestValidatorCommitterDropsEmptyStatusBatch: submits to the mock VC before its stream is registered可能已有人在做 @liran-funaro 今天认领。 未关闭coordinator flaky-test race-condition testing
难度 2/5 1-3 小时 新手友好度 83/100
hyperledger/fabric-x-committer#876 ·
维护者通常 1 天内回复
-
kind/features
难度 2/5 1-3 小时 新手友好度 65/100
TencentBlueKing/bk-nodemgr#3804 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
cloudnative-pg/plugin-barman-cloud#1187 ·
维护者通常 1 天内回复
-
[deliverclient] Remove the unused common/deliverclient package可能已有人在做 @liran-funaro 今天认领。 未关闭code-hygiene
难度 2/5 1-3 小时 新手友好度 72/100
hyperledger/fabric-x-common#236 ·
维护者通常 1 天内回复
-
consensus feature I2 S4 U2
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复