Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/columbia/environment/agent-browser/browser-use +152 -0
- tasks/columbia/environment/agent-browser/gateway.py +524 -0
- tasks/columbia/environment/candidate-abi/websitebench-candidate-preflight +5 -0
- tasks/columbia/environment/mailbox/Dockerfile +5 -0
- tasks/columbia/environment/mailbox/mailbox.py +2433 -0
- tasks/columbia/environment/reference/.websitebench-reference-tls/ca.crt +20 -0
- tasks/columbia/environment/reference/.websitebench-reference-tls/reference.crt +20 -0
- tasks/columbia/environment/reference/.websitebench-reference-tls/reference.key +28 -0
- tasks/columbia/environment/reference/.websitebench-reference-tls/tls_proxy.py +164 -0
- tasks/columbia/environment/reference/Dockerfile +19 -0
- tasks/columbia/environment/reference/README.md +5 -0
- tasks/columbia/environment/reference/backend/model.json +435 -0
- tasks/columbia/environment/reference/backend/runtime.json +75 -0
- tasks/columbia/environment/reference/clone/app.py +707 -0
- tasks/columbia/environment/reference/clone/backend/site_backend_integration.py +112 -0
- tasks/columbia/environment/reference/clone/data/categories.json +0 -0
- tasks/columbia/environment/reference/clone/data/design-tokens.json +586 -0
- tasks/columbia/environment/reference/clone/data/measured-membership.json +1 -0
- tasks/columbia/environment/reference/clone/data/messages-en-US.json +0 -0
- tasks/columbia/environment/reference/clone/data/plp-visnav.json +169 -0
- tasks/columbia/environment/reference/clone/data/products.json +0 -0
- tasks/columbia/environment/reference/clone/requirements.txt +2 -0
- tasks/columbia/environment/reference/clone/site/catalog.py +422 -0
- tasks/columbia/environment/reference/clone/site/grid.py +170 -0
- tasks/columbia/environment/reference/clone/site/models.py +170 -0
- tasks/columbia/environment/reference/clone/site/render.py +75 -0
- tasks/columbia/environment/reference/clone/site/session.py +164 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1011622_485_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1011651_442_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1011671_450_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1011772_160_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275701_032_a2_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275701_032_a6_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275701_101_a3_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275701_101_a6_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275701_372_a2_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275701_482_a3_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275701_580_a4_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275701_580_a6_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275711_011_a1_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275711_278_ht3_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275711_350_a3_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275711_446_a2_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275711_482_a3_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1275711_661_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1277021_161_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1286061_019_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1286061_100_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1286061_482_f_om.webp +3 -0
- tasks/columbia/environment/reference/clone/static/assets/media/1286062_445_f_om.webp +3 -0
tasks/columbia/environment/agent-browser/browser-use
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Forward the safe Browser Use CLI subset to the isolated browser sidecar."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
import shutil
|
| 9 |
+
import sys
|
| 10 |
+
import urllib.error
|
| 11 |
+
import urllib.request
|
| 12 |
+
import uuid
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
GATEWAY_URL = os.environ.get(
|
| 17 |
+
"WEBSITEBENCH_BROWSER_GATEWAY_URL",
|
| 18 |
+
"http://browser:9224/v1/command",
|
| 19 |
+
)
|
| 20 |
+
SHARED_ROOT = Path("/browser-share")
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _translate_candidate_origin(arguments: list[str]) -> list[str]:
|
| 24 |
+
public_origin = os.environ.get(
|
| 25 |
+
"WEBSITEBENCH_CANDIDATE_URL", "http://127.0.0.1:3000"
|
| 26 |
+
).rstrip("/")
|
| 27 |
+
browser_origin = os.environ.get(
|
| 28 |
+
"WEBSITEBENCH_BROWSER_CANDIDATE_URL", "http://candidate:3000"
|
| 29 |
+
).rstrip("/")
|
| 30 |
+
return [
|
| 31 |
+
browser_origin + value[len(public_origin) :]
|
| 32 |
+
if value == public_origin or value.startswith(public_origin + "/")
|
| 33 |
+
else value
|
| 34 |
+
for value in arguments
|
| 35 |
+
]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def _command_index(arguments: list[str]) -> int | None:
|
| 39 |
+
index = 0
|
| 40 |
+
while index < len(arguments):
|
| 41 |
+
value = arguments[index]
|
| 42 |
+
if value in {"--session"}:
|
| 43 |
+
index += 2
|
| 44 |
+
continue
|
| 45 |
+
if value.startswith("--session=") or value == "--json":
|
| 46 |
+
index += 1
|
| 47 |
+
continue
|
| 48 |
+
if value in {"-h", "--help"}:
|
| 49 |
+
return None
|
| 50 |
+
if value.startswith("-"):
|
| 51 |
+
return index
|
| 52 |
+
return index
|
| 53 |
+
return None
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def _prepare_screenshot(arguments: list[str]) -> tuple[list[str], Path | None, Path | None]:
|
| 57 |
+
forwarded = list(arguments)
|
| 58 |
+
command_index = _command_index(forwarded)
|
| 59 |
+
if command_index is None or forwarded[command_index] != "screenshot":
|
| 60 |
+
return forwarded, None, None
|
| 61 |
+
|
| 62 |
+
local_path: Path | None = None
|
| 63 |
+
path_index: int | None = None
|
| 64 |
+
for index in range(command_index + 1, len(forwarded)):
|
| 65 |
+
if forwarded[index] == "--path" and index + 1 < len(forwarded):
|
| 66 |
+
path_index = index + 1
|
| 67 |
+
local_path = Path(forwarded[path_index])
|
| 68 |
+
break
|
| 69 |
+
if not forwarded[index].startswith("-"):
|
| 70 |
+
path_index = index
|
| 71 |
+
local_path = Path(forwarded[path_index])
|
| 72 |
+
break
|
| 73 |
+
if local_path is None:
|
| 74 |
+
local_path = Path("screenshot.png")
|
| 75 |
+
forwarded.append(str(local_path))
|
| 76 |
+
path_index = len(forwarded) - 1
|
| 77 |
+
|
| 78 |
+
shared_path = SHARED_ROOT / f"screenshot-{uuid.uuid4().hex}.png"
|
| 79 |
+
assert path_index is not None
|
| 80 |
+
forwarded[path_index] = str(shared_path)
|
| 81 |
+
return forwarded, local_path, shared_path
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def _prepare_asset(arguments: list[str]) -> tuple[list[str], Path | None, Path | None]:
|
| 85 |
+
forwarded = list(arguments)
|
| 86 |
+
command_index = _command_index(forwarded)
|
| 87 |
+
if command_index is None or forwarded[command_index] != "save-asset":
|
| 88 |
+
return forwarded, None, None
|
| 89 |
+
tail = forwarded[command_index + 1 :]
|
| 90 |
+
if len(tail) != 2:
|
| 91 |
+
# Let the gateway reject the malformed command with its own message.
|
| 92 |
+
return forwarded, None, None
|
| 93 |
+
local_path = Path(tail[1])
|
| 94 |
+
shared_path = SHARED_ROOT / f"asset-{uuid.uuid4().hex}"
|
| 95 |
+
forwarded[command_index + 2] = str(shared_path)
|
| 96 |
+
return forwarded, local_path, shared_path
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def main() -> int:
|
| 100 |
+
translated = _translate_candidate_origin(sys.argv[1:])
|
| 101 |
+
arguments, local_screenshot, shared_screenshot = _prepare_screenshot(translated)
|
| 102 |
+
if local_screenshot is None:
|
| 103 |
+
arguments, local_screenshot, shared_screenshot = _prepare_asset(arguments)
|
| 104 |
+
request = urllib.request.Request(
|
| 105 |
+
GATEWAY_URL,
|
| 106 |
+
data=json.dumps({"argv": arguments}, separators=(",", ":")).encode("utf-8"),
|
| 107 |
+
headers={"Content-Type": "application/json"},
|
| 108 |
+
method="POST",
|
| 109 |
+
)
|
| 110 |
+
try:
|
| 111 |
+
with urllib.request.urlopen(request, timeout=240) as response:
|
| 112 |
+
payload = json.load(response)
|
| 113 |
+
except urllib.error.HTTPError as exc:
|
| 114 |
+
try:
|
| 115 |
+
detail = json.loads(exc.read().decode("utf-8")).get("error")
|
| 116 |
+
except (UnicodeError, ValueError, AttributeError):
|
| 117 |
+
detail = None
|
| 118 |
+
print(detail or f"Browser Use gateway refused the command (HTTP {exc.code})", file=sys.stderr)
|
| 119 |
+
return 2
|
| 120 |
+
except (OSError, UnicodeError, ValueError) as exc:
|
| 121 |
+
print(f"Browser Use gateway unavailable: {exc}", file=sys.stderr)
|
| 122 |
+
return 2
|
| 123 |
+
|
| 124 |
+
stdout = payload.get("stdout", "")
|
| 125 |
+
stderr = payload.get("stderr", "")
|
| 126 |
+
if local_screenshot is not None and shared_screenshot is not None:
|
| 127 |
+
# The shared file is moved to the caller's path below; report that path, not the
|
| 128 |
+
# transient gateway-owned one, so a later read of the printed path succeeds.
|
| 129 |
+
if isinstance(stdout, str):
|
| 130 |
+
stdout = stdout.replace(str(shared_screenshot), str(local_screenshot))
|
| 131 |
+
if isinstance(stderr, str):
|
| 132 |
+
stderr = stderr.replace(str(shared_screenshot), str(local_screenshot))
|
| 133 |
+
if isinstance(stdout, str) and stdout:
|
| 134 |
+
print(stdout, end="" if stdout.endswith("\n") else "\n")
|
| 135 |
+
if isinstance(stderr, str) and stderr:
|
| 136 |
+
print(stderr, end="" if stderr.endswith("\n") else "\n", file=sys.stderr)
|
| 137 |
+
|
| 138 |
+
if local_screenshot is not None and shared_screenshot is not None and shared_screenshot.exists():
|
| 139 |
+
try:
|
| 140 |
+
local_screenshot.parent.mkdir(parents=True, exist_ok=True)
|
| 141 |
+
shutil.copyfile(shared_screenshot, local_screenshot)
|
| 142 |
+
shared_screenshot.unlink(missing_ok=True)
|
| 143 |
+
except OSError as exc:
|
| 144 |
+
print(f"Browser file transfer failed: {exc}", file=sys.stderr)
|
| 145 |
+
return 2
|
| 146 |
+
|
| 147 |
+
exit_code = payload.get("exit_code", 2)
|
| 148 |
+
return exit_code if isinstance(exit_code, int) and 0 <= exit_code <= 255 else 2
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
if __name__ == "__main__":
|
| 152 |
+
raise SystemExit(main())
|
tasks/columbia/environment/agent-browser/gateway.py
ADDED
|
@@ -0,0 +1,524 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Constrained Browser Use command gateway for browser-only references.
|
| 3 |
+
|
| 4 |
+
The gateway is the only process that joins the reference network. It exposes
|
| 5 |
+
interactive browser actions, but deliberately excludes arbitrary Python,
|
| 6 |
+
JavaScript evaluation, DOM serialization, cloud/tunnel commands, and direct
|
| 7 |
+
CDP attachment. The Agent container can inspect the rendered site without
|
| 8 |
+
obtaining a general-purpose HTTP path to its source responses.
|
| 9 |
+
|
| 10 |
+
Static assets are the one exception to that boundary. ``assets`` lists the
|
| 11 |
+
reference-origin images, icons, fonts and media the current page uses, and
|
| 12 |
+
``save-asset`` copies one of them into the Agent's repository. Stylesheets and
|
| 13 |
+
scripts are the reference's code: formal runs never hand them to the Agent, so
|
| 14 |
+
both commands refuse them, as they refuse documents and API responses.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
from __future__ import annotations
|
| 18 |
+
|
| 19 |
+
import json
|
| 20 |
+
import os
|
| 21 |
+
import re
|
| 22 |
+
import ssl
|
| 23 |
+
import subprocess
|
| 24 |
+
import threading
|
| 25 |
+
import urllib.error
|
| 26 |
+
import urllib.parse
|
| 27 |
+
import urllib.request
|
| 28 |
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
| 29 |
+
from pathlib import Path
|
| 30 |
+
from typing import Any
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
MAX_REQUEST_BYTES = 64 * 1024
|
| 34 |
+
MAX_OUTPUT_BYTES = 4 * 1024 * 1024
|
| 35 |
+
COMMAND_TIMEOUT_SEC = 180
|
| 36 |
+
SESSION_PATTERN = re.compile(r"[A-Za-z0-9][A-Za-z0-9_.-]{0,63}\Z")
|
| 37 |
+
SHARED_ROOT = Path("/browser-share").resolve()
|
| 38 |
+
ASSET_MAX_BYTES = 32 * 1024 * 1024
|
| 39 |
+
ASSET_TIMEOUT_SEC = 60
|
| 40 |
+
ASSET_LIST_LIMIT = 2000
|
| 41 |
+
ASSET_SHARED_NAME = re.compile(r"asset-[0-9a-f]{32}\Z")
|
| 42 |
+
# Static media only: a document, JSON or other API body is never an asset, and neither is
|
| 43 |
+
# a stylesheet or script (the agent must not receive the reference's CSS or JavaScript).
|
| 44 |
+
STATIC_CONTENT_PREFIXES = ("image/", "font/", "audio/", "video/")
|
| 45 |
+
STATIC_CONTENT_TYPES = frozenset(
|
| 46 |
+
{
|
| 47 |
+
"application/font-woff",
|
| 48 |
+
"application/font-woff2",
|
| 49 |
+
"application/x-font-woff",
|
| 50 |
+
"application/x-font-ttf",
|
| 51 |
+
"application/x-font-otf",
|
| 52 |
+
"application/font-sfnt",
|
| 53 |
+
"application/vnd.ms-fontobject",
|
| 54 |
+
}
|
| 55 |
+
)
|
| 56 |
+
# Servers often label fonts and media application/octet-stream; accept that
|
| 57 |
+
# label only when the path itself names a static file.
|
| 58 |
+
STATIC_EXTENSIONS = frozenset(
|
| 59 |
+
{
|
| 60 |
+
".png", ".jpg", ".jpeg", ".gif", ".webp", ".avif", ".svg", ".ico", ".bmp",
|
| 61 |
+
".woff", ".woff2", ".ttf", ".otf", ".eot",
|
| 62 |
+
".mp4", ".webm", ".ogv", ".mp3", ".ogg", ".wav", ".m4a",
|
| 63 |
+
}
|
| 64 |
+
)
|
| 65 |
+
# Reference code is refused whatever its declared type: a script served as octet-stream or a
|
| 66 |
+
# stylesheet under an image-like path must not pass.
|
| 67 |
+
CODE_CONTENT_TYPES = frozenset(
|
| 68 |
+
{
|
| 69 |
+
"text/css",
|
| 70 |
+
"text/javascript",
|
| 71 |
+
"text/ecmascript",
|
| 72 |
+
"application/javascript",
|
| 73 |
+
"application/x-javascript",
|
| 74 |
+
"application/ecmascript",
|
| 75 |
+
"application/wasm",
|
| 76 |
+
}
|
| 77 |
+
)
|
| 78 |
+
CODE_EXTENSIONS = frozenset({".css", ".scss", ".less", ".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx", ".map", ".wasm"})
|
| 79 |
+
# Gateway-owned inventory script: returns only URLs the page references or loaded.
|
| 80 |
+
ASSET_INVENTORY_JS = r"""JSON.stringify((() => {
|
| 81 |
+
const found = new Set();
|
| 82 |
+
const add = (value, base) => { try { if (value) found.add(new URL(value, base || location.href).href); } catch (e) {} };
|
| 83 |
+
const urls = (text, base) => { for (const m of String(text || '').matchAll(/url\(\s*["']?([^"')]+)["']?\s*\)/g)) add(m[1], base); };
|
| 84 |
+
for (const entry of performance.getEntriesByType('resource')) add(entry.name);
|
| 85 |
+
for (const image of document.images) { add(image.currentSrc); add(image.src); }
|
| 86 |
+
for (const node of document.querySelectorAll('link[href]')) add(node.href);
|
| 87 |
+
for (const node of document.querySelectorAll('script[src]')) add(node.src);
|
| 88 |
+
for (const node of document.querySelectorAll('source[src], source[srcset], video[src], video[poster], audio[src], img[srcset]')) {
|
| 89 |
+
add(node.src); add(node.poster);
|
| 90 |
+
for (const part of String(node.srcset || '').split(',')) add(part.trim().split(/\s+/)[0]);
|
| 91 |
+
}
|
| 92 |
+
let count = 0;
|
| 93 |
+
for (const element of document.querySelectorAll('*')) {
|
| 94 |
+
if (++count > 5000) break;
|
| 95 |
+
const style = getComputedStyle(element);
|
| 96 |
+
urls(style.backgroundImage); urls(style.listStyleImage); urls(style.content);
|
| 97 |
+
}
|
| 98 |
+
for (const sheet of document.styleSheets) {
|
| 99 |
+
try { for (const rule of sheet.cssRules) urls(rule.cssText, sheet.href || location.href); } catch (e) {}
|
| 100 |
+
}
|
| 101 |
+
return [...found];
|
| 102 |
+
})())"""
|
| 103 |
+
REAL_BROWSER_USE = os.environ.get(
|
| 104 |
+
"WEBSITEBENCH_BROWSER_USE_REAL",
|
| 105 |
+
"/usr/local/bin/browser-use-real",
|
| 106 |
+
)
|
| 107 |
+
SAFE_COMMANDS = frozenset(
|
| 108 |
+
{
|
| 109 |
+
"open",
|
| 110 |
+
"click",
|
| 111 |
+
"type",
|
| 112 |
+
"input",
|
| 113 |
+
"scroll",
|
| 114 |
+
"back",
|
| 115 |
+
"screenshot",
|
| 116 |
+
"state",
|
| 117 |
+
"switch",
|
| 118 |
+
"close-tab",
|
| 119 |
+
"keys",
|
| 120 |
+
"select",
|
| 121 |
+
"hover",
|
| 122 |
+
"dblclick",
|
| 123 |
+
"rightclick",
|
| 124 |
+
"cookies",
|
| 125 |
+
"close",
|
| 126 |
+
"sessions",
|
| 127 |
+
}
|
| 128 |
+
)
|
| 129 |
+
FORBIDDEN_COMMANDS = frozenset(
|
| 130 |
+
{
|
| 131 |
+
"install",
|
| 132 |
+
"init",
|
| 133 |
+
"setup",
|
| 134 |
+
"doctor",
|
| 135 |
+
"upload",
|
| 136 |
+
"eval",
|
| 137 |
+
"extract",
|
| 138 |
+
"get",
|
| 139 |
+
"python",
|
| 140 |
+
"tunnel",
|
| 141 |
+
"cloud",
|
| 142 |
+
"profile",
|
| 143 |
+
"wait",
|
| 144 |
+
}
|
| 145 |
+
)
|
| 146 |
+
FORBIDDEN_GLOBAL_OPTIONS = frozenset(
|
| 147 |
+
{"--headed", "--profile", "--cdp-url", "--connect", "--mcp", "--template"}
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
class CommandRejected(ValueError):
|
| 152 |
+
"""Raised when an Agent command crosses the browser-only boundary."""
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def _origin(value: str) -> tuple[str, str, int]:
|
| 156 |
+
parsed = urllib.parse.urlsplit(value)
|
| 157 |
+
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
|
| 158 |
+
raise ValueError(f"invalid browser origin: {value!r}")
|
| 159 |
+
port = parsed.port or (443 if parsed.scheme == "https" else 80)
|
| 160 |
+
return parsed.scheme, parsed.hostname.lower(), port
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def allowed_origins() -> frozenset[tuple[str, str, int]]:
|
| 164 |
+
values = (
|
| 165 |
+
os.environ.get(
|
| 166 |
+
"WEBSITEBENCH_BROWSER_REFERENCE_URL", "https://reference:8080"
|
| 167 |
+
),
|
| 168 |
+
os.environ.get(
|
| 169 |
+
"WEBSITEBENCH_BROWSER_CANDIDATE_URL", "http://candidate:3000"
|
| 170 |
+
),
|
| 171 |
+
os.environ.get(
|
| 172 |
+
"WEBSITEBENCH_BROWSER_MAILBOX_URL", "http://mailbox:8026"
|
| 173 |
+
),
|
| 174 |
+
)
|
| 175 |
+
return frozenset(_origin(value) for value in values)
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def reference_origin() -> tuple[str, str, int]:
|
| 179 |
+
return _origin(
|
| 180 |
+
os.environ.get("WEBSITEBENCH_BROWSER_REFERENCE_URL", "https://reference:8080")
|
| 181 |
+
)
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
def _reference_asset_url(value: str) -> str:
|
| 185 |
+
try:
|
| 186 |
+
requested = _origin(value)
|
| 187 |
+
except (TypeError, ValueError) as exc:
|
| 188 |
+
raise CommandRejected(str(exc)) from exc
|
| 189 |
+
if requested != reference_origin():
|
| 190 |
+
raise CommandRejected("static assets can only be saved from the reference origin")
|
| 191 |
+
parsed = urllib.parse.urlsplit(value)
|
| 192 |
+
if parsed.username is not None or parsed.password is not None:
|
| 193 |
+
raise CommandRejected("asset URL must not carry credentials")
|
| 194 |
+
return urllib.parse.urlunsplit(parsed._replace(fragment=""))
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def is_reference_code(url: str, content_type: str = "") -> bool:
|
| 198 |
+
media = content_type.split(";", 1)[0].strip().lower()
|
| 199 |
+
suffix = Path(urllib.parse.urlsplit(url).path).suffix.lower()
|
| 200 |
+
return media in CODE_CONTENT_TYPES or suffix in CODE_EXTENSIONS
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def is_static_asset(url: str, content_type: str) -> bool:
|
| 204 |
+
if is_reference_code(url, content_type):
|
| 205 |
+
return False
|
| 206 |
+
media = content_type.split(";", 1)[0].strip().lower()
|
| 207 |
+
if media.startswith(STATIC_CONTENT_PREFIXES) or media in STATIC_CONTENT_TYPES:
|
| 208 |
+
return True
|
| 209 |
+
suffix = Path(urllib.parse.urlsplit(url).path).suffix.lower()
|
| 210 |
+
return media in {"application/octet-stream", "binary/octet-stream", ""} and suffix in STATIC_EXTENSIONS
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def _parse_global_options(arguments: list[str]) -> tuple[str, int]:
|
| 214 |
+
session = "default"
|
| 215 |
+
index = 0
|
| 216 |
+
while index < len(arguments):
|
| 217 |
+
value = arguments[index]
|
| 218 |
+
if value == "--session":
|
| 219 |
+
if index + 1 >= len(arguments):
|
| 220 |
+
raise CommandRejected("--session requires a value")
|
| 221 |
+
session = arguments[index + 1]
|
| 222 |
+
index += 2
|
| 223 |
+
continue
|
| 224 |
+
if value.startswith("--session="):
|
| 225 |
+
session = value.partition("=")[2]
|
| 226 |
+
index += 1
|
| 227 |
+
continue
|
| 228 |
+
if value == "--json":
|
| 229 |
+
index += 1
|
| 230 |
+
continue
|
| 231 |
+
if value in {"-h", "--help"}:
|
| 232 |
+
break
|
| 233 |
+
if value in FORBIDDEN_GLOBAL_OPTIONS or any(
|
| 234 |
+
value.startswith(option + "=") for option in FORBIDDEN_GLOBAL_OPTIONS
|
| 235 |
+
):
|
| 236 |
+
raise CommandRejected(f"Browser Use option {value!r} is disabled")
|
| 237 |
+
if value.startswith("-"):
|
| 238 |
+
raise CommandRejected(f"unsupported Browser Use option {value!r}")
|
| 239 |
+
break
|
| 240 |
+
if not SESSION_PATTERN.fullmatch(session):
|
| 241 |
+
raise CommandRejected("invalid Browser Use session name")
|
| 242 |
+
return session, index
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def validate_command(raw_arguments: Any) -> list[str]:
|
| 246 |
+
if not isinstance(raw_arguments, list) or not raw_arguments:
|
| 247 |
+
raise CommandRejected("argv must be a non-empty string array")
|
| 248 |
+
if len(raw_arguments) > 128:
|
| 249 |
+
raise CommandRejected("too many Browser Use arguments")
|
| 250 |
+
arguments: list[str] = []
|
| 251 |
+
for value in raw_arguments:
|
| 252 |
+
if not isinstance(value, str) or "\x00" in value or len(value) > 16_384:
|
| 253 |
+
raise CommandRejected("invalid Browser Use argument")
|
| 254 |
+
arguments.append(value)
|
| 255 |
+
|
| 256 |
+
for value in arguments:
|
| 257 |
+
if value in FORBIDDEN_GLOBAL_OPTIONS or any(
|
| 258 |
+
value.startswith(option + "=") for option in FORBIDDEN_GLOBAL_OPTIONS
|
| 259 |
+
):
|
| 260 |
+
raise CommandRejected(f"Browser Use option {value!r} is disabled")
|
| 261 |
+
|
| 262 |
+
_session, command_index = _parse_global_options(arguments)
|
| 263 |
+
if (
|
| 264 |
+
command_index == len(arguments) - 1
|
| 265 |
+
and arguments[command_index] in {"-h", "--help"}
|
| 266 |
+
):
|
| 267 |
+
return arguments
|
| 268 |
+
if command_index >= len(arguments):
|
| 269 |
+
raise CommandRejected("missing Browser Use command")
|
| 270 |
+
command = arguments[command_index]
|
| 271 |
+
if command == "assets":
|
| 272 |
+
if len(arguments) != command_index + 1:
|
| 273 |
+
raise CommandRejected("assets takes no arguments; it lists the current page")
|
| 274 |
+
return arguments
|
| 275 |
+
if command == "save-asset":
|
| 276 |
+
tail = arguments[command_index + 1 :]
|
| 277 |
+
if len(tail) != 2:
|
| 278 |
+
raise CommandRejected("save-asset requires a reference asset URL and a destination path")
|
| 279 |
+
url = _reference_asset_url(tail[0])
|
| 280 |
+
if is_reference_code(url):
|
| 281 |
+
raise CommandRejected("reference stylesheets and scripts are not available to the agent")
|
| 282 |
+
destination = Path(tail[1]).resolve()
|
| 283 |
+
if destination.parent != SHARED_ROOT or ASSET_SHARED_NAME.fullmatch(destination.name) is None:
|
| 284 |
+
raise CommandRejected("saved assets must use one gateway-owned path")
|
| 285 |
+
return arguments[: command_index + 1] + [url, str(destination)]
|
| 286 |
+
if command in FORBIDDEN_COMMANDS:
|
| 287 |
+
raise CommandRejected(
|
| 288 |
+
f"Browser Use command {command!r} is disabled for browser-only references"
|
| 289 |
+
)
|
| 290 |
+
if command not in SAFE_COMMANDS:
|
| 291 |
+
raise CommandRejected(f"unsupported Browser Use command {command!r}")
|
| 292 |
+
|
| 293 |
+
if command == "open":
|
| 294 |
+
urls = [
|
| 295 |
+
value
|
| 296 |
+
for value in arguments[command_index + 1 :]
|
| 297 |
+
if "://" in value
|
| 298 |
+
]
|
| 299 |
+
if len(urls) != 1:
|
| 300 |
+
raise CommandRejected("open requires exactly one absolute URL")
|
| 301 |
+
try:
|
| 302 |
+
requested_origin = _origin(urls[0])
|
| 303 |
+
except (TypeError, ValueError) as exc:
|
| 304 |
+
raise CommandRejected(str(exc)) from exc
|
| 305 |
+
if requested_origin not in allowed_origins():
|
| 306 |
+
raise CommandRejected("browser navigation target is outside task origins")
|
| 307 |
+
|
| 308 |
+
if command == "screenshot":
|
| 309 |
+
# The bundled Browser Use CLI is `screenshot [--full] [path]`; accept the spellings
|
| 310 |
+
# agents reach for (`--full-page`, `--path X`, `--path=X`) and hand the CLI its own.
|
| 311 |
+
path_values: list[str] = []
|
| 312 |
+
options: list[str] = []
|
| 313 |
+
tail = arguments[command_index + 1 :]
|
| 314 |
+
index = 0
|
| 315 |
+
while index < len(tail):
|
| 316 |
+
value = tail[index]
|
| 317 |
+
if value == "--path":
|
| 318 |
+
if index + 1 >= len(tail):
|
| 319 |
+
raise CommandRejected("screenshot --path requires a value")
|
| 320 |
+
path_values.append(tail[index + 1])
|
| 321 |
+
index += 2
|
| 322 |
+
continue
|
| 323 |
+
if value.startswith("--path="):
|
| 324 |
+
path_values.append(value.partition("=")[2])
|
| 325 |
+
index += 1
|
| 326 |
+
continue
|
| 327 |
+
if value in {"--full", "--full-page"}:
|
| 328 |
+
if "--full" not in options:
|
| 329 |
+
options.append("--full")
|
| 330 |
+
index += 1
|
| 331 |
+
continue
|
| 332 |
+
if value in {"--json", "-h", "--help"}:
|
| 333 |
+
options.append(value)
|
| 334 |
+
index += 1
|
| 335 |
+
continue
|
| 336 |
+
if value.startswith("-"):
|
| 337 |
+
raise CommandRejected(f"unsupported screenshot option {value!r}")
|
| 338 |
+
path_values.append(value)
|
| 339 |
+
index += 1
|
| 340 |
+
paths = [Path(value).resolve() for value in path_values]
|
| 341 |
+
if (
|
| 342 |
+
len(paths) != 1
|
| 343 |
+
or paths[0].parent != SHARED_ROOT
|
| 344 |
+
or re.fullmatch(r"screenshot-[0-9a-f]{32}\.png", paths[0].name) is None
|
| 345 |
+
):
|
| 346 |
+
raise CommandRejected("screenshots must use one gateway-owned PNG path")
|
| 347 |
+
return arguments[: command_index + 1] + options + [str(paths[0])]
|
| 348 |
+
|
| 349 |
+
return arguments
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
_COMMAND_LOCK = threading.Lock()
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
def execute(arguments: list[str]) -> dict[str, Any]:
|
| 356 |
+
with _COMMAND_LOCK:
|
| 357 |
+
try:
|
| 358 |
+
completed = subprocess.run(
|
| 359 |
+
[REAL_BROWSER_USE, *arguments],
|
| 360 |
+
stdin=subprocess.DEVNULL,
|
| 361 |
+
stdout=subprocess.PIPE,
|
| 362 |
+
stderr=subprocess.PIPE,
|
| 363 |
+
timeout=COMMAND_TIMEOUT_SEC,
|
| 364 |
+
check=False,
|
| 365 |
+
)
|
| 366 |
+
except subprocess.TimeoutExpired as exc:
|
| 367 |
+
raise CommandRejected("Browser Use command exceeded 180 seconds") from exc
|
| 368 |
+
except OSError as exc:
|
| 369 |
+
raise CommandRejected(f"Browser Use runtime unavailable: {exc}") from exc
|
| 370 |
+
stdout = completed.stdout[:MAX_OUTPUT_BYTES]
|
| 371 |
+
stderr = completed.stderr[:MAX_OUTPUT_BYTES]
|
| 372 |
+
if len(completed.stdout) > MAX_OUTPUT_BYTES or len(completed.stderr) > MAX_OUTPUT_BYTES:
|
| 373 |
+
raise CommandRejected("Browser Use output exceeded the interactive limit")
|
| 374 |
+
return {
|
| 375 |
+
"exit_code": completed.returncode,
|
| 376 |
+
"stdout": stdout.decode("utf-8", errors="replace"),
|
| 377 |
+
"stderr": stderr.decode("utf-8", errors="replace"),
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
GATEWAY_HELP = """
|
| 382 |
+
WebsiteBench gateway commands:
|
| 383 |
+
assets List the reference-origin images, icons, fonts and media that the
|
| 384 |
+
current page references or loaded.
|
| 385 |
+
save-asset URL PATH Save one of those assets to PATH (for example under /app/repo).
|
| 386 |
+
Stylesheets, scripts, HTML documents, JSON and other API responses are refused.
|
| 387 |
+
"""
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
def _find_result(value: Any) -> Any:
|
| 391 |
+
if isinstance(value, dict):
|
| 392 |
+
if "result" in value:
|
| 393 |
+
return value["result"]
|
| 394 |
+
for nested in value.values():
|
| 395 |
+
found = _find_result(nested)
|
| 396 |
+
if found is not None:
|
| 397 |
+
return found
|
| 398 |
+
return None
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
def list_assets(arguments: list[str], command_index: int) -> dict[str, Any]:
|
| 402 |
+
inventory = execute(arguments[:command_index] + ["--json", "eval", ASSET_INVENTORY_JS])
|
| 403 |
+
if inventory["exit_code"] != 0:
|
| 404 |
+
return {"exit_code": inventory["exit_code"], "stdout": "", "stderr": "could not list assets: " + inventory["stderr"][-400:]}
|
| 405 |
+
try:
|
| 406 |
+
urls = json.loads(_find_result(json.loads(inventory["stdout"])) or "[]")
|
| 407 |
+
except (TypeError, ValueError):
|
| 408 |
+
return {"exit_code": 1, "stdout": "", "stderr": "could not list assets: no page is open"}
|
| 409 |
+
origin = reference_origin()
|
| 410 |
+
assets = []
|
| 411 |
+
for url in urls if isinstance(urls, list) else []:
|
| 412 |
+
try:
|
| 413 |
+
if not isinstance(url, str) or _origin(url) != origin:
|
| 414 |
+
continue
|
| 415 |
+
except ValueError:
|
| 416 |
+
continue
|
| 417 |
+
path = urllib.parse.urlsplit(url).path
|
| 418 |
+
if is_reference_code(url):
|
| 419 |
+
continue
|
| 420 |
+
if Path(path).suffix.lower() in STATIC_EXTENSIONS or "/static/" in path or "/assets/" in path:
|
| 421 |
+
assets.append(urllib.parse.urlunsplit(urllib.parse.urlsplit(url)._replace(fragment="")))
|
| 422 |
+
assets = sorted(set(assets))[:ASSET_LIST_LIMIT]
|
| 423 |
+
text = "\n".join(assets) + ("\n" if assets else "no reference static assets found on the current page\n")
|
| 424 |
+
return {"exit_code": 0, "stdout": text, "stderr": ""}
|
| 425 |
+
|
| 426 |
+
|
| 427 |
+
class _SameOriginRedirect(urllib.request.HTTPRedirectHandler):
|
| 428 |
+
def redirect_request(self, req, fp, code, msg, headers, newurl): # type: ignore[override]
|
| 429 |
+
_reference_asset_url(urllib.parse.urljoin(req.full_url, newurl))
|
| 430 |
+
return super().redirect_request(req, fp, code, msg, headers, newurl)
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
def save_asset(url: str, destination: Path) -> dict[str, Any]:
|
| 434 |
+
opener = urllib.request.build_opener(
|
| 435 |
+
urllib.request.HTTPSHandler(context=ssl.create_default_context()), _SameOriginRedirect()
|
| 436 |
+
)
|
| 437 |
+
request = urllib.request.Request(url, headers={"User-Agent": "WebsiteBenchAssetGateway/1", "Accept": "*/*"})
|
| 438 |
+
try:
|
| 439 |
+
with opener.open(request, timeout=ASSET_TIMEOUT_SEC) as response:
|
| 440 |
+
content_type = response.headers.get("Content-Type", "")
|
| 441 |
+
final_url = response.geturl()
|
| 442 |
+
if is_reference_code(final_url, content_type):
|
| 443 |
+
raise CommandRejected(f"refused stylesheet or script ({content_type or 'no content type'}): reference CSS and JavaScript are not available to the agent")
|
| 444 |
+
if not is_static_asset(final_url, content_type):
|
| 445 |
+
raise CommandRejected(f"refused non-static response ({content_type or 'no content type'})")
|
| 446 |
+
body = response.read(ASSET_MAX_BYTES + 1)
|
| 447 |
+
except urllib.error.HTTPError as exc:
|
| 448 |
+
raise CommandRejected(f"reference returned HTTP {exc.code} for {url}") from exc
|
| 449 |
+
except (urllib.error.URLError, OSError) as exc:
|
| 450 |
+
raise CommandRejected(f"asset download failed: {exc}") from exc
|
| 451 |
+
if len(body) > ASSET_MAX_BYTES:
|
| 452 |
+
raise CommandRejected("asset exceeds the 32 MiB limit")
|
| 453 |
+
temporary = destination.with_name(destination.name + ".partial")
|
| 454 |
+
temporary.write_bytes(body)
|
| 455 |
+
os.replace(temporary, destination)
|
| 456 |
+
return {
|
| 457 |
+
"exit_code": 0,
|
| 458 |
+
"stdout": f"saved {url} -> {destination} ({len(body)} bytes, {content_type.split(';', 1)[0].strip() or 'unknown type'})\n",
|
| 459 |
+
"stderr": "",
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
def run(arguments: list[str]) -> dict[str, Any]:
|
| 464 |
+
_session, command_index = _parse_global_options(arguments)
|
| 465 |
+
command = arguments[command_index] if command_index < len(arguments) else None
|
| 466 |
+
if command == "assets":
|
| 467 |
+
return list_assets(arguments, command_index)
|
| 468 |
+
if command == "save-asset":
|
| 469 |
+
return save_asset(arguments[command_index + 1], Path(arguments[command_index + 2]))
|
| 470 |
+
result = execute(arguments)
|
| 471 |
+
if command in {None, "-h", "--help"}:
|
| 472 |
+
result["stdout"] = result["stdout"] + GATEWAY_HELP
|
| 473 |
+
return result
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
class Handler(BaseHTTPRequestHandler):
|
| 477 |
+
server_version = "WebsiteBenchBrowserGateway/1"
|
| 478 |
+
|
| 479 |
+
def log_message(self, _format: str, *_arguments: object) -> None:
|
| 480 |
+
return
|
| 481 |
+
|
| 482 |
+
def _send(self, status: int, value: dict[str, Any]) -> None:
|
| 483 |
+
body = json.dumps(value, separators=(",", ":")).encode("utf-8")
|
| 484 |
+
self.send_response(status)
|
| 485 |
+
self.send_header("Content-Type", "application/json")
|
| 486 |
+
self.send_header("Content-Length", str(len(body)))
|
| 487 |
+
self.send_header("Cache-Control", "no-store")
|
| 488 |
+
self.end_headers()
|
| 489 |
+
self.wfile.write(body)
|
| 490 |
+
|
| 491 |
+
def do_GET(self) -> None:
|
| 492 |
+
if self.path == "/healthz":
|
| 493 |
+
self._send(200, {"status": "ok"})
|
| 494 |
+
else:
|
| 495 |
+
self._send(404, {"error": "not_found"})
|
| 496 |
+
|
| 497 |
+
def do_POST(self) -> None:
|
| 498 |
+
if self.path != "/v1/command":
|
| 499 |
+
self._send(404, {"error": "not_found"})
|
| 500 |
+
return
|
| 501 |
+
try:
|
| 502 |
+
length = int(self.headers.get("Content-Length", ""))
|
| 503 |
+
if length <= 0 or length > MAX_REQUEST_BYTES:
|
| 504 |
+
raise CommandRejected("invalid request size")
|
| 505 |
+
payload = json.loads(self.rfile.read(length))
|
| 506 |
+
if not isinstance(payload, dict) or set(payload) != {"argv"}:
|
| 507 |
+
raise CommandRejected("request must contain only argv")
|
| 508 |
+
result = run(validate_command(payload["argv"]))
|
| 509 |
+
except (CommandRejected, json.JSONDecodeError, UnicodeError, ValueError) as exc:
|
| 510 |
+
self._send(400, {"error": str(exc)})
|
| 511 |
+
return
|
| 512 |
+
self._send(200, result)
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
def main() -> None:
|
| 516 |
+
bind = os.environ.get("WEBSITEBENCH_BROWSER_GATEWAY_BIND", "0.0.0.0")
|
| 517 |
+
port = int(os.environ.get("WEBSITEBENCH_BROWSER_GATEWAY_PORT", "9224"))
|
| 518 |
+
server = ThreadingHTTPServer((bind, port), Handler)
|
| 519 |
+
server.daemon_threads = True
|
| 520 |
+
server.serve_forever()
|
| 521 |
+
|
| 522 |
+
|
| 523 |
+
if __name__ == "__main__":
|
| 524 |
+
main()
|
tasks/columbia/environment/candidate-abi/websitebench-candidate-preflight
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
PYTHONPATH=/opt/websitebench/candidate-abi
|
| 4 |
+
export PYTHONPATH
|
| 5 |
+
exec python3 -m websitebench.harbor.candidate_preflight "$@"
|
tasks/columbia/environment/mailbox/Dockerfile
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12.11-slim-bookworm@sha256:519591d6871b7bc437060736b9f7456b8731f1499a57e22e6c285135ae657bf7
|
| 2 |
+
WORKDIR /srv/mailbox
|
| 3 |
+
COPY mailbox.py .
|
| 4 |
+
HEALTHCHECK --interval=2s --timeout=2s --retries=30 CMD python -c "import os,urllib.request as r;a=os.environ.get('WEBSITEBENCH_MAILBOX_API_BIND') or '127.0.0.1';i=os.environ.get('WEBSITEBENCH_MAILBOX_INBOX_BIND') or '127.0.0.1';r.urlopen(f'http://{a}:8025/healthz',timeout=1);r.urlopen(f'http://{i}:8026/healthz',timeout=1)"
|
| 5 |
+
CMD ["python", "mailbox.py", "--smtp-port", "1025", "--http-port", "8025", "--inbox-port", "8026"]
|
tasks/columbia/environment/mailbox/mailbox.py
ADDED
|
@@ -0,0 +1,2433 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Local-only mail writers plus Inbox HTTP sidecar for deterministic tasks.
|
| 2 |
+
|
| 3 |
+
The sidecar serves two disjoint listeners so the agent and the evaluator never
|
| 4 |
+
share a surface:
|
| 5 |
+
|
| 6 |
+
``api``
|
| 7 |
+
The Bearer-gated JSON API plus ``/internal/bootstrap``. The reference site
|
| 8 |
+
and the evaluator reach it; it is where every capability lives.
|
| 9 |
+
``inbox``
|
| 10 |
+
An HTML-only inbox for exactly one namespace, reachable without a
|
| 11 |
+
credential because a browser has none to present. It exposes no JSON, no
|
| 12 |
+
capability, and no way to name a second namespace.
|
| 13 |
+
|
| 14 |
+
Formal candidates receive a separate per-case write listener. Its primary
|
| 15 |
+
surface is a text-only Resend-style ``POST /emails`` API; legacy SMTP and the
|
| 16 |
+
``websitebench.site_backend`` bootstrap remain compatibility writers. None of
|
| 17 |
+
those surfaces exposes an inbox or a JSON read route.
|
| 18 |
+
|
| 19 |
+
This module is copied *alone* into the mailbox container build context, so it
|
| 20 |
+
must stay self-contained: no imports outside the standard library.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
from __future__ import annotations
|
| 24 |
+
|
| 25 |
+
import email
|
| 26 |
+
import hashlib
|
| 27 |
+
import hmac
|
| 28 |
+
import html
|
| 29 |
+
import http.client
|
| 30 |
+
import json
|
| 31 |
+
import os
|
| 32 |
+
import re
|
| 33 |
+
import secrets
|
| 34 |
+
import shutil
|
| 35 |
+
import socket
|
| 36 |
+
import socketserver
|
| 37 |
+
import signal
|
| 38 |
+
import subprocess
|
| 39 |
+
import sys
|
| 40 |
+
import tempfile
|
| 41 |
+
import threading
|
| 42 |
+
import time
|
| 43 |
+
import urllib.parse
|
| 44 |
+
from collections.abc import Mapping
|
| 45 |
+
from dataclasses import dataclass, field, replace
|
| 46 |
+
from email.message import EmailMessage
|
| 47 |
+
from email.policy import default
|
| 48 |
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
| 49 |
+
from typing import Any
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
_NAMESPACE = re.compile(r"^[a-zA-Z0-9._-]{1,160}$")
|
| 53 |
+
_OTP = re.compile(r"(?<!\d)(\d{4,8})(?!\d)")
|
| 54 |
+
_MAX_MESSAGE_BYTES = 1024 * 1024
|
| 55 |
+
_MAX_MESSAGES_PER_NAMESPACE = 32
|
| 56 |
+
_MAX_STORED_BYTES_PER_NAMESPACE = 2 * 1024 * 1024
|
| 57 |
+
_MAX_RECIPIENTS = 16
|
| 58 |
+
_MAX_COMMANDS_PER_CONNECTION = 256
|
| 59 |
+
_CONNECTION_TIMEOUT_SECONDS = 10
|
| 60 |
+
_MAX_CONNECTION_LIFETIME_SECONDS = 30
|
| 61 |
+
_MAX_CONCURRENT_CONNECTIONS = 16
|
| 62 |
+
MAILPIT_IMAGE = (
|
| 63 |
+
"ghcr.io/axllent/mailpit:v1.30.6@"
|
| 64 |
+
"sha256:7f33095f80e901f6ad08028f06ca284aa58fe84942be5496008d041d3b9f4d4d"
|
| 65 |
+
)
|
| 66 |
+
#: The one variable that names the Mailpit a trial or capture must use. It is
|
| 67 |
+
#: read in exactly one place, :meth:`MailPlane.from_environment`.
|
| 68 |
+
MAILPIT_HTTP_SOCKET_ENV = "WEBSITEBENCH_MAILPIT_HTTP_SOCKET"
|
| 69 |
+
#: Where Mailpit's private sockets live inside the compose sidecar. A value
|
| 70 |
+
#: mentioning this path in a candidate environment is an evaluator-side leak.
|
| 71 |
+
MAILPIT_RUNTIME_DIR = "/run/websitebench-mailpit"
|
| 72 |
+
#: The envelope sender every benchmark mail writer presents. Some captured
|
| 73 |
+
#: runtimes pin this exact suffix before opening SMTP, so paired capture and a
|
| 74 |
+
#: scored candidate trial must agree on it to the byte.
|
| 75 |
+
CANDIDATE_MAIL_SENDER = "no-reply@candidate.websitebench.local"
|
| 76 |
+
#: The complete optional mail ABI a candidate runtime may be handed. Nothing
|
| 77 |
+
#: outside this set ever reaches a candidate process.
|
| 78 |
+
CANDIDATE_MAIL_ENVIRONMENT = frozenset(
|
| 79 |
+
{
|
| 80 |
+
"WEBSITEBENCH_MAIL_API_URL",
|
| 81 |
+
"WEBSITEBENCH_MAIL_API_TOKEN",
|
| 82 |
+
"WEBSITEBENCH_MAIL_FROM",
|
| 83 |
+
"WEBSITEBENCH_SMTP_HOST",
|
| 84 |
+
"WEBSITEBENCH_SMTP_PORT",
|
| 85 |
+
"WEBSITEBENCH_SMTP_FROM",
|
| 86 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_URL",
|
| 87 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_TOKEN",
|
| 88 |
+
}
|
| 89 |
+
)
|
| 90 |
+
#: Every mail variable an authoring capture exports into its own process, so
|
| 91 |
+
#: capture can save and restore exactly this set around a shard.
|
| 92 |
+
AUTHORING_MAIL_ENVIRONMENT = (
|
| 93 |
+
"WEBSITEBENCH_MAIL_API_URL",
|
| 94 |
+
"WEBSITEBENCH_MAIL_API_TOKEN",
|
| 95 |
+
"WEBSITEBENCH_MAIL_FROM",
|
| 96 |
+
"WEBSITEBENCH_SMTP_FROM",
|
| 97 |
+
"WEBSITEBENCH_MAILBOX_URL",
|
| 98 |
+
"WEBSITEBENCH_MAILBOX_ALLOWLIST",
|
| 99 |
+
"WEBSITEBENCH_MAILBOX_NAMESPACE",
|
| 100 |
+
"WEBSITEBENCH_SMTP_HOST",
|
| 101 |
+
"WEBSITEBENCH_SMTP_PORT",
|
| 102 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_URL",
|
| 103 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_TOKEN",
|
| 104 |
+
"WEBSITEBENCH_MAILBOX_CREDENTIAL",
|
| 105 |
+
)
|
| 106 |
+
_LOG_SECRET = re.compile(
|
| 107 |
+
r"(?i)(?:bearer\s+[^\s\"']+|"
|
| 108 |
+
r"(?:authorization|cookie|credential|password|secret|token|otp|"
|
| 109 |
+
r"verification[-_ ]?code|card[-_ ]?number)\s*[:=]\s*"
|
| 110 |
+
r"(?:bearer\s+)?[^\s,;]+)"
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
class MailpitInfrastructureError(RuntimeError):
|
| 115 |
+
"""Mailpit is missing or unhealthy, as distinct from rejected candidate mail."""
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
class MailInfrastructureUnavailable(MailpitInfrastructureError):
|
| 119 |
+
"""No Mailpit is configured for this process, or the configured one is down."""
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class MailboxCapacityError(RuntimeError):
|
| 123 |
+
"""A namespace exhausted its fixed message or submitted-byte quota."""
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
class _UnixHTTPConnection(http.client.HTTPConnection):
|
| 127 |
+
"""A minimal HTTP/1.1 connection transported over one Unix socket."""
|
| 128 |
+
|
| 129 |
+
def __init__(self, socket_path: str, timeout: float) -> None:
|
| 130 |
+
super().__init__("localhost", timeout=timeout)
|
| 131 |
+
self._socket_path = socket_path
|
| 132 |
+
|
| 133 |
+
def connect(self) -> None:
|
| 134 |
+
connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
| 135 |
+
connection.settimeout(self.timeout)
|
| 136 |
+
connection.connect(self._socket_path)
|
| 137 |
+
self.sock = connection
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
class MailpitClient:
|
| 141 |
+
"""Trusted Mailpit client: HTTP UDS reads and sibling SMTP UDS writes.
|
| 142 |
+
|
| 143 |
+
This is intentionally not a general Mailpit client. It never exposes the
|
| 144 |
+
UI, delete, release, tag-mutation, or remote-content endpoints. All
|
| 145 |
+
candidate-authored control headers are discarded and the SMTP writer adds
|
| 146 |
+
exactly one trusted tag.
|
| 147 |
+
"""
|
| 148 |
+
|
| 149 |
+
_MAX_RESPONSE_BYTES = 8 * 1024 * 1024
|
| 150 |
+
|
| 151 |
+
def __init__(
|
| 152 |
+
self,
|
| 153 |
+
socket_path: str | os.PathLike[str],
|
| 154 |
+
*,
|
| 155 |
+
smtp_socket_path: str | os.PathLike[str] | None = None,
|
| 156 |
+
timeout: float = 5.0,
|
| 157 |
+
) -> None:
|
| 158 |
+
self.socket_path = os.fspath(socket_path)
|
| 159 |
+
if not self.socket_path:
|
| 160 |
+
raise ValueError("Mailpit HTTP socket path must not be empty")
|
| 161 |
+
if timeout <= 0:
|
| 162 |
+
raise ValueError("Mailpit timeout must be positive")
|
| 163 |
+
self.smtp_socket_path = (
|
| 164 |
+
os.fspath(smtp_socket_path)
|
| 165 |
+
if smtp_socket_path is not None
|
| 166 |
+
else os.path.join(os.path.dirname(self.socket_path), "smtp.sock")
|
| 167 |
+
)
|
| 168 |
+
self.timeout = float(timeout)
|
| 169 |
+
|
| 170 |
+
def _request(
|
| 171 |
+
self, method: str, path: str, body: dict[str, Any] | None = None
|
| 172 |
+
) -> tuple[int, bytes]:
|
| 173 |
+
encoded = None if body is None else json.dumps(body).encode("utf-8")
|
| 174 |
+
headers = {"Accept": "application/json", "Connection": "close"}
|
| 175 |
+
if encoded is not None:
|
| 176 |
+
headers["Content-Type"] = "application/json"
|
| 177 |
+
headers["Content-Length"] = str(len(encoded))
|
| 178 |
+
connection = _UnixHTTPConnection(self.socket_path, self.timeout)
|
| 179 |
+
try:
|
| 180 |
+
connection.request(method, path, body=encoded, headers=headers)
|
| 181 |
+
response = connection.getresponse()
|
| 182 |
+
length = response.getheader("Content-Length")
|
| 183 |
+
if length is not None and int(length) > self._MAX_RESPONSE_BYTES:
|
| 184 |
+
raise MailpitInfrastructureError("Mailpit response exceeded limit")
|
| 185 |
+
value = response.read(self._MAX_RESPONSE_BYTES + 1)
|
| 186 |
+
if len(value) > self._MAX_RESPONSE_BYTES:
|
| 187 |
+
raise MailpitInfrastructureError("Mailpit response exceeded limit")
|
| 188 |
+
return int(response.status), value
|
| 189 |
+
except (OSError, TimeoutError, http.client.HTTPException, ValueError) as error:
|
| 190 |
+
raise MailpitInfrastructureError(
|
| 191 |
+
f"Mailpit request failed: {redact_text(str(error))}"
|
| 192 |
+
) from error
|
| 193 |
+
finally:
|
| 194 |
+
connection.close()
|
| 195 |
+
|
| 196 |
+
def _json(
|
| 197 |
+
self, method: str, path: str, body: dict[str, Any] | None = None
|
| 198 |
+
) -> dict[str, Any]:
|
| 199 |
+
status, raw = self._request(method, path, body)
|
| 200 |
+
if not 200 <= status < 300:
|
| 201 |
+
raise MailpitInfrastructureError(f"Mailpit API returned HTTP {status}")
|
| 202 |
+
try:
|
| 203 |
+
value = json.loads(raw)
|
| 204 |
+
except (UnicodeDecodeError, json.JSONDecodeError) as error:
|
| 205 |
+
raise MailpitInfrastructureError("Mailpit returned invalid JSON") from error
|
| 206 |
+
if not isinstance(value, dict):
|
| 207 |
+
raise MailpitInfrastructureError("Mailpit returned an invalid response")
|
| 208 |
+
return value
|
| 209 |
+
|
| 210 |
+
def ready(self) -> bool:
|
| 211 |
+
"""Return whether Mailpit's built-in readiness endpoint is healthy."""
|
| 212 |
+
|
| 213 |
+
try:
|
| 214 |
+
status, _body = self._request("GET", "/readyz")
|
| 215 |
+
except MailpitInfrastructureError:
|
| 216 |
+
return False
|
| 217 |
+
return status == 200
|
| 218 |
+
|
| 219 |
+
def send(
|
| 220 |
+
self,
|
| 221 |
+
raw: bytes,
|
| 222 |
+
envelope_from: str,
|
| 223 |
+
recipients: list[str],
|
| 224 |
+
*,
|
| 225 |
+
tag: str,
|
| 226 |
+
) -> str:
|
| 227 |
+
"""Store mail with one trusted tag, ignoring all untrusted X-headers."""
|
| 228 |
+
|
| 229 |
+
if any(
|
| 230 |
+
"\r" in value or "\n" in value for value in [envelope_from, *recipients]
|
| 231 |
+
):
|
| 232 |
+
raise ValueError("invalid SMTP envelope")
|
| 233 |
+
message = email.message_from_bytes(raw, policy=default)
|
| 234 |
+
for part in message.walk():
|
| 235 |
+
for header in list(part.keys()):
|
| 236 |
+
lowered = header.lower()
|
| 237 |
+
if lowered == "x-tags" or lowered.startswith("x-websitebench-"):
|
| 238 |
+
del part[header]
|
| 239 |
+
for header in ("From", "To", "Cc", "Bcc"):
|
| 240 |
+
if message.get(header) is not None:
|
| 241 |
+
del message[header]
|
| 242 |
+
message["From"] = envelope_from
|
| 243 |
+
message["To"] = ", ".join(recipients)
|
| 244 |
+
message["X-Tags"] = tag
|
| 245 |
+
wire = message.as_bytes(policy=default.clone(linesep="\r\n"))
|
| 246 |
+
|
| 247 |
+
connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
| 248 |
+
connection.settimeout(self.timeout)
|
| 249 |
+
stream = None
|
| 250 |
+
try:
|
| 251 |
+
connection.connect(self.smtp_socket_path)
|
| 252 |
+
stream = connection.makefile("rb")
|
| 253 |
+
|
| 254 |
+
def response() -> tuple[int, str]:
|
| 255 |
+
lines: list[str] = []
|
| 256 |
+
while True:
|
| 257 |
+
line = stream.readline(65537)
|
| 258 |
+
if not line or len(line) > 65536:
|
| 259 |
+
raise MailpitInfrastructureError(
|
| 260 |
+
"invalid Mailpit SMTP response"
|
| 261 |
+
)
|
| 262 |
+
decoded = line.decode("utf-8", "replace").rstrip("\r\n")
|
| 263 |
+
lines.append(decoded)
|
| 264 |
+
if len(decoded) < 4 or decoded[3:4] != "-":
|
| 265 |
+
break
|
| 266 |
+
try:
|
| 267 |
+
return int(lines[-1][:3]), "\n".join(lines)
|
| 268 |
+
except ValueError as error:
|
| 269 |
+
raise MailpitInfrastructureError(
|
| 270 |
+
"invalid Mailpit SMTP status"
|
| 271 |
+
) from error
|
| 272 |
+
|
| 273 |
+
def command(value: bytes, expected: set[int]) -> str:
|
| 274 |
+
connection.sendall(value + b"\r\n")
|
| 275 |
+
status, reply = response()
|
| 276 |
+
if status not in expected:
|
| 277 |
+
raise MailpitInfrastructureError(
|
| 278 |
+
f"Mailpit SMTP returned status {status}: "
|
| 279 |
+
f"{redact_text(reply)[:200]}"
|
| 280 |
+
)
|
| 281 |
+
return reply
|
| 282 |
+
|
| 283 |
+
status, _greeting = response()
|
| 284 |
+
if status != 220:
|
| 285 |
+
raise MailpitInfrastructureError(
|
| 286 |
+
"Mailpit SMTP did not greet the gateway"
|
| 287 |
+
)
|
| 288 |
+
command(b"EHLO websitebench.local", {250})
|
| 289 |
+
command(f"MAIL FROM:<{envelope_from}>".encode("utf-8"), {250})
|
| 290 |
+
for recipient in recipients:
|
| 291 |
+
command(f"RCPT TO:<{recipient}>".encode("utf-8"), {250})
|
| 292 |
+
command(b"DATA", {354})
|
| 293 |
+
stuffed = b"\r\n".join(
|
| 294 |
+
(b"." + line if line.startswith(b".") else line)
|
| 295 |
+
for line in wire.split(b"\r\n")
|
| 296 |
+
)
|
| 297 |
+
connection.sendall(stuffed + b"\r\n.\r\n")
|
| 298 |
+
status, reply = response()
|
| 299 |
+
if status != 250:
|
| 300 |
+
raise MailpitInfrastructureError(
|
| 301 |
+
f"Mailpit SMTP returned status {status}: {redact_text(reply)[:200]}"
|
| 302 |
+
)
|
| 303 |
+
match = re.search(r"queued as ([A-Za-z0-9_-]+)", reply)
|
| 304 |
+
return match.group(1) if match else hashlib.sha256(wire).hexdigest()[:24]
|
| 305 |
+
except (OSError, TimeoutError) as error:
|
| 306 |
+
raise MailpitInfrastructureError("Mailpit SMTP request failed") from error
|
| 307 |
+
finally:
|
| 308 |
+
if stream is not None:
|
| 309 |
+
stream.close()
|
| 310 |
+
connection.close()
|
| 311 |
+
|
| 312 |
+
@staticmethod
|
| 313 |
+
def _addresses(value: Any) -> list[str]:
|
| 314 |
+
if not isinstance(value, list):
|
| 315 |
+
return []
|
| 316 |
+
return [
|
| 317 |
+
str(item.get("Address", item.get("Email")))
|
| 318 |
+
for item in value
|
| 319 |
+
if isinstance(item, dict)
|
| 320 |
+
and isinstance(item.get("Address", item.get("Email")), str)
|
| 321 |
+
]
|
| 322 |
+
|
| 323 |
+
def messages(self, *, tag: str, recipient: str) -> list[dict[str, Any]]:
|
| 324 |
+
"""Read only exact-tag, exact-recipient messages, oldest first."""
|
| 325 |
+
|
| 326 |
+
query = urllib.parse.urlencode(
|
| 327 |
+
{"query": f"tag:{tag}", "start": "0", "limit": "512"}
|
| 328 |
+
)
|
| 329 |
+
listing = self._json("GET", f"/api/v1/search?{query}")
|
| 330 |
+
summaries = listing.get("messages", [])
|
| 331 |
+
if not isinstance(summaries, list):
|
| 332 |
+
raise MailpitInfrastructureError(
|
| 333 |
+
"Mailpit returned invalid message summaries"
|
| 334 |
+
)
|
| 335 |
+
values: list[dict[str, Any]] = []
|
| 336 |
+
for summary in reversed(summaries):
|
| 337 |
+
if not isinstance(summary, dict):
|
| 338 |
+
continue
|
| 339 |
+
tags = summary.get("Tags", [])
|
| 340 |
+
all_recipients = (
|
| 341 |
+
self._addresses(summary.get("To"))
|
| 342 |
+
+ self._addresses(summary.get("Cc"))
|
| 343 |
+
+ self._addresses(summary.get("Bcc"))
|
| 344 |
+
)
|
| 345 |
+
identifier = summary.get("ID")
|
| 346 |
+
if (
|
| 347 |
+
tag not in tags
|
| 348 |
+
or recipient not in all_recipients
|
| 349 |
+
or not isinstance(identifier, str)
|
| 350 |
+
):
|
| 351 |
+
continue
|
| 352 |
+
detail = self._json(
|
| 353 |
+
"GET", "/api/v1/message/" + urllib.parse.quote(identifier, safe="")
|
| 354 |
+
)
|
| 355 |
+
# Recheck authorization against the detailed record. Search is an
|
| 356 |
+
# index, never an authorization decision.
|
| 357 |
+
detail_tags = detail.get("Tags", [])
|
| 358 |
+
detailed_recipients = (
|
| 359 |
+
self._addresses(detail.get("To"))
|
| 360 |
+
+ self._addresses(detail.get("Cc"))
|
| 361 |
+
+ self._addresses(detail.get("Bcc"))
|
| 362 |
+
)
|
| 363 |
+
if tag not in detail_tags or recipient not in detailed_recipients:
|
| 364 |
+
continue
|
| 365 |
+
sender = detail.get("From", {})
|
| 366 |
+
attachments = detail.get("Attachments", [])
|
| 367 |
+
inline = detail.get("Inline", [])
|
| 368 |
+
metadata = [
|
| 369 |
+
*(attachments if isinstance(attachments, list) else []),
|
| 370 |
+
*(inline if isinstance(inline, list) else []),
|
| 371 |
+
]
|
| 372 |
+
values.append(
|
| 373 |
+
{
|
| 374 |
+
"mailpit_id": identifier,
|
| 375 |
+
"envelope_from": str(sender.get("Address", sender.get("Email", "")))
|
| 376 |
+
if isinstance(sender, dict)
|
| 377 |
+
else "",
|
| 378 |
+
"recipients": detailed_recipients,
|
| 379 |
+
"subject": str(detail.get("Subject", "")),
|
| 380 |
+
"text": str(detail.get("Text", "")),
|
| 381 |
+
"attachments": metadata,
|
| 382 |
+
"stored_bytes": int(detail.get("Size", 0)),
|
| 383 |
+
}
|
| 384 |
+
)
|
| 385 |
+
for index, item in enumerate(values, 1):
|
| 386 |
+
item["id"] = index
|
| 387 |
+
match = _OTP.search(str(item["text"]))
|
| 388 |
+
item["otp"] = match.group(1) if match else None
|
| 389 |
+
return values
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
@dataclass
|
| 393 |
+
class MailAccount:
|
| 394 |
+
"""Internal ``websitebench.mail-account.v1`` logical account."""
|
| 395 |
+
|
| 396 |
+
account_id: str
|
| 397 |
+
tag: str
|
| 398 |
+
address: str
|
| 399 |
+
role: str
|
| 400 |
+
allowed_from: set[str]
|
| 401 |
+
allowed_to: set[str]
|
| 402 |
+
send_capability: str = field(repr=False)
|
| 403 |
+
read_capability: str = field(repr=False)
|
| 404 |
+
state: str = "active"
|
| 405 |
+
schema: str = field(default="websitebench.mail-account.v1", init=False)
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
class MailAccountBroker:
|
| 409 |
+
"""Authorize logical accounts before calling the untrusted storage engine."""
|
| 410 |
+
|
| 411 |
+
_SEND_ROLES = frozenset(
|
| 412 |
+
{
|
| 413 |
+
"reference-backend",
|
| 414 |
+
"formal-candidate",
|
| 415 |
+
"capture-writer",
|
| 416 |
+
"gateway",
|
| 417 |
+
"selfhost-pair",
|
| 418 |
+
"formal-pair",
|
| 419 |
+
"capture-pair",
|
| 420 |
+
}
|
| 421 |
+
)
|
| 422 |
+
_READ_ROLES = frozenset(
|
| 423 |
+
{
|
| 424 |
+
"agent",
|
| 425 |
+
"formal-verifier",
|
| 426 |
+
"capture-reader",
|
| 427 |
+
"gateway",
|
| 428 |
+
"selfhost-pair",
|
| 429 |
+
"formal-pair",
|
| 430 |
+
"capture-pair",
|
| 431 |
+
}
|
| 432 |
+
)
|
| 433 |
+
_ROLES = _SEND_ROLES | _READ_ROLES
|
| 434 |
+
|
| 435 |
+
def __init__(self, client: MailpitClient) -> None:
|
| 436 |
+
self.client = client
|
| 437 |
+
self._accounts: dict[str, MailAccount] = {}
|
| 438 |
+
self._lock = threading.Lock()
|
| 439 |
+
|
| 440 |
+
def create_account(
|
| 441 |
+
self,
|
| 442 |
+
*,
|
| 443 |
+
address: str,
|
| 444 |
+
role: str,
|
| 445 |
+
allowed_from: Any = (),
|
| 446 |
+
allowed_to: Any = (),
|
| 447 |
+
) -> MailAccount:
|
| 448 |
+
if address and ("@" not in address or "\r" in address or "\n" in address):
|
| 449 |
+
raise ValueError("invalid mail account address")
|
| 450 |
+
if role not in self._ROLES:
|
| 451 |
+
raise ValueError("invalid mail account role")
|
| 452 |
+
account = MailAccount(
|
| 453 |
+
account_id="acct_" + secrets.token_hex(24),
|
| 454 |
+
tag="wb-" + secrets.token_hex(24),
|
| 455 |
+
address=address,
|
| 456 |
+
role=role,
|
| 457 |
+
allowed_from=set(allowed_from),
|
| 458 |
+
allowed_to=set(allowed_to) | ({address} if address else set()),
|
| 459 |
+
send_capability="send_" + secrets.token_hex(32),
|
| 460 |
+
read_capability="read_" + secrets.token_hex(32),
|
| 461 |
+
)
|
| 462 |
+
with self._lock:
|
| 463 |
+
self._accounts[account.account_id] = account
|
| 464 |
+
return account
|
| 465 |
+
|
| 466 |
+
def _account(self, account_id: str) -> MailAccount:
|
| 467 |
+
with self._lock:
|
| 468 |
+
account = self._accounts.get(account_id)
|
| 469 |
+
if account is None or account.state == "destroyed":
|
| 470 |
+
raise PermissionError("mail account is unavailable")
|
| 471 |
+
return account
|
| 472 |
+
|
| 473 |
+
def send(
|
| 474 |
+
self,
|
| 475 |
+
account_id: str,
|
| 476 |
+
capability: str,
|
| 477 |
+
raw: bytes,
|
| 478 |
+
envelope_from: str,
|
| 479 |
+
recipients: list[str],
|
| 480 |
+
) -> str:
|
| 481 |
+
account = self._account(account_id)
|
| 482 |
+
if (
|
| 483 |
+
account.role not in self._SEND_ROLES
|
| 484 |
+
or account.state != "active"
|
| 485 |
+
or not hmac.compare_digest(account.send_capability, capability)
|
| 486 |
+
):
|
| 487 |
+
raise PermissionError("mail account cannot send")
|
| 488 |
+
if (
|
| 489 |
+
not envelope_from
|
| 490 |
+
or "@" not in envelope_from
|
| 491 |
+
or "\r" in envelope_from
|
| 492 |
+
or "\n" in envelope_from
|
| 493 |
+
or not 1 <= len(recipients) <= _MAX_RECIPIENTS
|
| 494 |
+
or len(raw) > _MAX_MESSAGE_BYTES
|
| 495 |
+
or any(
|
| 496 |
+
not recipient
|
| 497 |
+
or len(recipient) > 320
|
| 498 |
+
or "@" not in recipient
|
| 499 |
+
or "\r" in recipient
|
| 500 |
+
or "\n" in recipient
|
| 501 |
+
for recipient in recipients
|
| 502 |
+
)
|
| 503 |
+
):
|
| 504 |
+
raise PermissionError("mail envelope is not allowed")
|
| 505 |
+
if account.allowed_from and envelope_from not in account.allowed_from:
|
| 506 |
+
raise PermissionError("mail sender is not allowed")
|
| 507 |
+
learn_recipients = account.role == "gateway" or not account.allowed_to
|
| 508 |
+
if account.role != "gateway" and account.allowed_to and any(
|
| 509 |
+
value not in account.allowed_to for value in recipients
|
| 510 |
+
):
|
| 511 |
+
raise PermissionError("mail recipient is not allowed")
|
| 512 |
+
provider_id = self.client.send(raw, envelope_from, recipients, tag=account.tag)
|
| 513 |
+
if learn_recipients:
|
| 514 |
+
# A trial can legitimately exercise more than one authentication
|
| 515 |
+
# address. Namespace-scoped gateway accounts therefore learn every
|
| 516 |
+
# address from a Mailpit-accepted envelope; reads remain limited to
|
| 517 |
+
# those exact delivered addresses and still require the capability.
|
| 518 |
+
with self._lock:
|
| 519 |
+
account.allowed_to.update(recipients)
|
| 520 |
+
if not account.address and recipients:
|
| 521 |
+
account.address = recipients[0]
|
| 522 |
+
return provider_id
|
| 523 |
+
|
| 524 |
+
def messages(
|
| 525 |
+
self, account_id: str, capability: str, recipient: str | None = None
|
| 526 |
+
) -> list[dict[str, Any]]:
|
| 527 |
+
account = self._account(account_id)
|
| 528 |
+
if account.role not in self._READ_ROLES or not hmac.compare_digest(
|
| 529 |
+
account.read_capability, capability
|
| 530 |
+
):
|
| 531 |
+
raise PermissionError("mail account cannot read")
|
| 532 |
+
with self._lock:
|
| 533 |
+
allowed_to = set(account.allowed_to)
|
| 534 |
+
# SMTP delivery is asynchronous. A verifier can legitimately poll the
|
| 535 |
+
# exact recipient before the writer has learned its first envelope. An
|
| 536 |
+
# empty account therefore means "not delivered yet", not "forbidden".
|
| 537 |
+
# Once the first envelope arrives, the usual exact-recipient boundary
|
| 538 |
+
# applies and a different address is still rejected.
|
| 539 |
+
if recipient is not None and not allowed_to:
|
| 540 |
+
return []
|
| 541 |
+
targets = [recipient] if recipient is not None else sorted(allowed_to)
|
| 542 |
+
if any(target not in allowed_to for target in targets):
|
| 543 |
+
raise PermissionError("mail recipient is not allowed")
|
| 544 |
+
combined: dict[str, dict[str, Any]] = {}
|
| 545 |
+
for target in targets:
|
| 546 |
+
for message in self.client.messages(tag=account.tag, recipient=target):
|
| 547 |
+
combined[str(message["mailpit_id"])] = message
|
| 548 |
+
values = list(combined.values())
|
| 549 |
+
for index, item in enumerate(values, 1):
|
| 550 |
+
item["id"] = index
|
| 551 |
+
return values
|
| 552 |
+
|
| 553 |
+
def seal(self, account_id: str) -> None:
|
| 554 |
+
account = self._account(account_id)
|
| 555 |
+
with self._lock:
|
| 556 |
+
account.state = "sealed"
|
| 557 |
+
|
| 558 |
+
def destroy(self, account_id: str) -> None:
|
| 559 |
+
account = self._account(account_id)
|
| 560 |
+
with self._lock:
|
| 561 |
+
account.state = "destroyed"
|
| 562 |
+
|
| 563 |
+
|
| 564 |
+
class EphemeralMailpit:
|
| 565 |
+
"""One pinned, networkless Mailpit container with a private UDS directory."""
|
| 566 |
+
|
| 567 |
+
def __init__(
|
| 568 |
+
self,
|
| 569 |
+
runtime_dir: str | os.PathLike[str] | None = None,
|
| 570 |
+
*,
|
| 571 |
+
docker_binary: str = "docker",
|
| 572 |
+
startup_timeout: float = 45.0,
|
| 573 |
+
) -> None:
|
| 574 |
+
if startup_timeout <= 0:
|
| 575 |
+
raise ValueError("startup timeout must be positive")
|
| 576 |
+
self._owns_runtime_dir = runtime_dir is None
|
| 577 |
+
self.runtime_dir = (
|
| 578 |
+
tempfile.mkdtemp(prefix="websitebench-mailpit-")
|
| 579 |
+
if runtime_dir is None
|
| 580 |
+
else os.path.abspath(os.fspath(runtime_dir))
|
| 581 |
+
)
|
| 582 |
+
os.makedirs(self.runtime_dir, mode=0o700, exist_ok=True)
|
| 583 |
+
os.chmod(self.runtime_dir, 0o700)
|
| 584 |
+
self.docker_binary = docker_binary
|
| 585 |
+
self.startup_timeout = float(startup_timeout)
|
| 586 |
+
self.container_name = "websitebench-mailpit-" + secrets.token_hex(12)
|
| 587 |
+
self.client = MailpitClient(os.path.join(self.runtime_dir, "http.sock"))
|
| 588 |
+
self._process: subprocess.Popen[bytes] | None = None
|
| 589 |
+
|
| 590 |
+
def _uses_rootless_podman(self) -> bool:
|
| 591 |
+
"""Detect the Podman Docker shim that needs the host uid preserved."""
|
| 592 |
+
|
| 593 |
+
try:
|
| 594 |
+
result = subprocess.run(
|
| 595 |
+
[self.docker_binary, "info"],
|
| 596 |
+
stdin=subprocess.DEVNULL,
|
| 597 |
+
stdout=subprocess.PIPE,
|
| 598 |
+
stderr=subprocess.STDOUT,
|
| 599 |
+
text=True,
|
| 600 |
+
timeout=5,
|
| 601 |
+
check=False,
|
| 602 |
+
)
|
| 603 |
+
except (OSError, subprocess.TimeoutExpired):
|
| 604 |
+
return False
|
| 605 |
+
output = result.stdout.casefold()
|
| 606 |
+
return result.returncode == 0 and "podman" in output and "rootless" in output
|
| 607 |
+
|
| 608 |
+
def start(self) -> "EphemeralMailpit":
|
| 609 |
+
if self._process is not None:
|
| 610 |
+
return self
|
| 611 |
+
command = [
|
| 612 |
+
self.docker_binary,
|
| 613 |
+
"run",
|
| 614 |
+
"--rm",
|
| 615 |
+
"--name",
|
| 616 |
+
self.container_name,
|
| 617 |
+
]
|
| 618 |
+
if self._uses_rootless_podman():
|
| 619 |
+
command.append("--userns=keep-id")
|
| 620 |
+
command.extend(
|
| 621 |
+
[
|
| 622 |
+
"--user",
|
| 623 |
+
f"{os.getuid()}:{os.getgid()}",
|
| 624 |
+
"--network",
|
| 625 |
+
"none",
|
| 626 |
+
"--tmpfs",
|
| 627 |
+
"/tmp:rw,noexec,nosuid,nodev,size=64m",
|
| 628 |
+
"--mount",
|
| 629 |
+
f"type=bind,src={self.runtime_dir},dst=/run/websitebench-mailpit",
|
| 630 |
+
]
|
| 631 |
+
)
|
| 632 |
+
settings = {
|
| 633 |
+
"MP_UI_BIND_ADDR": "unix:/run/websitebench-mailpit/http.sock:660",
|
| 634 |
+
"MP_SMTP_BIND_ADDR": "unix:/run/websitebench-mailpit/smtp.sock:660",
|
| 635 |
+
"MP_DATABASE": "/tmp/mailpit.db",
|
| 636 |
+
"MP_MAX_MESSAGES": "512",
|
| 637 |
+
"MP_MAX_MESSAGE_SIZE": "1",
|
| 638 |
+
"MP_SMTP_MAX_RECIPIENTS": "16",
|
| 639 |
+
"MP_POP3_BIND_ADDR": "",
|
| 640 |
+
"MP_POP3_AUTH_FILE": "",
|
| 641 |
+
"MP_SMTP_RELAY_CONFIG": "",
|
| 642 |
+
"MP_SMTP_RELAY_ALL": "false",
|
| 643 |
+
"MP_SMTP_FORWARD_CONFIG": "",
|
| 644 |
+
"MP_WEBHOOK_URL": "",
|
| 645 |
+
"MP_ENABLE_CHAOS": "false",
|
| 646 |
+
"MP_ENABLE_PROMETHEUS": "false",
|
| 647 |
+
"MP_DISABLE_VERSION_CHECK": "true",
|
| 648 |
+
"MP_BLOCK_REMOTE_CSS_AND_FONTS": "true",
|
| 649 |
+
"MP_ALLOW_INTERNAL_HTTP_REQUESTS": "false",
|
| 650 |
+
}
|
| 651 |
+
for key, value in settings.items():
|
| 652 |
+
command.extend(("--env", f"{key}={value}"))
|
| 653 |
+
command.append(MAILPIT_IMAGE)
|
| 654 |
+
try:
|
| 655 |
+
self._process = subprocess.Popen(
|
| 656 |
+
command,
|
| 657 |
+
stdin=subprocess.DEVNULL,
|
| 658 |
+
stdout=subprocess.DEVNULL,
|
| 659 |
+
stderr=subprocess.DEVNULL,
|
| 660 |
+
)
|
| 661 |
+
except OSError as error:
|
| 662 |
+
self.close()
|
| 663 |
+
raise MailpitInfrastructureError(
|
| 664 |
+
"Docker is unavailable for Mailpit"
|
| 665 |
+
) from error
|
| 666 |
+
deadline = time.monotonic() + self.startup_timeout
|
| 667 |
+
while time.monotonic() < deadline:
|
| 668 |
+
if self._process.poll() is not None:
|
| 669 |
+
self.close()
|
| 670 |
+
raise MailpitInfrastructureError(
|
| 671 |
+
"Mailpit container exited during startup"
|
| 672 |
+
)
|
| 673 |
+
if self.client.ready():
|
| 674 |
+
return self
|
| 675 |
+
time.sleep(0.1)
|
| 676 |
+
self.close()
|
| 677 |
+
raise MailpitInfrastructureError("Mailpit did not become ready")
|
| 678 |
+
|
| 679 |
+
def close(self) -> None:
|
| 680 |
+
process, self._process = self._process, None
|
| 681 |
+
if process is not None and process.poll() is None:
|
| 682 |
+
try:
|
| 683 |
+
subprocess.run(
|
| 684 |
+
[self.docker_binary, "stop", "--time", "3", self.container_name],
|
| 685 |
+
stdin=subprocess.DEVNULL,
|
| 686 |
+
stdout=subprocess.DEVNULL,
|
| 687 |
+
stderr=subprocess.DEVNULL,
|
| 688 |
+
timeout=8,
|
| 689 |
+
check=False,
|
| 690 |
+
)
|
| 691 |
+
except (OSError, subprocess.TimeoutExpired):
|
| 692 |
+
process.terminate()
|
| 693 |
+
try:
|
| 694 |
+
process.wait(timeout=5)
|
| 695 |
+
except subprocess.TimeoutExpired:
|
| 696 |
+
process.kill()
|
| 697 |
+
process.wait(timeout=5)
|
| 698 |
+
if self._owns_runtime_dir:
|
| 699 |
+
shutil.rmtree(self.runtime_dir, ignore_errors=True)
|
| 700 |
+
else:
|
| 701 |
+
for name in ("http.sock", "smtp.sock"):
|
| 702 |
+
try:
|
| 703 |
+
os.unlink(os.path.join(self.runtime_dir, name))
|
| 704 |
+
except FileNotFoundError:
|
| 705 |
+
pass
|
| 706 |
+
|
| 707 |
+
def __enter__(self) -> "EphemeralMailpit":
|
| 708 |
+
return self.start()
|
| 709 |
+
|
| 710 |
+
def __exit__(self, exc_type: object, exc: object, traceback: object) -> None:
|
| 711 |
+
self.close()
|
| 712 |
+
|
| 713 |
+
|
| 714 |
+
def redact_text(value: str) -> str:
|
| 715 |
+
"""Redact secret-like log fragments without retaining the matched value."""
|
| 716 |
+
|
| 717 |
+
return _LOG_SECRET.sub("[REDACTED]", value)
|
| 718 |
+
|
| 719 |
+
|
| 720 |
+
def redact_log_file(path: str) -> None:
|
| 721 |
+
"""Sanitize one UTF-8 verifier log in place before it is published."""
|
| 722 |
+
|
| 723 |
+
from pathlib import Path
|
| 724 |
+
|
| 725 |
+
target = Path(path)
|
| 726 |
+
if not target.is_file():
|
| 727 |
+
return
|
| 728 |
+
value = target.read_text(encoding="utf-8", errors="replace")
|
| 729 |
+
target.write_text(redact_text(value), encoding="utf-8", newline="\n")
|
| 730 |
+
|
| 731 |
+
|
| 732 |
+
def redact_evidence(value: Any) -> Any:
|
| 733 |
+
"""Remove credentials and sensitive form values from retained evidence."""
|
| 734 |
+
|
| 735 |
+
sensitive = re.compile(
|
| 736 |
+
r"(?:authorization|cookie|credential|password|secret|token|otp|code|payment|card)",
|
| 737 |
+
re.IGNORECASE,
|
| 738 |
+
)
|
| 739 |
+
if isinstance(value, dict):
|
| 740 |
+
return {
|
| 741 |
+
str(key): "[REDACTED]"
|
| 742 |
+
if sensitive.search(str(key))
|
| 743 |
+
else redact_evidence(child)
|
| 744 |
+
for key, child in value.items()
|
| 745 |
+
}
|
| 746 |
+
if isinstance(value, list):
|
| 747 |
+
return [redact_evidence(child) for child in value]
|
| 748 |
+
return value
|
| 749 |
+
|
| 750 |
+
|
| 751 |
+
@dataclass
|
| 752 |
+
class MailboxStore:
|
| 753 |
+
mailpit_client: MailpitClient
|
| 754 |
+
_capabilities: dict[str, str] = field(default_factory=dict)
|
| 755 |
+
_idempotency: dict[tuple[str, str], str] = field(default_factory=dict)
|
| 756 |
+
_namespace_message_counts: dict[str, int] = field(default_factory=dict)
|
| 757 |
+
_namespace_stored_bytes: dict[str, int] = field(default_factory=dict)
|
| 758 |
+
_lock: threading.Lock = field(default_factory=threading.Lock)
|
| 759 |
+
_broker: MailAccountBroker = field(init=False)
|
| 760 |
+
_accounts: dict[str, MailAccount] = field(default_factory=dict, init=False)
|
| 761 |
+
|
| 762 |
+
def __post_init__(self) -> None:
|
| 763 |
+
if not isinstance(self.mailpit_client, MailpitClient):
|
| 764 |
+
raise MailpitInfrastructureError("Mailpit client is required")
|
| 765 |
+
self._broker = MailAccountBroker(self.mailpit_client)
|
| 766 |
+
|
| 767 |
+
def healthy(self) -> bool:
|
| 768 |
+
return self.mailpit_client.ready()
|
| 769 |
+
|
| 770 |
+
def register(
|
| 771 |
+
self,
|
| 772 |
+
namespace: str,
|
| 773 |
+
capability: str,
|
| 774 |
+
*,
|
| 775 |
+
allowed_from: tuple[str, ...] = (),
|
| 776 |
+
) -> None:
|
| 777 |
+
if not _NAMESPACE.fullmatch(namespace) or len(capability) < 32:
|
| 778 |
+
raise ValueError("invalid mailbox namespace capability")
|
| 779 |
+
if any(
|
| 780 |
+
not value or "@" not in value or "\r" in value or "\n" in value
|
| 781 |
+
for value in allowed_from
|
| 782 |
+
):
|
| 783 |
+
raise ValueError("invalid allowed mail sender")
|
| 784 |
+
allowed_senders = set(allowed_from)
|
| 785 |
+
with self._lock:
|
| 786 |
+
existing = self._capabilities.get(namespace)
|
| 787 |
+
if existing is not None and existing != capability:
|
| 788 |
+
raise ValueError("mailbox namespace is already registered")
|
| 789 |
+
self._capabilities[namespace] = capability
|
| 790 |
+
account = self._accounts.get(namespace)
|
| 791 |
+
if account is None:
|
| 792 |
+
self._accounts[namespace] = self._broker.create_account(
|
| 793 |
+
address="", role="gateway", allowed_from=allowed_senders
|
| 794 |
+
)
|
| 795 |
+
elif account.allowed_from != allowed_senders:
|
| 796 |
+
raise ValueError("mailbox namespace sender policy is already registered")
|
| 797 |
+
|
| 798 |
+
def authorized(self, namespace: str, capability: str | None) -> bool:
|
| 799 |
+
with self._lock:
|
| 800 |
+
expected = self._capabilities.get(namespace)
|
| 801 |
+
return (
|
| 802 |
+
expected is not None
|
| 803 |
+
and capability is not None
|
| 804 |
+
and hmac.compare_digest(expected, capability)
|
| 805 |
+
)
|
| 806 |
+
|
| 807 |
+
def seal_namespace(self, namespace: str) -> None:
|
| 808 |
+
"""Retire one writer while retaining trusted reads until teardown."""
|
| 809 |
+
|
| 810 |
+
with self._lock:
|
| 811 |
+
self._capabilities.pop(namespace, None)
|
| 812 |
+
account = self._accounts.get(namespace)
|
| 813 |
+
self._namespace_message_counts.pop(namespace, None)
|
| 814 |
+
self._namespace_stored_bytes.pop(namespace, None)
|
| 815 |
+
self._idempotency = {
|
| 816 |
+
identity: provider_id
|
| 817 |
+
for identity, provider_id in self._idempotency.items()
|
| 818 |
+
if identity[0] != namespace
|
| 819 |
+
}
|
| 820 |
+
if account is not None:
|
| 821 |
+
self._broker.seal(account.account_id)
|
| 822 |
+
|
| 823 |
+
def destroy_namespaces(self) -> None:
|
| 824 |
+
"""Revoke every logical account without deleting Mailpit messages."""
|
| 825 |
+
|
| 826 |
+
with self._lock:
|
| 827 |
+
accounts = list(self._accounts.values())
|
| 828 |
+
self._capabilities.clear()
|
| 829 |
+
self._accounts.clear()
|
| 830 |
+
self._namespace_message_counts.clear()
|
| 831 |
+
self._namespace_stored_bytes.clear()
|
| 832 |
+
self._idempotency.clear()
|
| 833 |
+
for account in accounts:
|
| 834 |
+
if account.state != "destroyed":
|
| 835 |
+
self._broker.destroy(account.account_id)
|
| 836 |
+
|
| 837 |
+
def _store_message(
|
| 838 |
+
self,
|
| 839 |
+
message: Any,
|
| 840 |
+
envelope_from: str,
|
| 841 |
+
recipients: list[str],
|
| 842 |
+
*,
|
| 843 |
+
namespace: str,
|
| 844 |
+
idempotency_key: str | None = None,
|
| 845 |
+
raw: bytes | None = None,
|
| 846 |
+
) -> tuple[bool, str | None]:
|
| 847 |
+
with self._lock:
|
| 848 |
+
idempotency_identity = (
|
| 849 |
+
(namespace, idempotency_key) if idempotency_key else None
|
| 850 |
+
)
|
| 851 |
+
if idempotency_identity is not None:
|
| 852 |
+
previous = self._idempotency.get(idempotency_identity)
|
| 853 |
+
if previous is not None:
|
| 854 |
+
return True, previous
|
| 855 |
+
account = self._accounts.get(namespace)
|
| 856 |
+
if account is None:
|
| 857 |
+
return False, None
|
| 858 |
+
wire = raw if raw is not None else message.as_bytes()
|
| 859 |
+
message_count = self._namespace_message_counts.get(namespace, 0)
|
| 860 |
+
stored_bytes = self._namespace_stored_bytes.get(namespace, 0)
|
| 861 |
+
if (
|
| 862 |
+
message_count >= _MAX_MESSAGES_PER_NAMESPACE
|
| 863 |
+
or stored_bytes + len(wire) > _MAX_STORED_BYTES_PER_NAMESPACE
|
| 864 |
+
):
|
| 865 |
+
raise MailboxCapacityError("mailbox namespace capacity exceeded")
|
| 866 |
+
# Keep the lock across the final hop so concurrent requests with
|
| 867 |
+
# one idempotency key cannot manufacture two accepted messages.
|
| 868 |
+
# No message body or code is retained after Mailpit acknowledges
|
| 869 |
+
# the SMTP DATA command.
|
| 870 |
+
provider_id = self._broker.send(
|
| 871 |
+
account.account_id,
|
| 872 |
+
account.send_capability,
|
| 873 |
+
wire,
|
| 874 |
+
envelope_from,
|
| 875 |
+
recipients,
|
| 876 |
+
)
|
| 877 |
+
self._namespace_message_counts[namespace] = message_count + 1
|
| 878 |
+
self._namespace_stored_bytes[namespace] = stored_bytes + len(wire)
|
| 879 |
+
if idempotency_identity is not None:
|
| 880 |
+
self._idempotency[idempotency_identity] = provider_id
|
| 881 |
+
return True, provider_id
|
| 882 |
+
|
| 883 |
+
def deliver(self, raw: bytes, envelope_from: str, recipients: list[str]) -> bool:
|
| 884 |
+
message = email.message_from_bytes(raw, policy=default)
|
| 885 |
+
namespace = str(message.get("X-WebsiteBench-Namespace", "default"))
|
| 886 |
+
capability = str(message.get("X-WebsiteBench-Capability", ""))
|
| 887 |
+
if not _NAMESPACE.fullmatch(namespace) or not self.authorized(
|
| 888 |
+
namespace, capability
|
| 889 |
+
):
|
| 890 |
+
return False
|
| 891 |
+
accepted, _provider_id = self._store_message(
|
| 892 |
+
message,
|
| 893 |
+
envelope_from,
|
| 894 |
+
recipients,
|
| 895 |
+
namespace=namespace,
|
| 896 |
+
raw=raw,
|
| 897 |
+
)
|
| 898 |
+
return accepted
|
| 899 |
+
|
| 900 |
+
def deliver_to(
|
| 901 |
+
self,
|
| 902 |
+
namespace: str,
|
| 903 |
+
raw: bytes,
|
| 904 |
+
envelope_from: str,
|
| 905 |
+
recipients: list[str],
|
| 906 |
+
) -> bool:
|
| 907 |
+
"""Store mail on a listener already fixed to one registered namespace.
|
| 908 |
+
|
| 909 |
+
Formal candidate runtimes receive access to that write-only listener,
|
| 910 |
+
not to the namespace-selecting SMTP or JSON API used by reference
|
| 911 |
+
capture. The routing decision therefore belongs to trusted verifier
|
| 912 |
+
infrastructure rather than to candidate-authored message headers.
|
| 913 |
+
"""
|
| 914 |
+
|
| 915 |
+
if not _NAMESPACE.fullmatch(namespace):
|
| 916 |
+
return False
|
| 917 |
+
with self._lock:
|
| 918 |
+
registered = namespace in self._capabilities
|
| 919 |
+
if not registered:
|
| 920 |
+
return False
|
| 921 |
+
message = email.message_from_bytes(raw, policy=default)
|
| 922 |
+
accepted, _provider_id = self._store_message(
|
| 923 |
+
message,
|
| 924 |
+
envelope_from,
|
| 925 |
+
recipients,
|
| 926 |
+
namespace=namespace,
|
| 927 |
+
raw=raw,
|
| 928 |
+
)
|
| 929 |
+
return accepted
|
| 930 |
+
|
| 931 |
+
def deliver_resend_style_to(
|
| 932 |
+
self,
|
| 933 |
+
namespace: str,
|
| 934 |
+
*,
|
| 935 |
+
envelope_from: str,
|
| 936 |
+
recipients: list[str],
|
| 937 |
+
subject: str,
|
| 938 |
+
text: str,
|
| 939 |
+
idempotency_key: str | None,
|
| 940 |
+
) -> tuple[bool, str | None]:
|
| 941 |
+
"""Store one text-only Resend-style request in a fixed namespace."""
|
| 942 |
+
|
| 943 |
+
if not _NAMESPACE.fullmatch(namespace):
|
| 944 |
+
return False, None
|
| 945 |
+
with self._lock:
|
| 946 |
+
registered = namespace in self._capabilities
|
| 947 |
+
if not registered:
|
| 948 |
+
return False, None
|
| 949 |
+
message = EmailMessage()
|
| 950 |
+
message["From"] = envelope_from
|
| 951 |
+
message["To"] = ", ".join(recipients)
|
| 952 |
+
message["Subject"] = subject
|
| 953 |
+
message.set_content(text)
|
| 954 |
+
return self._store_message(
|
| 955 |
+
message,
|
| 956 |
+
envelope_from,
|
| 957 |
+
recipients,
|
| 958 |
+
namespace=namespace,
|
| 959 |
+
idempotency_key=idempotency_key,
|
| 960 |
+
raw=message.as_bytes(),
|
| 961 |
+
)
|
| 962 |
+
|
| 963 |
+
def messages(
|
| 964 |
+
self, namespace: str, recipient: str | None = None
|
| 965 |
+
) -> list[dict[str, Any]]:
|
| 966 |
+
with self._lock:
|
| 967 |
+
account = self._accounts.get(namespace)
|
| 968 |
+
if account is None:
|
| 969 |
+
return []
|
| 970 |
+
values = self._broker.messages(
|
| 971 |
+
account.account_id, account.read_capability, recipient
|
| 972 |
+
)
|
| 973 |
+
for item in values:
|
| 974 |
+
item["namespace"] = namespace
|
| 975 |
+
item.pop("stored_bytes", None)
|
| 976 |
+
item.pop("mailpit_id", None)
|
| 977 |
+
return values
|
| 978 |
+
|
| 979 |
+
|
| 980 |
+
_INBOX_STYLE = (
|
| 981 |
+
"body{font:16px/1.5 system-ui,sans-serif;margin:0;background:#f6f7f9;"
|
| 982 |
+
"color:#1b1f24}"
|
| 983 |
+
"header{background:#fff;border-bottom:1px solid #d8dee4;padding:16px 24px}"
|
| 984 |
+
"h1{font-size:20px;margin:0}"
|
| 985 |
+
"main{max-width:52rem;margin:0 auto;padding:24px}"
|
| 986 |
+
"a{color:#0b62d0}"
|
| 987 |
+
".msg{background:#fff;border:1px solid #d8dee4;border-radius:8px;"
|
| 988 |
+
"padding:12px 16px;margin-bottom:12px}"
|
| 989 |
+
".msg h2{font-size:16px;margin:0 0 4px}"
|
| 990 |
+
".meta{color:#57606a;font-size:13px;margin:0}"
|
| 991 |
+
".empty{color:#57606a}"
|
| 992 |
+
"pre{white-space:pre-wrap;word-break:break-word;background:#f6f8fa;"
|
| 993 |
+
"border-radius:6px;padding:12px;margin:12px 0 0}"
|
| 994 |
+
)
|
| 995 |
+
|
| 996 |
+
|
| 997 |
+
def _document(title: str, body: str) -> bytes:
|
| 998 |
+
"""One self-contained HTML page. Every interpolated value is escaped."""
|
| 999 |
+
|
| 1000 |
+
return (
|
| 1001 |
+
"<!doctype html><html lang=en><meta charset=utf-8>"
|
| 1002 |
+
'<meta name=viewport content="width=device-width,initial-scale=1">'
|
| 1003 |
+
f"<title>{html.escape(title)}</title>"
|
| 1004 |
+
f"<style>{_INBOX_STYLE}</style>"
|
| 1005 |
+
f"<header><h1>{html.escape(title)}</h1></header><main>{body}</main>"
|
| 1006 |
+
"</html>"
|
| 1007 |
+
).encode("utf-8")
|
| 1008 |
+
|
| 1009 |
+
|
| 1010 |
+
def _recipients(message: dict[str, Any]) -> str:
|
| 1011 |
+
return ", ".join(str(item) for item in message.get("recipients", []))
|
| 1012 |
+
|
| 1013 |
+
|
| 1014 |
+
def render_inbox(messages: list[dict[str, Any]], *, base_path: str = "") -> bytes:
|
| 1015 |
+
"""The message list an agent reads in a browser.
|
| 1016 |
+
|
| 1017 |
+
The extracted ``otp`` is deliberately absent: an agent should read the code
|
| 1018 |
+
out of the body the way a person would. That field stays an evaluator-side
|
| 1019 |
+
convenience on the JSON API.
|
| 1020 |
+
"""
|
| 1021 |
+
|
| 1022 |
+
if not messages:
|
| 1023 |
+
body = (
|
| 1024 |
+
"<p class=empty id=inbox-empty>No messages yet. Mail sent to this "
|
| 1025 |
+
"mailbox appears here.</p>"
|
| 1026 |
+
)
|
| 1027 |
+
else:
|
| 1028 |
+
body = "".join(
|
| 1029 |
+
"<article class=msg>"
|
| 1030 |
+
f'<h2><a href="{html.escape(base_path)}/messages/{int(item["id"])}">'
|
| 1031 |
+
f"{html.escape(str(item.get('subject', '')))}</a></h2>"
|
| 1032 |
+
f"<p class=meta>From {html.escape(str(item.get('envelope_from', '')))}"
|
| 1033 |
+
f" · To {html.escape(_recipients(item))}"
|
| 1034 |
+
f" · Message {int(item['id'])}</p>"
|
| 1035 |
+
"</article>"
|
| 1036 |
+
for item in messages
|
| 1037 |
+
)
|
| 1038 |
+
refresh = f'<p><a href="{html.escape(base_path)}" id=inbox-refresh>Refresh</a></p>'
|
| 1039 |
+
return _document("Inbox", body + refresh)
|
| 1040 |
+
|
| 1041 |
+
|
| 1042 |
+
def render_message(message: dict[str, Any], *, base_path: str = "") -> bytes:
|
| 1043 |
+
"""One message, body included, for the agent to read the code out of."""
|
| 1044 |
+
|
| 1045 |
+
body = (
|
| 1046 |
+
"<article class=msg>"
|
| 1047 |
+
f"<h2>{html.escape(str(message.get('subject', '')))}</h2>"
|
| 1048 |
+
f"<p class=meta>From {html.escape(str(message.get('envelope_from', '')))}"
|
| 1049 |
+
f" · To {html.escape(_recipients(message))}</p>"
|
| 1050 |
+
f"<pre id=message-body>{html.escape(str(message.get('text', '')))}</pre>"
|
| 1051 |
+
"</article>"
|
| 1052 |
+
f'<p><a href="{html.escape(base_path)}" id=inbox-back>Back to inbox</a></p>'
|
| 1053 |
+
)
|
| 1054 |
+
return _document("Message", body)
|
| 1055 |
+
|
| 1056 |
+
|
| 1057 |
+
class _SmtpHandler(socketserver.StreamRequestHandler):
|
| 1058 |
+
def handle(self) -> None:
|
| 1059 |
+
timer = threading.Timer(
|
| 1060 |
+
_MAX_CONNECTION_LIFETIME_SECONDS, self._expire_connection
|
| 1061 |
+
)
|
| 1062 |
+
timer.daemon = True
|
| 1063 |
+
timer.start()
|
| 1064 |
+
try:
|
| 1065 |
+
self._handle_session()
|
| 1066 |
+
finally:
|
| 1067 |
+
timer.cancel()
|
| 1068 |
+
|
| 1069 |
+
def _expire_connection(self) -> None:
|
| 1070 |
+
try:
|
| 1071 |
+
self.connection.shutdown(socket.SHUT_RDWR)
|
| 1072 |
+
except OSError:
|
| 1073 |
+
pass
|
| 1074 |
+
|
| 1075 |
+
def _handle_session(self) -> None:
|
| 1076 |
+
store: MailboxStore = self.server.store # type: ignore[attr-defined]
|
| 1077 |
+
self.connection.settimeout(_CONNECTION_TIMEOUT_SECONDS)
|
| 1078 |
+
self.wfile.write(b"220 websitebench.local ESMTP\r\n")
|
| 1079 |
+
envelope_from = ""
|
| 1080 |
+
recipients: list[str] = []
|
| 1081 |
+
for _command_count in range(_MAX_COMMANDS_PER_CONNECTION):
|
| 1082 |
+
try:
|
| 1083 |
+
line = self.rfile.readline(65537)
|
| 1084 |
+
except (TimeoutError, socket.timeout):
|
| 1085 |
+
return
|
| 1086 |
+
if not line:
|
| 1087 |
+
return
|
| 1088 |
+
if len(line) > 65536:
|
| 1089 |
+
self.wfile.write(b"500 Command line too long\r\n")
|
| 1090 |
+
return
|
| 1091 |
+
command = line.decode("utf-8", "replace").rstrip("\r\n")
|
| 1092 |
+
upper = command.upper()
|
| 1093 |
+
if upper.startswith(("EHLO", "HELO")):
|
| 1094 |
+
self.wfile.write(b"250-websitebench.local\r\n250 SIZE 1048576\r\n")
|
| 1095 |
+
elif upper.startswith("MAIL FROM:"):
|
| 1096 |
+
path = command.split(":", 1)[1].strip()
|
| 1097 |
+
envelope_from = (
|
| 1098 |
+
path[1:].split(">", 1)[0]
|
| 1099 |
+
if path.startswith("<") and ">" in path
|
| 1100 |
+
else path.split(None, 1)[0].strip("<>")
|
| 1101 |
+
)
|
| 1102 |
+
recipients = []
|
| 1103 |
+
self.wfile.write(b"250 OK\r\n")
|
| 1104 |
+
elif upper.startswith("RCPT TO:"):
|
| 1105 |
+
if len(recipients) >= _MAX_RECIPIENTS:
|
| 1106 |
+
self.wfile.write(b"452 Too many recipients\r\n")
|
| 1107 |
+
continue
|
| 1108 |
+
path = command.split(":", 1)[1].strip()
|
| 1109 |
+
recipients.append(
|
| 1110 |
+
path[1:].split(">", 1)[0]
|
| 1111 |
+
if path.startswith("<") and ">" in path
|
| 1112 |
+
else path.split(None, 1)[0].strip("<>")
|
| 1113 |
+
)
|
| 1114 |
+
self.wfile.write(b"250 OK\r\n")
|
| 1115 |
+
elif upper == "DATA":
|
| 1116 |
+
self.wfile.write(b"354 End data with <CR><LF>.<CR><LF>\r\n")
|
| 1117 |
+
chunks = bytearray()
|
| 1118 |
+
oversized = False
|
| 1119 |
+
while True:
|
| 1120 |
+
try:
|
| 1121 |
+
data_line = self.rfile.readline(65537)
|
| 1122 |
+
except (TimeoutError, socket.timeout):
|
| 1123 |
+
return
|
| 1124 |
+
if data_line in {b".\r\n", b".\n", b""}:
|
| 1125 |
+
break
|
| 1126 |
+
if len(data_line) > 65536:
|
| 1127 |
+
oversized = True
|
| 1128 |
+
value = data_line[1:] if data_line.startswith(b"..") else data_line
|
| 1129 |
+
if len(chunks) + len(value) > _MAX_MESSAGE_BYTES:
|
| 1130 |
+
oversized = True
|
| 1131 |
+
elif not oversized:
|
| 1132 |
+
chunks.extend(value)
|
| 1133 |
+
if oversized:
|
| 1134 |
+
self.wfile.write(b"552 Message exceeds fixed local limit\r\n")
|
| 1135 |
+
continue
|
| 1136 |
+
fixed_namespace = getattr(self.server, "fixed_namespace", None)
|
| 1137 |
+
try:
|
| 1138 |
+
accepted = (
|
| 1139 |
+
store.deliver_to(
|
| 1140 |
+
fixed_namespace,
|
| 1141 |
+
bytes(chunks),
|
| 1142 |
+
envelope_from,
|
| 1143 |
+
recipients,
|
| 1144 |
+
)
|
| 1145 |
+
if isinstance(fixed_namespace, str)
|
| 1146 |
+
else store.deliver(bytes(chunks), envelope_from, recipients)
|
| 1147 |
+
)
|
| 1148 |
+
except MailboxCapacityError:
|
| 1149 |
+
self.wfile.write(b"452 Mailbox capacity exceeded\r\n")
|
| 1150 |
+
continue
|
| 1151 |
+
except PermissionError:
|
| 1152 |
+
self.wfile.write(b"550 Mail sender or recipient is not allowed\r\n")
|
| 1153 |
+
continue
|
| 1154 |
+
except MailpitInfrastructureError:
|
| 1155 |
+
self.wfile.write(b"451 Mailpit delivery unavailable\r\n")
|
| 1156 |
+
continue
|
| 1157 |
+
self.wfile.write(
|
| 1158 |
+
b"250 Accepted by Mailpit\r\n"
|
| 1159 |
+
if accepted
|
| 1160 |
+
else b"550 Invalid namespace capability\r\n"
|
| 1161 |
+
)
|
| 1162 |
+
elif upper == "RSET":
|
| 1163 |
+
envelope_from, recipients = "", []
|
| 1164 |
+
self.wfile.write(b"250 OK\r\n")
|
| 1165 |
+
elif upper == "NOOP":
|
| 1166 |
+
self.wfile.write(b"250 OK\r\n")
|
| 1167 |
+
elif upper == "QUIT":
|
| 1168 |
+
self.wfile.write(b"221 Bye\r\n")
|
| 1169 |
+
return
|
| 1170 |
+
else:
|
| 1171 |
+
self.wfile.write(b"502 Command not implemented\r\n")
|
| 1172 |
+
self.wfile.write(b"421 Command limit exceeded\r\n")
|
| 1173 |
+
|
| 1174 |
+
|
| 1175 |
+
class _SmtpServer(socketserver.ThreadingTCPServer):
|
| 1176 |
+
allow_reuse_address = True
|
| 1177 |
+
daemon_threads = True
|
| 1178 |
+
|
| 1179 |
+
def __init__(
|
| 1180 |
+
self,
|
| 1181 |
+
address: tuple[str, int],
|
| 1182 |
+
store: MailboxStore,
|
| 1183 |
+
*,
|
| 1184 |
+
fixed_namespace: str | None = None,
|
| 1185 |
+
) -> None:
|
| 1186 |
+
self.store = store
|
| 1187 |
+
self.fixed_namespace = fixed_namespace
|
| 1188 |
+
self._connection_slots = threading.BoundedSemaphore(_MAX_CONCURRENT_CONNECTIONS)
|
| 1189 |
+
super().__init__(address, _SmtpHandler)
|
| 1190 |
+
|
| 1191 |
+
def process_request(self, request: Any, client_address: Any) -> None:
|
| 1192 |
+
if not self._connection_slots.acquire(blocking=False):
|
| 1193 |
+
request.close()
|
| 1194 |
+
return
|
| 1195 |
+
super().process_request(request, client_address)
|
| 1196 |
+
|
| 1197 |
+
def process_request_thread(self, request: Any, client_address: Any) -> None:
|
| 1198 |
+
try:
|
| 1199 |
+
super().process_request_thread(request, client_address)
|
| 1200 |
+
finally:
|
| 1201 |
+
self._connection_slots.release()
|
| 1202 |
+
|
| 1203 |
+
|
| 1204 |
+
class _HttpServer(ThreadingHTTPServer):
|
| 1205 |
+
daemon_threads = True
|
| 1206 |
+
|
| 1207 |
+
def __init__(self, address: tuple[str, int], handler: Any) -> None:
|
| 1208 |
+
self._connection_slots = threading.BoundedSemaphore(_MAX_CONCURRENT_CONNECTIONS)
|
| 1209 |
+
super().__init__(address, handler)
|
| 1210 |
+
|
| 1211 |
+
def process_request(self, request: Any, client_address: Any) -> None:
|
| 1212 |
+
if not self._connection_slots.acquire(blocking=False):
|
| 1213 |
+
request.close()
|
| 1214 |
+
return
|
| 1215 |
+
super().process_request(request, client_address)
|
| 1216 |
+
|
| 1217 |
+
def process_request_thread(self, request: Any, client_address: Any) -> None:
|
| 1218 |
+
def expire() -> None:
|
| 1219 |
+
try:
|
| 1220 |
+
request.shutdown(socket.SHUT_RDWR)
|
| 1221 |
+
except OSError:
|
| 1222 |
+
pass
|
| 1223 |
+
|
| 1224 |
+
timer = threading.Timer(_MAX_CONNECTION_LIFETIME_SECONDS, expire)
|
| 1225 |
+
timer.daemon = True
|
| 1226 |
+
timer.start()
|
| 1227 |
+
try:
|
| 1228 |
+
request.settimeout(_CONNECTION_TIMEOUT_SECONDS)
|
| 1229 |
+
super().process_request_thread(request, client_address)
|
| 1230 |
+
finally:
|
| 1231 |
+
timer.cancel()
|
| 1232 |
+
self._connection_slots.release()
|
| 1233 |
+
|
| 1234 |
+
|
| 1235 |
+
def _http_handler(
|
| 1236 |
+
store: MailboxStore,
|
| 1237 |
+
bootstrap: "_Bootstrap | _BootstrapSlot | None" = None,
|
| 1238 |
+
) -> type[BaseHTTPRequestHandler]:
|
| 1239 |
+
"""The evaluator- and site-facing listener: JSON, Bearer-gated throughout."""
|
| 1240 |
+
|
| 1241 |
+
slot = (
|
| 1242 |
+
bootstrap
|
| 1243 |
+
if isinstance(bootstrap, _BootstrapSlot)
|
| 1244 |
+
else _BootstrapSlot(bootstrap)
|
| 1245 |
+
)
|
| 1246 |
+
|
| 1247 |
+
class Handler(BaseHTTPRequestHandler):
|
| 1248 |
+
def _authorized(self, namespace: str) -> bool:
|
| 1249 |
+
prefix = "Bearer "
|
| 1250 |
+
header = self.headers.get("Authorization", "")
|
| 1251 |
+
capability = header[len(prefix) :] if header.startswith(prefix) else None
|
| 1252 |
+
if store.authorized(namespace, capability):
|
| 1253 |
+
return True
|
| 1254 |
+
self._json(403, {"error": "forbidden"})
|
| 1255 |
+
return False
|
| 1256 |
+
|
| 1257 |
+
def _json(self, status: int, value: Any) -> None:
|
| 1258 |
+
body = json.dumps(value, ensure_ascii=False, sort_keys=True).encode("utf-8")
|
| 1259 |
+
self.send_response(status)
|
| 1260 |
+
self.send_header("Content-Type", "application/json; charset=utf-8")
|
| 1261 |
+
self.send_header("Content-Length", str(len(body)))
|
| 1262 |
+
self.end_headers()
|
| 1263 |
+
self.wfile.write(body)
|
| 1264 |
+
|
| 1265 |
+
def _html(self, status: int, body: bytes) -> None:
|
| 1266 |
+
self.send_response(status)
|
| 1267 |
+
self.send_header("Content-Type", "text/html; charset=utf-8")
|
| 1268 |
+
self.send_header("Content-Length", str(len(body)))
|
| 1269 |
+
self.end_headers()
|
| 1270 |
+
self.wfile.write(body)
|
| 1271 |
+
|
| 1272 |
+
def do_GET(self) -> None: # noqa: N802
|
| 1273 |
+
parsed = urllib.parse.urlsplit(self.path)
|
| 1274 |
+
if parsed.path == "/healthz":
|
| 1275 |
+
if store.healthy():
|
| 1276 |
+
self._json(200, {"status": "ok"})
|
| 1277 |
+
else:
|
| 1278 |
+
self._json(503, {"status": "unavailable"})
|
| 1279 |
+
return
|
| 1280 |
+
if parsed.path == "/internal/bootstrap":
|
| 1281 |
+
# The site process learns this trial's namespace and capability
|
| 1282 |
+
# here. It is gated on its own token so the route stays closed
|
| 1283 |
+
# even if the internal network were misrouted.
|
| 1284 |
+
identity = slot.get()
|
| 1285 |
+
if identity is None:
|
| 1286 |
+
self._json(404, {"error": "not_found"})
|
| 1287 |
+
return
|
| 1288 |
+
prefix = "Bearer "
|
| 1289 |
+
header = self.headers.get("Authorization", "")
|
| 1290 |
+
presented = header[len(prefix) :] if header.startswith(prefix) else ""
|
| 1291 |
+
if not hmac.compare_digest(identity.token, presented):
|
| 1292 |
+
self._json(403, {"error": "forbidden"})
|
| 1293 |
+
return
|
| 1294 |
+
self._json(200, identity.payload())
|
| 1295 |
+
return
|
| 1296 |
+
parts = parsed.path.strip("/").split("/")
|
| 1297 |
+
if (
|
| 1298 |
+
len(parts) >= 4
|
| 1299 |
+
and parts[:2] == ["api", "namespaces"]
|
| 1300 |
+
and parts[3] == "messages"
|
| 1301 |
+
):
|
| 1302 |
+
namespace = urllib.parse.unquote(parts[2])
|
| 1303 |
+
if not _NAMESPACE.fullmatch(namespace):
|
| 1304 |
+
self._json(400, {"error": "invalid_namespace"})
|
| 1305 |
+
return
|
| 1306 |
+
if not self._authorized(namespace):
|
| 1307 |
+
return
|
| 1308 |
+
recipient = urllib.parse.parse_qs(parsed.query).get(
|
| 1309 |
+
"recipient", [None]
|
| 1310 |
+
)[0]
|
| 1311 |
+
try:
|
| 1312 |
+
values = store.messages(namespace, recipient)
|
| 1313 |
+
except PermissionError:
|
| 1314 |
+
self._json(403, {"error": "recipient_forbidden"})
|
| 1315 |
+
return
|
| 1316 |
+
except MailpitInfrastructureError:
|
| 1317 |
+
self._json(503, {"error": "mailpit_unavailable"})
|
| 1318 |
+
return
|
| 1319 |
+
if len(parts) == 5 and parts[4] == "latest":
|
| 1320 |
+
if not values:
|
| 1321 |
+
self._json(404, {"error": "message_not_found"})
|
| 1322 |
+
else:
|
| 1323 |
+
self._json(200, values[-1])
|
| 1324 |
+
else:
|
| 1325 |
+
self._json(200, {"messages": values})
|
| 1326 |
+
return
|
| 1327 |
+
if len(parts) == 2 and parts[0] == "inbox":
|
| 1328 |
+
namespace = urllib.parse.unquote(parts[1])
|
| 1329 |
+
if not _NAMESPACE.fullmatch(namespace):
|
| 1330 |
+
self._json(400, {"error": "invalid_namespace"})
|
| 1331 |
+
return
|
| 1332 |
+
if not self._authorized(namespace):
|
| 1333 |
+
return
|
| 1334 |
+
try:
|
| 1335 |
+
messages = store.messages(namespace)
|
| 1336 |
+
except PermissionError:
|
| 1337 |
+
self._json(403, {"error": "forbidden"})
|
| 1338 |
+
return
|
| 1339 |
+
except MailpitInfrastructureError:
|
| 1340 |
+
self._json(503, {"error": "mailpit_unavailable"})
|
| 1341 |
+
return
|
| 1342 |
+
body = render_inbox(
|
| 1343 |
+
messages, base_path=f"/inbox/{urllib.parse.quote(namespace)}"
|
| 1344 |
+
)
|
| 1345 |
+
self._html(200, body)
|
| 1346 |
+
return
|
| 1347 |
+
self._json(404, {"error": "not_found"})
|
| 1348 |
+
|
| 1349 |
+
def do_POST(self) -> None: # noqa: N802
|
| 1350 |
+
"""Accept reference mail through a bootstrap-token write-only API."""
|
| 1351 |
+
|
| 1352 |
+
parsed = urllib.parse.urlsplit(self.path)
|
| 1353 |
+
if parsed.path != "/emails" or parsed.query or parsed.fragment:
|
| 1354 |
+
self._json(404, {"error": "not_found"})
|
| 1355 |
+
return
|
| 1356 |
+
identity = slot.get()
|
| 1357 |
+
if identity is None:
|
| 1358 |
+
self._json(404, {"error": "not_found"})
|
| 1359 |
+
return
|
| 1360 |
+
prefix = "Bearer "
|
| 1361 |
+
header = self.headers.get("Authorization", "")
|
| 1362 |
+
presented = header[len(prefix) :] if header.startswith(prefix) else ""
|
| 1363 |
+
if not hmac.compare_digest(identity.token, presented):
|
| 1364 |
+
self._json(401, {"error": "unauthorized"})
|
| 1365 |
+
return
|
| 1366 |
+
if self.headers.get("Content-Type", "").split(";", 1)[0].strip().lower() != "application/json":
|
| 1367 |
+
self._json(415, {"error": "application_json_required"})
|
| 1368 |
+
return
|
| 1369 |
+
try:
|
| 1370 |
+
content_length = int(self.headers.get("Content-Length", ""))
|
| 1371 |
+
except ValueError:
|
| 1372 |
+
self._json(411, {"error": "content_length_required"})
|
| 1373 |
+
return
|
| 1374 |
+
if content_length < 0 or content_length > _MAX_MESSAGE_BYTES:
|
| 1375 |
+
self._json(413, {"error": "message_too_large"})
|
| 1376 |
+
return
|
| 1377 |
+
try:
|
| 1378 |
+
value = json.loads(self.rfile.read(content_length).decode("utf-8"))
|
| 1379 |
+
except (UnicodeDecodeError, json.JSONDecodeError):
|
| 1380 |
+
self._json(400, {"error": "invalid_json"})
|
| 1381 |
+
return
|
| 1382 |
+
if not isinstance(value, dict) or set(value) != {"from", "to", "subject", "text"}:
|
| 1383 |
+
self._json(400, {"error": "invalid_message_fields"})
|
| 1384 |
+
return
|
| 1385 |
+
envelope_from = value.get("from")
|
| 1386 |
+
recipients = value.get("to")
|
| 1387 |
+
subject = value.get("subject")
|
| 1388 |
+
message_text = value.get("text")
|
| 1389 |
+
recipients = [recipients] if isinstance(recipients, str) else recipients
|
| 1390 |
+
if (
|
| 1391 |
+
not isinstance(envelope_from, str)
|
| 1392 |
+
or not envelope_from
|
| 1393 |
+
or "@" not in envelope_from
|
| 1394 |
+
or "\r" in envelope_from
|
| 1395 |
+
or "\n" in envelope_from
|
| 1396 |
+
or not isinstance(recipients, list)
|
| 1397 |
+
or not 1 <= len(recipients) <= _MAX_RECIPIENTS
|
| 1398 |
+
or any(
|
| 1399 |
+
not isinstance(recipient, str)
|
| 1400 |
+
or not recipient
|
| 1401 |
+
or len(recipient) > 320
|
| 1402 |
+
or "@" not in recipient
|
| 1403 |
+
or "\r" in recipient
|
| 1404 |
+
or "\n" in recipient
|
| 1405 |
+
for recipient in recipients
|
| 1406 |
+
)
|
| 1407 |
+
or not isinstance(subject, str)
|
| 1408 |
+
or len(subject) > 998
|
| 1409 |
+
or "\r" in subject
|
| 1410 |
+
or "\n" in subject
|
| 1411 |
+
or not isinstance(message_text, str)
|
| 1412 |
+
or len(message_text.encode("utf-8")) > _MAX_MESSAGE_BYTES
|
| 1413 |
+
):
|
| 1414 |
+
self._json(400, {"error": "invalid_message"})
|
| 1415 |
+
return
|
| 1416 |
+
idempotency_key = self.headers.get("Idempotency-Key")
|
| 1417 |
+
if idempotency_key is not None and (
|
| 1418 |
+
not idempotency_key
|
| 1419 |
+
or len(idempotency_key) > 256
|
| 1420 |
+
or "\r" in idempotency_key
|
| 1421 |
+
or "\n" in idempotency_key
|
| 1422 |
+
):
|
| 1423 |
+
self._json(400, {"error": "invalid_idempotency_key"})
|
| 1424 |
+
return
|
| 1425 |
+
try:
|
| 1426 |
+
accepted, provider_id = store.deliver_resend_style_to(
|
| 1427 |
+
identity.namespace,
|
| 1428 |
+
envelope_from=envelope_from,
|
| 1429 |
+
recipients=recipients,
|
| 1430 |
+
subject=subject,
|
| 1431 |
+
text=message_text,
|
| 1432 |
+
idempotency_key=idempotency_key,
|
| 1433 |
+
)
|
| 1434 |
+
except MailboxCapacityError:
|
| 1435 |
+
self._json(429, {"error": "mailbox_capacity"})
|
| 1436 |
+
return
|
| 1437 |
+
except MailpitInfrastructureError:
|
| 1438 |
+
self._json(503, {"error": "mailpit_unavailable"})
|
| 1439 |
+
return
|
| 1440 |
+
if not accepted or provider_id is None:
|
| 1441 |
+
self._json(503, {"error": "delivery_failed"})
|
| 1442 |
+
return
|
| 1443 |
+
self._json(200, {"id": provider_id})
|
| 1444 |
+
|
| 1445 |
+
def log_message(self, format: str, *args: Any) -> None:
|
| 1446 |
+
return
|
| 1447 |
+
|
| 1448 |
+
return Handler
|
| 1449 |
+
|
| 1450 |
+
|
| 1451 |
+
def _candidate_bootstrap_handler(
|
| 1452 |
+
*,
|
| 1453 |
+
store: MailboxStore,
|
| 1454 |
+
bootstrap_token: str,
|
| 1455 |
+
mail_api_token: str,
|
| 1456 |
+
namespace: str,
|
| 1457 |
+
capability: str,
|
| 1458 |
+
smtp_host: str,
|
| 1459 |
+
smtp_port: int,
|
| 1460 |
+
sender: str,
|
| 1461 |
+
) -> type[BaseHTTPRequestHandler]:
|
| 1462 |
+
"""Expose write-only mail paths without exposing the mailbox read API.
|
| 1463 |
+
|
| 1464 |
+
``POST /emails`` is deliberately a small Resend-style subset: one fixed
|
| 1465 |
+
sender, one or more recipients, a subject, and a plain-text body. The
|
| 1466 |
+
endpoint owns the trial namespace, so candidate input can never select a
|
| 1467 |
+
second mailbox. The legacy bootstrap and SMTP coordinates remain here for
|
| 1468 |
+
candidates using the vendored ``websitebench.site_backend`` transport.
|
| 1469 |
+
"""
|
| 1470 |
+
|
| 1471 |
+
payload = {
|
| 1472 |
+
"namespace": namespace,
|
| 1473 |
+
"capability": capability,
|
| 1474 |
+
"smtp_host": smtp_host,
|
| 1475 |
+
"smtp_port": smtp_port,
|
| 1476 |
+
}
|
| 1477 |
+
|
| 1478 |
+
class CandidateBootstrapHandler(BaseHTTPRequestHandler):
|
| 1479 |
+
def _json(self, status: int, value: Any) -> None:
|
| 1480 |
+
body = json.dumps(value, ensure_ascii=False, sort_keys=True).encode("utf-8")
|
| 1481 |
+
self.send_response(status)
|
| 1482 |
+
self.send_header("Content-Type", "application/json; charset=utf-8")
|
| 1483 |
+
self.send_header("Content-Length", str(len(body)))
|
| 1484 |
+
self.send_header("Cache-Control", "no-store")
|
| 1485 |
+
self.end_headers()
|
| 1486 |
+
self.wfile.write(body)
|
| 1487 |
+
|
| 1488 |
+
def do_GET(self) -> None: # noqa: N802
|
| 1489 |
+
parsed = urllib.parse.urlsplit(self.path)
|
| 1490 |
+
if parsed.path == "/healthz":
|
| 1491 |
+
healthy = store.healthy()
|
| 1492 |
+
self._json(200 if healthy else 503, {"status": "ok" if healthy else "unavailable"})
|
| 1493 |
+
return
|
| 1494 |
+
if parsed.path != "/internal/bootstrap":
|
| 1495 |
+
self._json(404, {"error": "not_found"})
|
| 1496 |
+
return
|
| 1497 |
+
prefix = "Bearer "
|
| 1498 |
+
header = self.headers.get("Authorization", "")
|
| 1499 |
+
presented = header[len(prefix) :] if header.startswith(prefix) else ""
|
| 1500 |
+
if not hmac.compare_digest(bootstrap_token, presented):
|
| 1501 |
+
self._json(403, {"error": "forbidden"})
|
| 1502 |
+
return
|
| 1503 |
+
self._json(200, payload)
|
| 1504 |
+
|
| 1505 |
+
def do_POST(self) -> None: # noqa: N802
|
| 1506 |
+
parsed = urllib.parse.urlsplit(self.path)
|
| 1507 |
+
if parsed.path != "/emails" or parsed.query or parsed.fragment:
|
| 1508 |
+
self._json(404, {"error": "not_found"})
|
| 1509 |
+
return
|
| 1510 |
+
prefix = "Bearer "
|
| 1511 |
+
header = self.headers.get("Authorization", "")
|
| 1512 |
+
presented = header[len(prefix) :] if header.startswith(prefix) else ""
|
| 1513 |
+
if not hmac.compare_digest(mail_api_token, presented):
|
| 1514 |
+
self._json(401, {"error": "unauthorized"})
|
| 1515 |
+
return
|
| 1516 |
+
content_type = self.headers.get("Content-Type", "").split(";", 1)[0]
|
| 1517 |
+
if content_type.strip().lower() != "application/json":
|
| 1518 |
+
self._json(415, {"error": "application_json_required"})
|
| 1519 |
+
return
|
| 1520 |
+
try:
|
| 1521 |
+
content_length = int(self.headers.get("Content-Length", ""))
|
| 1522 |
+
except ValueError:
|
| 1523 |
+
self._json(411, {"error": "content_length_required"})
|
| 1524 |
+
return
|
| 1525 |
+
if content_length < 0 or content_length > _MAX_MESSAGE_BYTES:
|
| 1526 |
+
self._json(413, {"error": "message_too_large"})
|
| 1527 |
+
return
|
| 1528 |
+
raw = self.rfile.read(content_length)
|
| 1529 |
+
if len(raw) != content_length:
|
| 1530 |
+
self._json(400, {"error": "incomplete_request"})
|
| 1531 |
+
return
|
| 1532 |
+
try:
|
| 1533 |
+
value = json.loads(raw.decode("utf-8"))
|
| 1534 |
+
except (UnicodeDecodeError, json.JSONDecodeError):
|
| 1535 |
+
self._json(400, {"error": "invalid_json"})
|
| 1536 |
+
return
|
| 1537 |
+
if not isinstance(value, dict) or set(value) != {
|
| 1538 |
+
"from",
|
| 1539 |
+
"to",
|
| 1540 |
+
"subject",
|
| 1541 |
+
"text",
|
| 1542 |
+
}:
|
| 1543 |
+
self._json(400, {"error": "invalid_message_fields"})
|
| 1544 |
+
return
|
| 1545 |
+
envelope_from = value.get("from")
|
| 1546 |
+
subject = value.get("subject")
|
| 1547 |
+
text = value.get("text")
|
| 1548 |
+
raw_recipients = value.get("to")
|
| 1549 |
+
recipients = (
|
| 1550 |
+
[raw_recipients] if isinstance(raw_recipients, str) else raw_recipients
|
| 1551 |
+
)
|
| 1552 |
+
if (
|
| 1553 |
+
envelope_from != sender
|
| 1554 |
+
or not isinstance(subject, str)
|
| 1555 |
+
or not isinstance(text, str)
|
| 1556 |
+
or not isinstance(recipients, list)
|
| 1557 |
+
or not 1 <= len(recipients) <= _MAX_RECIPIENTS
|
| 1558 |
+
or any(
|
| 1559 |
+
not isinstance(recipient, str)
|
| 1560 |
+
or not recipient
|
| 1561 |
+
or len(recipient) > 320
|
| 1562 |
+
or "@" not in recipient
|
| 1563 |
+
or "\r" in recipient
|
| 1564 |
+
or "\n" in recipient
|
| 1565 |
+
for recipient in recipients
|
| 1566 |
+
)
|
| 1567 |
+
or len(subject) > 998
|
| 1568 |
+
or "\r" in subject
|
| 1569 |
+
or "\n" in subject
|
| 1570 |
+
):
|
| 1571 |
+
self._json(400, {"error": "invalid_message"})
|
| 1572 |
+
return
|
| 1573 |
+
try:
|
| 1574 |
+
encoded_text = text.encode("utf-8")
|
| 1575 |
+
subject.encode("utf-8")
|
| 1576 |
+
for recipient in recipients:
|
| 1577 |
+
recipient.encode("utf-8")
|
| 1578 |
+
except UnicodeEncodeError:
|
| 1579 |
+
self._json(400, {"error": "invalid_message"})
|
| 1580 |
+
return
|
| 1581 |
+
if len(encoded_text) > _MAX_MESSAGE_BYTES:
|
| 1582 |
+
self._json(413, {"error": "message_too_large"})
|
| 1583 |
+
return
|
| 1584 |
+
idempotency_key = self.headers.get("Idempotency-Key")
|
| 1585 |
+
if idempotency_key is not None and (
|
| 1586 |
+
not idempotency_key
|
| 1587 |
+
or len(idempotency_key) > 256
|
| 1588 |
+
or "\r" in idempotency_key
|
| 1589 |
+
or "\n" in idempotency_key
|
| 1590 |
+
):
|
| 1591 |
+
self._json(400, {"error": "invalid_idempotency_key"})
|
| 1592 |
+
return
|
| 1593 |
+
try:
|
| 1594 |
+
accepted, provider_id = store.deliver_resend_style_to(
|
| 1595 |
+
namespace,
|
| 1596 |
+
envelope_from=envelope_from,
|
| 1597 |
+
recipients=recipients,
|
| 1598 |
+
subject=subject,
|
| 1599 |
+
text=text,
|
| 1600 |
+
idempotency_key=idempotency_key,
|
| 1601 |
+
)
|
| 1602 |
+
except MailboxCapacityError:
|
| 1603 |
+
self._json(429, {"error": "mailbox_capacity"})
|
| 1604 |
+
return
|
| 1605 |
+
except MailpitInfrastructureError:
|
| 1606 |
+
self._json(503, {"error": "mailpit_unavailable"})
|
| 1607 |
+
return
|
| 1608 |
+
if not accepted or provider_id is None:
|
| 1609 |
+
self._json(429, {"error": "mailbox_capacity"})
|
| 1610 |
+
return
|
| 1611 |
+
self._json(200, {"id": provider_id})
|
| 1612 |
+
|
| 1613 |
+
def log_message(self, format: str, *args: Any) -> None:
|
| 1614 |
+
return
|
| 1615 |
+
|
| 1616 |
+
return CandidateBootstrapHandler
|
| 1617 |
+
|
| 1618 |
+
|
| 1619 |
+
@dataclass(frozen=True, repr=False)
|
| 1620 |
+
class _Bootstrap:
|
| 1621 |
+
"""What the site process is allowed to learn, and the token that gates it."""
|
| 1622 |
+
|
| 1623 |
+
token: str
|
| 1624 |
+
namespace: str
|
| 1625 |
+
capability: str
|
| 1626 |
+
smtp_host: str
|
| 1627 |
+
smtp_port: int
|
| 1628 |
+
|
| 1629 |
+
def __repr__(self) -> str:
|
| 1630 |
+
return f"_Bootstrap(namespace={self.namespace!r}, token=<redacted>)"
|
| 1631 |
+
|
| 1632 |
+
def payload(self) -> dict[str, Any]:
|
| 1633 |
+
return {
|
| 1634 |
+
"namespace": self.namespace,
|
| 1635 |
+
"capability": self.capability,
|
| 1636 |
+
"smtp_host": self.smtp_host,
|
| 1637 |
+
"smtp_port": self.smtp_port,
|
| 1638 |
+
}
|
| 1639 |
+
|
| 1640 |
+
|
| 1641 |
+
class _BootstrapSlot:
|
| 1642 |
+
"""The identity ``/internal/bootstrap`` is serving right now.
|
| 1643 |
+
|
| 1644 |
+
A trial's mailbox identity is minted once and never moves, so the slot is
|
| 1645 |
+
written once and read forever. Reference capture is the exception that
|
| 1646 |
+
makes it a slot at all: it relaunches the reference between tasks, and each
|
| 1647 |
+
relaunch has to be its own trial -- same bootstrap token, because that is
|
| 1648 |
+
the site process's own credential and the site is what stays the same, but
|
| 1649 |
+
a namespace and capability nothing before it could have seen. Rotating
|
| 1650 |
+
behind the slot lets the operator do that without tearing down the listener
|
| 1651 |
+
the site is about to call.
|
| 1652 |
+
"""
|
| 1653 |
+
|
| 1654 |
+
def __init__(self, bootstrap: "_Bootstrap | None" = None) -> None:
|
| 1655 |
+
self._lock = threading.Lock()
|
| 1656 |
+
self._value = bootstrap
|
| 1657 |
+
|
| 1658 |
+
def __repr__(self) -> str:
|
| 1659 |
+
return f"_BootstrapSlot({self._value!r})"
|
| 1660 |
+
|
| 1661 |
+
def get(self) -> "_Bootstrap | None":
|
| 1662 |
+
with self._lock:
|
| 1663 |
+
return self._value
|
| 1664 |
+
|
| 1665 |
+
def rotate(self, *, namespace: str, capability: str) -> "_Bootstrap":
|
| 1666 |
+
"""Swap in a fresh namespace and capability, keeping the token."""
|
| 1667 |
+
|
| 1668 |
+
with self._lock:
|
| 1669 |
+
current = self._value
|
| 1670 |
+
if current is None:
|
| 1671 |
+
raise RuntimeError("this mailbox serves no bootstrap identity")
|
| 1672 |
+
rotated = replace(current, namespace=namespace, capability=capability)
|
| 1673 |
+
self._value = rotated
|
| 1674 |
+
return rotated
|
| 1675 |
+
|
| 1676 |
+
|
| 1677 |
+
def _inbox_handler(
|
| 1678 |
+
store: MailboxStore, namespace: str, token: str
|
| 1679 |
+
) -> type[BaseHTTPRequestHandler]:
|
| 1680 |
+
"""The agent-facing listener: one namespace, HTML only, no capability.
|
| 1681 |
+
|
| 1682 |
+
The namespace is closed over at construction, so there is no request-time
|
| 1683 |
+
parameter an agent could vary to reach a second mailbox. Requirement 5
|
| 1684 |
+
holds by construction rather than by a check that could be bypassed.
|
| 1685 |
+
"""
|
| 1686 |
+
|
| 1687 |
+
inbox_path = "/inbox/" + urllib.parse.quote(token, safe="")
|
| 1688 |
+
|
| 1689 |
+
class InboxHandler(BaseHTTPRequestHandler):
|
| 1690 |
+
def _send(self, status: int, body: bytes, content_type: str) -> None:
|
| 1691 |
+
self.send_response(status)
|
| 1692 |
+
self.send_header("Content-Type", content_type)
|
| 1693 |
+
self.send_header("Content-Length", str(len(body)))
|
| 1694 |
+
# The inbox is per-trial and mutates; never let it be cached.
|
| 1695 |
+
self.send_header("Cache-Control", "no-store")
|
| 1696 |
+
self.send_header("Referrer-Policy", "no-referrer")
|
| 1697 |
+
self.end_headers()
|
| 1698 |
+
self.wfile.write(body)
|
| 1699 |
+
|
| 1700 |
+
def _not_found(self) -> None:
|
| 1701 |
+
self._send(
|
| 1702 |
+
404,
|
| 1703 |
+
_document("Not found", "<p>No such page.</p>"),
|
| 1704 |
+
"text/html; charset=utf-8",
|
| 1705 |
+
)
|
| 1706 |
+
|
| 1707 |
+
def do_GET(self) -> None: # noqa: N802
|
| 1708 |
+
parsed = urllib.parse.urlsplit(self.path)
|
| 1709 |
+
if parsed.path == "/healthz":
|
| 1710 |
+
healthy = store.healthy()
|
| 1711 |
+
body = json.dumps(
|
| 1712 |
+
{"status": "ok" if healthy else "unavailable"}
|
| 1713 |
+
).encode("utf-8")
|
| 1714 |
+
self._send(
|
| 1715 |
+
200 if healthy else 503,
|
| 1716 |
+
body,
|
| 1717 |
+
"application/json; charset=utf-8",
|
| 1718 |
+
)
|
| 1719 |
+
return
|
| 1720 |
+
if parsed.path in {"", "/"}:
|
| 1721 |
+
self.send_response(302)
|
| 1722 |
+
self.send_header("Location", inbox_path)
|
| 1723 |
+
self.send_header("Content-Length", "0")
|
| 1724 |
+
self.end_headers()
|
| 1725 |
+
return
|
| 1726 |
+
parts = [
|
| 1727 |
+
urllib.parse.unquote(part) for part in parsed.path.strip("/").split("/")
|
| 1728 |
+
]
|
| 1729 |
+
# Defence in depth for the shared-origin topology, where the path is
|
| 1730 |
+
# the only thing separating one trial's inbox from another's.
|
| 1731 |
+
if len(parts) < 2 or parts[0] != "inbox":
|
| 1732 |
+
self._not_found()
|
| 1733 |
+
return
|
| 1734 |
+
if not hmac.compare_digest(token, parts[1]):
|
| 1735 |
+
self._not_found()
|
| 1736 |
+
return
|
| 1737 |
+
try:
|
| 1738 |
+
values = store.messages(namespace)
|
| 1739 |
+
except MailpitInfrastructureError:
|
| 1740 |
+
body = json.dumps({"status": "unavailable"}).encode("utf-8")
|
| 1741 |
+
self._send(503, body, "application/json; charset=utf-8")
|
| 1742 |
+
return
|
| 1743 |
+
if len(parts) == 2:
|
| 1744 |
+
self._send(
|
| 1745 |
+
200,
|
| 1746 |
+
render_inbox(values, base_path=inbox_path),
|
| 1747 |
+
"text/html; charset=utf-8",
|
| 1748 |
+
)
|
| 1749 |
+
return
|
| 1750 |
+
if len(parts) == 4 and parts[2] == "messages":
|
| 1751 |
+
try:
|
| 1752 |
+
identifier = int(parts[3])
|
| 1753 |
+
except ValueError:
|
| 1754 |
+
self._not_found()
|
| 1755 |
+
return
|
| 1756 |
+
for item in values:
|
| 1757 |
+
if int(item["id"]) == identifier:
|
| 1758 |
+
self._send(
|
| 1759 |
+
200,
|
| 1760 |
+
render_message(item, base_path=inbox_path),
|
| 1761 |
+
"text/html; charset=utf-8",
|
| 1762 |
+
)
|
| 1763 |
+
return
|
| 1764 |
+
self._not_found()
|
| 1765 |
+
|
| 1766 |
+
def log_message(self, format: str, *args: Any) -> None:
|
| 1767 |
+
return
|
| 1768 |
+
|
| 1769 |
+
return InboxHandler
|
| 1770 |
+
|
| 1771 |
+
|
| 1772 |
+
class LocalMailboxSidecar:
|
| 1773 |
+
"""A loopback-only SMTP and Inbox API pair with namespace isolation."""
|
| 1774 |
+
|
| 1775 |
+
def __init__(
|
| 1776 |
+
self,
|
| 1777 |
+
*,
|
| 1778 |
+
smtp_port: int = 0,
|
| 1779 |
+
http_port: int = 0,
|
| 1780 |
+
bind_host: str = "127.0.0.1",
|
| 1781 |
+
inbox_port: int | None = None,
|
| 1782 |
+
inbox_bind_host: str | None = None,
|
| 1783 |
+
inbox_namespace: str | None = None,
|
| 1784 |
+
inbox_token: str | None = None,
|
| 1785 |
+
bootstrap: "_Bootstrap | None" = None,
|
| 1786 |
+
mailpit_client: MailpitClient,
|
| 1787 |
+
) -> None:
|
| 1788 |
+
self.store = MailboxStore(mailpit_client=mailpit_client)
|
| 1789 |
+
self._bootstrap = _BootstrapSlot(bootstrap)
|
| 1790 |
+
self.smtp = _SmtpServer((bind_host, smtp_port), self.store)
|
| 1791 |
+
self.http = _HttpServer(
|
| 1792 |
+
(bind_host, http_port), _http_handler(self.store, self._bootstrap)
|
| 1793 |
+
)
|
| 1794 |
+
self.inbox: _HttpServer | None = None
|
| 1795 |
+
self._inbox_token = inbox_token
|
| 1796 |
+
if inbox_namespace is not None or inbox_token is not None:
|
| 1797 |
+
if not inbox_namespace or not inbox_token:
|
| 1798 |
+
raise ValueError("an inbox listener needs both namespace and token")
|
| 1799 |
+
self.inbox = _HttpServer(
|
| 1800 |
+
(inbox_bind_host or bind_host, inbox_port or 0),
|
| 1801 |
+
_inbox_handler(self.store, inbox_namespace, inbox_token),
|
| 1802 |
+
)
|
| 1803 |
+
self._threads: list[threading.Thread] = []
|
| 1804 |
+
|
| 1805 |
+
@property
|
| 1806 |
+
def smtp_port(self) -> int:
|
| 1807 |
+
return int(self.smtp.server_address[1])
|
| 1808 |
+
|
| 1809 |
+
@property
|
| 1810 |
+
def http_port(self) -> int:
|
| 1811 |
+
return int(self.http.server_address[1])
|
| 1812 |
+
|
| 1813 |
+
@property
|
| 1814 |
+
def inbox_port(self) -> int:
|
| 1815 |
+
if self.inbox is None:
|
| 1816 |
+
raise RuntimeError("this sidecar has no inbox listener")
|
| 1817 |
+
return int(self.inbox.server_address[1])
|
| 1818 |
+
|
| 1819 |
+
@property
|
| 1820 |
+
def url(self) -> str:
|
| 1821 |
+
return f"http://127.0.0.1:{self.http_port}"
|
| 1822 |
+
|
| 1823 |
+
@property
|
| 1824 |
+
def inbox_url(self) -> str:
|
| 1825 |
+
"""The bare origin an agent is handed. It carries no secret."""
|
| 1826 |
+
|
| 1827 |
+
return f"http://127.0.0.1:{self.inbox_port}"
|
| 1828 |
+
|
| 1829 |
+
@property
|
| 1830 |
+
def _servers(self) -> tuple[Any, ...]:
|
| 1831 |
+
return (
|
| 1832 |
+
(self.smtp, self.http)
|
| 1833 |
+
if self.inbox is None
|
| 1834 |
+
else (
|
| 1835 |
+
self.smtp,
|
| 1836 |
+
self.http,
|
| 1837 |
+
self.inbox,
|
| 1838 |
+
)
|
| 1839 |
+
)
|
| 1840 |
+
|
| 1841 |
+
def register_namespace(self, namespace: str, capability: str) -> None:
|
| 1842 |
+
"""Bind one opaque namespace to its unguessable per-worker capability."""
|
| 1843 |
+
|
| 1844 |
+
self.store.register(namespace, capability)
|
| 1845 |
+
|
| 1846 |
+
def rotate_bootstrap(self, namespace: str, capability: str) -> None:
|
| 1847 |
+
"""Point ``/internal/bootstrap`` at a freshly minted namespace.
|
| 1848 |
+
|
| 1849 |
+
Registration happens first on purpose: a site that fetched the new
|
| 1850 |
+
identity and sent before the store knew it would have its message
|
| 1851 |
+
dropped at the SMTP door, which reads as a flaky mailbox rather than
|
| 1852 |
+
the ordering bug it is.
|
| 1853 |
+
"""
|
| 1854 |
+
|
| 1855 |
+
previous = self._bootstrap.get()
|
| 1856 |
+
self.register_namespace(namespace, capability)
|
| 1857 |
+
# Candidate trials route direct SMTP into one fixed namespace. Mirror
|
| 1858 |
+
# that ABI during paired reference capture so runtimes using the direct
|
| 1859 |
+
# writer do not need the structured transport's namespace headers.
|
| 1860 |
+
self.smtp.fixed_namespace = namespace
|
| 1861 |
+
self._bootstrap.rotate(namespace=namespace, capability=capability)
|
| 1862 |
+
if previous is not None and previous.namespace != namespace:
|
| 1863 |
+
self.store.seal_namespace(previous.namespace)
|
| 1864 |
+
|
| 1865 |
+
def start(self) -> "LocalMailboxSidecar":
|
| 1866 |
+
if not self.store.healthy():
|
| 1867 |
+
raise MailpitInfrastructureError("Mailpit is not ready")
|
| 1868 |
+
for server in self._servers:
|
| 1869 |
+
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
| 1870 |
+
thread.start()
|
| 1871 |
+
self._threads.append(thread)
|
| 1872 |
+
return self
|
| 1873 |
+
|
| 1874 |
+
def close(self) -> None:
|
| 1875 |
+
for server in self._servers:
|
| 1876 |
+
server.shutdown()
|
| 1877 |
+
server.server_close()
|
| 1878 |
+
for thread in self._threads:
|
| 1879 |
+
thread.join(timeout=5)
|
| 1880 |
+
self._threads.clear()
|
| 1881 |
+
self.store.destroy_namespaces()
|
| 1882 |
+
|
| 1883 |
+
def __enter__(self) -> "LocalMailboxSidecar":
|
| 1884 |
+
return self.start()
|
| 1885 |
+
|
| 1886 |
+
def __exit__(self, exc_type: object, exc: object, traceback: object) -> None:
|
| 1887 |
+
self.close()
|
| 1888 |
+
|
| 1889 |
+
|
| 1890 |
+
class CandidateMailboxTrial:
|
| 1891 |
+
"""One formal case's write-only candidate mailbox and trusted reader.
|
| 1892 |
+
|
| 1893 |
+
Candidate code prefers the Resend-style ``POST /emails`` endpoint and may
|
| 1894 |
+
use ``smtp``/``bootstrap`` for compatibility. Both writers are fixed to
|
| 1895 |
+
this trial's namespace. The verifier API listens on a third, unadvertised
|
| 1896 |
+
port that the candidate sandbox does not permit, and it uses a distinct
|
| 1897 |
+
read credential that never enters the candidate environment.
|
| 1898 |
+
"""
|
| 1899 |
+
|
| 1900 |
+
def __init__(
|
| 1901 |
+
self,
|
| 1902 |
+
*,
|
| 1903 |
+
bind_host: str = "127.0.0.1",
|
| 1904 |
+
mailpit_client: MailpitClient | None = None,
|
| 1905 |
+
) -> None:
|
| 1906 |
+
self._runtime = None if mailpit_client is not None else EphemeralMailpit()
|
| 1907 |
+
storage_client = (
|
| 1908 |
+
mailpit_client
|
| 1909 |
+
if mailpit_client is not None
|
| 1910 |
+
else self._runtime.client
|
| 1911 |
+
if self._runtime is not None
|
| 1912 |
+
else None
|
| 1913 |
+
)
|
| 1914 |
+
namespace, read_credential, _inbox_token = _mint_identity()
|
| 1915 |
+
self.namespace = namespace
|
| 1916 |
+
self.read_credential = read_credential
|
| 1917 |
+
self._write_capability = secrets.token_hex(32)
|
| 1918 |
+
self._bootstrap_token = secrets.token_hex(32)
|
| 1919 |
+
self._mail_api_token = secrets.token_hex(32)
|
| 1920 |
+
self._sender = CANDIDATE_MAIL_SENDER
|
| 1921 |
+
self.store = MailboxStore(mailpit_client=storage_client)
|
| 1922 |
+
self.store.register(
|
| 1923 |
+
namespace,
|
| 1924 |
+
read_credential,
|
| 1925 |
+
allowed_from=(self._sender,),
|
| 1926 |
+
)
|
| 1927 |
+
self.smtp = _SmtpServer(
|
| 1928 |
+
(bind_host, 0),
|
| 1929 |
+
self.store,
|
| 1930 |
+
fixed_namespace=namespace,
|
| 1931 |
+
)
|
| 1932 |
+
self.http = _HttpServer(
|
| 1933 |
+
(bind_host, 0),
|
| 1934 |
+
_http_handler(self.store),
|
| 1935 |
+
)
|
| 1936 |
+
self.bootstrap = _HttpServer(
|
| 1937 |
+
(bind_host, 0),
|
| 1938 |
+
_candidate_bootstrap_handler(
|
| 1939 |
+
store=self.store,
|
| 1940 |
+
bootstrap_token=self._bootstrap_token,
|
| 1941 |
+
mail_api_token=self._mail_api_token,
|
| 1942 |
+
namespace=namespace,
|
| 1943 |
+
capability=self._write_capability,
|
| 1944 |
+
smtp_host=bind_host,
|
| 1945 |
+
smtp_port=self.smtp_port,
|
| 1946 |
+
sender=self._sender,
|
| 1947 |
+
),
|
| 1948 |
+
)
|
| 1949 |
+
self._threads: list[threading.Thread] = []
|
| 1950 |
+
|
| 1951 |
+
@property
|
| 1952 |
+
def smtp_port(self) -> int:
|
| 1953 |
+
return int(self.smtp.server_address[1])
|
| 1954 |
+
|
| 1955 |
+
@property
|
| 1956 |
+
def http_port(self) -> int:
|
| 1957 |
+
return int(self.http.server_address[1])
|
| 1958 |
+
|
| 1959 |
+
@property
|
| 1960 |
+
def bootstrap_port(self) -> int:
|
| 1961 |
+
return int(self.bootstrap.server_address[1])
|
| 1962 |
+
|
| 1963 |
+
@property
|
| 1964 |
+
def url(self) -> str:
|
| 1965 |
+
return f"http://127.0.0.1:{self.http_port}"
|
| 1966 |
+
|
| 1967 |
+
@property
|
| 1968 |
+
def candidate_environment(self) -> dict[str, str]:
|
| 1969 |
+
"""The complete optional mail ABI handed to the candidate runtime."""
|
| 1970 |
+
|
| 1971 |
+
return {
|
| 1972 |
+
"WEBSITEBENCH_MAIL_API_URL": (
|
| 1973 |
+
f"http://127.0.0.1:{self.bootstrap_port}/emails"
|
| 1974 |
+
),
|
| 1975 |
+
"WEBSITEBENCH_MAIL_API_TOKEN": self._mail_api_token,
|
| 1976 |
+
"WEBSITEBENCH_MAIL_FROM": self._sender,
|
| 1977 |
+
"WEBSITEBENCH_SMTP_HOST": "127.0.0.1",
|
| 1978 |
+
"WEBSITEBENCH_SMTP_PORT": str(self.smtp_port),
|
| 1979 |
+
"WEBSITEBENCH_SMTP_FROM": self._sender,
|
| 1980 |
+
# Compatibility seam for candidates using websitebench.site_backend.
|
| 1981 |
+
# It serves write coordinates only and has no read routes.
|
| 1982 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_URL": (
|
| 1983 |
+
f"http://127.0.0.1:{self.bootstrap_port}/internal/bootstrap"
|
| 1984 |
+
),
|
| 1985 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_TOKEN": self._bootstrap_token,
|
| 1986 |
+
}
|
| 1987 |
+
|
| 1988 |
+
@property
|
| 1989 |
+
def candidate_connect_ports(self) -> frozenset[int]:
|
| 1990 |
+
return frozenset({self.smtp_port, self.bootstrap_port})
|
| 1991 |
+
|
| 1992 |
+
def start(self) -> "CandidateMailboxTrial":
|
| 1993 |
+
if self._runtime is not None:
|
| 1994 |
+
try:
|
| 1995 |
+
self._runtime.start()
|
| 1996 |
+
except BaseException:
|
| 1997 |
+
for server in (self.smtp, self.http, self.bootstrap):
|
| 1998 |
+
server.server_close()
|
| 1999 |
+
raise
|
| 2000 |
+
if not self.store.healthy():
|
| 2001 |
+
for server in (self.smtp, self.http, self.bootstrap):
|
| 2002 |
+
server.server_close()
|
| 2003 |
+
if self._runtime is not None:
|
| 2004 |
+
self._runtime.close()
|
| 2005 |
+
raise MailpitInfrastructureError("Mailpit is not ready")
|
| 2006 |
+
for server in (self.smtp, self.http, self.bootstrap):
|
| 2007 |
+
thread = threading.Thread(
|
| 2008 |
+
target=server.serve_forever,
|
| 2009 |
+
name=f"candidate-mailbox-{server.server_address[1]}",
|
| 2010 |
+
daemon=True,
|
| 2011 |
+
)
|
| 2012 |
+
thread.start()
|
| 2013 |
+
self._threads.append(thread)
|
| 2014 |
+
return self
|
| 2015 |
+
|
| 2016 |
+
def close(self) -> None:
|
| 2017 |
+
for server in (self.smtp, self.http, self.bootstrap):
|
| 2018 |
+
server.shutdown()
|
| 2019 |
+
server.server_close()
|
| 2020 |
+
for thread in self._threads:
|
| 2021 |
+
thread.join(timeout=5)
|
| 2022 |
+
self._threads.clear()
|
| 2023 |
+
self.store.destroy_namespaces()
|
| 2024 |
+
if self._runtime is not None:
|
| 2025 |
+
self._runtime.close()
|
| 2026 |
+
|
| 2027 |
+
def __enter__(self) -> "CandidateMailboxTrial":
|
| 2028 |
+
return self.start()
|
| 2029 |
+
|
| 2030 |
+
def __exit__(self, exc_type: object, exc: object, traceback: object) -> None:
|
| 2031 |
+
self.close()
|
| 2032 |
+
|
| 2033 |
+
|
| 2034 |
+
def _candidate_environment_problem(
|
| 2035 |
+
environment: Mapping[str, str], private_values: tuple[str, ...]
|
| 2036 |
+
) -> str | None:
|
| 2037 |
+
"""Return why ``environment`` may not be handed to a candidate, or ``None``.
|
| 2038 |
+
|
| 2039 |
+
The candidate mail ABI is a closed set of names carrying loopback
|
| 2040 |
+
coordinates only. A name outside the set, a Mailpit control variable, or
|
| 2041 |
+
any value naming the evaluator's own Mailpit socket would hand a candidate
|
| 2042 |
+
the trusted store instead of its write-only door.
|
| 2043 |
+
"""
|
| 2044 |
+
|
| 2045 |
+
unknown = sorted(set(environment) - CANDIDATE_MAIL_ENVIRONMENT)
|
| 2046 |
+
if unknown:
|
| 2047 |
+
return f"candidate mailbox environment has unknown names: {unknown}"
|
| 2048 |
+
leaked = any(
|
| 2049 |
+
name.startswith("WEBSITEBENCH_MAILPIT_")
|
| 2050 |
+
or MAILPIT_RUNTIME_DIR in str(value)
|
| 2051 |
+
or any(private and private in str(value) for private in private_values)
|
| 2052 |
+
for name, value in environment.items()
|
| 2053 |
+
)
|
| 2054 |
+
if leaked:
|
| 2055 |
+
return "candidate mailbox environment exposed the Mailpit UDS"
|
| 2056 |
+
return None
|
| 2057 |
+
|
| 2058 |
+
|
| 2059 |
+
class MailTrial:
|
| 2060 |
+
"""One case's candidate mailbox, as the rest of the evaluator sees it.
|
| 2061 |
+
|
| 2062 |
+
The candidate environment handed out here is already proved to be the
|
| 2063 |
+
closed mail ABI and free of evaluator-side coordinates, so no caller
|
| 2064 |
+
re-scans it. Reads stay on the trusted side: :meth:`deliveries` is the
|
| 2065 |
+
only way out of the store and it never leaves this trial's namespace.
|
| 2066 |
+
"""
|
| 2067 |
+
|
| 2068 |
+
def __init__(
|
| 2069 |
+
self,
|
| 2070 |
+
trial: CandidateMailboxTrial,
|
| 2071 |
+
*,
|
| 2072 |
+
private_values: tuple[str, ...] = (),
|
| 2073 |
+
) -> None:
|
| 2074 |
+
environment = dict(trial.candidate_environment)
|
| 2075 |
+
problem = _candidate_environment_problem(environment, private_values)
|
| 2076 |
+
if problem is not None:
|
| 2077 |
+
trial.close()
|
| 2078 |
+
raise MailpitInfrastructureError(problem)
|
| 2079 |
+
self._trial = trial
|
| 2080 |
+
self._environment = environment
|
| 2081 |
+
|
| 2082 |
+
@property
|
| 2083 |
+
def namespace(self) -> str:
|
| 2084 |
+
return self._trial.namespace
|
| 2085 |
+
|
| 2086 |
+
@property
|
| 2087 |
+
def read_credential(self) -> str:
|
| 2088 |
+
return self._trial.read_credential
|
| 2089 |
+
|
| 2090 |
+
@property
|
| 2091 |
+
def url(self) -> str:
|
| 2092 |
+
"""The verifier-only reader origin; the candidate cannot reach it."""
|
| 2093 |
+
|
| 2094 |
+
return self._trial.url
|
| 2095 |
+
|
| 2096 |
+
@property
|
| 2097 |
+
def http_port(self) -> int:
|
| 2098 |
+
return self._trial.http_port
|
| 2099 |
+
|
| 2100 |
+
@property
|
| 2101 |
+
def store(self) -> MailboxStore:
|
| 2102 |
+
return self._trial.store
|
| 2103 |
+
|
| 2104 |
+
@property
|
| 2105 |
+
def candidate_environment(self) -> dict[str, str]:
|
| 2106 |
+
"""The complete optional mail ABI this case's candidate receives."""
|
| 2107 |
+
|
| 2108 |
+
return dict(self._environment)
|
| 2109 |
+
|
| 2110 |
+
@property
|
| 2111 |
+
def candidate_connect_ports(self) -> frozenset[int]:
|
| 2112 |
+
"""The loopback ports the candidate sandbox may connect out to."""
|
| 2113 |
+
|
| 2114 |
+
return self._trial.candidate_connect_ports
|
| 2115 |
+
|
| 2116 |
+
def healthy(self) -> bool:
|
| 2117 |
+
"""Whether the backing store still answers, so an outage is not scored."""
|
| 2118 |
+
|
| 2119 |
+
return self._trial.store.healthy()
|
| 2120 |
+
|
| 2121 |
+
def deliveries(self) -> list[dict[str, Any]]:
|
| 2122 |
+
"""Every message this trial's namespace received, newest first."""
|
| 2123 |
+
|
| 2124 |
+
return self._trial.store.messages(self._trial.namespace)
|
| 2125 |
+
|
| 2126 |
+
def close(self) -> None:
|
| 2127 |
+
self._trial.close()
|
| 2128 |
+
|
| 2129 |
+
def __enter__(self) -> "MailTrial":
|
| 2130 |
+
return self
|
| 2131 |
+
|
| 2132 |
+
def __exit__(self, exc_type: object, exc: object, traceback: object) -> None:
|
| 2133 |
+
self.close()
|
| 2134 |
+
|
| 2135 |
+
|
| 2136 |
+
class MailPlane:
|
| 2137 |
+
"""The evaluator's single door to Mailpit.
|
| 2138 |
+
|
| 2139 |
+
Everything that knows a socket path, a container lifetime, a namespace or
|
| 2140 |
+
the candidate mail ABI lives behind this facade. ``formal``,
|
| 2141 |
+
``trusted_check`` and ``capture`` ask the plane for a trial, a runner
|
| 2142 |
+
passthrough or an authoring gateway; they never build a Mailpit client,
|
| 2143 |
+
read a Mailpit variable, or inspect what they hand a candidate.
|
| 2144 |
+
"""
|
| 2145 |
+
|
| 2146 |
+
def __init__(
|
| 2147 |
+
self, client: MailpitClient, *, runtime: EphemeralMailpit | None = None
|
| 2148 |
+
) -> None:
|
| 2149 |
+
self.client = client
|
| 2150 |
+
self._runtime = runtime
|
| 2151 |
+
|
| 2152 |
+
@staticmethod
|
| 2153 |
+
def _configured_socket(env: Mapping[str, str]) -> str:
|
| 2154 |
+
"""The evaluator's only read of :data:`MAILPIT_HTTP_SOCKET_ENV`."""
|
| 2155 |
+
|
| 2156 |
+
return str(env.get(MAILPIT_HTTP_SOCKET_ENV, "") or "").strip()
|
| 2157 |
+
|
| 2158 |
+
@classmethod
|
| 2159 |
+
def from_environment(cls, env: Mapping[str, str] = os.environ) -> "MailPlane":
|
| 2160 |
+
"""Open the Mailpit the environment advertises.
|
| 2161 |
+
|
| 2162 |
+
A missing variable and an unhealthy Mailpit are the same answer to the
|
| 2163 |
+
caller: this process has no mail plane.
|
| 2164 |
+
"""
|
| 2165 |
+
|
| 2166 |
+
socket_path = cls._configured_socket(env)
|
| 2167 |
+
if not socket_path:
|
| 2168 |
+
raise MailInfrastructureUnavailable(
|
| 2169 |
+
f"{MAILPIT_HTTP_SOCKET_ENV} is not configured"
|
| 2170 |
+
)
|
| 2171 |
+
client = MailpitClient(socket_path)
|
| 2172 |
+
if not client.ready():
|
| 2173 |
+
raise MailInfrastructureUnavailable(
|
| 2174 |
+
"Mailpit is not ready on its configured HTTP socket"
|
| 2175 |
+
)
|
| 2176 |
+
return cls(client)
|
| 2177 |
+
|
| 2178 |
+
@classmethod
|
| 2179 |
+
def ephemeral(
|
| 2180 |
+
cls, runtime_dir: str | os.PathLike[str] | None = None
|
| 2181 |
+
) -> "MailPlane":
|
| 2182 |
+
"""Start a private, networkless Mailpit this plane owns and will stop.
|
| 2183 |
+
|
| 2184 |
+
Host-side only: a Harbor trial has no Docker binary, so a scored run
|
| 2185 |
+
always goes through :meth:`from_environment` instead.
|
| 2186 |
+
"""
|
| 2187 |
+
|
| 2188 |
+
runtime = EphemeralMailpit(runtime_dir=runtime_dir).start()
|
| 2189 |
+
return cls(runtime.client, runtime=runtime)
|
| 2190 |
+
|
| 2191 |
+
@classmethod
|
| 2192 |
+
def open(
|
| 2193 |
+
cls,
|
| 2194 |
+
*,
|
| 2195 |
+
runtime_dir: str | os.PathLike[str] | None = None,
|
| 2196 |
+
env: Mapping[str, str] = os.environ,
|
| 2197 |
+
) -> "MailPlane":
|
| 2198 |
+
"""Prefer the advertised Mailpit; start a private one when there is none."""
|
| 2199 |
+
|
| 2200 |
+
if cls._configured_socket(env):
|
| 2201 |
+
return cls.from_environment(env)
|
| 2202 |
+
return cls.ephemeral(runtime_dir=runtime_dir)
|
| 2203 |
+
|
| 2204 |
+
@property
|
| 2205 |
+
def socket_path(self) -> str:
|
| 2206 |
+
return self.client.socket_path
|
| 2207 |
+
|
| 2208 |
+
@property
|
| 2209 |
+
def owns_runtime(self) -> bool:
|
| 2210 |
+
"""Whether closing this plane stops a Mailpit container."""
|
| 2211 |
+
|
| 2212 |
+
return self._runtime is not None
|
| 2213 |
+
|
| 2214 |
+
def healthy(self) -> bool:
|
| 2215 |
+
return self.client.ready()
|
| 2216 |
+
|
| 2217 |
+
def trial(self, *, bind_host: str = "127.0.0.1") -> MailTrial:
|
| 2218 |
+
"""Start one case's write-only candidate mailbox on this plane.
|
| 2219 |
+
|
| 2220 |
+
The result is a context manager, so a caller that owns the mailbox for
|
| 2221 |
+
the length of a ``with`` block needs no other cleanup; a caller that
|
| 2222 |
+
owns it for the length of a case calls :meth:`MailTrial.close`.
|
| 2223 |
+
"""
|
| 2224 |
+
|
| 2225 |
+
trial = CandidateMailboxTrial(
|
| 2226 |
+
bind_host=bind_host, mailpit_client=self.client
|
| 2227 |
+
).start()
|
| 2228 |
+
return MailTrial(trial, private_values=(self.socket_path,))
|
| 2229 |
+
|
| 2230 |
+
def runner_environment(self, base: Mapping[str, str]) -> dict[str, str]:
|
| 2231 |
+
"""Add to ``base`` exactly what a child verifier runner needs.
|
| 2232 |
+
|
| 2233 |
+
A trusted CI/CD runner is launched with a scrubbed environment and has
|
| 2234 |
+
to find the same Mailpit; that is one variable, and no other mail
|
| 2235 |
+
coordinate crosses the boundary.
|
| 2236 |
+
"""
|
| 2237 |
+
|
| 2238 |
+
return {**dict(base), MAILPIT_HTTP_SOCKET_ENV: self.socket_path}
|
| 2239 |
+
|
| 2240 |
+
def authoring_gateway(
|
| 2241 |
+
self,
|
| 2242 |
+
*,
|
| 2243 |
+
namespace: str,
|
| 2244 |
+
capability: str,
|
| 2245 |
+
bootstrap_token: str,
|
| 2246 |
+
smtp_port: int,
|
| 2247 |
+
bind_host: str = "127.0.0.1",
|
| 2248 |
+
) -> LocalMailboxSidecar:
|
| 2249 |
+
"""Expose the stable loopback writer ABI over this plane, for authoring.
|
| 2250 |
+
|
| 2251 |
+
Capture hands a reference site the same SMTP/bootstrap door a scored
|
| 2252 |
+
candidate gets, so what capture exercises is what a trial will run.
|
| 2253 |
+
There is intentionally no in-memory fallback.
|
| 2254 |
+
"""
|
| 2255 |
+
|
| 2256 |
+
if not self.client.ready():
|
| 2257 |
+
raise MailInfrastructureUnavailable("Mailpit is not ready for capture")
|
| 2258 |
+
sidecar = LocalMailboxSidecar(
|
| 2259 |
+
smtp_port=smtp_port,
|
| 2260 |
+
bind_host=bind_host,
|
| 2261 |
+
bootstrap=_Bootstrap(
|
| 2262 |
+
token=bootstrap_token,
|
| 2263 |
+
namespace=namespace,
|
| 2264 |
+
capability=capability,
|
| 2265 |
+
smtp_host=bind_host,
|
| 2266 |
+
smtp_port=smtp_port,
|
| 2267 |
+
),
|
| 2268 |
+
mailpit_client=self.client,
|
| 2269 |
+
)
|
| 2270 |
+
sidecar.register_namespace(namespace, capability)
|
| 2271 |
+
sidecar.start()
|
| 2272 |
+
return sidecar
|
| 2273 |
+
|
| 2274 |
+
def close(self) -> None:
|
| 2275 |
+
runtime, self._runtime = self._runtime, None
|
| 2276 |
+
if runtime is not None:
|
| 2277 |
+
runtime.close()
|
| 2278 |
+
|
| 2279 |
+
def __enter__(self) -> "MailPlane":
|
| 2280 |
+
return self
|
| 2281 |
+
|
| 2282 |
+
def __exit__(self, exc_type: object, exc: object, traceback: object) -> None:
|
| 2283 |
+
self.close()
|
| 2284 |
+
|
| 2285 |
+
|
| 2286 |
+
def authoring_environment(
|
| 2287 |
+
sidecar: LocalMailboxSidecar,
|
| 2288 |
+
*,
|
| 2289 |
+
namespace: str,
|
| 2290 |
+
capability: str,
|
| 2291 |
+
bootstrap_token: str,
|
| 2292 |
+
smtp_port: int,
|
| 2293 |
+
smtp_host: str = "127.0.0.1",
|
| 2294 |
+
) -> dict[str, str]:
|
| 2295 |
+
"""The complete mail ABI an authoring capture exports around a reference site.
|
| 2296 |
+
|
| 2297 |
+
It is a superset of the candidate ABI: authoring also owns the read
|
| 2298 |
+
credential and the namespace, which a scored candidate never sees. The
|
| 2299 |
+
names are exactly :data:`AUTHORING_MAIL_ENVIRONMENT`.
|
| 2300 |
+
"""
|
| 2301 |
+
|
| 2302 |
+
gateway = sidecar.url.rstrip("/")
|
| 2303 |
+
return {
|
| 2304 |
+
"WEBSITEBENCH_MAILBOX_URL": sidecar.url,
|
| 2305 |
+
"WEBSITEBENCH_MAILBOX_ALLOWLIST": "",
|
| 2306 |
+
"WEBSITEBENCH_MAILBOX_CREDENTIAL": capability,
|
| 2307 |
+
"WEBSITEBENCH_MAILBOX_NAMESPACE": namespace,
|
| 2308 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_URL": f"{gateway}/internal/bootstrap",
|
| 2309 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_TOKEN": bootstrap_token,
|
| 2310 |
+
"WEBSITEBENCH_SMTP_HOST": smtp_host,
|
| 2311 |
+
"WEBSITEBENCH_SMTP_PORT": str(smtp_port),
|
| 2312 |
+
# Paired capture must present the same sender ABI as a formal candidate
|
| 2313 |
+
# trial: some runtimes pin this exact suffix before opening SMTP, so a
|
| 2314 |
+
# site-specific authoring sender would disable their only mail path.
|
| 2315 |
+
"WEBSITEBENCH_MAIL_API_URL": f"{gateway}/emails",
|
| 2316 |
+
"WEBSITEBENCH_MAIL_API_TOKEN": bootstrap_token,
|
| 2317 |
+
"WEBSITEBENCH_MAIL_FROM": CANDIDATE_MAIL_SENDER,
|
| 2318 |
+
"WEBSITEBENCH_SMTP_FROM": CANDIDATE_MAIL_SENDER,
|
| 2319 |
+
}
|
| 2320 |
+
|
| 2321 |
+
|
| 2322 |
+
def _mint_identity() -> tuple[str, str, str]:
|
| 2323 |
+
"""Mint one trial's mailbox identity.
|
| 2324 |
+
|
| 2325 |
+
Minted from ``secrets``, never derived from the public ``seed-<seed>``
|
| 2326 |
+
trial ID, while the inbox token doubles as the browser's access token.
|
| 2327 |
+
Determinism is not lost, because scoring reads no mail.
|
| 2328 |
+
"""
|
| 2329 |
+
|
| 2330 |
+
return (
|
| 2331 |
+
f"trial-{secrets.token_hex(16)}",
|
| 2332 |
+
secrets.token_hex(32),
|
| 2333 |
+
secrets.token_urlsafe(32),
|
| 2334 |
+
)
|
| 2335 |
+
|
| 2336 |
+
|
| 2337 |
+
def main(argv: list[str] | None = None) -> int:
|
| 2338 |
+
"""Run one trial's mailbox, minting that trial's identity at boot.
|
| 2339 |
+
|
| 2340 |
+
``materialize`` runs once per *bundle*; a trial is one *run* of that
|
| 2341 |
+
bundle, so a value written into ``docker-compose.yaml`` can never be
|
| 2342 |
+
per-trial. The identity is therefore minted here, by the one process that
|
| 2343 |
+
owns it, and each party learns only its own half over the listener it is
|
| 2344 |
+
allowed to reach: the site reads ``/internal/bootstrap`` on the API
|
| 2345 |
+
listener, the agent gets a bare inbox URL and no credential at all.
|
| 2346 |
+
|
| 2347 |
+
The values come from ``secrets`` rather than from the public
|
| 2348 |
+
``seed-<seed>`` trial ID. Determinism is not lost, because formal scoring
|
| 2349 |
+
never reads mail.
|
| 2350 |
+
"""
|
| 2351 |
+
|
| 2352 |
+
import argparse
|
| 2353 |
+
|
| 2354 |
+
parser = argparse.ArgumentParser(prog="websitebench-local-mailbox")
|
| 2355 |
+
parser.add_argument("--smtp-port", type=int, default=1025)
|
| 2356 |
+
parser.add_argument("--http-port", type=int, default=8025)
|
| 2357 |
+
parser.add_argument("--inbox-port", type=int, default=8026)
|
| 2358 |
+
parser.add_argument("--bind-host", default="127.0.0.1")
|
| 2359 |
+
parser.add_argument(
|
| 2360 |
+
"--api-bind-host",
|
| 2361 |
+
default=None,
|
| 2362 |
+
help="interface for the SMTP and JSON API listeners (defaults to --bind-host)",
|
| 2363 |
+
)
|
| 2364 |
+
parser.add_argument(
|
| 2365 |
+
"--inbox-bind-host",
|
| 2366 |
+
default=None,
|
| 2367 |
+
help="interface for the agent inbox listener (defaults to --bind-host)",
|
| 2368 |
+
)
|
| 2369 |
+
args = parser.parse_args(argv)
|
| 2370 |
+
|
| 2371 |
+
api_bind = (
|
| 2372 |
+
args.api_bind_host
|
| 2373 |
+
or os.environ.get("WEBSITEBENCH_MAILBOX_API_BIND")
|
| 2374 |
+
or args.bind_host
|
| 2375 |
+
)
|
| 2376 |
+
inbox_bind = (
|
| 2377 |
+
args.inbox_bind_host
|
| 2378 |
+
or os.environ.get("WEBSITEBENCH_MAILBOX_INBOX_BIND")
|
| 2379 |
+
or args.bind_host
|
| 2380 |
+
)
|
| 2381 |
+
smtp_advertise_host = (
|
| 2382 |
+
os.environ.get("WEBSITEBENCH_MAILBOX_SMTP_ADVERTISE_HOST", "").strip()
|
| 2383 |
+
or api_bind
|
| 2384 |
+
)
|
| 2385 |
+
|
| 2386 |
+
namespace, capability, inbox_token = _mint_identity()
|
| 2387 |
+
bootstrap_token = os.environ.get("WEBSITEBENCH_MAILBOX_BOOTSTRAP_TOKEN", "")
|
| 2388 |
+
if len(bootstrap_token) < 32:
|
| 2389 |
+
raise SystemExit(
|
| 2390 |
+
"WEBSITEBENCH_MAILBOX_BOOTSTRAP_TOKEN must be at least 32 characters"
|
| 2391 |
+
)
|
| 2392 |
+
try:
|
| 2393 |
+
mailpit_client = MailPlane.from_environment().client
|
| 2394 |
+
except MailInfrastructureUnavailable as error:
|
| 2395 |
+
# The sidecar discovers its store the same way the evaluator does, and
|
| 2396 |
+
# refuses to serve an in-memory production mailbox when there is none.
|
| 2397 |
+
raise SystemExit(f"{error}; refusing an in-memory production mailbox")
|
| 2398 |
+
|
| 2399 |
+
stopped = threading.Event()
|
| 2400 |
+
signal.signal(signal.SIGTERM, lambda _signum, _frame: stopped.set())
|
| 2401 |
+
signal.signal(signal.SIGINT, lambda _signum, _frame: stopped.set())
|
| 2402 |
+
sidecar = LocalMailboxSidecar(
|
| 2403 |
+
smtp_port=args.smtp_port,
|
| 2404 |
+
http_port=args.http_port,
|
| 2405 |
+
bind_host=api_bind,
|
| 2406 |
+
inbox_port=args.inbox_port,
|
| 2407 |
+
inbox_bind_host=inbox_bind,
|
| 2408 |
+
inbox_namespace=namespace,
|
| 2409 |
+
inbox_token=inbox_token,
|
| 2410 |
+
bootstrap=_Bootstrap(
|
| 2411 |
+
token=bootstrap_token,
|
| 2412 |
+
namespace=namespace,
|
| 2413 |
+
capability=capability,
|
| 2414 |
+
smtp_host=smtp_advertise_host,
|
| 2415 |
+
smtp_port=args.smtp_port,
|
| 2416 |
+
),
|
| 2417 |
+
mailpit_client=mailpit_client,
|
| 2418 |
+
)
|
| 2419 |
+
sidecar.register_namespace(namespace, capability)
|
| 2420 |
+
sidecar.start()
|
| 2421 |
+
# The inbox path is the agent's entry point and holds no secret beyond the
|
| 2422 |
+
# token that scopes it to this trial; nothing else about the trial is
|
| 2423 |
+
# printed, and the capability never is.
|
| 2424 |
+
print(f"inbox listening on {inbox_bind}:{args.inbox_port}", flush=True)
|
| 2425 |
+
try:
|
| 2426 |
+
stopped.wait()
|
| 2427 |
+
finally:
|
| 2428 |
+
sidecar.close()
|
| 2429 |
+
return 0
|
| 2430 |
+
|
| 2431 |
+
|
| 2432 |
+
if __name__ == "__main__":
|
| 2433 |
+
raise SystemExit(main(sys.argv[1:]))
|
tasks/columbia/environment/reference/.websitebench-reference-tls/ca.crt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-----BEGIN CERTIFICATE-----
|
| 2 |
+
MIIDSzCCAjOgAwIBAgIJV1NCSEFSQk9SMA0GCSqGSIb3DQEBCwUAMDExLzAtBgNV
|
| 3 |
+
B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y2lC8Ey425m4XEROraenAGMqVMfxJsJ5wjqRhlV
|
| 11 |
+
AgMBAAGjgZIwgY8wDAYDVR0TAQH/BAIwADAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0l
|
| 12 |
+
BAwwCgYIKwYBBQUHAwEwGgYDVR0RBBMwEYIJcmVmZXJlbmNlhwR/AAABMB0GA1Ud
|
| 13 |
+
DgQWBBQ0EtbLFU1HI9Wdikc8qRx8TdRT8TAfBgNVHSMEGDAWgBQn+U1eizvlvKbf
|
| 14 |
+
avSxHoXFYQ/UfTANBgkqhkiG9w0BAQsFAAOCAQEATXVQdAfuOvbbsBhNHCvfoYuM
|
| 15 |
+
rgnUOdAHevutvg/gPe6AcshAJMvvfL6J/TpimY+TKDqVBVs0qB6jXjgZURQ9EsFR
|
| 16 |
+
WDJywamDHAFNTTuq1A+78VAS3LK3z54JH2BRlvtjnEDkzDei0/brOentce73YwVR
|
| 17 |
+
XU6+y/yGlSYGdq63wzDxBOUwD/I/src9WpmYqrSwstlD1epemMUIsfDpfSRcGYM2
|
| 18 |
+
tB+zMBccmP/hrB3eJcrjiediwhSBNJjdKysK66GzFRqcyGwwvsz1YPbWcpcQXoVZ
|
| 19 |
+
nnNXEs5TrxTj67/DLuP/233oEoz2XQNh1O2ohq1o5JMu4hbotqkepCwcidNBmQ==
|
| 20 |
+
-----END CERTIFICATE-----
|
tasks/columbia/environment/reference/.websitebench-reference-tls/reference.key
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-----BEGIN PRIVATE KEY-----
|
| 2 |
+
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDNJXc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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Terminate trusted local TLS in front of a Harbor reference process.
|
| 2 |
+
|
| 3 |
+
The reference application's own launch contract remains HTTP on loopback. The
|
| 4 |
+
Agent-facing Docker service is HTTPS only, so Secure ``__Host-`` cookies have
|
| 5 |
+
the same browser semantics as the source site without changing clone code.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import asyncio
|
| 11 |
+
import contextlib
|
| 12 |
+
import os
|
| 13 |
+
import signal
|
| 14 |
+
import ssl
|
| 15 |
+
import subprocess
|
| 16 |
+
import sys
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
BUFFER_SIZE = 64 * 1024
|
| 21 |
+
STARTUP_TIMEOUT_SECONDS = 30.0
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
async def _copy_stream(
|
| 25 |
+
reader: asyncio.StreamReader,
|
| 26 |
+
writer: asyncio.StreamWriter,
|
| 27 |
+
) -> None:
|
| 28 |
+
while block := await reader.read(BUFFER_SIZE):
|
| 29 |
+
writer.write(block)
|
| 30 |
+
await writer.drain()
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
async def _forward(
|
| 34 |
+
client_reader: asyncio.StreamReader,
|
| 35 |
+
client_writer: asyncio.StreamWriter,
|
| 36 |
+
*,
|
| 37 |
+
upstream_port: int,
|
| 38 |
+
) -> None:
|
| 39 |
+
try:
|
| 40 |
+
upstream_reader, upstream_writer = await asyncio.open_connection(
|
| 41 |
+
"127.0.0.1", upstream_port
|
| 42 |
+
)
|
| 43 |
+
except OSError:
|
| 44 |
+
client_writer.close()
|
| 45 |
+
await client_writer.wait_closed()
|
| 46 |
+
return
|
| 47 |
+
|
| 48 |
+
tasks = {
|
| 49 |
+
asyncio.create_task(_copy_stream(client_reader, upstream_writer)),
|
| 50 |
+
asyncio.create_task(_copy_stream(upstream_reader, client_writer)),
|
| 51 |
+
}
|
| 52 |
+
try:
|
| 53 |
+
_done, pending = await asyncio.wait(
|
| 54 |
+
tasks, return_when=asyncio.FIRST_COMPLETED
|
| 55 |
+
)
|
| 56 |
+
for task in pending:
|
| 57 |
+
task.cancel()
|
| 58 |
+
await asyncio.gather(*tasks, return_exceptions=True)
|
| 59 |
+
finally:
|
| 60 |
+
upstream_writer.close()
|
| 61 |
+
client_writer.close()
|
| 62 |
+
with contextlib.suppress(OSError):
|
| 63 |
+
await upstream_writer.wait_closed()
|
| 64 |
+
with contextlib.suppress(OSError):
|
| 65 |
+
await client_writer.wait_closed()
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
async def _wait_for_upstream(process: subprocess.Popen[bytes], port: int) -> None:
|
| 69 |
+
loop = asyncio.get_running_loop()
|
| 70 |
+
deadline = loop.time() + STARTUP_TIMEOUT_SECONDS
|
| 71 |
+
while loop.time() < deadline:
|
| 72 |
+
return_code = process.poll()
|
| 73 |
+
if return_code is not None:
|
| 74 |
+
raise RuntimeError(
|
| 75 |
+
f"reference process exited before readiness with {return_code}"
|
| 76 |
+
)
|
| 77 |
+
try:
|
| 78 |
+
_reader, writer = await asyncio.open_connection("127.0.0.1", port)
|
| 79 |
+
except OSError:
|
| 80 |
+
await asyncio.sleep(0.1)
|
| 81 |
+
continue
|
| 82 |
+
writer.close()
|
| 83 |
+
await writer.wait_closed()
|
| 84 |
+
return
|
| 85 |
+
raise TimeoutError("reference process did not open its loopback port")
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
async def _terminate(process: subprocess.Popen[bytes]) -> None:
|
| 89 |
+
if process.poll() is not None:
|
| 90 |
+
return
|
| 91 |
+
process.terminate()
|
| 92 |
+
try:
|
| 93 |
+
await asyncio.wait_for(asyncio.to_thread(process.wait), timeout=10.0)
|
| 94 |
+
except TimeoutError:
|
| 95 |
+
process.kill()
|
| 96 |
+
await asyncio.to_thread(process.wait)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
async def _serve(command: list[str]) -> int:
|
| 100 |
+
external_port = int(os.environ.get("PORT", "8080"))
|
| 101 |
+
upstream_port = int(
|
| 102 |
+
os.environ.get("WEBSITEBENCH_REFERENCE_UPSTREAM_PORT", "18080")
|
| 103 |
+
)
|
| 104 |
+
if external_port == upstream_port:
|
| 105 |
+
raise ValueError("reference TLS and upstream ports must differ")
|
| 106 |
+
|
| 107 |
+
child_environment = dict(os.environ)
|
| 108 |
+
child_environment["HOST"] = "127.0.0.1"
|
| 109 |
+
child_environment["PORT"] = str(upstream_port)
|
| 110 |
+
process = subprocess.Popen(command, env=child_environment)
|
| 111 |
+
server: asyncio.AbstractServer | None = None
|
| 112 |
+
try:
|
| 113 |
+
await _wait_for_upstream(process, upstream_port)
|
| 114 |
+
tls_root = Path(__file__).resolve().parent
|
| 115 |
+
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
| 116 |
+
context.minimum_version = ssl.TLSVersion.TLSv1_2
|
| 117 |
+
context.load_cert_chain(
|
| 118 |
+
certfile=tls_root / "reference.crt",
|
| 119 |
+
keyfile=tls_root / "reference.key",
|
| 120 |
+
)
|
| 121 |
+
server = await asyncio.start_server(
|
| 122 |
+
lambda reader, writer: _forward(
|
| 123 |
+
reader, writer, upstream_port=upstream_port
|
| 124 |
+
),
|
| 125 |
+
"0.0.0.0",
|
| 126 |
+
external_port,
|
| 127 |
+
ssl=context,
|
| 128 |
+
)
|
| 129 |
+
print(
|
| 130 |
+
"WebsiteBench reference HTTPS ready on "
|
| 131 |
+
f"0.0.0.0:{external_port}; upstream=127.0.0.1:{upstream_port}",
|
| 132 |
+
flush=True,
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
stop = asyncio.Event()
|
| 136 |
+
loop = asyncio.get_running_loop()
|
| 137 |
+
for signum in (signal.SIGINT, signal.SIGTERM):
|
| 138 |
+
loop.add_signal_handler(signum, stop.set)
|
| 139 |
+
process_wait = asyncio.create_task(asyncio.to_thread(process.wait))
|
| 140 |
+
stop_wait = asyncio.create_task(stop.wait())
|
| 141 |
+
done, pending = await asyncio.wait(
|
| 142 |
+
{process_wait, stop_wait}, return_when=asyncio.FIRST_COMPLETED
|
| 143 |
+
)
|
| 144 |
+
for task in pending:
|
| 145 |
+
task.cancel()
|
| 146 |
+
await asyncio.gather(*pending, return_exceptions=True)
|
| 147 |
+
if process_wait in done:
|
| 148 |
+
return process_wait.result()
|
| 149 |
+
return 0
|
| 150 |
+
finally:
|
| 151 |
+
if server is not None:
|
| 152 |
+
server.close()
|
| 153 |
+
await server.wait_closed()
|
| 154 |
+
await _terminate(process)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def main() -> int:
|
| 158 |
+
if len(sys.argv) < 2:
|
| 159 |
+
raise SystemExit("usage: tls_proxy.py COMMAND [ARG ...]")
|
| 160 |
+
return asyncio.run(_serve(sys.argv[1:]))
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
if __name__ == "__main__":
|
| 164 |
+
raise SystemExit(main())
|
tasks/columbia/environment/reference/Dockerfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12.11-slim-bookworm@sha256:519591d6871b7bc437060736b9f7456b8731f1499a57e22e6c285135ae657bf7
|
| 2 |
+
WORKDIR /srv/reference
|
| 3 |
+
# BEGIN WebsiteBench runtime dependencies
|
| 4 |
+
COPY --from=ghcr.io/astral-sh/uv:0.12.8@sha256:d1cbaeadc234fe19c0d93daabcf5e98738cd93c6d1dd4918ef6aa30735feb23a /uv /usr/local/bin/uv
|
| 5 |
+
COPY vendor.requirements.lock vendor.requirements.lock
|
| 6 |
+
RUN uv pip install --python /usr/local/bin/python --no-cache --no-deps --require-hashes --only-binary :all: --link-mode copy --target vendor -r vendor.requirements.lock && rm -f vendor/.lock
|
| 7 |
+
# END WebsiteBench runtime dependencies
|
| 8 |
+
COPY . .
|
| 9 |
+
ENV HOST=0.0.0.0 PORT=8080 DATA_DIR=/tmp/websitebench-columbia-reference-data SEED=0 TZ=UTC
|
| 10 |
+
RUN ./compile.sh
|
| 11 |
+
HEALTHCHECK --interval=2s --timeout=3s --retries=30 CMD python3 -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/healthz', timeout=2)"
|
| 12 |
+
CMD ["./executable"]
|
| 13 |
+
|
| 14 |
+
# Added by the WebsiteBench Harbor materializer. The original app runs only on loopback; the Agent-facing reference is trusted HTTPS.
|
| 15 |
+
COPY .websitebench-reference-tls/ /opt/websitebench/reference-tls/
|
| 16 |
+
RUN chmod 600 /opt/websitebench/reference-tls/reference.key && chmod 755 /opt/websitebench/reference-tls/tls_proxy.py
|
| 17 |
+
ENV WEBSITEBENCH_REFERENCE_UPSTREAM_PORT=18080
|
| 18 |
+
HEALTHCHECK --interval=2s --timeout=3s --retries=30 CMD python3 -c "import os,ssl,urllib.request as r;c=ssl.create_default_context(cafile='/opt/websitebench/reference-tls/ca.crt');u='https://127.0.0.1:'+os.environ.get('PORT','8080')+'/healthz';r.urlopen(u,context=c,timeout=2).close()"
|
| 19 |
+
CMD ["python3", "/opt/websitebench/reference-tls/tls_proxy.py", "./run.sh"]
|
tasks/columbia/environment/reference/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Direct reference adapter
|
| 2 |
+
|
| 3 |
+
The materializer overlays these ABI files on the frozen Columbia Sportswear clone and
|
| 4 |
+
backend. The same assembled bytes form the private oracle implementation; the
|
| 5 |
+
clone and backend are not duplicated in this authoring directory.
|
tasks/columbia/environment/reference/backend/model.json
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": "offline-clone.backend-model.v1",
|
| 3 |
+
"site_id": "columbia",
|
| 4 |
+
"status": "draft",
|
| 5 |
+
"profile": "offline-benchmark",
|
| 6 |
+
"database": {
|
| 7 |
+
"engine": "sqlite",
|
| 8 |
+
"location_policy": "runtime-data-outside-candidate",
|
| 9 |
+
"concurrency_model": "wal-transactional-single-writer",
|
| 10 |
+
"migration_strategy": "versioned-forward-migrations",
|
| 11 |
+
"deterministic_reset": true,
|
| 12 |
+
"restart_persistence": true,
|
| 13 |
+
"site_isolation": "one-database-per-site",
|
| 14 |
+
"proofs": [
|
| 15 |
+
{
|
| 16 |
+
"obligation": "data-location",
|
| 17 |
+
"status": "planned",
|
| 18 |
+
"evidence": []
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"obligation": "schema-migration",
|
| 22 |
+
"status": "planned",
|
| 23 |
+
"evidence": []
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"obligation": "deterministic-reset",
|
| 27 |
+
"status": "planned",
|
| 28 |
+
"evidence": []
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"obligation": "restart-persistence",
|
| 32 |
+
"status": "planned",
|
| 33 |
+
"evidence": []
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"obligation": "backup-restore",
|
| 37 |
+
"status": "planned",
|
| 38 |
+
"evidence": []
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"obligation": "concurrency",
|
| 42 |
+
"status": "planned",
|
| 43 |
+
"evidence": []
|
| 44 |
+
}
|
| 45 |
+
]
|
| 46 |
+
},
|
| 47 |
+
"auth_semantics": {
|
| 48 |
+
"account_database_scope": "site-isolated",
|
| 49 |
+
"credential_storage": "salted-scrypt-hash",
|
| 50 |
+
"session_storage": "opaque-cookie-digest-at-rest",
|
| 51 |
+
"registration_account_creation": "after-email-verification",
|
| 52 |
+
"verification_challenge_storage": "salted-hash",
|
| 53 |
+
"password_reset_enumeration": "indistinguishable-public-response",
|
| 54 |
+
"mail_default": "LOCAL_ONLY",
|
| 55 |
+
"mail_statuses": [
|
| 56 |
+
"LOCAL_ONLY",
|
| 57 |
+
"SMTP_PENDING",
|
| 58 |
+
"SMTP_SENT",
|
| 59 |
+
"SMTP_FAILED"
|
| 60 |
+
],
|
| 61 |
+
"smtp_activation": "explicit-complete-config-only",
|
| 62 |
+
"smtp_delivery_ceiling": 3,
|
| 63 |
+
"rejected_secret_journaling": "forbidden",
|
| 64 |
+
"legacy_write_policy": "read-compatible-write-rejected"
|
| 65 |
+
},
|
| 66 |
+
"common_capabilities": {
|
| 67 |
+
"account_registration": "account-registration",
|
| 68 |
+
"account_sign_in": "account-sign-in",
|
| 69 |
+
"session_lifecycle": "session-lifecycle",
|
| 70 |
+
"password_recovery": "password-recovery",
|
| 71 |
+
"email_delivery": "email-delivery"
|
| 72 |
+
},
|
| 73 |
+
"capabilities": [
|
| 74 |
+
{
|
| 75 |
+
"id": "account-registration",
|
| 76 |
+
"label": "Verified local account registration",
|
| 77 |
+
"priority": "p0",
|
| 78 |
+
"category": "authentication",
|
| 79 |
+
"implementation_status": "planned",
|
| 80 |
+
"entities": [
|
| 81 |
+
{
|
| 82 |
+
"name": "pending-registration",
|
| 83 |
+
"identity": "opaque pending id bound to one browser session",
|
| 84 |
+
"owner_scope": "session",
|
| 85 |
+
"persistence": "durable"
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"name": "local-account",
|
| 89 |
+
"identity": "site-local account id and unique normalized email",
|
| 90 |
+
"owner_scope": "account",
|
| 91 |
+
"persistence": "durable"
|
| 92 |
+
}
|
| 93 |
+
],
|
| 94 |
+
"state_machine": {
|
| 95 |
+
"kind": "challenge-lifecycle",
|
| 96 |
+
"states": [
|
| 97 |
+
"collecting",
|
| 98 |
+
"pending-verification",
|
| 99 |
+
"verified",
|
| 100 |
+
"account-created",
|
| 101 |
+
"expired",
|
| 102 |
+
"locked"
|
| 103 |
+
],
|
| 104 |
+
"transitions": [
|
| 105 |
+
{
|
| 106 |
+
"from": "collecting",
|
| 107 |
+
"to": "pending-verification",
|
| 108 |
+
"trigger": "validated registration request"
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"from": "pending-verification",
|
| 112 |
+
"to": "verified",
|
| 113 |
+
"trigger": "correct unexpired code within attempt budget"
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"from": "verified",
|
| 117 |
+
"to": "account-created",
|
| 118 |
+
"trigger": "transactional account creation and session rotation"
|
| 119 |
+
},
|
| 120 |
+
{
|
| 121 |
+
"from": "pending-verification",
|
| 122 |
+
"to": "expired",
|
| 123 |
+
"trigger": "challenge expiry"
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"from": "pending-verification",
|
| 127 |
+
"to": "locked",
|
| 128 |
+
"trigger": "verification attempt budget exhausted"
|
| 129 |
+
}
|
| 130 |
+
]
|
| 131 |
+
},
|
| 132 |
+
"server_authorities": [
|
| 133 |
+
"The server normalizes identity and hashes password and code.",
|
| 134 |
+
"An account is created only after successful verification.",
|
| 135 |
+
"Duplicate normalized email creation is rejected transactionally."
|
| 136 |
+
],
|
| 137 |
+
"external_effect": "none",
|
| 138 |
+
"journey_ids": [],
|
| 139 |
+
"invariant_ids": [],
|
| 140 |
+
"proofs": {
|
| 141 |
+
"evidence": {},
|
| 142 |
+
"planned": [
|
| 143 |
+
"valid",
|
| 144 |
+
"invalid",
|
| 145 |
+
"duplicate",
|
| 146 |
+
"stale",
|
| 147 |
+
"foreign-owner",
|
| 148 |
+
"unauthorized-role",
|
| 149 |
+
"restart",
|
| 150 |
+
"migration",
|
| 151 |
+
"concurrency"
|
| 152 |
+
],
|
| 153 |
+
"not_applicable": []
|
| 154 |
+
}
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"id": "account-sign-in",
|
| 158 |
+
"label": "Password-based local account sign-in",
|
| 159 |
+
"priority": "p0",
|
| 160 |
+
"category": "authentication",
|
| 161 |
+
"implementation_status": "planned",
|
| 162 |
+
"entities": [
|
| 163 |
+
{
|
| 164 |
+
"name": "local-account",
|
| 165 |
+
"identity": "site-local account id and normalized email",
|
| 166 |
+
"owner_scope": "account",
|
| 167 |
+
"persistence": "durable"
|
| 168 |
+
}
|
| 169 |
+
],
|
| 170 |
+
"state_machine": {
|
| 171 |
+
"kind": "entity-lifecycle",
|
| 172 |
+
"states": [
|
| 173 |
+
"signed-out",
|
| 174 |
+
"identified",
|
| 175 |
+
"authenticated",
|
| 176 |
+
"rejected"
|
| 177 |
+
],
|
| 178 |
+
"transitions": [
|
| 179 |
+
{
|
| 180 |
+
"from": "signed-out",
|
| 181 |
+
"to": "identified",
|
| 182 |
+
"trigger": "normalized email submitted"
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"from": "identified",
|
| 186 |
+
"to": "authenticated",
|
| 187 |
+
"trigger": "constant-time password verification succeeds"
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"from": "identified",
|
| 191 |
+
"to": "rejected",
|
| 192 |
+
"trigger": "credentials are invalid"
|
| 193 |
+
}
|
| 194 |
+
]
|
| 195 |
+
},
|
| 196 |
+
"server_authorities": [
|
| 197 |
+
"The server verifies salted password hashes.",
|
| 198 |
+
"The server rotates the authenticated session.",
|
| 199 |
+
"Client-selected fixture identity is not authentication."
|
| 200 |
+
],
|
| 201 |
+
"external_effect": "none",
|
| 202 |
+
"journey_ids": [],
|
| 203 |
+
"invariant_ids": [],
|
| 204 |
+
"proofs": {
|
| 205 |
+
"evidence": {},
|
| 206 |
+
"planned": [
|
| 207 |
+
"valid",
|
| 208 |
+
"invalid",
|
| 209 |
+
"duplicate",
|
| 210 |
+
"stale",
|
| 211 |
+
"foreign-owner",
|
| 212 |
+
"unauthorized-role",
|
| 213 |
+
"restart",
|
| 214 |
+
"migration",
|
| 215 |
+
"concurrency"
|
| 216 |
+
],
|
| 217 |
+
"not_applicable": []
|
| 218 |
+
}
|
| 219 |
+
},
|
| 220 |
+
{
|
| 221 |
+
"id": "session-lifecycle",
|
| 222 |
+
"label": "Anonymous and authenticated browser sessions",
|
| 223 |
+
"priority": "p0",
|
| 224 |
+
"category": "authentication",
|
| 225 |
+
"implementation_status": "planned",
|
| 226 |
+
"entities": [
|
| 227 |
+
{
|
| 228 |
+
"name": "browser-session",
|
| 229 |
+
"identity": "opaque cookie token with digest persisted at rest",
|
| 230 |
+
"owner_scope": "session",
|
| 231 |
+
"persistence": "durable"
|
| 232 |
+
}
|
| 233 |
+
],
|
| 234 |
+
"state_machine": {
|
| 235 |
+
"kind": "session-lifecycle",
|
| 236 |
+
"states": [
|
| 237 |
+
"anonymous",
|
| 238 |
+
"authenticated",
|
| 239 |
+
"revoked",
|
| 240 |
+
"expired"
|
| 241 |
+
],
|
| 242 |
+
"transitions": [
|
| 243 |
+
{
|
| 244 |
+
"from": "anonymous",
|
| 245 |
+
"to": "authenticated",
|
| 246 |
+
"trigger": "successful sign-in or registration rotates session"
|
| 247 |
+
},
|
| 248 |
+
{
|
| 249 |
+
"from": "authenticated",
|
| 250 |
+
"to": "revoked",
|
| 251 |
+
"trigger": "sign-out or security reset"
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"from": "anonymous",
|
| 255 |
+
"to": "expired",
|
| 256 |
+
"trigger": "session expiry"
|
| 257 |
+
},
|
| 258 |
+
{
|
| 259 |
+
"from": "authenticated",
|
| 260 |
+
"to": "expired",
|
| 261 |
+
"trigger": "session expiry"
|
| 262 |
+
}
|
| 263 |
+
]
|
| 264 |
+
},
|
| 265 |
+
"server_authorities": [
|
| 266 |
+
"Raw session tokens are never stored in the database.",
|
| 267 |
+
"Ownership is resolved from the server-side session record.",
|
| 268 |
+
"Sign-out revokes server-side authority before deleting the cookie."
|
| 269 |
+
],
|
| 270 |
+
"external_effect": "none",
|
| 271 |
+
"journey_ids": [],
|
| 272 |
+
"invariant_ids": [],
|
| 273 |
+
"proofs": {
|
| 274 |
+
"evidence": {},
|
| 275 |
+
"planned": [
|
| 276 |
+
"valid",
|
| 277 |
+
"invalid",
|
| 278 |
+
"duplicate",
|
| 279 |
+
"stale",
|
| 280 |
+
"foreign-owner",
|
| 281 |
+
"unauthorized-role",
|
| 282 |
+
"restart",
|
| 283 |
+
"migration",
|
| 284 |
+
"concurrency"
|
| 285 |
+
],
|
| 286 |
+
"not_applicable": []
|
| 287 |
+
}
|
| 288 |
+
},
|
| 289 |
+
{
|
| 290 |
+
"id": "password-recovery",
|
| 291 |
+
"label": "Enumeration-resistant local password recovery",
|
| 292 |
+
"priority": "p0",
|
| 293 |
+
"category": "authentication",
|
| 294 |
+
"implementation_status": "planned",
|
| 295 |
+
"entities": [
|
| 296 |
+
{
|
| 297 |
+
"name": "password-reset-challenge",
|
| 298 |
+
"identity": "opaque reset id bound to one browser session",
|
| 299 |
+
"owner_scope": "session",
|
| 300 |
+
"persistence": "durable"
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"name": "local-account",
|
| 304 |
+
"identity": "nullable concealed account binding",
|
| 305 |
+
"owner_scope": "account",
|
| 306 |
+
"persistence": "durable"
|
| 307 |
+
}
|
| 308 |
+
],
|
| 309 |
+
"state_machine": {
|
| 310 |
+
"kind": "challenge-lifecycle",
|
| 311 |
+
"states": [
|
| 312 |
+
"requested",
|
| 313 |
+
"verified",
|
| 314 |
+
"consumed",
|
| 315 |
+
"expired",
|
| 316 |
+
"locked"
|
| 317 |
+
],
|
| 318 |
+
"transitions": [
|
| 319 |
+
{
|
| 320 |
+
"from": "requested",
|
| 321 |
+
"to": "verified",
|
| 322 |
+
"trigger": "correct unexpired code within attempt budget"
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"from": "verified",
|
| 326 |
+
"to": "consumed",
|
| 327 |
+
"trigger": "password is replaced and sessions are revoked"
|
| 328 |
+
},
|
| 329 |
+
{
|
| 330 |
+
"from": "requested",
|
| 331 |
+
"to": "expired",
|
| 332 |
+
"trigger": "challenge expiry"
|
| 333 |
+
},
|
| 334 |
+
{
|
| 335 |
+
"from": "requested",
|
| 336 |
+
"to": "locked",
|
| 337 |
+
"trigger": "verification attempt budget exhausted"
|
| 338 |
+
}
|
| 339 |
+
]
|
| 340 |
+
},
|
| 341 |
+
"server_authorities": [
|
| 342 |
+
"Known and unknown emails receive indistinguishable public responses.",
|
| 343 |
+
"Only the server binds a reset flow to an account.",
|
| 344 |
+
"Password replacement revokes prior authenticated sessions."
|
| 345 |
+
],
|
| 346 |
+
"external_effect": "local-only",
|
| 347 |
+
"journey_ids": [],
|
| 348 |
+
"invariant_ids": [],
|
| 349 |
+
"proofs": {
|
| 350 |
+
"evidence": {},
|
| 351 |
+
"planned": [
|
| 352 |
+
"valid",
|
| 353 |
+
"invalid",
|
| 354 |
+
"duplicate",
|
| 355 |
+
"stale",
|
| 356 |
+
"foreign-owner",
|
| 357 |
+
"unauthorized-role",
|
| 358 |
+
"restart",
|
| 359 |
+
"migration",
|
| 360 |
+
"concurrency"
|
| 361 |
+
],
|
| 362 |
+
"not_applicable": []
|
| 363 |
+
}
|
| 364 |
+
},
|
| 365 |
+
{
|
| 366 |
+
"id": "email-delivery",
|
| 367 |
+
"label": "Truthful local verification and recovery mail outbox",
|
| 368 |
+
"priority": "p0",
|
| 369 |
+
"category": "communication",
|
| 370 |
+
"implementation_status": "planned",
|
| 371 |
+
"entities": [
|
| 372 |
+
{
|
| 373 |
+
"name": "mail-outbox-entry",
|
| 374 |
+
"identity": "site-local outbox id and purpose-bound flow id",
|
| 375 |
+
"owner_scope": "system",
|
| 376 |
+
"persistence": "durable"
|
| 377 |
+
}
|
| 378 |
+
],
|
| 379 |
+
"state_machine": {
|
| 380 |
+
"kind": "delivery-lifecycle",
|
| 381 |
+
"states": [
|
| 382 |
+
"local-only",
|
| 383 |
+
"smtp-pending",
|
| 384 |
+
"smtp-sent",
|
| 385 |
+
"smtp-failed"
|
| 386 |
+
],
|
| 387 |
+
"transitions": [
|
| 388 |
+
{
|
| 389 |
+
"from": "local-only",
|
| 390 |
+
"to": "smtp-pending",
|
| 391 |
+
"trigger": "operator enables complete explicit SMTP configuration"
|
| 392 |
+
},
|
| 393 |
+
{
|
| 394 |
+
"from": "smtp-pending",
|
| 395 |
+
"to": "smtp-sent",
|
| 396 |
+
"trigger": "SMTP transport confirms delivery handoff"
|
| 397 |
+
},
|
| 398 |
+
{
|
| 399 |
+
"from": "smtp-pending",
|
| 400 |
+
"to": "smtp-failed",
|
| 401 |
+
"trigger": "delivery attempt fails or ceiling is reached"
|
| 402 |
+
},
|
| 403 |
+
{
|
| 404 |
+
"from": "smtp-failed",
|
| 405 |
+
"to": "smtp-pending",
|
| 406 |
+
"trigger": "bounded idempotent retry below the delivery ceiling"
|
| 407 |
+
}
|
| 408 |
+
]
|
| 409 |
+
},
|
| 410 |
+
"server_authorities": [
|
| 411 |
+
"Offline mode records LOCAL_ONLY and never claims external delivery.",
|
| 412 |
+
"SMTP is disabled unless every required setting is present.",
|
| 413 |
+
"Claim, retry, and startup replay share one delivery ceiling."
|
| 414 |
+
],
|
| 415 |
+
"external_effect": "local-only",
|
| 416 |
+
"journey_ids": [],
|
| 417 |
+
"invariant_ids": [],
|
| 418 |
+
"proofs": {
|
| 419 |
+
"evidence": {},
|
| 420 |
+
"planned": [
|
| 421 |
+
"valid",
|
| 422 |
+
"invalid",
|
| 423 |
+
"duplicate",
|
| 424 |
+
"stale",
|
| 425 |
+
"foreign-owner",
|
| 426 |
+
"unauthorized-role",
|
| 427 |
+
"restart",
|
| 428 |
+
"migration",
|
| 429 |
+
"concurrency"
|
| 430 |
+
],
|
| 431 |
+
"not_applicable": []
|
| 432 |
+
}
|
| 433 |
+
}
|
| 434 |
+
]
|
| 435 |
+
}
|
tasks/columbia/environment/reference/backend/runtime.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"database": {
|
| 3 |
+
"data_dir": "data",
|
| 4 |
+
"engine": "sqlite",
|
| 5 |
+
"filename": "columbia.sqlite3",
|
| 6 |
+
"legacy_unbound_migration": false,
|
| 7 |
+
"migration_hook": null,
|
| 8 |
+
"seed_hook": null,
|
| 9 |
+
"volume_identity": "websitebench-columbia-data"
|
| 10 |
+
},
|
| 11 |
+
"deployment": {
|
| 12 |
+
"profiles": {
|
| 13 |
+
"cloudflare-review": {
|
| 14 |
+
"mail_adapter": "redis-resend",
|
| 15 |
+
"payment_adapter": "local-sandbox",
|
| 16 |
+
"persistence": "ephemeral-reset"
|
| 17 |
+
},
|
| 18 |
+
"docker-volume": {
|
| 19 |
+
"mail_adapter": "effects-gateway",
|
| 20 |
+
"payment_adapter": "local-sandbox",
|
| 21 |
+
"persistence": "persistent-volume"
|
| 22 |
+
},
|
| 23 |
+
"offline-harbor": {
|
| 24 |
+
"mail_adapter": "local-outbox",
|
| 25 |
+
"payment_adapter": "local-sandbox",
|
| 26 |
+
"persistence": "persistent"
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"mail": {
|
| 31 |
+
"enabled": false,
|
| 32 |
+
"purposes": {},
|
| 33 |
+
"sender": {
|
| 34 |
+
"address_env": "RESEND_FROM_EMAIL",
|
| 35 |
+
"display_name": "Columbia Sportswear"
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
"payments": {
|
| 39 |
+
"currency": "USD",
|
| 40 |
+
"default_adapter": "local-sandbox",
|
| 41 |
+
"enabled": false,
|
| 42 |
+
"local_sandbox": {
|
| 43 |
+
"scenarios": [
|
| 44 |
+
{
|
| 45 |
+
"display_label": "Simulated approval",
|
| 46 |
+
"id": "sandbox-approved",
|
| 47 |
+
"outcome": "approved"
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"display_label": "Simulated decline",
|
| 51 |
+
"id": "sandbox-declined",
|
| 52 |
+
"outcome": "declined"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"display_label": "Simulated retry",
|
| 56 |
+
"id": "sandbox-retry",
|
| 57 |
+
"outcome": "retryable"
|
| 58 |
+
}
|
| 59 |
+
]
|
| 60 |
+
},
|
| 61 |
+
"stripe_test": null
|
| 62 |
+
},
|
| 63 |
+
"schema_version": "websitebench.site-backend-runtime.v1",
|
| 64 |
+
"session": {
|
| 65 |
+
"host_only": true,
|
| 66 |
+
"http_only": true,
|
| 67 |
+
"same_site": "Lax",
|
| 68 |
+
"secure": true
|
| 69 |
+
},
|
| 70 |
+
"site": {
|
| 71 |
+
"id": "columbia",
|
| 72 |
+
"label": "Columbia Sportswear",
|
| 73 |
+
"public_origin": "https://columbia.offline.invalid"
|
| 74 |
+
}
|
| 75 |
+
}
|
tasks/columbia/environment/reference/clone/app.py
ADDED
|
@@ -0,0 +1,707 @@
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Columbia Sportswear offline clone.
|
| 2 |
+
|
| 3 |
+
Serves the source-observed route families over the locally captured catalog and
|
| 4 |
+
a deterministic SQLite-backed cart. No request ever leaves this process.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import sys
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
SITE_DIR = Path(__file__).resolve().parent / "site"
|
| 13 |
+
if str(SITE_DIR) not in sys.path:
|
| 14 |
+
sys.path.insert(0, str(SITE_DIR))
|
| 15 |
+
|
| 16 |
+
from fastapi import FastAPI, Form, Request # noqa: E402
|
| 17 |
+
from fastapi.responses import HTMLResponse, RedirectResponse # noqa: E402
|
| 18 |
+
from fastapi.staticfiles import StaticFiles # noqa: E402
|
| 19 |
+
from fastapi.templating import Jinja2Templates # noqa: E402
|
| 20 |
+
|
| 21 |
+
import grid # noqa: E402
|
| 22 |
+
import json # noqa: E402
|
| 23 |
+
import render # noqa: E402
|
| 24 |
+
from catalog import SORT_OPTIONS, get_catalog # noqa: E402
|
| 25 |
+
from session import CartService, session_id_for # noqa: E402
|
| 26 |
+
|
| 27 |
+
SITE_ID = "columbia"
|
| 28 |
+
DISPLAY_NAME = "Columbia Sportswear"
|
| 29 |
+
ROOT = Path(__file__).resolve().parent
|
| 30 |
+
|
| 31 |
+
app = FastAPI(title=DISPLAY_NAME)
|
| 32 |
+
app.mount("/static", StaticFiles(directory=ROOT / "static"), name="static")
|
| 33 |
+
templates = Jinja2Templates(directory=str(ROOT / "templates"))
|
| 34 |
+
templates.env.globals["min"] = min
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class _LazyCatalog:
|
| 38 |
+
"""Build the captured catalog on first use rather than at import.
|
| 39 |
+
|
| 40 |
+
The index is a pure function of ``data/*.json`` and every read path reaches
|
| 41 |
+
it through attribute access, so deferring construction changes no response.
|
| 42 |
+
It keeps the ~0.3 s parse out of the runtime's start-to-health window, which
|
| 43 |
+
a lifecycle restart pays inside a fixed harness budget.
|
| 44 |
+
"""
|
| 45 |
+
|
| 46 |
+
__slots__ = ("_catalog",)
|
| 47 |
+
|
| 48 |
+
def __init__(self) -> None:
|
| 49 |
+
self._catalog = None
|
| 50 |
+
|
| 51 |
+
def _resolve(self):
|
| 52 |
+
if self._catalog is None:
|
| 53 |
+
self._catalog = get_catalog()
|
| 54 |
+
return self._catalog
|
| 55 |
+
|
| 56 |
+
def __getattr__(self, name: str):
|
| 57 |
+
return getattr(self._resolve(), name)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
catalog = _LazyCatalog()
|
| 61 |
+
carts = CartService(catalog)
|
| 62 |
+
|
| 63 |
+
# Source-observed category carousel on the Women grid, with the CMS artwork the
|
| 64 |
+
# source itself serves for each tile.
|
| 65 |
+
_VISNAV_PATH = ROOT / "data" / "plp-visnav.json"
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def _visnav_tiles(rows):
|
| 69 |
+
tiles = []
|
| 70 |
+
for row in rows:
|
| 71 |
+
asset = ROOT / "static" / "assets" / "cms" / f"{row['asset']}.webp"
|
| 72 |
+
tiles.append(
|
| 73 |
+
{
|
| 74 |
+
"label": row["label"],
|
| 75 |
+
"url": row["href"],
|
| 76 |
+
"image": f"/static/assets/cms/{row['asset']}.webp" if asset.exists() else None,
|
| 77 |
+
}
|
| 78 |
+
)
|
| 79 |
+
return tiles
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
VISNAV = (
|
| 83 |
+
{
|
| 84 |
+
category_id: _visnav_tiles(rows)
|
| 85 |
+
for category_id, rows in json.loads(_VISNAV_PATH.read_text()).items()
|
| 86 |
+
}
|
| 87 |
+
if _VISNAV_PATH.exists()
|
| 88 |
+
else {}
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
# One of the source's rotating Amplience campaign strings, captured from the
|
| 93 |
+
# promotional bar above the header.
|
| 94 |
+
PROMO_BAR = "Want Extra Savings On Sale Styles?"
|
| 95 |
+
|
| 96 |
+
# Stylesheet fingerprint so an edited sheet is never served from a stale cache.
|
| 97 |
+
ASSET_VERSION = str(
|
| 98 |
+
max(
|
| 99 |
+
int(path.stat().st_mtime)
|
| 100 |
+
for path in (ROOT / "static" / "css").glob("*.css")
|
| 101 |
+
)
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def _shell(request: Request) -> dict[str, object]:
|
| 106 |
+
session_id = session_id_for(request)
|
| 107 |
+
return {
|
| 108 |
+
"request": request,
|
| 109 |
+
"cart_count": carts.item_count(session_id),
|
| 110 |
+
"session_id": session_id,
|
| 111 |
+
"promo_bar": PROMO_BAR,
|
| 112 |
+
"asset_version": ASSET_VERSION,
|
| 113 |
+
# The source pins the header differently by page family: category and
|
| 114 |
+
# search grids use a sticky header under a 56px promotional bar, while
|
| 115 |
+
# the home page and PDP use a fixed header offset 72px from the top.
|
| 116 |
+
"header_mode": "fixed",
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def _with_cookie(response, request: Request, session_id: str):
|
| 121 |
+
if request.cookies.get(CartService.COOKIE) != session_id:
|
| 122 |
+
response.set_cookie(
|
| 123 |
+
CartService.COOKIE, session_id, httponly=True, samesite="lax", path="/"
|
| 124 |
+
)
|
| 125 |
+
return response
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
@app.get("/healthz")
|
| 129 |
+
def healthz() -> dict[str, object]:
|
| 130 |
+
return {"ok": True, "site_id": SITE_ID, "products": len(catalog.products)}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
@app.get("/", response_class=HTMLResponse)
|
| 134 |
+
def home(request: Request):
|
| 135 |
+
context = _shell(request)
|
| 136 |
+
featured = catalog.products_in("newArrivals") or catalog.products_in("women")
|
| 137 |
+
context.update(
|
| 138 |
+
page_title="Outerwear, Sportswear & Footwear | Columbia Sportswear",
|
| 139 |
+
heading="New & Trending",
|
| 140 |
+
tiles=_tiles(featured[:12]),
|
| 141 |
+
promo_tiles=_home_tiles(),
|
| 142 |
+
hero=HERO,
|
| 143 |
+
banner_before=BANNERS[0],
|
| 144 |
+
banner_after=BANNERS[1],
|
| 145 |
+
cards=[dict(card, image=_cms(card["asset"])) for card in CARDS],
|
| 146 |
+
)
|
| 147 |
+
response = templates.TemplateResponse(request, "home.html", context)
|
| 148 |
+
return _with_cookie(response, request, context["session_id"])
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _tiles(products, enable_compare: bool = False, promo_label: str | None = None):
|
| 152 |
+
rows = []
|
| 153 |
+
for position, product in enumerate(products, start=1):
|
| 154 |
+
variant = product.variants[0] if product.variants else None
|
| 155 |
+
primary, hover = render.tile_images(product, variant)
|
| 156 |
+
rows.append(
|
| 157 |
+
{
|
| 158 |
+
"product": product,
|
| 159 |
+
"variant": variant,
|
| 160 |
+
"primary": primary,
|
| 161 |
+
"hover": hover,
|
| 162 |
+
"price": render.price_block(product),
|
| 163 |
+
"position": position,
|
| 164 |
+
"enable_compare": enable_compare,
|
| 165 |
+
"promo_label": promo_label if product.is_sale else None,
|
| 166 |
+
}
|
| 167 |
+
)
|
| 168 |
+
return rows
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def _cms(asset: str, ext: str = "webp") -> str | None:
|
| 172 |
+
path = ROOT / "static" / "assets" / "cms" / f"{asset}.{ext}"
|
| 173 |
+
return f"/static/assets/cms/{asset}.{ext}" if path.exists() else None
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
# Source-observed homepage content. Copy is transcribed from the captured page;
|
| 177 |
+
# artwork is the CMS asset the source itself serves for each slot.
|
| 178 |
+
HERO = {
|
| 179 |
+
"image": _cms("Q3_2026_WeHeart_Toolkit_Hero"),
|
| 180 |
+
"lockup": _cms("SummerSale_Icon_Final_v2", "svg"),
|
| 181 |
+
"heading": "MEMBERS NOW GET EXTRA 30%",
|
| 182 |
+
"subheading": (
|
| 183 |
+
"We can\u2019t make summer longer, but can give you extra savings on gear "
|
| 184 |
+
"up to 50% off. Terms apply."
|
| 185 |
+
),
|
| 186 |
+
"cta": "Shop Sale",
|
| 187 |
+
"url": "/c/sale/",
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
BANNERS = [
|
| 191 |
+
{
|
| 192 |
+
"image": _cms("9-08_COL_US_S26_HP_Back_to_School_MomentsBan_Youth_V6"),
|
| 193 |
+
"heading": "BACK TO SCHOOL",
|
| 194 |
+
"body": "Get ready for next semester with new styles that pass the vibe check.",
|
| 195 |
+
"cta": "Shop Now",
|
| 196 |
+
"url": "/c/back-to-school/",
|
| 197 |
+
},
|
| 198 |
+
{
|
| 199 |
+
"image": _cms("8-10_ROC_MomensBan_DG"),
|
| 200 |
+
"heading": "THE ROC\u2122 PANT",
|
| 201 |
+
"body": (
|
| 202 |
+
"Elevate your everyday comfort with our versatile and rugged "
|
| 203 |
+
"bestselling ROC\u2122 pants."
|
| 204 |
+
),
|
| 205 |
+
"cta": "Shop Men",
|
| 206 |
+
"url": "/c/roc/",
|
| 207 |
+
},
|
| 208 |
+
]
|
| 209 |
+
|
| 210 |
+
CARDS = [
|
| 211 |
+
{"asset": "8-10_2686468_COL_US_HP_AmazeSweats_Subhero", "heading": "Sweat Sets",
|
| 212 |
+
"body": "Soft, comfortable, effortless. Everything you could want in a sweat set.",
|
| 213 |
+
"url": "/c/sweatsets/"},
|
| 214 |
+
{"asset": "8-27_COL_US_HP_We_Heart_LukeCombs_Subhero",
|
| 215 |
+
"heading": "Luke Combs Stage Edition Bahama\u2122 Shirt",
|
| 216 |
+
"body": "Get a custom version of our iconic PFG shirt.",
|
| 217 |
+
"url": "/p/mens-pfg-bahama-ii-luke-combs-short-sleeve-shirt-2194741.html"},
|
| 218 |
+
{"asset": "8-10_2686468_COL_US_HP_FallNA_DG_Subhero", "heading": "New Arrivals",
|
| 219 |
+
"body": "More drops all season.", "url": "/c/new-arrivals/"},
|
| 220 |
+
{"asset": "7-30_COL_CA_S26_HP_Run_Subhero", "heading": "All Gas, Great Brakes",
|
| 221 |
+
"body": "Go further faster with the Konos Speed Trail ATR\u2019s trail-ready "
|
| 222 |
+
"cushioning and traction.",
|
| 223 |
+
"url": "/c/trailrunning/"},
|
| 224 |
+
{"asset": "6-30_COL_US_S26_HP_SummerTech_M_Subhero", "heading": "Cool & UV Protected",
|
| 225 |
+
"body": "Get gear with built-in cooling and sun protection built to beat the heat.",
|
| 226 |
+
"url": "/c/sun-protection/"},
|
| 227 |
+
{"asset": "8-27_COL_US_HP_We_Heart_AmazePuff_Style_Subhero_v2",
|
| 228 |
+
"heading": "Amaze Puff\u2122 Is Back", "body": "The bestseller, now in new colors.",
|
| 229 |
+
"url": "/c/amaze-collection/"},
|
| 230 |
+
]
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
# Source-observed promotional cell injected into the category grid after the
|
| 234 |
+
# third product tile.
|
| 235 |
+
GRID_PROMO = {
|
| 236 |
+
"image": _cms("Q3_WeHeart_CA_Toolkit_Main_Gridbanner_LO"),
|
| 237 |
+
"heading": "MEMBERS GET EXTRA 30%",
|
| 238 |
+
"body": "On our Annual Summer Sale.",
|
| 239 |
+
"cta": "Shop Now",
|
| 240 |
+
"url": "/c/sale/",
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
def _home_tiles():
|
| 245 |
+
# Source-observed homepage visual-nav tiles.
|
| 246 |
+
return [
|
| 247 |
+
{"label": "Men", "url": "/c/mens/"},
|
| 248 |
+
{"label": "Women", "url": "/c/womens/"},
|
| 249 |
+
{"label": "Kids", "url": "/c/kids/"},
|
| 250 |
+
{"label": "Shoes", "url": "/c/footwear/"},
|
| 251 |
+
{"label": "Accessories", "url": "/c/accessories/"},
|
| 252 |
+
{"label": "Bags & Gear", "url": "/c/equipment/"},
|
| 253 |
+
{"label": "Sale", "url": "/c/sale/"},
|
| 254 |
+
]
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def _breadcrumb(category):
|
| 258 |
+
trail = []
|
| 259 |
+
current = category
|
| 260 |
+
seen = set()
|
| 261 |
+
while current is not None and current.id not in seen:
|
| 262 |
+
seen.add(current.id)
|
| 263 |
+
trail.append(current)
|
| 264 |
+
parent_id = current.parent
|
| 265 |
+
current = catalog.categories.get(parent_id) if parent_id else None
|
| 266 |
+
if current is not None and current.id == "root":
|
| 267 |
+
break
|
| 268 |
+
trail.reverse()
|
| 269 |
+
crumbs = [{"name": "Home", "url": "/"}]
|
| 270 |
+
for node in trail:
|
| 271 |
+
if node.id == "root" or not node.name:
|
| 272 |
+
continue
|
| 273 |
+
is_last = node is trail[-1]
|
| 274 |
+
crumbs.append({"name": node.name, "url": None if is_last else node.url})
|
| 275 |
+
return crumbs
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def _siblings(category):
|
| 279 |
+
"""The source shows a category's own children when it has any, and falls
|
| 280 |
+
back to its siblings on a leaf grid (observed on /c/womens/ vs
|
| 281 |
+
/c/fleece-jackets/)."""
|
| 282 |
+
own = _menu_children(category)
|
| 283 |
+
if own:
|
| 284 |
+
return own
|
| 285 |
+
parent = catalog.categories.get(category.parent) if category.parent else None
|
| 286 |
+
if parent is None:
|
| 287 |
+
return []
|
| 288 |
+
out = []
|
| 289 |
+
for child_id in parent.children:
|
| 290 |
+
child = catalog.categories.get(child_id)
|
| 291 |
+
if not child or not child.show_in_menu or not child.url:
|
| 292 |
+
continue
|
| 293 |
+
out.append({"name": child.name, "url": child.url, "current": child.id == category.id})
|
| 294 |
+
return out if len(out) > 1 else []
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def _menu_children(category):
|
| 298 |
+
out = []
|
| 299 |
+
for child_id in category.children:
|
| 300 |
+
child = catalog.categories.get(child_id)
|
| 301 |
+
if not child or not child.show_in_menu or not child.url:
|
| 302 |
+
continue
|
| 303 |
+
# `alturl_*` entries are navigation aliases of a sibling that is already
|
| 304 |
+
# in this row, so the source's pill row does not repeat them.
|
| 305 |
+
if child.id.startswith("alturl_"):
|
| 306 |
+
continue
|
| 307 |
+
out.append({"name": child.name, "url": child.url, "current": False})
|
| 308 |
+
return out
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
@app.get("/c/{slug:path}", response_class=HTMLResponse)
|
| 312 |
+
def category_page(slug: str, request: Request):
|
| 313 |
+
url = f"/c/{slug}"
|
| 314 |
+
if not url.endswith("/"):
|
| 315 |
+
url += "/"
|
| 316 |
+
category = catalog.category_by_url(url)
|
| 317 |
+
if category is None:
|
| 318 |
+
return _not_found(request)
|
| 319 |
+
|
| 320 |
+
params = request.query_params
|
| 321 |
+
selected = grid.parse_refine(params.getlist("refine"))
|
| 322 |
+
sort_id = params.get("sort", "featured-new")
|
| 323 |
+
try:
|
| 324 |
+
page_size = max(int(params.get("pagesize", grid.PAGE_SIZE)), 1)
|
| 325 |
+
except ValueError:
|
| 326 |
+
page_size = grid.PAGE_SIZE
|
| 327 |
+
|
| 328 |
+
result = grid.build(catalog.products_in(category.id), selected, sort_id, page_size)
|
| 329 |
+
context = _shell(request)
|
| 330 |
+
heading = _category_heading(category)
|
| 331 |
+
context.update(
|
| 332 |
+
page_title=category.page_title or f"{category.name} | Columbia Sportswear",
|
| 333 |
+
meta_description=category.description,
|
| 334 |
+
heading=heading,
|
| 335 |
+
breadcrumb=_breadcrumb(category),
|
| 336 |
+
# The source omits the breadcrumb on a top-level grid such as
|
| 337 |
+
# /c/womens/ and shows it on a leaf grid such as /c/fleece-jackets/.
|
| 338 |
+
show_breadcrumb=category.depth > 1,
|
| 339 |
+
siblings=_siblings(category),
|
| 340 |
+
visnav=VISNAV.get(category.id),
|
| 341 |
+
result=result,
|
| 342 |
+
tiles=_tiles(result.products, category.enable_compare, "Extra 30% Off Applied"),
|
| 343 |
+
sort_options=SORT_OPTIONS,
|
| 344 |
+
header_mode="sticky",
|
| 345 |
+
grid_promo=GRID_PROMO,
|
| 346 |
+
base_path=url,
|
| 347 |
+
selected_any=any(selected.values()),
|
| 348 |
+
q=None,
|
| 349 |
+
more_url=_page_url(url, params, result.next_page_size),
|
| 350 |
+
all_url=_page_url(url, params, result.total),
|
| 351 |
+
)
|
| 352 |
+
response = templates.TemplateResponse(request, "grid.html", context)
|
| 353 |
+
return _with_cookie(response, request, context["session_id"])
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
# Headings observed directly on the source category pages. Everywhere else the
|
| 357 |
+
# source derives the h1 from its SEO page title minus the brand suffix, which
|
| 358 |
+
# matched every page checked (for example /c/fleece-jackets/ -> "Fleece Jackets").
|
| 359 |
+
OBSERVED_HEADINGS = {"women": "Shop All Women\u2019s"}
|
| 360 |
+
BRAND_SUFFIX = " | Columbia Sportswear"
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
def _category_heading(category) -> str:
|
| 364 |
+
observed = OBSERVED_HEADINGS.get(category.id)
|
| 365 |
+
if observed:
|
| 366 |
+
return observed
|
| 367 |
+
title = category.page_title or ""
|
| 368 |
+
if title.endswith(BRAND_SUFFIX):
|
| 369 |
+
return title[: -len(BRAND_SUFFIX)]
|
| 370 |
+
return category.name or ""
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
def _page_url(base: str, params, page_size: int) -> str:
|
| 374 |
+
pairs = [(key, value) for key, value in params.multi_items() if key != "pagesize"]
|
| 375 |
+
pairs.append(("pagesize", str(page_size)))
|
| 376 |
+
from urllib.parse import urlencode
|
| 377 |
+
|
| 378 |
+
return f"{base}?{urlencode(pairs)}"
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
@app.get("/search/", response_class=HTMLResponse)
|
| 382 |
+
@app.get("/search", response_class=HTMLResponse)
|
| 383 |
+
def search_page(request: Request):
|
| 384 |
+
params = request.query_params
|
| 385 |
+
query = (params.get("q") or "").strip()
|
| 386 |
+
matches = catalog.search(query) if query else []
|
| 387 |
+
|
| 388 |
+
# The source redirects a query that names a category straight to that grid.
|
| 389 |
+
if query:
|
| 390 |
+
target = _category_for_query(query)
|
| 391 |
+
if target is not None:
|
| 392 |
+
return RedirectResponse(target.url, status_code=302)
|
| 393 |
+
|
| 394 |
+
selected = grid.parse_refine(params.getlist("refine"))
|
| 395 |
+
sort_id = params.get("sort", "featured-new")
|
| 396 |
+
try:
|
| 397 |
+
page_size = max(int(params.get("pagesize", grid.PAGE_SIZE)), 1)
|
| 398 |
+
except ValueError:
|
| 399 |
+
page_size = grid.PAGE_SIZE
|
| 400 |
+
|
| 401 |
+
result = grid.build(matches, selected, sort_id, page_size)
|
| 402 |
+
context = _shell(request)
|
| 403 |
+
context.update(
|
| 404 |
+
page_title=f"{query} | Columbia Sportswear" if query else "Search | Columbia Sportswear",
|
| 405 |
+
heading=query,
|
| 406 |
+
breadcrumb=None,
|
| 407 |
+
show_breadcrumb=False,
|
| 408 |
+
siblings=None,
|
| 409 |
+
visnav=None,
|
| 410 |
+
result=result,
|
| 411 |
+
tiles=_tiles(result.products, False, "Extra 30% Off Applied"),
|
| 412 |
+
sort_options=SORT_OPTIONS,
|
| 413 |
+
header_mode="sticky",
|
| 414 |
+
grid_promo=GRID_PROMO,
|
| 415 |
+
base_path="/search/",
|
| 416 |
+
selected_any=any(selected.values()),
|
| 417 |
+
q=query,
|
| 418 |
+
more_url=_page_url("/search/", params, result.next_page_size),
|
| 419 |
+
all_url=_page_url("/search/", params, result.total),
|
| 420 |
+
)
|
| 421 |
+
response = templates.TemplateResponse(request, "grid.html", context)
|
| 422 |
+
return _with_cookie(response, request, context["session_id"])
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
def _category_for_query(query: str):
|
| 426 |
+
from catalog import _normalize
|
| 427 |
+
|
| 428 |
+
wanted = _normalize(query)
|
| 429 |
+
for category in catalog.categories.values():
|
| 430 |
+
if not category.url or not catalog.category_products.get(category.id):
|
| 431 |
+
continue
|
| 432 |
+
names = {category.name or "", _category_heading(category)}
|
| 433 |
+
if any(_normalize(name) == wanted for name in names if name):
|
| 434 |
+
return category
|
| 435 |
+
return None
|
| 436 |
+
|
| 437 |
+
|
| 438 |
+
@app.get("/p/{slug}", response_class=HTMLResponse)
|
| 439 |
+
def product_page(slug: str, request: Request):
|
| 440 |
+
url = f"/p/{slug}"
|
| 441 |
+
product = catalog.by_url.get(url)
|
| 442 |
+
if product is None:
|
| 443 |
+
# The source resolves a PDP by its trailing product id and treats the
|
| 444 |
+
# slug as cosmetic, so recover the product that way before 404ing.
|
| 445 |
+
import re
|
| 446 |
+
|
| 447 |
+
match = re.search(r"-(\d+)\.html$", url)
|
| 448 |
+
product = catalog.products.get(match.group(1)) if match else None
|
| 449 |
+
if product is None:
|
| 450 |
+
return _not_found(request)
|
| 451 |
+
return RedirectResponse(product.url, status_code=302)
|
| 452 |
+
|
| 453 |
+
params = request.query_params
|
| 454 |
+
color_code = params.get("color")
|
| 455 |
+
variant = product.variant_for_color(color_code)
|
| 456 |
+
if variant is not None and color_code != (variant.color_code or ""):
|
| 457 |
+
target = f"{product.url}?color={variant.color_code}"
|
| 458 |
+
if params.get("size"):
|
| 459 |
+
target += f"&size={params['size']}"
|
| 460 |
+
return RedirectResponse(target, status_code=302)
|
| 461 |
+
|
| 462 |
+
selected_size = params.get("size")
|
| 463 |
+
if variant and selected_size and selected_size not in variant.sizes:
|
| 464 |
+
selected_size = None
|
| 465 |
+
|
| 466 |
+
gallery = [render.slide(media) for media in (variant.images if variant else [])]
|
| 467 |
+
gallery = [item for item in gallery if item]
|
| 468 |
+
swatches = {
|
| 469 |
+
option.color_code: render.media_url(option.primary_image)
|
| 470 |
+
for option in product.variants
|
| 471 |
+
}
|
| 472 |
+
# The source lists the selected colour first, then the remaining variants.
|
| 473 |
+
ordered_variants = (
|
| 474 |
+
[variant] + [v for v in product.variants if v is not variant]
|
| 475 |
+
if variant is not None
|
| 476 |
+
else list(product.variants)
|
| 477 |
+
)
|
| 478 |
+
price = render.price_block(product)
|
| 479 |
+
unit = product.sale_price if product.sale_price is not None else product.min_price
|
| 480 |
+
|
| 481 |
+
context = _shell(request)
|
| 482 |
+
context.update(
|
| 483 |
+
page_title=f"{product.name} | Columbia",
|
| 484 |
+
meta_description=product.pitch,
|
| 485 |
+
product=product,
|
| 486 |
+
variant=variant,
|
| 487 |
+
selected_size=selected_size,
|
| 488 |
+
gallery=gallery,
|
| 489 |
+
poster=next((item["src"] for item in gallery if item["kind"] == "image"), None),
|
| 490 |
+
swatches=swatches,
|
| 491 |
+
ordered_variants=ordered_variants,
|
| 492 |
+
price=price,
|
| 493 |
+
points=int(unit * 10) if unit else None,
|
| 494 |
+
collection=_collection_for(product),
|
| 495 |
+
breadcrumb=_pdp_breadcrumb(product),
|
| 496 |
+
parent_category=_pdp_parent(product),
|
| 497 |
+
)
|
| 498 |
+
response = templates.TemplateResponse(request, "pdp.html", context)
|
| 499 |
+
return _with_cookie(response, request, context["session_id"])
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
def _collection_for(product):
|
| 503 |
+
for path in product.category_path:
|
| 504 |
+
leaf = path.split(">")[-1]
|
| 505 |
+
category = catalog.categories.get(leaf)
|
| 506 |
+
if category and category.name and "Collection" in category.name:
|
| 507 |
+
return category.name
|
| 508 |
+
return None
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
def _pdp_parent(product):
|
| 512 |
+
"""The source's PDP card links back to the product's leaf category."""
|
| 513 |
+
crumbs = _pdp_breadcrumb(product) or []
|
| 514 |
+
for crumb in reversed(crumbs):
|
| 515 |
+
if crumb.get("url") and crumb["url"] != "/":
|
| 516 |
+
return crumb
|
| 517 |
+
return None
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
def _pdp_breadcrumb(product):
|
| 521 |
+
best = None
|
| 522 |
+
for path in product.category_path:
|
| 523 |
+
parts = path.split(">")
|
| 524 |
+
if len(parts) < 2:
|
| 525 |
+
continue
|
| 526 |
+
leaf = catalog.categories.get(parts[-1])
|
| 527 |
+
if leaf and leaf.show_in_menu and leaf.name:
|
| 528 |
+
if best is None or len(parts) > best[0]:
|
| 529 |
+
best = (len(parts), parts)
|
| 530 |
+
if best is None:
|
| 531 |
+
return None
|
| 532 |
+
crumbs = [{"name": "Home", "url": "/"}]
|
| 533 |
+
for part in best[1]:
|
| 534 |
+
category = catalog.categories.get(part)
|
| 535 |
+
if category and category.name and category.url:
|
| 536 |
+
crumbs.append({"name": category.name, "url": category.url})
|
| 537 |
+
crumbs.append({"name": product.name, "url": None})
|
| 538 |
+
return crumbs
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
@app.get("/cart", response_class=HTMLResponse)
|
| 542 |
+
def cart_page(request: Request, promo_error: str | None = None):
|
| 543 |
+
context = _shell(request)
|
| 544 |
+
view = carts.view(context["session_id"])
|
| 545 |
+
context.update(view, promo_error=promo_error)
|
| 546 |
+
response = templates.TemplateResponse(request, "cart.html", context)
|
| 547 |
+
return _with_cookie(response, request, context["session_id"])
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
@app.post("/cart/add")
|
| 551 |
+
def cart_add(
|
| 552 |
+
request: Request,
|
| 553 |
+
product_id: str = Form(...),
|
| 554 |
+
variant_id: str = Form(None),
|
| 555 |
+
color_code: str = Form(None),
|
| 556 |
+
size: str = Form(None),
|
| 557 |
+
quantity: int = Form(1),
|
| 558 |
+
):
|
| 559 |
+
session_id = session_id_for(request)
|
| 560 |
+
product = catalog.products.get(product_id)
|
| 561 |
+
if product is None:
|
| 562 |
+
return _redirect("/cart", request, session_id)
|
| 563 |
+
if not size:
|
| 564 |
+
target = f"{product.url}?color={color_code}&error=size" if color_code else product.url
|
| 565 |
+
return _redirect(target, request, session_id)
|
| 566 |
+
carts.add(session_id, product_id, variant_id, color_code, size, max(quantity, 1))
|
| 567 |
+
return _redirect("/cart", request, session_id)
|
| 568 |
+
|
| 569 |
+
|
| 570 |
+
@app.post("/cart/update")
|
| 571 |
+
def cart_update(request: Request, line_id: int = Form(...), quantity: int = Form(...)):
|
| 572 |
+
session_id = session_id_for(request)
|
| 573 |
+
carts.set_quantity(session_id, line_id, quantity)
|
| 574 |
+
return _redirect("/cart", request, session_id)
|
| 575 |
+
|
| 576 |
+
|
| 577 |
+
@app.post("/cart/remove")
|
| 578 |
+
def cart_remove(request: Request, line_id: int = Form(...)):
|
| 579 |
+
session_id = session_id_for(request)
|
| 580 |
+
carts.remove(session_id, line_id)
|
| 581 |
+
return _redirect("/cart", request, session_id)
|
| 582 |
+
|
| 583 |
+
|
| 584 |
+
@app.post("/cart/save")
|
| 585 |
+
def cart_save(request: Request, line_id: int = Form(...)):
|
| 586 |
+
session_id = session_id_for(request)
|
| 587 |
+
carts.set_saved(session_id, line_id, True)
|
| 588 |
+
return _redirect("/cart", request, session_id)
|
| 589 |
+
|
| 590 |
+
|
| 591 |
+
@app.post("/cart/move")
|
| 592 |
+
def cart_move(request: Request, line_id: int = Form(...)):
|
| 593 |
+
session_id = session_id_for(request)
|
| 594 |
+
carts.set_saved(session_id, line_id, False)
|
| 595 |
+
return _redirect("/cart", request, session_id)
|
| 596 |
+
|
| 597 |
+
|
| 598 |
+
@app.post("/cart/promo")
|
| 599 |
+
def cart_promo(request: Request, code: str = Form("")):
|
| 600 |
+
session_id = session_id_for(request)
|
| 601 |
+
applied = carts.apply_promo(session_id, code)
|
| 602 |
+
target = "/cart" if applied else "/cart?promo_error=That+promo+code+is+not+valid."
|
| 603 |
+
return _redirect(target, request, session_id)
|
| 604 |
+
|
| 605 |
+
|
| 606 |
+
@app.post("/cart/promo/clear")
|
| 607 |
+
def cart_promo_clear(request: Request):
|
| 608 |
+
session_id = session_id_for(request)
|
| 609 |
+
carts.clear_promo(session_id)
|
| 610 |
+
return _redirect("/cart", request, session_id)
|
| 611 |
+
|
| 612 |
+
|
| 613 |
+
def _redirect(target: str, request: Request, session_id: str):
|
| 614 |
+
response = RedirectResponse(target, status_code=303)
|
| 615 |
+
return _with_cookie(response, request, session_id)
|
| 616 |
+
|
| 617 |
+
|
| 618 |
+
def _not_found(request: Request):
|
| 619 |
+
context = _shell(request)
|
| 620 |
+
context.update(page_title="Page Not Found | Columbia Sportswear", heading="Page Not Found", body=None)
|
| 621 |
+
response = templates.TemplateResponse(request, "content.html", context, status_code=404)
|
| 622 |
+
return _with_cookie(response, request, context["session_id"])
|
| 623 |
+
|
| 624 |
+
|
| 625 |
+
# Content routes observed in the source header, footer and mega-menu. Copy for
|
| 626 |
+
# these pages was not captured, so they render structurally and are reported as
|
| 627 |
+
# `inferred` rather than presented as source-observed.
|
| 628 |
+
CONTENT_ROUTES = {
|
| 629 |
+
"/t/accessibility/": "Accessibility Statement",
|
| 630 |
+
"/t/product-care/": "Product Care",
|
| 631 |
+
"/t/tech/": "Product Technology",
|
| 632 |
+
"/t/responsibility/": "Corporate Responsibility",
|
| 633 |
+
"/t/drops/": "Special-Edition Collections",
|
| 634 |
+
"/t/ambassadors/": "Elite Athletes & Ambassadors",
|
| 635 |
+
"/t/business-partner/": "Wholesale",
|
| 636 |
+
"/t/giftcards/": "Gift Cards",
|
| 637 |
+
"/t/coupons/": "Special Deals",
|
| 638 |
+
"/t/discount-programs/": "ID.me Verification",
|
| 639 |
+
"/t/size-fit/": "Size Guides",
|
| 640 |
+
"/t/legal/terms-of-use/": "Terms of Use",
|
| 641 |
+
"/t/legal/terms-of-sale/": "Terms of Sale",
|
| 642 |
+
"/t/legal/privacy-policy/": "Privacy Policy",
|
| 643 |
+
"/t/legal/cgr-terms/": "Rewards Terms and Conditions",
|
| 644 |
+
"/t/legal/ugc-terms/": "User Generated Content Terms of Use",
|
| 645 |
+
"/t/legal/do-not-sell-my-information/": "Do Not Sell or Share My Information",
|
| 646 |
+
"/our-story/": "Our Story",
|
| 647 |
+
"/careers/": "Careers",
|
| 648 |
+
"/warranty/": "Warranty",
|
| 649 |
+
"/order-returns/": "Returns",
|
| 650 |
+
"/stores/": "Find a Store",
|
| 651 |
+
"/rewardsprogram/": "Columbia Greater Rewards",
|
| 652 |
+
"/outdoor-guide.html": "Tough Mother Outdoor Guide",
|
| 653 |
+
"/pro": "Pro Program",
|
| 654 |
+
"/pfg/": "PFG Fishing",
|
| 655 |
+
"/featured/": "Explore",
|
| 656 |
+
"/on/demandware.store/Sites-Columbia_US-Site/en_US/Login-Show": "Log In or Join For Free",
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
|
| 660 |
+
@app.get("/t/{path:path}", response_class=HTMLResponse)
|
| 661 |
+
def content_route(path: str, request: Request):
|
| 662 |
+
return _content(f"/t/{path}" if path.endswith("/") else f"/t/{path}/", request)
|
| 663 |
+
|
| 664 |
+
|
| 665 |
+
for _route in list(CONTENT_ROUTES):
|
| 666 |
+
if _route.startswith("/t/"):
|
| 667 |
+
continue
|
| 668 |
+
|
| 669 |
+
def _make(route: str):
|
| 670 |
+
def handler(request: Request):
|
| 671 |
+
return _content(route, request)
|
| 672 |
+
|
| 673 |
+
return handler
|
| 674 |
+
|
| 675 |
+
app.add_api_route(_route, _make(_route), methods=["GET"], response_class=HTMLResponse)
|
| 676 |
+
|
| 677 |
+
|
| 678 |
+
def _content(route: str, request: Request):
|
| 679 |
+
heading = CONTENT_ROUTES.get(route)
|
| 680 |
+
if heading is None:
|
| 681 |
+
return _not_found(request)
|
| 682 |
+
context = _shell(request)
|
| 683 |
+
context.update(
|
| 684 |
+
page_title=f"{heading} | Columbia Sportswear", heading=heading, body=None
|
| 685 |
+
)
|
| 686 |
+
response = templates.TemplateResponse(request, "content.html", context)
|
| 687 |
+
return _with_cookie(response, request, context["session_id"])
|
| 688 |
+
|
| 689 |
+
|
| 690 |
+
@app.get("/account", response_class=HTMLResponse)
|
| 691 |
+
@app.get("/account/orders", response_class=HTMLResponse)
|
| 692 |
+
def account(request: Request):
|
| 693 |
+
"""Account surfaces were blocked by the source's bot protection during
|
| 694 |
+
capture, so they are structural-only and reported as `inferred`."""
|
| 695 |
+
context = _shell(request)
|
| 696 |
+
context.update(
|
| 697 |
+
page_title="My Account | Columbia Sportswear", heading="My Account", body=None
|
| 698 |
+
)
|
| 699 |
+
response = templates.TemplateResponse(request, "content.html", context)
|
| 700 |
+
return _with_cookie(response, request, context["session_id"])
|
| 701 |
+
|
| 702 |
+
|
| 703 |
+
@app.post("/checkout")
|
| 704 |
+
def checkout(request: Request):
|
| 705 |
+
"""Checkout terminates in the local sandbox; no payment path exists here."""
|
| 706 |
+
session_id = session_id_for(request)
|
| 707 |
+
return _redirect("/cart", request, session_id)
|
tasks/columbia/environment/reference/clone/backend/site_backend_integration.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generated, site-bound backend integration seam."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import importlib
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
import sqlite3
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
from typing import Any, Callable
|
| 11 |
+
|
| 12 |
+
from websitebench.local_clone_auth import LocalAuthStore
|
| 13 |
+
from websitebench.site_backend import (
|
| 14 |
+
SiteBackend,
|
| 15 |
+
load_runtime,
|
| 16 |
+
serve_jsonl,
|
| 17 |
+
validate_allowlist,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
DEFAULT_RUNTIME_PATH = (
|
| 22 |
+
Path(__file__).resolve().parents[2] / "backend" / "runtime.json"
|
| 23 |
+
)
|
| 24 |
+
BRIDGE_DESCRIPTOR_PATH = (
|
| 25 |
+
Path(__file__).resolve().parents[2] / "backend" / "node-bridge.json"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _declared_hook(
|
| 30 |
+
declaration: str | None,
|
| 31 |
+
) -> Callable[[sqlite3.Connection], None] | None:
|
| 32 |
+
if declaration is None:
|
| 33 |
+
return None
|
| 34 |
+
module_name, function_name = declaration.split(":", 1)
|
| 35 |
+
module = importlib.import_module(module_name)
|
| 36 |
+
hook: Any = getattr(module, function_name, None)
|
| 37 |
+
if not callable(hook):
|
| 38 |
+
raise RuntimeError(f"declared backend hook is not callable: {declaration}")
|
| 39 |
+
actual = f"{hook.__module__}:{hook.__name__}"
|
| 40 |
+
if actual != declaration:
|
| 41 |
+
raise RuntimeError(
|
| 42 |
+
f"declared backend hook resolved as {actual!r}, expected {declaration!r}"
|
| 43 |
+
)
|
| 44 |
+
return hook
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def open_site_services() -> tuple[SiteBackend, LocalAuthStore]:
|
| 48 |
+
"""Open one bound database; never omit the site id for permanent auth."""
|
| 49 |
+
|
| 50 |
+
runtime_path = Path(
|
| 51 |
+
os.environ.get(
|
| 52 |
+
"WEBSITEBENCH_SITE_BACKEND_RUNTIME",
|
| 53 |
+
str(DEFAULT_RUNTIME_PATH),
|
| 54 |
+
)
|
| 55 |
+
).resolve()
|
| 56 |
+
runtime = load_runtime(runtime_path)
|
| 57 |
+
migration_hook = _declared_hook(runtime.migration_hook)
|
| 58 |
+
seed_hook = _declared_hook(runtime.seed_hook)
|
| 59 |
+
deployed_database = os.environ.get(
|
| 60 |
+
"WEBSITEBENCH_SITE_BACKEND_DATABASE",
|
| 61 |
+
)
|
| 62 |
+
if deployed_database is None:
|
| 63 |
+
backend = SiteBackend.open(
|
| 64 |
+
runtime_path,
|
| 65 |
+
migration_hook=migration_hook,
|
| 66 |
+
seed_hook=seed_hook,
|
| 67 |
+
)
|
| 68 |
+
else:
|
| 69 |
+
database_path = Path(deployed_database).resolve()
|
| 70 |
+
if database_path.name != runtime.database_filename:
|
| 71 |
+
raise RuntimeError(
|
| 72 |
+
"deployed database filename does not match runtime contract"
|
| 73 |
+
)
|
| 74 |
+
backend = SiteBackend.open(
|
| 75 |
+
json.loads(runtime_path.read_text(encoding="utf-8")),
|
| 76 |
+
data_root=database_path.parent,
|
| 77 |
+
migration_hook=migration_hook,
|
| 78 |
+
seed_hook=seed_hook,
|
| 79 |
+
)
|
| 80 |
+
if backend.lifecycle.database_path != database_path:
|
| 81 |
+
raise RuntimeError(
|
| 82 |
+
"deployed database path does not match backend preflight"
|
| 83 |
+
)
|
| 84 |
+
backend.lifecycle.initialize()
|
| 85 |
+
auth = LocalAuthStore(
|
| 86 |
+
backend.lifecycle.database_path,
|
| 87 |
+
site_id=backend.config.site_id,
|
| 88 |
+
)
|
| 89 |
+
auth.ensure_schema()
|
| 90 |
+
return backend, auth
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def run_stdio_bridge() -> None:
|
| 94 |
+
"""Run only operations frozen in this site's descriptor."""
|
| 95 |
+
|
| 96 |
+
backend, auth = open_site_services()
|
| 97 |
+
descriptor = json.loads(BRIDGE_DESCRIPTOR_PATH.read_text(encoding="utf-8"))
|
| 98 |
+
allowed = validate_allowlist(
|
| 99 |
+
descriptor,
|
| 100 |
+
expected_site_id=backend.config.site_id,
|
| 101 |
+
)
|
| 102 |
+
serve_jsonl(backend, auth, allowed, sys.stdin, sys.stdout)
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
if __name__ == "__main__":
|
| 106 |
+
import argparse
|
| 107 |
+
import sys
|
| 108 |
+
|
| 109 |
+
parser = argparse.ArgumentParser(prog="websitebench-node-backend-bridge")
|
| 110 |
+
parser.add_argument("--stdio", action="store_true", required=True)
|
| 111 |
+
parser.parse_args()
|
| 112 |
+
run_stdio_bridge()
|
tasks/columbia/environment/reference/clone/data/categories.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tasks/columbia/environment/reference/clone/data/design-tokens.json
ADDED
|
@@ -0,0 +1,586 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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| 7 |
+
"--chakra-ring-shadow": "0 0 #0000",
|
| 8 |
+
"--chakra-space-x-reverse": "0",
|
| 9 |
+
"--chakra-space-y-reverse": "0",
|
| 10 |
+
"--chakra-colors-transparent": "transparent",
|
| 11 |
+
"--chakra-colors-current": "currentColor",
|
| 12 |
+
"--chakra-colors-black": "#000000",
|
| 13 |
+
"--chakra-colors-white": "#FFFFFF",
|
| 14 |
+
"--chakra-colors-whiteAlpha-50": "rgba(255, 255, 255, 0.04)",
|
| 15 |
+
"--chakra-colors-whiteAlpha-100": "rgba(255, 255, 255, 0.06)",
|
| 16 |
+
"--chakra-colors-whiteAlpha-200": "rgba(255, 255, 255, 0.08)",
|
| 17 |
+
"--chakra-colors-whiteAlpha-300": "rgba(255, 255, 255, 0.16)",
|
| 18 |
+
"--chakra-colors-whiteAlpha-400": "rgba(255, 255, 255, 0.24)",
|
| 19 |
+
"--chakra-colors-whiteAlpha-500": "rgba(255, 255, 255, 0.36)",
|
| 20 |
+
"--chakra-colors-whiteAlpha-600": "rgba(255, 255, 255, 0.48)",
|
| 21 |
+
"--chakra-colors-whiteAlpha-700": "rgba(255, 255, 255, 0.64)",
|
| 22 |
+
"--chakra-colors-whiteAlpha-800": "rgba(255, 255, 255, 0.80)",
|
| 23 |
+
"--chakra-colors-whiteAlpha-900": "rgba(255, 255, 255, 0.92)",
|
| 24 |
+
"--chakra-colors-blackAlpha-50": "rgba(0, 0, 0, 0.04)",
|
| 25 |
+
"--chakra-colors-blackAlpha-100": "rgba(0, 0, 0, 0.06)",
|
| 26 |
+
"--chakra-colors-blackAlpha-200": "rgba(0, 0, 0, 0.08)",
|
| 27 |
+
"--chakra-colors-blackAlpha-300": "rgba(0, 0, 0, 0.16)",
|
| 28 |
+
"--chakra-colors-blackAlpha-400": "rgba(0, 0, 0, 0.24)",
|
| 29 |
+
"--chakra-colors-blackAlpha-500": "rgba(0, 0, 0, 0.36)",
|
| 30 |
+
"--chakra-colors-blackAlpha-600": "rgba(0, 0, 0, 0.48)",
|
| 31 |
+
"--chakra-colors-blackAlpha-700": "rgba(0, 0, 0, 0.64)",
|
| 32 |
+
"--chakra-colors-blackAlpha-800": "rgba(0, 0, 0, 0.80)",
|
| 33 |
+
"--chakra-colors-blackAlpha-900": "rgba(0, 0, 0, 0.92)",
|
| 34 |
+
"--chakra-colors-gray-50": "#F7F7F7",
|
| 35 |
+
"--chakra-colors-gray-100": "#E8E9E9",
|
| 36 |
+
"--chakra-colors-gray-200": "#D3D4D4",
|
| 37 |
+
"--chakra-colors-gray-300": "#BCBDBD",
|
| 38 |
+
"--chakra-colors-gray-400": "#A5A6A6",
|
| 39 |
+
"--chakra-colors-gray-500": "#919292",
|
| 40 |
+
"--chakra-colors-gray-600": "#7A7B7B",
|
| 41 |
+
"--chakra-colors-gray-700": "#636464",
|
| 42 |
+
"--chakra-colors-gray-800": "#4E4F4F",
|
| 43 |
+
"--chakra-colors-gray-900": "#262626",
|
| 44 |
+
"--chakra-colors-gray-950": "#141515",
|
| 45 |
+
"--chakra-colors-gray-100-opaque": "#E8E9E9B4",
|
| 46 |
+
"--chakra-colors-gray-900-opaque": "#262626B4",
|
| 47 |
+
"--chakra-colors-red-50": "#FEF2F2",
|
| 48 |
+
"--chakra-colors-red-100": "#FEE2E2",
|
| 49 |
+
"--chakra-colors-red-200": "#FECACA",
|
| 50 |
+
"--chakra-colors-red-300": "#FCA5A5",
|
| 51 |
+
"--chakra-colors-red-400": "#F87171",
|
| 52 |
+
"--chakra-colors-red-500": "#EF4444",
|
| 53 |
+
"--chakra-colors-red-600": "#D42B2B",
|
| 54 |
+
"--chakra-colors-red-700": "#991919",
|
| 55 |
+
"--chakra-colors-red-800": "#6D1616",
|
| 56 |
+
"--chakra-colors-red-900": "#300C0C",
|
| 57 |
+
"--chakra-colors-red-950": "#1F0808",
|
| 58 |
+
"--chakra-colors-orange-50": "#FFF7ED",
|
| 59 |
+
"--chakra-colors-orange-100": "#FFEDD5",
|
| 60 |
+
"--chakra-colors-orange-200": "#FED7AA",
|
| 61 |
+
"--chakra-colors-orange-300": "#FDBA74",
|
| 62 |
+
"--chakra-colors-orange-400": "#FB923C",
|
| 63 |
+
"--chakra-colors-orange-500": "#F97316",
|
| 64 |
+
"--chakra-colors-orange-600": "#C74904",
|
| 65 |
+
"--chakra-colors-orange-700": "#92310A",
|
| 66 |
+
"--chakra-colors-orange-800": "#6C2710",
|
| 67 |
+
"--chakra-colors-orange-900": "#3B1106",
|
| 68 |
+
"--chakra-colors-orange-950": "#220A04",
|
| 69 |
+
"--chakra-colors-yellow-50": "#FEFCE8",
|
| 70 |
+
"--chakra-colors-yellow-100": "#FEF9C3",
|
| 71 |
+
"--chakra-colors-yellow-200": "#FEF08A",
|
| 72 |
+
"--chakra-colors-yellow-300": "#FDE047",
|
| 73 |
+
"--chakra-colors-yellow-400": "#FACC15",
|
| 74 |
+
"--chakra-colors-yellow-500": "#EAB308",
|
| 75 |
+
"--chakra-colors-yellow-600": "#CA8A04",
|
| 76 |
+
"--chakra-colors-yellow-700": "#845209",
|
| 77 |
+
"--chakra-colors-yellow-800": "#713F12",
|
| 78 |
+
"--chakra-colors-yellow-900": "#422006",
|
| 79 |
+
"--chakra-colors-yellow-950": "#281304",
|
| 80 |
+
"--chakra-colors-green-50": "#F0FDF4",
|
| 81 |
+
"--chakra-colors-green-100": "#DCFCE7",
|
| 82 |
+
"--chakra-colors-green-200": "#BBF7D0",
|
| 83 |
+
"--chakra-colors-green-300": "#97EFAC",
|
| 84 |
+
"--chakra-colors-green-400": "#4ADE80",
|
| 85 |
+
"--chakra-colors-green-500": "#22C55E",
|
| 86 |
+
"--chakra-colors-green-600": "#008631",
|
| 87 |
+
"--chakra-colors-green-700": "#0E6B31",
|
| 88 |
+
"--chakra-colors-green-800": "#124A28",
|
| 89 |
+
"--chakra-colors-green-900": "#042713",
|
| 90 |
+
"--chakra-colors-green-950": "#03190C",
|
| 91 |
+
"--chakra-colors-teal-50": "#F0FDFA",
|
| 92 |
+
"--chakra-colors-teal-100": "#CCFBF1",
|
| 93 |
+
"--chakra-colors-teal-200": "#99F6E4",
|
| 94 |
+
"--chakra-colors-teal-300": "#5EEAD4",
|
| 95 |
+
"--chakra-colors-teal-400": "#2DD4BF",
|
| 96 |
+
"--chakra-colors-teal-500": "#14B8A6",
|
| 97 |
+
"--chakra-colors-teal-600": "#0D9488",
|
| 98 |
+
"--chakra-colors-teal-700": "#0C5D56",
|
| 99 |
+
"--chakra-colors-teal-800": "#114240",
|
| 100 |
+
"--chakra-colors-teal-900": "#032726",
|
| 101 |
+
"--chakra-colors-teal-950": "#021716",
|
| 102 |
+
"--chakra-colors-blue-25": "#F6FBFF",
|
| 103 |
+
"--chakra-colors-blue-50": "#E5F7FF",
|
| 104 |
+
"--chakra-colors-blue-100": "#CBEDFF",
|
| 105 |
+
"--chakra-colors-blue-200": "#A1E0FF",
|
| 106 |
+
"--chakra-colors-blue-300": "#41BFFF",
|
| 107 |
+
"--chakra-colors-blue-400": "#00A2F3",
|
| 108 |
+
"--chakra-colors-blue-500": "#007AB8",
|
| 109 |
+
"--chakra-colors-blue-600": "#006699",
|
| 110 |
+
"--chakra-colors-blue-700": "#00527A",
|
| 111 |
+
"--chakra-colors-blue-800": "#003A57",
|
| 112 |
+
"--chakra-colors-blue-900": "#002538",
|
| 113 |
+
"--chakra-colors-blue-950": "#001B29",
|
| 114 |
+
"--chakra-colors-cyan-50": "#ECFEFF",
|
| 115 |
+
"--chakra-colors-cyan-100": "#CFFAFE",
|
| 116 |
+
"--chakra-colors-cyan-200": "#A5F3FC",
|
| 117 |
+
"--chakra-colors-cyan-300": "#67E8F9",
|
| 118 |
+
"--chakra-colors-cyan-400": "#22D3EE",
|
| 119 |
+
"--chakra-colors-cyan-500": "#06B6D4",
|
| 120 |
+
"--chakra-colors-cyan-600": "#0891B2",
|
| 121 |
+
"--chakra-colors-cyan-700": "#0C5C72",
|
| 122 |
+
"--chakra-colors-cyan-800": "#134152",
|
| 123 |
+
"--chakra-colors-cyan-900": "#072A38",
|
| 124 |
+
"--chakra-colors-cyan-950": "#051B24",
|
| 125 |
+
"--chakra-colors-purple-50": "#FAF5FF",
|
| 126 |
+
"--chakra-colors-purple-100": "#F3E8FF",
|
| 127 |
+
"--chakra-colors-purple-200": "#E9D5FF",
|
| 128 |
+
"--chakra-colors-purple-300": "#D8B4FE",
|
| 129 |
+
"--chakra-colors-purple-400": "#C084FC",
|
| 130 |
+
"--chakra-colors-purple-500": "#A855F7",
|
| 131 |
+
"--chakra-colors-purple-600": "#9333EA",
|
| 132 |
+
"--chakra-colors-purple-700": "#641BA3",
|
| 133 |
+
"--chakra-colors-purple-800": "#4A1772",
|
| 134 |
+
"--chakra-colors-purple-900": "#2F0553",
|
| 135 |
+
"--chakra-colors-purple-950": "#1A032E",
|
| 136 |
+
"--chakra-colors-pink-50": "#FFEEF2",
|
| 137 |
+
"--chakra-colors-pink-100": "#FBDEE6",
|
| 138 |
+
"--chakra-colors-pink-200": "#FFC0D0",
|
| 139 |
+
"--chakra-colors-pink-300": "#E37D98",
|
| 140 |
+
"--chakra-colors-pink-400": "#D84F74",
|
| 141 |
+
"--chakra-colors-pink-500": "#C92C56",
|
| 142 |
+
"--chakra-colors-pink-600": "#9B2242",
|
| 143 |
+
"--chakra-colors-pink-700": "#751A32",
|
| 144 |
+
"--chakra-colors-pink-800": "#4F1122",
|
| 145 |
+
"--chakra-colors-pink-900": "#260810",
|
| 146 |
+
"--chakra-colors-pink-950": "#150509",
|
| 147 |
+
"--chakra-colors-primary-inverted": "var(--chakra-colors-white)",
|
| 148 |
+
"--chakra-colors-primary": "var(--chakra-colors-black)",
|
| 149 |
+
"--chakra-colors-brand": "var(--chakra-colors-blue-500)",
|
| 150 |
+
"--chakra-colors-sale": "var(--chakra-colors-pink-600)",
|
| 151 |
+
"--chakra-colors-warm": "var(--chakra-colors-tech-warm-500)",
|
| 152 |
+
"--chakra-colors-dry": "var(--chakra-colors-tech-dry-500)",
|
| 153 |
+
"--chakra-colors-cool": "var(--chakra-colors-tech-cool-400)",
|
| 154 |
+
"--chakra-colors-protected": "var(--chakra-colors-tech-protected-400)",
|
| 155 |
+
"--chakra-colors-error-primary": "var(--chakra-colors-red-600)",
|
| 156 |
+
"--chakra-colors-error-minimal": "var(--chakra-colors-red-50)",
|
| 157 |
+
"--chakra-colors-error-contrast": "var(--chakra-colors-red-700)",
|
| 158 |
+
"--chakra-colors-error-secondary": "var(--chakra-colors-red-100)",
|
| 159 |
+
"--chakra-colors-warning-primary": "var(--chakra-colors-orange-600)",
|
| 160 |
+
"--chakra-colors-warning-minimal": "var(--chakra-colors-orange-50)",
|
| 161 |
+
"--chakra-colors-warning-contrast": "var(--chakra-colors-orange-700)",
|
| 162 |
+
"--chakra-colors-warning-secondary": "var(--chakra-colors-orange-100)",
|
| 163 |
+
"--chakra-colors-success-primary": "var(--chakra-colors-green-600)",
|
| 164 |
+
"--chakra-colors-success-minimal": "var(--chakra-colors-green-50)",
|
| 165 |
+
"--chakra-colors-success-contrast": "var(--chakra-colors-green-700)",
|
| 166 |
+
"--chakra-colors-success-secondary": "var(--chakra-colors-green-100)",
|
| 167 |
+
"--chakra-colors-info-primary": "var(--chakra-colors-blue-600)",
|
| 168 |
+
"--chakra-colors-info-minimal": "var(--chakra-colors-blue-50)",
|
| 169 |
+
"--chakra-colors-info-contrast": "var(--chakra-colors-blue-700)",
|
| 170 |
+
"--chakra-colors-info-secondary": "var(--chakra-colors-blue-100)",
|
| 171 |
+
"--chakra-colors-black-alpha-0": "#00000000",
|
| 172 |
+
"--chakra-colors-black-alpha-50": "#0000000D",
|
| 173 |
+
"--chakra-colors-black-alpha-100": "#0000001A",
|
| 174 |
+
"--chakra-colors-black-alpha-200": "#00000034",
|
| 175 |
+
"--chakra-colors-black-alpha-300": "#0000004D",
|
| 176 |
+
"--chakra-colors-black-alpha-400": "#00000067",
|
| 177 |
+
"--chakra-colors-black-alpha-500": "#00000080",
|
| 178 |
+
"--chakra-colors-black-alpha-600": "#0000009A",
|
| 179 |
+
"--chakra-colors-black-alpha-700": "#000000B4",
|
| 180 |
+
"--chakra-colors-black-alpha-800": "#000000CD",
|
| 181 |
+
"--chakra-colors-black-alpha-900": "#000000E7",
|
| 182 |
+
"--chakra-colors-black-alpha-950": "#000000F4",
|
| 183 |
+
"--chakra-colors-black-alpha-1000": "#000000",
|
| 184 |
+
"--chakra-colors-component-button-disabled-bg-inverted": "#4E4F4F",
|
| 185 |
+
"--chakra-colors-component-button-disabled-bg-primary": "#E8E9E9",
|
| 186 |
+
"--chakra-colors-component-button-disabled-border-inverted": "#919292",
|
| 187 |
+
"--chakra-colors-component-button-disabled-border-primary": "#A5A6A6",
|
| 188 |
+
"--chakra-colors-component-button-disabled-fg-inverted": "#A5A6A6",
|
| 189 |
+
"--chakra-colors-component-button-disabled-fg-primary": "#7A7B7B",
|
| 190 |
+
"--chakra-colors-component-button-error-border-primary": "#D42B2B",
|
| 191 |
+
"--chakra-colors-component-button-error-fg-primary": "#FFFFFF",
|
| 192 |
+
"--chakra-colors-component-button-error-fg-primary-inverted": "#D42B2B",
|
| 193 |
+
"--chakra-colors-component-button-error-fg-secondary-inverted": "#F87171",
|
| 194 |
+
"--chakra-colors-component-button-light-bg-primary": "#FFFFFF",
|
| 195 |
+
"--chakra-colors-component-button-light-bg-primary-inverted": "#141515",
|
| 196 |
+
"--chakra-colors-component-button-light-bg-secondary": "#F7F7F7",
|
| 197 |
+
"--chakra-colors-component-button-light-bg-secondary-inverted": "#4E4F4F",
|
| 198 |
+
"--chakra-colors-component-button-light-bg-tertiary": "#D3D4D4",
|
| 199 |
+
"--chakra-colors-component-button-light-bg-tertiary-inverted": "#7A7B7B",
|
| 200 |
+
"--chakra-colors-component-button-light-border-primary": "#FFFFFF",
|
| 201 |
+
"--chakra-colors-component-button-light-fg-primary": "#000000",
|
| 202 |
+
"--chakra-colors-component-button-light-fg-primary-inverted": "#FFFFFF",
|
| 203 |
+
"--chakra-colors-component-button-light-fg-secondary-inverted": "#D3D4D4",
|
| 204 |
+
"--chakra-colors-component-button-sale-bg-primary": "#9B2242",
|
| 205 |
+
"--chakra-colors-component-button-sale-bg-primary-inverted": "#FFEEF2",
|
| 206 |
+
"--chakra-colors-component-button-sale-bg-secondary": "#751A32",
|
| 207 |
+
"--chakra-colors-component-button-sale-bg-secondary-inverted": "#FBDEE6",
|
| 208 |
+
"--chakra-colors-component-button-sale-bg-tertiary": "#4F1122",
|
| 209 |
+
"--chakra-colors-component-button-sale-bg-tertiary-inverted": "#FFC0D0",
|
| 210 |
+
"--chakra-colors-component-button-sale-border-primary": "#9B2242",
|
| 211 |
+
"--chakra-colors-component-button-sale-fg-primary": "#FFFFFF",
|
| 212 |
+
"--chakra-colors-component-button-sale-fg-primary-inverted": "#9B2242",
|
| 213 |
+
"--chakra-colors-component-button-sale-fg-secondary-inverted": "#D84F74",
|
| 214 |
+
"--chakra-colors-limited-edition-disney-fall": "#88296F",
|
| 215 |
+
"--chakra-colors-limited-edition-disney-spring": "#88296F",
|
| 216 |
+
"--chakra-colors-limited-edition-drops-fall": "#D3BEA3",
|
| 217 |
+
"--chakra-colors-limited-edition-drops-spring": "#D3BEA3",
|
| 218 |
+
"--chakra-colors-limited-edition-holiday-1": "#D1DEEF",
|
| 219 |
+
"--chakra-colors-limited-edition-holiday-2": "#332F89",
|
| 220 |
+
"--chakra-colors-limited-edition-holiday-3": "#332F89",
|
| 221 |
+
"--chakra-colors-limited-edition-star-wars-fall": "#151515",
|
| 222 |
+
"--chakra-colors-limited-edition-star-wars-spring": "#151515",
|
| 223 |
+
"--chakra-colors-tech-cool-400": "#48BCE8",
|
| 224 |
+
"--chakra-colors-tech-cool-500": "#309EC8",
|
| 225 |
+
"--chakra-colors-tech-cool-600": "#188FBF",
|
| 226 |
+
"--chakra-colors-tech-cool-700": "#147FA7",
|
| 227 |
+
"--chakra-colors-tech-dry-300": "#A6CC00",
|
| 228 |
+
"--chakra-colors-tech-dry-500": "#819F00",
|
| 229 |
+
"--chakra-colors-tech-dry-600": "#758F00",
|
| 230 |
+
"--chakra-colors-tech-dry-700": "#677F00",
|
| 231 |
+
"--chakra-colors-tech-protected-400": "#FF622F",
|
| 232 |
+
"--chakra-colors-tech-protected-500": "#FD602D",
|
| 233 |
+
"--chakra-colors-tech-protected-600": "#FA3E00",
|
| 234 |
+
"--chakra-colors-tech-protected-700": "#D64111",
|
| 235 |
+
"--chakra-colors-tech-warm-500": "#FF283C",
|
| 236 |
+
"--chakra-colors-tech-warm-600": "#E71C2F",
|
| 237 |
+
"--chakra-colors-white-alpha-0": "#FFFFFF00",
|
| 238 |
+
"--chakra-colors-white-alpha-50": "#FFFFFF0D",
|
| 239 |
+
"--chakra-colors-white-alpha-100": "#FFFFFF1A",
|
| 240 |
+
"--chakra-colors-white-alpha-200": "#FFFFFF34",
|
| 241 |
+
"--chakra-colors-white-alpha-300": "#FFFFFF4D",
|
| 242 |
+
"--chakra-colors-white-alpha-400": "#FFFFFF67",
|
| 243 |
+
"--chakra-colors-white-alpha-500": "#FFFFFF80",
|
| 244 |
+
"--chakra-colors-white-alpha-600": "#FFFFFF9A",
|
| 245 |
+
"--chakra-colors-white-alpha-700": "#FFFFFFB4",
|
| 246 |
+
"--chakra-colors-white-alpha-800": "#FFFFFFCD",
|
| 247 |
+
"--chakra-colors-white-alpha-900": "#FFFFFFE7",
|
| 248 |
+
"--chakra-colors-white-alpha-950": "#FFFFFFF4",
|
| 249 |
+
"--chakra-colors-white-alpha-1000": "#FFFFFF",
|
| 250 |
+
"--chakra-borders-none": "0",
|
| 251 |
+
"--chakra-borders-1px": "1px solid",
|
| 252 |
+
"--chakra-borders-2px": "2px solid",
|
| 253 |
+
"--chakra-borders-4px": "4px solid",
|
| 254 |
+
"--chakra-borders-8px": "8px solid",
|
| 255 |
+
"--chakra-fonts-heading": "'Avenir Next','Avenir','Segoe UI','Noto Sans','Helvetica Neue','Arial',sans-serif",
|
| 256 |
+
"--chakra-fonts-body": "'Avenir Next','Avenir','Segoe UI','Noto Sans','Helvetica Neue','Arial',sans-serif",
|
| 257 |
+
"--chakra-fonts-mono": "SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace",
|
| 258 |
+
"--chakra-fonts-display-primary": "'GerTTBold',sans-serif",
|
| 259 |
+
"--chakra-fonts-display-secondary": "'GerTT CD',sans-serif",
|
| 260 |
+
"--chakra-fonts-legal": "'Avenir Next','Avenir','Segoe UI','Noto Sans','Helvetica Neue','Arial',sans-serif",
|
| 261 |
+
"--chakra-fontSizes-3xs": "0.45rem",
|
| 262 |
+
"--chakra-fontSizes-2xs": "0.625rem",
|
| 263 |
+
"--chakra-fontSizes-xs": "0.75rem",
|
| 264 |
+
"--chakra-fontSizes-sm": "0.875rem",
|
| 265 |
+
"--chakra-fontSizes-md": "1rem",
|
| 266 |
+
"--chakra-fontSizes-lg": "1.125rem",
|
| 267 |
+
"--chakra-fontSizes-xl": "1.25rem",
|
| 268 |
+
"--chakra-fontSizes-2xl": "1.5rem",
|
| 269 |
+
"--chakra-fontSizes-3xl": "1.875rem",
|
| 270 |
+
"--chakra-fontSizes-4xl": "2.25rem",
|
| 271 |
+
"--chakra-fontSizes-5xl": "3rem",
|
| 272 |
+
"--chakra-fontSizes-6xl": "3.75rem",
|
| 273 |
+
"--chakra-fontSizes-7xl": "4.5rem",
|
| 274 |
+
"--chakra-fontSizes-8xl": "6rem",
|
| 275 |
+
"--chakra-fontSizes-9xl": "8rem",
|
| 276 |
+
"--chakra-fontWeights-hairline": "100",
|
| 277 |
+
"--chakra-fontWeights-thin": "200",
|
| 278 |
+
"--chakra-fontWeights-light": "300",
|
| 279 |
+
"--chakra-fontWeights-normal": "400",
|
| 280 |
+
"--chakra-fontWeights-medium": "500",
|
| 281 |
+
"--chakra-fontWeights-semibold": "600",
|
| 282 |
+
"--chakra-fontWeights-bold": "700",
|
| 283 |
+
"--chakra-fontWeights-extrabold": "800",
|
| 284 |
+
"--chakra-fontWeights-black": "900",
|
| 285 |
+
"--chakra-gradients-imageBackground": "linear(270deg, #E6E5EA, #EEEEEE)",
|
| 286 |
+
"--chakra-letterSpacings-tighter": "-0.05em",
|
| 287 |
+
"--chakra-letterSpacings-tight": "-0.025em",
|
| 288 |
+
"--chakra-letterSpacings-normal": "0",
|
| 289 |
+
"--chakra-letterSpacings-wide": "0.025em",
|
| 290 |
+
"--chakra-letterSpacings-wider": "0.05em",
|
| 291 |
+
"--chakra-letterSpacings-widest": "0.1em",
|
| 292 |
+
"--chakra-lineHeights-3": ".75rem",
|
| 293 |
+
"--chakra-lineHeights-4": "1rem",
|
| 294 |
+
"--chakra-lineHeights-5": "1.25rem",
|
| 295 |
+
"--chakra-lineHeights-6": "1.5rem",
|
| 296 |
+
"--chakra-lineHeights-7": "1.75rem",
|
| 297 |
+
"--chakra-lineHeights-8": "2rem",
|
| 298 |
+
"--chakra-lineHeights-9": "2.25rem",
|
| 299 |
+
"--chakra-lineHeights-10": "2.5rem",
|
| 300 |
+
"--chakra-lineHeights-normal": "normal",
|
| 301 |
+
"--chakra-lineHeights-none": "1",
|
| 302 |
+
"--chakra-lineHeights-shorter": "1.25",
|
| 303 |
+
"--chakra-lineHeights-short": "1.375",
|
| 304 |
+
"--chakra-lineHeights-base": "1.5",
|
| 305 |
+
"--chakra-lineHeights-tall": "1.625",
|
| 306 |
+
"--chakra-lineHeights-taller": "2",
|
| 307 |
+
"--chakra-radii-none": "0",
|
| 308 |
+
"--chakra-radii-sm": "0.125rem",
|
| 309 |
+
"--chakra-radii-base": "0.25rem",
|
| 310 |
+
"--chakra-radii-md": "0.375rem",
|
| 311 |
+
"--chakra-radii-lg": "0.5rem",
|
| 312 |
+
"--chakra-radii-xl": "0.75rem",
|
| 313 |
+
"--chakra-radii-2xl": "1rem",
|
| 314 |
+
"--chakra-radii-3xl": "1.5rem",
|
| 315 |
+
"--chakra-radii-full": "9999px",
|
| 316 |
+
"--chakra-space-1": "0.25rem",
|
| 317 |
+
"--chakra-space-2": "0.5rem",
|
| 318 |
+
"--chakra-space-3": "0.75rem",
|
| 319 |
+
"--chakra-space-4": "1rem",
|
| 320 |
+
"--chakra-space-5": "1.25rem",
|
| 321 |
+
"--chakra-space-6": "1.5rem",
|
| 322 |
+
"--chakra-space-7": "1.75rem",
|
| 323 |
+
"--chakra-space-8": "2rem",
|
| 324 |
+
"--chakra-space-9": "2.25rem",
|
| 325 |
+
"--chakra-space-10": "2.5rem",
|
| 326 |
+
"--chakra-space-11": "2.75rem",
|
| 327 |
+
"--chakra-space-12": "3rem",
|
| 328 |
+
"--chakra-space-14": "3.5rem",
|
| 329 |
+
"--chakra-space-16": "4rem",
|
| 330 |
+
"--chakra-space-20": "5rem",
|
| 331 |
+
"--chakra-space-24": "6rem",
|
| 332 |
+
"--chakra-space-28": "7rem",
|
| 333 |
+
"--chakra-space-32": "8rem",
|
| 334 |
+
"--chakra-space-36": "9rem",
|
| 335 |
+
"--chakra-space-40": "10rem",
|
| 336 |
+
"--chakra-space-44": "11rem",
|
| 337 |
+
"--chakra-space-48": "12rem",
|
| 338 |
+
"--chakra-space-52": "13rem",
|
| 339 |
+
"--chakra-space-56": "14rem",
|
| 340 |
+
"--chakra-space-60": "15rem",
|
| 341 |
+
"--chakra-space-64": "16rem",
|
| 342 |
+
"--chakra-space-72": "18rem",
|
| 343 |
+
"--chakra-space-80": "20rem",
|
| 344 |
+
"--chakra-space-96": "24rem",
|
| 345 |
+
"--chakra-space-px": "1px",
|
| 346 |
+
"--chakra-space-0-5": "0.125rem",
|
| 347 |
+
"--chakra-space-1-5": "0.375rem",
|
| 348 |
+
"--chakra-space-2-5": "0.625rem",
|
| 349 |
+
"--chakra-space-3-5": "0.875rem",
|
| 350 |
+
"--chakra-shadows-xs": "0 0 0 1px rgba(0, 0, 0, 0.05)",
|
| 351 |
+
"--chakra-shadows-sm": "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
| 352 |
+
"--chakra-shadows-base": "0 1px 3px 0 rgba(0, 0, 0, 0.1),0 1px 2px 0 rgba(0, 0, 0, 0.06)",
|
| 353 |
+
"--chakra-shadows-md": "0px 4px 8px 0px rgba(24, 24, 27, 0.10),0px 0px 1px 0px rgba(24, 24, 27, 0.30)",
|
| 354 |
+
"--chakra-shadows-lg": "0 10px 15px -3px rgba(0, 0, 0, 0.1),0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
| 355 |
+
"--chakra-shadows-xl": "0 20px 25px -5px rgba(0, 0, 0, 0.1),0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
| 356 |
+
"--chakra-shadows-2xl": "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
| 357 |
+
"--chakra-shadows-outline": "0 0 0 3px var(--chakra-colors-blue-500)",
|
| 358 |
+
"--chakra-shadows-inner": "inset 0 2px 4px 0 rgba(0,0,0,0.06)",
|
| 359 |
+
"--chakra-shadows-none": "none",
|
| 360 |
+
"--chakra-shadows-dark-lg": "rgba(0, 0, 0, 0.1) 0px 0px 0px 1px,rgba(0, 0, 0, 0.2) 0px 5px 10px,rgba(0, 0, 0, 0.4) 0px 15px 40px",
|
| 361 |
+
"--chakra-shadows-top": "0px -1px 3px rgba(0, 0, 0, 0.1),0px -1px 2px rgba(0, 0, 0, 0.06)",
|
| 362 |
+
"--chakra-sizes-1": "0.25rem",
|
| 363 |
+
"--chakra-sizes-2": "0.5rem",
|
| 364 |
+
"--chakra-sizes-3": "0.75rem",
|
| 365 |
+
"--chakra-sizes-4": "1rem",
|
| 366 |
+
"--chakra-sizes-5": "1.25rem",
|
| 367 |
+
"--chakra-sizes-6": "1.5rem",
|
| 368 |
+
"--chakra-sizes-7": "1.75rem",
|
| 369 |
+
"--chakra-sizes-8": "2rem",
|
| 370 |
+
"--chakra-sizes-9": "2.25rem",
|
| 371 |
+
"--chakra-sizes-10": "2.5rem",
|
| 372 |
+
"--chakra-sizes-11": "2.75rem",
|
| 373 |
+
"--chakra-sizes-12": "3rem",
|
| 374 |
+
"--chakra-sizes-14": "3.5rem",
|
| 375 |
+
"--chakra-sizes-16": "4rem",
|
| 376 |
+
"--chakra-sizes-20": "5rem",
|
| 377 |
+
"--chakra-sizes-24": "6rem",
|
| 378 |
+
"--chakra-sizes-28": "7rem",
|
| 379 |
+
"--chakra-sizes-32": "8rem",
|
| 380 |
+
"--chakra-sizes-36": "9rem",
|
| 381 |
+
"--chakra-sizes-40": "10rem",
|
| 382 |
+
"--chakra-sizes-44": "11rem",
|
| 383 |
+
"--chakra-sizes-48": "12rem",
|
| 384 |
+
"--chakra-sizes-52": "13rem",
|
| 385 |
+
"--chakra-sizes-56": "14rem",
|
| 386 |
+
"--chakra-sizes-60": "15rem",
|
| 387 |
+
"--chakra-sizes-64": "16rem",
|
| 388 |
+
"--chakra-sizes-72": "18rem",
|
| 389 |
+
"--chakra-sizes-80": "20rem",
|
| 390 |
+
"--chakra-sizes-96": "24rem",
|
| 391 |
+
"--chakra-sizes-px": "1px",
|
| 392 |
+
"--chakra-sizes-0-5": "0.125rem",
|
| 393 |
+
"--chakra-sizes-1-5": "0.375rem",
|
| 394 |
+
"--chakra-sizes-2-5": "0.625rem",
|
| 395 |
+
"--chakra-sizes-3-5": "0.875rem",
|
| 396 |
+
"--chakra-sizes-max": "max-content",
|
| 397 |
+
"--chakra-sizes-min": "min-content",
|
| 398 |
+
"--chakra-sizes-full": "100%",
|
| 399 |
+
"--chakra-sizes-3xs": "14rem",
|
| 400 |
+
"--chakra-sizes-2xs": "16rem",
|
| 401 |
+
"--chakra-sizes-xs": "20rem",
|
| 402 |
+
"--chakra-sizes-sm": "24rem",
|
| 403 |
+
"--chakra-sizes-md": "28rem",
|
| 404 |
+
"--chakra-sizes-lg": "32rem",
|
| 405 |
+
"--chakra-sizes-xl": "36rem",
|
| 406 |
+
"--chakra-sizes-2xl": "42rem",
|
| 407 |
+
"--chakra-sizes-3xl": "48rem",
|
| 408 |
+
"--chakra-sizes-4xl": "56rem",
|
| 409 |
+
"--chakra-sizes-5xl": "64rem",
|
| 410 |
+
"--chakra-sizes-6xl": "72rem",
|
| 411 |
+
"--chakra-sizes-7xl": "80rem",
|
| 412 |
+
"--chakra-sizes-8xl": "90rem",
|
| 413 |
+
"--chakra-sizes-prose": "60ch",
|
| 414 |
+
"--chakra-sizes-container-sm": "640px",
|
| 415 |
+
"--chakra-sizes-container-md": "768px",
|
| 416 |
+
"--chakra-sizes-container-lg": "1024px",
|
| 417 |
+
"--chakra-sizes-container-xl": "1200px",
|
| 418 |
+
"--chakra-sizes-container-xs": "512px",
|
| 419 |
+
"--chakra-sizes-container-xxl": "1440px",
|
| 420 |
+
"--chakra-sizes-container-xxxl": "1560px",
|
| 421 |
+
"--chakra-sizes-0px-Columbia": "0px",
|
| 422 |
+
"--chakra-sizes-0px-Sorel": "0px",
|
| 423 |
+
"--chakra-sizes-0px-undefined": "0px",
|
| 424 |
+
"--chakra-sizes-1px-Columbia": "1px",
|
| 425 |
+
"--chakra-sizes-1px-Sorel": "1px",
|
| 426 |
+
"--chakra-sizes-1px-undefined": "1px",
|
| 427 |
+
"--chakra-sizes-2px-Columbia": "2px",
|
| 428 |
+
"--chakra-sizes-2px-Sorel": "2px",
|
| 429 |
+
"--chakra-sizes-2px-undefined": "2px",
|
| 430 |
+
"--chakra-sizes-4px-Columbia": "4px",
|
| 431 |
+
"--chakra-sizes-4px-Sorel": "4px",
|
| 432 |
+
"--chakra-sizes-4px-undefined": "4px",
|
| 433 |
+
"--chakra-sizes-6px-Columbia": "6px",
|
| 434 |
+
"--chakra-sizes-6px-Sorel": "6px",
|
| 435 |
+
"--chakra-sizes-6px-undefined": "6px",
|
| 436 |
+
"--chakra-sizes-8px-Columbia": "8px",
|
| 437 |
+
"--chakra-sizes-8px-Sorel": "8px",
|
| 438 |
+
"--chakra-sizes-8px-undefined": "8px",
|
| 439 |
+
"--chakra-sizes-10px-Columbia": "10px",
|
| 440 |
+
"--chakra-sizes-10px-Sorel": "10px",
|
| 441 |
+
"--chakra-sizes-10px-undefined": "10px",
|
| 442 |
+
"--chakra-sizes-12px-Columbia": "12px",
|
| 443 |
+
"--chakra-sizes-12px-Sorel": "12px",
|
| 444 |
+
"--chakra-sizes-12px-undefined": "12px",
|
| 445 |
+
"--chakra-sizes-14px-Columbia": "14px",
|
| 446 |
+
"--chakra-sizes-14px-Sorel": "14px",
|
| 447 |
+
"--chakra-sizes-14px-undefined": "14px",
|
| 448 |
+
"--chakra-sizes-16px-Columbia": "16px",
|
| 449 |
+
"--chakra-sizes-16px-Sorel": "16px",
|
| 450 |
+
"--chakra-sizes-16px-undefined": "16px",
|
| 451 |
+
"--chakra-sizes-18px-Columbia": "18px",
|
| 452 |
+
"--chakra-sizes-18px-Sorel": "18px",
|
| 453 |
+
"--chakra-sizes-18px-undefined": "18px",
|
| 454 |
+
"--chakra-sizes-20px-Columbia": "20px",
|
| 455 |
+
"--chakra-sizes-20px-Sorel": "20px",
|
| 456 |
+
"--chakra-sizes-20px-undefined": "20px",
|
| 457 |
+
"--chakra-sizes-24px-Columbia": "24px",
|
| 458 |
+
"--chakra-sizes-24px-Sorel": "24px",
|
| 459 |
+
"--chakra-sizes-24px-undefined": "24px",
|
| 460 |
+
"--chakra-sizes-28px-Columbia": "28px",
|
| 461 |
+
"--chakra-sizes-28px-Sorel": "28px",
|
| 462 |
+
"--chakra-sizes-28px-undefined": "28px",
|
| 463 |
+
"--chakra-sizes-32px-Columbia": "32px",
|
| 464 |
+
"--chakra-sizes-32px-Sorel": "32px",
|
| 465 |
+
"--chakra-sizes-32px-undefined": "32px",
|
| 466 |
+
"--chakra-sizes-36px-Columbia": "36px",
|
| 467 |
+
"--chakra-sizes-36px-Sorel": "36px",
|
| 468 |
+
"--chakra-sizes-36px-undefined": "36px",
|
| 469 |
+
"--chakra-sizes-40px-Columbia": "40px",
|
| 470 |
+
"--chakra-sizes-40px-Sorel": "40px",
|
| 471 |
+
"--chakra-sizes-40px-undefined": "40px",
|
| 472 |
+
"--chakra-sizes-44px-Columbia": "44px",
|
| 473 |
+
"--chakra-sizes-44px-Sorel": "44px",
|
| 474 |
+
"--chakra-sizes-44px-undefined": "44px",
|
| 475 |
+
"--chakra-sizes-48px-Columbia": "48px",
|
| 476 |
+
"--chakra-sizes-48px-Sorel": "48px",
|
| 477 |
+
"--chakra-sizes-48px-undefined": "48px",
|
| 478 |
+
"--chakra-sizes-56px-Columbia": "56px",
|
| 479 |
+
"--chakra-sizes-56px-Sorel": "56px",
|
| 480 |
+
"--chakra-sizes-56px-undefined": "56px",
|
| 481 |
+
"--chakra-sizes-64px-Columbia": "64px",
|
| 482 |
+
"--chakra-sizes-64px-Sorel": "64px",
|
| 483 |
+
"--chakra-sizes-64px-undefined": "64px",
|
| 484 |
+
"--chakra-sizes-72px-Columbia": "72px",
|
| 485 |
+
"--chakra-sizes-72px-Sorel": "72px",
|
| 486 |
+
"--chakra-sizes-72px-undefined": "72px",
|
| 487 |
+
"--chakra-sizes-80px-Columbia": "80px",
|
| 488 |
+
"--chakra-sizes-80px-Sorel": "80px",
|
| 489 |
+
"--chakra-sizes-80px-undefined": "80px",
|
| 490 |
+
"--chakra-sizes-96px-Columbia": "96px",
|
| 491 |
+
"--chakra-sizes-96px-Sorel": "96px",
|
| 492 |
+
"--chakra-sizes-96px-undefined": "96px",
|
| 493 |
+
"--chakra-sizes-112px-Columbia": "112px",
|
| 494 |
+
"--chakra-sizes-112px-Sorel": "112px",
|
| 495 |
+
"--chakra-sizes-112px-undefined": "112px",
|
| 496 |
+
"--chakra-sizes-128px-Columbia": "128px",
|
| 497 |
+
"--chakra-sizes-128px-Sorel": "128px",
|
| 498 |
+
"--chakra-sizes-128px-undefined": "128px",
|
| 499 |
+
"--chakra-sizes-144px-Columbia": "144px",
|
| 500 |
+
"--chakra-sizes-144px-Sorel": "144px",
|
| 501 |
+
"--chakra-sizes-144px-undefined": "144px",
|
| 502 |
+
"--chakra-sizes-160px-Columbia": "160px",
|
| 503 |
+
"--chakra-sizes-160px-Sorel": "160px",
|
| 504 |
+
"--chakra-sizes-160px-undefined": "160px",
|
| 505 |
+
"--chakra-sizes-176px-Columbia": "176px",
|
| 506 |
+
"--chakra-sizes-176px-Sorel": "176px",
|
| 507 |
+
"--chakra-sizes-176px-undefined": "176px",
|
| 508 |
+
"--chakra-sizes-192px-Columbia": "192px",
|
| 509 |
+
"--chakra-sizes-192px-Sorel": "192px",
|
| 510 |
+
"--chakra-sizes-192px-undefined": "192px",
|
| 511 |
+
"--chakra-sizes-208px-Columbia": "208px",
|
| 512 |
+
"--chakra-sizes-208px-Sorel": "208px",
|
| 513 |
+
"--chakra-sizes-208px-undefined": "208px",
|
| 514 |
+
"--chakra-sizes-224px-Columbia": "224px",
|
| 515 |
+
"--chakra-sizes-224px-Sorel": "224px",
|
| 516 |
+
"--chakra-sizes-224px-undefined": "224px",
|
| 517 |
+
"--chakra-sizes-240px-Columbia": "240px",
|
| 518 |
+
"--chakra-sizes-240px-Sorel": "240px",
|
| 519 |
+
"--chakra-sizes-240px-undefined": "240px",
|
| 520 |
+
"--chakra-sizes-256px-Columbia": "256px",
|
| 521 |
+
"--chakra-sizes-256px-Sorel": "256px",
|
| 522 |
+
"--chakra-sizes-256px-undefined": "256px",
|
| 523 |
+
"--chakra-sizes-288px-Columbia": "288px",
|
| 524 |
+
"--chakra-sizes-288px-Sorel": "288px",
|
| 525 |
+
"--chakra-sizes-288px-undefined": "288px",
|
| 526 |
+
"--chakra-sizes-320px-Columbia": "320px",
|
| 527 |
+
"--chakra-sizes-320px-Sorel": "320px",
|
| 528 |
+
"--chakra-sizes-320px-undefined": "320px",
|
| 529 |
+
"--chakra-sizes-384px-Columbia": "384px",
|
| 530 |
+
"--chakra-sizes-384px-Sorel": "384px",
|
| 531 |
+
"--chakra-sizes-384px-undefined": "384px",
|
| 532 |
+
"--chakra-sizes-480px-Columbia": "480px",
|
| 533 |
+
"--chakra-sizes-480px-Sorel": "480px",
|
| 534 |
+
"--chakra-sizes-480px-undefined": "480px",
|
| 535 |
+
"--chakra-zIndices-hide": "-1",
|
| 536 |
+
"--chakra-zIndices-auto": "auto",
|
| 537 |
+
"--chakra-zIndices-base": "0",
|
| 538 |
+
"--chakra-zIndices-docked": "10",
|
| 539 |
+
"--chakra-zIndices-dropdown": "1000",
|
| 540 |
+
"--chakra-zIndices-sticky": "1100",
|
| 541 |
+
"--chakra-zIndices-banner": "1200",
|
| 542 |
+
"--chakra-zIndices-overlay": "1300",
|
| 543 |
+
"--chakra-zIndices-modal": "1400",
|
| 544 |
+
"--chakra-zIndices-popover": "1500",
|
| 545 |
+
"--chakra-zIndices-skipLink": "1600",
|
| 546 |
+
"--chakra-zIndices-toast": "1700",
|
| 547 |
+
"--chakra-zIndices-tooltip": "1800",
|
| 548 |
+
"--chakra-transition-property-common": "background-color,border-color,color,fill,stroke,opacity,box-shadow,transform",
|
| 549 |
+
"--chakra-transition-property-colors": "background-color,border-color,color,fill,stroke",
|
| 550 |
+
"--chakra-transition-property-dimensions": "width,height",
|
| 551 |
+
"--chakra-transition-property-position": "left,right,top,bottom",
|
| 552 |
+
"--chakra-transition-property-background": "background-color,background-image,background-position",
|
| 553 |
+
"--chakra-transition-easing-ease-in": "cubic-bezier(0.4, 0, 1, 1)",
|
| 554 |
+
"--chakra-transition-easing-ease-out": "cubic-bezier(0, 0, 0.2, 1)",
|
| 555 |
+
"--chakra-transition-easing-ease-in-out": "cubic-bezier(0.4, 0, 0.2, 1)",
|
| 556 |
+
"--chakra-transition-duration-ultra-fast": "50ms",
|
| 557 |
+
"--chakra-transition-duration-faster": "100ms",
|
| 558 |
+
"--chakra-transition-duration-fast": "150ms",
|
| 559 |
+
"--chakra-transition-duration-normal": "200ms",
|
| 560 |
+
"--chakra-transition-duration-slow": "300ms",
|
| 561 |
+
"--chakra-transition-duration-slower": "400ms",
|
| 562 |
+
"--chakra-transition-duration-ultra-slow": "500ms",
|
| 563 |
+
"--chakra-blur-none": "0",
|
| 564 |
+
"--chakra-blur-sm": "4px",
|
| 565 |
+
"--chakra-blur-base": "8px",
|
| 566 |
+
"--chakra-blur-md": "12px",
|
| 567 |
+
"--chakra-blur-lg": "16px",
|
| 568 |
+
"--chakra-blur-xl": "24px",
|
| 569 |
+
"--chakra-blur-2xl": "40px",
|
| 570 |
+
"--chakra-blur-3xl": "64px",
|
| 571 |
+
"--chakra-breakpoints-base": "0em",
|
| 572 |
+
"--chakra-breakpoints-sm": "480px",
|
| 573 |
+
"--chakra-breakpoints-md": "768px",
|
| 574 |
+
"--chakra-breakpoints-lg": "992px",
|
| 575 |
+
"--chakra-breakpoints-xl": "1280px",
|
| 576 |
+
"--chakra-breakpoints-2xl": "1536px",
|
| 577 |
+
"--chakra-breakpoints-xs": "375px",
|
| 578 |
+
"--chakra-colors-chakra-body-text": "var(--chakra-colors-whiteAlpha-900)",
|
| 579 |
+
"--chakra-colors-chakra-body-bg": "var(--chakra-colors-gray-800)",
|
| 580 |
+
"--chakra-colors-chakra-border-color": "var(--chakra-colors-whiteAlpha-300)",
|
| 581 |
+
"--chakra-colors-chakra-inverse-text": "var(--chakra-colors-gray-800)",
|
| 582 |
+
"--chakra-colors-chakra-subtle-bg": "var(--chakra-colors-gray-700)",
|
| 583 |
+
"--chakra-colors-chakra-subtle-text": "var(--chakra-colors-gray-400)",
|
| 584 |
+
"--chakra-colors-chakra-placeholder-color": "var(--chakra-colors-whiteAlpha-400)",
|
| 585 |
+
"--chakra-vh": "100dvh"
|
| 586 |
+
}
|
tasks/columbia/environment/reference/clone/data/measured-membership.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"accessories":["2175531","2175411","2184801","1911321","2175581","2011061","2134431_AUB","2116681","2116701","2094031","2136931","2094191","2094091","2094081","HUM0250","2137421","2137321","1185181","2094311","1625971","2094281","1982011","2078511","2094301","2120421","2158421","2094131","2175601","1840131","2138331","2134431_UO","1862551","2001521","1911181","DGU0514","1908201","2020121","1911251","1836821","2180791","2158911","2137531","DGU0154","1555501","2159031","DGU0441","2164351","DGU0619","2159011","2159171","2158531","2175571","HUM0161","1836571","DGU0019","1975921","1714811","2175591","2180781","2121341","2158571","2175001","DGU0096","2120451","2096351","1862541","2121141","HUM0251","2159191","1447091","2137521","2178751","2092911","2175121","HUM0305","1837001","2010871","1991401","1495921","1503971","DGU0257","1837101","2010831","2181601","2010821","DGU0153","2070981","2158641","2121221","2175111","MEI0043","1652541","2175011","2158991","2010841","2078601","2121121","2120471","2169961","1836811","2175561","2175541","2175521","2175511","2175481","2175461","2134431_MS","2134431_FLA","2134431_NEB","2136721","2136731","2137301","HUM0246","HUM0261","2134431_LSU","2136611","2137581","2134431_TAM","2134431_DC","MEI0037","2134421_UT","HUM0020","MEI0064_S","2134421_DC","HUM0144","2118721_UO","DGU0635","DGU0037","DGU0577","2134431_ALA","DGU0533","2136641","HUM0297","2134431_UM","MEI0064","2134431_WV","2137311","DGU0372","HUM0304","HUM0303","2137511","2134431_CLE","HUM0260","2134431_UGA","HUM0259","DGU0636","2136691","2118721_ALA","2134431_TEX","HUM0249","DGU0542","2136941","2175361","MEI0058","2136631","MEI0057","DGU0534","2137291","2134431_FSU","DGU0111","DGU0578","2158551","DGU0571","HUM0302","DGU0066","DGU0686","2175381","2175021","DGU0535","2134421","DGU0244","DGU0374","DGU0262","HUM0300","2174991","DGU0063","DGU0618","DGU0602","DGU0095","2175441","MEI0062","2137582","DGU0104","DGU0609","2174981","HUM0289","2168971","2159151","MEI0048","DGU0572","DGU0620","DGU0580","2053801","DGU0576","MEI0066","DGU0103","2158581","GSO0091","2126531","2175451","2097421_UT","2097421_UM","2097421_UK","2097421_UGA","2097421_TAM","2097421_LSU","1913151_CLE","1913151_FSU","1892241_TAM","1913151_SC","1913151_TAM","1809851_OSU","2097421_FLA","1809851_TAM","1809851_ALA","1809851_FLA","1913151_FLA","1892241_AUB","1913151_ALA","1892241_ARK","2097011","1913151_UK","1913151_ARK","1892241_UO","1892241_SC","1809851_FSU","1809851_UM","1809851_LSU","1892241_FLA","1809851_SC","1809851_AUB","2097051","1809851_ARK","1892241_ALA","2097421_ALA","1913151_LSU","1892241_CLE","1892241_LSU","1892241_OSU","1892241_FSU","1892241_UK","2094201","1892241_UGA","2096801_TAM","2094161","1809851_UT","2094171","1913151_AUB","2094061","2096801_LSU","1892241_UM","2094331","2097421_FSU","1892241_UT","1682201","2096801_UAB","1913151_MS","1892241_OK","1809851_DC","2096801_TEX","1809851_UGA","1913151_UT","2094321","1913151_TEX","2096801_ALA","2096801_UM","MEI0063","2096801_UGA","1809851_UK","1913151_UGA","2094051","1809851_TEX","2011062","2094071","2094211","HUM0264","2097421_DC","2093221","1769681","2096811_UO","1917291","1865971","2071501","1913151_DC","2094291","2055311","MEI0011","1464091","2094271","MEI0065","2093151","1865972","2096801_DC"],"equipment":["AHM0005","GSO0019","2072181","GSO0006","GSO0170","GSO0008","AHM0015","GSO0136","GSO0169","GSO0135","AHM0002","CIN0061","2093301","AHM0001","GSO0165","GSO0137","GSO0041","AHM0003","ITD0017","2121541","GSO0007","GSO0134","ITD0014","GSO0025","GSO0026","GSO0171","GSO0131","CIN0062","2071541","GSO0132","GSO0130","GSO0099","GSO0044","GSO0144","GSO0120","AHM0014","GSO0168","GSO0146","2071611","GSO0046","ITD0006","GSO0124","GSO0123","GSO0143","CIN0028","GSO0020","GSO0140","AHM0013","ITD0016","2190641","2145331","GSO0145","2144911","2164271","GSO0133","GSO0021","AHM0016","2093271","GSO0119","GSO0139","2093291","2094541","2145431","GSO0045","2145421","2145451","2158221","2121521","2126181","GSO0043","2121511","2157941","2175671","CIN0073","2094421","GSO0009","2190631","2094431","ITD0021","2121591","2175651","CIN0074","2158211","GSO0050","2121451","2121401","2094401","GSO0030","2175691","CIN0077","2178801","2175101","2175071","2121411","2175661","CIN0088","2158021","2145301","2121421","GSO0109","AHM0008","GSO0095","GSO0126","GSO0102","GSO0042","GSO0129","LDN0002","GSO0096","GSO0094","GSO0103","GSO0125","GSO0098","GSO0097","GSO0049","CIN0004","CIN0014","CIN0030","CIN0048","CIN0050","CIN0065","CIN0069","CIN0070","CIN0080","CIN0086","CIN0087"],"footwear":["2169861","2148851","2148911","2077801","2101081","2141933","2108291","2169891","2165841","2100311","2165791","2149901","2140371","2132221","2108271","2165911","2146791","2159501","2146321","2149891","2079171","2165701","2159491","2165731","2078911","2103591","2165771","1781181","2165641","1575461","2165781","2182631","2081121","2125221","2165861","2127251","2153131","2149751","2165891","2075121","2164881","2079181","1826501","2103771","2165912","2077331","2062531","2115261","2100641","2169931","2130691","2165871","2108521","2100881","2126851","2169921","2105011","2146311","2079411","2143961","2103761","2108261","2115301","1594731","2165651","2148981","2063071","2149011","1424692","2149721","2128031","2067401","2079321","2128861","2108631","1826371","2182611","2062701","2144541","2164671","2108431","1718821","2177621","2076891","2145281","2121561","2126591","2100831","2078561","2099811","2148991","2182621","2079061","2108491","2128021","2180901","2177611","1987201","1987161","2149741","2100011","2108811","2062741","2108561","2063101","2101361","2078551","2078921","2164931","2093911","1781141","2126821","2125521","2128882","2149881","1673141","2128881","2093912","2079182","1554171","2077802","2109401","2153141","2108432","2078922","2101351","2100651","2100351","2076861","2079191","1862391","2109441","1791221","2100361","2100381","2148992","2078901","2078971","2075111","2078923","2144021","1718822","1553631","2149001","2099981","2179781","2128851","2115081","2044121","2053371","2121261","2164921","2100941","2128831","2143891","2079111","2077341","2079141","2162111","2126891","2130731","2126841","2115101","2162101","2115091","2148722","2141621","2079421","2099741","2128821","2062241","2130711","DGU0580","2109421","2093913","2078912","2144531","2062521","2143881","2148721","1746411","2121311","2126581","2144491","2125531","2121251","2144011","2141611","2145291","1661511","2027291","2148731","2078961","2063431","2062261","2148732","2108831","2108771","2149121","2149711","2153142","2148852","2108292","2128022","2140372","2141932","2165782","2125522","2101362","1781142","1554172","2100652","2103592","1781182","2165842","2164672","2143892","2165702","2100642","2125532","2164932","2164922","1746412","2067402","2149002","2109442","1791222","2105012","2165652","2126852","2099742","2076862","2165792","2159492","2079172","1424694","2063072","2164882","2078562","2075112","2128032","2101352","2078552","2141622","2153132","1594732","2165772","2144532","1673142","2075122","2165642","2100832","2076892","2079192","2143882","1553632","2062702","2148982","2141612","2125222","2063102","2148912","2108522","2179782","2108492","2077342"],"kids":["2156451","2174121","2035471","2119961","2089611","2159091","2089721","2174161","2196561","2108261","2165912","2097071","2173891","2159071","2090191","2154881","2090001","2094131","2172901","2090081","2154902","2181541","2146321","2172851","2175341","2078901","2089581","2175331","2175321","2115921","2099981","1675321","1541251","2173811","2118261","2121751","2087871","2175471","2154912","2133852","2172891","2090021","2011061","2172881","2154911","2175351","2175473","2154901","2062241","2175352","2001781","2116031","2172861","1867041","2001791","2118301","2146311","2090141","2175461","1568041","2087882","2088741","2198951","2115932","2183121","2156442","2090151","2134071","2175671","2001801","1618261","2154871","1574731","2090152","1510453","2175353","2001803","2175474","2050351","1510631","2093901","2001802","2175691","2173721","2178801","2125621","2088701","2087831","1799081","1799084","1510454","2090142","2175661","2001792","1510633","2089921","1510451","1618281","1568031","1618282","2121761","2119971","2125651","HYB3038","HYB3049","HYB3047","HYB3062","2125611","2125601","2089911","2133841","HYB3064","2196551","2089851","HYB3051","HYB3052","HYB3048","HYB3035","HYB3050","HYB3063","HYB3036","2089871","2118281","2159081","2090201","2090041","2154571","2070611","2159101","2035521","2070601","2159121","1987991","2116021","1713191","2144251","2156481","1833151","2159051","2116001","2174141","2089981","2154561","2121771","1833201","2001771","2078911","1987961","2156541","1527891","1620801","2115931","2115991","1990261","2090131","1931232","1990262","2154891","1923531","1541252","2121741","2118251","2148722","2126051","1833152","2078912","2089941","1833202","1713193","2097021","2148721","2159111","2090022","1990451","2089931","2090271","1527892","2126181","2115922","2134072","2156441","2070772","2088791","2070771","2121591","2001782","2158211","2108271","2001793","1574732","2121451","2094401","2118252","2115902","2116052","1618262","1510636","2116051","1799082","1867042","HYB3046","HYB3045","2133851","2196571","HYB3042","HYB3043","2159061","HYB3039","HYB3037","HYB3034","HYB3033","HYB2723","HYB2722","2100011","HYB3040","2133861","HYB2720","2133811","2089421","HYB3044","2116681","2093911","2133771","2116701","HYB2721","2137581","2126821","2135021","2094331","2128882","2128881","2089882","2089961","2089891","2089852","2088371","2089441","2093912","2090601","2135001","2156511","2094311","2089881","HYB3041","2137311","2094281","2094321","2094301","2174171","2144241","2117151","2133751","2138331","2096271","2125641","2166911","2089892","2133862","2133842","2089722","2125631","2097061","2078923","DGU0431","2156461","2087881","2094291","2133891","2090002","2137582","2117152","2182161","2133871","2089872","2090042","2156421","2135022","2165911","DGU0580","2121781","2093913","2088952","2094271","2134941","2134091","2134092","2135002","2088721","2090192","2182162","2183122","2088951","2088702","2088751","2148732","2175651","2135011","2173831","CIN0014","CIN0030","2078922","2078921","1892231_FLA","2156991_OK","2156991_LSU","1892231_UGA","2156991_UGA","2001783","2001773","2001772","1989831","1987962","1917291","1892231_LSU","1892231_FSU","2156991_FSU","2156991_ARK","2156991_SC","2156991_UT","1892231_ALA","1892231_TAM","2156991_NC","2156991_AUB","2156991_TAM","1892231_DC","1892231_CLE","1892231_UT","1566811","2156991_ALA","2156991_FLA","2156991_WV","2082581","2156991_UK","1566801","1892231_TEX","2156991_TEX","1557963","1931231","1833161","1566702","1908201","2011062","2156991_OS","2020121","2050431","1556943","1620803","1769681","1555501","1566703","1865971","1833192","1566812","2156991_CLE","1566802","2156521","1663801","2044121","1833191","1864001","1833162","2031931","1908631","1620804","2142311","1865972","1664102","1523731","1864002","1908632","2148731","2062261","1523741","1618283_S","1618263_S","2089531","1863981","1618263","1618283","2088852","1926971","1926972","2089741"],"men":["1533891","2156721","2187341","1011651","1011621","2157201","2118571","2165641","2173401","1476671","2173561","2179761","2176101","2173571","2175661","2178801","2120911","2174251","2173231","2169861","2141933","2174841","1836811","2174981","2173501","1837001","2118501","2157581","2149741","1011652","1287053","2078861","2179751","2195781","HYB2401","1287055","1011653","2155041","2155051","2096181","2120291","2172811","2172971","2174851","2194741","2001731","2040241","2165651","1772051","2174421","2155151","2180931","2173321","2176891","2067401","2012951","2135671","2120801","1577761","2174701","2179771","2174821","2173191","2182611","2195771","2174901","2164671","1556531","2173291","2099811","2148991","2182621","1388261","2117051","2148851","2173121","2128021","1990751","1011771","1287051","2094731","2173601","2173551","2180901","2174491","2172991","2157291","2173621","1536171","1955431","2012961","1987201","2173341","2089341","2001721","2098461","1286061","1577051","2001681","2178681","1638591","2175691","2175671","2175651","2175211","2157191","2157161","2155321","2173021","2174871","2174771","2172911","2174721","2174711","2174681","2174671","2157281","2165701","2165731","2174331","2174301","2155171","2174201","2174191","2156321","DGU0363","2123321","2156711","2155301","2173531","2173451","2172791","2173311","2157321","2164881","2173261","2173241","2173201","2173131","2099741","2172951","2172801","1503971","2160261","2173821","1653741","2174731","DGU0153","2030741","2126851","2174891","2169921","2172931","2173281","2120841","1594731","2172921","2173001","2156751","2142131","2173101","2173011","2174101","2120831","2174261","2161091","2079321","2123351","1826371","2173331","2126201","1768831","2157081","1577671","2175201","2172821","2173651","2108291","2176881","2173301","2079061","2157571","2121121","2173741","2136761","2136841","2090891","2174431","2172981","2175101","2142141","1639261","2175071","1768931","2173061","1575001","2158021","2173581","2174651","2174661","2157311","2161121","2089791","1491953","2078471","2157131","2157121","2120261","2157451","2157531","2086961","DGU0682","2181561","1447091","2118561","2156281","2120871","HYB2673","2114761","2108521","2071211","2120231","2108491","2097721","2157171","DGU0247","2156821","2165081","1836821","2100881","1411621","HYB2292","2157351","2118551","2078481","2156221","2124301","1441701","2155191","2159491","2165271","2123231","1536071","2165071","2156781","2013801","1714811","2160271","2120961","2157541","2095701","2120451","2157421","2156761","2121141","2125221","1441671","2089401","2120661","2156701","2156691","2156121","2090471","2070981","DGU0375","2097681","2156801","2142121","1872661","1653761","2115301","2157371","2142151","2156301","2063071","2094741","2103381","2135541","2125421","2155201","2134261","2033131","2105651","2136831","2120751","1805101","2086941","2076891","2145281","2121561","2126591","2100831","2078601","1552051","2063101","2120191","2120471","2136481","2145301","1617951","2012331","1438961","2077331","2158911","OCS0127","2012391","2161031","2157331","2157181","HYB2705","2159171","2119071","2181601","2157211","2149881","2156331","2157641","HYB2204","2078261","2156201","2118661","HYB2199","HUM0161","2156191","OCS0240","2078511","2157661","2155081","HYB2285","2103761","2148981","2155251","2093301","DGU0514","2140371","2149751","2125481","2153131","DGU0019","DGU0684","2076861","HYB2232","DGU0111","2157621","1791221","2149891","2159031","HYB2709","HYB2224","DGU0244","2135721","2156111","HYB2685","HYB2406","1781181","1411601","2134121","2121341","2126251","2158571","2135561","2164921","DGU0096","2159181","2120221","2126331","2126891","HUM0251","HYB2239","DGU0375_S","2159191","2136821","2156231","2135531","1957931","2125261","2089541","2154771","2090451","2090281","2010821","2093291","2155181","HYB2268","2121251","2144011","2141611","1661511","2125451","1011671","2158221","2078961","1673141","2158991","2121591","2134301","2108771","2123711","2095891","2097691","OCS0267_DB","2078971","OCS0289","2194742","2142134","OCS0265_AF","HYB2903","HYB2905","OCS0244_BO","OCS0292_SF","OCS0292_DB","HYB2900","OCS0289_SM","OCS0289_SFG","OCS0289_PPH","OCS0289_NYY","OCS0267_PS","HYB2907","OCS0293_AF","OCS0285_TR","OCS0285_PP","OCS0264_LAR","OCS0284_PP","OCS0284_LAD","OCS0267_NP","OCS0263_NOS","HYB2899","HYB2901","HYB2910","OCS0268_WC","OCS0268_TT","HYB2914","OCS0289_LAD","OCS0244_TR","OCS0270_NOS","OCS0268_PE","OCS0268_NP","OCS0268_NOS","OCS0268_MD","OCS0244_SM","HYB2904","OCS0226","OCS0268_LAR","OCS0268_SS","OCS0268_CB","HYB2913","OCS0268_PS","OCS0265_SF","HYB2902","OCS0289_BO","HYB2909","OCS0292_WC","OCS0263_SS","OCS0245","OCS0263_NP","OCS0244_PP","OCS0263_DB","HYB2906","OCS0214","OCS0263_WC","OCS0267_PE","OCS0265_DB","OCS0263_BR","OCS0268_SF","OCS0244_SFG","OCS0268_DB","OCS0263_PE","OCS0263_SF","OCS0289_CC","OCS0268_AF","HYB2911","OCS0265_CB","OCS0263_MD","OCS0267_SF","OCS0254","OCS0270_KC","OCS0194","OCS0284_SM","OCS0289_TR","OCS0265_GB","OCS0265_NYG","OCS0251","OCS0243","OCS0268_TBB","HYB2908","OCS0265_HT","OCS0270_TBB","OCS0268_KC","OCS0249","2181571","OCS0268_BR","OCS0299","OCS0307","MEI0011","OCS0253","OCS0284_BO","OCS0265_PS","OCS0275","OCS0265_NS","OCS0265_TT","HYB2246","HYB2897","HYB2896","HYB2895","HYB2894","HYB2661","HYB2243","HYB2227","HYB2654","HYB2888","HYB2887","HYB2262","HYB2885","HYB2884","HYB2883","HYB2882","HYB2666","HYB2886","HYB2282","HYB2878","HYB2877","HYB2853","HYB2866","HYB2863","HYB2649","HYB2681","HYB2881","HYB2648","HYB2889","HYB2822","HYB2821","HYB2650","HYB2215","HYB2670","HYB2667","HYB2693","HYB2691","HYB2690","HYB2688","HYB2686","HYB2212","HYB2203","HYB2245","HYB2211","HYB2890","HYB2677","HYB2269","HYB2852","HYB2823","HYB2274","HYB2674","HYB2241","HYB2660","HYB2680","HYB2293","HYB2867","HYB2672","HYB2205","HYB2252","HYB2659","HYB2216","HYB2272","HYB2664","HYB2233","HYB2708","HYB2893","HYB2824","HYB2859","HYB2001","HYB2880","HYB2820","HYB2002","HYB2706","HYB2655","HYB2665","HYB2662","HYB2676","HYB2657","HYB2898","HYB2879","HYB2286","HYB2653","HYB2707","HYB2682","HYB2652","HYB2668","HYB2240","HYB2276","HYB2249","HYB2892","HYB2678","HYB2298","HYB2679","HYB2253","HYB2281","HYB2289","HYB2283","HYB2200","HYB2402","HYB2410","DGU0433","HYB1998","HYB1997","HYB1995","HYB1993","HYB2000","HYB1991","DGU0624","2189561","HUM0304","HUM0303","DGU0524","HUM0300","HUM0297","HUM0289","HUM0264","2181001","2157431","DGU0526","HUM0249","HUM0246","DGU0634","HUM0020","DGU0686","HUM0261","DGU0475","2189511","2157071","2181001_TM","DGU0633","DGU0629","2181001_AHF","2189541","HUM0144","HUM0250","DGU0571","DGU0567","DGU0566","DGU0543","DGU0635","DGU0037","HYB1974","DGU0683","2189521","2156351","2189481","2160171","DGU0680","HUM0260","2189591","2157481","HYB0967","2189551","CIN0061","2156961_VT","2157471","2189571","2170091","2156851","HUM0302","DGU0066","2156871","2189471","2156131","DGU0248","DGU0441","2160161","DGU0535","2159011","2165251","2156831","DGU0262","DGU0249","DGU0063","DGU0602","2157021","DGU0095","2164521","2156681","2157251","2179781","2189501","DGU0609","2168971","2159151","CIN0028","2156571","2156841","DGU0572","2162101","HUM0305","2157061","2157681","2169841","2182141","2158581","2156651","2181581","DGU0685","2196221","2134371_FSU","2155261","2154781","2154761","2145331","2134371_SC","2134371_ALA","2134321_PSU","2134321_VT","2137401","2137351","2134321_UM","2137221","2137021","2137001","2136971","2136881","2134321_FLA","2134431_NEB","2136771","2136721","2134371_FLA","2136611","2135481","2134371_UGA","2134321_OK","2134431_AUB","2134371_TAM","2134321_TAM","2134431_UO","2134431_UM","2134371_LSU","2134791","2134531","2134431_TAM","2134431_MS","2134431_LSU","2134431_FSU","2134431_FLA","2134431_DC","2134371_UM","2134371_UT","2134431_ALA","2134371_DC","2136961","2136641","2134431_WV","2134371_UK","2109401","2134431_CLE","2134431_UGA","2134801","2134321_LSU","2133951","2134321_UO","2134431_TEX","2101351","2134761","2116161","2134321_OSU","2134321_ALA","2136941","2125541","2105031","2109441","2118601","2155271","2133981","2120171","2134321_UW","2120161","2125561","2134191","2125551","2100941","2128831","2133971","2120271","2126841","2134281","2128821","2133991","2142411","2137271","2100641","2125461","2143881","2101311","2134151","2105011","2134211","2134221","2131471","2128861","2134231","2134251","2137431","2142421","2134371_OK","2134371_OS","2054981_TAM","2098691","2098391","2097421_UT","2097421_UM","2097421_LSU","2054981_UGA","2097421_UGA","2096821_OS","2097421_FSU","2097421_FLA","2096821_TAM","2097421_ALA","2097401_FLA","2097401","2097281_TEX","2097281_TAM","2096821_FLA","2096821_FSU","2097221","2097011","2096821_MS","2096851_WIS","2096851_UGA","2054981_SC","2054981_TEX","2094981","2097421_TAM","2094161","2096851_ALA","2096841_WV","2096821_UGA","2087141","2096801_LSU","2096821_IW","2096841_FSU","2096841_DC","2096821_WV","2096821_WIS","2096821_UO","2096851_DC","2094191","2096851_TAM","2096801_UAB","2096821_NEB","2096821_DC","2096821_VT","2097421_UK","2094081","2054981_UT","2096801_TEX","2096821_UM","2098731","2096851_MS","2096851_PD","2054981_UM","2087371","2096841_TEX","2088781","2096801_UM","2088001","2096821_UT","2054981_UK","2097281_LSU","2094051","2054981_UO","2096821_TEX","2096841_PSU","2088031","2097421_DC","2071501","2096851_ND","2096821_LSU","2085131","2097281_OK","2088681","2086891","2085291","2090901","2079111","2089591","2096321","2088081","2088121","2096841_LSU","2086261","2086971","2088631","2096311","2096911","2093151","2096761","2086221","2079411","2088761","2088551","2096841_TAM","2095741","2054981_UW","2054981_VT","1929591_TAM","2054981_OK","2054981_NC","2054981_MS","2054981_LSU","1913151_CLE","1913151_FSU","1892241_TAM","1929591_OK","2054721","2050931","2054981_CLE","2031111","2027291","2013311","2012821","1990181_ALA","1929591_FSU","1913151_SC","1990181_TEX","1990181_TAM","2054981_FSU","1990181_LSU","1990181_FSU","1913151_TAM","1990181_CLE","1929591_ALA","1929591_ARK","2054981_ALA","1958291_TEX","1958291_FLA","1929591_UGA","1954451_FSU","1954451_LSU","1892211_FLA","1954451_UGA","1954451_TEX","1954451_TAM","1954451_SC","1990181_UGA","1913151_FLA","1954451_FLA","1913151_ALA","1892241_ARK","1954451_NC","1892211_TAM","1892211_UM","1929591_LSU","1929591_UK","1913151_UK","1913151_ARK","1892211_UK","1892211_LSU","2040231","1892241_SC","1954451_DC","1929591_DC","1929591_UT","1892211_CLE","2054981_OSU","1892241_ALA","1913151_LSU","1892241_CLE","1892241_UK","1929591_TEX","2054981_DC","1892211_UGA","1929591_FLA","1892241_UGA","1954451_UT","1892211_OK","1913151_AUB","1990181_UT","1990181_FLA","1892211_UT","1892241_UT","1892211_FSU","1990181_DC","1913151_MS","1892241_OK","1892211_TEX","1892211_UO","1954451_UK","1913151_UT","1954451_MS","1913151_TEX","1958291_UT","1892211_DC","1990181_SC","1913151_UGA","1992911","1913151_DC","1905451","1954451_ALA","1954451_ARK","1954451_AUB","1954451_OK","1954451_OSU","1954451_UM","1954451_UO","1277021_ALA","1892211_ALA","1892201_UT","1892201_UGA","1892201_TEX","1277021_CLE","1277021_UK","1277021_TAM","1892211_ARK","1861581","1809851_UK","1277021_ARK","1809851_TEX","1802051","1794791","1792581","1892201_SC","1638601","1277021_UGA","1625621","1625231","1638571","1561651_WIS","1561651_OK","1892201_DC","1883371","1809851_UGA","1277021_TEX","2174823","1277021_WV","1277021_UT","1892201_FLA","2173233","2136763","2174842","1277021_OK","1277021_LSU","1277021_FLA","1277021_DC","2174262","2117052","1559041","2174253","2173192","2013803","2160264","2160274","2157294","1772054","1625233","2142124","2160273","2089793","2142144","2089343","2174902","2086963","1533894","2078473","2120293","2174263","1577765","1561651","2174903","2157374","2174252","1653764","1746411","1556533","2173604","2156291","2174822","1388263","1352471","1552054","2173622","2001733","2173603","1011623","2173103","1990753","1553511","2001723","1286064","1536174","1577674","1577052","1577054","2078482","1617954","1768934","2173102","2173623","1955433","1478231","2001683","1476673","2174302","2174303","1620191","1277023_UGA","1533893","1536173","1286062","2096182","2040233","1277023_DC","1277023_TAM","1638594","2118572","2117053","2136963","2118503","1577764","2103382","1011622","1892213_TEX","1277023_TEX","1277023_UT","1772053","2001682","2136964","2160263","2012963","2089593","2085293","1892213_ALA","2125423","2125552","2157324","2157295","2118562","2125452","2089543","2087373","2125563","2125553","2125543","2125483","2090453","2125562","2125422","2125453","1892213_LSU","2088553","2090283","1892213_UGA","2088123","2135722","2125482","2090473","2134282","2105652","2125542","2142413","1639263","1553517","2086943","2120292","2156292","2097724","2142412","2165083","2125462","2096913","2125463","2165073","1411605","1892213_DC","1011773","1491956","2012955","2088043","2120754","2142424","2089342","2136762","2088763","1411626","2170092","2001732","1388262","2136843","2157373","2125262","2144462","2124305","1990752","1768833","2097693","2156302","2142423","2125263","1768933","1577673","1478233","2136842","1955432","1476672","1277023_CLE","2040232","2123352","2120753","2118602","2105653","HYB2669","2156961_UGA","2012393","HYB2208","2096842_PSU","2095893","HYB2238","2090452","2090282","2089792","2089592","1638603","HYB2220","1277022_TAM","2088122","2088083","HYB2225","2088002","2087372","1277022_UGA","DGU0632","OCS0244_NYY","OCS0244","2156961_UK","2085132","2040242","1638593","HYB2692","HYB2267","OCS0270_HT","2012333","2001722","1892212_DC","1805102","2156961_UM","1653743","HYB2860","2157441","HYB2683","OCS0261","HYB1896","HYB2675","HYB2231","2089542","OCS0257","2164672","HYB2684","2096842_UW","HYB2912","2013802","2165652","2181591","HYB2007","2085292","2089402","2086892","1277022_DC","2086972","2164882","1277022_TEX","1411604","HYB2257","2097723","HYB2409","OCS0284_CC","2165642","HYB2242","1625232","2140372","HYB2405","HYB2689","2090472","2030742","2086942","1011772","2088042","1411625","2088552","OCS0285_NYY","1553516","2108561","1653763","1556532","2124304","2130691","2096912","1552053","1617953","1639262","2086962","1478232","2136671","2097692","1277022_CLE","1277022_FSU","1929591_CLE","2156961_TAM","2156961_PSU","2156961_OS","2156961_OK","2096821_CLE","2054981_FLA","2074311_TAM","2120891","2134371_TEX","2134371_CLE","2097281_AUB","2134341_UT","2134341_UM","2134341_UGA","2134341_PSU","1892211_SC","2134341_WIS","2118701_ALA","2134321_NEB","2134321_ND","2097401_ND","2134321_IW","2134321_DC","2118701_FLA","1892211_NC","2156961_TEX","1892201_ALA","2096821_AUB","2118701_SC","2118701_FSU","1929591_MS","2113721","2096821_OK","2118701_UT","2107471","2103741_UO","2100651","2097471_TAM","1892201_LSU","2118701_UGA","2096821_ARK","2134321_UGA","2096821_PD","2134341_OSU","2134321_MS","2096851_VT","2134341_MS","2096841_UO","2096821_PSU","2096821_UK","2096821_SC","1892201_TAM","2097281_UK","1958291_ALA","2096851_CLE","2156961_ARK","1561651_ALA","1892211_AUB","1958291_TAM","2097281_UGA","1892201_NC","2096821_WAZ","2165702","2096821_ALA","1958291_LSU","2120861","2097281_UT","2096841_ALA","2096821_ND","1929591_UM","2096821_OSU","1892211_OHIO","1561651_UT","2096851_NC","1958291_UK","2133931","2096851_UW","1892201_UK","2097401_UT","2054981_OS","2097281_UM","1958291_OS","2142211","1553631","1892201_OS","2115081","2096841_UT","2077341","2142154","2096841_OSU","2136491","2097321_UO","2142291","2088771","2063431","1929591_SC","1954451_OS","2086241","2096841_UM","1277023_FLA","2067402","1957914","1553632","2128022","1892213_TAM","2096842_LSU","2096822_WAZ","1892212_TAM","2148852","2063072","1277022_LSU","2108492","1673142","2153132","2063102","2096823_OS","1277023_LSU","2096822_CLE","2148982","2126852","2096822_UO","2164922","2143882","2096822_UT","2096823_WAZ","1892212_ALA","2096842_ALA","1892212_FLA","2157325","2156293","2096823_UO","2096823_UM","1781182","1892213_SC","2096843_UT","2096843_UM","2096843_TEX","2096843_TAM","1892213_FLA","2096823_CLE","1892213_ARK","2096842_TAM","2096823_ALA","2096842_UT","2096822_UM","2096822_OS","2096822_ALA","2096822_OSU","1746412","1277022_FLA","2088084","2109442","1791222","1892212_NC","1892213_FSU","2108292","2118563","2099742","2096823_OSU","1892212_LSU","2076862","1892212_TEX","1892213_UT","1892212_UT","1892212_UGA","2096842_MS","2096823_DC","2096822_DC","2134283","2088633","2096842_FLA","2101352","2096842_TEX","1594732","1277022_UT","2096843_ALA","1892213_UK","2148992","2096842_UM","1794792","2144463","2088762","2096842_ND","2103383","2100832","2076892","2157423","1872662","2141612","2141932","2135672","2125222","2097682","2142292","2182142","1277022_ARK","1277022_OK","1277023_ARK","1277023_OK","2100642","2179782","2159492","2105012","2100652","2108522","2077342"],"sale":["2086711","1533891","1885751","2118571","2116531","2116331","2117971","1577051","1287051","2090141","2093901","2141933","2148991","2086371","2160211","2119141","2160221","2119751","2093111","1987161","1987201","1372111","2098501","2092991","2154711","2103412","2086712","2078601","1836811","1011652","1577052","2114811","2119791","GSO0053","1837001","1388263","1011653","2108291","2079321","2125341","2118961","2124281","2181901","2118501","2157581","2078861","2125331","2001791","2116511","HYB2401","2096181","2120291","2120841","2162251","2149011","1709221","2130901","2035361","2012951","2001591","2120831","2135671","1577761","2103411","2116671","2001611","1556961","1556531","2093161","2125571","1388261","2114801","2117051","1275701","1799081","2156721","2086701","2148851","1990751","2125441","2125271","2094731","2159691","1536171","2012961","1907601","2051791","1011651","2089341","2001721","1738161","1011621","2125321","2149741","1538021","2098461","2092231","1286061","1476671","2086631","2093211","2157201","2114821","2070251","2135311","2196561","2157161","2001801","2155911","2089391","2118241","1653741","1955431","2119271","2119251","2158031","2118561","2118231","2078481","1275711","2089931","1618281","2090151","2155701","2114061","1768831","1547181","2120911","2136761","2161121","2160261","2086131","2156321","2118251","2101071","2157571","2156751","1491953","2035471","2115921","1675321","2118261","2140402","2119171","1987791","2161051","2119451","2116371","2156701","2135881","2116031","2131481","1503971","2196551","1372113","2118921","2030741","2118301","1872661","2156291","2119641","2118591","2155451","2142131","2070351","2159241","1955441","1772051","2157531","1652541","2149721","2181561","2183121","2120801","2161091","2123351","2078471","1574731","2126201","2120751","2156281","1510453","2086411","1574732","2078561","1510631","2086961","2001802","2121121","1534111","2090891","2142141","2119321","1768931","2090142","2120471","1510451","2157291","1933601","2001681","2157131","2155831","2155821","2157121","2155731","2154941","2098621","2118281","2119281","2097721","2121561","2155381","2157751","2155741","2072571","2119191","2158071","2114761","2072351","2121741","2125371","1805101","1577671","2158121","2165081","2157321","2116001","2115991","2115931","1411621","2155151","2160981","2155421","2121751","2090152","2001731","2155901","2120661","1510633","1836821","2119971","2157351","2118551","2164461","2121771","2165271","2156221","2155191","2136241","2156781","2160231","1714811","1990261","2158111","2157541","2123321","2116491","2156761","1802201","2126071","2119961","2154741","1826501","2156691","2001781","2062531","2115261","2156121","1867041","2108521","2070981","2125391","2158641","2159111","2156801","2108261","2124301","2070271","2156301","2063071","2160651","2094741","2135541","2155201","2119611","2033131","1618261","2118221","2136831","2062701","2126591","2123011","2125621","2120191","1799084","1639261","2001792","2155481","1618282","GSO0109","2159091","2157311","2155721","2078261","2159081","2120871","2159101","2165071","1837101","2156441","2158051","2157451","2160271","2118661","2120421","2035521","2155521","2157171","2164451","1833151","2118581","2123231","2070601","2001521","2155691","2156821","2154531","1495921","2062241","2062521","2120261","OCS0127","2113671","2120231","1959881","2090471","2158451","2157901","2120451","2155891","1713191","2155321","2159501","2159051","2157911","2158911","2156331","2154561","2159491","1833201","2159171","2001771","1987961","2140391","2155681","2120961","2095701","2157421","2081121","2157211","2121141","2113681","2125221","2159191","2136821","1438961","2156231","2156201","2156641","2077331","2154411","GSO0006","2089941","2181601","DGU0375","2097681","2121311","1990451","2121221","1653761","2157371","1527892","2134261","2108631","GSO0008","2134301","2108271","2145281","2001793","2001803","2108771","2118252","2136841","2115902","2123711","2149121","1510454","2116051","1799082","2145301","2164421","2119591","2154751","2158041","2161031","2154451","2157091","2157971","2120221","2157051","2121341","2162241","1867042","OCS0114","2154401","2155811","2155671","2155661","2157331","2148981","1991401","2116561","1990262","2084991","2157181","2119691","1957931","2149751","1713193","2135561","2121251","2119071","OCS0240","2126331","2159131","2126061","1618262","2126251","2097691","2078511","2154571","2157661","2070611","2155251","1840131","2159121","1987991","2116021","2121761","2123821","OCS0255","HYB2232","2156481","2157621","2155851","2159031","2156111","2156541","1527891","2085191","HYB2406","HUM0161","1836571","2182151","2134121","1931232","GSO0046","OCS0258","2154891","2159181","2126891","HUM0251","2141621","2156631","GSO0133","2154771","1833202","GSO0119","2148721","2155181","2144011","2141611","2121521","GSO0043","2115922","2094421","2070772","2158991","2070771","2121591","2157081","2001782","2156191","2158211","GSO0030","2116052","CIN0088","2169961","1510636","2095891","OCS0272_DB","OCS0265_AF","OCS0244_BO","OCS0266","OCS0272_SF","OCS0272_AF","OCS0272_PE","2157641","2181571","1833152","2158101","2148911","OCS0307","OCS0293_AF","OCS0264_LAR","OCS0267_NP","OCS0263_NOS","OCS0289_LAD","OCS0244_TR","OCS0289_SM","OCS0289_SFG","OCS0289_PPH","OCS0289_NYY","OCS0270_NOS","OCS0244_SM","OCS0289_BO","OCS0285_TR","OCS0285_PP","OCS0284_SM","OCS0284_PP","OCS0284_BO","OCS0226","OCS0268_LAR","OCS0273_NOS","OCS0273_MD","OCS0273_KC","OCS0273_HT","OCS0272_WC","OCS0272_TB","OCS0265_SF","OCS0263_SS","MEI0064_S","OCS0245","OCS0263_NP","OCS0244_PP","OCS0263_DB","OCS0263_WC","OCS0267_PE","OCS0265_DB","OCS0263_BR","OCS0268_SF","OCS0244_SFG","MEI0064","OCS0263_PE","OCS0263_SF","OCS0289_CC","OCS0265_CB","OCS0263_MD","OCS0267_SF","OCS0268_PE","MEI0063","OCS0270_KC","OCS0289_TR","OCS0265_GB","OCS0265_NYG","DGU0684","OCS0251","MEI0058","MEI0057","OCS0243","OCS0305","OCS0268_TT","OCS0265_HT","2157821","OCS0270_TBB","OCS0268_KC","OCS0249","OCS0256","OCS0268_BR","OCS0299","OCS0268_WC","OCS0247","MEI0062","OCS0272_CB","MEI0048","OCS0265_PS","OCS0273_TBB","OCS0275","DGU0375_S","2148722","OCS0306","2125261","OCS0265_NS","MEI0066","MEI0065","OCS0304","OCS0265_TT","OCS0272_NG","2094431","2108831","HYB2649","HYB2650","HYB2667","HYB2245","HYB2693","HYB1995","HYB2672","HYB2686","HYB2682","HYB2681","HYB2677","HYB2676","HYB2673","HUM0246","HYB2659","HUM0261","MEI0037","DGU0633","GSO0019","HYB2402","HYB2298","HYB2272","HYB2252","HUM0020","HUM0144","HYB2203","HYB2002","HYB2001","HYB2000","HYB1998","HYB1997","HUM0250","HYB2240","HYB1991","HYB1974","HYB0967","HUM0305","HUM0304","HUM0303","HUM0297","GSO0170","HYB1993","HUM0260","GSO0095","GSO0136","HUM0259","GSO0126","GSO0169","GSO0102","GSO0042","GSO0135","GSO0129","HUM0249","GSO0096","GSO0165","GSO0094","GSO0137","GSO0041","HUM0264","GSO0134","HUM0302","GSO0025","GSO0026","GSO0171","GSO0131","GSO0125","GSO0098","HUM0300","DGU0249","DGU0431","GSO0132","GSO0130","GSO0099","GSO0097","GSO0044","GSO0144","GSO0120","GSO0168","GSO0146","MEI0011","HUM0289","ITD0006","GSO0124","GSO0123","GSO0143","GSO0020","GSO0140","ITD0016","GSO0145","HYB2410","GSO0049","GSO0021","GSO0139","GSO0045","MEI0043","GSO0091","GSO0009","ITD0021","GSO0050","DGU0685","2097421_UGA","2189561","2097421_ALA","2181001","2157431","2096851_UGA","2097421_TAM","CIN0048","CIN0030","CIN0014","AHM0016","AHM0015","AHM0014","2157071","2097421_FSU","2159071","2189541","2118721_UO","2097421_UK","2189521","2189511","2189501","2189481","2154951","2156511","2182162","2182161","2182141","2181581","2181001_TM","2181001_AHF","2136961","2156351","2169871","2169841","2168971","2165251","2164441","2164351","2109401","2154881","2189591","2117151","2157481","2158151","2158421","2097401","2136971","2189551","2096851_WIS","2155391","2156961_VT","2157471","2189571","2132221","2170091","2156851","2097421_DC","2118601","2156871","2189471","DGU0248","2156971_ALA","2137001","2096851_ND","2159011","2134421","2156831","2144021","2097281_OK","2157021","2156681","2149001","2157251","2157691","2097421_UM","2117152","2159151","2156571","2156841","2156421","AHM0013","2137021","2109421","2154781","2154761","2121781","2157061","2158581","2145291","2156651","2183122","2121511","CIN0073","2148732","CIN0074","CIN0077","CIN0080","CIN0086","CIN0087","HYB2669","HYB2238","DGU0566","2096821_TAM","1892201_SC","DGU0624","DGU0524","2096821_IW","2096821_FSU","2096801_UM","2096801_UGA","2096801_UAB","2094211","2054981_SC","DGU0634","2054981_NC","DGU0475","2096821_UGA","1990181_UT","2054721","2012821","2001783","2001773","2096821_NEB","2096821_VT","1990181_SC","1987962","1958291_UT","1929591_UK","1929591_TEX","1913151_UK","DGU0635","DGU0577","1913151_CLE","1892241_UGA","1892241_CLE","1892241_ARK","1892211_OK","1892201_UT","1794791","DGU0683","1809851_UGA","2096851_MS","DGU0682","DGU0680","1913151_TEX","DGU0636","DGU0247","1913151_UGA","1892201_TEX","2054981_UK","DGU0542","1833161","DGU0514","2096841_PSU","DGU0534","DGU0111","DGU0578","DGU0571","2096851_ALA","1769681","DGU0154","DGU0686","DGU0619","2071501","DGU0535","1833192","DGU0244","DGU0618","DGU0602","1663801","DGU0363","1833191","DGU0567","DGU0609","2001772","DGU0096","1833162","HYB2689","DGU0572","OCS0285_NYY","2115101","2079421","2071211","DGU0620","DGU0580","1561651","DGU0576","DGU0257","2092981","DGU0153","1277021_OK","2103381","2062261","1618283_S","1618263_S","1618263","2118931","1618283","2136671","2113721","DGU0632","2158042","2070252","2096821_WAZ","DGU0533","DGU0372","DGU0095","DGU0066","DGU0063","DGU0037","2148731","2142291","2116492","2154943","2114062","2096851_NC","2114822","2072352","2119752","2118243","2161842","2098502","2113672","2116332","2125322","2086702","1275712","2086372","1885754","1538022","2116532","2119192","2093162","1556962","2092982","2160222","2001592","1275702","2119172","2116512","HYB2413","DGU0441","2155382","2155392","DGU0374","DGU0262","2118922","1547182","2116672","2158122","2181902","2155452","2130902","2092232","2125332","2135882","DGU0104","2160213","2092992","1802203","2085652","2136242","2160232","2086132","1577663","2086982","2125342","1372122","2155852","2113692","2125372","1955442","2126073","2119612","2113901","2114812","DGU0103","2125572","2119642","2118232","1819792","2118932","2125442","2086981","2001612","2086412","2114802","1372112","2051792","1907604","2035362","1577054","2076891","2125272","2164732","2089921","1568031","1933602","1287055","2054981_FSU","1929591_ALA","1954451_FSU","1954451_NC","HYB2269","2116291","1929591_FLA","2097071","1536174","1286064","2087831","2105651","2120293","1892211_UT","2054981_UT","1954451_UK","1954451_MS","2118562","2133951","2154481","1955433","2115301","2136481","2157324","2088031","2097021","HYB2268","2117052","2001723","2001683","2164431","2160263","OCS0289","2157374","1372123","2126581","2115932","2136763","2155081","1892213_UGA","2155271","2089201","2118572","1541251","2118503","1639263","2120292","2156292","2165083","2157294","2165073","1491956","1533894","2096182","1577661","2120754","2089342","2103771","1577765","2124304","2136762","2170092","2001732","1388262","1372121","2126851","1653764","2113691","2157373","2125262","2144462","2124305","1990752","2001733","1768833","2097693","2156302","2103382","1819791","1533893","2117053","1577764","1536173","2085651","2125263","1577674","2078482","2108431","1768933","1577673","1768934","1287053","1286062","2136842","2001682","2142421","1955432","2101081","1476673","1476672","2118701_SC","2118701_FSU","2096821_CLE","2120891","2134341_WIS","2118701_ALA","2134371_CLE","2001722","1653763","1639262","1556532","1478232","1411604","2156961_UGA","2118701_FLA","2156961_PSU","2156961_TEX","HYB2208","2096821_AUB","HYB2257","2085311","2116571","2130711","2096821_OK","2118701_UT","OCS0284_CC","OCS0270_HT","OCS0261","OCS0244_NYY","OCS0244","OCS0193","2156961_TAM","HYB2220","HYB2684","HYB2683","HYB2675","HYB2409","HYB2405","HYB2267","2118701_UGA","2096821_ARK","HYB2225","2096821_PD","2134341_OSU","2096821_UK","2096821_SC","2097281_UK","2096851_CLE","2156961_ARK","2158131","2156961_UK","HYB2692","OCS0290","2156961_UM","2096821_ALA","2120861","2097281_UT","HYB2860","2157441","2134341_UT","2103741_UO","HYB2231","2096842_UW","2181591","2156961_OK","HYB2007","1931231","2133931","2096851_UW","GSO0103","2157801","2107471","2156961_OS","2054981_OS","2097281_UM","2142211","2156521","2096843_UM","2115081","2121261","2120753","2077341","2118602","2062741","2130731","2108561","2115091","2123352","2142311","2108811","2130691","2085451","2063431","2156971_OS","2086962","2089531","2095893","2097692","2149711","2088852","2054981_FLA","2096842_LSU","1892201_ALA","2027421_UK","1892201_TAM","2096842_ALA","2027421_UT","1958291_TAM","1958291_OS","1958291_LSU","1958291_ALA","1929591_MS","1929591_CLE","2096843_TEX","2027421_TAM","2096842_TAM","2096842_UT","2027421_UGA","2096822_UM","1534113","1738162","2116372","2135312","2027421_LSU","2157325","1011623","1556533","2086963","1011622","1772053","2149002","2108432","2126852","2157295","2136843","1478233","1553632","2148992","2108292","2118563","1958291_UK","1892213_UT","2159492","1892201_UK","2096842_MS","2096823_DC","2096822_DC","1277021_AUB","2096843_TAM","2063072","2096843_UT","2078552","2141622","2096842_TEX","2096843_ALA","1892213_UK","1794792","1553631","2144463","2096842_ND","2103383","1892201_OS","2076892","2119692","2156293","2157423","1957914","2090472","1872662","2062702","2148982","2141932","2135672","2125222","2148912","2108522","2097682","2077342","1617953","2142292","2182142","2158061"],"women":["2196541","2174361","2174321","1538021","2035361","2196501","2165791","2173471","1372111","2169891","2177611","2121121","1836811","2173481","2176091","2116531","2171361","2173991","2175661","2158021","2171401","2170771","1987161","1718821","2174341","2175511","2180781","2116331","2170841","2135814","1372112","2117971","2172671","2172571","2165771","2086371","2160211","2173461","2160221","2119751","2093111","2187351","2173921","2170781","2165781","2092991","2172541","2174391","2171391","2154711","2196841","2114811","2133711","2119791","2118961","2113901","2173641","1275711","2170831","2165871","2118921","2092981","2161821","2077801","2162251","1709221","2196851","2130901","2196871","2001591","2196941","2173901","2103411","2171301","2173801","2134891","2116671","2173691","2177621","2118241","1556961","2093161","2173391","2125571","2114801","1275701","1534111","2086701","2125441","2159691","2086711","1885751","1907601","2051791","2148911","1738161","2125321","2092231","2098501","2086631","2165841","2155841","2172731","2196861","2196831","2170851","2170711","2178801","2178751","2178161","2175691","2175671","2175651","2175581","2175451","2155671","2114821","2179691","2174991","2174641","2155901","2170751","2174561","2174381","2155741","2174031","2173961","2171451","2101071","2173861","2173731","2119281","2119271","2158121","2158001","2173871","2173941","2079171","2170741","2171381","2103591","2172681","2119141","2135811","2155911","2175001","2155751","2087061","2170721","2182631","2119451","2086671","1802201","2165861","2088641","2142381","2165891","2116371","1577661","2079181","2125341","2154971","2172781","2089391","2172771","2124281","2174051","2154411","2133701","2131481","1372113","2169931","1547181","2125391","2125331","2089071","2116511","2172561","2173701","2118591","2155451","2125371","2086981","2149011","1424692","1819791","1799751","2173411","2108431","2086411","2173711","2123011","2175101","2175071","2125271","1862581","2101081","2171441","2174621","2174631","2154531","2116291","2155831","1933601","2085651","2155821","2155731","1955441","2155651","2161051","2086131","2078561","1652541","2119321","2114061","2154941","2118581","2155721","2119251","2093211","2087081","2154481","2070251","2120471","2098621","2155701","2070351","2135311","2157901","2158031","2149721","2087001","2119191","2158071","2155521","2155381","2164451","2001521","2072351","2155691","2101361","2113671","2160981","2155421","1836821","2157751","1738151","2118231","1959881","2164461","2142391","2136241","2160231","2052381","1714811","2140402","2155681","2119171","1987791","2086651","2158111","2120451","2116491","2121141","2113681","2126071","1447091","2154741","1826501","2103771","1837001","2158051","2135881","2062531","2115261","1495921","1503971","2181901","1837101","2062521","1372121","2070981","2158641","2158451","2113691","2119641","AHM0001","2121221","2078551","2070271","2159241","2135821","2160651","2128031","2119611","2118221","2062701","2001611","2078601","2155481","2164421","2126061","1788661","2081121","DGU0154","2037614","2119591","2149901","2158911","2159501","2155891","HYB2715","2120421","2121311","2135771","2154751","2012301","2158041","2159191","2149121","1639031","2154451","2156641","1554171","1781141","2140391","2085961","OCS0114","2154401","2157091","2155811","2155661","2164431","2084991","HYB2718","2085901","1639021","2012291","HYB2719","2078511","2153141","2087041","1840131","2089041","2159131","2123821","OCS0255","2085021","1372123","2116561","2146791","2086421","2155851","2157911","2119691","2157821","2159031","2159171","2089201","2089731","2135281","2085761","2158531","DGU0618","2085191","2089451","1836571","2162241","2182151","2052431","2128851","2121341","1911321","2158571","2089561","2135791","1575461","OCS0258","2089371","2096351","1862541","2141621","2075121","DGU0620","2156631","1991401","DGU0576","2133581","DGU0257","2157971","2126581","2021771","2125531","2143961","2157051","2121521","2094421","2108631","2158991","2158211","2154421","2154831","OCS0272_SF","2145451","2158101","OCS0272_AF","OCS0272_PE","OCS0304","OCS0273_TBB","OCS0273_NOS","OCS0273_MD","OCS0273_KC","OCS0273_HT","OCS0272_WC","OCS0272_TB","2136731","2164931","HYB2714","OCS0272_DB","OCS0272_CB","2135781","DGU0631","OCS0247","MEI0064_S","2136931","HYB2717","HYB2716","HYB2713","GSO0019","GSO0131","GSO0130","2156971_TAM","DGU0635","DGU0037","2137421","DGU0577","2154951","2137321","DGU0525","DGU0533","DGU0544","2164441","MEI0064","DGU0372","2135831","2137511","2158151","DGU0636","2136691","2158421","2155391","DGU0542","2164721","2136631","2137291","OCS0305","DGU0578","2158551","2137531","GSO0025","OCS0256","2156971_ALA","2164351","DGU0619","DGU0535","2154511","2159011","DGU0374","2144021","2136321","2149001","2157691","DGU0104","2143891","2168971","2159151","2156971_UGA","2162111","2156971_LSU","2156971_TEX","2156971_UK","2137521","OCS0306","DGU0580","GSO0021","2169871","2144531","DGU0103","2158581","2145431","2133541","2133681","2144491","2145291","OCS0272_NG","2145421","CIN0073","CIN0074","2108831","2136171","2097421_FLA","2119151","2085791","2134431_WV","2134431_UO","2119711","2097421_LSU","2134431_TEX","2134431_TAM","2134431_NEB","2134431_MS","2134431_LSU","2134431_FSU","2134431_FLA","2134431_DC","2085301","2097421_UGA","2085231","2134421_UT","2134421_DC","2085321","2116581","2133591","2133521","2134431_AUB","2133491","2133481","2097051","2097421_ALA","2127251","2126531","2097421_UT","2094201","2097421_TAM","2094171","2094031","2125521","2094061","2097421_FSU","2119311","2135221","2094751","2118721_UO","2094091","2097421_UK","2100311","2134431_ALA","2085831","2134431_UM","1982011","2133411","1913151_TEX","2134431_CLE","2134431_UGA","2085641","2085921","2133501","2118721_ALA","2086401","2105141","2086071","2089191","2133671","2134861","2100351","2085681","2094071","2094211","2132221","2079191","2121541","2086681","2097421_DC","2100361","2116401","2093221","2100381","2096811_UO","2099271","2085611","2085081","2099261","2071501","2134421","2135101","2085031","2075111","2058361","2055311","1975921","2097421_UM","2085051","2053371","2079141","2119651","2079421","2092911","2109421","2093151","2085661","1892241_ARK","2087082","2087002","1862561","1862551","2174383","1682201","1625971","1465351","1464091","1185181","2118931","2144541","2170782","2125322","2162243","2170832","2072571","2174363","2174342","2135312","2135793","2171442","2171302","2174323","2170772","2164722","1911181","1911251","2161822","2142383","2133704","2105142","2085032","2116332","1862391","2116532","2119192","2196542","2119172","HYB2413","1547182","2133544","2116672","2174393","2113902","2162252","2155452","2130902","2092232","2125332","2086702","2135882","1275712","2160213","2092992","2160222","2135824","2093162","1802203","2086132","2086982","2125342","1372122","2113692","2086372","1955442","1738162","2116372","1275702","2126073","2173714","2114812","2125572","2119642","2118232","2118243","2086712","2176093","2118932","2092982","2103412","2001612","2086412","1744621","2114802","2001592","1534113","2051792","2119752","2098502","2035362","2173441","1885754","1538022","1556962","2125272","2164732","2161842","1933602","2089042","1639033","2119301","2052382","1907604","2085902","2085082","2114822","2154943","2136242","1738152","2125442","2160232","2181902","2158061","1639023","2085232","2156981_TEX","2136172","2135782","2027421_UK","2116431","2133712","2133682","2099272","2119713","2119612","2085962","2027421_UT","2116402","2114062","2085922","2089202","1781142","2158131","2156981_UGA","2158042","2070252","OCS0290","2027421_UGA","2086672","1788663","2089393","2085642","2089192","2089452","2086682","2058362","2116492","2085022","2133502","OCS0193","2133621","2086422","2085832","2072352","2113672","2094752","2135282","2165792","2088642","2156981_LSU","2085612","2087043","2157801","2165842","2165772","2116512","1799754","2155382","2155392","2089562","2118922","2165782","2158122","2021772","2085762","2089372","2089732","2052432","2121261","2085652","2062741","1577663","2116571","2130731","2085311","2115101","2155852","2125372","2115091","2130711","2134892","2108811","2156971_UT","1862584","1819792","2085451","2156971_OS","2149711","2125522","2086072","2133592","2171454","2154513","2027421_TAM","1554172","2077802","1718822","2079182","2108432","2078552","2103592","1424694","2078562","2143892","2164932","2027421_LSU","2153142","2149002","2079172","2128032","2141622","2125532","2144532","2101362","2079192","2075122","2119692","2075112","2135224","2062702","2148912","2085662","2133492","2085683"]}
|
tasks/columbia/environment/reference/clone/data/messages-en-US.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tasks/columbia/environment/reference/clone/data/plp-visnav.json
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"women": [
|
| 3 |
+
{
|
| 4 |
+
"label": "Jackets",
|
| 5 |
+
"href": "/c/womens-jackets/",
|
| 6 |
+
"asset": "2500648_C_NA_May_Visnavs_NewArrivals_Jackets"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"label": "Dresses",
|
| 10 |
+
"href": "/c/womens-dresses/",
|
| 11 |
+
"asset": "2500648_C_NA_May_Visnavs_NewArrivals_Dresses"
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"label": "Tops",
|
| 15 |
+
"href": "/c/womens-tops-shirts/",
|
| 16 |
+
"asset": "2500648_C_NA_May_Visnavs_NewArrivals_Tops"
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"label": "Bottoms",
|
| 20 |
+
"href": "/c/pants-women/",
|
| 21 |
+
"asset": "2500648_C_NA_May_Visnavs_NewArrivals_Bottoms"
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"label": "Shoes",
|
| 25 |
+
"href": "/c/womens-shoes/",
|
| 26 |
+
"asset": "2500648_C_NA_May_Visnavs_NewArrivals_Shoes"
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"label": "Accessories",
|
| 30 |
+
"href": "/c/accessories/",
|
| 31 |
+
"asset": "2500648_C_NA_May_Visnavs_NewArrivals_ACE"
|
| 32 |
+
}
|
| 33 |
+
],
|
| 34 |
+
"men": [
|
| 35 |
+
{
|
| 36 |
+
"label": "Jackets",
|
| 37 |
+
"href": "/c/mens-jackets-coats/",
|
| 38 |
+
"asset": "2308014_CA_Jackets_Mens_VisNav_Slot04"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"label": "Shirts",
|
| 42 |
+
"href": "/c/shirts-men/",
|
| 43 |
+
"asset": "2279348_COL_US_Q1-Q2_SpringSummer_NewArrivals_Visnav_Mens_Shirts"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"label": "Bottoms",
|
| 47 |
+
"href": "/c/mens-bottoms/",
|
| 48 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_MensBottoms"
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"label": "Shoes",
|
| 52 |
+
"href": "/c/shoes-boots-mens/",
|
| 53 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_MensShoes"
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"label": "Accessories",
|
| 57 |
+
"href": "/c/accessories/",
|
| 58 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_MensACE"
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"label": "Big & Tall",
|
| 62 |
+
"href": "/c/mens-big-tall/",
|
| 63 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_BigTall"
|
| 64 |
+
}
|
| 65 |
+
],
|
| 66 |
+
"kids": [
|
| 67 |
+
{
|
| 68 |
+
"label": "Boys",
|
| 69 |
+
"href": "/c/boys-outdoor-clothing/",
|
| 70 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_Boys"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"label": "Girls",
|
| 74 |
+
"href": "/c/girls-outdoor-clothing/",
|
| 75 |
+
"asset": "2500648_C_NA_May_Visnavs_NewArrivals_Girls"
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"label": "Toddler",
|
| 79 |
+
"href": "/c/toddler-outdoor-clothing/",
|
| 80 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_Toddlers_v2"
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"label": "Infant",
|
| 84 |
+
"href": "/c/toddler-outdoor-clothing/",
|
| 85 |
+
"asset": "2279348_COL_US_Q1-Q2_SpringSummer_NewArrivals_Visnav_Infant"
|
| 86 |
+
}
|
| 87 |
+
],
|
| 88 |
+
"footwear": [
|
| 89 |
+
{
|
| 90 |
+
"label": "Men",
|
| 91 |
+
"href": "/c/shoes-boots-mens/",
|
| 92 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_M_Shoes"
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"label": "Women",
|
| 96 |
+
"href": "/c/womens-shoes/",
|
| 97 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_W_Shoes"
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"label": "Kids",
|
| 101 |
+
"href": "/c/kids-shoes/",
|
| 102 |
+
"asset": "2500648_C_US_May_Visnavs_NewArrivals_K_Shoes"
|
| 103 |
+
}
|
| 104 |
+
],
|
| 105 |
+
"accessories": [
|
| 106 |
+
{
|
| 107 |
+
"label": "Ball Caps",
|
| 108 |
+
"href": "/c/accessories-hats-ballcaps/",
|
| 109 |
+
"asset": "250731_beta_2124148_COL_US_Visnav_Ace_Hats"
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"label": "Booney Hats",
|
| 113 |
+
"href": "/c/booney-hats/",
|
| 114 |
+
"asset": "250731_beta_2124148_COL_US_Visnav_Ace_Booney"
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"label": "Beanies",
|
| 118 |
+
"href": "/c/accessories-hats-beanies/",
|
| 119 |
+
"asset": "250731_beta_2124148_COL_US_Visnav_Ace_Beanie"
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"label": "Gaiters",
|
| 123 |
+
"href": "/c/neck-gaiters/",
|
| 124 |
+
"asset": "250731_beta_2124148_COL_US_Visnav_Ace_Gaiters"
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"label": "Socks",
|
| 128 |
+
"href": "/c/accessories-socks/",
|
| 129 |
+
"asset": "250731_beta_2124148_COL_US_Visnav_Ace_Socks"
|
| 130 |
+
},
|
| 131 |
+
{
|
| 132 |
+
"label": "Belts",
|
| 133 |
+
"href": "/c/accessories-walletsbelts/",
|
| 134 |
+
"asset": "250731_beta_2124148_COL_US_Visnav_Ace_Belts"
|
| 135 |
+
}
|
| 136 |
+
],
|
| 137 |
+
"equipment": [
|
| 138 |
+
{
|
| 139 |
+
"label": "Backpacks",
|
| 140 |
+
"href": "/c/backpacks/",
|
| 141 |
+
"asset": "2308014_US_Supergrid_TopLevel_Equip_VisNav_Slot01"
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
"label": "Hip Packs",
|
| 145 |
+
"href": "/c/hip-packs/",
|
| 146 |
+
"asset": "2308014_US_Supergrid_TopLevel_Equip_VisNav_Slot02"
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"label": "Duffels",
|
| 150 |
+
"href": "/c/equipment-rollersduffles/",
|
| 151 |
+
"asset": "2308014_US_Supergrid_TopLevel_Equip_VisNav_Slot03"
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"label": "Commuter Bags",
|
| 155 |
+
"href": "/c/commuter-bags/",
|
| 156 |
+
"asset": "2308014_US_Supergrid_TopLevel_Equip_VisNav_Slot04"
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"label": "Outdoor Gear",
|
| 160 |
+
"href": "/c/outdoor-gear/",
|
| 161 |
+
"asset": "250731_beta_2124148_COL_NA_August_VisNavBanners_CampingGear"
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
"label": "Drinkware",
|
| 165 |
+
"href": "/c/water-bottles/",
|
| 166 |
+
"asset": "250731_beta_2124148_COL_NA_August_VisNavBanners_Drinkware"
|
| 167 |
+
}
|
| 168 |
+
]
|
| 169 |
+
}
|
tasks/columbia/environment/reference/clone/data/products.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tasks/columbia/environment/reference/clone/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi>=0.115
|
| 2 |
+
uvicorn>=0.30
|
tasks/columbia/environment/reference/clone/site/catalog.py
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""In-memory catalog index built from source-observed Columbia data.
|
| 2 |
+
|
| 3 |
+
Data provenance: every field here comes from the source site's own product and
|
| 4 |
+
category payloads captured with Playwright against https://www.columbia.com.
|
| 5 |
+
Nothing is invented; missing source values stay ``None`` rather than guessed.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import json
|
| 11 |
+
import re
|
| 12 |
+
import unicodedata
|
| 13 |
+
from collections import defaultdict
|
| 14 |
+
from dataclasses import dataclass, field
|
| 15 |
+
from functools import lru_cache
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
from typing import Any
|
| 18 |
+
|
| 19 |
+
DATA_DIR = Path(__file__).resolve().parents[1] / "data"
|
| 20 |
+
|
| 21 |
+
# Refinement dimensions in the order the source renders them, with the product
|
| 22 |
+
# field each one reads. Source evidence: the Unbxd refinement list on
|
| 23 |
+
# /c/womens/ (16 dimensions) and the reduced list on /c/fleece-jackets/.
|
| 24 |
+
REFINEMENTS: tuple[tuple[str, str, str], ...] = (
|
| 25 |
+
("c_productType", "Product Type", "productClass"),
|
| 26 |
+
("c_genderFilter", "Gender", "gender"),
|
| 27 |
+
("c_bigTall", "Size Range", "bigTall"),
|
| 28 |
+
("c_size", "Size", "sizes"),
|
| 29 |
+
("c_technologyBenefit", "Benefit", "techBadge"),
|
| 30 |
+
("c_activity", "Activity", "activity"),
|
| 31 |
+
("c_refinementColor", "Color", "refinementColor"),
|
| 32 |
+
("c_apparelFit", "Fit", "fit"),
|
| 33 |
+
("c_jacketHood", "Hood", "jacketHood"),
|
| 34 |
+
("c_warmth", "Warmth", "warmth"),
|
| 35 |
+
("price", "Price", "price"),
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
# Source-observed price buckets from the Women refinement panel.
|
| 39 |
+
PRICE_BUCKETS: tuple[tuple[str, float, float], ...] = (
|
| 40 |
+
("Under $50", 0.0, 50.0),
|
| 41 |
+
("$50 - $99.99", 50.0, 100.0),
|
| 42 |
+
("$100 - $149.99", 100.0, 150.0),
|
| 43 |
+
("Over $150", 150.0, float("inf")),
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# Source-observed sorting options (Unbxd sortingOptions on every grid).
|
| 47 |
+
SORT_OPTIONS: tuple[tuple[str, str], ...] = (
|
| 48 |
+
("featured-new", "Featured"),
|
| 49 |
+
("newest", "Newest"),
|
| 50 |
+
("price-high-to-low", "Price: High to Low"),
|
| 51 |
+
("price-low-to-high", "Price: Low to High"),
|
| 52 |
+
("top-rated", "Top Rated"),
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
SIZE_ORDER = [
|
| 56 |
+
"XXS", "XS", "S", "M", "L", "XL", "XXL", "1X", "2X", "3X", "4X",
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _size_key(value: str) -> tuple[int, float, str]:
|
| 61 |
+
if value in SIZE_ORDER:
|
| 62 |
+
return (0, SIZE_ORDER.index(value), value)
|
| 63 |
+
try:
|
| 64 |
+
return (1, float(value), value)
|
| 65 |
+
except ValueError:
|
| 66 |
+
return (2, 0.0, value)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def _as_list(value: Any) -> list[str]:
|
| 70 |
+
if value is None:
|
| 71 |
+
return []
|
| 72 |
+
if isinstance(value, list):
|
| 73 |
+
return [str(v) for v in value if v]
|
| 74 |
+
return [str(value)]
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
@dataclass(slots=True)
|
| 78 |
+
class Variant:
|
| 79 |
+
variant_id: str | None
|
| 80 |
+
color_code: str | None
|
| 81 |
+
color_name: str | None
|
| 82 |
+
sizes: list[str]
|
| 83 |
+
price: float | None
|
| 84 |
+
images: list[str]
|
| 85 |
+
|
| 86 |
+
@property
|
| 87 |
+
def primary_image(self) -> str | None:
|
| 88 |
+
for image in self.images:
|
| 89 |
+
if "_f_om" in image:
|
| 90 |
+
return image
|
| 91 |
+
return self.images[0] if self.images else None
|
| 92 |
+
|
| 93 |
+
@property
|
| 94 |
+
def hover_image(self) -> str | None:
|
| 95 |
+
for image in self.images:
|
| 96 |
+
if "_ht1_om" in image:
|
| 97 |
+
return image
|
| 98 |
+
return None
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
@dataclass(slots=True)
|
| 102 |
+
class Product:
|
| 103 |
+
product_id: str
|
| 104 |
+
name: str
|
| 105 |
+
url: str
|
| 106 |
+
min_price: float | None
|
| 107 |
+
max_price: float | None
|
| 108 |
+
sale_price: float | None
|
| 109 |
+
grid_badge: str | None
|
| 110 |
+
tech_badge: str | None
|
| 111 |
+
pitch: str | None
|
| 112 |
+
features: list[str]
|
| 113 |
+
fabric: list[str]
|
| 114 |
+
fit: str | None
|
| 115 |
+
warmth: str | None
|
| 116 |
+
center_back_length: str | None
|
| 117 |
+
product_class: str | None
|
| 118 |
+
gender: list[str]
|
| 119 |
+
activity: list[str]
|
| 120 |
+
colors: list[str]
|
| 121 |
+
refinement_color: list[str]
|
| 122 |
+
big_tall: str | None
|
| 123 |
+
jacket_hood: str | None
|
| 124 |
+
pocket_type: str | None
|
| 125 |
+
additional_features: str | None
|
| 126 |
+
fleece_weight: str | None
|
| 127 |
+
hood_features: str | None
|
| 128 |
+
category_path: list[str]
|
| 129 |
+
default_color: str | None
|
| 130 |
+
variants: list[Variant]
|
| 131 |
+
categories: set[str] = field(default_factory=set)
|
| 132 |
+
|
| 133 |
+
@property
|
| 134 |
+
def slug(self) -> str:
|
| 135 |
+
return self.url
|
| 136 |
+
|
| 137 |
+
@property
|
| 138 |
+
def is_sale(self) -> bool:
|
| 139 |
+
return bool(
|
| 140 |
+
self.max_price is not None
|
| 141 |
+
and self.sale_price is not None
|
| 142 |
+
and self.sale_price < self.max_price
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
@property
|
| 146 |
+
def sizes(self) -> list[str]:
|
| 147 |
+
found: set[str] = set()
|
| 148 |
+
for variant in self.variants:
|
| 149 |
+
found.update(variant.sizes)
|
| 150 |
+
return sorted(found, key=_size_key)
|
| 151 |
+
|
| 152 |
+
def variant_for_color(self, color_code: str | None) -> Variant | None:
|
| 153 |
+
if not self.variants:
|
| 154 |
+
return None
|
| 155 |
+
if color_code is None:
|
| 156 |
+
# The source canonicalises a bare PDP URL to its default colour.
|
| 157 |
+
if self.default_color:
|
| 158 |
+
for variant in self.variants:
|
| 159 |
+
if variant.color_code == self.default_color:
|
| 160 |
+
return variant
|
| 161 |
+
return self.variants[0]
|
| 162 |
+
for variant in self.variants:
|
| 163 |
+
if variant.color_code == color_code:
|
| 164 |
+
return variant
|
| 165 |
+
return self.variants[0]
|
| 166 |
+
|
| 167 |
+
def facet_values(self, source_field: str) -> list[str]:
|
| 168 |
+
if source_field == "sizes":
|
| 169 |
+
return self.sizes
|
| 170 |
+
if source_field == "price":
|
| 171 |
+
# The source counts a product into every bucket its price range
|
| 172 |
+
# spans: on /c/womens/ the four buckets sum to 944 against 836
|
| 173 |
+
# products, which only holds if ranges overlap buckets.
|
| 174 |
+
low_price = self.min_price
|
| 175 |
+
high_price = self.max_price if self.max_price is not None else self.min_price
|
| 176 |
+
if low_price is None:
|
| 177 |
+
return []
|
| 178 |
+
if high_price is None or high_price < low_price:
|
| 179 |
+
high_price = low_price
|
| 180 |
+
return [
|
| 181 |
+
label
|
| 182 |
+
for label, low, high in PRICE_BUCKETS
|
| 183 |
+
if low_price < high and high_price >= low
|
| 184 |
+
]
|
| 185 |
+
return _as_list(getattr(self, _FIELD_MAP[source_field]))
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
_FIELD_MAP = {
|
| 189 |
+
"productClass": "product_class",
|
| 190 |
+
"gender": "gender",
|
| 191 |
+
"bigTall": "big_tall",
|
| 192 |
+
"techBadge": "tech_badge",
|
| 193 |
+
"activity": "activity",
|
| 194 |
+
"refinementColor": "refinement_color",
|
| 195 |
+
"fit": "fit",
|
| 196 |
+
"jacketHood": "jacket_hood",
|
| 197 |
+
"warmth": "warmth",
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
@dataclass(slots=True)
|
| 202 |
+
class Category:
|
| 203 |
+
id: str
|
| 204 |
+
name: str | None
|
| 205 |
+
url: str | None
|
| 206 |
+
depth: int
|
| 207 |
+
parent: str | None
|
| 208 |
+
show_in_menu: bool
|
| 209 |
+
enable_compare: bool
|
| 210 |
+
page_title: str | None
|
| 211 |
+
description: str | None
|
| 212 |
+
children: list[str]
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
def _normalize(text: str) -> str:
|
| 216 |
+
text = unicodedata.normalize("NFKD", text.lower())
|
| 217 |
+
return re.sub(r"[^a-z0-9]+", " ", text).strip()
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
class Catalog:
|
| 221 |
+
"""Loads the captured catalog once and serves every read path."""
|
| 222 |
+
|
| 223 |
+
def __init__(self, data_dir: Path = DATA_DIR) -> None:
|
| 224 |
+
self.products: dict[str, Product] = {}
|
| 225 |
+
self.by_url: dict[str, Product] = {}
|
| 226 |
+
self.categories: dict[str, Category] = {}
|
| 227 |
+
self.category_products: dict[str, list[str]] = defaultdict(list)
|
| 228 |
+
self._search_index: dict[str, str] = {}
|
| 229 |
+
self._load(data_dir)
|
| 230 |
+
|
| 231 |
+
# -- loading -----------------------------------------------------------
|
| 232 |
+
def _load(self, data_dir: Path) -> None:
|
| 233 |
+
raw_products = json.loads((data_dir / "products.json").read_text())
|
| 234 |
+
for row in raw_products:
|
| 235 |
+
variants = [
|
| 236 |
+
Variant(
|
| 237 |
+
variant_id=v.get("variantId"),
|
| 238 |
+
color_code=v.get("colorCode"),
|
| 239 |
+
color_name=v.get("colorName"),
|
| 240 |
+
sizes=sorted(v.get("sizes") or [], key=_size_key),
|
| 241 |
+
price=v.get("price"),
|
| 242 |
+
images=v.get("images") or [],
|
| 243 |
+
)
|
| 244 |
+
for v in row.get("variants") or []
|
| 245 |
+
]
|
| 246 |
+
product = Product(
|
| 247 |
+
product_id=row["productId"],
|
| 248 |
+
name=row.get("name") or "",
|
| 249 |
+
url=row["url"],
|
| 250 |
+
min_price=row.get("minPrice"),
|
| 251 |
+
max_price=row.get("maxPrice"),
|
| 252 |
+
sale_price=row.get("salePrice"),
|
| 253 |
+
grid_badge=row.get("gridBadge"),
|
| 254 |
+
tech_badge=row.get("techBadge"),
|
| 255 |
+
pitch=row.get("pitch"),
|
| 256 |
+
features=row.get("features") or [],
|
| 257 |
+
fabric=row.get("fabric") or [],
|
| 258 |
+
fit=row.get("fit"),
|
| 259 |
+
warmth=row.get("warmth"),
|
| 260 |
+
center_back_length=row.get("centerBackLength"),
|
| 261 |
+
product_class=row.get("productClass"),
|
| 262 |
+
gender=row.get("gender") or [],
|
| 263 |
+
activity=row.get("activity") or [],
|
| 264 |
+
colors=row.get("colors") or [],
|
| 265 |
+
refinement_color=row.get("refinementColor") or [],
|
| 266 |
+
big_tall=row.get("bigTall"),
|
| 267 |
+
jacket_hood=row.get("jacketHood"),
|
| 268 |
+
pocket_type=row.get("pocketType"),
|
| 269 |
+
additional_features=row.get("additionalFeatures"),
|
| 270 |
+
fleece_weight=row.get("fleeceWeight"),
|
| 271 |
+
hood_features=row.get("hoodFeatures"),
|
| 272 |
+
category_path=row.get("categoryPath") or [],
|
| 273 |
+
default_color=row.get("defaultColor"),
|
| 274 |
+
variants=variants,
|
| 275 |
+
)
|
| 276 |
+
for path in product.category_path:
|
| 277 |
+
for part in path.split(">"):
|
| 278 |
+
product.categories.add(part)
|
| 279 |
+
self.products[product.product_id] = product
|
| 280 |
+
self.by_url[product.url] = product
|
| 281 |
+
self._search_index[product.product_id] = _normalize(
|
| 282 |
+
" ".join(
|
| 283 |
+
[product.name or "", product.product_class or "",
|
| 284 |
+
product.pitch or "", " ".join(product.colors),
|
| 285 |
+
" ".join(product.activity), " ".join(product.gender),
|
| 286 |
+
product.tech_badge or "", product.warmth or "",
|
| 287 |
+
" ".join(product.features)]
|
| 288 |
+
)
|
| 289 |
+
)
|
| 290 |
+
|
| 291 |
+
raw_categories = json.loads((data_dir / "categories.json").read_text())
|
| 292 |
+
for row in raw_categories:
|
| 293 |
+
category = Category(
|
| 294 |
+
id=row["id"],
|
| 295 |
+
name=row.get("name"),
|
| 296 |
+
url=row.get("url"),
|
| 297 |
+
depth=row.get("depth", 0),
|
| 298 |
+
parent=row.get("parent"),
|
| 299 |
+
show_in_menu=bool(row.get("showInMenu")),
|
| 300 |
+
enable_compare=bool(row.get("enableCompare")),
|
| 301 |
+
page_title=row.get("pageTitle"),
|
| 302 |
+
description=row.get("description"),
|
| 303 |
+
children=row.get("children") or [],
|
| 304 |
+
)
|
| 305 |
+
self.categories[category.id] = category
|
| 306 |
+
|
| 307 |
+
for product in self.products.values():
|
| 308 |
+
for category_id in product.categories:
|
| 309 |
+
if category_id in self.categories:
|
| 310 |
+
self.category_products[category_id].append(product.product_id)
|
| 311 |
+
|
| 312 |
+
# Seven categories were queried directly against the source's own
|
| 313 |
+
# category endpoint, so their membership is measured rather than
|
| 314 |
+
# derived. `categoryPath` lists promotional ancestors (notably `sale`)
|
| 315 |
+
# that are not real category assignments, so measured membership wins.
|
| 316 |
+
measured_path = data_dir / "measured-membership.json"
|
| 317 |
+
if measured_path.exists():
|
| 318 |
+
measured = json.loads(measured_path.read_text())
|
| 319 |
+
for category_id, product_ids in measured.items():
|
| 320 |
+
self.category_products[category_id] = [
|
| 321 |
+
pid for pid in product_ids if pid in self.products
|
| 322 |
+
]
|
| 323 |
+
|
| 324 |
+
# Menu aliases: the source exposes `alturl_*` navigation entries that
|
| 325 |
+
# carry no product assignment of their own. Resolve each to the
|
| 326 |
+
# canonical category with the same name under the same gender branch so
|
| 327 |
+
# the route stays populated instead of dead.
|
| 328 |
+
self._resolve_aliases()
|
| 329 |
+
|
| 330 |
+
def _resolve_aliases(self) -> None:
|
| 331 |
+
by_name: dict[str, list[str]] = defaultdict(list)
|
| 332 |
+
for category in self.categories.values():
|
| 333 |
+
if category.name and self.category_products.get(category.id):
|
| 334 |
+
by_name[_normalize(category.name)].append(category.id)
|
| 335 |
+
for category in self.categories.values():
|
| 336 |
+
if self.category_products.get(category.id):
|
| 337 |
+
continue
|
| 338 |
+
if not category.name:
|
| 339 |
+
continue
|
| 340 |
+
candidates = by_name.get(_normalize(category.name)) or []
|
| 341 |
+
if not candidates:
|
| 342 |
+
continue
|
| 343 |
+
branch = self._branch_root(category.id)
|
| 344 |
+
best = None
|
| 345 |
+
for candidate in candidates:
|
| 346 |
+
if self._branch_root(candidate) == branch:
|
| 347 |
+
best = candidate
|
| 348 |
+
break
|
| 349 |
+
best = best or max(
|
| 350 |
+
candidates, key=lambda c: len(self.category_products[c])
|
| 351 |
+
)
|
| 352 |
+
self.category_products[category.id] = self.category_products[best]
|
| 353 |
+
|
| 354 |
+
def _branch_root(self, category_id: str) -> str:
|
| 355 |
+
seen = set()
|
| 356 |
+
current = category_id
|
| 357 |
+
while current and current not in seen:
|
| 358 |
+
seen.add(current)
|
| 359 |
+
category = self.categories.get(current)
|
| 360 |
+
if not category or not category.parent or category.parent == "root":
|
| 361 |
+
return current
|
| 362 |
+
current = category.parent
|
| 363 |
+
return category_id
|
| 364 |
+
|
| 365 |
+
# -- lookups -----------------------------------------------------------
|
| 366 |
+
def category_by_url(self, url: str) -> Category | None:
|
| 367 |
+
for category in self.categories.values():
|
| 368 |
+
if category.url == url:
|
| 369 |
+
return category
|
| 370 |
+
return None
|
| 371 |
+
|
| 372 |
+
def menu_tree(self) -> list[tuple[Category, list[Category]]]:
|
| 373 |
+
roots = [
|
| 374 |
+
c for c in self.categories.values()
|
| 375 |
+
if c.show_in_menu and c.depth == 1
|
| 376 |
+
]
|
| 377 |
+
roots.sort(key=lambda c: _MENU_ORDER.index(c.id) if c.id in _MENU_ORDER else 99)
|
| 378 |
+
out = []
|
| 379 |
+
for root in roots:
|
| 380 |
+
children = [
|
| 381 |
+
self.categories[cid]
|
| 382 |
+
for cid in root.children
|
| 383 |
+
if cid in self.categories and self.categories[cid].show_in_menu
|
| 384 |
+
]
|
| 385 |
+
out.append((root, children))
|
| 386 |
+
return out
|
| 387 |
+
|
| 388 |
+
def products_in(self, category_id: str) -> list[Product]:
|
| 389 |
+
return [
|
| 390 |
+
self.products[pid]
|
| 391 |
+
for pid in self.category_products.get(category_id, [])
|
| 392 |
+
if pid in self.products
|
| 393 |
+
]
|
| 394 |
+
|
| 395 |
+
# -- search ------------------------------------------------------------
|
| 396 |
+
def search(self, query: str) -> list[Product]:
|
| 397 |
+
terms = [t for t in _normalize(query).split() if t]
|
| 398 |
+
if not terms:
|
| 399 |
+
return []
|
| 400 |
+
scored: list[tuple[float, Product]] = []
|
| 401 |
+
for product_id, blob in self._search_index.items():
|
| 402 |
+
score = 0.0
|
| 403 |
+
for term in terms:
|
| 404 |
+
if term in blob:
|
| 405 |
+
score += 1.0
|
| 406 |
+
if blob.startswith(term):
|
| 407 |
+
score += 0.5
|
| 408 |
+
if score:
|
| 409 |
+
scored.append((score, self.products[product_id]))
|
| 410 |
+
scored.sort(key=lambda pair: (-pair[0], pair[1].name))
|
| 411 |
+
return [product for _, product in scored]
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
_MENU_ORDER = [
|
| 415 |
+
"newTrending", "men", "women", "kids", "footwear",
|
| 416 |
+
"pfg-landing", "sale", "featured",
|
| 417 |
+
]
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
@lru_cache(maxsize=1)
|
| 421 |
+
def get_catalog() -> Catalog:
|
| 422 |
+
return Catalog()
|
tasks/columbia/environment/reference/clone/site/grid.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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select refinements with live hit counts, five sorting options, and a
|
| 5 |
+
`pagesize`-driven "Show More" that grows the rendered window.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
from dataclasses import dataclass
|
| 11 |
+
from typing import Iterable, Sequence
|
| 12 |
+
|
| 13 |
+
from catalog import PRICE_BUCKETS, REFINEMENTS, Product
|
| 14 |
+
|
| 15 |
+
PAGE_SIZE = 47
|
| 16 |
+
PAGE_STEP = 48
|
| 17 |
+
|
| 18 |
+
# Source-observed `quickFilters` on /c/womens/: only these render as pills in
|
| 19 |
+
# the control row; the rest stay behind the "All Filters" panel.
|
| 20 |
+
QUICK_FILTERS = (
|
| 21 |
+
"c_productType", "c_bigTall", "c_size", "c_technologyBenefit", "c_activity",
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
@dataclass(slots=True)
|
| 26 |
+
class RefinementValue:
|
| 27 |
+
label: str
|
| 28 |
+
hit_count: int
|
| 29 |
+
selected: bool
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
@dataclass(slots=True)
|
| 33 |
+
class Refinement:
|
| 34 |
+
attribute_id: str
|
| 35 |
+
label: str
|
| 36 |
+
values: list[RefinementValue]
|
| 37 |
+
|
| 38 |
+
@property
|
| 39 |
+
def selected_count(self) -> int:
|
| 40 |
+
return sum(1 for value in self.values if value.selected)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
@dataclass(slots=True)
|
| 44 |
+
class GridResult:
|
| 45 |
+
products: list[Product]
|
| 46 |
+
total: int
|
| 47 |
+
shown: int
|
| 48 |
+
refinements: list[Refinement]
|
| 49 |
+
sort_id: str
|
| 50 |
+
page_size: int
|
| 51 |
+
|
| 52 |
+
@property
|
| 53 |
+
def quick(self) -> list["Refinement"]:
|
| 54 |
+
order = {attribute: index for index, attribute in enumerate(QUICK_FILTERS)}
|
| 55 |
+
chosen = [r for r in self.refinements if r.attribute_id in order]
|
| 56 |
+
chosen.sort(key=lambda r: order[r.attribute_id])
|
| 57 |
+
return chosen
|
| 58 |
+
|
| 59 |
+
@property
|
| 60 |
+
def rest(self) -> list["Refinement"]:
|
| 61 |
+
return [r for r in self.refinements if r.attribute_id not in QUICK_FILTERS]
|
| 62 |
+
|
| 63 |
+
@property
|
| 64 |
+
def has_more(self) -> bool:
|
| 65 |
+
return self.shown < self.total
|
| 66 |
+
|
| 67 |
+
@property
|
| 68 |
+
def next_page_size(self) -> int:
|
| 69 |
+
return self.page_size + PAGE_STEP
|
| 70 |
+
|
| 71 |
+
@property
|
| 72 |
+
def remaining(self) -> int:
|
| 73 |
+
return max(self.total - self.shown, 0)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def parse_refine(values: Sequence[str]) -> dict[str, set[str]]:
|
| 77 |
+
"""Parse the source's `refine=<attribute>=<value>` repeated parameter."""
|
| 78 |
+
selected: dict[str, set[str]] = {}
|
| 79 |
+
for raw in values:
|
| 80 |
+
if "=" not in raw:
|
| 81 |
+
continue
|
| 82 |
+
attribute, _, value = raw.partition("=")
|
| 83 |
+
selected.setdefault(attribute.strip(), set()).add(value.strip())
|
| 84 |
+
return selected
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def _matches(product: Product, attribute: str, wanted: set[str]) -> bool:
|
| 88 |
+
source_field = _FIELD_FOR.get(attribute)
|
| 89 |
+
if source_field is None:
|
| 90 |
+
return True
|
| 91 |
+
return bool(wanted & set(product.facet_values(source_field)))
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
_FIELD_FOR = {attribute: field for attribute, _label, field in REFINEMENTS}
|
| 95 |
+
_LABEL_FOR = {attribute: label for attribute, label, _field in REFINEMENTS}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def _sort(products: list[Product], sort_id: str) -> list[Product]:
|
| 99 |
+
def price(product: Product) -> float:
|
| 100 |
+
value = product.sale_price if product.sale_price is not None else product.min_price
|
| 101 |
+
return value if value is not None else 0.0
|
| 102 |
+
|
| 103 |
+
if sort_id == "price-low-to-high":
|
| 104 |
+
return sorted(products, key=price)
|
| 105 |
+
if sort_id == "price-high-to-low":
|
| 106 |
+
return sorted(products, key=price, reverse=True)
|
| 107 |
+
if sort_id == "newest":
|
| 108 |
+
return sorted(products, key=lambda p: (p.grid_badge != "New", p.name))
|
| 109 |
+
if sort_id == "top-rated":
|
| 110 |
+
# The source ranks by review score, which this clone did not capture.
|
| 111 |
+
# Fall back to the stable featured order rather than inventing ratings.
|
| 112 |
+
return list(products)
|
| 113 |
+
return list(products)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def build(
|
| 117 |
+
products: Iterable[Product],
|
| 118 |
+
selected: dict[str, set[str]],
|
| 119 |
+
sort_id: str = "featured-new",
|
| 120 |
+
page_size: int = PAGE_SIZE,
|
| 121 |
+
) -> GridResult:
|
| 122 |
+
pool = list(products)
|
| 123 |
+
|
| 124 |
+
def passes(product: Product, skip: str | None = None) -> bool:
|
| 125 |
+
for attribute, wanted in selected.items():
|
| 126 |
+
if attribute == skip or not wanted:
|
| 127 |
+
continue
|
| 128 |
+
if not _matches(product, attribute, wanted):
|
| 129 |
+
return False
|
| 130 |
+
return True
|
| 131 |
+
|
| 132 |
+
matched = [product for product in pool if passes(product)]
|
| 133 |
+
|
| 134 |
+
refinements: list[Refinement] = []
|
| 135 |
+
for attribute, label, source_field in REFINEMENTS:
|
| 136 |
+
# Counts for a facet are computed with that facet's own selection
|
| 137 |
+
# removed, which is what multi-select refinement panels show.
|
| 138 |
+
others = [product for product in pool if passes(product, skip=attribute)]
|
| 139 |
+
counts: dict[str, int] = {}
|
| 140 |
+
for product in others:
|
| 141 |
+
for value in product.facet_values(source_field):
|
| 142 |
+
counts[value] = counts.get(value, 0) + 1
|
| 143 |
+
if not counts:
|
| 144 |
+
continue
|
| 145 |
+
chosen = selected.get(attribute, set())
|
| 146 |
+
if attribute == "price":
|
| 147 |
+
ordered = [label for label, _low, _high in PRICE_BUCKETS if label in counts]
|
| 148 |
+
else:
|
| 149 |
+
ordered = sorted(counts, key=lambda value: (-counts[value], value))
|
| 150 |
+
refinements.append(
|
| 151 |
+
Refinement(
|
| 152 |
+
attribute_id=attribute,
|
| 153 |
+
label=label,
|
| 154 |
+
values=[
|
| 155 |
+
RefinementValue(label=value, hit_count=counts[value], selected=value in chosen)
|
| 156 |
+
for value in ordered
|
| 157 |
+
],
|
| 158 |
+
)
|
| 159 |
+
)
|
| 160 |
+
|
| 161 |
+
ordered_products = _sort(matched, sort_id)
|
| 162 |
+
window = ordered_products[:page_size]
|
| 163 |
+
return GridResult(
|
| 164 |
+
products=window,
|
| 165 |
+
total=len(ordered_products),
|
| 166 |
+
shown=len(window),
|
| 167 |
+
refinements=refinements,
|
| 168 |
+
sort_id=sort_id,
|
| 169 |
+
page_size=page_size,
|
| 170 |
+
)
|
tasks/columbia/environment/reference/clone/site/models.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic local store for cart, sessions and saved items.
|
| 2 |
+
|
| 3 |
+
Every mutation lands in the site-bound SQLite database created by the generated
|
| 4 |
+
site_backend integration; nothing is kept in process memory.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import sqlite3
|
| 10 |
+
from dataclasses import dataclass
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
SCHEMA = """
|
| 14 |
+
CREATE TABLE IF NOT EXISTS cart_item (
|
| 15 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 16 |
+
session_id TEXT NOT NULL,
|
| 17 |
+
product_id TEXT NOT NULL,
|
| 18 |
+
variant_id TEXT,
|
| 19 |
+
color_code TEXT,
|
| 20 |
+
size TEXT,
|
| 21 |
+
quantity INTEGER NOT NULL DEFAULT 1,
|
| 22 |
+
saved_for_later INTEGER NOT NULL DEFAULT 0,
|
| 23 |
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
| 24 |
+
UNIQUE (session_id, product_id, color_code, size, saved_for_later)
|
| 25 |
+
);
|
| 26 |
+
CREATE INDEX IF NOT EXISTS cart_item_session ON cart_item (session_id);
|
| 27 |
+
|
| 28 |
+
CREATE TABLE IF NOT EXISTS promo_code (
|
| 29 |
+
code TEXT PRIMARY KEY,
|
| 30 |
+
label TEXT NOT NULL,
|
| 31 |
+
percent_off REAL NOT NULL
|
| 32 |
+
);
|
| 33 |
+
|
| 34 |
+
CREATE TABLE IF NOT EXISTS applied_promo (
|
| 35 |
+
session_id TEXT PRIMARY KEY,
|
| 36 |
+
code TEXT NOT NULL
|
| 37 |
+
);
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
# Source-observed member promotion: the Women grid and cart both render
|
| 41 |
+
# "Extra 30% Off Applied" for Greater Rewards members on sale styles.
|
| 42 |
+
SEED_PROMOS = (
|
| 43 |
+
("MEMBER30", "Extra 30% Off Applied", 30.0),
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
@dataclass(slots=True)
|
| 48 |
+
class CartLine:
|
| 49 |
+
id: int
|
| 50 |
+
product_id: str
|
| 51 |
+
variant_id: str | None
|
| 52 |
+
color_code: str | None
|
| 53 |
+
size: str | None
|
| 54 |
+
quantity: int
|
| 55 |
+
saved_for_later: bool
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def ensure_schema(connection: sqlite3.Connection) -> None:
|
| 59 |
+
connection.executescript(SCHEMA)
|
| 60 |
+
connection.executemany(
|
| 61 |
+
"INSERT OR IGNORE INTO promo_code (code, label, percent_off) VALUES (?, ?, ?)",
|
| 62 |
+
SEED_PROMOS,
|
| 63 |
+
)
|
| 64 |
+
connection.commit()
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def add_item(
|
| 68 |
+
connection: sqlite3.Connection,
|
| 69 |
+
session_id: str,
|
| 70 |
+
product_id: str,
|
| 71 |
+
variant_id: str | None,
|
| 72 |
+
color_code: str | None,
|
| 73 |
+
size: str | None,
|
| 74 |
+
quantity: int = 1,
|
| 75 |
+
) -> None:
|
| 76 |
+
connection.execute(
|
| 77 |
+
"""
|
| 78 |
+
INSERT INTO cart_item
|
| 79 |
+
(session_id, product_id, variant_id, color_code, size, quantity, saved_for_later)
|
| 80 |
+
VALUES (?, ?, ?, ?, ?, ?, 0)
|
| 81 |
+
ON CONFLICT (session_id, product_id, color_code, size, saved_for_later)
|
| 82 |
+
DO UPDATE SET quantity = quantity + excluded.quantity
|
| 83 |
+
""",
|
| 84 |
+
(session_id, product_id, variant_id, color_code, size, quantity),
|
| 85 |
+
)
|
| 86 |
+
connection.commit()
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def set_quantity(
|
| 90 |
+
connection: sqlite3.Connection, session_id: str, line_id: int, quantity: int
|
| 91 |
+
) -> None:
|
| 92 |
+
if quantity <= 0:
|
| 93 |
+
remove_item(connection, session_id, line_id)
|
| 94 |
+
return
|
| 95 |
+
connection.execute(
|
| 96 |
+
"UPDATE cart_item SET quantity = ? WHERE id = ? AND session_id = ?",
|
| 97 |
+
(quantity, line_id, session_id),
|
| 98 |
+
)
|
| 99 |
+
connection.commit()
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def remove_item(connection: sqlite3.Connection, session_id: str, line_id: int) -> None:
|
| 103 |
+
connection.execute(
|
| 104 |
+
"DELETE FROM cart_item WHERE id = ? AND session_id = ?", (line_id, session_id)
|
| 105 |
+
)
|
| 106 |
+
connection.commit()
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def set_saved(
|
| 110 |
+
connection: sqlite3.Connection, session_id: str, line_id: int, saved: bool
|
| 111 |
+
) -> None:
|
| 112 |
+
connection.execute(
|
| 113 |
+
"UPDATE cart_item SET saved_for_later = ? WHERE id = ? AND session_id = ?",
|
| 114 |
+
(1 if saved else 0, line_id, session_id),
|
| 115 |
+
)
|
| 116 |
+
connection.commit()
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def lines(
|
| 120 |
+
connection: sqlite3.Connection, session_id: str, saved: bool = False
|
| 121 |
+
) -> list[CartLine]:
|
| 122 |
+
rows = connection.execute(
|
| 123 |
+
"""
|
| 124 |
+
SELECT id, product_id, variant_id, color_code, size, quantity, saved_for_later
|
| 125 |
+
FROM cart_item WHERE session_id = ? AND saved_for_later = ?
|
| 126 |
+
ORDER BY created_at, id
|
| 127 |
+
""",
|
| 128 |
+
(session_id, 1 if saved else 0),
|
| 129 |
+
).fetchall()
|
| 130 |
+
return [
|
| 131 |
+
CartLine(
|
| 132 |
+
id=row[0], product_id=row[1], variant_id=row[2], color_code=row[3],
|
| 133 |
+
size=row[4], quantity=row[5], saved_for_later=bool(row[6]),
|
| 134 |
+
)
|
| 135 |
+
for row in rows
|
| 136 |
+
]
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def apply_promo(connection: sqlite3.Connection, session_id: str, code: str) -> bool:
|
| 140 |
+
row = connection.execute(
|
| 141 |
+
"SELECT code FROM promo_code WHERE code = ?", (code.strip().upper(),)
|
| 142 |
+
).fetchone()
|
| 143 |
+
if not row:
|
| 144 |
+
return False
|
| 145 |
+
connection.execute(
|
| 146 |
+
"INSERT INTO applied_promo (session_id, code) VALUES (?, ?) "
|
| 147 |
+
"ON CONFLICT (session_id) DO UPDATE SET code = excluded.code",
|
| 148 |
+
(session_id, row[0]),
|
| 149 |
+
)
|
| 150 |
+
connection.commit()
|
| 151 |
+
return True
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def clear_promo(connection: sqlite3.Connection, session_id: str) -> None:
|
| 155 |
+
connection.execute("DELETE FROM applied_promo WHERE session_id = ?", (session_id,))
|
| 156 |
+
connection.commit()
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def active_promo(
|
| 160 |
+
connection: sqlite3.Connection, session_id: str
|
| 161 |
+
) -> tuple[str, str, float] | None:
|
| 162 |
+
row = connection.execute(
|
| 163 |
+
"""
|
| 164 |
+
SELECT p.code, p.label, p.percent_off
|
| 165 |
+
FROM applied_promo a JOIN promo_code p ON p.code = a.code
|
| 166 |
+
WHERE a.session_id = ?
|
| 167 |
+
""",
|
| 168 |
+
(session_id,),
|
| 169 |
+
).fetchone()
|
| 170 |
+
return (row[0], row[1], row[2]) if row else None
|
tasks/columbia/environment/reference/clone/site/render.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Presentation helpers shared by every template."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from catalog import Product, Variant
|
| 8 |
+
|
| 9 |
+
import re
|
| 10 |
+
|
| 11 |
+
MEDIA_ROOT = Path(__file__).resolve().parents[1] / "static" / "assets" / "media"
|
| 12 |
+
VIDEO_ROOT = Path(__file__).resolve().parents[1] / "static" / "assets" / "video"
|
| 13 |
+
VIDEO_ID = re.compile(r"/v/columbia/([^/]+)/")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def money(value: float | None) -> str:
|
| 17 |
+
if value is None:
|
| 18 |
+
return ""
|
| 19 |
+
return f"${value:,.2f}"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def media_url(image_id: str | None) -> str | None:
|
| 23 |
+
"""Map a source media id to the locally stored asset, if it was captured."""
|
| 24 |
+
if not image_id:
|
| 25 |
+
return None
|
| 26 |
+
if (MEDIA_ROOT / f"{image_id}.webp").exists():
|
| 27 |
+
return f"/static/assets/media/{image_id}.webp"
|
| 28 |
+
return None
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def video_url(media_id: str | None) -> str | None:
|
| 32 |
+
"""PDP galleries mix in product videos; resolve those to local mp4s."""
|
| 33 |
+
if not media_id:
|
| 34 |
+
return None
|
| 35 |
+
match = VIDEO_ID.search(media_id)
|
| 36 |
+
if not match:
|
| 37 |
+
return None
|
| 38 |
+
if (VIDEO_ROOT / f"{match.group(1)}.mp4").exists():
|
| 39 |
+
return f"/static/assets/video/{match.group(1)}.mp4"
|
| 40 |
+
return None
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def slide(media_id: str | None) -> dict[str, str] | None:
|
| 44 |
+
"""Return the renderable gallery slide for a captured media id."""
|
| 45 |
+
video = video_url(media_id)
|
| 46 |
+
if video:
|
| 47 |
+
return {"kind": "video", "src": video}
|
| 48 |
+
image = media_url(media_id)
|
| 49 |
+
if image:
|
| 50 |
+
return {"kind": "image", "src": image}
|
| 51 |
+
return None
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def tile_images(product: Product, variant: Variant | None) -> tuple[str | None, str | None]:
|
| 55 |
+
variant = variant or (product.variants[0] if product.variants else None)
|
| 56 |
+
if variant is None:
|
| 57 |
+
return (None, None)
|
| 58 |
+
return (media_url(variant.primary_image), media_url(variant.hover_image))
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def price_block(product: Product) -> dict[str, object]:
|
| 62 |
+
"""Reproduce the source's current/original price pairing."""
|
| 63 |
+
current = product.sale_price if product.sale_price is not None else product.min_price
|
| 64 |
+
original = product.max_price
|
| 65 |
+
spread = (
|
| 66 |
+
product.max_price is not None
|
| 67 |
+
and product.min_price is not None
|
| 68 |
+
and product.max_price != product.min_price
|
| 69 |
+
)
|
| 70 |
+
return {
|
| 71 |
+
"current": money(current),
|
| 72 |
+
"original": money(original) if product.is_sale else "",
|
| 73 |
+
"range_high": money(product.max_price) if spread else "",
|
| 74 |
+
"is_sale": product.is_sale,
|
| 75 |
+
}
|
tasks/columbia/environment/reference/clone/site/session.py
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Session identity and the cart read/write service.
|
| 2 |
+
|
| 3 |
+
State lives in the site-bound SQLite database opened through the generated
|
| 4 |
+
site_backend integration seam, so a restart keeps the bag and a reset clears it.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import secrets
|
| 10 |
+
import sqlite3
|
| 11 |
+
import sys
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
from typing import Any
|
| 14 |
+
|
| 15 |
+
import models
|
| 16 |
+
import render
|
| 17 |
+
|
| 18 |
+
CLONE_ROOT = Path(__file__).resolve().parents[1]
|
| 19 |
+
if str(CLONE_ROOT) not in sys.path:
|
| 20 |
+
sys.path.insert(0, str(CLONE_ROOT))
|
| 21 |
+
|
| 22 |
+
# Source-observed delivery ladder from the cart Order Summary.
|
| 23 |
+
DELIVERY_OPTIONS = (
|
| 24 |
+
{"id": "standard", "label": "Standard Delivery (4-6 Business Days)", "price": 0.0,
|
| 25 |
+
"price_label": "FREE"},
|
| 26 |
+
{"id": "expedited", "label": "Expedited Delivery (2-3 Business Days)", "price": 19.0,
|
| 27 |
+
"price_label": "$19.00"},
|
| 28 |
+
{"id": "rush", "label": "Rush Delivery (1-2 Business Days)", "price": 25.0,
|
| 29 |
+
"price_label": "$25.00"},
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# Source-observed member state for the captured account: a Greater Rewards
|
| 33 |
+
# member with a zero rewards balance and free standard shipping.
|
| 34 |
+
REWARDS_BALANCE = 0.0
|
| 35 |
+
POINTS_PER_DOLLAR = 10
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def _database_path() -> Path:
|
| 39 |
+
import json
|
| 40 |
+
|
| 41 |
+
runtime = json.loads((CLONE_ROOT.parent / "backend" / "runtime.json").read_text())
|
| 42 |
+
database = runtime["database"]
|
| 43 |
+
data_dir = CLONE_ROOT / database["data_dir"]
|
| 44 |
+
data_dir.mkdir(parents=True, exist_ok=True)
|
| 45 |
+
return data_dir / database["filename"]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def session_id_for(request: Any) -> str:
|
| 49 |
+
existing = request.cookies.get(CartService.COOKIE)
|
| 50 |
+
if existing and len(existing) >= 16 and existing.isalnum():
|
| 51 |
+
return existing
|
| 52 |
+
return secrets.token_hex(16)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
class CartService:
|
| 56 |
+
COOKIE = "columbia_session"
|
| 57 |
+
|
| 58 |
+
def __init__(self, catalog) -> None:
|
| 59 |
+
self.catalog = catalog
|
| 60 |
+
self._path = _database_path()
|
| 61 |
+
with self._connect() as connection:
|
| 62 |
+
models.ensure_schema(connection)
|
| 63 |
+
|
| 64 |
+
def _connect(self) -> sqlite3.Connection:
|
| 65 |
+
connection = sqlite3.connect(self._path)
|
| 66 |
+
connection.execute("PRAGMA foreign_keys = ON")
|
| 67 |
+
return connection
|
| 68 |
+
|
| 69 |
+
# -- mutations ---------------------------------------------------------
|
| 70 |
+
def add(self, session_id, product_id, variant_id, color_code, size, quantity):
|
| 71 |
+
with self._connect() as connection:
|
| 72 |
+
models.add_item(connection, session_id, product_id, variant_id, color_code, size, quantity)
|
| 73 |
+
|
| 74 |
+
def set_quantity(self, session_id, line_id, quantity):
|
| 75 |
+
with self._connect() as connection:
|
| 76 |
+
models.set_quantity(connection, session_id, line_id, quantity)
|
| 77 |
+
|
| 78 |
+
def remove(self, session_id, line_id):
|
| 79 |
+
with self._connect() as connection:
|
| 80 |
+
models.remove_item(connection, session_id, line_id)
|
| 81 |
+
|
| 82 |
+
def set_saved(self, session_id, line_id, saved):
|
| 83 |
+
with self._connect() as connection:
|
| 84 |
+
models.set_saved(connection, session_id, line_id, saved)
|
| 85 |
+
|
| 86 |
+
def apply_promo(self, session_id, code) -> bool:
|
| 87 |
+
with self._connect() as connection:
|
| 88 |
+
return models.apply_promo(connection, session_id, code)
|
| 89 |
+
|
| 90 |
+
def clear_promo(self, session_id) -> None:
|
| 91 |
+
with self._connect() as connection:
|
| 92 |
+
models.clear_promo(connection, session_id)
|
| 93 |
+
|
| 94 |
+
# -- reads -------------------------------------------------------------
|
| 95 |
+
def item_count(self, session_id: str) -> int:
|
| 96 |
+
with self._connect() as connection:
|
| 97 |
+
return sum(line.quantity for line in models.lines(connection, session_id))
|
| 98 |
+
|
| 99 |
+
def view(self, session_id: str) -> dict[str, object]:
|
| 100 |
+
with self._connect() as connection:
|
| 101 |
+
raw_lines = models.lines(connection, session_id)
|
| 102 |
+
saved_raw = models.lines(connection, session_id, saved=True)
|
| 103 |
+
promo = models.active_promo(connection, session_id)
|
| 104 |
+
|
| 105 |
+
lines = [self._hydrate(line) for line in raw_lines]
|
| 106 |
+
lines = [line for line in lines if line]
|
| 107 |
+
saved_lines = [self._hydrate(line) for line in saved_raw]
|
| 108 |
+
saved_lines = [line for line in saved_lines if line]
|
| 109 |
+
|
| 110 |
+
subtotal = sum(line["line_total_value"] for line in lines)
|
| 111 |
+
regular = sum(line["regular_total_value"] for line in lines)
|
| 112 |
+
discount = subtotal * (promo[2] / 100.0) if promo else 0.0
|
| 113 |
+
shipping = 0.0 # members get free standard shipping (source-observed)
|
| 114 |
+
total = max(subtotal - discount, 0.0) + shipping
|
| 115 |
+
savings = max(regular - (subtotal - discount), 0.0)
|
| 116 |
+
|
| 117 |
+
for line in lines:
|
| 118 |
+
line["promo_label"] = promo[1] if promo and line["is_sale"] else None
|
| 119 |
+
|
| 120 |
+
return {
|
| 121 |
+
"lines": lines,
|
| 122 |
+
"saved_lines": saved_lines,
|
| 123 |
+
"item_count": sum(line["quantity"] for line in lines),
|
| 124 |
+
"promo": {"code": promo[0], "label": promo[1]} if promo else None,
|
| 125 |
+
"rewards_balance": render.money(REWARDS_BALANCE),
|
| 126 |
+
"total_points": int(total * POINTS_PER_DOLLAR) if total else 0,
|
| 127 |
+
"delivery_options": DELIVERY_OPTIONS,
|
| 128 |
+
"delivery_id": "standard",
|
| 129 |
+
"totals": {
|
| 130 |
+
"subtotal": render.money(subtotal),
|
| 131 |
+
"discount": render.money(discount) if discount else "",
|
| 132 |
+
"shipping": "FREE",
|
| 133 |
+
"tax": "—",
|
| 134 |
+
"total": render.money(total),
|
| 135 |
+
"savings": render.money(savings) if savings else "",
|
| 136 |
+
},
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
def _hydrate(self, line) -> dict[str, object] | None:
|
| 140 |
+
product = self.catalog.products.get(line.product_id)
|
| 141 |
+
if product is None:
|
| 142 |
+
return None
|
| 143 |
+
variant = product.variant_for_color(line.color_code)
|
| 144 |
+
unit = product.sale_price if product.sale_price is not None else product.min_price
|
| 145 |
+
unit = unit or 0.0
|
| 146 |
+
regular = product.max_price if product.max_price is not None else unit
|
| 147 |
+
return {
|
| 148 |
+
"id": line.id,
|
| 149 |
+
"product": product,
|
| 150 |
+
"variant": variant,
|
| 151 |
+
"color_code": line.color_code,
|
| 152 |
+
"color_name": variant.color_name if variant else None,
|
| 153 |
+
"size": line.size,
|
| 154 |
+
"quantity": line.quantity,
|
| 155 |
+
"image": render.media_url(variant.primary_image) if variant else None,
|
| 156 |
+
"unit_price": render.money(unit),
|
| 157 |
+
"regular_price": render.money(regular),
|
| 158 |
+
"line_total": render.money(unit * line.quantity),
|
| 159 |
+
"line_total_value": unit * line.quantity,
|
| 160 |
+
"regular_total_value": regular * line.quantity,
|
| 161 |
+
"is_sale": product.is_sale,
|
| 162 |
+
"points": int(unit * line.quantity * POINTS_PER_DOLLAR),
|
| 163 |
+
"promo_label": None,
|
| 164 |
+
}
|
tasks/columbia/environment/reference/clone/static/assets/media/1011622_485_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1011651_442_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1011671_450_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1011772_160_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275701_032_a2_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275701_032_a6_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275701_101_a3_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275701_101_a6_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275701_372_a2_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275701_482_a3_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275701_580_a4_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275701_580_a6_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275711_011_a1_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275711_278_ht3_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275711_350_a3_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275711_446_a2_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275711_482_a3_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1275711_661_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1277021_161_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1286061_019_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1286061_100_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1286061_482_f_om.webp
ADDED
|
Git LFS Details
|
tasks/columbia/environment/reference/clone/static/assets/media/1286062_445_f_om.webp
ADDED
|
Git LFS Details
|