Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conformance/fixtures/usd-reserve.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ increments:
amount_minor_units: 2500
opens_at: "2026-09-01T12:00:00Z"
closes_at: "2026-09-01T13:00:00Z"
extension: null
1 change: 1 addition & 0 deletions conformance/fixtures/usd-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ increments:
amount_minor_units: 1000
opens_at: "2026-09-01T12:00:00Z"
closes_at: "2026-09-01T13:00:00Z"
extension: null
1 change: 1 addition & 0 deletions conformance/fixtures/usd-tiered.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ increments:
amount_minor_units: 2500
opens_at: "2026-09-01T12:00:00Z"
closes_at: "2026-09-01T13:00:00Z"
extension: null
10 changes: 9 additions & 1 deletion conformance/scenarios/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Scenarios

The `timed-proxy/` directory contains the RFC 0001 conformance suite.
The `timed-proxy/` directory contains the executable RFC 0001 / RFC 0005 timed
online proxy bidding conformance suite.

Sibling suites live alongside `scenarios/`:

- [`../initial-scheduling/`](../initial-scheduling/) — RFC 0002 initial closing
schedule planning vectors;
- [`../shared-closing-clock/`](../shared-closing-clock/) — RFC 0003 / RFC 0004
shared closing clock vectors.
9 changes: 9 additions & 0 deletions rfcs/0001-timed-online-proxy-bidding.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,15 @@ rejected.

## Amendments

- 2026-11-24 (PR #59): added opt-in `extension.extend_on_void` (default `false`)
to timed proxy extension configuration. When `true`, an operator `void_bid`
that changes the leader or standing amount inside the trigger window extends
closing time by the same rule as a qualifying bid, records the extended
`closes_at` on `bid_voided`, and emits public `closing_time_changed`. Default
behavior (`false`) is unchanged, and RFC 0004 linked closing sets keep
`extend_on_void` disabled. Covered by conformance scenario `044` and fixture
`usd-soft-close-extend-on-void`.

- 2026-11-10 (second ruling): maintainer decision on the result of a void
(Will McLemore). He was shown that in rare histories, voiding a bidder's last
bid gives a different winner or price under rule A than under the previous
Expand Down
7 changes: 5 additions & 2 deletions rfcs/0004-flexible-live-scheduling.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,11 @@ or reductions of their maximum, do not reset an individual or group closing
clock, even when the public projection changes (for example, a raise that
crosses the reserve and moves the price to it). This departs from RFC 0001,
where any change to the public standing amount qualifies, and applies only
under this capability. A reduction cannot go below the executed floor, so in
practice it never changes the public result.
under this capability. A reduction cannot go below the executed floor (so it
never lowers the standing amount), though under RFC 0001 a leader reducing onto
a tied executable rung takes later priority and can change the leader and
standing public state; when a reduction changes no public result, it does not
extend closing under either RFC 0001 or this capability.

Every other accepted bidding command follows RFC 0001's qualifying rule. In
particular, any accepted command that changes the leader is a qualifying bid,
Expand Down
7 changes: 5 additions & 2 deletions rfcs/proposals/flexible-live-scheduling-scenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ remain unchanged. Another qualifying group bid at 15:03 moves the group to

**Then:** all closing times remain unchanged, including when a raise crosses the
reserve and moves the public price to it. Normal bidding validity checks still
apply; a reduction cannot go below the executed floor, so it never changes the
public result. This exemption covers only the current leader's own adjustments
apply; a reduction cannot go below the executed floor (so it cannot lower the
standing amount), though under RFC 0001 a leader reducing onto a tied
executable rung with later priority can change the leader and standing public
state (in this non-tied example, leader and public state remain unchanged). This
exemption covers only the current leader's own adjustments
(see FLS-21). Current engine behavior and the existing private-only example
alone do not certify it.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"bidder_role": "current_leader",
"leader_changed": false,
"public_projection_changed": false,
"note": "A reduction cannot go below the executed floor, so it cannot change the public result.",
"note": "A reduction cannot go below the executed floor, though under RFC 0001 a leader reducing onto a tied executable rung with later priority can change the leader and standing public state; in this non-tied case both remain unchanged.",
"expected_group_close": "15:02"
}
]
Expand Down
113 changes: 112 additions & 1 deletion ruby/engine/test/schema_assertions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
require_relative "support/schema_assertions"

# Guards the dependency-free schema checker itself: a conforming public event
# envelope passes, privileged leaks and missing envelope fields fail, and a
# envelope passes, privileged leaks and missing envelope fields fail,
# unevaluatedProperties/if-then-else/not/anyOf enforce 2020-12 semantics, and a
# file-relative `$ref` that cannot be resolved fails with a clear message.
class SchemaAssertionsTest < Minitest::Test
include SchemaAssertions
Expand Down Expand Up @@ -34,6 +35,116 @@ def test_missing_envelope_field_fails
assert_raises(Minitest::Assertion) { assert_matches_schema(@schema, ENVELOPE.except("event_id")) }
end

def test_unevaluated_properties_catches_extra_top_level_key_on_events_and_commands
error = assert_raises(Minitest::Assertion) do
assert_matches_schema(@schema, ENVELOPE.merge("unexpected_top_level" => true))
end
assert_match(/unevaluated key unexpected_top_level/, error.message)

place_bid_schema = load_schema("specification/commands/place-bid.schema.json")
valid_command = {
"command_id" => "command-1", "type" => "place_bid",
"auction_id" => "auction-1", "bidding_unit_id" => "unit-1",
"expected_version" => 0, "effective_at" => "2026-09-01T12:10:00Z",
"bid_id" => "bid-1", "bidder_id" => "bidder-a", "maximum_minor_units" => 10_000
}
assert_matches_schema(place_bid_schema, valid_command)
assert_raises(Minitest::Assertion) do
assert_matches_schema(place_bid_schema, valid_command.merge("operator_id" => "op-1"))
end

privileged_schema = load_schema("specification/events/privileged-event.schema.json")
valid_privileged = {
"event_id" => "command-1-0", "type" => "executed_amount_changed", "visibility" => "privileged",
"auction_id" => "auction-1", "bidding_unit_id" => "unit-1", "aggregate_version" => 2,
"event_index" => 1, "command_id" => "command-2",
"effective_at" => "2026-09-01T12:12:00Z", "recorded_at" => "2026-09-01T12:12:00Z",
"data" => {"bidder_id" => "bidder-a", "old_minor_units" => 30_000, "new_minor_units" => 10_000}
}
assert_matches_schema(privileged_schema, valid_privileged)
assert_raises(Minitest::Assertion) do
assert_matches_schema(privileged_schema, valid_privileged.merge("stray" => 1))
end
end

def test_unevaluated_properties_tracks_all_of_one_of_any_of_if_then_else_and_ref
schema = {
"allOf" => [
{"$ref" => "#/$defs/base"},
{
"if" => {"required" => ["kind"], "properties" => {"kind" => {"const" => "a"}}},
"then" => {"properties" => {"a_only" => {"type" => "integer"}}},
"else" => {"properties" => {"b_only" => {"type" => "string"}}}
}
],
"anyOf" => [
{"properties" => {"tag" => {"const" => "x"}}},
{"properties" => {"extra_tag" => {"type" => "boolean"}}}
],
"unevaluatedProperties" => false,
"$defs" => {
"base" => {"type" => "object", "required" => ["kind"], "properties" => {"kind" => {"type" => "string"}}}
}
}

assert_matches_schema(schema, {"kind" => "a", "a_only" => 1, "tag" => "x"})
assert_matches_schema(schema, {"kind" => "b", "b_only" => "ok", "extra_tag" => true})
assert_raises(Minitest::Assertion) do
assert_matches_schema(schema, {"kind" => "a", "b_only" => "wrong-branch", "tag" => "x"})
end
assert_raises(Minitest::Assertion) do
assert_matches_schema(schema, {"kind" => "a", "a_only" => 1, "tag" => "x", "stray" => 99})
end
end

def test_if_then_else_and_not_enforce_rejection_schema
rejection_schema = load_schema("specification/rejections/rejection.schema.json")

assert_matches_schema(
rejection_schema,
{"command_id" => "cmd-1", "status" => "rejected", "reason" => "bidding_closed"}
)
assert_matches_schema(
rejection_schema,
{
"command_id" => "cmd-2",
"status" => "rejected",
"reason" => "maximum_below_executed_amount",
"executed_floor_minor_units" => 10_000
}
)

assert_raises(Minitest::Assertion) do
assert_matches_schema(
rejection_schema,
{"command_id" => "cmd-3", "status" => "rejected", "reason" => "maximum_below_executed_amount"}
)
end
assert_raises(Minitest::Assertion) do
assert_matches_schema(
rejection_schema,
{
"command_id" => "cmd-4",
"status" => "rejected",
"reason" => "bidding_closed",
"executed_floor_minor_units" => 10_000
}
)
end
end

