Nous.Eval.ProfileReport (nous v0.21.1)

Copy Markdown View Source

The review report for a candidate Nous.Profile: what text changed, what the evidence says, and every line of text the candidate removes.

{:ok, report} = Nous.Eval.ProfileReport.build(current, candidate, comparison: cmp, split: "test")
IO.puts(Nous.Eval.ProfileReport.render(report, format: :markdown))

It is what a human reads before promoting a profile (mix nous.profile.promote), and what mix nous.profile.diff prints.

Sections

  1. Title and lineage - both profiles (name, version, id) and the candidate's parent_id, provenance source and optimizer summary.
  2. Verdict (only with evidence) - ACCEPT or REJECT with the split, k, the number of comparable cases and the test used (paired cluster bootstrap, Holm over the gate metrics; see Nous.Eval.Compare), the gate metric table, mean tokens per sample, hard gates and the reasons for a rejection.
  3. Components changed - per added, removed or changed component, a line diff (List.myers_difference/2) with the line counts, the character delta and an estimated token delta (characters / 4).
  4. Per-case evidence (only with a comparison) - fixed / broken / flaky / unchanged counts (descriptive labels, not per-case significance), every broken case in full, fixed cases up to :max_cases, each with its pass counts and a run_id#case_id trace reference.
  5. Removed text (safety review) - every non-blank line the candidate deletes from the instructions or a tool or parameter description, verbatim. An optimizer is rewarded for deleting rules that cost it points, and its guard gates only catch what they measure, so this section is always rendered, even when empty. Lines with wording that usually carries a rule ("never", "do not", "must", "refuse", "confirm", "always", "only", "forbidden", secrets/safety/policy terms) are flagged high attention.

Base text

A profile replaces the agent's base text, and a candidate usually starts from no profile at all. Pass the agent as agent: so a component one side does not set is compared against the agent's base text (see Nous.Profile.components/1); otherwise it is compared against nothing, and a candidate that rewrites the base instructions shows no removed lines.

Untrusted text

Component text, case ids, run ids, names and provenance come from optimizer output and stores, so they are untrusted. Markdown escapes them with Nous.Eval.Reporter.Markdown.escape/1 (a | cannot break a table, a backtick cannot open code, @ cannot mention); diff blocks are fenced with a run of backticks longer than any in the text. Control characters are removed in every format, so text cannot carry terminal escapes.

Summary

Functions

The names of the high-attention patterns text matches (see "Sections"), [] for none.

Builds the report for candidate against base (a profile, or nil for the agent's base text).

Renders report as a string.

The report as JSON-native data (string keys, strings for atoms), marked "schema" => "nous.profile_report/1".

Types

t()

@type t() :: %Nous.Eval.ProfileReport{
  base: map() | nil,
  base_text?: boolean(),
  candidate: map(),
  cases: map() | nil,
  diff: map(),
  lineage: map(),
  removed: [map()],
  verdict: map() | nil
}
  • :base / :candidate - %{id, name, version, parent_id} of each profile (:base is nil without a base profile)
  • :base_text? - whether the agent's base text filled the components a profile does not set
  • :diff - Nous.Profile.diff/2 of the compared texts
  • :removed - the removed lines: %{key, line, text, attention} with line the 1-based line number in the old text and attention the matched pattern names ([] when none)
  • :verdict - nil without evidence, else the decision, split, k, n, gate metrics, gates and reasons
  • :cases - nil without a comparison, else counts and per-case rows
  • :lineage - the candidate's parent_id, provenance source and optimizer summary

Functions

attention(text)

@spec attention(String.t()) :: [String.t()]

The names of the high-attention patterns text matches (see "Sections"), [] for none.

build(base, candidate, evidence \\ nil, opts \\ [])

@spec build(
  Nous.Profile.t() | nil,
  Nous.Profile.t(),
  keyword() | map() | nil,
  keyword()
) ::
  {:ok, t()} | {:error, term()}

Builds the report for candidate against base (a profile, or nil for the agent's base text).

evidence is nil (a pure text diff) or a keyword list or map:

  • :comparison - a Nous.Eval.Compare of the base run (baseline) against the candidate run
  • :decision - :accept | :reject; defaults to :accept when the comparison's verdict is :pass and :reject otherwise. An optimizer that runs its own acceptance test passes its decision here

  • :split - the dataset split the evidence ran on, e.g. "test"
  • :gates - hard gates, [%{name: String.t(), passed?: boolean(), detail: String.t() | nil}]; a failed gate makes the default decision :reject

Options:

  • :agent - a %Nous.Agent{} whose base text fills the components a profile does not set (see "Base text")

render(report, opts \\ [])

@spec render(t(), keyword()) :: String.t()

Renders report as a string.

Options:

  • :format - :markdown (default), :console or :json (canonical JSON of to_map/1)
  • :max_cases - fixed cases listed, default 20 (broken cases are always listed in full)
  • :heading - Markdown heading level of the title, default 1
  • :context - unchanged lines shown around each change, default 2

to_map(report)

@spec to_map(t()) :: map()

The report as JSON-native data (string keys, strings for atoms), marked "schema" => "nous.profile_report/1".