Spaces:
Sleeping
Sleeping
Remove integrity gate and rely on private database access
Browse files- app.py +2 -23
- data/friedman_references.jsonl +0 -0
- data/records.jsonl +0 -0
- packing_benchmark/store.py +6 -11
app.py
CHANGED
|
@@ -1780,8 +1780,6 @@ def submission_guide_html() -> str:
|
|
| 1780 |
|
| 1781 |
def setup_title(setup: str) -> str:
|
| 1782 |
for record in cached_reference_records():
|
| 1783 |
-
if record.get("_integrity_errors"):
|
| 1784 |
-
continue
|
| 1785 |
if record.get("setup") == setup and record.get("title"):
|
| 1786 |
return str(record["title"])
|
| 1787 |
return setup
|
|
@@ -1794,8 +1792,6 @@ def setup_updated(setup: str) -> str:
|
|
| 1794 |
if text:
|
| 1795 |
return text
|
| 1796 |
for record in cached_reference_records():
|
| 1797 |
-
if record.get("_integrity_errors"):
|
| 1798 |
-
continue
|
| 1799 |
if record.get("setup") != setup:
|
| 1800 |
continue
|
| 1801 |
meta = record.get("friedman_reference")
|
|
@@ -1819,12 +1815,12 @@ def setup_choices() -> list[str]:
|
|
| 1819 |
choices = {
|
| 1820 |
str(record["setup"])
|
| 1821 |
for record in cached_reference_records()
|
| 1822 |
-
if record.get("setup")
|
| 1823 |
}
|
| 1824 |
choices.update(
|
| 1825 |
str(record["setup"])
|
| 1826 |
for record in cached_verified_records()
|
| 1827 |
-
if record.get("verified") and record.get("setup")
|
| 1828 |
)
|
| 1829 |
return sorted(choices, key=lambda setup: (setup_title(setup).lower(), setup.lower()))
|
| 1830 |
|
|
@@ -1929,8 +1925,6 @@ def author_credit_html(author: str) -> str:
|
|
| 1929 |
def existing_author_choices() -> list[str]:
|
| 1930 |
seen: dict[str, str] = {}
|
| 1931 |
for record in [*cached_reference_records(), *cached_verified_records()]:
|
| 1932 |
-
if record.get("_integrity_errors"):
|
| 1933 |
-
continue
|
| 1934 |
name = display_author(record)
|
| 1935 |
normalized = name.strip()
|
| 1936 |
if not normalized or normalized.lower() in {"unknown", "anonymous"}:
|
|
@@ -2131,20 +2125,6 @@ def previous_bests_table(record: dict[str, Any]) -> str:
|
|
| 2131 |
)
|
| 2132 |
|
| 2133 |
|
| 2134 |
-
def integrity_status_text(record: dict[str, Any], visual_record: dict[str, Any]) -> str:
|
| 2135 |
-
errors = list(record.get("_integrity_errors") or [])
|
| 2136 |
-
if visual_record is not record:
|
| 2137 |
-
errors.extend(list(visual_record.get("_integrity_errors") or []))
|
| 2138 |
-
if errors:
|
| 2139 |
-
return "failed: " + "; ".join(esc(error) for error in errors)
|
| 2140 |
-
integrity = record.get("integrity") or visual_record.get("integrity")
|
| 2141 |
-
if isinstance(integrity, dict) and integrity.get("signature"):
|
| 2142 |
-
return "verified with signed record and solution hashes"
|
| 2143 |
-
if isinstance(integrity, dict):
|
| 2144 |
-
return "verified with record and solution hashes"
|
| 2145 |
-
return "legacy row; no integrity stamp"
|
| 2146 |
-
|
| 2147 |
-
|
| 2148 |
def visual_provenance(record: dict[str, Any], visual_record: dict[str, Any]) -> str:
|
| 2149 |
source_case = str(visual_record.get("monotone_upper_bound_from_case") or "").strip()
|
| 2150 |
if source_case:
|
|
@@ -2198,7 +2178,6 @@ def record_detail_rows(record: dict[str, Any], visual_record: dict[str, Any], so
|
|
| 2198 |
rows: list[str] = []
|
| 2199 |
rows.append(detail_row("Rendering", esc(visual_provenance(record, visual_record))))
|
| 2200 |
rows.append(detail_row("Record date", record_date_with_source(record)))
|
| 2201 |
-
rows.append(detail_row("Database integrity", esc(integrity_status_text(record, visual_record))))
|
| 2202 |
if record.get("record_type") == "reference" and visual_record.get("verified"):
|
| 2203 |
if is_trivial_record(record):
|
| 2204 |
rows.append(
|
|
|
|
| 1780 |
|
| 1781 |
def setup_title(setup: str) -> str:
|
| 1782 |
for record in cached_reference_records():
|
|
|
|
|
|
|
| 1783 |
if record.get("setup") == setup and record.get("title"):
|
| 1784 |
return str(record["title"])
|
| 1785 |
return setup
|
|
|
|
| 1792 |
if text:
|
| 1793 |
return text
|
| 1794 |
for record in cached_reference_records():
|
|
|
|
|
|
|
| 1795 |
if record.get("setup") != setup:
|
| 1796 |
continue
|
| 1797 |
meta = record.get("friedman_reference")
|
|
|
|
| 1815 |
choices = {
|
| 1816 |
str(record["setup"])
|
| 1817 |
for record in cached_reference_records()
|
| 1818 |
+
if record.get("setup")
|
| 1819 |
}
|
| 1820 |
choices.update(
|
| 1821 |
str(record["setup"])
|
| 1822 |
for record in cached_verified_records()
|
| 1823 |
+
if record.get("verified") and record.get("setup")
|
| 1824 |
)
|
| 1825 |
return sorted(choices, key=lambda setup: (setup_title(setup).lower(), setup.lower()))
|
| 1826 |
|
|
|
|
| 1925 |
def existing_author_choices() -> list[str]:
|
| 1926 |
seen: dict[str, str] = {}
|
| 1927 |
for record in [*cached_reference_records(), *cached_verified_records()]:
|
|
|
|
|
|
|
| 1928 |
name = display_author(record)
|
| 1929 |
normalized = name.strip()
|
| 1930 |
if not normalized or normalized.lower() in {"unknown", "anonymous"}:
|
|
|
|
| 2125 |
)
|
| 2126 |
|
| 2127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2128 |
def visual_provenance(record: dict[str, Any], visual_record: dict[str, Any]) -> str:
|
| 2129 |
source_case = str(visual_record.get("monotone_upper_bound_from_case") or "").strip()
|
| 2130 |
if source_case:
|
|
|
|
| 2178 |
rows: list[str] = []
|
| 2179 |
rows.append(detail_row("Rendering", esc(visual_provenance(record, visual_record))))
|
| 2180 |
rows.append(detail_row("Record date", record_date_with_source(record)))
|
|
|
|
| 2181 |
if record.get("record_type") == "reference" and visual_record.get("verified"):
|
| 2182 |
if is_trivial_record(record):
|
| 2183 |
rows.append(
|
data/friedman_references.jsonl
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/records.jsonl
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
packing_benchmark/store.py
CHANGED
|
@@ -9,7 +9,6 @@ from typing import Any
|
|
| 9 |
|
| 10 |
from .dates import date_from_friedman_record, date_from_submission
|
| 11 |
from .hub_sync import maybe_sync_dataset
|
| 12 |
-
from .integrity import attach_integrity_status, seal_record
|
| 13 |
from .renderer import svg_markup
|
| 14 |
from .verifier import (
|
| 15 |
DEFAULT_TOLERANCE,
|
|
@@ -95,7 +94,7 @@ class SolutionStore:
|
|
| 95 |
with self.records_path.open() as f:
|
| 96 |
for line in f:
|
| 97 |
if line.strip():
|
| 98 |
-
records.append(
|
| 99 |
return records
|
| 100 |
|
| 101 |
def load_reference_records(self) -> list[dict[str, Any]]:
|
|
@@ -105,7 +104,7 @@ class SolutionStore:
|
|
| 105 |
with self.references_path.open() as f:
|
| 106 |
for line in f:
|
| 107 |
if line.strip():
|
| 108 |
-
records.append(
|
| 109 |
return records
|
| 110 |
|
| 111 |
def normalized_public_record(self, record: dict[str, Any]) -> dict[str, Any]:
|
|
@@ -126,12 +125,11 @@ class SolutionStore:
|
|
| 126 |
references = [
|
| 127 |
self.normalized_public_record(r)
|
| 128 |
for r in self.load_reference_records()
|
| 129 |
-
if not r.get("_integrity_errors")
|
| 130 |
]
|
| 131 |
verified = [
|
| 132 |
self.normalized_public_record(r)
|
| 133 |
for r in self.load_records()
|
| 134 |
-
if r.get("verified")
|
| 135 |
]
|
| 136 |
if setup and setup != "All":
|
| 137 |
references = [r for r in references if r.get("setup") == setup]
|
|
@@ -184,11 +182,10 @@ class SolutionStore:
|
|
| 184 |
|
| 185 |
def write_records(self, records: list[dict[str, Any]]) -> None:
|
| 186 |
tmp = self.records_path.with_suffix(".tmp")
|
| 187 |
-
signed_at = datetime.now(UTC).isoformat(timespec="seconds")
|
| 188 |
with tmp.open("w") as f:
|
| 189 |
for record in records:
|
| 190 |
clean = clean_record_for_storage(record)
|
| 191 |
-
f.write(json.dumps(
|
| 192 |
tmp.replace(self.records_path)
|
| 193 |
|
| 194 |
def solution_for_record(self, record: dict[str, Any]) -> dict[str, Any]:
|
|
@@ -235,7 +232,7 @@ class SolutionStore:
|
|
| 235 |
candidates = [
|
| 236 |
self.normalized_public_record(record)
|
| 237 |
for record in self.load_reference_records()
|
| 238 |
-
if
|
| 239 |
]
|
| 240 |
if metric_symbol:
|
| 241 |
symbol_candidates = [record for record in candidates if str(record.get("metric_symbol") or "s") == metric_symbol]
|
|
@@ -284,15 +281,13 @@ class SolutionStore:
|
|
| 284 |
candidates.extend(
|
| 285 |
self.normalized_public_record(record)
|
| 286 |
for record in self.load_reference_records()
|
| 287 |
-
if
|
| 288 |
-
and str(record.get("case")) == case
|
| 289 |
and str(record.get("metric_symbol") or "s") == metric_symbol
|
| 290 |
)
|
| 291 |
candidates.extend(
|
| 292 |
self.normalized_public_record(record)
|
| 293 |
for record in self.load_records()
|
| 294 |
if record.get("verified")
|
| 295 |
-
and not record.get("_integrity_errors")
|
| 296 |
and str(record.get("case")) == case
|
| 297 |
and str(record.get("metric_symbol") or "s") == metric_symbol
|
| 298 |
)
|
|
|
|
| 9 |
|
| 10 |
from .dates import date_from_friedman_record, date_from_submission
|
| 11 |
from .hub_sync import maybe_sync_dataset
|
|
|
|
| 12 |
from .renderer import svg_markup
|
| 13 |
from .verifier import (
|
| 14 |
DEFAULT_TOLERANCE,
|
|
|
|
| 94 |
with self.records_path.open() as f:
|
| 95 |
for line in f:
|
| 96 |
if line.strip():
|
| 97 |
+
records.append(json.loads(line))
|
| 98 |
return records
|
| 99 |
|
| 100 |
def load_reference_records(self) -> list[dict[str, Any]]:
|
|
|
|
| 104 |
with self.references_path.open() as f:
|
| 105 |
for line in f:
|
| 106 |
if line.strip():
|
| 107 |
+
records.append(json.loads(line))
|
| 108 |
return records
|
| 109 |
|
| 110 |
def normalized_public_record(self, record: dict[str, Any]) -> dict[str, Any]:
|
|
|
|
| 125 |
references = [
|
| 126 |
self.normalized_public_record(r)
|
| 127 |
for r in self.load_reference_records()
|
|
|
|
| 128 |
]
|
| 129 |
verified = [
|
| 130 |
self.normalized_public_record(r)
|
| 131 |
for r in self.load_records()
|
| 132 |
+
if r.get("verified")
|
| 133 |
]
|
| 134 |
if setup and setup != "All":
|
| 135 |
references = [r for r in references if r.get("setup") == setup]
|
|
|
|
| 182 |
|
| 183 |
def write_records(self, records: list[dict[str, Any]]) -> None:
|
| 184 |
tmp = self.records_path.with_suffix(".tmp")
|
|
|
|
| 185 |
with tmp.open("w") as f:
|
| 186 |
for record in records:
|
| 187 |
clean = clean_record_for_storage(record)
|
| 188 |
+
f.write(json.dumps(clean, sort_keys=True) + "\n")
|
| 189 |
tmp.replace(self.records_path)
|
| 190 |
|
| 191 |
def solution_for_record(self, record: dict[str, Any]) -> dict[str, Any]:
|
|
|
|
| 232 |
candidates = [
|
| 233 |
self.normalized_public_record(record)
|
| 234 |
for record in self.load_reference_records()
|
| 235 |
+
if str(record.get("case")) == case
|
| 236 |
]
|
| 237 |
if metric_symbol:
|
| 238 |
symbol_candidates = [record for record in candidates if str(record.get("metric_symbol") or "s") == metric_symbol]
|
|
|
|
| 281 |
candidates.extend(
|
| 282 |
self.normalized_public_record(record)
|
| 283 |
for record in self.load_reference_records()
|
| 284 |
+
if str(record.get("case")) == case
|
|
|
|
| 285 |
and str(record.get("metric_symbol") or "s") == metric_symbol
|
| 286 |
)
|
| 287 |
candidates.extend(
|
| 288 |
self.normalized_public_record(record)
|
| 289 |
for record in self.load_records()
|
| 290 |
if record.get("verified")
|
|
|
|
| 291 |
and str(record.get("case")) == case
|
| 292 |
and str(record.get("metric_symbol") or "s") == metric_symbol
|
| 293 |
)
|