Skip to content

About

Auto项目的改建

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

AutoFan — Dataset & Artifacts

中文版完整架构、实现、运行和扩展说明请参阅 TECHNICAL_DOCUMENTATION_ZH.md。

One-liner. Artifact repository for converting RFC prose into executable I/O grammars, with evaluation results across five protocols (SMTP, POP3, IMAP, FTP, ManageSieve).

Who is this for?

Engineers and researchers who read RFCs for protocol testing and want an automated path from RFC text to formal I/O grammars and executable tests.

What’s inside

  • README.md — this file.
  • Protocols_and_CMDs_List.txt — consolidated protocol and command lists referenced in the evaluation.
  • src/ — minimal method-supporting code (context only).
  • RFC/ — RFC inputs and machine-readable artifacts.
  • Evaluation/ — generated results and manual ground truth for five protocols.

Data layers at a glance

  • Preprocessed (RFC/rfc_text/) — cleaned RFC text used as inputs to grammar synthesis.
  • Protocol artifacts (RFC/protocol_spec_artifacts/) — machine-readable artifacts derived from RFCs (consumed by synthesis).
  • Generated (Evaluation/experiments/<protocol>/generated_grammars/) — outputs from AutoFan’s synthesis-and-repair process.
  • Manual ground truth (Evaluation/experiments/<protocol>/manual_grammars/) — expert-curated “golden” I/O grammars used for reference.

Directory overview (exact)

AutoFan/
├─ README.md
├─ Protocols_and_CMDs_List.txt      # consolidated protocol/command lists
├─ src/                             # method-supporting code 
├─ RFC/
│  ├─ rfc_text/                     # cleaned RFC text
│  └─ protocol_spec_artifacts/      # machine-readable artifacts derived from RFCs
└─ Evaluation/
   └─ experiments/                  # one folder per protocol
      ├─ <protocol>/
      │  ├─ manual_grammars/        # expert-curated (golden) I/O grammars
      │  └─ generated_grammars/     # synthesis-and-repair outputs per iteration
      │     ├─ grammar_iterN.fan    # generated grammar at iteration N (N=1,2,3…)
      │     ├─ fandango_output_iterN.txt  # execution logs / run outputs
      │     ├─ evaluation_iterN.json      # fix/evaluation report at iteration N
      │     └─ FINAL_REPORT_iterK.md      # final summary when a run converges (K = final iter)
      ├─ SMTP/
      ├─ POP3/
      ├─ IMAP/
      ├─ FTP/
      └─ ManageSieve/

Notes on experiments

For each protocol, generated_grammars/ contains the per-iteration grammar (.fan), its execution log (.txt), and the evaluator/fix report (.json). If a run converges, a FINAL_REPORT_iterK.md summarizes the successful iteration.

Rebuilding the preprocessed RFC text

The first stage is deterministic and does not call an LLM. It reads the five official RFC Editor plain-text documents from RFC/raw/, removes page furniture, identifies numbered sections and appendices, and writes compatible section JSON files to RFC/rfc_text_generated/. The checked-in author results under RFC/rfc_text/ are never overwritten.

Run the full evaluation corpus:

python -m src.autospec.preprocessing batch

This also writes structural and normalized-text comparisons to RFC/preprocessing_reports/. To process one RFC:

python -m src.autospec.preprocessing preprocess \
  --rfc 1939 \
  --input RFC/raw/rfc1939.txt \
  --output RFC/rfc_text_generated/rfc1939

Each generated section uses the input shape expected by the semantic extraction stage:

{
  "section_number": "4",
  "section_name": "The AUTHORIZATION State",
  "content": "4. The AUTHORIZATION State\n\n..."
}

The preprocessor conservatively preserves paragraph, ABNF, command example, and ASCII-art line breaks. It also produces stable paragraph anchors, although the current semantic extraction code only requires the three fields above.

Qwen configuration and compatibility Stage 1

AutoFan uses Alibaba Cloud Model Studio's OpenAI-compatible endpoint. Fill in the two empty values under [API] in src/autospec/config_rfc.ini:

[API]
api_key = your-DashScope-key
base_url = https://dashscope.aliyuncs.com/compatible-mode/v1
model_id = qwen-plus
enable_thinking = false

For better secret hygiene, leave api_key empty and export DASHSCOPE_API_KEY instead. Install dependencies and run the original three-prompt workflow (classification, extraction, LLM multigraph generation):

python -m pip install -r requirements.txt
python -m src.autospec.llm_client --config src/autospec/config_rfc.ini
# Add --live to send one small connectivity request.
python -m src.autospec.agents.stage1.rfc_summarizer_agent \
  --config src/autospec/config_rfc.ini

