Skip to content

factory: every finished job counts toward cost, and a new job's estimate before it exists - #2188

Merged
santoshkumarradha merged 4 commits into
app/v3from
c36/cost-pools
Nov 2, 2026
Merged

santoshkumarradha merged 4 commits into
app/v3from
c36/cost-pools

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

What

The factory's cost history now counts every finished job, not only the ones that have a read.

  • Jobs nobody read get a figure. A job with no read, or with fewer than five similar read jobs, is measured on its kind: the latest 12 finished jobs of the same kind, read or not, in its repository first and then in every repository. The estimate carries basis: "kind", and the app says from 12 jobs in api, not read. A job with enough similar read jobs keeps basis: "read", and that match always comes first.
  • Calibration per basis. Each basis is backtested and widened on its own. A kind pool that misses does not widen read matches, and the read matches do not hide its misses. queue.desk.estimates.basis carries {read, kind} hit rates.
  • Estimate before a job exists. factory.estimate_new {factory, repo, kind} (GET /v1/repos/{owner}/{repo}/estimate?kind=K) answers the kind pool's figure from the finished jobs the caller can see. It shows nothing below five jobs. This is for New job's "Start now". No model is asked.

The no-figure rule is unchanged: below five jobs on both bases, the app shows "no cost history yet". No background AI is added.

Tests (written first)

  • estimate: an unread job is measured on its kind; a read job with too few similar jobs falls back to its kind; a read match comes before the pool; the pool borrows from every repository but never from another kind; the pool uses the latest jobs; a new job is estimated before it exists; calibration is kept per basis and only the basis that misses is widened.
  • wire: basis on the estimate and the per-basis hit rate.
  • serve: the before-create route, its no-figure case, and refused query keys.
  • appwire: factory.estimate_new is registered, announced only by an engine that serves it, and its params are checked.
  • app against the real server and store: five finished unread jobs give the next job's figure.

Docs

PROTOCOL (method row, basis, per-basis calibration, factory.estimate_new), the manual's cost section, and the changelog.

🤖 Generated with Claude Code

@santoshkumarradha
santoshkumarradha marked this pull request as ready for review November 2, 2026 13:45
@santoshkumarradha
santoshkumarradha merged commit e05b9ae into app/v3 Nov 2, 2026
@santoshkumarradha
santoshkumarradha deleted the c36/cost-pools branch November 2, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant