scribe-gate 0.1.3__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pongtana Feronti
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,205 @@
1
+ Metadata-Version: 2.4
2
+ Name: scribe-gate
3
+ Version: 0.1.3
4
+ Summary: Scribe: a validation gauntlet and trust gate for agent-written Python code
5
+ Author: Pongtana Feronti
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Mrpongalfer/scribe
8
+ Project-URL: Repository, https://github.com/Mrpongalfer/scribe
9
+ Keywords: agents,validation,code-review,trust-gate,llm,devops
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: tomli>=2.0; python_version < "3.11"
26
+ Provides-Extra: tools
27
+ Requires-Dist: ruff>=0.4; extra == "tools"
28
+ Requires-Dist: mypy>=1.10; extra == "tools"
29
+ Requires-Dist: pytest>=8; extra == "tools"
30
+ Requires-Dist: pip-audit>=2.7; extra == "tools"
31
+ Requires-Dist: pre-commit>=3; extra == "tools"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=8; extra == "dev"
34
+ Requires-Dist: ruff>=0.4; extra == "dev"
35
+ Requires-Dist: mypy>=1.10; extra == "dev"
36
+ Dynamic: license-file
37
+
38
+ scribe-gate
39
+ A validation gauntlet and trust gate for agent-written Python code.
40
+ Scribe sits between an agent writing code and that code being committed. It runs
41
+ a deterministic gauntlet — isolated virtualenv, formatting, lint, type check,
42
+ AI-generated tests, AI code review, pre-commit hooks — and emits a structured
43
+ JSON report. It validates; it never rewrites your code. And it never commits
44
+ without explicit operator approval.
45
+ agent writes code ──▶ SCRIBE ──▶ ✅ report + optional commit
46
+ ──▶ ❌ report, pipeline halts
47
+ AI coding agents write code fast — and wrong in ways that look right. Existing
48
+ guardrails either auto-fix what they find (hiding the problem from you) or run
49
+ a single linter and call it done. Scribe is the gate between the agent and the
50
+ commit: a deterministic gauntlet that checks the code, reports honestly, and
51
+ never touches it. Built for anyone running coding agents — local or API — who
52
+ wants proof, not vibes, before code lands.
53
+ Install
54
+ pip install git+https://github.com/Mrpongalfer/Scribe.git
55
+ # with the gauntlet tools (ruff, mypy, pytest, pip-audit, pre-commit):
56
+ pip install "scribe-gate[tools] @ git+https://github.com/Mrpongalfer/Scribe.git"
57
+ Requires Python 3.10+.
58
+ Quickstart
59
+ (PyPI release coming — for now, install from source.)
60
+ Review a file in place (no changes, no commit — the safest first run):
61
+ scribe --review-only --files src/my_module.py
62
+ Validate a new file an agent produced, copying it into the project:
63
+ scribe /path/to/project \
64
+ --source-file /tmp/agent_output.py \
65
+ --target-file src/my_module.py
66
+ Full run with a commit on success (prompts for approval first):
67
+ scribe /path/to/project \
68
+ --source-file /tmp/agent_output.py \
69
+ --target-file src/my_module.py \
70
+ --commit
71
+ Use as a pre-commit hook — add to .pre-commit-config.yaml:
72
+ - repo: https://github.com/Mrpongalfer/Scribe
73
+ rev: v0.1.3
74
+ hooks:
75
+ - id: scribe-gate
76
+ (Requires pip install "scribe-gate[tools]" in the environment running pre-commit.)
77
+ The gauntlet
78
+ Default validation_steps in order:
79
+ Step
80
+ What it does
81
+ validate_inputs
82
+ Path safety checks (no escapes from the target dir)
83
+ setup_environment
84
+ Create/reuse an isolated .venv (package isolation only) in the target dir
85
+ install_deps
86
+ Install the target project's declared dependencies
87
+ audit_deps
88
+ pip-audit vulnerability scan
89
+ apply_code
90
+ Copy the source file into the target location
91
+ format_code
92
+ ruff format --check (check only — never rewrites)
93
+ lint_code
94
+ ruff check (check only — never auto-fixes)
95
+ type_check
96
+ mypy
97
+ extract_signatures
98
+ AST signature extraction for test focus
99
+ generate_tests
100
+ LLM generates pytest tests (strict code-only contract)
101
+ save_tests
102
+ Write them to tests/scribe_generated/
103
+ execute_tests
104
+ Run them with pytest
105
+ review_code
106
+ LLM structured review → findings (advisory)
107
+ run_precommit
108
+ Project's own pre-commit hooks, if configured
109
+ commit_changes
110
+ git add + git commit — only with --commit and operator approval
111
+ generate_report
112
+ Emit the final JSON report
113
+ Any FAILURE halts the pipeline. Exit code is 0 on success, 1 on validation
114
+ failure, 2 on configuration/initialization errors.
115
+ LLM backends
116
+ Two backends ship; both go through the same generate() interface.
117
+ Backend
118
+ Selection
119
+ Config
120
+ Ollama (default)
121
+ SCRIBE_LLM_BACKEND=ollama
122
+ SCRIBE_LLM_BASE_URL (default http://localhost:11434), SCRIBE_LLM_MODEL (default gemma:2b)
123
+ OpenAI-compatible
124
+ SCRIBE_LLM_BACKEND=openai
125
+ SCRIBE_LLM_BASE_URL, SCRIBE_LLM_API_KEY, SCRIBE_LLM_MODEL (default gpt-4o-mini)
126
+ CLI flags --llm-backend, --llm-model, --llm-base-url override env/config.
127
+ LLM calls use bounded retries (llm_request_timeout, llm_retries,
128
+ llm_retry_delay). An LLM failure fails its step — it never silently passes.
129
+ Configuration (scribe.toml)
130
+ Place scribe.toml in the target project dir (or pass --config-file).
131
+ All keys are optional; shown with defaults:
132
+ # Paths the target dir is allowed to live under (safety rail).
133
+ allowed_target_bases = ["~", "/tmp", "."]
134
+
135
+ # Gate strictness
136
+ fail_on_lint_critical = true
137
+ fail_on_mypy_error = true
138
+ fail_on_test_failure = true
139
+ fail_on_audit_severity = "high" # low | medium | high | critical
140
+
141
+ # LLM
142
+ llm_backend = "ollama" # or "openai" / "openai-compatible"
143
+ llm_model = "" # default: backend default
144
+ llm_base_url = "" # default: backend default
145
+ # llm_api_key: prefer SCRIBE_LLM_API_KEY env var over this file
146
+ llm_request_timeout = 180.0
147
+ llm_retries = 2
148
+ llm_retry_delay = 5.0
149
+
150
+ # Tools
151
+ default_tool_timeout = 180.0
152
+ max_tool_output_chars = 200000
153
+ tool_paths = {} # e.g. { ruff = "/opt/bin/ruff" } — see "Scope and limits"
154
+
155
+ commit_message_template = "chore(scribe): validate {target_file}"
156
+
157
+ # Subset/reorder the gauntlet, e.g. for fast CI runs:
158
+ # validation_steps = ["validate_inputs", "apply_code", "format_code",
159
+ # "lint_code", "type_check", "generate_report"]
160
+ The report
161
+ --report-format json (default) prints a machine-readable report:
162
+ {
163
+ "scribe_version": "0.1.3",
164
+ "run_id": "scribe_20261101_...",
165
+ "overall_status": "SUCCESS",
166
+ "target_project_dir": "/path/to/project",
167
+ "target_file_relative": "src/my_module.py",
168
+ "commit_attempted": false,
169
+ "commit_sha": null,
170
+ "steps": [
171
+ {"name": "lint_code", "status": "SUCCESS", "duration_seconds": 0.42,
172
+ "details": {"tool_name": "ruff check", "return_code": 0}, "error_message": null}
173
+ ],
174
+ "audit_findings": [],
175
+ "ai_review_findings": [{"severity": "low", "description": "...", "location": "..."}],
176
+ "test_results_summary": {"return_code": 0}
177
+ }
178
+ Step statuses: SUCCESS | FAILURE | WARNING | SKIPPED | ADVISORY | PENDING.
179
+ --report-format text prints a human-readable summary; --report-file PATH
180
+ also writes the report to disk.
181
+ Design principles
182
+ Validate, don't fix. Formatting and lint run in check mode. Fixing is the
183
+ your job (or your agent's) — Scribe is the gate, not the mechanic.
184
+ Safe defaults. No commit unless --commit is passed, and even then the
185
+ operator approves at an interactive prompt (or passes --yes explicitly for
186
+ CI). Non-interactive runs without --yes decline the commit.
187
+ Idempotent. Re-running against the same inputs is safe: venvs are reused,
188
+ file writes are deterministic overwrites, reports are regenerated.
189
+ Typed config, structured output. Every run ends in a schema-stable JSON
190
+ report suitable for CI artifacts and audit logs.
191
+ Local-first. The default backend is local Ollama; no cloud account needed.
192
+ Scope and limits
193
+ Scribe is a quality gate, not a sandbox. The .venv is package isolation
194
+ only — Scribe runs the project's install code, LLM-generated tests, and
195
+ pre-commit hooks with your privileges, and a scribe.toml in the target dir
196
+ can override tool paths and steps. Pre-commit hooks run after the static
197
+ checks and can modify validated files; generated tests are syntax-checked,
198
+ not safety-checked. Point it at code you trust; for anything else, run it
199
+ inside a disposable container or VM.
200
+ v1 scope
201
+ Python only. No auto-fix loop. No governance/policy engine — the goal-vector
202
+ experiment from the original prototype was cut as unproven. The self-improvement
203
+ loop is a separate project.
204
+ License
205
+ MIT — see LICENSE.
@@ -0,0 +1,168 @@
1
+ scribe-gate
2
+ A validation gauntlet and trust gate for agent-written Python code.
3
+ Scribe sits between an agent writing code and that code being committed. It runs
4
+ a deterministic gauntlet — isolated virtualenv, formatting, lint, type check,
5
+ AI-generated tests, AI code review, pre-commit hooks — and emits a structured
6
+ JSON report. It validates; it never rewrites your code. And it never commits
7
+ without explicit operator approval.
8
+ agent writes code ──▶ SCRIBE ──▶ ✅ report + optional commit
9
+ ──▶ ❌ report, pipeline halts
10
+ AI coding agents write code fast — and wrong in ways that look right. Existing
11
+ guardrails either auto-fix what they find (hiding the problem from you) or run
12
+ a single linter and call it done. Scribe is the gate between the agent and the
13
+ commit: a deterministic gauntlet that checks the code, reports honestly, and
14
+ never touches it. Built for anyone running coding agents — local or API — who
15
+ wants proof, not vibes, before code lands.
16
+ Install
17
+ pip install git+https://github.com/Mrpongalfer/Scribe.git
18
+ # with the gauntlet tools (ruff, mypy, pytest, pip-audit, pre-commit):
19
+ pip install "scribe-gate[tools] @ git+https://github.com/Mrpongalfer/Scribe.git"
20
+ Requires Python 3.10+.
21
+ Quickstart
22
+ (PyPI release coming — for now, install from source.)
23
+ Review a file in place (no changes, no commit — the safest first run):
24
+ scribe --review-only --files src/my_module.py
25
+ Validate a new file an agent produced, copying it into the project:
26
+ scribe /path/to/project \
27
+ --source-file /tmp/agent_output.py \
28
+ --target-file src/my_module.py
29
+ Full run with a commit on success (prompts for approval first):
30
+ scribe /path/to/project \
31
+ --source-file /tmp/agent_output.py \
32
+ --target-file src/my_module.py \
33
+ --commit
34
+ Use as a pre-commit hook — add to .pre-commit-config.yaml:
35
+ - repo: https://github.com/Mrpongalfer/Scribe
36
+ rev: v0.1.3
37
+ hooks:
38
+ - id: scribe-gate
39
+ (Requires pip install "scribe-gate[tools]" in the environment running pre-commit.)
40
+ The gauntlet
41
+ Default validation_steps in order:
42
+ Step
43
+ What it does
44
+ validate_inputs
45
+ Path safety checks (no escapes from the target dir)
46
+ setup_environment
47
+ Create/reuse an isolated .venv (package isolation only) in the target dir
48
+ install_deps
49
+ Install the target project's declared dependencies
50
+ audit_deps
51
+ pip-audit vulnerability scan
52
+ apply_code
53
+ Copy the source file into the target location
54
+ format_code
55
+ ruff format --check (check only — never rewrites)
56
+ lint_code
57
+ ruff check (check only — never auto-fixes)
58
+ type_check
59
+ mypy
60
+ extract_signatures
61
+ AST signature extraction for test focus
62
+ generate_tests
63
+ LLM generates pytest tests (strict code-only contract)
64
+ save_tests
65
+ Write them to tests/scribe_generated/
66
+ execute_tests
67
+ Run them with pytest
68
+ review_code
69
+ LLM structured review → findings (advisory)
70
+ run_precommit
71
+ Project's own pre-commit hooks, if configured
72
+ commit_changes
73
+ git add + git commit — only with --commit and operator approval
74
+ generate_report
75
+ Emit the final JSON report
76
+ Any FAILURE halts the pipeline. Exit code is 0 on success, 1 on validation
77
+ failure, 2 on configuration/initialization errors.
78
+ LLM backends
79
+ Two backends ship; both go through the same generate() interface.
80
+ Backend
81
+ Selection
82
+ Config
83
+ Ollama (default)
84
+ SCRIBE_LLM_BACKEND=ollama
85
+ SCRIBE_LLM_BASE_URL (default http://localhost:11434), SCRIBE_LLM_MODEL (default gemma:2b)
86
+ OpenAI-compatible
87
+ SCRIBE_LLM_BACKEND=openai
88
+ SCRIBE_LLM_BASE_URL, SCRIBE_LLM_API_KEY, SCRIBE_LLM_MODEL (default gpt-4o-mini)
89
+ CLI flags --llm-backend, --llm-model, --llm-base-url override env/config.
90
+ LLM calls use bounded retries (llm_request_timeout, llm_retries,
91
+ llm_retry_delay). An LLM failure fails its step — it never silently passes.
92
+ Configuration (scribe.toml)
93
+ Place scribe.toml in the target project dir (or pass --config-file).
94
+ All keys are optional; shown with defaults:
95
+ # Paths the target dir is allowed to live under (safety rail).
96
+ allowed_target_bases = ["~", "/tmp", "."]
97
+
98
+ # Gate strictness
99
+ fail_on_lint_critical = true
100
+ fail_on_mypy_error = true
101
+ fail_on_test_failure = true
102
+ fail_on_audit_severity = "high" # low | medium | high | critical
103
+
104
+ # LLM
105
+ llm_backend = "ollama" # or "openai" / "openai-compatible"
106
+ llm_model = "" # default: backend default
107
+ llm_base_url = "" # default: backend default
108
+ # llm_api_key: prefer SCRIBE_LLM_API_KEY env var over this file
109
+ llm_request_timeout = 180.0
110
+ llm_retries = 2
111
+ llm_retry_delay = 5.0
112
+
113
+ # Tools
114
+ default_tool_timeout = 180.0
115
+ max_tool_output_chars = 200000
116
+ tool_paths = {} # e.g. { ruff = "/opt/bin/ruff" } — see "Scope and limits"
117
+
118
+ commit_message_template = "chore(scribe): validate {target_file}"
119
+
120
+ # Subset/reorder the gauntlet, e.g. for fast CI runs:
121
+ # validation_steps = ["validate_inputs", "apply_code", "format_code",
122
+ # "lint_code", "type_check", "generate_report"]
123
+ The report
124
+ --report-format json (default) prints a machine-readable report:
125
+ {
126
+ "scribe_version": "0.1.3",
127
+ "run_id": "scribe_20261101_...",
128
+ "overall_status": "SUCCESS",
129
+ "target_project_dir": "/path/to/project",
130
+ "target_file_relative": "src/my_module.py",
131
+ "commit_attempted": false,
132
+ "commit_sha": null,
133
+ "steps": [
134
+ {"name": "lint_code", "status": "SUCCESS", "duration_seconds": 0.42,
135
+ "details": {"tool_name": "ruff check", "return_code": 0}, "error_message": null}
136
+ ],
137
+ "audit_findings": [],
138
+ "ai_review_findings": [{"severity": "low", "description": "...", "location": "..."}],
139
+ "test_results_summary": {"return_code": 0}
140
+ }
141
+ Step statuses: SUCCESS | FAILURE | WARNING | SKIPPED | ADVISORY | PENDING.
142
+ --report-format text prints a human-readable summary; --report-file PATH
143
+ also writes the report to disk.
144
+ Design principles
145
+ Validate, don't fix. Formatting and lint run in check mode. Fixing is the
146
+ your job (or your agent's) — Scribe is the gate, not the mechanic.
147
+ Safe defaults. No commit unless --commit is passed, and even then the
148
+ operator approves at an interactive prompt (or passes --yes explicitly for
149
+ CI). Non-interactive runs without --yes decline the commit.
150
+ Idempotent. Re-running against the same inputs is safe: venvs are reused,
151
+ file writes are deterministic overwrites, reports are regenerated.
152
+ Typed config, structured output. Every run ends in a schema-stable JSON
153
+ report suitable for CI artifacts and audit logs.
154
+ Local-first. The default backend is local Ollama; no cloud account needed.
155
+ Scope and limits
156
+ Scribe is a quality gate, not a sandbox. The .venv is package isolation
157
+ only — Scribe runs the project's install code, LLM-generated tests, and
158
+ pre-commit hooks with your privileges, and a scribe.toml in the target dir
159
+ can override tool paths and steps. Pre-commit hooks run after the static
160
+ checks and can modify validated files; generated tests are syntax-checked,
161
+ not safety-checked. Point it at code you trust; for anything else, run it
162
+ inside a disposable container or VM.
163
+ v1 scope
164
+ Python only. No auto-fix loop. No governance/policy engine — the goal-vector
165
+ experiment from the original prototype was cut as unproven. The self-improvement
166
+ loop is a separate project.
167
+ License
168
+ MIT — see LICENSE.
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scribe-gate"
7
+ version = "0.1.3"
8
+ description = "Scribe: a validation gauntlet and trust gate for agent-written Python code"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Pongtana Feronti" }]
13
+ keywords = ["agents", "validation", "code-review", "trust-gate", "llm", "devops"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Software Development :: Quality Assurance",
25
+ "Topic :: Software Development :: Testing",
26
+ ]
27
+ dependencies = [
28
+ "httpx>=0.27",
29
+ "tomli>=2.0; python_version < '3.11'",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ tools = [
34
+ "ruff>=0.4",
35
+ "mypy>=1.10",
36
+ "pytest>=8",
37
+ "pip-audit>=2.7",
38
+ "pre-commit>=3",
39
+ ]
40
+ dev = [
41
+ "pytest>=8",
42
+ "ruff>=0.4",
43
+ "mypy>=1.10",
44
+ ]
45
+
46
+ [project.scripts]
47
+ scribe = "scribe.cli:main"
48
+ scribe-gate = "scribe.cli:main"
49
+
50
+ [project.urls]
51
+ Homepage = "https://github.com/Mrpongalfer/scribe"
52
+ Repository = "https://github.com/Mrpongalfer/scribe"
53
+
54
+ [tool.setuptools.packages.find]
55
+ where = ["src"]
56
+
57
+ [tool.ruff]
58
+ target-version = "py310"
59
+ line-length = 100
60
+ # tests/fixtures contains deliberately broken files for the gauntlet tests.
61
+ exclude = ["tests/fixtures"]
62
+
63
+ [tool.ruff.lint]
64
+ select = ["E", "F", "W", "I", "UP"]
65
+
66
+ [tool.mypy]
67
+ python_version = "3.10"
68
+ strict = false
69
+ warn_return_any = true
70
+ warn_unused_configs = true
71
+ ignore_missing_imports = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ """scribe-gate: a validation gauntlet / trust gate for agent-written Python code."""
2
+
3
+ __version__ = "0.1.3"
4
+ __all__ = ["__version__"]