Skip to main content

cmd/taisce/reportrebuild.go

cmd/taisce · 108 lines · 3 declarations · source

Declarations

const MaxReportPage

const MaxReportPage = 100

MaxReportPage bounds one invocation. Each community written is one model call, and an operator who asked for a thousand would hold a terminal open for an hour with nothing committed until it ended. A hundred is the same ceiling `rebuild project` puts on sources, for the same reason.

source

func reportRebuildCommand

func reportRebuildCommand(ctx context.Context, args []string, out io.Writer) error

reportRebuildCommand writes the reports a project is missing, now.

Why this command exists

A report is deleted when the facts under it change, and the worker's subject pass writes it back a few per tick. That is correct — a report describing a claim the system has stopped believing is worse than a missing one — and it leaves a window in which a recall that would have returned a theme returns nothing. `rebuild staleness` says how large that window is; without this command the only answer to it was to wait.

Why it is the subject pass and not something new

The pass partitions the graph, then writes what `Unwritten` returns. Running it here means an operator's rewrite and the worker's are the same code: the partition is not recomputed differently, the writer identity is the same, and a report written by hand is indistinguishable from one written on a tick — which is what makes it safe for both to be running at once.

Why it needs the model and the operator connection

Writing a report is a model call, so this cannot be the connection `status` and `cancel` use. The identity it stamps comes from the configured reporter, so a deployment whose report prompt changed rewrites into the new identity simply by running it.

source

type reportRebuildResult

type reportRebuildResult struct {
Project string `json:"project"`
Entities int `json:"entities"`
Communities int `json:"communities"`
Written int `json:"reports_written"`
Failed int `json:"reports_failed"`
}

reportRebuildResult is what one invocation did, in the vocabulary the subject pass already uses.

Written and Failed are this invocation's, never a total: a community whose material a model refused is counted here and tried again by the next invocation or the next tick, because `Unwritten` selects on the absence of a report rather than on a record of having tried.

source