Skip to content

feat(design): screenshots-only viewer, list filtering, admin requeue - #70

Merged
echobt merged 3 commits into
mainfrom
design-display-fixes
Aug 7, 2026
Merged

feat(design): screenshots-only viewer, list filtering, admin requeue#70
echobt merged 3 commits into
mainfrom
design-display-fixes

Conversation

@echobt

@echobt echobt commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Screenshots-only servingGET /v1/view/{id}/{page} now serves PNG artifacts only (image/png); .html/bare page names get 410 Gone with a short JSON error. GET /v1/runs/{id}/bundle.json no longer embeds produced HTML — also 410 Gone with a pointer to /v1/runs/{id}/pages (metadata) and /v1/view/{id}/index.png. Produced HTML is never served; the gateway view-lockdown header floor stays as defense in depth.
  • Public list filtering — site-api design_submission now returns None unless the run has a captured index.png (explicit screenshot_url or pages list), so failed/no-artifact runs no longer render dead view links on the public site. Submission.url becomes Option<String>; design rows drop the html url and keep screenshotUrl only (prism rows unchanged).
  • Manual round trigger — new POST /v1/admin/rounds/current/requeue (operator bearer, master-local like the other v1/admin/* routes) schedules every active harness into the current open round via the existing idempotent schedule_harness_for_round; a second call is a no-op (same run ids, no quota burn), and quota-blocked harnesses are reported under skipped.
  • Contract/docsDESIGN_CHALLENGE.md §5/§6/§13, SITE_API.md, docs/external-miner/design.md, and the design-check pin (raw_never_servedhtml_never_served) updated to the screenshots-only wording.

Decisions

  • 410 Gone (not 404 / not strip) for both retired shapes: an explicit, greppable signal with a JSON pointer beats a bare 404, and for bundle.json a stripped-to-metadata body would byte-duplicate /v1/runs/{id}/pages while silently dropping the content callers actually wanted.
  • Requeue uses the current round id (floor(unix/8640)), complementing submit-time scheduling into round+1.

Test plan

  • view_page_serves_screenshots_only.html/bare → 410 JSON (no HTML leak, no Set-Cookie), index.png → 200 image/png byte-exact, missing png → 404
  • bundle_json_is_gone — 410, stored HTML not in body
  • admin_requeue_schedules_current_round_once — 401 without bearer; 2 harnesses scheduled into current round; second call identical + quota untouched
  • design_submission_requires_screenshot (map) + design_submissions_exclude_runs_without_screenshots (handler, wiremock) — html-only and detail-less runs excluded, html+png run included
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (166 suites, 0 failures), xtask loc-cap (site-api 1481/1500), consensus-lint, spec-check, design-check, external-docs-check, cargo deny check — all green

Deploy note

Prod deploys from pins (deploy/pins/prod.json), so this takes effect only after merge → tag → pin bump per deploy/AGENTS.md. That is a follow-up, not part of this PR. Public miner docs PR for BaseIntelligence/design-challenge accompanies this change.

Summary by CodeRabbit

  • New Features

    • Design submissions now provide captured PNG screenshots through a dedicated preview URL.
    • Added an administrator option to requeue active harnesses into the current round, with scheduled and skipped results.
  • Changes

    • Design viewers now serve full-page PNG screenshots only.
    • HTML pages and bundle responses are retired and return 410 Gone.
    • Submissions without captured screenshots are excluded from design listings.
    • Page metadata remains available separately from visual previews.

echobt added 3 commits August 7, 2026 05:18
Viewer contract is screenshots-only: GET /v1/view/{id}/{page} serves
PNG artifacts (image/png) and answers 410 Gone with a JSON error for
.html/bare page names; bundle.json no longer embeds produced HTML
(410 Gone, use /v1/runs/{id}/pages for metadata). The gateway view
lockdown floor stays as defense in depth.

The public submissions list now keys on the captured screenshot:
design_submission returns None unless the run has index.png evidence
(screenshot_url field or pages list), so failed/no-artifact runs no
longer render dead view links. Submission.url becomes optional; design
rows drop the html url and keep screenshot_url only.
Operator escape hatch to (re)fill the current open round: loops
list_active_harnesses and schedules each via the existing
schedule_harness_for_round. Idempotent for the current round — a
(harness, round) pair with runs returns its existing ids, so a second
call creates nothing and consumes no quota; quota-blocked harnesses
are reported under `skipped` without failing the rest. Bearer-protected
via check_admin like candidates/winners and master-local by gateway
policy (v1/admin/* is not proxied).
DESIGN_CHALLENGE.md §5/§6/§13: produced HTML is never served (was
"raw HTML"); the viewer serves PNG screenshots only, .html requests
and bundle.json return 410 Gone, and the CSP sandbox floor is now
documented as the gateway-enforced defense-in-depth layer. Route
tables updated, including POST /v1/admin/rounds/current/requeue.
SITE_API.md and docs/external-miner/design.md synced to the new
viewer/pages semantics; design-check pin raw_never_served renamed to
html_never_served with the new wording.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The design viewer now serves PNG screenshots only. HTML and bundle responses return 410 Gone. Design submissions require screenshots. Administrators can requeue active harnesses into the current round with idempotent results.

Changes

Design delivery and requeue

Layer / File(s) Summary
Screenshot-only viewer
crates/design-http/src/api.rs, docs/DESIGN_CHALLENGE.md, docs/external-miner/design.md, docs/DESIGN_CHALLENGE_CHECKLIST.md, xtask/src/design_check.rs
The viewer serves PNG artifacts only. HTML, bare-page, and bundle requests return 410 Gone. Documentation and checks use the produced-HTML marker.
Screenshot-backed submissions
crates/site-types/src/types.rs, crates/site-api/src/map.rs, crates/site-api/src/handlers.rs, docs/SITE_API.md
Design submissions require screenshot evidence, expose screenshot_url, and omit the optional HTML url. Runs without screenshots are excluded.
Current-round admin requeue
crates/design-http/src/api.rs, docs/DESIGN_CHALLENGE.md
The new administrator endpoint schedules active harnesses, reports skipped harnesses, and remains idempotent across repeated calls.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AdminClient
  participant admin_requeue_current
  participant CurrentRound
  participant ActiveHarnesses
  AdminClient->>admin_requeue_current: POST /v1/admin/rounds/current/requeue
  admin_requeue_current->>CurrentRound: Authenticate and load open round
  admin_requeue_current->>ActiveHarnesses: Schedule active harnesses
  ActiveHarnesses-->>admin_requeue_current: Return scheduled and skipped harnesses
  admin_requeue_current-->>AdminClient: Return requeue report
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: screenshots-only viewing, submission filtering, and the admin requeue endpoint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch design-display-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/design-http/src/api.rs`:
- Around line 1351-1366: Replace the hard-coded admin token in
admin_requeue_schedules_current_round_once with a test-only value generated at
runtime, and use that value consistently when hashing and authenticating the
request. Do not log, document, or otherwise expose the generated token or any
full secret value.
- Around line 761-767: Update the PNG validation in the surrounding viewer
handler so it allows only the exact `index.png` artifact, rejecting every other
path or filename with the existing gone response; preserve successful serving
for `index.png`.
- Around line 949-981: Update schedule_harness_for_round to handle
StoreError::Duplicate from insert_run by re-reading the existing runs for the
harness and round and returning their run IDs as a successful scheduling result.
Preserve normal success behavior and continue propagating non-duplicate errors,
so concurrent requeue requests remain idempotent instead of marking the harness
skipped.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 603264b4-26a4-4607-b955-cf5f93564695

📥 Commits

Reviewing files that changed from the base of the PR and between 2d6711a and eeef2bd.

📒 Files selected for processing (9)
  • crates/design-http/src/api.rs
  • crates/site-api/src/handlers.rs
  • crates/site-api/src/map.rs
  • crates/site-types/src/types.rs
  • docs/DESIGN_CHALLENGE.md
  • docs/DESIGN_CHALLENGE_CHECKLIST.md
  • docs/SITE_API.md
  • docs/external-miner/design.md
  • xtask/src/design_check.rs

Comment on lines +761 to +767
if !page.ends_with(".png") {
return json_err(
StatusCode::GONE,
"gone",
"produced HTML is never served; fetch the index.png screenshot instead",
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Allow only index.png.

Line 761 accepts every path ending in .png. A stored non-screenshot artifact can then become public through the viewer. This breaks the screenshots-only contract.

Proposed fix
-    if !page.ends_with(".png") {
+    if page != "index.png" {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if !page.ends_with(".png") {
return json_err(
StatusCode::GONE,
"gone",
"produced HTML is never served; fetch the index.png screenshot instead",
);
}
if page != "index.png" {
return json_err(
StatusCode::GONE,
"gone",
"produced HTML is never served; fetch the index.png screenshot instead",
);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/design-http/src/api.rs` around lines 761 - 767, Update the PNG
validation in the surrounding viewer handler so it allows only the exact
`index.png` artifact, rejecting every other path or filename with the existing
gone response; preserve successful serving for `index.png`.

Comment on lines +949 to +981
async fn admin_requeue_current(State(st): State<Arc<AppState>>, headers: HeaderMap) -> Response {
if let Err(r) = check_admin(&st, &headers) {
return r;
}
let rid = round_id_at(now_secs());
let harnesses = match st.store.list_active_harnesses(rid).await {
Ok(h) => h,
Err(e) => return json_err(StatusCode::INTERNAL_SERVER_ERROR, "store", &e.to_string()),
};
let epoch = st.epoch.load(std::sync::atomic::Ordering::Relaxed);
let mut scheduled = Vec::new();
let mut skipped = Vec::new();
for harness in &harnesses {
match schedule_harness_for_round(st.store.as_ref(), harness, rid, st.netuid, epoch).await {
Ok(run_ids) => scheduled.push(json!({
"harness_id": harness.id,
"miner_hotkey": harness.miner_hotkey,
"run_ids": run_ids,
})),
Err(e) => skipped.push(json!({
"harness_id": harness.id,
"miner_hotkey": harness.miner_hotkey,
"reason": e,
})),
}
}
Json(json!({
"round_id": rid,
"scheduled": scheduled,
"skipped": skipped,
}))
.into_response()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

fd -t f -e rs . crates | while IFS= read -r file; do
  ast-grep outline "$file" --items all --match 'DesignStore|insert_run|runs_for_round' || true
done

rg -n -C 5 'trait\s+DesignStore|fn\s+insert_run|fn\s+runs_for_round|INSERT INTO.*run|UNIQUE.*run' crates

Repository: BaseIntelligence/base

Length of output: 26201


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== api schedule_harness_for_round and admin_requeue_current =="
fd -a api.rs crates | while IFS= read -r file; do
  echo "--- $file"
  rg -n -C 8 'fn schedule_harness_for_round|admin_requeue_current|check_.*runs|#\(.*run' "$file" || true
done

echo "== db schema constraints for design_run =="
sed -n '1,120p' crates/db/migrations/0006_design_challenge.sql

echo "== design-db insert_design_run and runs_for_round =="
sed -n '440,540p' crates/design-db/src/lib.rs
sed -n '590,700p' crates/design-db/src/lib.rs

echo "== design-store implementations and errors =="
sed -n '300,365p' crates/design-store/src/store.rs
sed -n '230,285p' crates/design-store/src/dbstore.rs

echo "== deterministic schema/behavior probe =="
python3 - <<'PY'
import pathlib
p = pathlib.Path('crates/db/migrations/0006_design_challenge.sql')
text = p.read_text()
print('CREATE TABLE design_run exists:', 'CREATE TABLE design_run' in text)
print('CREATE TABLE design_run lines:')
tbl = []
collect = False
for line in text.splitlines():
    if line.startswith('CREATE TABLE design_run'):
        collect = True
    if collect:
        tbl.append(line)
        if ');' in line:
            break
print('\n'.join(tbl))
print('contains UNIQUE:', any('UNIQUE' in l for l in tbl))
print('contains PRIMARY KEY:', any('PRIMARY KEY' in l for l in tbl))
print('constraints:', [l.strip() for l in tbl if any(k in l for k in ('PRIMARY KEY', 'UNIQUE', 'CONSTRAINT', 'FOREIGN KEY', 'REFERENCES', 'NOT NULL'))])
for key in ('CREATE TABLE design_round', 'CREATE TABLE design_artifact', 'CREATE TABLE design_stage_event'):
    print(f'{key} exists:', key in text)
PY

Repository: BaseIntelligence/base

Length of output: 21444


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== schedule_harness_for_round implementation =="
sed -n '441,580p' crates/design-http/src/api.rs

echo "== StoreError variants and DB error mapping =="
rg -n -C 6 'enum StoreError|StoreError::.*Duplicate|map_db|impl From<DbError>|Backend' crates/design-store/src crates/design-http/src/api.rs

echo "== quota helpers =="
rg -n -C 5 'quota|daily|runs_allowed|quota_get|quota_bump|DesignStore' crates/design-http/src/api.rs crates/design-store/src/dbstore.rs crates/design-db/src/lib.rs

Repository: BaseIntelligence/base

Length of output: 50377


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

api = Path('crates/design-http/src/api.rs').read_text()
schema = Path('crates/db/migrations/0006_design_challenge.sql').read_text()
dbstore = Path('crates/design-store/src/dbstore.rs').read_text()
dbs_lib = Path('crates/design-db/src/lib.rs').read_text()

def between(s, start, end):
    return s[s.index(start)+len(start):s.index(end)].strip()

schedule = between(api, 'pub async fn schedule_harness_for_round(', 'pub async fn get_harness')
print('schedule calls runs_for_round:', 'run_ids' in schedule and 'runs_for_round' in schedule)
print('schedule calls get_run before insert:', 'if store\n            .get_run' in schedule)
print('schedule calls insert_run:', 'store.insert_run' in schedule)
print('schedule handles insert error:', re.search(r'store\.insert_run\(&row\)\.await\.map_err\(.*\)\?;', schedule) is not None)
print('insert handles duplicate later via get_run?', 'continue;' in schedule and 'return Err("' in schedule)

design_run = between(schema, 'CREATE TABLE design_run (', ');')
unique_ids = re.findall(r'UNIQUE\s*\((.*?)\)', design_run)
pk_ids = re.findall(r'PRIMARY\s+KEY(?:\s*\((.*?)(?:\)|\s+NOT))?', design_run)
print('design_run primary key:', 'id' in pk_ids)
print('design_run unique constraints:', unique_ids)

db_insert_call = re.search(r'impl\s+DesignStore\s+for\s+DbDesignStore\n\s*{(?P<body>.*?)\n}', dbstore, re.S).group('body')
print('DbDesignStore insert_run calls insert_design_run:', 'async fn insert_run' in db_insert_call and 'insert_design_run' in db_insert_call)
print('DbDesignStore insert_run maps errors:', '.map_err(map_db)' in db_insert_call)

map_db = re.search(r'fn\s+map_db\(.*?\n\{(?P<body>.*?)\n\}', dbstore, re.S).group('body')
print('map_db treats duplicate/unique as StoreError::Duplicate:', 'duplicate' in map_db and 'unique' in map_db and 'StoreError::Duplicate' in map_db)

insert_design_run_call = re.search(r'pub\s+async\s+fn\s+insert_design_run\([^;]+;', dbs_lib).group(0)
print('insert_design_run INSERT id only:', 'VALUES ($1' in insert_design_run_call and not 'ON CONFLICT' in insert_design_run_call)
PY

Repository: BaseIntelligence/base

Length of output: 303


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== insert_design_run body =="
python3 - <<'PY'
from pathlib import Path
import re
dbs = Path('crates/design-db/src/lib.rs').read_text()
m = re.search(r'pub async fn insert_design_run\(.*?\n\}\n', dbs, re.S)
if not m:
    # broader until next pub fn
    start = dbs.index('pub async fn insert_design_run')
    search = dbs[start:]
    nexts = [search.index(p, 1) for p in ('\npub ', '\n[', '\n///')]
    end = min(n for n in nexts if n > 0) if any(n > 0 for n in nexts) else len(search)
    print('`#BEGIN`')
    print(search[:end])
    print('`#END`')
else:
    print('`#BEGIN`')
    print(m.group(0))
    print('`#END`')
PY

echo "== behavior probe from source text =="
python3 - <<'PY'
from pathlib import Path
import re
api = Path('crates/design-http/src/api.rs').read_text()
schema = Path('crates/db/migrations/0006_design_challenge.sql').read_text()
dbstore = Path('crates/design-store/src/dbstore.rs').read_text()
dbs_lib = Path('crates/design-db/src/lib.rs').read_text()

start = api.index('pub async fn schedule_harness_for_round(')
end = api.index('\npub async fn get_harness(', start)
schedule = api[start:end]
print('schedule_checks_run_ids_from_round:', 'run_ids: Vec<String> = existing' in schedule and '..filter(|r| r.harness_id == harness.id)' in schedule)
print('schedule_returns_existing_run_ids:', 'if !run_ids.is_empty()' in schedule and 'return Ok(run_ids)' in schedule)
print('schedule_rechecks_each_run_id_before_insert:', re.search(r'if\s+store\s*\.[^\n]*get_run\(&run_id\).*?\.is_some\(\)\s*\{\s*run_ids\.push\(run_id\);', schedule, re.S) is not None)
print('schedule_inserts_run:', 'store.insert_run(&row).await.map_err' in schedule)
print('schedule_promotes_on_insert_success:', 'run_ids.push(run_id)' in schedule and 'store.quota_bump' in schedule)

run = schema[schema.index('CREATE TABLE design_run ('): schema.index('\n\nCREATE TABLE design_artifact', schema.index('CREATE TABLE design_run ('))]
print('design_run_primary_key_id:', re.search(r'id\s+TEXT\s+PRIMARY\s+KEY', run) is not None)
print('design_run_unique_constraints:', ',\n'.join(re.findall(r',?\s*(?:CONSTRAINT\s+\w+\s+)?\s*UNIQUE\s*\([^)]+\)', run, re.S)))

print('DbDesignStore_insert_run_uses_insert_design_run:', 'async fn insert_run' in dbstore and 'insert_design_run' in dbstore[dbstore.index('async fn insert_run'):dbstore.index('async fn get_run')])
print('DbDesignStore_maps_duplicate_errors:', 'if s.contains("duplicate") || s.contains("unique")' in dbstore and 'StoreError::Duplicate' in dbstore[dbstore.index('fn map_db'):dbstore.index('fn extras_from_value')])

print('insert_design_run_plain_insert_no_upsert:', 'fn map_db' not in dbs_lib[dbs_lib.index('pub async fn insert_design_run'):dbs_lib.index('/// Fetch run.')])
PY

Repository: BaseIntelligence/base

Length of output: 715


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

api = Path('crates/design-http/src/api.rs').read_text()
schema = Path('crates/db/migrations/0006_design_challenge.sql').read_text()
dbstore = Path('crates/design-store/src/dbstore.rs').read_text()
dbs_lib = Path('crates/design-db/src/lib.rs').read_text()

start = re.search(r'pub async fn schedule_harness_for_round\(', api).start()
end = re.search(r'(?::#\s*async fn get_harness)', api[start:]) or re.search(r'\n\nasync fn get_harness', api[start:])
schedule = api[start:api.index('\n\nasync fn get_harness', start)]

print('schedule_checks_run_ids_from_round:', 'run_ids: Vec<String> = existing' in schedule and 'filter(|r| r.harness_id == harness.id)' in schedule)
print('schedule_returns_existing_run_ids:', 'if !run_ids.is_empty()' in schedule and 'return Ok(run_ids)' in schedule)
print('schedule_rechecks_each_run_id_before_insert:', re.search(r'if\s+store\s*\.[^\n]*get_run\(&run_id\).*?\.is_some\(\)\s*\{\s*run_ids\.push\(run_id\);', schedule, re.S) is not None)
print('schedule_inserts_run:', 'store.insert_run(&row).await.map_err' in schedule)
print('schedule_promotes_on_insert_success:', 'run_ids.push(run_id)' in schedule and 'store.quota_bump' in schedule)

run = schema[schema.index('CREATE TABLE design_run ('): schema.index('\n\nCREATE TABLE design_artifact', schema.index('CREATE TABLE design_run ('))]
print('design_run_primary_key_id:', re.search(r'id\s+TEXT\s+PRIMARY\s+KEY', run) is not None)
print('design_run_unique_constraints:', ',\n'.join(re.findall(r',?\s*(?:CONSTRAINT\s+\w+\s+)?\s*UNIQUE\s*\([^)]+\)', run, re.S)))

insert_start = dbstore.index('async fn insert_run')
insert_end = dbstore.index('async fn get_run')
insert_chunk = dbstore[insert_start:insert_end]
print('DbDesignStore_insert_run_uses_insert_design_run:', 'insert_design_run' in insert_chunk)
print('DbDesignStore_maps_duplicate_errors:', 'if s.contains("duplicate") || s.contains("unique")' in dbstore[dbstore.index('fn map_db'):dbstore.index('fn extras_from_value')])

ins_start = dbs_lib.index('pub async fn insert_design_run')
ins_end = dbs_lib.index('/// Fetch run.', ins_start)
print('insert_design_run_plain_insert_no_upsert:', 'ON CONFLICT' not in dbs_lib[ins_start:ins_end])
PY

Repository: BaseIntelligence/base

Length of output: 566


Handle run-insert races by reading existing runs after a duplicate error.

design_run only has id as a key, so insert_design_run is a plain insert and concurrent /requeue calls can both pass the empty per-round check. insert_run maps duplicate/unique DB errors to StoreError::Duplicate, but schedule_harness_for_round treats that as scheduling failure and reports the harness as skipped. On that error, re-read runs for (harness, round) instead of returning the error so the endpoint stays idempotent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/design-http/src/api.rs` around lines 949 - 981, Update
schedule_harness_for_round to handle StoreError::Duplicate from insert_run by
re-reading the existing runs for the harness and round and returning their run
IDs as a successful scheduling result. Preserve normal success behavior and
continue propagating non-duplicate errors, so concurrent requeue requests remain
idempotent instead of marking the harness skipped.

Comment on lines +1351 to +1366
async fn admin_requeue_schedules_current_round_once() {
let admin_token = "test-admin-token";
let gating = Arc::new(MemoryGatingStore::new());
let st = Arc::new(AppState {
store: Arc::new(MemoryDesignStore::new()),
epoch: std::sync::atomic::AtomicU64::new(0),
netuid: 541,
backend_mode: "memory",
annotator_token_hashes: vec![],
admin_token_hashes: vec![token_hash(admin_token)],
frame_ancestors: "'none'".into(),
retry_max: 2,
award_hook: None,
gating: Some(Arc::clone(&gating) as Arc<dyn GatingStore>),
metagraph: None,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Remove the literal bearer token.

Line 1352 embeds an operator bearer token in source. Generate a test-only value at runtime and do not print it.

As per coding guidelines, “Never log, document, or include evidence containing private keys, wallet mnemonics, API tokens, or full secret values.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/design-http/src/api.rs` around lines 1351 - 1366, Replace the
hard-coded admin token in admin_requeue_schedules_current_round_once with a
test-only value generated at runtime, and use that value consistently when
hashing and authenticating the request. Do not log, document, or otherwise
expose the generated token or any full secret value.

Source: Coding guidelines

@echobt
echobt merged commit ba0040f into main Aug 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant