feat(A1): 变异执行器+定向初筛+属性/裁判+分数台账(IR-0004 AC-1/2 rev6,卡 .github#322/#323) - #104
Conversation
…绿;卡 .github#322/#323)
|
Warning Review limit reachedNext included review available in 3 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
PR Summary by QodoAdd A1 mutation/property scoring tools with tamper-evident ledger + weekly workflow
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo
1. Mutmut glob passed as path
|
| cmd = [sys.executable, "-m", "mutmut", "run", | ||
| "--paths-to-mutate", module_glob, "--no-progress"] | ||
| proc = subprocess.run(cmd, cwd=str(work), capture_output=True, text=True, | ||
| timeout=overall_timeout) |
There was a problem hiding this comment.
1. Mutmut glob passed as path 🐞 Bug ≡ Correctness
run_mutmut() passes a file-glob like "src/**/*.py" to mutmut via --paths-to-mutate, but that flag is for source directories/packages, not selecting individual files; with the workflow always installing mutmut, engine=auto will pick mutmut and may fail or score the wrong scope.
Agent Prompt
### Issue description
`run_mutmut()` uses `--paths-to-mutate <module_glob>` where `<module_glob>` is a recursive file glob (e.g. `src/**/*.py`). In mutmut, `paths_to_mutate` is intended to point at source directories/packages needed to run tests, not a file-selection glob. With the weekly workflow installing mutmut, `--engine auto` will select the mutmut engine and this mismatch can break the run or produce an unintended mutation scope.
### Issue Context
- The workflow computes `MODULE_GLOB` as a file glob (e.g. `src/**/*.py`).
- The builtin engine correctly treats it as a glob.
- The mutmut engine should either:
1) translate that glob to one or more source root directories, or
2) ignore `module_glob` for mutmut and rely on mutmut’s own configuration/selection mechanism, or
3) force `--engine builtin` in the scheduled workflow.
### Fix Focus Areas
- pipeline/testing/mutation/run_mutation.py[459-463]
- .github/workflows/mutation-weekly.yml[54-71]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| records = _read_records(path) | ||
| prev_hash = records[-1]["hash"] if records else GENESIS | ||
| record = { |
There was a problem hiding this comment.
2. Ledger append doesn’t validate 🐞 Bug ☼ Reliability
append_entry() assumes the last record has a valid "hash" and never validates the existing hash chain before extending, so a corrupted/tampered ledger can cause a KeyError crash or be extended without an explicit integrity failure at append time.
Agent Prompt
### Issue description
`append_entry()` reads prior records and unconditionally uses `records[-1]["hash"]` as `prev_hash`. If the last record is missing `hash` (or the file is otherwise corrupt-but-JSON), this raises `KeyError` (uncaught) instead of a controlled `LedgerError`. Also, `append_entry()` does not verify the existing chain before appending, so callers can extend a tampered ledger unless they remember to call `verify()` separately.
### Issue Context
The workflow currently calls `append` and then `verify`, but the CLI/tool should be robust and fail-closed on its own. The module docstring claims it “refuses to extend a structurally corrupt ledger”.
### Fix Focus Areas
- pipeline/testing/mutation/ledger.py[61-82]
- pipeline/testing/mutation/ledger.py[85-125]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| mutated = mutate_at(source, site["index"]) | ||
| original = work_file.read_text(encoding="utf-8") | ||
| work_file.write_text(mutated, encoding="utf-8", newline="\n") | ||
| run = run_test_suite(work, runner=runner, timeout=per_mutant_timeout) | ||
| work_file.write_text(original, encoding="utf-8", newline="\n") |
There was a problem hiding this comment.
3. Pycache can skew mutations 🐞 Bug ☼ Reliability
The builtin mutation engine repeatedly overwrites the same file and reruns tests without disabling bytecode caching or clearing __pycache__, which can (on coarse mtime filesystems or same-size rewrites) cause Python to reuse stale .pyc and yield incorrect killed/survived results.
Agent Prompt
### Issue description
The builtin engine mutates a file, runs the suite, then restores the file, but it never clears `__pycache__` and doesn’t run Python with `-B`/`PYTHONDONTWRITEBYTECODE`. In repeated runs, Python may load cached bytecode that no longer matches the current source, which can silently misclassify mutants.
### Issue Context
The judge explicitly clears `__pycache__` between mutant/property runs, indicating the project already recognizes cache staleness as a correctness risk.
### Fix Focus Areas
- pipeline/testing/mutation/run_mutation.py[284-306]
- pipeline/testing/mutation/run_mutation.py[391-419]
- pipeline/testing/property/judge.py[116-119]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| try: | ||
| _run() | ||
| except Exception as exc: # noqa: BLE001 - hypothesis re-raises the falsification | ||
| return {"name": spec["name"], "property": spec["property"], |
There was a problem hiding this comment.
4. Hypothesis mislabels config errors 🐞 Bug ≡ Correctness
The Hypothesis engine catches all exceptions as "failed", so manifest/configuration errors (ManifestError) become test failures instead of "error", which misreports operator mistakes and breaks parity with the random engine’s error handling.
Agent Prompt
### Issue description
In `_run_hypothesis()`, `ManifestError` thrown from `_check_property()` is caught under a broad `except Exception` and returned as `status: failed`. In `_run_random()`, `ManifestError` is treated as `status: error`. This makes the same bad manifest look like a property falsification under Hypothesis.
### Issue Context
`_check_property()` can raise `ManifestError` at runtime (e.g., invariant properties missing `gen.params.check`). With Hypothesis installed, `engine=auto` selects Hypothesis and the result classification becomes inconsistent.
### Fix Focus Areas
- pipeline/testing/property/invariants.py[322-335]
- pipeline/testing/property/invariants.py[384-446]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
变更(pipeline/testing/{mutation,property})
55 用例全绿(约 16s 离线)+ CLI 端到端冒烟(20 变异体/60% 分/裁判 8 存活→2 accepted 3 trivial rejected)。
依据
IR-0004 rev6(.github#359);LLM 只出候选、判定全机械(rev6 边界)。
Cards: Cloudbird-Software/.github#322 Cloudbird-Software/.github#323
依据
ADR-0085(PM 优先范式——LLM 只出候选、判定全机械);IR-0004 rev6(.github#359)。