Skip to content

feat(score): parse BendableScore from its text form - #278

Merged
blackopsrepl merged 1 commit into
SolverForge:mainfrom
slapers:feat/bendable-parseable-score
Nov 26, 2026
Merged

blackopsrepl merged 1 commit into
SolverForge:mainfrom
slapers:feat/bendable-parseable-score

Conversation

@slapers

@slapers slapers commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Change and Purpose

BendableScore<H, S> is the only built-in score type without ParseableScore. The solver
setup requires ParseableScore on the solution's score (for example run.rs and
runtime/compiler/defaults.rs, which read best_score_limit from solver.toml), so a
#[planning_solution] scored with a BendableScore does not compile. Today a bendable model
needs a newtype around the score, and the orphan rule makes that newtype re-implement Score,
the operators and Display by hand.

BendableScore now implements ParseableScore in bendable.rs, next to its Display:

  • parse reads the Display form, [h1/h2]hard/[s1/s2/s3]soft, with each level list in
    brackets, highest priority first; empty brackets hold zero levels. It trims whitespace like
    the other parsers and rejects a level list whose length is not exactly H (or S).
  • to_string_repr is the Display form, so parse and render round-trip.

The bracket format has no fixed field per suffix, so impl_score_parse! does not apply; the
impl is hand-written like SoftScore's and HardSoftDecimalScore's. The core wireframe now
lists ParseableScore for BendableScore instead of "Does not implement
ParseableScore".

Verification

Commands and results on the branch (macOS, Rust 1.99.1):

  • make build: ok.
  • cargo test --workspace: ok, every crate green, including 149 solverforge-core lib tests.
  • make fmt-check, make clippy, make doc-names, make file-length,
    make facade-reachability, make public-api: all ok. The public API snapshot is unchanged
    (it does not list trait impls).
  • make deps was not run: cargo-machete is not installed here. The change touches no
    manifest.

New tests in score/tests/bendable_score.rs, following the other score types' tests:
test_parse, test_display, display_then_parse_round_trips (including i64::MIN/MAX),
parse_rejects_a_wrong_number_of_levels and parse_rejects_malformed_text. They do not
compile on main, where BendableScore has no parse.

Review Checklist

  • I understand the final diff and will address review findings.
  • The change follows the relevant architecture and style rules in AGENTS.md.
  • Tests cover changed behavior.
  • Documentation and affected wireframes match any public API changes.
  • The contribution respects copyright, attribution, license compatibility, and confidentiality.

BendableScore now implements ParseableScore, so a planning solution scored
with it satisfies the planning_solution bounds and reads score limits such as
termination.best_score_limit from solver.toml.

The text form is the Display form, `[h1/h2]hard/[s1/s2/s3]soft`; parse
rejects a level list whose length is not exactly H (or S).
@blackopsrepl
blackopsrepl merged commit 710390e into SolverForge:main Nov 26, 2026
7 checks passed
@blackopsrepl

Copy link
Copy Markdown
Collaborator

Thanks @slapers — bendable models can now use BendableScore directly, no newtype needed. Ships in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants