v3.1.0 feat: 重构算法复杂度分析体系为多规模采样与经验倍率拟合 - #1
Merged
SummerOneTwo merged 7 commits intoSep 19, 2026
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved correctness and safety issues affect complexity defaults, resource enforcement, sampling, and monitoring.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 3
Open (5)
What changed in this PR
Refactors complexity analysis around multi-scale sampling, execution monitoring, and empirical growth fitting.
Changes:
- Adds sampling, ratio analysis, and process-monitoring utilities.
- Integrates empirical verification into solution and problem audits.
- Adds tests, documentation, release notes, and version metadata.
| File | Summary |
|---|---|
uv.lock |
Updates locked package metadata. |
tests/test_utils/test_execution_monitor.py |
Tests execution monitoring. |
tests/test_tools/test_solution_audit.py |
Tests solution-audit integration. |
tests/test_tools/test_multi_scale_sampler.py |
Tests multi-scale sampling. |
tests/test_tools/test_empirical_ratio_analyzer.py |
Tests empirical fitting. |
tests/test_integration/test_complexity_empirical_e2e.py |
Adds end-to-end complexity tests. |
src/autocode_mcp/utils/scale_sampler.py |
Implements scale sampling and generator commands. |
src/autocode_mcp/utils/ratio_analyzer.py |
Implements empirical complexity fitting. |
src/autocode_mcp/utils/execution_monitor.py |
Adds process and resource monitoring. |
src/autocode_mcp/tools/solution_audit.py |
Integrates empirical audit results. |
src/autocode_mcp/tools/schemas.py |
Adds claimed-complexity input. |
src/autocode_mcp/tools/complexity.py |
Integrates empirical verification. |
src/autocode_mcp/tools/audit.py |
Adds empirical audit quality gates. |
pyproject.toml |
Bumps project version. |
docs/plans/multi-scale-complexity-empirical-fitting-plan.md |
Documents implementation tasks. |
docs/designs/multi-scale-complexity-empirical-fitting-design.md |
Documents the architecture. |
CHANGELOG.md |
Records the release. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| actual_n_max = int(constraints.get("n_max") or 10000) | ||
| time_limit_ms = float(constraints.get("time_limit_ms") or 2000.0) | ||
|
|
||
| effective_complexity = claimed_complexity or "O(n)" |
| baseline_overhead_ms: float = 0.0, | ||
| ) -> dict[str, Any]: | ||
| timeout_sec = max(0.1, time_limit_ms / 1000.0) | ||
| max_output_bytes = 10 * 1024 * 1024 # 10MB 输出上限,防止管道填满挂起 |
Comment on lines
+70
to
+73
| if normalized_expr in ("O(2^n)",): | ||
| return math.pow(2.0, min(n, 60.0)) | ||
| if normalized_expr in ("O(n!)",): | ||
| return float(math.factorial(min(int(n), 20))) |
Comment on lines
+63
to
+68
| generator_exe, | ||
| str(seed), | ||
| "random", | ||
| str(vars_map.get("n_min", n)), | ||
| str(n), | ||
| str(vars_map.get("t_min", 1)), |
| # 多规模阶梯数据采样与经验复杂度拟合执行计划 | ||
|
|
||
| ## 一、概述 | ||
| 本计划依据 [docs/designs/multi-scale-complexity-empirical-fitting-design.md](file:///home/cvm-204/AutoCode/docs/designs/multi-scale-complexity-empirical-fitting-design.md),实施对 AutoCode 复杂度与算法分析体系的全面重构。 |
…test thresholds for virtualized environments
…d tolerance for cloud runners
…pper bound compliance
SummerOneTwo
deleted the
feat/multi-scale-complexity-empirical-fitting
branch
September 19, 2026 09:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



变更概述
依据 docs/designs/multi-scale-complexity-empirical-fitting-design.md 与 docs/plans/multi-scale-complexity-empirical-fitting-plan.md,实施对 AutoCode 复杂度与算法分析体系的全面重构。
彻底移除原有的脆弱正则表达式静态分析,建立“大语言模型声明理论复杂度 + 底层工具链多规模物理实测与对数线性倍率拟合”的确定性实证架构。
核心变更
MultiScaleSampler(多规模阶梯数据采样器):DynamicExecutionMonitor(动态执行监控器):utime + stime)与物理内存,测量并扣除系统原生启动物理底噪(约 2.1ms)。EmpiricalRatioAnalyzer(经验倍率拟合分析器):工具层与质量门禁联动:
solution_analyze与solution_audit_std接入claimed_complexity归一化解析。problem_audit将empirical_complexity纳入质量信号门禁,未通过时追加阻断提示与修复指引。测试验证与覆盖结论
tests/test_tools/test_empirical_ratio_analyzer.py(10/10 通过)tests/test_tools/test_multi_scale_sampler.py(8/8 通过)tests/test_utils/test_execution_monitor.py(4/4 通过)tests/test_tools/test_solution_audit.py(5/5 通过)tests/test_integration/test_complexity_empirical_e2e.py(4/4 通过)uv run pytest tests/ -q:403 passed, 7 skipped in 360.69s,403 个用例全部通过。uv run ruff check .:通过(All checks passed)uv run mypy src/:通过(41 个源文件全部通过,零报错)计划达成度审计(Plan Completion Audit)