tiny.reducer.bytes.model
Defined in bytes.
Data model for byte reduction: the error types, the oracle interface, and the settings of a run.
API (7)
Types and contracts
Public types and contracts.
Completion: Status recording which stopping condition the search reached.Error: This error set gathers the errors the reduction framework produces directly.Exhaustion: These failures arise from the workspace bounds or from another run already holding the workspace.InputError: These failures arise from the state of the input or from too small an attempt budget.Interesting: Oracle's answer about one candidate byte slice.InterestingFn: Type of the caller's oracle function pointer.Settings: Options that control how a run executes.
Source
Source: lib/reducer/src/bytes/model.zig
zig
//! Data model for byte reduction: the error types, the oracle interface, and//! the settings of a run. A run works against the caller's function that//! answers whether one candidate still reproduces the defect, the *oracle*,//! whose type is `InterestingFn`. The oracle answers *interesting* when a//! candidate (one shorter byte sequence built by deleting a run of bytes from//! the current sequence and handed to the oracle) satisfies the failure//! property under investigation, and answers *uninteresting* when the candidate//! does not show that failure.//!//! ## Error Classification//!//! The errors the package raises itself fall into two sets://! - `Exhaustion` covers a resource bound and a conflicting use of the//! workspace: `InputCapacityExceeded` and `ReductionStorageInUse`.//! - `InputError` covers a broken contract and an insufficient budget://! `AttemptBudgetExhausted` and `InitialInputUninteresting`.//!//! The `Error` alias lists those framework errors, while `reduce()` returns//! `anyerror!Result`, because a caller's callback may return any error at all,//! including one whose name matches a standard error name. An error the oracle//! returns travels straight out through `reduce()`, ending the run and giving//! up the lease this call acquired./// This error set gathers the errors the reduction framework produces directly./// The set leaves out the errors a caller's predicate returns, which `reduce()`/// passes through as `anyerror`, so that error travels outward to the caller.pub const Error = Exhaustion || InputError;/// These failures arise from the workspace bounds or from another run already/// holding the workspace.pub const Exhaustion = error{ /// The input slice is longer than the `Limits.max_input_bytes` the /// `Storage` instance was allocated for. InputCapacityExceeded, /// The `Storage` instance is already held by a running reduction or by a /// `Result` whose `deinit()` has yet to be called, so a reentrant call, and /// a second call made while the first run's result is still live, are both /// refused before any workspace byte changes. ReductionStorageInUse,};/// These failures arise from the state of the input or from too small an/// attempt budget.pub const InputError = error{ /// `Settings.max_attempts` is zero. The check runs before the workspace is /// acquired, so no workspace memory is taken or written. AttemptBudgetExhausted, /// The oracle answered uninteresting for the initial input. A run starts /// from a witness, an input that already reproduces the failure under /// investigation. InitialInputUninteresting,};/// Oracle's answer about one candidate byte slice.pub const Interesting = enum { /// The candidate reproduces the failure, or shows the property under /// investigation, so the search takes this shorter candidate as its new /// current sequence. interesting, /// The candidate does not show the property under investigation, so the /// search drops this candidate and tries another deletion. uninteresting,};/// Status recording which stopping condition the search reached.pub const Completion = enum { /// Every occurrence deletion of one byte from the returned output was put /// to the oracle and came back uninteresting. Given a deterministic oracle /// that decides from the candidate's content alone, no single byte comes /// out of the result while the result stays interesting. 1-minimality is a /// local guarantee, and it leaves open whether the result is globally /// shortest. one_minimal, /// The number of oracle calls reached `Settings.max_attempts` before the /// single-byte sweep could finish. The returned slice is an interesting /// subsequence of the initial input. The 1-minimality guarantee is given /// up, because the search stopped before trying every single-byte deletion, /// and that holds even when the result happens to be minimal. budget_exhausted,};/// Type of the caller's oracle function pointer.////// ## Calling Convention and Contract////// - **Candidate slice:** on attempt 1 the callback receives the caller's own/// `initial` slice, before any copy. On every later attempt it receives a/// slice into the scratch lane, and the next iteration overwrites those/// bytes, so the callback retains no slice into a candidate buffer past its/// return./// - **Context pointer:** the caller keeps the context alive for the whole/// synchronous call of `reduce()`, and the cast `@ptrCast(@alignCast(ctx))`/// matches the real type and alignment of what the pointer points at./// - **Answers and errors:** the callback answers interesting for the specific/// failure or symptom under investigation and uninteresting for everything/// else, which covers a candidate that fails to parse, holds invalid UTF-8,/// or hits an unrelated error. Returning a Zig error ends the run at once./// - **Side effects and determinism:** a side effect such as logging or the/// callback's own scratch allocation is allowed as long as the answer for a/// given candidate stays the same. The minimality claims rest on an oracle/// that is deterministic and decides from the candidate's content alone,/// which is an assumption about the caller's code.pub const InterestingFn = *const fn ([]const u8, *anyopaque) anyerror!Interesting;/// Options that control how a run executes.pub const Settings = struct { /// Largest number of oracle calls a run may make, counting the call on the /// caller's own input. It defaults to `10_000`. /// /// - Zero returns `error.AttemptBudgetExhausted` before the workspace is /// acquired. /// - One, with a nonempty interesting input, ends the run after attempt 1 /// with `Completion.budget_exhausted` and keeps the input as it arrived. /// - One, with an empty interesting input, ends the run with /// `Completion.one_minimal`, because a zero-length input has no deletion /// to try. /// /// The ceiling counts oracle calls alone: bytes copied, memory the callback /// allocates, and wall-clock time all sit outside it, so a callback that /// loops forever leaves `reduce()` running forever. max_attempts: usize = 10_000,};Source: lib/reducer/src/bytes/root.zig:48
zig
/// Module holding the data types, the oracle function interface, the error/// sets, and the execution settings.pub const model = @import("model.zig");Audit
| Definitions | 2 |
|---|---|
| Public names | 2 |
| Members | 2 |
| Version | 26.7.0 |
| Revision | daab053ee433 |