Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Feed recording, sessions and cost through one input that does not depend on the Go listeners

未关闭
#1,497 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
go
领域
api, backend, databases

调研方向

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 内容生成。

描述

enhancement laptop

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:

  1. Events are built in 11 places. Each listener builds pipeline.SessionEvent literals by hand, and they have drifted.
  2. Cost is computed inside a plugin, from data the event does not carry.
  3. There is no way to feed events from outside the process.

What Cortex does today

Event construction — 11 literals plus the Deny helpers:

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:

Cost.

  • Computed by settle.Settle(pctx, rates), called from inference-parser.
  • It reads pctx.ResponseHeaders (LiteLLM cost headers), pctx.Host and the parsed inference.
  • Publish puts the result in Extensions.Custom, which reaches the event as plugins["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-envoy builds a store but no ledger, usage aggregator or archive (warnCostLedgerInert).
  • So /v1/usage answers 404 there.

Proposal

  1. 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.
  2. 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 by requestId instead of *Bucket.
  3. Make cost computable from the event. Narrow settle.Settle to {host, inference, responseHeaders, isSSE} and record the cost-relevant response headers on the response event.
  4. A loopback-only event-ingestion endpoint (e.g. POST /v1/events, NDJSON) into the same sink. Use the same guards as DELETE /v1/sessions: loopback Host, no Origin, gated like WithClearAllowed.
  5. 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 in docs/session-api.md which 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

  1. Does ingestion live on the session API port, or on a separate loopback-only listener?
  2. Should the ingesting side recompute cost from the event, or trust a producer-supplied cost record?
  3. Is ext_proc's lack of requestedHost a bug to fix in this change or separately?

Done when

  • No pipeline.SessionEvent{ literal remains outside sessionevent.
  • core/listener/parity asserts identical event fields across forward proxy, reverse proxy and ext_proc for the same exchange.
  • settle has a unit test that prices from an event alone, with no pipeline.Context.
  • (Item 4) A replayed NDJSON capture through the ingestion endpoint produces the same /v1/sessions and /v1/usage as 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rossoctl/cortex 的其他 Issue

查看 rossoctl/cortex 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。