Include LeetCode problem numbers in metadata

SE
3h ago
+911-357

Candidates benefit from seeing standard LeetCode problem numbers alongside titles to cross-reference practice material.

Update problem ingestion, schema validation, and metadata generation to capture questionFrontendId from LeetCode, enforce strict type constraints, and propagate the formatted source ("<number>. <title>") across Rust runtime structures, per-page bundles, and frontend tests.

Key Changes

  1. Ingestion & Validation:

    • scripts/problem_bank/fetch.py: Capture questionFrontendId as an integer number during problem scaffolding.
    • scripts/problem_bank/bank.py: Enforce strict positive integer validation for number (type(num) is int and num > 0), properly rejecting booleans, non-positive numbers, and string values.
    • problem-bank/problems.json: Add LeetCode question numbers to imported exercises while preserving original JSON formatting and multi-line array layout.
  2. Metadata Generation & Rust Runtime:

    • scripts/problem_bank/emit.py: Prepend problem number to source (f"{number}. {title}") for imported exercises, and emit source: Option<&'static str> in generated Rust definitions.
    • src/agent.rs: Keep source_title() returning the bare published title for report leakage checks. Add source_label() to return the number-prefixed source label, and use it when comparing generated public metadata.
    • src/agent/problem_rubrics.rs: Regenerate rubric tables with static source string references.
    • web/problems/*.json & web/problem-pages.json: Regenerate 150 per-page scenario files and the client mapping table.
  3. Frontend & Documentation:

    • web/app.js & web/render.js: Update internal documentation regarding map-loaded names and numbers, keeping initial lobby HTML free of published problem identifiers until candidate opt-in.
  4. Test Coverage:

    • tests/test_gen_problems.py: Add test_rejects_invalid_numbers covering -1, 0, True, and "20"; update projection assertions for numbered sources.
    • tests/browser/leetcode-import.test.js: Update expectations to assert ${source.number}. ${source.title}.

Fixes #507

Screenshots

Before
before

After
after