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
8 changes: 8 additions & 0 deletions dag/extdeps/currency/currency.dag
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ fn currency_numeric_code(c: CurrencyCode) -> Int {
}
}

// THE ISO 4217 ALPHABETIC CODE, the spelling APIs put on the wire ("USD").
fn currency_alphabetic_code(c: CurrencyCode) -> String {
match c {
Eur => "EUR"
Usd => "USD"
}
}

fn currency_code_eq(a: CurrencyCode, b: CurrencyCode) -> Bool {
currency_numeric_code(c: a) == currency_numeric_code(c: b)
}
615 changes: 615 additions & 0 deletions dag/extdeps/ebay/browse.dag

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion dag/extdeps/ebay/mock_corpus.dag
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ data ebay_inventory_mock_case_publish_offer: PublishedMockCase = PublishedMockCa
case_id: 0
}

data ebay_browse_mock_case_search_item_summaries: PublishedMockCase = PublishedMockCase {
operation_key: "ebay.Browse.SearchItemSummaries",
service: "ebay.Browse",
operation: "SearchItemSummaries",
case_id: 0
}

data ebay_browse_mock_case_get_item: PublishedMockCase = PublishedMockCase {
operation_key: "ebay.Browse.GetItem",
service: "ebay.Browse",
operation: "GetItem",
case_id: 0
}

