ledgr uses stable top-level condition classes for public cost-model, timing-model, execution-window, saved-sweep, retained-series, and legacy-shape failures. User tests should assert on these classes instead of parsing message text.
Legacy shape classes
ledgr_legacy_fill_model_shape is raised when callers pass the v0.1.8
fill_model shape or legacy scalar cost fields to public entry points.
ledgr fails closed; it does not translate the legacy shape.
ledgr_legacy_config_shape is raised when reopening a stored config whose
execution shape still contains legacy fill/cost fields.
Cost and timing classes
ledgr_cost_model_unspecified is raised when a public execution entry point
omits cost_model or supplies NULL. Use ledgr_cost_zero() for explicit
zero-cost execution.
ledgr_invalid_cost_model is raised for invalid cost-model objects,
malformed cost plans, unsupported cost-plan steps, or invalid cost-model
constructor arguments.
ledgr_invalid_cost_chain_order is raised when a cost chain violates the
required order: price-transform steps before explicit-fee steps.
ledgr_invalid_timing_model is raised for non-ledgr timing-model objects or
malformed ledgr timing-model payloads.
Fill seam classes
ledgr_invalid_fill_proposal and ledgr_invalid_fill_context are raised at
the internal proposal/resolver seam when a cost resolver receives the wrong
object shape. They are stable top-level classes for tests that exercise that
seam directly.
Execution window classes
ledgr_run_window_too_short is raised when a run window contains fewer than
two executable pulses. Next-bar fill semantics require a decision pulse and a
later execution pulse.
Accounting classes
ledgr_invalid_lot_fill is raised when the lot-accounting layer receives an
invalid fill side, quantity, price, fee, or instrument id. Invalid lot input
fails closed because the ledger event stream and lot state must not diverge.
Snapshot hash classes
ledgr_snapshot_hash_invalid_timestamp is raised when snapshot hashing sees
a non-POSIXct ts_utc representation. Snapshot hashes fail closed on driver
timestamp representation drift instead of silently re-keying sealed data.
Saved sweep classes
ledgr_invalid_sweep_id is raised when a saved sweep id is not a non-empty,
non-whitespace ASCII character scalar of at most 256 bytes.
ledgr_sweep_id_exists is raised when ledgr_sweep_save() would overwrite
an existing saved sweep id.
ledgr_sweep_not_found is raised when ledgr_sweep_open() is called with
a structurally valid saved sweep id that is not present in the experiment
store.
ledgr_sweep_snapshot_not_found is raised when a saved sweep's snapshot is
not present in the provided experiment store.
ledgr_sweep_snapshot_hash_mismatch is raised when the snapshot id exists
but its hash differs from the hash stored on the saved sweep.
ledgr_sweep_schema_incompatible is raised when saved sweep tables,
columns, or artifact schema versions are not compatible with the current
ledgr version.
ledgr_invalid_sweep_retention is raised when ledgr_sweep_retention() or
ledgr_sweep(..., retain = ) receives an invalid retention policy.
ledgr_sweep_returns_unretained is raised when callers ask for retained
return rows from a scalar-only sweep.
ledgr_sweep_returns_candidate_not_found is raised when retained returns are
requested for an unknown candidate_id.
ledgr_sweep_returns_candidate_not_completed is raised when retained
returns are requested for a failed candidate or for a completed candidate
whose retained rows are missing.
ledgr_sweep_returns_first_row_invalid is raised when retained return rows
do not carry the required structural first-row NA_real_ period return.
ledgr_sweep_returns_incomplete_panel is raised when callers request a
complete retained-return panel but selected completed candidates do not share
one common timestamp grid after first-row handling.
ledgr_validation_pbo_incomplete_panel is a compatibility alias on the same
condition for future PBO/CSCV adapters.
ledgr_validation_pbo_invalid_s is raised when a PBO/CSCV request supplies
an invalid S subset count.
ledgr_validation_pbo_too_few_candidates is raised when PBO/CSCV has fewer
than two completed candidates.
ledgr_validation_pbo_too_few_observations is raised when PBO/CSCV has too
few post-first-row observations for the requested partitioning.
ledgr_validation_pbo_invalid_metric is raised when a PBO/CSCV metric is not
callable or does not return one finite numeric score per candidate.
ledgr_validation_pbo_invalid_panel is raised when PBO/CSCV receives a
non-finite retained-return panel after the structural first-row handling.
ledgr_validation_pbo_invalid_threshold is raised when a PBO/CSCV threshold
is not a finite numeric scalar.
ledgr_validation_min_trl_invalid_reference is raised when a minimum track
record length request supplies an invalid reference Sharpe ratio.
ledgr_validation_min_trl_invalid_confidence is raised when a minimum track
record length request supplies a confidence level outside (0, 1).
ledgr_validation_min_trl_invalid_risk_free is raised when a minimum track
record length request supplies an invalid per-period risk-free return.
ledgr_validation_min_trl_too_few_observations is raised when minimum track
record length has too few post-first-row observations.
ledgr_validation_min_trl_invalid_returns is raised when minimum track
record length receives non-finite or constant retained returns.
ledgr_validation_cluster_invalid_threshold is raised when retained-return
clustering receives an invalid correlation-distance threshold.
ledgr_validation_cluster_too_few_candidates is raised when retained-return
clustering has fewer than two completed candidates.
ledgr_validation_cluster_too_few_observations is raised when retained-return
clustering has too few post-first-row observations.
ledgr_validation_cluster_invalid_returns is raised when retained-return
clustering receives non-finite or constant retained returns.
ledgr_validation_dsr_invalid_effective_trials is raised when DSR receives
an invalid effective independent trial count.
ledgr_validation_dsr_too_few_candidates is raised when DSR has fewer than
two completed candidates.
ledgr_validation_dsr_invalid_confidence is raised when DSR receives a
confidence level outside (0, 1).
ledgr_validation_dsr_invalid_risk_free is raised when DSR receives an
invalid per-period risk-free return.
ledgr_validation_dsr_too_few_observations is raised when DSR has too few
post-first-row observations.
ledgr_validation_dsr_invalid_returns is raised when DSR receives
non-finite, constant, or otherwise unsupported retained returns.
ledgr_missing_package is raised when a public optional-package adapter is
requested but the package is not installed.
Walk-forward classes
ledgr_walk_forward_metric_missing is raised when a selection rule requests
a metric column that is absent from the train-window score rows.
ledgr_walk_forward_metric_class_invalid is raised when a selection metric
is not classified as valid for v1 scalar selection.
ledgr_walk_forward_no_selection is raised when all candidate values for the
requested selection metric are missing, NA, NaN, or infinite.
ledgr_walk_forward_candidate_key_missing is raised when the train-window
score rows passed to a selection rule do not include a candidate_key column.
ledgr_walk_forward_test_run_failed is raised when a selected test run
cannot produce a usable test score row.
ledgr_walk_forward_session_not_found is raised when walk-forward
inspection helpers cannot find the requested session.
ledgr_walk_forward_snapshot_hash_mismatch is raised when the supplied
snapshot does not match the persisted walk-forward session identity.
ledgr_walk_forward_snapshot_override_mismatch is raised when an explicit
snapshot override for candidate extraction has a different snapshot_id or
snapshot_hash than the walk-forward result locator.
ledgr_walk_forward_invalid_session is raised when persisted walk-forward
session rows, linked test runs, or identity fields cannot be reopened
safely.
ledgr_walk_forward_latest_without_rationale is raised when extracting
fold_seq = "latest" without an explicit selection_rationale.
ledgr_walk_forward_candidate_not_found is raised when a requested
walk-forward fold does not contain a completed selected candidate.
Related existing classes
ledgr_run_not_found is raised when run-store inspection helpers cannot
find the requested run. ledgr_unresolved_feature_id is raised when callers
ask for a concrete feature ID before parameterized feature declarations have
been resolved.
Examples
err <- try(ledgr_cost_spread_bps(-1), silent = TRUE)
inherits(attr(err, "condition"), "ledgr_invalid_cost_model")
#> [1] TRUE
err <- try(
ledgr_cost_chain(ledgr_cost_fixed_fee(1), ledgr_cost_spread_bps(5)),
silent = TRUE
)
inherits(attr(err, "condition"), "ledgr_invalid_cost_chain_order")
#> [1] TRUE