How msv-lab/specfix works
Main system components
• CLI / Entrypoint
• main.py (under specfix/) – parses command-line arguments, kicks off the pipeline
• run.sh – convenience wrapper
• Configuration & Dataset Loader
• Arg parser in main.py
• Dataset loader in dataset/ & dataset/dataset_script.py
• Core Pipeline Modules (under specfix/)
• Prompting (prompting.py): constructs prompts for code generation, test generation, and spec refinement
• Model / LLM API (model.py): wraps calls to OpenAI / Qwen APIs
• Candidate Generator (main.py + model.py + prompting.py): generates N programs per iteration
• Tester (tester.py): runs generated programs against test suites in parallel
• Clusterer (cluster.py): groups functionally equivalent implementations
• Solution Transformer (solution_transformer.py): refines the requirement (spec) based on test outcomes & clustering
• Evaluator / Metrics (evaluator.py): computes success rate, iteration count, etc.
• Utilities (utils.py): JSON I/O, logging, concurrency helpers
• Experiment Harness (experiment/): dozens of standalone scripts for data collection, ambiguity detection, threshold tuning, user studies. They import or invoke the core modules above to run specific workflows.
• Data Storage
• JSONL files under dataset/ and experiment/…/*.jsonl
• Ground-truth, interim outputs, and final reports
Relationships & Dataflow
• The CLI/Entrypoint reads arguments (dataset name, path, API key, model, temperature, num-programs, max-iterations)
→ calls the Pipeline Orchestrator in main.py.
• Dataset Loader reads examples from JSONL or CSV → hands off to the orchestrator.
• For each iteration:
a. Orchestrator calls Prompting → builds generation prompt
b. Orchestrator calls Model → sends prompt to external LLM API → receives N candidate programs
c. Orchestrator sends candidates to Tester → runs test suite concurrently → returns pass/fail metadata
d. Orchestrator feeds test results to Clusterer → groups implementations into equivalence clusters
e. Orchestrator uses Solution Transformer → generates clarified/refined requirement for next iteration
f. Loop back until convergence or max iterations
• On completion, Evaluator collects metrics, writes final reports to disk
Architectural Patterns & Principles
• Pipeline / Orchestrator pattern: clear sequential steps, but parallelism inside testing
• Iterative feedback loop: spec refinement and re-generation until convergence
• Modular design: each core responsibility (prompting, LLM interface, testing, clustering, transformation, evaluation) lives in its own module
• Extensibility: experiment scripts plug into the core modules to run different workflows (ambiguity detection, threshold tuning, user study, etc.)
Relevant Technologies & Frameworks
• Language: Python
• LLM APIs: OpenAI or Qwen (via model.py)
• Data format: JSONL, CSV
• Concurrency: Python threads/processes in tester.py
• Third-party libs: jsonlines, evalplus
• CLI: built-in argparse