Documentation
¶
Overview ¶
Package actions performs the human verdicts of the review queue (spec §12.1): `kb review accept|reject` dispatches each item to the action of its queue (keep or quarantine a gated source, rescue a skipped item, recapture a broken page, write a relation or a body link, create a stub concept, record an OKF type verdict), appends the verdict as a label (spec §12.2) and resolves the item. Nothing leaves raw/ without an accept.
Index ¶
Constants ¶
const ( Accept = "accept" Reject = "reject" )
Verdicts.
const ( DidRestored = "restored" DidKept = "kept" DidQuarantined = "quarantined" DidRescued = "rescued" DidDismissed = "dismissed" DidRecaptured = "recaptured" DidWritten = "written" DidDemoted = "demoted" DidCreated = "created" DidRecorded = "recorded" DidNothing = "nothing" )
What an action did (Result.Action).
Variables ¶
var ErrNotPending = errors.New("actions: item is not pending")
ErrNotPending is returned for an item that is already resolved.
var ErrUndecided = errors.New("actions: required judgment is undecided")
ErrUndecided is returned when a judgment an action needs is undecided (invalid receipt, exhausted retries, budget, ...): nothing is changed, no label is written and the item stays pending (spec §2 principle 3: a failed judgment is never a "no").
Functions ¶
func LabelVerdict ¶
LabelVerdict maps a verdict on a queue item to its label (spec §12.2 convention: positive = keep / link, negative = remove / broken): gate, skip, link, contradiction, concept-proposal and okf-type accepts are positive; remove and recapture accepts (the source is off topic or broken) are negative, and so is accepting a link demotion. Rejects are the opposite.
Types ¶
type Deps ¶
type Deps struct {
// Scrape fetches a URL with explicit Firecrawl options (recapture).
Scrape func(ctx context.Context, sourceURL string, opts firecrawl.ScrapeOptions) (*firecrawl.ScrapeResult, error)
// Rescue fetches and ingests a skipped item, bypassing only the
// pre-fetch gate, and returns the written path (skip accept).
Rescue func(ctx context.Context, row gate.SkippedRow) (string, error)
}
Deps are the fetchers an action may need; both are optional and an action that needs a missing one fails without changing anything.
type ManualRepair ¶
type ManualRepair struct {
File string `json:"file"`
LineOrKey string `json:"line_or_key"`
Line int `json:"line,omitempty"`
Before string `json:"before"`
}
ManualRepair is one restore entry left for the owner.
func (ManualRepair) Lines ¶
func (m ManualRepair) Lines() []string
Lines renders a manual repair for the terminal: "manual repair: wiki/index/sources.md (line 12): - [[x]] — ...".
type Result ¶
type Result struct {
ID string `json:"id"`
Queue string `json:"queue"`
Verdict string `json:"verdict"`
Subject string `json:"subject"`
// Action is what was done (restored, kept, quarantined, rescued, ...).
Action string `json:"action"`
// Path is the document path after the action (the quarantine path for a
// quarantined source).
Path string `json:"path,omitempty"`
// Message is one line for the terminal.
Message string `json:"message,omitempty"`
// Manual lists the quarantine-ledger entries a restore did not replay
// because the touched file changed since (spec §7.1): each needs a
// manual repair and is printed with its file, line or key and the text
// that was removed.
Manual []ManualRepair `json:"manual,omitempty"`
Label review.Label `json:"label"`
// Closed lists sibling items (same source, other gate/remove/recapture
// queue) resolved by the same action.
Closed []string `json:"closed,omitempty"`
}
Result reports one applied verdict.
func Apply ¶
func Apply(ctx context.Context, s *session.Session, deps Deps, item review.Item, verdict string) (Result, error)
Apply performs verdict (Accept or Reject) on one pending item, appends its label and resolves it. When the action fails nothing is labelled and the item stays pending. The item's status is read again from the queue on disk right before dispatch, so an item resolved since it was selected (a sibling closed by an earlier action of the same run) returns ErrNotPending without any action.