callrows

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package callrows reads the model-call log this build always writes (`~/.codeaf/logs/calls.jsonl`, internal/calllog) back into rows.

IT IS ONE READER BECAUSE THERE IS ONE FILE. Two instruments now read it — cmd/codeaf-census, which prints what went wrong, and cmd/codeaf-replay, which asks what a different chooser would have done — and a second reader is a second answer to "was this attempt a failure", "which of these two rows is the same call" and "what does a torn last line mean". The census had all three in its own package and the first replay bench (`internal/lane/replay_bench_test.go`, deleted with this package's first caller) had its own copy of the first two, already disagreeing about whether a hedge's losing arm is a failure. So the reading lives here, once, and an instrument built next week starts from the same rows.

WHAT IS NOT HERE is anything that turns a row into a JUDGEMENT. Which family a failure belongs to, which signature it shares with another, what a regret is — those are each instrument's own argument about the same bytes, and they stay where the argument is made.

Index

Constants

View Source
const TimeLayout = "2006-01-02T15:04:05.000Z07:00"

TimeLayout is how internal/calllog spells Record.Time.

Variables

This section is empty.

Functions

func SaidStatus

func SaidStatus(said string) int

SaidStatus is the status a router's own sentence carries — `API error (429): …` — and zero when it carries none.

IT IS READ BECAUSE THE COLUMN CANNOT BE TRUSTED TO HOLD IT. A refusal delivered inside an opened 200 stream has a 200 in its status column and a 429 in its words, and no upstream 5xx in ten days of this log ever reached the column at all. internal/provider's velocity.go states the same rule as a law for the live path: a refusal is acted on from what it SAYS and never from where it was read.

func Unspellable

func Unspellable(line string) bool

Unspellable reports whether a line that would not decode carried a float JSON has no spelling for. Go's decoder refuses the whole object on one of these, so the row is lost — which is the defect internal/calllog's finite.go exists to prevent and an instrument exists to notice if it ever comes back.

Types

type Row

type Row struct {
	calllog.Record
	// HazardCeilingLegacy is `deadline_ms` as builds before 2026-09-10 wrote it.
	// It was never a deadline — it is the moment the wait controller was going
	// to think about a second request — and it is read here under its old name
	// so a reading of a mixed log does not silently lose ten days of it.
	HazardCeilingLegacy int64 `json:"deadline_ms,omitempty"`

	// At is Time parsed, and zero when the row carried no readable stamp.
	At time.Time
	// Raw is the line as it arrived, kept only long enough for the checks that
	// are about the bytes rather than about the values — a float JSON has no
	// spelling for reaches a reader as a decode failure, not as a number.
	Raw string
}

Row is one line of the log, decoded.

IT EMBEDS THE RECORD THE WRITER WRITES rather than restating its fields, so that a field added to internal/calllog is readable here the day it lands and the two can never disagree about a name. What is added beside it is the one thing an embedding cannot carry: a field a wave RENAMED, which ten days of already-written rows still spell the old way.

func Read

func Read(path string) ([]Row, error)

Read reads every line of a log into rows, in time order, skipping the ones that are not JSON at all.

A LINE THAT WILL NOT DECODE IS COUNTED AND NEVER FATAL. A log is appended to by a live process; the last line of a file read while a call is landing can be half a line, and an instrument that refused to run over it would be an instrument nobody could use while the thing it measures is running.

func (Row) Exhaust

func (r Row) Exhaust() bool

Exhaust reports whether this row is the losing arm of a hedge this build won.

IT IS NOT A FAILURE AND COUNTING IT AS ONE MEASURES OUR OWN HEDGING POLICY. The arm really was sent and really was cut off, so its row says `context canceled` and reads exactly like a caller walking away: 1,204 of 3,906 bad rows in the first census, the largest cause family in it, every one of them the price of a race that ended with an answer.

The sentence is read as well as the field because the rows already in the log have only the sentence — internal/provider wrote the note for one wave while this field was landing, and a reading that could not see it would show the finding disappearing on the day of the rebuild rather than on the day the build changed.

func (Row) Failed

func (r Row) Failed() bool

Failed reports whether this attempt produced no usable answer — which is NOT the same as a status outside the 200s, and that is the whole point of reading the log at all. A refusal delivered inside an opened 200 stream is a 200 in every dashboard and a failure to the person waiting.

func (Row) Finished

func (r Row) Finished() bool

Finished reports whether this row is the end of an attempt rather than its beginning. A start row omits nothing and says so in one word; everything else is an outcome (internal/calllog's PhaseStart).

func (Row) HazardCeiling

func (r Row) HazardCeiling() int64

HazardCeiling is how long this attempt had before the wait controller would have acted on its silence, whichever build wrote the row.

func (Row) Lost

func (r Row) Lost() bool

Lost is a line that was written and could not be read back: a float JSON has no spelling for took the whole object with it. It is kept as a row so a reader can count it, and it is not an attempt — nothing about the call it was about survived.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL