How devlup-labs/autosetter works
Purpose and entry point
AutoSetter converts a problem-statement image or PDF into a reviewable Codeforces/Polygon-style package: specification, statement, C++ solution/validator/generator/checker, accepted tests, validation report, and manifest. The CLI entry point is app.py; its output pipeline is represented concretely under example/01_intake through example/04_package.
1. Intake and specification extraction
app.py accepts an image/PDF and produces the canonical problem.json specification. Image/PDF handling and structured-model-output processing are separated into utils/image_parser.py and utils/json_generator.py. The extraction prompt is prompts/json_extraction.txt; example/01_intake/problem.json shows the handoff format.
2. Local model boundary
All generation is driven by local Qwen models exposed through Ollama, isolated behind utils/ollama_client.py. Prompt selection/loading is centralized in utils/prompt_loader.py, with artifact-specific contracts in prompts/statement.txt, prompts/solution.txt, prompts/validator.txt, prompts/generator.txt, and prompts/checker.txt. This boundary allows most pipeline logic to run without a model service.
3. Artifact generation
The normalized JSON spec is faned out into independently generated deliverables: Markdown statement plus four C++ programs. File materialization is handled by utils/file_generator.py; the expected generated set is illustrated by example/02_build/statement.md, example/02_build/solution.cpp, and example/02_build/validator.cpp. Generated C++ is compiled against the vendored third_party/testlib.h.
4. Test planning and validation pipeline
utils/test_plan.py defines test-shape intent (boundary, structural, and multi-case distributions), rather than relying only on random seeds. utils/test_pipeline.py performs the critical control flow: compile artifacts; verify validator acceptance of statement samples; generate candidates; reject validator-invalid inputs; solve accepted inputs; and run the checker on reference answers. Outputs include numbered .in/.ans pairs and a diagnosis-bearing report, as shown in example/03_validate/validation_report.json.
5. Independent correctness gates
Release readiness is deliberately stricter than successful generation. The validator is checked against problem samples and against generated tests. The checker must reject deliberately bad outputs (empty, truncated, perturbed), preventing a checker that merely accepts matching files. Test-plan conformance checks generator behavior, including deterministic minimum-case generation. These gates determine whether the process exits successfully or returns the “not fit to release” status.
6. Packaging boundary
utils/packager.py converts accepted artifacts and tests into the portable package layout: problem metadata, statement, source files, solutions, tests, report, and manifest. example/04_package/manifest.json, example/04_package/problem.json, and example/04_package/tests demonstrate the release bundle. The manifest’s readiness flag and validation report are the human-review decision surface.
7. Execution infrastructure
Python is the orchestration runtime; generated contestants/tooling are C++ compiled with g++. A separate Node.js sandbox service executes untrusted C++ inside Docker/nsjail: sandbox/server/src/server.js, sandbox/server/src/executor.js, and sandbox/server/src/config.js. Docker construction is in sandbox/docker/Dockerfile; configuration enforces CPU, memory, PID, and network limits. Ollama is the only required external model service.
Main entry points: packager.py Package builder · problem.json Canonical problem spec · json_generator.py Spec extractor · solution.cpp Generated statement and C++
Components 21
Intake
- AutoSetter CLI · Orchestrates the end-to-end conversion and release decision.
app.py - Image/PDF parser
utils/image_parser.py - Spec extractor
utils/json_generator.py - Extraction prompt
prompts/json_extraction.txt - Canonical problem spec · Normalized handoff for all generated deliverables.
example/01_intake/problem.json
Model generation
- Prompt loader · Loads artifact-specific generation contracts.
utils/prompt_loader.py - Local Qwen via Ollama · External local-model boundary.
utils/ollama_client.py - Artifact prompts · Statement, solution, validator, generator, and checker prompts.
prompts/statement.txt - Artifact materializer
utils/file_generator.py - Generated statement and C++ · Statement plus solution, validator, generator, and checker sources.
example/02_build/solution.cpp - testlib
third_party/testlib.h
Validation
- Test-shape plan · Defines boundary, structural, multi-case, and minimum-case intent.
utils/test_plan.py - Compile and test pipeline · Compiles tools, filters tests, solves them, and checks reference answers.
utils/test_pipeline.py - Accepted test pairs · Numbered input and reference-answer pairs.
example/03_validate/validation_report.json - Validation report · Records diagnoses and readiness gates, including bad-output checker tests.
example/03_validate/validation_report.json
Release package
- Package builder
utils/packager.py - Portable problem package · Contains metadata, statement, sources, solutions, tests, report, and manifest.
example/04_package/manifest.json
Execution sandbox
- Sandbox service · Executes untrusted C++ separately from orchestration.
sandbox/server/src/server.js - Sandbox executor
sandbox/server/src/executor.js - Sandbox limits · Enforces CPU, memory, PID, and network restrictions.
sandbox/server/src/config.js - Sandbox container
sandbox/docker/Dockerfile
Connections 24
- AutoSetter CLI → Image/PDF parser: reads input
- Image/PDF parser → Spec extractor: image/PDF content
- Extraction prompt → Spec extractor: extraction contract
- Spec extractor → Local Qwen via Ollama: structured request
- Spec extractor → Canonical problem spec: writes
- Canonical problem spec → Artifact materializer: generation context
- Prompt loader → Artifact prompts: loads
- Artifact prompts → Local Qwen via Ollama: artifact requests
- Local Qwen via Ollama → Artifact materializer: generated content
- Artifact materializer → Generated statement and C++: writes
- testlib → Generated statement and C++: compiled against
- Canonical problem spec → Test-shape plan: defines coverage for
- Generated statement and C++ → Compile and test pipeline: compile and execute
- Test-shape plan → Compile and test pipeline: candidate distributions
- Compile and test pipeline → Accepted test pairs: accepted .in/.ans pairs
- Compile and test pipeline → Validation report: diagnoses and gates
- Generated statement and C++ → Package builder: accepted sources
- Canonical problem spec → Package builder: metadata
- Accepted test pairs → Package builder: tests
- Validation report → Package builder: readiness decision
- Package builder → Portable problem package: assembles
- Sandbox service → Sandbox executor: dispatches
- Sandbox limits → Sandbox executor: enforces limits
- Sandbox container → Sandbox executor: runtime isolation