Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3a72572
Auction orchestration
ChristianPavilonis Dec 16, 2025
af1fd55
different way to register
ChristianPavilonis Dec 17, 2025
97c4270
init orcestrator once instead of on every request
ChristianPavilonis Dec 17, 2025
4fa14cd
move auction out of prebid
ChristianPavilonis Dec 17, 2025
b8f07a1
concurrent requests
ChristianPavilonis Dec 17, 2025
f08b082
More clear orcestrator singleton init / getters
ChristianPavilonis Dec 22, 2025
8aa500f
Fixes memory leak, changes to owned strings.
ChristianPavilonis Dec 22, 2025
a7415c2
move OrchestrationResult block above tests
ChristianPavilonis Dec 22, 2025
4a2b92c
aps integration fixes
ChristianPavilonis Jan 2, 2026
e58c49c
aps integration fixes
ChristianPavilonis Jan 2, 2026
2a2ee2a
wip
ChristianPavilonis Jan 7, 2026
ba26c92
new auction endpoint and creative rendering
ChristianPavilonis Jan 8, 2026
8761336
Clean up and update docs.
ChristianPavilonis Jan 8, 2026
67d9e6b
clean up: remove waterfall strategy
ChristianPavilonis Jan 9, 2026
c82ffd3
remove strategy field from config
ChristianPavilonis Jan 9, 2026
f12a47e
combined documentation and moved to guide
ChristianPavilonis Jan 14, 2026
fe7110a
reorganize
ChristianPavilonis Jan 15, 2026
17ac76a
remove duplicate geo struct
ChristianPavilonis Jan 15, 2026
1d5ad78
clean up aps mock references
ChristianPavilonis Jan 15, 2026
45ed4b6
uses real width and height.
ChristianPavilonis Jan 15, 2026
b5e8087
add log on error for decoding aps price
ChristianPavilonis Jan 15, 2026
2b06095
apply floor price when running orcestrated auction
ChristianPavilonis Jan 15, 2026
ea1d2f5
add creative tstoken query param
ChristianPavilonis Jan 15, 2026
45f4b16
remove mock gam and empty gam implementation
ChristianPavilonis Jan 15, 2026
8b28827
remove gam (mock and stub impl) for now
ChristianPavilonis Jan 15, 2026
b789851
move aps decoding to mocktioneer
ChristianPavilonis Jan 15, 2026
48aace5
replaces json! macro calls with openrtb structs
ChristianPavilonis Jan 15, 2026
01cd289
rename auction.bidders to auction.providers
ChristianPavilonis Jan 15, 2026
23ae5da
removes globals for auction orcestration
ChristianPavilonis Jan 15, 2026
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Once configured, the following endpoints are available:

- `/first-party/ad` (GET): returns HTML for a single slot (`slot`, `w`, `h` query params). The server inspects returned creative HTML and rewrites:
- All absolute images and iframes to `/first-party/proxy?tsurl=<base-url>&<original-query-params>&tstoken=<sig>` (1×1 pixels are detected server‑side heuristically for logging). The `tstoken` is derived from encrypting the full target URL and hashing it.
- `/third-party/ad` (POST): accepts tsjs ad units and proxies to Prebid Server.
- `/auction` (POST): accepts tsjs ad units and runs the auction orchestrator.
- `/first-party/proxy` (GET): unified proxy for resources referenced by creatives.
- Query params:
- `tsurl`: Target URL without query (base URL) — required
Expand Down
2 changes: 1 addition & 1 deletion SEQUENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ sequenceDiagram
## Notes
- TSJS
- Served first-party at `/static/tsjs-core.min.js` (and `/static/tsjs-ext.min.js` if prebid auto-config is enabled).
- Discovers ad units and renders placeholders; either uses slot-level HTML (`/first-party/ad`) or JSON auction (`/third-party/ad`).
- Discovers ad units and renders placeholders; either uses slot-level HTML (`/first-party/ad`) or JSON auction (`/auction`).
- Publisher HTML Rewriting
- Injects TSJS loader and rewrites absolute URLs from origin domain to first-party domain during streaming.
- Creative HTML Rewriting
Expand Down
181 changes: 181 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# Testing the Auction Orchestration System

## Quick Test Summary

The auction orchestration system has been integrated into the existing Prebid endpoints. You can test it right away using the Fastly local server!

## How to Test

### 1. Start the Local Server

```bash
fastly compute serve
```

### 2. Test with Existing Endpoint

The `/auction` endpoint now uses the orchestrator when `auction.enabled = true` in config.

