phases-oss 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 (67) hide show
  1. phases_oss-0.1.0/LICENSE +201 -0
  2. phases_oss-0.1.0/NOTICE +12 -0
  3. phases_oss-0.1.0/PKG-INFO +316 -0
  4. phases_oss-0.1.0/README.md +296 -0
  5. phases_oss-0.1.0/pyproject.toml +33 -0
  6. phases_oss-0.1.0/setup.cfg +4 -0
  7. phases_oss-0.1.0/src/phases_oss/__init__.py +18 -0
  8. phases_oss-0.1.0/src/phases_oss/audit/__init__.py +33 -0
  9. phases_oss-0.1.0/src/phases_oss/audit/cli.py +121 -0
  10. phases_oss-0.1.0/src/phases_oss/audit/guard.py +284 -0
  11. phases_oss-0.1.0/src/phases_oss/audit/overlay.py +168 -0
  12. phases_oss-0.1.0/src/phases_oss/audit/registry.py +300 -0
  13. phases_oss-0.1.0/src/phases_oss/audit/router.py +249 -0
  14. phases_oss-0.1.0/src/phases_oss/audit/runner.py +316 -0
  15. phases_oss-0.1.0/src/phases_oss/audit/runstate.py +297 -0
  16. phases_oss-0.1.0/src/phases_oss/audit/sarif.py +286 -0
  17. phases_oss-0.1.0/src/phases_oss/audit/tools.py +254 -0
  18. phases_oss-0.1.0/src/phases_oss/data_gate.py +237 -0
  19. phases_oss-0.1.0/src/phases_oss/events.py +103 -0
  20. phases_oss-0.1.0/src/phases_oss/hooks/__init__.py +10 -0
  21. phases_oss-0.1.0/src/phases_oss/hooks/common.py +109 -0
  22. phases_oss-0.1.0/src/phases_oss/hooks/pre_tool_use.py +229 -0
  23. phases_oss-0.1.0/src/phases_oss/hooks/stop.py +59 -0
  24. phases_oss-0.1.0/src/phases_oss/hooks/user_prompt_submit.py +104 -0
  25. phases_oss-0.1.0/src/phases_oss/install.py +185 -0
  26. phases_oss-0.1.0/src/phases_oss/multidim/__init__.py +21 -0
  27. phases_oss-0.1.0/src/phases_oss/multidim/__main__.py +20 -0
  28. phases_oss-0.1.0/src/phases_oss/multidim/base_contexts.py +196 -0
  29. phases_oss-0.1.0/src/phases_oss/multidim/client.py +238 -0
  30. phases_oss-0.1.0/src/phases_oss/multidim/frames.py +447 -0
  31. phases_oss-0.1.0/src/phases_oss/multidim/paths.py +101 -0
  32. phases_oss-0.1.0/src/phases_oss/multidim/server.py +745 -0
  33. phases_oss-0.1.0/src/phases_oss/multidim/store.py +532 -0
  34. phases_oss-0.1.0/src/phases_oss/multidim/validate.py +456 -0
  35. phases_oss-0.1.0/src/phases_oss/phases.py +1133 -0
  36. phases_oss-0.1.0/src/phases_oss/reviewers/__init__.py +22 -0
  37. phases_oss-0.1.0/src/phases_oss/reviewers/base.py +57 -0
  38. phases_oss-0.1.0/src/phases_oss/reviewers/cloud.py +161 -0
  39. phases_oss-0.1.0/src/phases_oss/reviewers/local.py +140 -0
  40. phases_oss-0.1.0/src/phases_oss.egg-info/PKG-INFO +316 -0
  41. phases_oss-0.1.0/src/phases_oss.egg-info/SOURCES.txt +65 -0
  42. phases_oss-0.1.0/src/phases_oss.egg-info/dependency_links.txt +1 -0
  43. phases_oss-0.1.0/src/phases_oss.egg-info/entry_points.txt +4 -0
  44. phases_oss-0.1.0/src/phases_oss.egg-info/top_level.txt +1 -0
  45. phases_oss-0.1.0/tests/test_audit_fixtures.py +114 -0
  46. phases_oss-0.1.0/tests/test_audit_pipeline.py +624 -0
  47. phases_oss-0.1.0/tests/test_data_gate.py +205 -0
  48. phases_oss-0.1.0/tests/test_data_gate_env_secrets.py +85 -0
  49. phases_oss-0.1.0/tests/test_examples.py +47 -0
  50. phases_oss-0.1.0/tests/test_flow_order.py +187 -0
  51. phases_oss-0.1.0/tests/test_hooks.py +453 -0
  52. phases_oss-0.1.0/tests/test_install.py +185 -0
  53. phases_oss-0.1.0/tests/test_integration_real.py +160 -0
  54. phases_oss-0.1.0/tests/test_multidim_client.py +246 -0
  55. phases_oss-0.1.0/tests/test_multidim_robustness.py +550 -0
  56. phases_oss-0.1.0/tests/test_multidim_server.py +277 -0
  57. phases_oss-0.1.0/tests/test_multidim_store.py +279 -0
  58. phases_oss-0.1.0/tests/test_multidim_v2.py +668 -0
  59. phases_oss-0.1.0/tests/test_multidim_v2_e2e.py +296 -0
  60. phases_oss-0.1.0/tests/test_package_safety.py +208 -0
  61. phases_oss-0.1.0/tests/test_phases.py +697 -0
  62. phases_oss-0.1.0/tests/test_regressions_high.py +213 -0
  63. phases_oss-0.1.0/tests/test_reviewer_cloud.py +245 -0
  64. phases_oss-0.1.0/tests/test_reviewer_local.py +117 -0
  65. phases_oss-0.1.0/tests/test_smoke.py +32 -0
  66. phases_oss-0.1.0/tests/test_staleness.py +107 -0
  67. phases_oss-0.1.0/tests/test_verdicts_strict.py +171 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 phases-oss contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,12 @@
1
+ phases-oss
2
+ Copyright 2026 S. Cherrid
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -0,0 +1,316 @@
1
+ Metadata-Version: 2.4
2
+ Name: phases-oss
3
+ Version: 0.1.0
4
+ Summary: A phase-based workflow runner for AI coding agents: bounded phases, deterministic proofs, and a consultative reviewer. Pure Python standard library, zero dependencies.
5
+ Author: S. Cherrid
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Cherridsaid/phases-oss
8
+ Project-URL: Issues, https://github.com/Cherridsaid/phases-oss/issues
9
+ Keywords: ai-agents,workflow,code-review,guardrails,llm
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development :: Quality Assurance
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ License-File: NOTICE
19
+ Dynamic: license-file
20
+
21
+ **English** · [Français](README.fr.md)
22
+
23
+ # phases-oss
24
+
25
+
26
+ ![phases-oss — guardrails for AI coding agents](docs/social.png)
27
+
28
+ A phase-based workflow runner for AI coding agents — bounded phases,
29
+ deterministic proofs, a consultative reviewer, and a bundled **Multidim**
30
+ analysis engine (structured, multi-axis analysis before you write code).
31
+ Pure Python standard library, **zero dependencies**.
32
+
33
+ `phases-oss` helps an agent (or a person) do risky work in small, verifiable
34
+ steps instead of one large, unaudited change.
35
+
36
+ ---
37
+
38
+ ## The idea
39
+
40
+ Break a task into **phases**. Each phase declares, up front:
41
+
42
+ | Field | Meaning |
43
+ |-------|---------|
44
+ | **objective** | one testable goal |
45
+ | **files_allowed** | the only files this phase may touch |
46
+ | **proof_command** | a reproducible command; exit code 0 = it works |
47
+ | **risk level** | `0`–`3`; normalizes the whole policy (see below) |
48
+
49
+ The **risk level** sets every gate at once (the legacy names `none` /
50
+ `review` / `security` / `critical` are still accepted as aliases for 0–3):
51
+
52
+ | Level | Proof | Review | Extra gates at close |
53
+ |-------|-------|--------|----------------------|
54
+ | **0** | targeted | none | — |
55
+ | **1** | standard | one independent review | — |
56
+ | **2** | **full test suite** (`--full-suite` required at init) | one strict review | full-suite declared |
57
+ | **3** | full test suite | one strict review | + runtime proof + **explicit human validation** (`human-approve`) |
58
+
59
+ A phase moves through explicit gates:
60
+
61
+ ```
62
+ init → approve → (write code) → prove → audit → [review] → [human-approve] → close
63
+ ```
64
+
65
+ * **prove** runs the proof command; its exit code is the single source of truth.
66
+ * **close** re-runs the proof against the *committed* tree (a throwaway git
67
+ worktree), so a green working copy can't be passed off as a green commit.
68
+ This independent verification runs when a commit sha is recorded
69
+ (`--commit-sha`); closing without one skips it — always pass the sha.
70
+ * a phase won't **close** until its proof passes, its audit is recorded, and
71
+ every level-specific gate above is satisfied.
72
+
73
+ State lives in `<repo>/.claude/phase-state.json`. Every transition appends a
74
+ **reconstructible v2 event** to `<repo>/.claude/phase-log.jsonl`: each line
75
+ carries `schema_version`, `event_id`, `phase_id`, `session_id`, `project_id`,
76
+ `review_id`/`finding_id` (null outside a review), a UTC timestamp, the
77
+ `event_type`, and a payload that snapshots the full state — the journal alone
78
+ can rebuild the phase. Both files are local-only (git-ignored).
79
+
80
+ ### Pre-phase analysis gate (optional, fail-closed)
81
+
82
+ A phase can require a structured pre-phase analysis (for example a
83
+ multi-dimensional analysis grid) before any code is written:
84
+
85
+ ```bash
86
+ python -m phases_oss.phases init ... --require-analysis \
87
+ --analysis-context code_audit --analysis-depth core \
88
+ --analysis-axes "surface,risques" \
89
+ --analysis-ref "artifact://analysis/md_0123456789abcdef01234567"
90
+ ```
91
+
92
+ The expected depth follows the level (`core` at 0–1, `deep` at 2, `full` at 3).
93
+ Missing or malformed metadata refuses `init`; a phase initialized with
94
+ `--require-analysis` refuses to **close** if the metadata is gone. The journal
95
+ records an `analysis.completed` event with the metadata and the artifact
96
+ reference only — the analysis text itself is never copied into the log.
97
+
98
+ ## Honest threat model — read this first
99
+
100
+ The local tooling here is a **discipline aid, not a security boundary.**
101
+
102
+ An agent and its reviewer run on the same machine with the same rights. No local
103
+ lock (a hook, a secret, a hash) can stop a determined process from editing the
104
+ state file and lifting every restriction. The hooks deliberately **fail open**
105
+ so they never wedge an unrelated session.
106
+
107
+ The real authority lives elsewhere:
108
+
109
+ - **deterministic tests** — exit code 0 or it didn't happen;
110
+ - **CI** with branch protection;
111
+ - **human review** before anything is merged or published.
112
+
113
+ Treat the static reviewer as a linter for process discipline, and the hooks as
114
+ guard rails that catch honest mistakes — not as a sandbox.
115
+
116
+ ### What this tool does and does not do
117
+
118
+ - **It reads local code, read-only.** Nothing here exploits anything, scans a
119
+ network, performs intrusion testing, or sends a request to a third-party
120
+ system.
121
+ - **It does not ship the skills.** It assumes a skill library already present on
122
+ your machine and resolves skill bodies *by reference*. Without that library,
123
+ the phases concerned report `missing_skill`. This is the limitation that
124
+ matters most on a fresh install.
125
+ - **Without a model-plane adapter wired in, the guided-review phases report
126
+ `degraded` / `model_plane_unavailable`.** The pipeline orchestrates; it does
127
+ not analyse. Read a full run as an ordered, traceable sequence — not as an
128
+ audit verdict.
129
+ - **CodeQL stays gated.** PHASE 22 remains in the sequence and reports
130
+ `skipped_license` until `--enable-codeql` confirms the terms. This is
131
+ deliberate.
132
+
133
+ ## Install
134
+
135
+ ```bash
136
+ git clone https://github.com/Cherridsaid/phases-oss
137
+ cd phases-oss && pip install -e .
138
+ ```
139
+
140
+ (Not on PyPI yet; install from a checkout.)
141
+
142
+ Wire the hooks into *one project* (never your global config):
143
+
144
+ ```bash
145
+ python -m phases_oss.install /path/to/your-project # dry-run, prints the plan
146
+ python -m phases_oss.install /path/to/your-project --apply # actually writes
147
+ ```
148
+
149
+ The installer writes exactly one file, `<project>/.claude/settings.json`, merges
150
+ non-destructively, and **refuses** to target your home directory or `~/.claude`.
151
+
152
+ ## Quickstart (the phase CLI)
153
+
154
+ ```bash
155
+ # 1. declare a phase
156
+ python -m phases_oss.phases init \
157
+ --objective "add a JSON parser" \
158
+ --files src/parser.py --files tests/test_parser.py \
159
+ --proof "python -m pytest tests/test_parser.py" \
160
+ --level 1
161
+
162
+ # 2. approve, then write code into files_allowed only
163
+ python -m phases_oss.phases approve
164
+
165
+ # 3. prove (exit code is authority)
166
+ python -m phases_oss.phases prove
167
+
168
+ # 4. record the audit, then close on a commit
169
+ python -m phases_oss.phases audit --report .claude/phase-reviews/r1.md
170
+ python -m phases_oss.phases close --lesson "parser handles trailing commas" --commit-sha "$(git rev-parse HEAD)"
171
+ ```
172
+
173
+ See [`examples/quickstart.md`](examples/quickstart.md) for a full walkthrough.
174
+
175
+ ## Reviewers
176
+
177
+ The audit step can call a **reviewer**:
178
+
179
+ - **`local`** (default) — a static, regex-based, fully offline linter. No model,
180
+ no network, **no LLM** anywhere in this path by construction. It flags
181
+ hardcoded secrets, debugger breakpoints, bare `except:`, `shell=True`,
182
+ `eval`/`exec`, and TODO markers. A `# phases-oss: allow` comment skips a
183
+ reviewed line.
184
+ - **`cloud`** (opt-in) — a thin shell that delegates to a **sender you wire
185
+ yourself**. With no sender it is inert (no network). When wired, every payload
186
+ is forced through a **data gate** first: the destination host must be on an
187
+ explicit allowlist (deny by default), and the payload is redacted (secrets,
188
+ tokens, emails, usernames in paths) with a disclosure attached.
189
+
190
+ The cloud reviewer **fails closed on unavailability**: an absent backend, an
191
+ unreachable sender, an empty reply or an unparseable reply all yield
192
+ `REVIEW_UNAVAILABLE` — never a PASS and never a silent skip. There are four
193
+ review verdicts: `PASS` (continue), `PASS_WITH_NOTES` (continue, findings
194
+ worth reading), `REFUS` (fix and re-review), `REVIEW_UNAVAILABLE` (the review
195
+ did not happen). Once a verdict is recorded on the phase, `close` is gated on
196
+ it: `REFUS` and `REVIEW_UNAVAILABLE` both refuse the close until a re-review
197
+ passes. Verdicts are a closed vocabulary parsed strictly — `VERDICT: PASSABLE`
198
+ or a stray occurrence of the word `VERDICT` approves nothing, and a new
199
+ `prove` invalidates every validation recorded against the previous tree.
200
+
201
+ ```python
202
+ from phases_oss.reviewers import get_reviewer
203
+ reviewer = get_reviewer("local") # default, offline
204
+ ```
205
+
206
+ ## Hooks
207
+
208
+ Three hooks port the gates into an agent harness (Claude Code-style
209
+ `hooks` in `settings.json`):
210
+
211
+ - **PreToolUse** — denies edits outside `files_allowed`, and Bash commands that
212
+ write a project file (git's own writes excepted).
213
+ - **Stop** — refuses to "finish" while a phase is still open (proof or audit
214
+ missing).
215
+ - **UserPromptSubmit** — approves on an exact `go phase`, and injects a
216
+ sanitized, *untrusted-marked* reminder of the active phase.
217
+
218
+ ## Multidim (bundled analysis)
219
+
220
+ ![Multidim — structured analysis before you write a line](docs/multidim.png)
221
+
222
+ phases-oss ships **Multidim**, a small analysis engine that turns a subject into
223
+ a hierarchical grid (axes → sub-lenses) for a caller to fill in, then checks the
224
+ filled analysis deterministically. The thinking stays with the caller; Multidim
225
+ provides structure, not cognition. It runs as its own stdio MCP server and has
226
+ its own dedicated store — it is never fused into the phase engine.
227
+
228
+ It exposes four tools:
229
+
230
+ - **`multidim_analyze`** — build the grid for a subject. `format: "text"` (a v1
231
+ grid) or `format: "v2"` (a deterministic JSON frame with a `frame_hash`,
232
+ required sections, validation rules and any learned traps).
233
+ - **`multidim_validate`** — deterministic, stateless check of a filled v2
234
+ analysis against its frame; returns an `ACCEPT` / `WARNING` / `REJECT` verdict
235
+ per section. Never mutates the store, judges structure and internal
236
+ consistency only.
237
+ - **`multidim_contexts`** — list the known analysis contexts.
238
+ - **`multidim_learn`** — create or enrich a context (the only write door).
239
+
240
+ Run the server directly (MCP clients spawn it this way):
241
+
242
+ ```bash
243
+ python -m phases_oss.multidim # or the console script: phases-multidim
244
+ ```
245
+
246
+ Or let the phase engine produce an analysis for a phase, with no external MCP:
247
+
248
+ ```bash
249
+ phases prepare-analysis --subject "what you are about to change" --level 2
250
+ # prints context / depth / axes / analysis-ref to feed:
251
+ phases init --require-analysis --analysis-context ... --analysis-depth ... \
252
+ --analysis-axes ... --analysis-ref artifact://multidim/<id> ...
253
+ ```
254
+
255
+ The store lives on a dedicated per-platform data dir (never `~/.multidim`), with
256
+ atomic writes, a cross-process lock, and a neutral base library. A private
257
+ denylist for the neutrality guard can be supplied out-of-band via
258
+ `PHASES_OSS_EXTRA_FORBIDDEN` (comma-separated), never committed to source.
259
+
260
+ ## Audit pipeline (71 phases, one skill each)
261
+
262
+ `phases-audit` walks a fixed sequence of 71 audit phases. **One skill, one
263
+ phase, always** — the order is frozen at import time, and a phase that does not
264
+ apply is still *visited*: it gets a terminal status and a typed reason, and the
265
+ sequence moves to `ordinal + 1`. Nothing is ever dropped.
266
+
267
+ ```bash
268
+ phases-audit pipeline # the frozen PHASE N -> skill mapping
269
+ phases-audit tools # which local scanners are installed
270
+ phases-audit run --target ../some-repo # visit all 71 phases
271
+ phases-audit resume run_<id> # continue at the interrupted ordinal
272
+ ```
273
+
274
+ Each phase runs inside a throwaway stage exposing exactly one `SKILL.md`, with
275
+ `HOME` repointed at that stage; the stage is destroyed before the next phase
276
+ begins. Skill bodies are resolved *by reference* to your local roots — none is
277
+ vendored here.
278
+
279
+ Statuses: `completed`, `not_applicable`, `degraded`, `failed`, `skipped_license`,
280
+ `skipped_offline`, `missing_skill`. Reasons come from a closed vocabulary
281
+ (`policy_static_only`, `tool_absent`, `signal_absent:<name>`, …) so they can be
282
+ tested rather than merely read.
283
+
284
+ Defaults, and their honest limits:
285
+
286
+ * **static_only** — the target's own code is not executed. Pass
287
+ `--allow-local-test-execution` to run it inside an ephemeral copy.
288
+ * **CodeQL is gated** — PHASE 22 stays in the sequence but reports
289
+ `skipped_license` until `--enable-codeql` confirms the terms.
290
+ * **No downloads** — commands carry no update/registry flags, and semgrep
291
+ refuses `--config auto`; with no local rule pack the phase reports
292
+ `tool_absent` instead of going online.
293
+ * **Secrets are stripped** — provider and registry credentials are removed from
294
+ every execution-plane environment.
295
+ * **The target is read-only** — fingerprinted before and after; a mutation is a
296
+ hard failure.
297
+ * **Network isolation is `advisory`, not enforced.** Proxy variables point at a
298
+ closed port, which stops well-behaved HTTP clients. There is no per-process
299
+ network namespace here, so a raw socket is *not* blocked. The run says
300
+ `advisory`; it never claims to be offline.
301
+ * **Missing skill bodies are reported, never substituted** (`missing_skill`).
302
+
303
+ Nothing in this pipeline publishes: `open-source-readiness` and
304
+ `release-readiness` return a verdict and stop. No remote, no push, no release.
305
+
306
+ ## Development
307
+
308
+ ```bash
309
+ python run_tests.py # standard-library unittest, exit 0 = green
310
+ ```
311
+
312
+ No dependencies, no build step. Python 3.9+ (the version range the CI proves).
313
+
314
+ ## License
315
+
316
+ Apache-2.0. See [LICENSE](LICENSE).