Skip to content

Migration and Maintenance Scripts

This directory contains one-off or maintenance-oriented scripts. These scripts are not part of the normal generation entry points under scripts/.

audit_missing_solutions.py

Audits generated Markdown files and reports:

  • missing language sections
  • complete files whose language section order can be repaired

Examples:

PYTHONPATH=src python migrate/audit_missing_solutions.py
PYTHONPATH=src python migrate/audit_missing_solutions.py --difficulty Hard
PYTHONPATH=src python migrate/audit_missing_solutions.py --frontend-ids 4 10

This script is read-only. It does not call Ollama, does not regenerate code, and does not modify Markdown files. If it reports issues, run scripts/generate_solutions.py for the selected problems to repair or fill them.

audit_suspicious_solutions.py

Audits generated Markdown files for suspicious code blocks, such as unusually long outputs, natural-language explanations inside code fences, Markdown leftovers, or repeated lines.

The length check is dynamic. Each run builds baselines from the currently generated solutions, preferring difficulty + language, then language, then global statistics when samples are limited.

PYTHONPATH=src python migrate/audit_suspicious_solutions.py

The script is read-only for solution files. It writes a local Markdown report to:

migrate/suspicious_solutions_report.md

The report is ignored by Git.

rename_bucket_dirs.py

Renames old bucket directories to fixed-width ranges:

1-100 -> 0001-0100
101-200 -> 0101-0200

Dry run:

python migrate/rename_bucket_dirs.py

Apply the rename:

python migrate/rename_bucket_dirs.py --apply

If the fixed-width target bucket already exists, the script merges files from the old bucket into the target bucket. Existing files are protected by default. To replace same-name files during archival import:

python migrate/rename_bucket_dirs.py --apply --overwrite-files

This migration is intentionally separate from the generator. The generator only writes new paths; this script handles historical directory names when needed.

normalize_markdown_language_sections.py

Normalizes legacy Markdown language headings and code fences for database, shell, and Python Data solutions generated by older versions.

This is a post-generation cleanup tool for historical outputs. Use it after an older generator has finished running, especially on remote machines or clusters that cannot immediately update to the latest generator code. It is intentionally kept outside the normal generation flow so existing long-running jobs do not need to be interrupted.

Examples:

Legacy form Normalized form
## Mysql ## MySQL
mysql</code> | <code>sql
## Pythondata ## PythonData
pythondata</code> | <code>python

Dry run:

python migrate/normalize_markdown_language_sections.py

Apply the rewrite:

python migrate/normalize_markdown_language_sections.py --apply

The script only rewrites Markdown headings and fence language tags. It does not change solution code and does not call the model.