def test_not_rejects_matching_documents_and_does_not_mark_properties_evaluated
schema = {
"type" => "object",
"properties" => {"allowed" => {"type" => "string"}},
"not" => {"required" => ["forbidden"], "properties" => {"forbidden" => {"type" => "string"}}},
"unevaluatedProperties" => false
}
assert_matches_schema(schema, {"allowed" => "yes"})
assert_raises(Minitest::Assertion) { assert_matches_schema(schema, {"allowed" => "yes", "forbidden" => "no"}) }
assert_raises(Minitest::Assertion) { assert_matches_schema(schema, {"allowed" => "yes", "forbidden" => 123}) }
end

def test_file_ref_with_pointer_fragment_resolves
assert_matches_schema({"$ref" => "./base.schema.json#/properties/visibility"}, "public", root: @schema)
assert_raises(Minitest::Assertion) do
Expand Down
66 changes: 61 additions & 5 deletions ruby/engine/test/specification_guard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
require "json"
require "open3"
require "tmpdir"
require "yaml"

# scripts/validate_documents.rb is the contract's guard against unbounded
# integers. These tests run it against a scratch copy of the repository so a
# regression in the guard itself fails the engine suite, not only CI.
# integers, version drift, malformed fixtures/scenarios, and privileged leaks.
# These tests run it against a scratch copy of the repository so a regression
# in the guard itself fails the engine suite, not only CI.
class SpecificationGuardTest < Minitest::Test
REPO_ROOT = File.expand_path("../../..", __dir__)
VALIDATOR = File.join(REPO_ROOT, "scripts", "validate_documents.rb")
Expand Down Expand Up @@ -59,21 +61,75 @@ def test_shared_integer_definition_drifting_from_the_bound_fails
assert_match(%r{common/integer.schema.json: \$defs/positiveInteger must use the shared maximum}, stderr)
end

def test_fixture_missing_extension_key_fails
stderr = run_validator_with_file_edit("conformance/fixtures/usd-standard.yaml") do |content|
fixture = YAML.safe_load(content, aliases: false)
fixture.delete("extension")
YAML.dump(fixture)
end

assert_match(%r{conformance/fixtures/usd-standard.yaml: missing required keys: extension}, stderr)
end

def test_scenario_unexpected_top_level_key_fails
stderr = run_validator_with_file_edit("conformance/scenarios/timed-proxy/001-first-maximum-opens-at-opening.yaml") do |content|
"extra_key: true\n#{content}"
end

assert_match(/unexpected top-level keys: extra_key/, stderr)
end

def test_version_drift_fails
stderr = run_validator_with_file_edit("specification/VERSION") { "9.9.9-draft\n" }

assert_match(/specification\/openapi.yaml: info\.version .* does not match specification\/VERSION/, stderr)
assert_match(/specification\/asyncapi.yaml: info\.version .* does not match specification\/VERSION/, stderr)
assert_match(/ruby\/engine\/lib\/rbbb\/version\.rb: SPECIFICATION_VERSION .* does not match specification\/VERSION/, stderr)
end

def test_expanded_public_leak_denylist_catches_privileged_keys_in_public_events
stderr = run_validator_with_file_edit("conformance/scenarios/timed-proxy/001-first-maximum-opens-at-opening.yaml") do |content|
scenario = YAML.safe_load(content, aliases: false)
scenario["expected"]["public_events"][0]["bidder_notice"] = nil
YAML.dump(scenario)
end

assert_match(/public_events\[0\] contains privileged keys: bidder_notice/, stderr)
end

def test_invalid_proposal_schema_ref_fails
stderr = run_validator_with_mutation("rfcs/proposals/flexible-live-scheduling/submission.schema.json") do |schema|
schema["properties"]["command_id"] = {"$ref" => "contract.schema.json#/$defs/missing_def"}
end

assert_match(%r{rfcs/proposals/flexible-live-scheduling/submission\.schema\.json: invalid \$ref}, stderr)
end

private

def run_validator(root = REPO_ROOT)
Open3.capture3(RbConfig.ruby, File.join(root, "scripts", "validate_documents.rb"))
end

def run_validator_with_mutation(relative_path)
run_validator_with_file_edit(relative_path) do |content|
schema = JSON.parse(content)
yield schema
JSON.pretty_generate(schema)
end
end

