Skip to main content

Module facets

Module facets 

Source
Expand description

Facets: one lesson phrased several ways, so keyword search finds it from different angles (document expansion, “doc2query”; internal evaluation “facets”, not published).

A lesson is written once, in the words of the correction it came from. A drone meets the same concern in other words: as a symptom it observes, as the edit it is about to make, in German, or after a rename. One model call per lesson writes 6–8 short facets, each from a fixed angle (ANGLES): the concept without names, the symptom, the action, the consequence, German, and the identifiers as aliases. Names churn and concepts persist, so the identifiers are one facet among several, never the only key. The conscience indexes every facet as its own document of the lesson (conscience.rs rank); a drone never sees them, and the question and consequence never change.

When: after borg learn and borg assimilate --from-dir --apply, for the lessons they wrote (fill with their ids), and by borg facets [--apply] for a store learned before facets existed (a dry run with a cost estimate by default). Every call’s cost is recorded in facets.jsonl beside the store. Off by default (the pre-registered test failed, internal evaluation “facets”, not published): BORG_FACETS=on turns the automatic step on; borg facets --apply works either way.

Structs§

Generated
One line of facets.jsonl beside the store: a lesson’s facets were written, at what cost.
Report
What fill did or (dry run) would do.

Constants§

ANGLES
The angles, in the order facets are stored.
EST_USD_PER_LESSON
The cost estimate of a dry run, USD per lesson. Learned (measured once): the mean on the eval stores, $0.0112 (internal evaluation “facets”, not published), rounded up. Display only: what borg facets without --apply says a run would cost; nothing is capped by it.
FACET_CHARS
Guard: one facet is a phrase, not a paragraph; a longer one is cut.
MAX_FACETS
At most this many facets per lesson, each at most FACET_CHARS characters. Guard: bounds what a model answer adds to a lesson (and to the search index) however much it writes; the prompt asks for 6 to 8, so a good answer is never cut.
USAGE

Functions§

appended_ids
Ids of the lessons on lines appended to path after byte from (len_of before a learn run).
beside
facets.jsonl beside a lessons file.
enabled
True only with BORG_FACETS=on: borg learn and borg assimilate then write facets (internal evaluation “facets”, not published: off by default).
fill
Give facets to the lessons of the store at path that have none (latest version), limited to only when given. A dry run (apply false) asks nothing and writes nothing. With apply, jobs calls at a time; each lesson with facets is appended as a new line of the same id and version (readers keep the latest line), its question, consequence and every other field unchanged, unless the lesson changed in the store meanwhile. After 3 failures without a success the run stops asking.
generate
One model call: the lesson’s facets and the call’s cost. None: no usable answer.
len_of
The store’s length in bytes (0 if absent).
main
borg facets [--apply] [--store PATH] [--jobs N]: backfill facets for a store (default: this collective’s, BORG_HOME). The exit code.
parse
The facets in a model answer: trimmed, clipped, unique, in ANGLES order (stable within an angle), at most MAX_FACETS. None when fewer than MIN_FACETS remain.
prompt
The prompt for one lesson: what it says, nothing about where it is stored.

Type Aliases§

Ask
The model call: (prompt, JSON schema) -> (answer, cost in USD). learn::ask_model in production.