Skip to content

impl(039): Bedrock rank, part a, the admission under spec 030 3.12 - #422

Merged
bartekus merged 1 commit into
mainfrom
impl/039-bedrock-rank
Oct 30, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/039-bedrock-rank

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Spec 039, Bedrock rank increment (owner decision A-49), part a: the admission of 3.15 in rustev-bedrock, made under spec 030 3.12 now that spec 030 is complete (#420).

  • Binding: operations admits rank with rank/1 or rank-scored/1, max_options 1 to 100. With structured_output: none, construction refuses it naming rank_requires_structured_output; no backend or descriptor exists (section 5 row).
  • Descriptor: ranking: {modes: [listwise, pointwise, pairwise], max_candidates, listwise_scores: never | always, listwise_partial: possible}; operations lists no rank. A binding without rank keeps its bytes, digest and descriptor id (3.18 item 1, 030 3.12.2), pinned against the id main produces.
  • Mapping: 3.15.2's schemas on tool_use and json_schema for both wires. What parses is supplied as received for the core to judge (duplicates, unknown ids, a scores list of another length, a pairwise choice outside first/second); a missing or wrongly typed member is malformed_response. A self-reported confidence is never supplied. check_plan checks rank steps' descriptor ids.
  • Fixtures: documented-shape SYNTHETIC responses on both wires, both carriers, the three modes (fixtures/rank/), mapped offline and through the signed adapter on loopback only. No network, no paid call.

Not in this PR: the rules/Bedrock swap test (part b, next) and the optional paid live rank smoke (Decision 18), which is separate.

Spec: 039 implementation record gains a dated paragraph; RANKING_ACCEPTANCE.md maps the items now covered.

Verification (local): cargo test -p rustev-bedrock --locked (all suites), cargo clippy -p rustev-bedrock --all-targets -- -D warnings, cargo fmt --check, make gate.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing this PR adding Bedrock rank support (spec 039 §3.15 part a).

binding.rs

Validation logic is internally consistent: rank requires StructuredOutput::ToolUse or JsonSchema (not None); max-ops ceiling raised to 4; rank gets its own max_options range 1..=100 and mapping-version allowlist ["rank/1","rank-scored/1"]. The duplicate-op guard (seen.insert) still applies. No issues.

adapter.rs

The ranking descriptor is built from the binding's rank op (all three modes, listwise_scores mapped from the mapping version, listwise_partial: Possible). The rank op is filtered out of operations, satisfying the "declared by ranking alone" rule. The plan-check loop now handles PlanStepDetail::Rank alongside Semantic for descriptor-mismatch detection. The live-call path is correctly changed from mapping::response to mapping::response_for. All consistent with spec claims.

mapping.rs

answer now returns Value (the full parsed answer object) instead of extracting "choice" inline. For StructuredOutput::None, the bare text is wrapped in {"choice": text} so response can uniformly extract ["choice"]. Behavior for all pre-existing non-rank operations is preserved.

response calls answer then extracts ["choice"]. For rank answers (which have no "choice" at the top level), response sets output = Err(MalformedResponse) but still populates raw. This is correct because response_for overwrites output for rank operations using mapped.raw.

response_for flow for rank: (1) response parses bytes and saves raw; (2) rank_schema re-validates the projection; (3) answer(b, &mapped.raw) re-extracts the answer object; (4) rank_answer maps it to RawOutput. The double call to answer is wasteful but not a bug.

rank_schema: validates presented items (id non-empty, ≤1024 bytes; exactly 2 object keys; item null or object; no duplicates; matches candidates in order; count ≤ max_options); validates mode/count combinations (listwise: any count; pointwise: exactly 1; pairwise: exactly 2 with options == ["first","second"]); builds the correct JSON schema for each mode. Consistent with spec §3.15.2.

rank_answer: passes through ids and choices as received (duplicates, unknown ids, length mismatches delegated to core); rejects a missing or wrongly-typed member as malformed_response; for rank-scored/1, an empty scores list is correctly malformed per the rustev.backend-output/1 bound; the 1024-element guard on both ids and scores is appropriate.

Fixtures

Both fixture files are clearly labeled "documented-shape; synthetic; not a live recording". The cases cover all three modes on both wires with both structured-output carriers.

Tests

  • documented_fixtures_map_on_both_wires_for_the_three_modes: exercises request schema shape and response mapping for every wire × carrier × mode combination. Replay assertion confirms determinism.
  • fixtures_answer_through_the_signed_adapter_on_loopback_only: end-to-end through the signed HTTP adapter on a loopback port; verifies AWS4 signature header is present and exchange record is emitted.
  • answers_are_supplied_as_received_or_malformed_never_repaired: boundary cases for pass-through vs. malformed.
  • construction_refuses_rank_without_structured_output_and_invalid_rank_bindings: covers rank_requires_structured_output at parse, validate, and BedrockBackend::new layers.
  • descriptor_declares_ranking_and_rank_plans_compile_and_check: verifies descriptor content, that rank plans compile and check correctly, and that a descriptor mismatch is caught.
  • bindings_without_rank_keep_their_bytes_and_identities: golden assertion on PLAIN_DESCRIPTOR_ID confirms backward stability.

Spec note

The revision note in specs/039-model-backed-rank/spec.md accurately summarises what the PR does and correctly marks the swap test and paid smoke as deferred to part b. The RANKING_ACCEPTANCE.md updates are consistent with the test names in the new file.

No concrete defects found.

{"head": "a46ccf7983ee5d2a6c7ccedb39658d0abb0c864e", "verdict": "no-findings", "findings": []}

Subject: 8517df9...a46ccf7, diff digest 6e1385f05cff7bb3b00f66778527fb1e397b0840e083dc797d7fc69a83ed30aa, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 30, 2026
@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit f94b716 Oct 30, 2026
30 checks passed
@bartekus
bartekus deleted the impl/039-bedrock-rank branch October 30, 2026 23:54
bartekus added a commit that referenced this pull request Oct 31, 2026
Amends approved spec 039's Verification section now that the Bedrock `rank` increment has landed. For the owner to ratify before this is armed.

- The paragraph "Externally blocked until spec 030 is complete" is reworded: the offline Bedrock items owner decision A-49 moves to the Bedrock `rank` increment (section 5's `structured_output: none` row, the fixtures on both wires for the three modes, the swap test, 3.18 item 1) are delivered by #422 and #424 and declared.
- The `verify:cli` block gains `cargo test -p rustev-bedrock --locked --test ranking --test rank_swap`.
- The optional paid live Bedrock `rank` smoke (Decision 18) stays outside declared verification; no live call is part of it.

Nothing else in the approved text changes. Derived shards refreshed.

Verification (local): `cargo test -p rustev-bedrock --locked --test ranking --test rank_swap`, `spec-spine verify 039`, `make gate`, `scripts/check-authored-content.sh`, `spec-spine couple`.
bartekus added a commit that referenced this pull request Oct 31, 2026
Amends approved spec 039's Verification section now that the Bedrock `rank` increment has landed. For the owner to ratify before this is armed.

- The paragraph "Externally blocked until spec 030 is complete" is reworded: the offline Bedrock items owner decision A-49 moves to the Bedrock `rank` increment (section 5's `structured_output: none` row, the fixtures on both wires for the three modes, the swap test, 3.18 item 1) are delivered by #422 and #424 and declared.
- The `verify:cli` block gains `cargo test -p rustev-bedrock --locked --test ranking --test rank_swap`.
- The optional paid live Bedrock `rank` smoke (Decision 18) stays outside declared verification; no live call is part of it.

Nothing else in the approved text changes. Derived shards refreshed.

Verification (local): `cargo test -p rustev-bedrock --locked --test ranking --test rank_swap`, `spec-spine verify 039`, `make gate`, `scripts/check-authored-content.sh`, `spec-spine couple`.
bartekus added a commit that referenced this pull request Oct 31, 2026
Amends approved spec 039's Verification section now that the Bedrock `rank` increment has landed. For the owner to ratify before this is armed.

- The paragraph "Externally blocked until spec 030 is complete" is reworded: the offline Bedrock items owner decision A-49 moves to the Bedrock `rank` increment (section 5's `structured_output: none` row, the fixtures on both wires for the three modes, the swap test, 3.18 item 1) are delivered by #422 and #424 and declared.
- The `verify:cli` block gains `cargo test -p rustev-bedrock --locked --test ranking --test rank_swap`.
- The optional paid live Bedrock `rank` smoke (Decision 18) stays outside declared verification; no live call is part of it.

Nothing else in the approved text changes. Derived shards refreshed.

Verification (local): `cargo test -p rustev-bedrock --locked --test ranking --test rank_swap`, `spec-spine verify 039`, `make gate`, `scripts/check-authored-content.sh`, `spec-spine couple`.
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.

1 participant