accounting: use the accountant's own size bound (Withhold(res)), stop passing TokensBefore

オープン
#2,159 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
57/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
backend

調査の方向性

Read core/accounting/host.go around line 654 and core/accounting/metrics.go around line 252, then check the accountant dependency versions and the v0.11.0 API. Update the dependency and make both call-site changes described in the issue; run the accounting tests. Done when Withhold receives only the result and the observation no longer sets TokensBefore.

索引モデルが issue の本文から書いたものです。

説明

Summary

Cortex passes its own request size to the accountant in two places. accountant v0.11.0 measures the size itself, and the host size is going away (rossoctl/context-guru#1523). Please move Cortex to the library's own size bound.

What we found

Cortex main at 2cb6e041 (accountant pinned at v0.10.0):

  • core/accounting/host.go:654: accountant.Withhold(p.result, before). This is the legacy form with a host size.
  • core/accounting/metrics.go:252: acmetrics.Observation{..., TokensBefore: tokensBefore}. A positive TokensBefore makes the sink use the legacy host bound.

Why

  • With a host size, the bound compares host tokens against the accountant's ratio tokens. That is two different measures. Removed text that is denser than the request average (hex, code) can then make an honest request fail as implausible_size (rossoctl/accountant#126 review).
  • From v0.11.0, Withhold(res) with no size measures the client messages itself (Result.MessageTokens, PricedOp.SavedMessages/CausedMessages, design §6.7). Tool declarations are not counted.
  • context-guru moved to it in rossoctl/context-guru#1529.

Proposal

  1. Bump to accountant and accountant/metrics v0.11.0.
  2. core/accounting/host.go: call accountant.Withhold(p.result).
  3. core/accounting/metrics.go: stop setting TokensBefore in the Observation.
  4. This is a behavior change for Cortex: the size bound moves from the host measure to the library measure. The Cortex owners decide it.

After this merges, the accountant removes the size argument of Withhold, SizeNotGiven and Observation.TokensBefore in its next minor release (rossoctl/context-guru#1523, #1524).

主要言語
Go
スター
31
フォーク
49
平均マージ
9時間 43分
マージ済み PR(30日)
367

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rossoctl/cortex のほかの issue

rossoctl/cortex の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。