certfix 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. certfix-0.1.0/.certfix.yaml.example +69 -0
  2. certfix-0.1.0/.gitignore +82 -0
  3. certfix-0.1.0/AGENTS.md +43 -0
  4. certfix-0.1.0/LICENSE +21 -0
  5. certfix-0.1.0/PKG-INFO +455 -0
  6. certfix-0.1.0/README.md +418 -0
  7. certfix-0.1.0/RELEASE_NOTES.md +144 -0
  8. certfix-0.1.0/THIRD_PARTY_NOTICES.md +32 -0
  9. certfix-0.1.0/configs/deepseek-v4-flash-api.yaml +79 -0
  10. certfix-0.1.0/configs/deepseek-v4-flash-openrouter.yaml +82 -0
  11. certfix-0.1.0/configs/examples/deepseek-gemini-step-overrides.yaml +97 -0
  12. certfix-0.1.0/configs/examples/local-detection-deepseek-fix.yaml +79 -0
  13. certfix-0.1.0/configs/gemini-3-flash-preview-openrouter.yaml +76 -0
  14. certfix-0.1.0/configs/qwen36-mtp-check.yaml +29 -0
  15. certfix-0.1.0/configs/qwen36-mtp-local.yaml +72 -0
  16. certfix-0.1.0/docs/ARCHITECTURE.md +266 -0
  17. certfix-0.1.0/docs/BENCHMARK_SUMMARY.md +133 -0
  18. certfix-0.1.0/docs/CONFIGURATION.md +224 -0
  19. certfix-0.1.0/docs/CONTRIBUTING.md +98 -0
  20. certfix-0.1.0/docs/INDEX.md +49 -0
  21. certfix-0.1.0/docs/MODEL_SMOKE_SUITE.md +113 -0
  22. certfix-0.1.0/docs/QWEN36_MTP_RUNTIME.md +158 -0
  23. certfix-0.1.0/docs/RELEASE_CHECKLIST.md +96 -0
  24. certfix-0.1.0/docs/RESEARCH_NOTES.md +49 -0
  25. certfix-0.1.0/docs/SUPPORTED_RULES.md +74 -0
  26. certfix-0.1.0/examples/input/mem30_use_after_free.c +27 -0
  27. certfix-0.1.0/examples/input/multi_rule_vulnerabilities.c +32 -0
  28. certfix-0.1.0/model-smoke-cases/clean_print.c +5 -0
  29. certfix-0.1.0/model-smoke-cases/exp33_uninitialized_read.c +7 -0
  30. certfix-0.1.0/model-smoke-cases/exp34_null_deref.c +5 -0
  31. certfix-0.1.0/model-smoke-cases/mem30_use_after_free.c +12 -0
  32. certfix-0.1.0/model-smoke-cases/mem35_short_alloc.c +11 -0
  33. certfix-0.1.0/model-smoke-cases/multi_file_mem30/helpers.c +5 -0
  34. certfix-0.1.0/model-smoke-cases/multi_file_mem30/helpers.h +8 -0
  35. certfix-0.1.0/model-smoke-cases/multi_file_mem30/main.c +14 -0
  36. certfix-0.1.0/model-smoke-cases/multi_function_mem30.c +24 -0
  37. certfix-0.1.0/pyproject.toml +90 -0
  38. certfix-0.1.0/scripts/check_release_readiness.py +517 -0
  39. certfix-0.1.0/scripts/run_model_smoke_suite.py +396 -0
  40. certfix-0.1.0/src/certfix/__init__.py +3 -0
  41. certfix-0.1.0/src/certfix/__main__.py +6 -0
  42. certfix-0.1.0/src/certfix/cli.py +1259 -0
  43. certfix-0.1.0/src/certfix/config.py +375 -0
  44. certfix-0.1.0/src/certfix/configs/__init__.py +0 -0
  45. certfix-0.1.0/src/certfix/configs/deepseek-v4-flash-api.yaml +79 -0
  46. certfix-0.1.0/src/certfix/configs/deepseek-v4-flash-openrouter.yaml +82 -0
  47. certfix-0.1.0/src/certfix/configs/examples/__init__.py +0 -0
  48. certfix-0.1.0/src/certfix/configs/examples/deepseek-gemini-step-overrides.yaml +97 -0
  49. certfix-0.1.0/src/certfix/configs/examples/local-detection-deepseek-fix.yaml +79 -0
  50. certfix-0.1.0/src/certfix/configs/gemini-3-flash-preview-openrouter.yaml +76 -0
  51. certfix-0.1.0/src/certfix/configs/qwen36-mtp-check.yaml +29 -0
  52. certfix-0.1.0/src/certfix/configs/qwen36-mtp-local.yaml +72 -0
  53. certfix-0.1.0/src/certfix/core/__init__.py +26 -0
  54. certfix-0.1.0/src/certfix/core/detector.py +209 -0
  55. certfix-0.1.0/src/certfix/core/fix_validator.py +335 -0
  56. certfix-0.1.0/src/certfix/core/fixer.py +92 -0
  57. certfix-0.1.0/src/certfix/core/include_resolver.py +113 -0
  58. certfix-0.1.0/src/certfix/core/preprocessor.py +133 -0
  59. certfix-0.1.0/src/certfix/core/programmatic_checks.py +412 -0
  60. certfix-0.1.0/src/certfix/core/rule_selection_cards.py +546 -0
  61. certfix-0.1.0/src/certfix/core/simple_repair.py +244 -0
  62. certfix-0.1.0/src/certfix/core/splitter.py +245 -0
  63. certfix-0.1.0/src/certfix/core/validate_guided_retry.py +278 -0
  64. certfix-0.1.0/src/certfix/core/validation.py +677 -0
  65. certfix-0.1.0/src/certfix/data/__init__.py +1 -0
  66. certfix-0.1.0/src/certfix/data/cert_c_rules_with_examples.json +211 -0
  67. certfix-0.1.0/src/certfix/env.py +47 -0
  68. certfix-0.1.0/src/certfix/exceptions.py +43 -0
  69. certfix-0.1.0/src/certfix/inference/__init__.py +10 -0
  70. certfix-0.1.0/src/certfix/inference/api.py +855 -0
  71. certfix-0.1.0/src/certfix/inference/base.py +55 -0
  72. certfix-0.1.0/src/certfix/inference/factory.py +160 -0
  73. certfix-0.1.0/src/certfix/inference/parsing.py +371 -0
  74. certfix-0.1.0/src/certfix/models.py +322 -0
  75. certfix-0.1.0/src/certfix/output.py +490 -0
  76. certfix-0.1.0/src/certfix/prompt_profiles.py +426 -0
  77. certfix-0.1.0/src/certfix/prompts.py +734 -0
  78. certfix-0.1.0/tests/__init__.py +1 -0
  79. certfix-0.1.0/tests/conftest.py +50 -0
  80. certfix-0.1.0/tests/fixtures/clean_no_violation.c +13 -0
  81. certfix-0.1.0/tests/fixtures/exp33_uninitialized.c +7 -0
  82. certfix-0.1.0/tests/fixtures/exp33_uninitialized.violations.json +11 -0
  83. certfix-0.1.0/tests/fixtures/mem30_use_after_free.c +11 -0
  84. certfix-0.1.0/tests/fixtures/mem30_use_after_free.violations.json +11 -0
  85. certfix-0.1.0/tests/fixtures/multi_file.violations.json +29 -0
  86. certfix-0.1.0/tests/fixtures/sarif-schema-2.1.0.json +3389 -0
  87. certfix-0.1.0/tests/fixtures/str31_buffer_overflow.c +9 -0
  88. certfix-0.1.0/tests/fixtures/str31_buffer_overflow.violations.json +11 -0
  89. certfix-0.1.0/tests/integration/__init__.py +1 -0
  90. certfix-0.1.0/tests/integration/test_cli.py +886 -0
  91. certfix-0.1.0/tests/unit/__init__.py +1 -0
  92. certfix-0.1.0/tests/unit/test_api_backend.py +713 -0
  93. certfix-0.1.0/tests/unit/test_build_prompt.py +188 -0
  94. certfix-0.1.0/tests/unit/test_config.py +258 -0
  95. certfix-0.1.0/tests/unit/test_detector.py +388 -0
  96. certfix-0.1.0/tests/unit/test_env.py +51 -0
  97. certfix-0.1.0/tests/unit/test_factory.py +331 -0
  98. certfix-0.1.0/tests/unit/test_fix_validator.py +259 -0
  99. certfix-0.1.0/tests/unit/test_include_resolver.py +128 -0
  100. certfix-0.1.0/tests/unit/test_models.py +160 -0
  101. certfix-0.1.0/tests/unit/test_output.py +85 -0
  102. certfix-0.1.0/tests/unit/test_parsing.py +191 -0
  103. certfix-0.1.0/tests/unit/test_preprocessor.py +79 -0
  104. certfix-0.1.0/tests/unit/test_programmatic_checks.py +26 -0
  105. certfix-0.1.0/tests/unit/test_prompt_profiles.py +195 -0
  106. certfix-0.1.0/tests/unit/test_rule_selection_cards.py +110 -0
  107. certfix-0.1.0/tests/unit/test_sarif.py +451 -0
  108. certfix-0.1.0/tests/unit/test_simple_repair.py +170 -0
  109. certfix-0.1.0/tests/unit/test_splitter.py +156 -0
  110. certfix-0.1.0/tests/unit/test_validate_guided_retry.py +191 -0
  111. certfix-0.1.0/tests/unit/test_validation.py +786 -0
@@ -0,0 +1,69 @@
1
+ # certfix configuration example
2
+ #
3
+ # Recommended setup:
4
+ #
5
+ # certfix config qwen36-mtp-local --output .certfix.yaml
6
+ #
7
+ # This checked-in example mirrors the v0.1.0 local Qwen3.6 MTP profile. Start an
8
+ # MTP-capable llama.cpp server before running `certfix check` or `certfix fix`.
9
+ # The server must support `--spec-type draft-mtp`.
10
+
11
+ detection:
12
+ backend: local_llama_server
13
+ prompt_profile: qwen36_certfix_check_v1
14
+ batch_size: 1
15
+ qwen36_rule_id_strategy: sequential_top2_p3
16
+ qwen36_selector_candidate_k: 2
17
+ qwen36_selector_permutations: 3
18
+ api:
19
+ base_url: http://127.0.0.1:8952/v1
20
+ model: unsloth/Qwen3.6-27B-MTP-GGUF:UD-Q4_K_XL
21
+ api_key_env: ""
22
+ timeout: 300
23
+ max_tokens: 1024
24
+ temperature: 0.0
25
+
26
+ models:
27
+ qwen36_local:
28
+ backend: local_llama_server
29
+ profile: qwen36_27b_local
30
+ max_tokens: 4096
31
+ temperature: 0.0
32
+ api:
33
+ base_url: http://127.0.0.1:8952/v1
34
+ model: unsloth/Qwen3.6-27B-MTP-GGUF:UD-Q4_K_XL
35
+ api_key_env: ""
36
+ timeout: 300
37
+ max_tokens: 4096
38
+ temperature: 0.0
39
+
40
+ validation:
41
+ compile:
42
+ enabled: true
43
+ command: gcc
44
+ args: ["-fsyntax-only"]
45
+ include_paths: []
46
+ timeout: 30
47
+ violation_removal:
48
+ enabled: true
49
+ detector_role: qwen36_local
50
+ method: non_target_advisory
51
+ max_tokens: 512
52
+ override_denylist: ["SIG34-C", "STR31-C"]
53
+ semantic:
54
+ enabled: true
55
+ reviewer_role: qwen36_local
56
+ block_on_uncertain: true
57
+
58
+ fix:
59
+ simple_repairer_role: qwen36_local
60
+ simple_repair_profile: qwen36_27b_complete_repair_rule_guided_v1
61
+ simple_max_tokens: 4096
62
+ validate_guided_retry: true
63
+ retry_max_attempts: 1
64
+ retry_max_tokens: 4096
65
+ retry_rule_addenda_v1: true
66
+ retry_rule_addenda_rule_ids: ["ARR37-C", "CON31-C", "POS48-C", "SIG30-C", "ENV33-C"]
67
+
68
+ check:
69
+ exclude: []
@@ -0,0 +1,82 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .env
25
+ .venv
26
+ env/
27
+ venv/
28
+ ENV/
29
+
30
+ # IDE
31
+ .idea/
32
+ .vscode/
33
+ *.swp
34
+ *.swo
35
+ *~
36
+
37
+ # Testing
38
+ .tox/
39
+ .nox/
40
+ .coverage
41
+ .coverage.*
42
+ htmlcov/
43
+ .pytest_cache/
44
+ model-smoke-results/
45
+ .mypy_cache/
46
+
47
+ # certfix-generated reports, fixed-code candidates, and patches
48
+ certfix-output/
49
+
50
+ # Local model smoke configs
51
+ configs/local-*.yaml
52
+ configs/local-*.yml
53
+
54
+ # Build
55
+ *.manifest
56
+ *.spec
57
+
58
+ # Installer logs
59
+ pip-log.txt
60
+ pip-delete-this-directory.txt
61
+
62
+ # Models (large files)
63
+ *.gguf
64
+ *.bin
65
+ models/
66
+
67
+ # MCP (local tool config)
68
+ .mcp.json
69
+ mcp-servers/
70
+
71
+ # OS
72
+ .DS_Store
73
+ Thumbs.db
74
+
75
+ # Local/private maintainer notes not included in the initial public repo
76
+ docs/research-archive/
77
+ CLAUDE.md
78
+ README.ja.local.md
79
+
80
+ # Locally generated maintainer evaluation datasets
81
+ src/certfix/data/*samples.jsonl.gz
82
+ eval-splits/
@@ -0,0 +1,43 @@
1
+ # certfix Public Release Notes For Agents
2
+
3
+ This repository is the release-side workspace for `certfix`, a CLI for detecting
4
+ and repairing CERT-C issues in C source code.
5
+
6
+ ## Public Boundary
7
+
8
+ - Treat this repository as publishable. Do not add local absolute paths,
9
+ private keys, model checkpoints, evaluation datasets, cloud run details, or
10
+ internal experiment logs.
11
+ - The initial public repository intentionally excludes `docs/research-archive/`
12
+ and local scratchpad files such as `CLAUDE.md`.
13
+ - Research provenance belongs in internal project records or a separately
14
+ sanitized archive, not in the primary public docs.
15
+ - SFT artifacts and experiment-side datasets are not required for normal
16
+ v0.1.0 usage.
17
+
18
+ ## Release Path
19
+
20
+ - The public v0.1.0 path is Qwen3.6-centered.
21
+ - The main local config is `configs/qwen36-mtp-local.yaml`.
22
+ - `certfix fix` uses the public Qwen3.6-centered repair path.
23
+ - API profiles are optional and send source code to the configured provider.
24
+
25
+ ## Documentation Wording
26
+
27
+ - Prefer cautious claims: validation gates reduce risk; they do not guarantee
28
+ behavior equivalence or security correctness.
29
+ - Benchmark claims should point to `docs/BENCHMARK_SUMMARY.md` and keep its
30
+ caveats intact.
31
+ - Do not present historical model names, old benchmark values, or archived
32
+ decisions as current release defaults.
33
+
34
+ ## Development Commands
35
+
36
+ ```bash
37
+ pip install -e ".[dev]"
38
+ pytest
39
+ ruff check src/ tests/ scripts/
40
+ ruff format src/ tests/ scripts/
41
+ python3 -m build --sdist --wheel
42
+ python3 scripts/check_release_readiness.py
43
+ ```
certfix-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 certfix team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
certfix-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,455 @@
1
+ Metadata-Version: 2.4
2
+ Name: certfix
3
+ Version: 0.1.0
4
+ Summary: CERT-C issue candidate detector and fixed-code candidate generator for C code
5
+ Project-URL: Homepage, https://github.com/safe-c-ai/certfix
6
+ Project-URL: Documentation, https://github.com/safe-c-ai/certfix#readme
7
+ Project-URL: Repository, https://github.com/safe-c-ai/certfix
8
+ Project-URL: Issues, https://github.com/safe-c-ai/certfix/issues
9
+ Author: certfix team
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: c,cert-c,llm,security,static-analysis
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Security
23
+ Classifier: Topic :: Software Development :: Quality Assurance
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: click>=8.0.0
26
+ Requires-Dist: httpx>=0.25.0
27
+ Requires-Dist: pyyaml>=6.0
28
+ Requires-Dist: rich>=13.0.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: build>=1.0.0; extra == 'dev'
31
+ Requires-Dist: jsonschema>=4.0.0; extra == 'dev'
32
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
33
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
34
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # certfix
39
+
40
+ certfix is a CLI tool for detecting CERT-C issue candidates and generating
41
+ fixed-code candidates for C source code with LLMs.
42
+
43
+ ## Features
44
+
45
+ - Detect CERT-C security violation candidates in C source code
46
+ - Use a bundled catalog of 115 CERT-C rule targets across PRE, DCL, EXP, INT,
47
+ FLP, ARR, STR, MEM, FIO, ENV, SIG, ERR, CON, MSC, and POS categories
48
+ - Write AI-generated fixed-code candidates and patches
49
+ - Run the standard local path with Qwen3.6 MTP through `llama-server`
50
+ - Use local servers and cloud APIs through OpenAI-compatible API backends
51
+ - v0.1.0 ships profiles for local `llama-server` with Qwen3.6-27B,
52
+ OpenRouter with DeepSeek V4 Flash / Gemini 3 Flash Preview, and DeepSeek's
53
+ official API with DeepSeek V4 Flash
54
+ - Reduce risk with compile validation, violation-removal checks, and semantic
55
+ review gates
56
+ - Produce machine-readable JSON / SARIF output and exit codes
57
+
58
+ ## Installation And Requirements
59
+
60
+ ### Install
61
+
62
+ ```bash
63
+ pip install certfix
64
+ ```
65
+
66
+ ### Requirements
67
+
68
+ - Python 3.10+
69
+ - A C compiler for compile validation, such as `gcc` or `clang`
70
+
71
+ Install a compiler first:
72
+
73
+ ```bash
74
+ # Ubuntu / Debian / WSL
75
+ sudo apt update
76
+ sudo apt install build-essential
77
+
78
+ # Fedora
79
+ sudo dnf install gcc
80
+
81
+ # macOS
82
+ xcode-select --install
83
+ ```
84
+
85
+ Check the environment:
86
+
87
+ ```bash
88
+ gcc --version
89
+ certfix doctor
90
+ ```
91
+
92
+ To use `clang`, set `validation.compile.command: clang` in `.certfix.yaml`.
93
+
94
+ ### API Keys
95
+
96
+ API profiles are optional.
97
+
98
+ - OpenRouter: `OPENROUTER_API_KEY`
99
+ - DeepSeek official API: `DEEPSEEK_API_KEY`
100
+
101
+ API routes send source code to the configured provider. Confirm your project
102
+ data policy before using a cloud provider.
103
+
104
+ ### Local Qwen3.6-27B Setup
105
+
106
+ For local inference, run an MTP-capable `llama-server` separately from certfix.
107
+
108
+ You need:
109
+
110
+ - MTP-capable `llama-server`
111
+ - Verified: `am17an/llama.cpp` `mtp-clean` fork, commit `a957b7747`
112
+ - Other builds may work if they support `--spec-type draft-mtp`
113
+ - Qwen3.6-27B MTP GGUF
114
+ - Recommended: `unsloth/Qwen3.6-27B-MTP-GGUF:UD-Q4_K_XL`
115
+ - Enough RAM / VRAM for the selected GGUF
116
+ - Rough minimum: 24GB VRAM + 32GB RAM
117
+ - Recommended: 32GB+ VRAM + 64GB RAM
118
+ - 16GB VRAM may require lower-bit quantization or partial offload
119
+ - Network access for the first model download, unless you already have the GGUF
120
+
121
+ Build example for Linux / WSL with NVIDIA GPU:
122
+
123
+ ```bash
124
+ sudo apt update
125
+ sudo apt install -y git cmake build-essential
126
+
127
+ git clone https://github.com/am17an/llama.cpp
128
+ cd llama.cpp
129
+ git checkout a957b7747
130
+ cmake -B build -DGGML_CUDA=ON
131
+ cmake --build build --config Release -t llama-server -j "$(nproc)"
132
+ ```
133
+
134
+ See also:
135
+
136
+ - llama.cpp build guide:
137
+ <https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md>
138
+ - llama-server README:
139
+ <https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md>
140
+ - certfix Qwen3.6 runtime notes: [docs/QWEN36_MTP_RUNTIME.md](docs/QWEN36_MTP_RUNTIME.md)
141
+
142
+ Put the binary in `PATH`, or run it by explicit path:
143
+
144
+ ```bash
145
+ sudo install -m 755 build/bin/llama-server /usr/local/bin/llama-server
146
+ llama-server --help | grep -- "--spec-type"
147
+ ```
148
+
149
+ If `--spec-type` is not listed, that build is not the intended MTP runtime.
150
+
151
+ Start the Qwen3.6 MTP server:
152
+
153
+ ```bash
154
+ llama-server \
155
+ -hf unsloth/Qwen3.6-27B-MTP-GGUF:UD-Q4_K_XL \
156
+ -ngl 99 -c 8192 -fa on -np 1 \
157
+ --host 127.0.0.1 --port 8952 \
158
+ --cache-ram 0 \
159
+ --spec-type draft-mtp --spec-draft-n-max 2 \
160
+ --reasoning-budget 1024
161
+ ```
162
+
163
+ In another terminal:
164
+
165
+ ```bash
166
+ certfix config qwen36-mtp-local --output .certfix.yaml
167
+ certfix doctor
168
+ ```
169
+
170
+ `certfix doctor` shows a warning and a server command example if the local
171
+ server is not reachable. v0.1.0 does not auto-start `llama-server`.
172
+
173
+ ## Quick Start
174
+
175
+ In a cloned certfix repository checkout, try the bundled samples in
176
+ `examples/input/`. They include a MEM30-C use-after-free example and a
177
+ multi-function file with EXP33-C / STR31-C violations.
178
+
179
+ If you installed certfix from PyPI only, `examples/input/` will not be created
180
+ in your current directory. Use your own `.c` file, or clone the repository to
181
+ run the bundled examples.
182
+
183
+ The commands below write results to `examples/certfix-output`. Source files are
184
+ not modified. `certfix check` writes reports, and `certfix fix` writes
185
+ comment-stripped fixed-code candidates under `fixes/` plus patches under
186
+ `patches/`.
187
+
188
+ ### API Only
189
+
190
+ No local GPU or `llama-server` is required.
191
+
192
+ OpenRouter with DeepSeek V4 Flash:
193
+
194
+ ```bash
195
+ export OPENROUTER_API_KEY=<openrouter-key>
196
+ certfix config deepseek-v4-flash-openrouter --output .certfix.yaml
197
+ certfix check examples/input/ --output-dir examples/certfix-output
198
+ certfix fix examples/input/ --output-dir examples/certfix-output
199
+ ```
200
+
201
+ OpenRouter with Gemini 3 Flash Preview:
202
+
203
+ ```bash
204
+ export OPENROUTER_API_KEY=<openrouter-key>
205
+ certfix config gemini-3-flash-preview-openrouter --output .certfix.yaml
206
+ certfix check examples/input/ --output-dir examples/certfix-output
207
+ certfix fix examples/input/ --output-dir examples/certfix-output
208
+ ```
209
+
210
+ ### Local Qwen3.6-27B Only
211
+
212
+ Start `llama-server` first, then run:
213
+
214
+ ```bash
215
+ certfix config qwen36-mtp-local --output .certfix.yaml
216
+ certfix doctor
217
+ certfix check examples/input/ --output-dir examples/certfix-output
218
+ certfix fix examples/input/ --output-dir examples/certfix-output
219
+ ```
220
+
221
+ This path keeps inference local and does not send code to a cloud API.
222
+
223
+ ### API And Local Combined
224
+
225
+ This profile uses local Qwen3.6-27B for detection and DeepSeek V4 Flash for
226
+ repair/validation. It requires both `OPENROUTER_API_KEY` and a running
227
+ `llama-server`.
228
+
229
+ ```bash
230
+ export OPENROUTER_API_KEY=<openrouter-key>
231
+ certfix config local-detection-deepseek-fix --output .certfix.yaml
232
+ certfix doctor
233
+ certfix check examples/input/ --output-dir examples/certfix-output
234
+ certfix fix examples/input/ --output-dir examples/certfix-output
235
+ ```
236
+
237
+ ## Commands
238
+
239
+ Basic flow:
240
+
241
+ 1. Create `.certfix.yaml` in the directory where you run certfix.
242
+ 2. Run `certfix doctor` to check the environment, API keys, and local server.
243
+ 3. Run `certfix check <path>` to detect CERT-C violation candidates.
244
+ 4. Run `certfix fix <path>` to generate repair candidates and validation
245
+ results.
246
+ 5. Review `certfix-output/` fixed-code candidates and patches, then merge
247
+ changes manually if appropriate.
248
+
249
+ | Command | First argument | Description |
250
+ |---------|----------------|-------------|
251
+ | `certfix config <profile>` | Profile name | Print or write a bundled config profile |
252
+ | `certfix doctor` | None | Check environment, API keys, and local server connectivity |
253
+ | `certfix check <path>` | C file or directory | Detect CERT-C violation candidates |
254
+ | `certfix fix <path>` | C file or directory | Generate repair candidates and validation results without editing source files |
255
+
256
+ Common options:
257
+
258
+ | Option | Commands | Description |
259
+ |--------|----------|-------------|
260
+ | `--config <file>` | `doctor`, `check`, `fix`, `setup` | Use a config file other than `.certfix.yaml` |
261
+ | `--output-dir <dir>` | `check`, `fix` | Save reports, comment-stripped fixed-code candidates, and patches |
262
+ | `--format text\|json\|sarif` | `check`, `fix` | Select output format |
263
+ | `--force` | `config` | Overwrite an existing output file |
264
+
265
+ Use `certfix --help` or `certfix <command> --help` for the full CLI reference.
266
+
267
+ `certfix setup` shows optional model-file diagnostics. It is not required for
268
+ the normal API or external `llama-server` paths.
269
+
270
+ ## Model Profiles
271
+
272
+ certfix writes bundled profiles to `.certfix.yaml`. Without `--config`, certfix
273
+ reads `.certfix.yaml` from the current working directory.
274
+
275
+ ```bash
276
+ certfix config qwen36-mtp-local --output .certfix.yaml
277
+ ```
278
+
279
+ A local Qwen3.6 profile contains connection details like:
280
+
281
+ ```yaml
282
+ detection:
283
+ backend: local_llama_server
284
+ prompt_profile: qwen36_certfix_check_v1
285
+ batch_size: 1
286
+ api:
287
+ base_url: http://127.0.0.1:8952/v1
288
+ model: unsloth/Qwen3.6-27B-MTP-GGUF:UD-Q4_K_XL
289
+ api_key_env: ""
290
+ ```
291
+
292
+ For API providers, put keys in your shell environment or in a local `.env` file.
293
+ Existing shell environment variables take precedence over `.env`.
294
+
295
+ ```dotenv
296
+ OPENROUTER_API_KEY=<openrouter-key>
297
+ DEEPSEEK_API_KEY=<deepseek-key>
298
+ ```
299
+
300
+ Bundled profiles:
301
+
302
+ | Purpose | Profile | Notes |
303
+ |---------|---------|-------|
304
+ | Local standard | `qwen36-mtp-local` | Local Qwen3.6-27B MTP for detection and repair |
305
+ | Local check only | `qwen36-mtp-check` | Detection without repair |
306
+ | API only: DeepSeek | `deepseek-v4-flash-openrouter` | DeepSeek V4 Flash through OpenRouter |
307
+ | API only: Gemini | `gemini-3-flash-preview-openrouter` | Gemini 3 Flash Preview through OpenRouter |
308
+ | API only: DeepSeek direct | `deepseek-v4-flash-api` | DeepSeek official API |
309
+ | Local detection + API repair | `local-detection-deepseek-fix` | Qwen3.6-27B detection with DeepSeek repair/validation |
310
+ | Advanced routing | `deepseek-gemini-step-overrides` | Example for routing selected steps to different models |
311
+
312
+ Repair-quality guideline from the v0.1.0 CERT-C repair release test set:
313
+
314
+ ```text
315
+ Qwen3.6-27B local < DeepSeek V4 Flash < Gemini 3 Flash Preview
316
+ ```
317
+
318
+ See [docs/BENCHMARK_SUMMARY.md](docs/BENCHMARK_SUMMARY.md) for benchmark
319
+ context and caveats.
320
+
321
+ Selection guideline:
322
+
323
+ - Use `qwen36-mtp-local` when you have a local GPU and do not want to send code
324
+ to an external API.
325
+ - Use `deepseek-v4-flash-openrouter` when you do not have a local GPU and want a
326
+ lower-cost API route.
327
+ - Use `local-detection-deepseek-fix` when you have local Qwen3.6 detection but
328
+ want low-cost API repair.
329
+ - Use `gemini-3-flash-preview-openrouter` when API repair quality matters more
330
+ than cost.
331
+
332
+ API routes send source code to the configured provider. For v0.1.0, the only
333
+ supported local LLM profile is Qwen3.6-27B MTP through `llama-server`.
334
+
335
+ ## Configuration
336
+
337
+ certfix reads `.certfix.yaml` to choose the model route, API provider,
338
+ validation gates, and project-specific exclusions.
339
+
340
+ Config lookup:
341
+
342
+ - With `--config <file>`: certfix reads the specified file.
343
+ - Without `--config`: certfix reads `.certfix.yaml` in the current working
344
+ directory.
345
+
346
+ If `.certfix.yaml` is missing, built-in defaults are incomplete for public use.
347
+ Create a profile first with `certfix config <profile> --output .certfix.yaml`.
348
+
349
+ Common project-specific edits:
350
+
351
+ ```yaml
352
+ check:
353
+ exclude:
354
+ - "tests/"
355
+ - "vendor/"
356
+
357
+ validation:
358
+ compile:
359
+ command: gcc
360
+ args: ["-fsyntax-only"]
361
+ include_paths:
362
+ - "include/"
363
+ ```
364
+
365
+ - `check.exclude`: files or directories to skip
366
+ - `validation.compile.command`: C compiler for compile validation
367
+ - `validation.compile.include_paths`: project header search paths for compiler
368
+ validation
369
+
370
+ For header context used by analysis prompts, advanced routing, token tuning for
371
+ long functions, and the full schema, see
372
+ [docs/CONFIGURATION.md](docs/CONFIGURATION.md).
373
+
374
+ ## Exit Codes
375
+
376
+ `certfix check`:
377
+
378
+ | Code | Meaning |
379
+ |------|---------|
380
+ | 0 | No violations found |
381
+ | 1 | Violations found |
382
+ | 2 | Usage, configuration, model, or runtime error |
383
+
384
+ `certfix fix`:
385
+
386
+ | Code | Meaning |
387
+ |------|---------|
388
+ | 0 | Command completed and no failed fixes were reported. Source files were not changed. |
389
+ | 1 | At least one detected issue could not be fixed or failed validation |
390
+ | 2 | Usage, configuration, model, or runtime error |
391
+
392
+ `certfix doctor` is diagnostic. Warnings such as a disconnected local server do
393
+ not change its exit code unless config loading itself fails. Use `certfix check`
394
+ exit codes for CI violation gating.
395
+
396
+ ## Limitations
397
+
398
+ - C only. C++ is not supported.
399
+ - Supported CERT-C coverage is limited to the 115 bundled rule targets.
400
+ CERT-C recommendations are not supported. See
401
+ [docs/SUPPORTED_RULES.md](docs/SUPPORTED_RULES.md) for the supported rule
402
+ catalog.
403
+ - Directory input scans `.c` / `.h` files. `certfix-output/` is skipped.
404
+ - certfix does not detect every violation, and detected violations are not
405
+ always repaired correctly.
406
+ - Analysis is file/function scoped, not whole-program semantic analysis.
407
+ - Repair assumes one violation per function. Multiple violations in one function
408
+ are not supported as a single repair task.
409
+ - Functions up to about 200 lines are the expected case. Results may become less
410
+ stable above that, and functions over about 300 lines should be split before
411
+ running certfix. See [docs/CONFIGURATION.md](docs/CONFIGURATION.md) for
412
+ best-effort token/context tuning.
413
+ - Header handling is limited. System headers and deep include graphs are not
414
+ fully expanded.
415
+ - v0.1.0 fixed-code candidates are comment-stripped; comment-preserving repair
416
+ is not implemented.
417
+ - Source files are not modified. Review generated fixed-code candidates and
418
+ patches, then merge changes manually.
419
+ - Validation gates reduce risk but do not guarantee semantic preservation,
420
+ security correctness, or compile success in your target build environment.
421
+ - For release test set success rates and caveats, see
422
+ [docs/BENCHMARK_SUMMARY.md](docs/BENCHMARK_SUMMARY.md).
423
+ - Local LLMs require a separately running `llama-server`. certfix does not
424
+ auto-start it or load GGUF files in-process.
425
+ - API routes send source code to the configured provider.
426
+
427
+ ## Documentation
428
+
429
+ The main public documents are:
430
+
431
+ | Document | Purpose |
432
+ |----------|---------|
433
+ | [docs/INDEX.md](docs/INDEX.md) | Documentation index |
434
+ | [docs/CONFIGURATION.md](docs/CONFIGURATION.md) | Config lookup, bundled profiles, common edits, include paths, advanced routing, and token/context tuning |
435
+ | [docs/SUPPORTED_RULES.md](docs/SUPPORTED_RULES.md) | Supported CERT-C rule target catalog and category coverage |
436
+ | [docs/QWEN36_MTP_RUNTIME.md](docs/QWEN36_MTP_RUNTIME.md) | Local Qwen3.6 MTP `llama-server` setup and verified runtime notes |
437
+ | [docs/BENCHMARK_SUMMARY.md](docs/BENCHMARK_SUMMARY.md) | v0.1.0 benchmark summary, release test set aggregate results, and caveats |
438
+ | [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | Release-side architecture and pipeline design |
439
+ | [docs/RESEARCH_NOTES.md](docs/RESEARCH_NOTES.md) | Boundary between public release docs and research/archive materials |
440
+ | [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) | SARIF, CERT-C metadata, and dataset boundary notices |
441
+
442
+ ## AI-Assisted Development
443
+
444
+ certfix was developed with assistance from Codex and Claude Code for
445
+ implementation, review, planning, and documentation support. Proprietary LLM
446
+ outputs were not used as training targets, training-data labels, or per-record
447
+ training-data audit decisions. See [docs/RESEARCH_NOTES.md](docs/RESEARCH_NOTES.md)
448
+ for the release/research boundary.
449
+
450
+ ## License
451
+
452
+ MIT. See [LICENSE](LICENSE).
453
+
454
+ See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for bundled standard
455
+ fixtures and rule metadata notices.