data ebay_published_mock_corpus: List<PublishedMockCase> = [
ebay_oauth_mock_case_mint_application_token,
ebay_oauth_mock_case_mint_user_token,
Expand All @@ -74,5 +88,7 @@ data ebay_published_mock_corpus: List<PublishedMockCase> = [
ebay_inventory_mock_case_get_inventory_items,
ebay_inventory_mock_case_create_offer,
ebay_inventory_mock_case_get_offers,
ebay_inventory_mock_case_publish_offer
ebay_inventory_mock_case_publish_offer,
ebay_browse_mock_case_search_item_summaries,
ebay_browse_mock_case_get_item
]
8 changes: 6 additions & 2 deletions dag/extdeps/ebay/rate_limits.dag
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import extdeps.uri { Uri, Https }
import extdeps.api_rate_limit { UpstreamRateLimit, RateLimitPeriod, PerMinute, PerDay }

// eBay's published call limits for the scopes the corpus consumes: the OAuth token endpoint at
// 1,000 per minute and the Sell Inventory API at 2,000,000 per day per application.
// 1,000 per minute, the Sell Inventory API at 2,000,000 per day per application, and the Buy
// Browse API at 5,000 per day for every method except getItems (which has its own 5,000 and no
// consumer here).

data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority {
uri: Uri {
Expand All @@ -18,4 +20,6 @@ data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority {
data ebay_oauth_rate_limit: UpstreamRateLimit = UpstreamRateLimit { upstream: "ebay" as NonEmptyStr, scope: "oauth" as NonEmptyStr, requests: 1000, period: PerMinute }
data ebay_sell_inventory_rate_limit: UpstreamRateLimit = UpstreamRateLimit { upstream: "ebay" as NonEmptyStr, scope: "sell_inventory" as NonEmptyStr, requests: 2000000, period: PerDay }

data ebay_rate_limits: List<UpstreamRateLimit> = [ebay_oauth_rate_limit, ebay_sell_inventory_rate_limit]
data ebay_buy_browse_rate_limit: UpstreamRateLimit = UpstreamRateLimit { upstream: "ebay" as NonEmptyStr, scope: "buy_browse" as NonEmptyStr, requests: 5000, period: PerDay }

data ebay_rate_limits: List<UpstreamRateLimit> = [ebay_oauth_rate_limit, ebay_sell_inventory_rate_limit, ebay_buy_browse_rate_limit]
2 changes: 2 additions & 0 deletions dag/gunbc/census_closure_frontier.dag
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import gunbc.cloudflare.r2_token_mint { cloudflare_r2_token_mint_frontier_rows }
import extdeps.cloudflare.account_api_tokens { cloudflare_account_api_tokens_frontier_rows }
import extdeps.cloudflare.r2 { cloudflare_r2_frontier_rows }
import extdeps.backblaze.b2 { backblaze_b2_frontier_rows }
import extdeps.ebay.browse { ebay_browse_frontier_rows }
import gunbc.cloudflare.r2_permission_group_observe { cloudflare_permission_group_observation_frontier_rows }

fn census_closure_frontier_row_groups() -> List<List<FrontierRow>> {
Expand Down Expand Up @@ -64,6 +65,7 @@ fn census_closure_frontier_row_groups() -> List<List<FrontierRow>> {
cloudflare_account_api_tokens_frontier_rows,
cloudflare_r2_frontier_rows,
backblaze_b2_frontier_rows,
ebay_browse_frontier_rows,
cloudflare_permission_group_observation_frontier_rows,
colo_types_frontier_rows,
]
Expand Down
3 changes: 2 additions & 1 deletion dag/gunbc/extdeps_scope_frontier.dag
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ data scope_carrier_paths: List<String> = [
"dag/extdeps/docker/images/gitcommit90_glm_53_one_spark.dag",
"dag/extdeps/docker/images/timothystewart6_vllm_gb10.dag",
"dag/extdeps/docker/images/xomoxcc_dgx_spark_sglang.dag",
"dag/extdeps/vllm/recipe_deepseek_v4_1_flash.dag"
"dag/extdeps/vllm/recipe_deepseek_v4_1_flash.dag",
"dag/extdeps/ebay/browse.dag"
]

data scope_machinery_exempt_paths: List<String> = [
Expand Down
16 changes: 13 additions & 3 deletions dag/test/claim/capacity_quota_witness_test.dag
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,30 @@ fn w_all_limits() -> List<UpstreamRateLimit> {
concat(concat(concat(github_rate_limits, gcp_rate_limits), ebay_rate_limits), [anthropic_messages_rate_limit, openai_chat_rate_limit])
}

data w_expected_scope_keys: List<String> = [
"github-core",
"gcp-iam_credentials", "gcp-iam_admin", "gcp-service_usage", "gcp-secret_manager", "gcp-sts",
"ebay-oauth", "ebay-sell_inventory", "ebay-buy_browse",
"anthropic-messages",
"openai-chat"
]

fn w_headroom(p: Pool<Count, One>, at: EpochSecs) -> Int {
match pool_reading_at(pool: p, at: at) {
PoolRead { committed: _, ceiling: _, headroom: h, over_committed: _ } => h.count
PoolReadingRefused { at: _, anchor: _ } => -1
}
}

// TEN SCOPES, EACH ITS OWN POOL, EACH NAMED ONCE: the seventeen annotations collapsed to ten typed
// rows because eight GitHub services drew from one core pool. Keys are distinct, the pool
// EVERY SCOPE ITS OWN POOL, EACH NAMED ONCE: the seventeen annotations collapsed to typed rows
// because eight GitHub services drew from one core pool. The roster is an IDENTITY join against
// the scopes each upstream module publishes, in both directions, not a count. Keys are distinct, the pool
// ceiling is the published count, and the period is the published period in seconds.
test fn every_upstream_scope_is_one_pool_with_the_published_ceiling_and_period() -> Bool {
let limits = w_all_limits()
let keys = map(limits, l => upstream_rate_limit_key(l: l) as String)
length(limits) == 10
all(w_expected_scope_keys, k => length(filter(keys, x => x == k)) == 1)
&& all(keys, k => length(filter(w_expected_scope_keys, x => x == k)) == 1)
&& all(keys, k => length(filter(keys, x => x == k)) == 1)
&& all(limits, l =>
(quota_partition(limit: l) as String) == join(["quota-", upstream_rate_limit_key(l: l) as String], "")
Expand Down
134 changes: 134 additions & 0 deletions dag/test/claim/ebay_browse_witness_test.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
module test.claim.ebay_browse_witness

import std.types { Bool, String, List }
import v2.std.algebra { for_all, filter }
import std.roster_frontier { FrontierRow, FrontierSubject, DeclSubject, frontier_rows_well_formed, frontier_subject_eq }
import std.decl_ref { decl_ref }
import gunbc.census_closure_frontier { census_closure_frontier_rows }
import std.measure { money_amount_micro }
import extdeps.currency.currency { Usd, Eur, currency_alphabetic_code }
import extdeps.api_rate_limit { rate_limit_period_seconds }
import extdeps.ebay.rate_limits { ebay_buy_browse_rate_limit, ebay_rate_limits }
import extdeps.ebay.inventory {
New, UsedExcellent, ForPartsOrNotWorking, ManufacturerRefurbished, FixedPrice, Auction
}
import extdeps.ebay.browse {
browse_condition_from_id, browse_condition_id, browse_condition_id_rows,
BrowsePriceAtMost, BrowseBuyingOptionsAnyOf, BrowseConditionAnyOf, BrowseDeliveryCountry,
BrowseFilterRendered, BrowseFilterEmptyValueSet, BrowseFilterConditionHasNoId,
browse_render_filters, browse_contextual_location_header,
browse_search_page_admission, ebay_browse_frontier_rows, browse_search_limit_default, BrowseSearchPageAdmitted, BrowseSearchLimitOutOfRange,
BrowseSearchOffsetNotAPageBoundary, BrowseSearchBeyondResultWindow
}

data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly

test fn witness_browse_condition_id_3000_decodes_to_used_excellent() -> Bool {
match browse_condition_from_id(raw: "3000") {
Present { value: UsedExcellent } => true
_ => false
}
}

test fn witness_browse_condition_id_7000_decodes_to_for_parts() -> Bool {
match browse_condition_from_id(raw: "7000") {
Present { value: ForPartsOrNotWorking } => true
_ => false
}
}

test fn witness_browse_unlisted_condition_id_is_absent() -> Bool {
match browse_condition_from_id(raw: "3500") {
Absent => true
_ => false
}
}

test fn witness_browse_manufacturer_refurbished_has_no_condition_id() -> Bool {
match browse_condition_id(c: ManufacturerRefurbished) {
Absent => true
_ => false
}
}

test fn witness_browse_condition_ids_round_trip_through_the_table() -> Bool {
for_all(xs: browse_condition_id_rows, predicate: fn(r) {
match browse_condition_id(c: r.condition) {
Present { value: id } => id == r.condition_id
Absent => false
}
})
}

test fn witness_browse_filters_render_the_published_grammar() -> Bool {
match browse_render_filters(filters: [
BrowsePriceAtMost { max: money_amount_micro(count: 179990000), currency: Usd },
BrowseBuyingOptionsAnyOf { formats: [FixedPrice, Auction] },
BrowseConditionAnyOf { conditions: [New, UsedExcellent] },
BrowseDeliveryCountry { country: "US" }
]) {
BrowseFilterRendered { param: p } =>
p == "price:[..179.990000],priceCurrency:USD,buyingOptions:\{FIXED_PRICE|AUCTION},conditionIds:\{1000|3000},deliveryCountry:US"
_ => false
}
}

test fn witness_browse_filter_refuses_a_condition_without_an_id() -> Bool {
match browse_render_filters(filters: [
BrowseDeliveryCountry { country: "US" },
BrowseConditionAnyOf { conditions: [New, ManufacturerRefurbished] }
]) {
BrowseFilterConditionHasNoId { condition: ManufacturerRefurbished } => true
_ => false
}
}

test fn witness_browse_filter_refuses_an_empty_value_set() -> Bool {
match browse_render_filters(filters: [BrowseBuyingOptionsAnyOf { formats: [] }]) {
BrowseFilterEmptyValueSet { field: f } => f as String == "buyingOptions"
_ => false
}
}

test fn witness_browse_contextual_location_header_matches_upstream_example() -> Bool {
browse_contextual_location_header(country: "US", postal_code: "19406") == "contextualLocation=country%3DUS%2Czip%3D19406"
}

test fn witness_currency_alphabetic_code_names_each_currency() -> Bool {
currency_alphabetic_code(c: Usd) == "USD" && currency_alphabetic_code(c: Eur) == "EUR"
}

test fn witness_browse_rate_limit_is_five_thousand_per_day_and_enrolled() -> Bool {
ebay_buy_browse_rate_limit.requests == 5000
&& rate_limit_period_seconds(p: ebay_buy_browse_rate_limit.period) == 86400
&& length(filter(xs: ebay_rate_limits, predicate: fn(l) { l.scope as String == "buy_browse" })) == 1
}

test fn witness_browse_search_page_admission_holds_the_published_bounds() -> Bool {
(match browse_search_page_admission(limit: browse_search_limit_default, offset: 0) { BrowseSearchPageAdmitted { limit: l, offset: _ } => l == 50 _ => false })
&& (match browse_search_page_admission(limit: 200, offset: 9800) { BrowseSearchPageAdmitted { limit: _, offset: _ } => true _ => false })
&& (match browse_search_page_admission(limit: 201, offset: 0) { BrowseSearchLimitOutOfRange { limit: l } => l == 201 _ => false })
&& (match browse_search_page_admission(limit: 200, offset: 150) { BrowseSearchOffsetNotAPageBoundary { limit: _, offset: o } => o == 150 _ => false })
&& (match browse_search_page_admission(limit: 200, offset: 10000) { BrowseSearchBeyondResultWindow { limit: _, offset: o } => o == 10000 _ => false })
}

test fn witness_browse_frontier_rows_are_well_formed_and_in_the_census() -> Bool {
frontier_rows_well_formed(rows: ebay_browse_frontier_rows)
&& for_all(xs: w_browse_expected_frontier_subjects(), predicate: fn(want) {
length(filter(xs: ebay_browse_frontier_rows, predicate: fn(row) { frontier_subject_eq(a: row.subject, b: want) })) == 1
})
&& for_all(xs: ebay_browse_frontier_rows, predicate: fn(row) {
length(filter(xs: w_browse_expected_frontier_subjects(), predicate: fn(want) { frontier_subject_eq(a: row.subject, b: want) })) == 1
})
&& for_all(xs: ebay_browse_frontier_rows, predicate: fn(row) {
any(census_closure_frontier_rows(), c => frontier_subject_eq(a: c.subject, b: row.subject))
})
}

fn w_browse_expected_frontier_subjects() -> List<FrontierSubject> {
[
DeclSubject { ref: decl_ref(module_path: "extdeps.ebay.browse", decl_name: "browse_production_access") },
DeclSubject { ref: decl_ref(module_path: "extdeps.ebay.browse", decl_name: "BrowseItem") },
DeclSubject { ref: decl_ref(module_path: "extdeps.ebay.browse", decl_name: "BrowseSearchPagedCollection") },
]
}
7 changes: 7 additions & 0 deletions src/v1/stage0/src/extdeps_currency_currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ pub fn currency_numeric_code(c: CurrencyCode) -> i64 {
}
}

pub fn currency_alphabetic_code(c: CurrencyCode) -> String {
match c.clone() {
CurrencyCode::Eur => "EUR".to_string(),
CurrencyCode::Usd => "USD".to_string(),
}
}

pub fn currency_code_eq(a: CurrencyCode, b: CurrencyCode) -> bool {
(currency_numeric_code(a.clone()) == currency_numeric_code(b.clone()))
}
Expand Down
Loading