def run_validator_with_file_edit(relative_path)
Dir.mktmpdir("rbbb-guard") do |dir|
%w[scripts specification conformance rfcs].each do |entry|
FileUtils.cp_r(File.join(REPO_ROOT, entry), dir)
end
version_target = File.join(dir, "ruby/engine/lib/rbbb/version.rb")
FileUtils.mkdir_p(File.dirname(version_target))
FileUtils.cp(File.join(REPO_ROOT, "ruby/engine/lib/rbbb/version.rb"), version_target)

target = File.join(dir, relative_path)
schema = JSON.parse(File.read(target))
yield schema
File.write(target, JSON.pretty_generate(schema))
File.write(target, yield(File.read(target)))

_stdout, stderr, status = run_validator(dir)
refute status.success?, "expected the validator to fail after mutating #{relative_path}"
Expand Down
32 changes: 22 additions & 10 deletions ruby/engine/test/support/conformance_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class ConformanceRunner
AGGREGATE_SCHEMA = "specification/state/aggregate.schema.json"
PUBLIC_STATE_SCHEMA = "specification/state/bidding-unit.schema.json"
PUBLIC_EVENT_SCHEMA = "specification/events/public-event.schema.json"
PRIVILEGED_EVENT_SCHEMA = "specification/events/privileged-event.schema.json"
REJECTION_SCHEMA = "specification/rejections/rejection.schema.json"

def initialize(test_case)
@test_case = test_case
Expand All @@ -30,14 +32,16 @@ def run(path)
public_events = []
public_envelopes = []
privileged_events = []
privileged_envelopes = []
rejections = []

scenario.fetch("commands").each do |command|
decision = engine.decide(state, command)
if decision.accepted?
public_events.concat(decision.events.select(&:public?).map(&:to_h))
privileged_events.concat(decision.events.select(&:privileged?).map(&:to_h))
public_envelopes.concat(public_event_envelopes(identity, command, decision.events))
public_envelopes.concat(event_envelopes(identity, command, decision.events, visibility: :public))
privileged_envelopes.concat(event_envelopes(identity, command, decision.events, visibility: :privileged))
state = engine.apply(state, decision.events)
else
rejections << decision.rejection
Expand All @@ -62,6 +66,12 @@ def run(path)
public_envelopes.each_with_index do |envelope, index|
assert_schema(PUBLIC_EVENT_SCHEMA, envelope, "public event[#{index}]")
end
privileged_envelopes.each_with_index do |envelope, index|
assert_schema(PRIVILEGED_EVENT_SCHEMA, envelope, "privileged event[#{index}]")
end
rejections.each_with_index do |rejection, index|
assert_schema(REJECTION_SCHEMA, rejection, "rejection[#{index}]")
end
end

private
Expand All @@ -72,28 +82,30 @@ def load_yaml(path)
YAML.safe_load_file(path, aliases: false)
end

# Wraps each public event in the transport envelope described by
# specification/events/base.schema.json. The engine emits event data with
# the command_id and aggregate_version inline; the host lifts those into
# the envelope and supplies identity, ordering, and recording fields.
def public_event_envelopes(identity, command, events)
# Wraps each engine event of the given visibility in the transport envelope
# described by specification/events/base.schema.json. The engine emits
# command_id, aggregate_version, and (on transitions) effective_at inline;
# the host lifts those into the envelope and supplies identity, ordering, and
# recording fields.
def event_envelopes(identity, command, events, visibility:)
events.each_with_index.filter_map do |event, event_index|
next unless event.public?
next unless event.visibility == visibility

data = event.data.dup
command_id = data.delete("command_id")
aggregate_version = data.delete("aggregate_version")
effective_at = data.delete("effective_at") || command.fetch("effective_at")
{
"event_id" => "#{command_id}-#{event_index}",
"type" => event.type,
"visibility" => "public",
"visibility" => visibility.to_s,
"auction_id" => identity.fetch("auction_id"),
"bidding_unit_id" => identity.fetch("bidding_unit_id"),
"aggregate_version" => aggregate_version,
"event_index" => event_index,
"command_id" => command_id,
"effective_at" => command.fetch("effective_at"),
"recorded_at" => command.fetch("effective_at"),
"effective_at" => effective_at,
"recorded_at" => effective_at,
"data" => data
}
end
Expand Down
Loading