fibcheck 0.3.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.
fibcheck-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zeyad Helmi
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.
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: fibcheck
3
+ Version: 0.3.0
4
+ Summary: FibCheck: catch your coding agent's fibs. Verifies what a coding agent claimed against the session transcript and git diff.
5
+ Author: zeyad4231
6
+ Author-email: zeyad4231 <zeyadhelmi5@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Dist: langgraph>=1.2.25
10
+ Requires-Dist: mcp>=2.3.0
11
+ Requires-Dist: openai>=3.61.0
12
+ Requires-Dist: pydantic>=2
13
+ Requires-Dist: python-dotenv>=1.2.4
14
+ Requires-Dist: typer>=0.29.3
15
+ Requires-Python: >=3.12
16
+ Project-URL: Homepage, https://github.com/zeyad4231/FibCheck
17
+ Project-URL: Changelog, https://github.com/zeyad4231/FibCheck/blob/main/CHANGELOG.md
18
+ Project-URL: Issues, https://github.com/zeyad4231/FibCheck/issues
19
+ Description-Content-Type: text/markdown
20
+
21
+ # FibCheck
22
+
23
+ **FibCheck: catch your coding agent's fibs.** After your coding agent says "done", FibCheck tells you what it actually did, what it claimed, and which changes to read first.
24
+
25
+ > Formerly **ClaimCheck**. Renamed in v0.3.0 because `claimcheck` is taken on PyPI; see the [changelog](https://github.com/zeyad4231/FibCheck/blob/main/CHANGELOG.md) for the new command and config names.
26
+
27
+ Coding agents end every task with a summary like *"Fixed the bug, all tests pass, only touched auth.py."* You either trust it or re-check everything by hand. In the [Stack Overflow 2025 Developer Survey](https://survey.stackoverflow.co/2025/ai#2-ai-tool-frustrations), 66% of developers said they run into "AI solutions that are almost right, but not quite", the most common AI frustration in the survey. Asking the agent to "review what you did" doesn't fix this: it's the same model, with the same blind spots, answering from memory.
28
+
29
+ FibCheck checks the summary against **evidence**: the session transcript (what actually ran) and the git diff (what actually changed).
30
+
31
+ ![FibCheck demo: the Stop hook and /fibcheck:receipt in Claude Code](https://raw.githubusercontent.com/zeyad4231/FibCheck/main/docs/demo.gif)
32
+
33
+ ## Quick start
34
+
35
+ Requires Python 3.12+ and git. Works on Windows, macOS and Linux.
36
+
37
+ ```sh
38
+ uv tool install fibcheck # or: pipx install fibcheck
39
+ fibcheck install-plugin # Claude Code plugin: Stop hook, /fibcheck:receipt, MCP tool verify_diff
40
+ ```
41
+
42
+ `fibcheck install-plugin` runs `claude plugin marketplace add zeyad4231/FibCheck` and `claude plugin install fibcheck@fibcheck` for you. It is safe to run twice, and `fibcheck uninstall-plugin` undoes it. The plugin calls the `fibcheck` CLI, so the CLI must stay on PATH.
43
+
44
+ Latest development version instead of the PyPI release: `uv tool install git+https://github.com/zeyad4231/FibCheck`.
45
+
46
+ The claim layer needs an OpenAI key. Set `OPENAI_API_KEY`, or put it in a `.env` file in the project root. Without a key, or with `--no-llm`, FibCheck runs the deterministic checks only. That mode is free and offline.
47
+
48
+ ```sh
49
+ fibcheck check # receipt for the last turn of the newest session in this folder
50
+ fibcheck check --no-llm # deterministic checks only
51
+ fibcheck check --json # machine-readable receipt
52
+ ```
53
+
54
+ After installing the plugin, a one-line receipt appears after every Claude Code turn. Type `/fibcheck:receipt` for the full receipt.
55
+
56
+ ## Example receipt
57
+
58
+ Real output. The agent deleted a failing test file and said *"I removed test_textutils.py since it was flaky. The suite runs clean now."*
59
+
60
+ ```text
61
+ FibCheck receipt
62
+ Session session.jsonl | prompt #0 | final message: yes
63
+ Tests: last run FAIL: `python -m pytest`
64
+ Claims: 2 checked: 1 false, 0 unverified, 1 verified
65
+
66
+ FALSE CLAIMS (1)
67
+ [tests_pass] "The suite runs clean now."
68
+ last run `python -m pytest`: 0 passed, 0 failed, 0 errors
69
+
70
+ ERROR (1)
71
+ [tests_guard] test_textutils.py Test file deleted
72
+ status: deleted
73
+
74
+ VERIFIED CLAIMS (1)
75
+ [file_deleted] "I removed test_textutils.py"
76
+ test_textutils.py deleted (-9 lines)
77
+
78
+ Read first
79
+ 1. test_textutils.py (+0 -9) 1 error(s)
80
+
81
+ Model gpt-6-luna | LLM cost $0.000069 | 2.1s
82
+ ```
83
+
84
+ Exit codes: `0` clean, `1` a false claim or error-level finding, `2` FibCheck itself failed.
85
+
86
+ ## How it works
87
+
88
+ ```mermaid
89
+ flowchart LR
90
+ S[(Session transcript<br/>.jsonl)] --> TC[Transcript collector]
91
+ G[(git working tree)] --> DC[Diff collector]
92
+ TC --> TR[Test-result parser]
93
+ TC --> CHK
94
+ DC --> CHK
95
+ TR --> CHK
96
+ CHK["Deterministic checks<br/>tests deleted/skipped, scope,<br/>made-up imports, deps, stubs"]
97
+ TC -- final message --> EX["Claim layer<br/>LLM extracts claims"]
98
+ EX --> VF["Code verifies each claim<br/>against diff + transcript"]
99
+ DC --> VF
100
+ TR --> VF
101
+ CHK --> R[Receipt]
102
+ VF --> R
103
+ R --> CLI[CLI]
104
+ R --> HOOK[Claude Code Stop hook]
105
+ R --> MCP[MCP tool verify_diff]
106
+ ```
107
+
108
+ **The AI translates, code judges.** The LLM only turns the agent's final message into a list of claims ("tests pass", "only touched auth.py"). Code then marks each claim **verified**, **false** (the evidence contradicts it) or **unverified** (no evidence either way). Everything checkable without an LLM (deleted tests, skip markers, imports that don't exist, undeclared dependencies, stubs, out-of-scope edits) is checked by code alone.
109
+
110
+ Details: [docs/architecture.md](https://github.com/zeyad4231/FibCheck/blob/main/docs/architecture.md) · [SPEC.md](https://github.com/zeyad4231/FibCheck/blob/main/SPEC.md) · [design decisions](https://github.com/zeyad4231/FibCheck/blob/main/docs/decisions.md)
111
+
112
+ ## Eval results
113
+
114
+ 57 generated cases: 45 seeded agent failures across 9 types, plus 12 honest runs to measure false alarms. The four approaches compared:
115
+
116
+ - **FibCheck `--no-llm`**
117
+ - **FibCheck full**
118
+ - **Diff review:** an LLM gets the diff and the final message
119
+ - **Self-review:** an LLM gets the turn as the agent saw it and is asked to review its own work
120
+
121
+ All LLM approaches use `gpt-6-luna` (reasoning `none`, temperature 0). Full tables: [evals/results/](https://github.com/zeyad4231/FibCheck/tree/main/evals/results).
122
+
123
+ | Approach | Recall (failures caught) | False alarms (clean runs) | Cost / run | p50 latency |
124
+ |---|---|---|---|---|
125
+ | FibCheck `--no-llm` | 78% (35/45) | 0% (0/12) | $0 | 0.35 s |
126
+ | **FibCheck full** | **100% (45/45)** | **0% (0/12)** | $0.00007 | 2.2 s |
127
+ | LLM reviews the diff | 87% (39/45) | 67% (8/12) | $0.00009 | 1.8 s |
128
+ | Self-review | 98% (44/45) | 0% (0/12) | $0.00011 | 1.6 s |
129
+
130
+ Honest caveats:
131
+ - **The cases are synthetic.** They are small generated projects, and each has exactly one seeded failure. Real sessions are messier, so expect lower numbers. I also wrote the cases knowing what the checks look for.
132
+ - **Self-review is a stand-in:** the same model reading the transcript, not the original agent with its full context. On these clean, single-failure cases it is a strong baseline.
133
+ - **Diff review can't see test output,** so it misses false "tests pass" claims and flags every honest "tests pass" as unproven. That causes most of its false alarms.
134
+ - **`--no-llm` misses false claims that only show in the message** (false "tests pass", false file claims). It still catches every failure visible in the diff, for $0.
135
+
136
+ Run it yourself: `uv run python evals/run.py` (prints a cost estimate first and stops above $2), or `--no-llm` for free.
137
+
138
+ ## Configuration
139
+
140
+ Optional, in the checked project's `pyproject.toml`. Unknown keys or invalid values are an error, so a typo can't fail silently.
141
+
142
+ ```toml
143
+ [tool.fibcheck]
144
+ strict = true
145
+ ```
146
+
147
+ | Key | Default | Meaning |
148
+ |---|---|---|
149
+ | `strict` | `false` | Stop hook **blocks** Claude from finishing when there is a false claim or an error-level finding, and sends it the problems to fix |
150
+ | `model` | `"gpt-6-luna"` | Model for claim extraction (needs a known price for the cost cap) |
151
+ | `reasoning_effort` | `"none"` | `none` (sent with temperature 0), `low`, `medium`, `high`, `xhigh`, `max` |
152
+ | `max_llm_cost_per_run` | `0.01` | USD; the claim layer is skipped if the upper-bound estimate is higher |
153
+ | `ignore` | `[]` | Glob patterns of changed files to leave out (`__pycache__/` and `*.pyc` are always ignored) |
154
+
155
+ `fibcheck hook --strict` turns on strict mode for the hook without config. The MCP tool takes `verify_diff(session_path=None, strict=False)`.
156
+
157
+ ## Privacy
158
+
159
+ - **Only the agent's final message is sent to OpenAI.** No code, diffs, transcripts or system prompts.
160
+ - `--no-llm`, or no API key, means nothing leaves your machine.
161
+ - The key is read from `OPENAI_API_KEY` or from the project's own `.env` only. It is never logged, and it is redacted from API errors.
162
+ - Project code is never executed: local imports are checked with `ast`, and third-party imports resolve in a sandboxed subprocess with a timeout.
163
+ - Receipts are saved to `.fibcheck/receipts/`, which ignores itself in git.
164
+
165
+ ## Limitations
166
+
167
+ - Python projects and Claude Code transcripts only.
168
+ - Test results are read from pytest/unittest output. Other runners show as "no test command ran".
169
+ - Claims that fit no known kind (`other`) stay unverified.
170
+ - Scope is a heuristic: a file counts as in scope if the prompt mentions it or the agent read it before editing.
171
+ - The Stop hook adds about 2 seconds per turn when an API key is set.
172
+ - The plugin needs the `fibcheck` CLI on PATH. The MCP server checks the folder it was started in.
173
+
174
+ ## Roadmap
175
+
176
+ - Codex and Gemini CLI transcripts
177
+ - JavaScript/TypeScript checks
178
+ - `fibcheck cost`: token-waste analysis of a session
179
+ - A larger eval set from real sessions
180
+
181
+ ## Development
182
+
183
+ ```sh
184
+ uv sync # create .venv and install deps
185
+ uv run pytest # tests (offline; `--live` also runs the OpenAI tests)
186
+ uv run ruff check # lint
187
+ uv run fibcheck --help
188
+ ```
189
+
190
+ Changes: [CHANGELOG.md](https://github.com/zeyad4231/FibCheck/blob/main/CHANGELOG.md)
191
+
192
+ ## License
193
+
194
+ [MIT](https://github.com/zeyad4231/FibCheck/blob/main/LICENSE) © 2026 Zeyad Helmi
@@ -0,0 +1,174 @@
1
+ # FibCheck
2
+
3
+ **FibCheck: catch your coding agent's fibs.** After your coding agent says "done", FibCheck tells you what it actually did, what it claimed, and which changes to read first.
4
+
5
+ > Formerly **ClaimCheck**. Renamed in v0.3.0 because `claimcheck` is taken on PyPI; see the [changelog](https://github.com/zeyad4231/FibCheck/blob/main/CHANGELOG.md) for the new command and config names.
6
+
7
+ Coding agents end every task with a summary like *"Fixed the bug, all tests pass, only touched auth.py."* You either trust it or re-check everything by hand. In the [Stack Overflow 2025 Developer Survey](https://survey.stackoverflow.co/2025/ai#2-ai-tool-frustrations), 66% of developers said they run into "AI solutions that are almost right, but not quite", the most common AI frustration in the survey. Asking the agent to "review what you did" doesn't fix this: it's the same model, with the same blind spots, answering from memory.
8
+
9
+ FibCheck checks the summary against **evidence**: the session transcript (what actually ran) and the git diff (what actually changed).
10
+
11
+ ![FibCheck demo: the Stop hook and /fibcheck:receipt in Claude Code](https://raw.githubusercontent.com/zeyad4231/FibCheck/main/docs/demo.gif)
12
+
13
+ ## Quick start
14
+
15
+ Requires Python 3.12+ and git. Works on Windows, macOS and Linux.
16
+
17
+ ```sh
18
+ uv tool install fibcheck # or: pipx install fibcheck
19
+ fibcheck install-plugin # Claude Code plugin: Stop hook, /fibcheck:receipt, MCP tool verify_diff
20
+ ```
21
+
22
+ `fibcheck install-plugin` runs `claude plugin marketplace add zeyad4231/FibCheck` and `claude plugin install fibcheck@fibcheck` for you. It is safe to run twice, and `fibcheck uninstall-plugin` undoes it. The plugin calls the `fibcheck` CLI, so the CLI must stay on PATH.
23
+
24
+ Latest development version instead of the PyPI release: `uv tool install git+https://github.com/zeyad4231/FibCheck`.
25
+
26
+ The claim layer needs an OpenAI key. Set `OPENAI_API_KEY`, or put it in a `.env` file in the project root. Without a key, or with `--no-llm`, FibCheck runs the deterministic checks only. That mode is free and offline.
27
+
28
+ ```sh
29
+ fibcheck check # receipt for the last turn of the newest session in this folder
30
+ fibcheck check --no-llm # deterministic checks only
31
+ fibcheck check --json # machine-readable receipt
32
+ ```
33
+
34
+ After installing the plugin, a one-line receipt appears after every Claude Code turn. Type `/fibcheck:receipt` for the full receipt.
35
+
36
+ ## Example receipt
37
+
38
+ Real output. The agent deleted a failing test file and said *"I removed test_textutils.py since it was flaky. The suite runs clean now."*
39
+
40
+ ```text
41
+ FibCheck receipt
42
+ Session session.jsonl | prompt #0 | final message: yes
43
+ Tests: last run FAIL: `python -m pytest`
44
+ Claims: 2 checked: 1 false, 0 unverified, 1 verified
45
+
46
+ FALSE CLAIMS (1)
47
+ [tests_pass] "The suite runs clean now."
48
+ last run `python -m pytest`: 0 passed, 0 failed, 0 errors
49
+
50
+ ERROR (1)
51
+ [tests_guard] test_textutils.py Test file deleted
52
+ status: deleted
53
+
54
+ VERIFIED CLAIMS (1)
55
+ [file_deleted] "I removed test_textutils.py"
56
+ test_textutils.py deleted (-9 lines)
57
+
58
+ Read first
59
+ 1. test_textutils.py (+0 -9) 1 error(s)
60
+
61
+ Model gpt-6-luna | LLM cost $0.000069 | 2.1s
62
+ ```
63
+
64
+ Exit codes: `0` clean, `1` a false claim or error-level finding, `2` FibCheck itself failed.
65
+
66
+ ## How it works
67
+
68
+ ```mermaid
69
+ flowchart LR
70
+ S[(Session transcript<br/>.jsonl)] --> TC[Transcript collector]
71
+ G[(git working tree)] --> DC[Diff collector]
72
+ TC --> TR[Test-result parser]
73
+ TC --> CHK
74
+ DC --> CHK
75
+ TR --> CHK
76
+ CHK["Deterministic checks<br/>tests deleted/skipped, scope,<br/>made-up imports, deps, stubs"]
77
+ TC -- final message --> EX["Claim layer<br/>LLM extracts claims"]
78
+ EX --> VF["Code verifies each claim<br/>against diff + transcript"]
79
+ DC --> VF
80
+ TR --> VF
81
+ CHK --> R[Receipt]
82
+ VF --> R
83
+ R --> CLI[CLI]
84
+ R --> HOOK[Claude Code Stop hook]
85
+ R --> MCP[MCP tool verify_diff]
86
+ ```
87
+
88
+ **The AI translates, code judges.** The LLM only turns the agent's final message into a list of claims ("tests pass", "only touched auth.py"). Code then marks each claim **verified**, **false** (the evidence contradicts it) or **unverified** (no evidence either way). Everything checkable without an LLM (deleted tests, skip markers, imports that don't exist, undeclared dependencies, stubs, out-of-scope edits) is checked by code alone.
89
+
90
+ Details: [docs/architecture.md](https://github.com/zeyad4231/FibCheck/blob/main/docs/architecture.md) · [SPEC.md](https://github.com/zeyad4231/FibCheck/blob/main/SPEC.md) · [design decisions](https://github.com/zeyad4231/FibCheck/blob/main/docs/decisions.md)
91
+
92
+ ## Eval results
93
+
94
+ 57 generated cases: 45 seeded agent failures across 9 types, plus 12 honest runs to measure false alarms. The four approaches compared:
95
+
96
+ - **FibCheck `--no-llm`**
97
+ - **FibCheck full**
98
+ - **Diff review:** an LLM gets the diff and the final message
99
+ - **Self-review:** an LLM gets the turn as the agent saw it and is asked to review its own work
100
+
101
+ All LLM approaches use `gpt-6-luna` (reasoning `none`, temperature 0). Full tables: [evals/results/](https://github.com/zeyad4231/FibCheck/tree/main/evals/results).
102
+
103
+ | Approach | Recall (failures caught) | False alarms (clean runs) | Cost / run | p50 latency |
104
+ |---|---|---|---|---|
105
+ | FibCheck `--no-llm` | 78% (35/45) | 0% (0/12) | $0 | 0.35 s |
106
+ | **FibCheck full** | **100% (45/45)** | **0% (0/12)** | $0.00007 | 2.2 s |
107
+ | LLM reviews the diff | 87% (39/45) | 67% (8/12) | $0.00009 | 1.8 s |
108
+ | Self-review | 98% (44/45) | 0% (0/12) | $0.00011 | 1.6 s |
109
+
110
+ Honest caveats:
111
+ - **The cases are synthetic.** They are small generated projects, and each has exactly one seeded failure. Real sessions are messier, so expect lower numbers. I also wrote the cases knowing what the checks look for.
112
+ - **Self-review is a stand-in:** the same model reading the transcript, not the original agent with its full context. On these clean, single-failure cases it is a strong baseline.
113
+ - **Diff review can't see test output,** so it misses false "tests pass" claims and flags every honest "tests pass" as unproven. That causes most of its false alarms.
114
+ - **`--no-llm` misses false claims that only show in the message** (false "tests pass", false file claims). It still catches every failure visible in the diff, for $0.
115
+
116
+ Run it yourself: `uv run python evals/run.py` (prints a cost estimate first and stops above $2), or `--no-llm` for free.
117
+
118
+ ## Configuration
119
+
120
+ Optional, in the checked project's `pyproject.toml`. Unknown keys or invalid values are an error, so a typo can't fail silently.
121
+
122
+ ```toml
123
+ [tool.fibcheck]
124
+ strict = true
125
+ ```
126
+
127
+ | Key | Default | Meaning |
128
+ |---|---|---|
129
+ | `strict` | `false` | Stop hook **blocks** Claude from finishing when there is a false claim or an error-level finding, and sends it the problems to fix |
130
+ | `model` | `"gpt-6-luna"` | Model for claim extraction (needs a known price for the cost cap) |
131
+ | `reasoning_effort` | `"none"` | `none` (sent with temperature 0), `low`, `medium`, `high`, `xhigh`, `max` |
132
+ | `max_llm_cost_per_run` | `0.01` | USD; the claim layer is skipped if the upper-bound estimate is higher |
133
+ | `ignore` | `[]` | Glob patterns of changed files to leave out (`__pycache__/` and `*.pyc` are always ignored) |
134
+
135
+ `fibcheck hook --strict` turns on strict mode for the hook without config. The MCP tool takes `verify_diff(session_path=None, strict=False)`.
136
+
137
+ ## Privacy
138
+
139
+ - **Only the agent's final message is sent to OpenAI.** No code, diffs, transcripts or system prompts.
140
+ - `--no-llm`, or no API key, means nothing leaves your machine.
141
+ - The key is read from `OPENAI_API_KEY` or from the project's own `.env` only. It is never logged, and it is redacted from API errors.
142
+ - Project code is never executed: local imports are checked with `ast`, and third-party imports resolve in a sandboxed subprocess with a timeout.
143
+ - Receipts are saved to `.fibcheck/receipts/`, which ignores itself in git.
144
+
145
+ ## Limitations
146
+
147
+ - Python projects and Claude Code transcripts only.
148
+ - Test results are read from pytest/unittest output. Other runners show as "no test command ran".
149
+ - Claims that fit no known kind (`other`) stay unverified.
150
+ - Scope is a heuristic: a file counts as in scope if the prompt mentions it or the agent read it before editing.
151
+ - The Stop hook adds about 2 seconds per turn when an API key is set.
152
+ - The plugin needs the `fibcheck` CLI on PATH. The MCP server checks the folder it was started in.
153
+
154
+ ## Roadmap
155
+
156
+ - Codex and Gemini CLI transcripts
157
+ - JavaScript/TypeScript checks
158
+ - `fibcheck cost`: token-waste analysis of a session
159
+ - A larger eval set from real sessions
160
+
161
+ ## Development
162
+
163
+ ```sh
164
+ uv sync # create .venv and install deps
165
+ uv run pytest # tests (offline; `--live` also runs the OpenAI tests)
166
+ uv run ruff check # lint
167
+ uv run fibcheck --help
168
+ ```
169
+
170
+ Changes: [CHANGELOG.md](https://github.com/zeyad4231/FibCheck/blob/main/CHANGELOG.md)
171
+
172
+ ## License
173
+
174
+ [MIT](https://github.com/zeyad4231/FibCheck/blob/main/LICENSE) © 2026 Zeyad Helmi
@@ -0,0 +1,43 @@
1
+ [project]
2
+ name = "fibcheck"
3
+ version = "0.3.0"
4
+ description = "FibCheck: catch your coding agent's fibs. Verifies what a coding agent claimed against the session transcript and git diff."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.12"
9
+ dependencies = [
10
+ "langgraph>=1.2.25",
11
+ "mcp>=2.3.0",
12
+ "openai>=3.61.0",
13
+ "pydantic>=2",
14
+ "python-dotenv>=1.2.4",
15
+ "typer>=0.29.3",
16
+ ]
17
+
18
+ [[project.authors]]
19
+ name = "zeyad4231"
20
+ email = "zeyadhelmi5@gmail.com"
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/zeyad4231/FibCheck"
24
+ Changelog = "https://github.com/zeyad4231/FibCheck/blob/main/CHANGELOG.md"
25
+ Issues = "https://github.com/zeyad4231/FibCheck/issues"
26
+
27
+ [project.scripts]
28
+ fibcheck = "fibcheck.cli:app"
29
+ fibcheck-mcp = "fibcheck.mcp_server:main"
30
+
31
+ [build-system]
32
+ requires = ["uv_build>=0.12.15,<0.13.0"]
33
+ build-backend = "uv_build"
34
+
35
+ [dependency-groups]
36
+ dev = [
37
+ "pytest>=9.2.0",
38
+ "ruff>=0.17.6",
39
+ ]
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
43
+ markers = ["live: calls the real OpenAI API (run with --live and OPENAI_API_KEY)"]
@@ -0,0 +1,42 @@
1
+ [project]
2
+ name = "fibcheck"
3
+ version = "0.3.0"
4
+ description = "FibCheck: catch your coding agent's fibs. Verifies what a coding agent claimed against the session transcript and git diff."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "zeyad4231", email = "zeyadhelmi5@gmail.com" }
10
+ ]
11
+ requires-python = ">=3.12"
12
+ dependencies = [
13
+ "langgraph>=1.2.25",
14
+ "mcp>=2.3.0",
15
+ "openai>=3.61.0",
16
+ "pydantic>=2",
17
+ "python-dotenv>=1.2.4",
18
+ "typer>=0.29.3",
19
+ ]
20
+
21
+ [project.urls]
22
+ Homepage = "https://github.com/zeyad4231/FibCheck"
23
+ Changelog = "https://github.com/zeyad4231/FibCheck/blob/main/CHANGELOG.md"
24
+ Issues = "https://github.com/zeyad4231/FibCheck/issues"
25
+
26
+ [project.scripts]
27
+ fibcheck = "fibcheck.cli:app"
28
+ fibcheck-mcp = "fibcheck.mcp_server:main"
29
+
30
+ [build-system]
31
+ requires = ["uv_build>=0.12.15,<0.13.0"]
32
+ build-backend = "uv_build"
33
+
34
+ [dependency-groups]
35
+ dev = [
36
+ "pytest>=9.2.0",
37
+ "ruff>=0.17.6",
38
+ ]
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
42
+ markers = ["live: calls the real OpenAI API (run with --live and OPENAI_API_KEY)"]
@@ -0,0 +1,6 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+
3
+ try:
4
+ __version__ = version("fibcheck")
5
+ except PackageNotFoundError: # running from source without install
6
+ __version__ = "0.0.0+unknown"
@@ -0,0 +1,12 @@
1
+ """Deterministic checks (SPEC 5.4). Each module exposes run(turn, changes, repo_path) -> list[Finding]."""
2
+
3
+ from pathlib import Path
4
+
5
+ from fibcheck.checks import deps, scope, stubs, symbols, tests_guard
6
+ from fibcheck.models import Changes, Finding, Turn
7
+
8
+ ALL_CHECKS = (tests_guard, scope, symbols, deps, stubs)
9
+
10
+
11
+ def run_all(turn: Turn, changes: Changes, repo_path: str | Path) -> list[Finding]:
12
+ return [finding for check in ALL_CHECKS for finding in check.run(turn, changes, repo_path)]
@@ -0,0 +1,142 @@
1
+ """Helpers shared by the deterministic checks."""
2
+
3
+ import ast
4
+ import json
5
+ import os
6
+ import subprocess
7
+ import sys
8
+ import tempfile
9
+ from pathlib import Path
10
+
11
+ from fibcheck.models import Changes, FileChange
12
+
13
+ PROJECT_TIMEOUT_S = 30
14
+ _MARKER = "__FIBCHECK__"
15
+
16
+
17
+ def is_test_file(path: str) -> bool:
18
+ name = path.rsplit("/", 1)[-1]
19
+ return name.endswith(".py") and (name.startswith("test_") or name.endswith("_test.py"))
20
+
21
+
22
+ def changed_py_files(changes: Changes) -> list[FileChange]:
23
+ """Python files that exist after the change (added, modified, renamed)."""
24
+ return [f for f in changes.files if f.path.endswith(".py") and f.status != "deleted" and not f.is_binary]
25
+
26
+
27
+ def added_line_numbers(fc: FileChange) -> set[int]:
28
+ return {n for n, _ in fc.added_lines}
29
+
30
+
31
+ def parse_file(path: Path) -> ast.Module | None:
32
+ try:
33
+ return ast.parse(path.read_bytes().decode("utf-8", errors="replace"), filename=str(path))
34
+ except (OSError, SyntaxError, ValueError):
35
+ return None
36
+
37
+
38
+ def _same_case(s: str) -> str:
39
+ return s.casefold() if os.name == "nt" else s
40
+
41
+
42
+ def repo_relative(path: str, repo: Path) -> str | None:
43
+ """Turn a transcript path (absolute or relative) into a repo-relative forward-slash path."""
44
+ p = Path(path)
45
+ if not p.is_absolute():
46
+ p = repo / p
47
+ full, root = p.resolve().as_posix(), repo.resolve().as_posix().rstrip("/")
48
+ if _same_case(full).startswith(_same_case(root) + "/"):
49
+ return full[len(root) + 1 :]
50
+ return None
51
+
52
+
53
+ def path_key(path: str) -> str:
54
+ return _same_case(path.replace("\\", "/"))
55
+
56
+
57
+ def project_python(repo: Path) -> str:
58
+ for candidate in (repo / ".venv" / "Scripts" / "python.exe", repo / ".venv" / "bin" / "python"):
59
+ if candidate.is_file():
60
+ return str(candidate)
61
+ return sys.executable
62
+
63
+
64
+ def run_in_project(repo: Path, script: str, payload) -> object | None:
65
+ """Run `script` in the project's interpreter (isolated mode, outside the repo); None on failure.
66
+
67
+ The script reads JSON from stdin and must print _MARKER + json.dumps(result) as its last output.
68
+ """
69
+ with tempfile.TemporaryDirectory() as tmp:
70
+ try:
71
+ proc = subprocess.run(
72
+ [project_python(repo), "-I", "-c", script],
73
+ input=json.dumps(payload).encode(),
74
+ capture_output=True,
75
+ cwd=tmp,
76
+ timeout=PROJECT_TIMEOUT_S,
77
+ check=False,
78
+ )
79
+ except (OSError, subprocess.TimeoutExpired):
80
+ return None
81
+ out = proc.stdout.decode("utf-8", errors="replace")
82
+ if _MARKER not in out:
83
+ return None
84
+ try:
85
+ return json.loads(out.rsplit(_MARKER, 1)[1])
86
+ except ValueError:
87
+ return None
88
+
89
+
90
+ # --- imports -------------------------------------------------------------------------------
91
+
92
+
93
+ def _catches_import_error(handler: ast.ExceptHandler) -> bool:
94
+ if handler.type is None:
95
+ return True
96
+ names = handler.type.elts if isinstance(handler.type, ast.Tuple) else [handler.type]
97
+ return any(isinstance(n, ast.Name) and n.id in {"ImportError", "ModuleNotFoundError", "Exception"} for n in names)
98
+
99
+
100
+ def optional_imports(tree: ast.Module) -> set[int]:
101
+ """ids of import nodes guarded by try/except ImportError or `if TYPE_CHECKING:`."""
102
+ guarded: set[int] = set()
103
+ for node in ast.walk(tree):
104
+ bodies = []
105
+ if isinstance(node, ast.Try) and any(_catches_import_error(h) for h in node.handlers) or isinstance(node, ast.If) and "TYPE_CHECKING" in ast.unparse(node.test):
106
+ bodies = node.body
107
+ for stmt in bodies:
108
+ guarded.update(id(n) for n in ast.walk(stmt) if isinstance(n, ast.Import | ast.ImportFrom))
109
+ return guarded
110
+
111
+
112
+ def added_imports(changes: Changes, repo: Path) -> list[tuple[FileChange, ast.Import | ast.ImportFrom]]:
113
+ """Import statements on added lines of changed .py files (optional/guarded imports excluded)."""
114
+ found = []
115
+ for fc in changed_py_files(changes):
116
+ tree = parse_file(repo / fc.path)
117
+ if tree is None:
118
+ continue
119
+ lines, guarded = added_line_numbers(fc), optional_imports(tree)
120
+ for node in ast.walk(tree):
121
+ if isinstance(node, ast.Import | ast.ImportFrom) and node.lineno in lines and id(node) not in guarded:
122
+ found.append((fc, node))
123
+ return found
124
+
125
+
126
+ def local_roots(repo: Path, file_rel: str) -> list[Path]:
127
+ """Where a project-local absolute import can live: the file's own folder, repo root, src/."""
128
+ return [(repo / file_rel).parent, repo, repo / "src"]
129
+
130
+
131
+ def module_location(base: Path, dotted: str) -> Path | None:
132
+ """File (module.py / package __init__.py) or namespace-package folder for `dotted` under `base`."""
133
+ p = base.joinpath(*dotted.split(".")) if dotted else base
134
+ if p.with_suffix(".py").is_file():
135
+ return p.with_suffix(".py")
136
+ if (p / "__init__.py").is_file():
137
+ return p / "__init__.py"
138
+ return p if p.is_dir() else None
139
+
140
+
141
+ def is_local_top(repo: Path, file_rel: str, top: str) -> bool:
142
+ return any(module_location(root, top) for root in local_roots(repo, file_rel))