Generated artifacts are written to RFC/protocol_spec_artifacts_generated/rfc1939/; the author's reference files remain unchanged. The Qwen JSON requests disable thinking by default because JSON Object mode is not reliable for hybrid-thinking output.

The later grammar retrieval/fixing stage has heavier embedding dependencies; install those only when needed with requirements-stage2.txt. A Python 3.12 virtual environment is recommended for broad PyTorch and parser-wheel compatibility:

uv venv --python 3.12 .venv
source .venv/bin/activate
uv pip install torch --index-url https://download.pytorch.org/whl/cpu
uv pip install -r requirements-stage2.txt
fandango --version

Live POP3 smoke test

After generating the RFC 1939 USER -> PASS -> QUIT grammar, run it against the strict local test server (loopback only):

.venv/bin/python scripts/live_pop3_smoke.py

The runner allocates an unused local port, starts a minimal POP3 server, runs one real fandango talk session, and requires the received command sequence to be exactly USER, PASS, QUIT. It also checks CRLF framing, non-empty test credentials, successful responses, and clean completion. The socket transcript and Fandango output are saved to output/stage2_smoke/rfc1939_user_pass_quit/live_validation_summary.json.

Regenerate this sample through the current retrieval/LLM pipeline and compare it with the initial grammar using reproducible random seeds:

.venv/bin/python scripts/regenerate_pop3_smoke_grammar.py
.venv/bin/python scripts/compare_pop3_grammars.py \
  --runs 20 \
  --seed-start 1 \
  --optimized output/stage2_smoke/rfc1939_user_pass_quit/user_pass_quit_regenerated.fan \
  --report output/stage2_smoke/rfc1939_user_pass_quit/reproducible_constraint_comparison.json

Generate and live-test the representative POP3 response classes (STAT single-line, LIST multi-line listing, and RETR dot-stuffed message data):

.venv/bin/python scripts/generate_pop3_representative_grammars.py
.venv/bin/python scripts/test_pop3_representative_grammars.py \
  --runs 10 --seed-start 1

The local server validates the exact command sequence and RFC framing. The aggregate traces are written to output/stage2_representative/rfc1939/live_validation_summary.json unless a different --report path is supplied.

Structured-IR Stage 2 (improved mode)

The original compatibility mode asks the LLM to write an entire Fandango grammar. The improved ir mode divides the work differently:

  1. Qwen extracts RFC semantics into a typed JSON IR, including short RFC evidence quotes.
  2. A semantic audit checks exact path/order, state names, concrete argument forms, global length limits, multi-line framing, dot stuffing, and evidence.
  3. Failed audit findings are returned to Qwen for a bounded repair cycle.
  4. Python deterministically compiles a valid IR into Fandango.
  5. A second audit checks productions/references/CRLF/terminators and performs a Fandango load check; live Socket tests verify actual generation.

The direct-LLM workflow remains available as the reproduction baseline. Run the improved mode for one path with:

.venv/bin/python -m src.autospec.agents.stage2.ir_pipeline \
  --config src/autospec/config_rfc.ini \
  --path "AUTHORIZATION (USER PASS) + TRANSACTION (RETR QUIT)" \
  --output output/stage2_ir/rfc1939/retr

[Stage2IR] max_repair_rounds in the config controls the repair budget. Each run keeps retrieval.json, every ir_round_N.json, compiled grammar_round_N.fan, audit_round_N.json, Fandango diagnostics, and a final report. Only an audit-passing run receives final_ir.json and final.fan. This makes semantic changes reviewable and keeps syntax generation fully reproducible.

Generate every minimal path from a JSON corpus. Successful outputs are re-audited and reused on later runs, so interrupted batches can resume safely:

.venv/bin/python -m src.autospec.agents.stage2.ir_pipeline \
  --config src/autospec/config_rfc.ini \
  --paths-file RFC/protocol_spec_artifacts_generated/rfc1939/minimal_paths.json \
  --output output/stage2_ir/rfc1939/all_paths

Run all generated RFC 1939 grammars against the strict loopback POP3 server:

.venv/bin/python scripts/test_pop3_ir_batch.py \
  --runs 3 --seed-start 1 \
  --report output/stage2_ir/rfc1939/all_paths/live_validation_3_seeds.json

The server validates exact command order, CRLF framing, command-specific arguments, single-line responses, multi-line payloads, dot stuffing, and the single-dot terminator for APOP, USER/PASS, DELE, LIST, NOOP, QUIT, RETR, RSET, STAT, TOP, and UIDL paths.

About

Auto项目的改建

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages