sourcepack 1.10.0a0__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.
- sourcepack-1.10.0a0/LICENSE +21 -0
- sourcepack-1.10.0a0/PKG-INFO +311 -0
- sourcepack-1.10.0a0/README.md +294 -0
- sourcepack-1.10.0a0/pyproject.toml +26 -0
- sourcepack-1.10.0a0/setup.cfg +4 -0
- sourcepack-1.10.0a0/src/sourcepack/__init__.py +19 -0
- sourcepack-1.10.0a0/src/sourcepack/assets/__init__.py +1 -0
- sourcepack-1.10.0a0/src/sourcepack/assets/audit_template.md +3 -0
- sourcepack-1.10.0a0/src/sourcepack/assets/packet_instructions.md +3 -0
- sourcepack-1.10.0a0/src/sourcepack/baseline.py +285 -0
- sourcepack-1.10.0a0/src/sourcepack/cli.py +2991 -0
- sourcepack-1.10.0a0/src/sourcepack/commands.py +149 -0
- sourcepack-1.10.0a0/src/sourcepack/dependencies.py +98 -0
- sourcepack-1.10.0a0/src/sourcepack/diff_parser.py +122 -0
- sourcepack-1.10.0a0/src/sourcepack/ecosystems/__init__.py +3 -0
- sourcepack-1.10.0a0/src/sourcepack/ecosystems/generic.py +13 -0
- sourcepack-1.10.0a0/src/sourcepack/ecosystems/node.py +3 -0
- sourcepack-1.10.0a0/src/sourcepack/ecosystems/python.py +12 -0
- sourcepack-1.10.0a0/src/sourcepack/errors.py +19 -0
- sourcepack-1.10.0a0/src/sourcepack/evidence.py +109 -0
- sourcepack-1.10.0a0/src/sourcepack/execution_ledger.py +252 -0
- sourcepack-1.10.0a0/src/sourcepack/git.py +50 -0
- sourcepack-1.10.0a0/src/sourcepack/judgment.py +1922 -0
- sourcepack-1.10.0a0/src/sourcepack/packet.py +837 -0
- sourcepack-1.10.0a0/src/sourcepack/paths.py +68 -0
- sourcepack-1.10.0a0/src/sourcepack/policy.py +38 -0
- sourcepack-1.10.0a0/src/sourcepack/reason_codes.py +72 -0
- sourcepack-1.10.0a0/src/sourcepack/reports/__init__.py +5 -0
- sourcepack-1.10.0a0/src/sourcepack/reports/html.py +88 -0
- sourcepack-1.10.0a0/src/sourcepack/reports/json.py +123 -0
- sourcepack-1.10.0a0/src/sourcepack/reports/markdown.py +61 -0
- sourcepack-1.10.0a0/src/sourcepack/schemas.py +63 -0
- sourcepack-1.10.0a0/src/sourcepack.egg-info/PKG-INFO +311 -0
- sourcepack-1.10.0a0/src/sourcepack.egg-info/SOURCES.txt +58 -0
- sourcepack-1.10.0a0/src/sourcepack.egg-info/dependency_links.txt +1 -0
- sourcepack-1.10.0a0/src/sourcepack.egg-info/entry_points.txt +2 -0
- sourcepack-1.10.0a0/src/sourcepack.egg-info/top_level.txt +1 -0
- sourcepack-1.10.0a0/tests/test_baseline_integrity.py +184 -0
- sourcepack-1.10.0a0/tests/test_baseline_lifecycle_cli.py +18 -0
- sourcepack-1.10.0a0/tests/test_behavior_matrix.py +96 -0
- sourcepack-1.10.0a0/tests/test_ci_docs_truth.py +9 -0
- sourcepack-1.10.0a0/tests/test_command_resolver.py +43 -0
- sourcepack-1.10.0a0/tests/test_confidence_report.py +16 -0
- sourcepack-1.10.0a0/tests/test_dependency_resolver.py +34 -0
- sourcepack-1.10.0a0/tests/test_engine_inversion.py +134 -0
- sourcepack-1.10.0a0/tests/test_evidence_model.py +44 -0
- sourcepack-1.10.0a0/tests/test_execution_ledger.py +148 -0
- sourcepack-1.10.0a0/tests/test_final_boss_integration.py +72 -0
- sourcepack-1.10.0a0/tests/test_gauntlet.py +358 -0
- sourcepack-1.10.0a0/tests/test_github_action.py +262 -0
- sourcepack-1.10.0a0/tests/test_golden_demo.py +39 -0
- sourcepack-1.10.0a0/tests/test_local_policy.py +24 -0
- sourcepack-1.10.0a0/tests/test_policy_integration.py +57 -0
- sourcepack-1.10.0a0/tests/test_readme_truth.py +65 -0
- sourcepack-1.10.0a0/tests/test_real_corpus_validation.py +586 -0
- sourcepack-1.10.0a0/tests/test_reason_code_docs.py +33 -0
- sourcepack-1.10.0a0/tests/test_release_docs.py +67 -0
- sourcepack-1.10.0a0/tests/test_report_ui.py +16 -0
- sourcepack-1.10.0a0/tests/test_simulation_harness.py +356 -0
- sourcepack-1.10.0a0/tests/test_smoke.py +1022 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SourcePack contributors
|
|
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,311 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sourcepack
|
|
3
|
+
Version: 1.10.0a0
|
|
4
|
+
Summary: Local-first guardrail for unsupported AI repository assumptions before commit.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Keywords: ai,git,developer-tools,guardrails,local-first
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
<img width="1800" height="620" alt="sourcepack-hero" src="https://github.com/user-attachments/assets/9b4af0df-1cfc-4aa8-8eb1-f673e6eb2e52" />
|
|
19
|
+
|
|
20
|
+
AI coding tools can edit files, add imports, invent commands, or assume project structure that is not actually present. SourcePack checks AI-generated repo changes against trusted local repo evidence before commit.
|
|
21
|
+
|
|
22
|
+
## Badges
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
## Quick demo
|
|
28
|
+
|
|
29
|
+
A small RED case: an AI change imports `fastapi`, but the repository does not declare `fastapi` in its dependency files.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
$ sourcepack init . --auto
|
|
33
|
+
$ printf 'from fastapi import FastAPI\n' > app.py
|
|
34
|
+
$ git add app.py
|
|
35
|
+
$ git commit -m "add API"
|
|
36
|
+
RED LIGHT: commit blocked
|
|
37
|
+
unsupported_dependency: app.py imports fastapi, but fastapi is not declared.
|
|
38
|
+
|
|
39
|
+
Fix:
|
|
40
|
+
- add fastapi intentionally to pyproject.toml
|
|
41
|
+
- or remove the import
|
|
42
|
+
- run sourcepack report open for details
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Then inspect the human report:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
sourcepack report open
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Product screenshot section
|
|
52
|
+
|
|
53
|
+
Screenshot assets are generated from deterministic golden demo outputs and should be committed at these paths when refreshed:
|
|
54
|
+
|
|
55
|
+
- `docs/assets/sourcepack-terminal-red.png` — terminal output from `fail-unsupported-dependency`.
|
|
56
|
+
- `docs/assets/sourcepack-red-report.png` — HTML report from `fail-unsupported-dependency`.
|
|
57
|
+
- `docs/assets/sourcepack-warn-report.png` — HTML report from `warn-new-file`.
|
|
58
|
+
- `docs/assets/sourcepack-pass-report.png` — HTML report from `pass-clean`.
|
|
59
|
+
|
|
60
|
+
See [`docs/assets/README.md`](docs/assets/README.md) for exact capture instructions. If these image files are absent, the paths above are expected screenshot targets, not claimed live screenshots.
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
Current local editable install:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
python -m pip install -e .
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
SourcePack is not documented here as a published PyPI package. Planned package install commands such as `pipx install sourcepack`, `uv tool install sourcepack`, or `pip install sourcepack` should only be advertised after publication is true from release metadata.
|
|
71
|
+
|
|
72
|
+
## Quick start
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
sourcepack init . --auto
|
|
76
|
+
# make or receive AI changes
|
|
77
|
+
sourcepack diff .
|
|
78
|
+
sourcepack report open
|
|
79
|
+
# if accepted, continue with normal git commit
|
|
80
|
+
git commit -m "your change"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Local policy:
|
|
84
|
+
|
|
85
|
+
- PASS exits `0`.
|
|
86
|
+
- WARN exits `0` locally.
|
|
87
|
+
- WARN exits nonzero with `--strict` or `--ci`.
|
|
88
|
+
- FAIL exits nonzero.
|
|
89
|
+
|
|
90
|
+
## How SourcePack works
|
|
91
|
+
|
|
92
|
+
SourcePack keeps trusted repo evidence separate from AI guidance:
|
|
93
|
+
|
|
94
|
+
- Baseline = the last trusted repo state.
|
|
95
|
+
- Prompt context = AI guidance only.
|
|
96
|
+
- Prompt context never becomes trust.
|
|
97
|
+
- `sourcepack diff` checks actual repo changes against the baseline.
|
|
98
|
+
|
|
99
|
+
Without baseline/prompt separation:
|
|
100
|
+
|
|
101
|
+
- AI prompt context says `deploy.sh` exists and uses port `8080`.
|
|
102
|
+
- That claim gets treated as trusted evidence.
|
|
103
|
+
- AI edits against a fake deploy script.
|
|
104
|
+
- The guardrail launders an AI claim into repo truth.
|
|
105
|
+
|
|
106
|
+
With SourcePack:
|
|
107
|
+
|
|
108
|
+
- Prompt context is only guidance.
|
|
109
|
+
- `.sourcepack/baseline/` is enforcement trust.
|
|
110
|
+
- If `deploy.sh` is not in the trusted baseline, the edit fails.
|
|
111
|
+
- AI-generated context cannot bless its own assumptions.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## Baseline lifecycle
|
|
115
|
+
|
|
116
|
+
SourcePack enforcement depends on a reviewed `.sourcepack/baseline/`, while `.sourcepack/prompt/` remains AI guidance only. CI should consume committed baseline state and must not create or update trusted baseline state automatically. See [`docs/baseline-lifecycle.md`](docs/baseline-lifecycle.md) for safe local and PR flows.
|
|
117
|
+
|
|
118
|
+
## Public-alpha readiness
|
|
119
|
+
|
|
120
|
+
Public-alpha readiness is tracked in [`docs/public-alpha-readiness.md`](docs/public-alpha-readiness.md). SourcePack is a local evidence guardrail; it does not prove code correctness, security, dependency safety, runtime success, semantic validity, external API truth, or user intent.
|
|
121
|
+
|
|
122
|
+
## What SourcePack catches
|
|
123
|
+
|
|
124
|
+
| Case | Local result | Reason code |
|
|
125
|
+
| --- | --- | --- |
|
|
126
|
+
| Missing/fake file edits | FAIL | `missing_file` |
|
|
127
|
+
| New file review | WARN | `new_file` |
|
|
128
|
+
| Deleted file review | WARN | `deleted_file` |
|
|
129
|
+
| Undeclared imports/dependencies | FAIL | `unsupported_dependency` |
|
|
130
|
+
| Same-patch dependency additions | WARN | `declared_dependency` |
|
|
131
|
+
| Unsupported commands | FAIL | `unsupported_command` |
|
|
132
|
+
| Unsupported ecosystems | WARN | `unsupported_ecosystem` |
|
|
133
|
+
| Protected `.sourcepack/` edits | FAIL | `protected_artifact` |
|
|
134
|
+
| `.git/` path edits | FAIL | `git_path_modification` |
|
|
135
|
+
| Unsafe paths | FAIL | `unsafe_path` |
|
|
136
|
+
| Binary diffs | WARN or FAIL for high-risk paths | `binary_diff` |
|
|
137
|
+
| Malformed diffs | FAIL | `malformed_diff` |
|
|
138
|
+
| Missing/stale/corrupt baseline | FAIL or WARN depending on state and mode | `baseline_missing`, `baseline_stale`, `baseline_corrupt` |
|
|
139
|
+
|
|
140
|
+
See [`docs/reason-codes.md`](docs/reason-codes.md) for reason-code behavior and fixes.
|
|
141
|
+
|
|
142
|
+
## What SourcePack does not claim
|
|
143
|
+
|
|
144
|
+
- Does not prove code correctness.
|
|
145
|
+
- Does not prove security.
|
|
146
|
+
- Does not replace tests.
|
|
147
|
+
- Does not understand full program semantics.
|
|
148
|
+
- Does not require cloud access.
|
|
149
|
+
- Does not upload repo contents.
|
|
150
|
+
|
|
151
|
+
## Commands
|
|
152
|
+
|
|
153
|
+
Documented user-facing commands that exist in the current CLI:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
sourcepack init . --auto
|
|
157
|
+
sourcepack diff .
|
|
158
|
+
sourcepack diff . --json
|
|
159
|
+
sourcepack diff . --strict
|
|
160
|
+
sourcepack diff . --ci
|
|
161
|
+
sourcepack prompt . "task" --copy
|
|
162
|
+
sourcepack baseline .
|
|
163
|
+
sourcepack baseline . --refresh
|
|
164
|
+
sourcepack report path
|
|
165
|
+
sourcepack report open
|
|
166
|
+
sourcepack status .
|
|
167
|
+
sourcepack exec -- pytest
|
|
168
|
+
sourcepack evidence list
|
|
169
|
+
sourcepack evidence show <entry-id>
|
|
170
|
+
sourcepack evidence clear
|
|
171
|
+
sourcepack doctor
|
|
172
|
+
sourcepack doctor --strict
|
|
173
|
+
sourcepack demo
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Hook management commands also exist for explicit maintenance:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
sourcepack install-hook .
|
|
180
|
+
sourcepack uninstall-hook .
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Local execution evidence
|
|
184
|
+
|
|
185
|
+
`sourcepack exec -- <command...>` runs a local command and records bounded evidence under `.sourcepack/evidence/ledger.jsonl`. Ledger entries store command metadata, exit code, stdout/stderr SHA-256 hashes, short excerpts, git head, dirty-worktree state before and after execution, duration, and a small environment summary. They do not store full logs by default and are local-only. Command output can still contain sensitive information, so review `.sourcepack/evidence/` before sharing it.
|
|
186
|
+
|
|
187
|
+
Use:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
sourcepack exec -- pytest
|
|
191
|
+
sourcepack evidence list
|
|
192
|
+
sourcepack evidence show <entry-id>
|
|
193
|
+
sourcepack evidence clear
|
|
194
|
+
sourcepack evidence export --json
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Execution evidence only supports bounded claims that a command was run locally. It does not prove code correctness, security, or external API behavior. Prompt context in `.sourcepack/prompt/` remains advisory and cannot satisfy execution evidence.
|
|
198
|
+
|
|
199
|
+
## Local reports
|
|
200
|
+
|
|
201
|
+
`sourcepack diff .` writes local report artifacts under `.sourcepack/reports/`:
|
|
202
|
+
|
|
203
|
+
- `.sourcepack/reports/latest.html`
|
|
204
|
+
- `.sourcepack/reports/latest.json`
|
|
205
|
+
- `.sourcepack/reports/latest.md`
|
|
206
|
+
|
|
207
|
+
Use:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
sourcepack report path
|
|
211
|
+
sourcepack report open
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
HTML is for humans. JSON is for automation and remains JSON-only on stdout when `sourcepack diff . --json` is used.
|
|
215
|
+
|
|
216
|
+
## Git hooks
|
|
217
|
+
|
|
218
|
+
`sourcepack init . --auto` installs hooks when possible in a Git repository.
|
|
219
|
+
|
|
220
|
+
- The pre-commit hook checks staged changes with `sourcepack diff . --staged`.
|
|
221
|
+
- The post-commit hook refreshes the baseline only after clean commits.
|
|
222
|
+
- If the working tree is dirty after a commit, SourcePack marks the baseline stale instead of silently trusting it.
|
|
223
|
+
- To uninstall hooks, run `sourcepack uninstall-hook .`.
|
|
224
|
+
|
|
225
|
+
## CI
|
|
226
|
+
|
|
227
|
+
The included GitHub Actions workflow installs SourcePack in editable mode, runs unit and pytest gates, runs the behavior matrix, and checks `sourcepack doctor` plus `sourcepack demo`.
|
|
228
|
+
|
|
229
|
+
Safe CI usage for projects that intentionally manage a trusted baseline:
|
|
230
|
+
|
|
231
|
+
```yaml
|
|
232
|
+
- uses: actions/checkout@v4
|
|
233
|
+
- run: python -m pip install -e .
|
|
234
|
+
- run: sourcepack diff . --ci
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`sourcepack diff . --ci` implies strict JSON output and exits nonzero for WARN or FAIL. CI must not establish trust automatically: if no trusted baseline exists, CI fails until a baseline strategy is intentionally created outside CI.
|
|
238
|
+
|
|
239
|
+
## Validation
|
|
240
|
+
|
|
241
|
+
Current validation is local and deterministic. `sourcepack doctor --strict` performs a production-readiness health check and fails on missing runtime prerequisites or packaged assets:
|
|
242
|
+
|
|
243
|
+
- Hosted GitHub Actions workflow is the source of truth for hosted checks.
|
|
244
|
+
- The behavior matrix covers canonical repo-state transitions.
|
|
245
|
+
- The simulation harness validates local workflow transitions.
|
|
246
|
+
- Gauntlet and smoke tests cover CLI and report behavior.
|
|
247
|
+
- The optional real-corpus harness is available in `tools/real_corpus_validation.py` for caller-provided repositories.
|
|
248
|
+
|
|
249
|
+
The primary proof unit is a repo-state transition, not a random repository.
|
|
250
|
+
|
|
251
|
+
## Status
|
|
252
|
+
|
|
253
|
+
v1.10.0-alpha: local-first alpha. Core judgment behavior is validated. Packaging, reports, demos, and UX polish are active areas.
|
|
254
|
+
|
|
255
|
+
## Public-alpha checklist
|
|
256
|
+
|
|
257
|
+
Before public alpha, verify:
|
|
258
|
+
|
|
259
|
+
- Install works from a clean environment.
|
|
260
|
+
- `sourcepack --version` works.
|
|
261
|
+
- `sourcepack doctor` works.
|
|
262
|
+
- `sourcepack demo` works.
|
|
263
|
+
- `sourcepack init . --auto` works.
|
|
264
|
+
- `sourcepack diff .` works.
|
|
265
|
+
- `sourcepack report open` or `sourcepack report path` works.
|
|
266
|
+
- Behavior matrix passes.
|
|
267
|
+
- Golden demos pass.
|
|
268
|
+
- Known limitations are documented.
|
|
269
|
+
- Do not claim PyPI publication unless SourcePack is actually published there.
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
## CI and editor planning
|
|
273
|
+
|
|
274
|
+
See `docs/ci.md` for CI usage and `docs/vscode-extension-plan.md` for the VS Code extension plan.
|
|
275
|
+
|
|
276
|
+
## GitHub Action
|
|
277
|
+
|
|
278
|
+
SourcePack includes a composite GitHub Action that runs the existing `sourcepack` CLI in CI. It packages the CLI behavior; it does not create a second implementation of SourcePack judgment logic.
|
|
279
|
+
|
|
280
|
+
Minimal workflow:
|
|
281
|
+
|
|
282
|
+
```yaml
|
|
283
|
+
name: SourcePack
|
|
284
|
+
|
|
285
|
+
on:
|
|
286
|
+
pull_request:
|
|
287
|
+
|
|
288
|
+
jobs:
|
|
289
|
+
sourcepack:
|
|
290
|
+
runs-on: ubuntu-latest
|
|
291
|
+
steps:
|
|
292
|
+
- uses: actions/checkout@v4
|
|
293
|
+
- uses: ./
|
|
294
|
+
with:
|
|
295
|
+
mode: ci
|
|
296
|
+
# fail-on-warn: 'true'
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Baseline trust rule: CI consumes `.sourcepack/baseline/`. CI does not create, refresh, bless, or update trusted baseline state automatically. If the baseline is missing, the Action fails closed with `SourcePack baseline not found` and explains that CI will not create or update trusted baseline state automatically. Maintainers should create or refresh baselines locally or in a separate trusted maintainer-controlled setup workflow before relying on PR checks.
|
|
300
|
+
|
|
301
|
+
The Action writes report artifacts to `sourcepack-report` by default, including `sourcepack.json`, `sourcepack.md`, `sourcepack.stderr.txt`, `sourcepack.stdout.txt`, and `sourcepack-command.txt` when available. `RED`/`FAIL` exits nonzero. `WARN` follows the selected CLI mode: `ci` and `strict` fail on WARN, while `local` does not unless `fail-on-warn: 'true'` is set.
|
|
302
|
+
|
|
303
|
+
Before pushing, run SourcePack locally with:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
sourcepack --version
|
|
307
|
+
sourcepack doctor
|
|
308
|
+
sourcepack diff . --json
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Current limitations: PR commenting is future work and is not implemented by this Action. Unsupported ecosystems remain YELLOW/WARN unless SourcePack core supports them.
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<img width="1800" height="620" alt="sourcepack-hero" src="https://github.com/user-attachments/assets/9b4af0df-1cfc-4aa8-8eb1-f673e6eb2e52" />
|
|
2
|
+
|
|
3
|
+
AI coding tools can edit files, add imports, invent commands, or assume project structure that is not actually present. SourcePack checks AI-generated repo changes against trusted local repo evidence before commit.
|
|
4
|
+
|
|
5
|
+
## Badges
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## Quick demo
|
|
11
|
+
|
|
12
|
+
A small RED case: an AI change imports `fastapi`, but the repository does not declare `fastapi` in its dependency files.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
$ sourcepack init . --auto
|
|
16
|
+
$ printf 'from fastapi import FastAPI\n' > app.py
|
|
17
|
+
$ git add app.py
|
|
18
|
+
$ git commit -m "add API"
|
|
19
|
+
RED LIGHT: commit blocked
|
|
20
|
+
unsupported_dependency: app.py imports fastapi, but fastapi is not declared.
|
|
21
|
+
|
|
22
|
+
Fix:
|
|
23
|
+
- add fastapi intentionally to pyproject.toml
|
|
24
|
+
- or remove the import
|
|
25
|
+
- run sourcepack report open for details
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then inspect the human report:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
sourcepack report open
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Product screenshot section
|
|
35
|
+
|
|
36
|
+
Screenshot assets are generated from deterministic golden demo outputs and should be committed at these paths when refreshed:
|
|
37
|
+
|
|
38
|
+
- `docs/assets/sourcepack-terminal-red.png` — terminal output from `fail-unsupported-dependency`.
|
|
39
|
+
- `docs/assets/sourcepack-red-report.png` — HTML report from `fail-unsupported-dependency`.
|
|
40
|
+
- `docs/assets/sourcepack-warn-report.png` — HTML report from `warn-new-file`.
|
|
41
|
+
- `docs/assets/sourcepack-pass-report.png` — HTML report from `pass-clean`.
|
|
42
|
+
|
|
43
|
+
See [`docs/assets/README.md`](docs/assets/README.md) for exact capture instructions. If these image files are absent, the paths above are expected screenshot targets, not claimed live screenshots.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
Current local editable install:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python -m pip install -e .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
SourcePack is not documented here as a published PyPI package. Planned package install commands such as `pipx install sourcepack`, `uv tool install sourcepack`, or `pip install sourcepack` should only be advertised after publication is true from release metadata.
|
|
54
|
+
|
|
55
|
+
## Quick start
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
sourcepack init . --auto
|
|
59
|
+
# make or receive AI changes
|
|
60
|
+
sourcepack diff .
|
|
61
|
+
sourcepack report open
|
|
62
|
+
# if accepted, continue with normal git commit
|
|
63
|
+
git commit -m "your change"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Local policy:
|
|
67
|
+
|
|
68
|
+
- PASS exits `0`.
|
|
69
|
+
- WARN exits `0` locally.
|
|
70
|
+
- WARN exits nonzero with `--strict` or `--ci`.
|
|
71
|
+
- FAIL exits nonzero.
|
|
72
|
+
|
|
73
|
+
## How SourcePack works
|
|
74
|
+
|
|
75
|
+
SourcePack keeps trusted repo evidence separate from AI guidance:
|
|
76
|
+
|
|
77
|
+
- Baseline = the last trusted repo state.
|
|
78
|
+
- Prompt context = AI guidance only.
|
|
79
|
+
- Prompt context never becomes trust.
|
|
80
|
+
- `sourcepack diff` checks actual repo changes against the baseline.
|
|
81
|
+
|
|
82
|
+
Without baseline/prompt separation:
|
|
83
|
+
|
|
84
|
+
- AI prompt context says `deploy.sh` exists and uses port `8080`.
|
|
85
|
+
- That claim gets treated as trusted evidence.
|
|
86
|
+
- AI edits against a fake deploy script.
|
|
87
|
+
- The guardrail launders an AI claim into repo truth.
|
|
88
|
+
|
|
89
|
+
With SourcePack:
|
|
90
|
+
|
|
91
|
+
- Prompt context is only guidance.
|
|
92
|
+
- `.sourcepack/baseline/` is enforcement trust.
|
|
93
|
+
- If `deploy.sh` is not in the trusted baseline, the edit fails.
|
|
94
|
+
- AI-generated context cannot bless its own assumptions.
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## Baseline lifecycle
|
|
98
|
+
|
|
99
|
+
SourcePack enforcement depends on a reviewed `.sourcepack/baseline/`, while `.sourcepack/prompt/` remains AI guidance only. CI should consume committed baseline state and must not create or update trusted baseline state automatically. See [`docs/baseline-lifecycle.md`](docs/baseline-lifecycle.md) for safe local and PR flows.
|
|
100
|
+
|
|
101
|
+
## Public-alpha readiness
|
|
102
|
+
|
|
103
|
+
Public-alpha readiness is tracked in [`docs/public-alpha-readiness.md`](docs/public-alpha-readiness.md). SourcePack is a local evidence guardrail; it does not prove code correctness, security, dependency safety, runtime success, semantic validity, external API truth, or user intent.
|
|
104
|
+
|
|
105
|
+
## What SourcePack catches
|
|
106
|
+
|
|
107
|
+
| Case | Local result | Reason code |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| Missing/fake file edits | FAIL | `missing_file` |
|
|
110
|
+
| New file review | WARN | `new_file` |
|
|
111
|
+
| Deleted file review | WARN | `deleted_file` |
|
|
112
|
+
| Undeclared imports/dependencies | FAIL | `unsupported_dependency` |
|
|
113
|
+
| Same-patch dependency additions | WARN | `declared_dependency` |
|
|
114
|
+
| Unsupported commands | FAIL | `unsupported_command` |
|
|
115
|
+
| Unsupported ecosystems | WARN | `unsupported_ecosystem` |
|
|
116
|
+
| Protected `.sourcepack/` edits | FAIL | `protected_artifact` |
|
|
117
|
+
| `.git/` path edits | FAIL | `git_path_modification` |
|
|
118
|
+
| Unsafe paths | FAIL | `unsafe_path` |
|
|
119
|
+
| Binary diffs | WARN or FAIL for high-risk paths | `binary_diff` |
|
|
120
|
+
| Malformed diffs | FAIL | `malformed_diff` |
|
|
121
|
+
| Missing/stale/corrupt baseline | FAIL or WARN depending on state and mode | `baseline_missing`, `baseline_stale`, `baseline_corrupt` |
|
|
122
|
+
|
|
123
|
+
See [`docs/reason-codes.md`](docs/reason-codes.md) for reason-code behavior and fixes.
|
|
124
|
+
|
|
125
|
+
## What SourcePack does not claim
|
|
126
|
+
|
|
127
|
+
- Does not prove code correctness.
|
|
128
|
+
- Does not prove security.
|
|
129
|
+
- Does not replace tests.
|
|
130
|
+
- Does not understand full program semantics.
|
|
131
|
+
- Does not require cloud access.
|
|
132
|
+
- Does not upload repo contents.
|
|
133
|
+
|
|
134
|
+
## Commands
|
|
135
|
+
|
|
136
|
+
Documented user-facing commands that exist in the current CLI:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
sourcepack init . --auto
|
|
140
|
+
sourcepack diff .
|
|
141
|
+
sourcepack diff . --json
|
|
142
|
+
sourcepack diff . --strict
|
|
143
|
+
sourcepack diff . --ci
|
|
144
|
+
sourcepack prompt . "task" --copy
|
|
145
|
+
sourcepack baseline .
|
|
146
|
+
sourcepack baseline . --refresh
|
|
147
|
+
sourcepack report path
|
|
148
|
+
sourcepack report open
|
|
149
|
+
sourcepack status .
|
|
150
|
+
sourcepack exec -- pytest
|
|
151
|
+
sourcepack evidence list
|
|
152
|
+
sourcepack evidence show <entry-id>
|
|
153
|
+
sourcepack evidence clear
|
|
154
|
+
sourcepack doctor
|
|
155
|
+
sourcepack doctor --strict
|
|
156
|
+
sourcepack demo
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Hook management commands also exist for explicit maintenance:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
sourcepack install-hook .
|
|
163
|
+
sourcepack uninstall-hook .
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Local execution evidence
|
|
167
|
+
|
|
168
|
+
`sourcepack exec -- <command...>` runs a local command and records bounded evidence under `.sourcepack/evidence/ledger.jsonl`. Ledger entries store command metadata, exit code, stdout/stderr SHA-256 hashes, short excerpts, git head, dirty-worktree state before and after execution, duration, and a small environment summary. They do not store full logs by default and are local-only. Command output can still contain sensitive information, so review `.sourcepack/evidence/` before sharing it.
|
|
169
|
+
|
|
170
|
+
Use:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
sourcepack exec -- pytest
|
|
174
|
+
sourcepack evidence list
|
|
175
|
+
sourcepack evidence show <entry-id>
|
|
176
|
+
sourcepack evidence clear
|
|
177
|
+
sourcepack evidence export --json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Execution evidence only supports bounded claims that a command was run locally. It does not prove code correctness, security, or external API behavior. Prompt context in `.sourcepack/prompt/` remains advisory and cannot satisfy execution evidence.
|
|
181
|
+
|
|
182
|
+
## Local reports
|
|
183
|
+
|
|
184
|
+
`sourcepack diff .` writes local report artifacts under `.sourcepack/reports/`:
|
|
185
|
+
|
|
186
|
+
- `.sourcepack/reports/latest.html`
|
|
187
|
+
- `.sourcepack/reports/latest.json`
|
|
188
|
+
- `.sourcepack/reports/latest.md`
|
|
189
|
+
|
|
190
|
+
Use:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
sourcepack report path
|
|
194
|
+
sourcepack report open
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
HTML is for humans. JSON is for automation and remains JSON-only on stdout when `sourcepack diff . --json` is used.
|
|
198
|
+
|
|
199
|
+
## Git hooks
|
|
200
|
+
|
|
201
|
+
`sourcepack init . --auto` installs hooks when possible in a Git repository.
|
|
202
|
+
|
|
203
|
+
- The pre-commit hook checks staged changes with `sourcepack diff . --staged`.
|
|
204
|
+
- The post-commit hook refreshes the baseline only after clean commits.
|
|
205
|
+
- If the working tree is dirty after a commit, SourcePack marks the baseline stale instead of silently trusting it.
|
|
206
|
+
- To uninstall hooks, run `sourcepack uninstall-hook .`.
|
|
207
|
+
|
|
208
|
+
## CI
|
|
209
|
+
|
|
210
|
+
The included GitHub Actions workflow installs SourcePack in editable mode, runs unit and pytest gates, runs the behavior matrix, and checks `sourcepack doctor` plus `sourcepack demo`.
|
|
211
|
+
|
|
212
|
+
Safe CI usage for projects that intentionally manage a trusted baseline:
|
|
213
|
+
|
|
214
|
+
```yaml
|
|
215
|
+
- uses: actions/checkout@v4
|
|
216
|
+
- run: python -m pip install -e .
|
|
217
|
+
- run: sourcepack diff . --ci
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`sourcepack diff . --ci` implies strict JSON output and exits nonzero for WARN or FAIL. CI must not establish trust automatically: if no trusted baseline exists, CI fails until a baseline strategy is intentionally created outside CI.
|
|
221
|
+
|
|
222
|
+
## Validation
|
|
223
|
+
|
|
224
|
+
Current validation is local and deterministic. `sourcepack doctor --strict` performs a production-readiness health check and fails on missing runtime prerequisites or packaged assets:
|
|
225
|
+
|
|
226
|
+
- Hosted GitHub Actions workflow is the source of truth for hosted checks.
|
|
227
|
+
- The behavior matrix covers canonical repo-state transitions.
|
|
228
|
+
- The simulation harness validates local workflow transitions.
|
|
229
|
+
- Gauntlet and smoke tests cover CLI and report behavior.
|
|
230
|
+
- The optional real-corpus harness is available in `tools/real_corpus_validation.py` for caller-provided repositories.
|
|
231
|
+
|
|
232
|
+
The primary proof unit is a repo-state transition, not a random repository.
|
|
233
|
+
|
|
234
|
+
## Status
|
|
235
|
+
|
|
236
|
+
v1.10.0-alpha: local-first alpha. Core judgment behavior is validated. Packaging, reports, demos, and UX polish are active areas.
|
|
237
|
+
|
|
238
|
+
## Public-alpha checklist
|
|
239
|
+
|
|
240
|
+
Before public alpha, verify:
|
|
241
|
+
|
|
242
|
+
- Install works from a clean environment.
|
|
243
|
+
- `sourcepack --version` works.
|
|
244
|
+
- `sourcepack doctor` works.
|
|
245
|
+
- `sourcepack demo` works.
|
|
246
|
+
- `sourcepack init . --auto` works.
|
|
247
|
+
- `sourcepack diff .` works.
|
|
248
|
+
- `sourcepack report open` or `sourcepack report path` works.
|
|
249
|
+
- Behavior matrix passes.
|
|
250
|
+
- Golden demos pass.
|
|
251
|
+
- Known limitations are documented.
|
|
252
|
+
- Do not claim PyPI publication unless SourcePack is actually published there.
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
## CI and editor planning
|
|
256
|
+
|
|
257
|
+
See `docs/ci.md` for CI usage and `docs/vscode-extension-plan.md` for the VS Code extension plan.
|
|
258
|
+
|
|
259
|
+
## GitHub Action
|
|
260
|
+
|
|
261
|
+
SourcePack includes a composite GitHub Action that runs the existing `sourcepack` CLI in CI. It packages the CLI behavior; it does not create a second implementation of SourcePack judgment logic.
|
|
262
|
+
|
|
263
|
+
Minimal workflow:
|
|
264
|
+
|
|
265
|
+
```yaml
|
|
266
|
+
name: SourcePack
|
|
267
|
+
|
|
268
|
+
on:
|
|
269
|
+
pull_request:
|
|
270
|
+
|
|
271
|
+
jobs:
|
|
272
|
+
sourcepack:
|
|
273
|
+
runs-on: ubuntu-latest
|
|
274
|
+
steps:
|
|
275
|
+
- uses: actions/checkout@v4
|
|
276
|
+
- uses: ./
|
|
277
|
+
with:
|
|
278
|
+
mode: ci
|
|
279
|
+
# fail-on-warn: 'true'
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Baseline trust rule: CI consumes `.sourcepack/baseline/`. CI does not create, refresh, bless, or update trusted baseline state automatically. If the baseline is missing, the Action fails closed with `SourcePack baseline not found` and explains that CI will not create or update trusted baseline state automatically. Maintainers should create or refresh baselines locally or in a separate trusted maintainer-controlled setup workflow before relying on PR checks.
|
|
283
|
+
|
|
284
|
+
The Action writes report artifacts to `sourcepack-report` by default, including `sourcepack.json`, `sourcepack.md`, `sourcepack.stderr.txt`, `sourcepack.stdout.txt`, and `sourcepack-command.txt` when available. `RED`/`FAIL` exits nonzero. `WARN` follows the selected CLI mode: `ci` and `strict` fail on WARN, while `local` does not unless `fail-on-warn: 'true'` is set.
|
|
285
|
+
|
|
286
|
+
Before pushing, run SourcePack locally with:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
sourcepack --version
|
|
290
|
+
sourcepack doctor
|
|
291
|
+
sourcepack diff . --json
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Current limitations: PR commenting is future work and is not implemented by this Action. Unsupported ecosystems remain YELLOW/WARN unless SourcePack core supports them.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sourcepack"
|
|
7
|
+
version = "1.10.0a0"
|
|
8
|
+
description = "Local-first guardrail for unsupported AI repository assumptions before commit."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
keywords = ["ai", "git", "developer-tools", "guardrails", "local-first"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
sourcepack = "sourcepack.cli:main"
|
|
25
|
+
[tool.setuptools.package-data]
|
|
26
|
+
sourcepack = ["assets/*.md"]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
__version__ = "1.10.0a0"
|
|
7
|
+
|
|
8
|
+
# Keep subprocess-based development/test invocations runnable from temporary
|
|
9
|
+
# repositories before the package is installed. Installed packages do not need
|
|
10
|
+
# this, but local `python -m sourcepack.cli` smoke tests spawned from another
|
|
11
|
+
# cwd do.
|
|
12
|
+
_src_root = str(Path(__file__).resolve().parents[1])
|
|
13
|
+
_pythonpath = os.environ.get("PYTHONPATH")
|
|
14
|
+
if _pythonpath:
|
|
15
|
+
_parts = _pythonpath.split(os.pathsep)
|
|
16
|
+
if _src_root not in _parts:
|
|
17
|
+
os.environ["PYTHONPATH"] = os.pathsep.join([_src_root, *_parts])
|
|
18
|
+
else:
|
|
19
|
+
os.environ["PYTHONPATH"] = _src_root
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Packaged SourcePack markdown assets."""
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# SourcePack Audit Template
|
|
2
|
+
|
|
3
|
+
Review the AI answer against the packet manifest and packet contents. Identify supported references, missing references, unsupported dependency claims, unsupported command claims, and unsupported capability claims. Do not claim semantic truth verification unless deterministic packet evidence supports it.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# SourcePack Packet Instructions
|
|
2
|
+
|
|
3
|
+
Use only the supplied SourcePack packet as source material. Cite file paths when making claims. Do not infer files, commands, dependencies, services, or capabilities that are not present in the packet. If evidence is missing, say NOT FOUND or UNCERTAIN.
|