Documentation
¶
Overview ¶
Package oracle implements the differential oracle and invariant checks of the eval layer (SPEC §4, SPEC-ADDITIONS §18): two independently written implementations of the same match rules grade each other, and a planted-defect self-test proves the oracle rejects a known regression. It is a two-dimensional port of evals-differential-oracle: on a board of gems every maximal horizontal or vertical run of length >= 3 clears, and a run of length >= 4 awards one special gem.
Two nets cover two failure modes. The differential net (React vs Native) uses independent run-enumeration strategies, so an enumeration bug in one surfaces as a disagreement. The invariant net recomputes the rule (special only for a run of >= 4) directly, so a rule bug is convicted even when both resolvers agree.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InvariantsHold ¶
InvariantsHold checks the governing rules directly, recomputing the runs itself and applying the special rule independently of any resolver, so it can convict a result both implementations agree on. It asserts three rules (a port of evals-differential-oracle's check_all): a special is awarded only by a run of length >= 4, the cleared set equals the union of runs of length >= 3, and the special count stays within [0, number of runs].
Types ¶
type Board ¶
type Board [][]int
Board is a grid of gems: 0 is empty, 1..k are colors. Boards are rectangular.
func Diverges ¶
Diverges runs both resolvers over the boards and returns the first board on which they disagree, or nil if they agree everywhere.
func GenerateBoards ¶
GenerateBoards produces a deterministic set of rectangular boards for a seed, so the oracle runs the same corpus every time without a clock or ambient randomness.
type CommandDivergence ¶
CommandDivergence is the first line at which two command outputs differ (§2.1): the 1-based line number and both sides' text. It is the general form of the board oracle's divergence — two implementations that should agree are each other's oracle, so any difference convicts one of them.
func DiffOutputs ¶
func DiffOutputs(reference, candidate string) *CommandDivergence
DiffOutputs compares two command outputs line by line and returns the first divergence, or nil when they match (§2.1): the pure core of the command-level differential oracle. A line present on only one side diverges against the empty string; trailing newlines are ignored so a command that adds one still matches. It is pure — the caller runs the commands and captures their output.
type Result ¶
Result is a resolved board: the cleared cells and the special-gem count.
func Buggy ¶
Buggy is a deliberately wrong resolver used only by the self-test: it awards a special for any run of length >= 3 (the rule is >= 4). Both nets must catch it.
func Native ¶
Native resolves by an independent algorithm: it starts a run only at a cell whose left (or upper) neighbor differs, then extends. It must always agree with React.