**Test Request:**
```bash
curl -X POST http://localhost:7676/auction \
-H "Content-Type: application/json" \
-d '{
"adUnits": [
{
"code": "header-banner",
"mediaTypes": {
"banner": {
"sizes": [[728, 90], [970, 250]]
}
}
},
{
"code": "sidebar",
"mediaTypes": {
"banner": {
"sizes": [[300, 250], [300, 600]]
}
}
}
]
}'
```

### 3. What You'll See

**With Orchestrator Enabled** (`auction.enabled = true`):
- Logs showing: `"Using auction orchestrator"`
- Parallel execution of APS (mocked) and Prebid (real)
- GAM mediation (mocked) selecting winning bids
- Final response with winning creatives

**With Orchestrator Disabled** (`auction.enabled = false`):
- Logs showing: `"Using legacy Prebid flow"`
- Direct Prebid Server call (backward compatible)

##Configuration

Edit `trusted-server.toml` to customize the auction:

```toml
# Enable/disable orchestrator
[auction]
enabled = true
providers = ["prebid", "aps"]
mediator = "adserver_mock" # If set: mediation, if omitted: highest bid wins
timeout_ms = 2000

# Mock provider configs
[integrations.aps]
enabled = true
mock = true
mock_price = 2.50

[integrations.adserver_mock]
enabled = true
endpoint = "http://localhost:6767/adserver/mediate"
timeout_ms = 500
```

## Test Scenarios

### Scenario 1: Parallel + Mediation (Default)
**Config:**
```toml
[auction]
enabled = true
providers = ["prebid", "aps"]
mediator = "adserver_mock" # Mediator configured = parallel mediation strategy
```

**Expected Flow:**
1. Prebid queries real SSPs
2. APS returns mock bids ($2.50 CPM)
3. AdServer Mock mediates between all bids
4. Winning creative returned

### Scenario 2: Parallel Only (No Mediation)
**Config:**
```toml
[auction]
enabled = true
providers = ["prebid", "aps"]
# No mediator = parallel only strategy
```

**Expected Flow:**
1. Prebid and APS run in parallel
2. Highest bid wins automatically
3. No mediation

### Scenario 3: Legacy Mode (Backward Compatible)
**Config:**
```toml
[auction]
enabled = false
```

**Expected Flow:**
- Original Prebid-only behavior
- No orchestration overhead

## Debugging

### Check Logs
The orchestrator logs extensively:
```
INFO: Using auction orchestrator
INFO: Running auction with strategy: parallel_mediation
INFO: Running 2 bidders in parallel
INFO: Requesting bids from: prebid
INFO: Prebid returned 2 bids (time: 120ms)
INFO: Requesting bids from: aps
INFO: APS (MOCK): returning 2 bids in 80ms
INFO: GAM mediation: slot 'header-banner' won by 'amazon-aps' at $2.50 CPM
```

### Verify Provider Registration
Look for these log messages on startup:
```
INFO: Registering auction provider: prebid
INFO: Registering auction provider: aps
INFO: Registering auction provider: adserver_mock
```

### Common Issues

**Issue:** `"Provider 'aps' not registered"`
**Fix:** Make sure `[integrations.aps]` is configured in `trusted-server.toml`

**Issue:** `"No providers configured"`
**Fix:** Make sure `providers = ["prebid", "aps"]` is set in `[auction]`

**Issue:** Tests fail with WASM errors
**Explanation:** Async tests don't work in WASM test environment. Integration tests via HTTP work fine!

## Next Steps

1. **Test with real Prebid Server** - Verify Prebid bids work correctly
2. **Implement real APS** - Replace mock with actual Amazon TAM API calls
3. **Implement real GAM** - Add Google Ad Manager API integration
4. **Add metrics** - Track bid rates, win rates, latency per provider

## Mock Provider Behavior

### APS (Amazon)
- Returns bids for all slots
- Default mock price: $2.50 CPM
- Always returns 2 bids
- Response time: ~80ms (simulated)

### AdServer Mock
- Acts as mediator by calling mocktioneer's mediation endpoint
- Selects winning bids based on highest CPM
- Response time varies based on mocktioneer instance

### Prebid
- **Real implementation** - makes actual HTTP calls
- Queries configured SSPs
- Returns real bids from real bidders
- Response time: varies (network dependent)
3 changes: 3 additions & 0 deletions crates/common/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#[path = "src/error.rs"]
mod error;

#[path = "src/auction_config_types.rs"]
mod auction_config_types;

#[path = "src/settings.rs"]
mod settings;

Expand Down
Loading
Loading