flowharness 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 (51) hide show
  1. flowharness-0.1.0/LICENSE +202 -0
  2. flowharness-0.1.0/PKG-INFO +197 -0
  3. flowharness-0.1.0/README.md +179 -0
  4. flowharness-0.1.0/pyproject.toml +44 -0
  5. flowharness-0.1.0/pyproject.toml.orig +50 -0
  6. flowharness-0.1.0/src/flowharness_scan/__init__.py +35 -0
  7. flowharness-0.1.0/src/flowharness_scan/_files.py +21 -0
  8. flowharness-0.1.0/src/flowharness_scan/attest.py +122 -0
  9. flowharness-0.1.0/src/flowharness_scan/cli.py +440 -0
  10. flowharness-0.1.0/src/flowharness_scan/compile/__init__.py +462 -0
  11. flowharness-0.1.0/src/flowharness_scan/compile/ci_format.py +63 -0
  12. flowharness-0.1.0/src/flowharness_scan/compile/config.py +108 -0
  13. flowharness-0.1.0/src/flowharness_scan/compile/fidelity_report.py +408 -0
  14. flowharness-0.1.0/src/flowharness_scan/compile/merge.py +63 -0
  15. flowharness-0.1.0/src/flowharness_scan/compile/source.py +226 -0
  16. flowharness-0.1.0/src/flowharness_scan/compile/writer.py +432 -0
  17. flowharness-0.1.0/src/flowharness_scan/conformance/__init__.py +136 -0
  18. flowharness-0.1.0/src/flowharness_scan/conformance/families.py +381 -0
  19. flowharness-0.1.0/src/flowharness_scan/flowharness_toml.py +155 -0
  20. flowharness-0.1.0/src/flowharness_scan/guarded_read.py +105 -0
  21. flowharness-0.1.0/src/flowharness_scan/infrastructure/__init__.py +2 -0
  22. flowharness-0.1.0/src/flowharness_scan/infrastructure/httpx_client.py +164 -0
  23. flowharness-0.1.0/src/flowharness_scan/init/__init__.py +179 -0
  24. flowharness-0.1.0/src/flowharness_scan/init/detect.py +91 -0
  25. flowharness-0.1.0/src/flowharness_scan/init/execute.py +96 -0
  26. flowharness-0.1.0/src/flowharness_scan/init/plan.py +212 -0
  27. flowharness-0.1.0/src/flowharness_scan/init/report.py +71 -0
  28. flowharness-0.1.0/src/flowharness_scan/init/templates.py +95 -0
  29. flowharness-0.1.0/src/flowharness_scan/py.typed +0 -0
  30. flowharness-0.1.0/src/flowharness_scan/remote/__init__.py +350 -0
  31. flowharness-0.1.0/src/flowharness_scan/remote/apply/__init__.py +71 -0
  32. flowharness-0.1.0/src/flowharness_scan/remote/apply/engine.py +111 -0
  33. flowharness-0.1.0/src/flowharness_scan/remote/apply/errors.py +24 -0
  34. flowharness-0.1.0/src/flowharness_scan/remote/apply/fs.py +231 -0
  35. flowharness-0.1.0/src/flowharness_scan/remote/apply/lockfile.py +227 -0
  36. flowharness-0.1.0/src/flowharness_scan/remote/apply/pathsafe.py +56 -0
  37. flowharness-0.1.0/src/flowharness_scan/remote/apply/plan.py +198 -0
  38. flowharness-0.1.0/src/flowharness_scan/remote/base_url.py +65 -0
  39. flowharness-0.1.0/src/flowharness_scan/remote/cache.py +73 -0
  40. flowharness-0.1.0/src/flowharness_scan/remote/dto.py +118 -0
  41. flowharness-0.1.0/src/flowharness_scan/remote/errors.py +79 -0
  42. flowharness-0.1.0/src/flowharness_scan/remote/ports.py +79 -0
  43. flowharness-0.1.0/src/flowharness_scan/remote/service.py +117 -0
  44. flowharness-0.1.0/src/flowharness_scan/remote/signing.py +25 -0
  45. flowharness-0.1.0/src/flowharness_scan/status/__init__.py +400 -0
  46. flowharness-0.1.0/src/flowharness_scan/status/applied_state.py +263 -0
  47. flowharness-0.1.0/src/flowharness_scan/status/banner.py +265 -0
  48. flowharness-0.1.0/src/flowharness_scan/status/channel_probe.py +285 -0
  49. flowharness-0.1.0/src/flowharness_scan/status/report.py +150 -0
  50. flowharness-0.1.0/src/flowharness_scan/verify/__init__.py +270 -0
  51. flowharness-0.1.0/src/flowharness_scan/verify/_report_io.py +69 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: flowharness
3
+ Version: 0.1.0
4
+ Summary: Architectural Drift Index and risk scan over a repo's agent-rules surface — local, deterministic, zero network
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Requires-Dist: flowharness-core==0.1.0
11
+ Requires-Dist: flowharness-inspection==0.1.0
12
+ Requires-Dist: flowharness-portability==0.1.0
13
+ Requires-Dist: httpx>=0.27 ; extra == 'remote'
14
+ Requires-Python: >=3.12
15
+ Project-URL: Homepage, https://github.com/flowharness-ai
16
+ Provides-Extra: remote
17
+ Description-Content-Type: text/markdown
18
+
19
+ <div align="center">
20
+
21
+ # flowharness (flowharness-scan console script)
22
+
23
+ <img src="assets/badge-example.svg" alt="flowharness drift badge" height="22" />
24
+
25
+ **The Architectural Drift Index + Vibe-Risk scan for your repo's agent-rules surface.**
26
+
27
+ Local · static · deterministic · zero network · zero model calls · zero config.
28
+
29
+ </div>
30
+
31
+ ---
32
+
33
+ `flowharness-scan` reads the agent-rules surface of a repository — `CLAUDE.md`,
34
+ `.cursorrules`, `.cursor/rules/*.mdc`, `AGENTS.md`, `.continue/**`, `.opencode/**`,
35
+ `playbook/**`, and an [agentharnesses](https://github.com/agentharnesses/agentharnesses)
36
+ bundle (`HARNESS.md` + `skills/**/SKILL.md` + routing/reference files) — and tells you
37
+ two things in one pass:
38
+
39
+ - **How messy** it is — the **Architectural Drift Index** (0–100): duplication,
40
+ contradictions, orphaned rules, and cross-harness divergence.
41
+ - **How dangerous** it is — a **quarantine verdict**: leaked secrets, indirect
42
+ prompt-injection, unattested/always-on guidance.
43
+
44
+ ## Quickstart
45
+
46
+ No install required:
47
+
48
+ ```console
49
+ $ uvx flowharness scan .
50
+ flowharness-scan: drift index 30/100 - QUARANTINE (policy scoring/1)
51
+ ```
52
+
53
+ `uvx flowharness init` scaffolds a new repo's agent-rules surface the same way, with no
54
+ persistent install. `flowharness` and `flowharness-scan` are the same entry point (see below);
55
+ `uvx --from flowharness flowharness-scan .` also works if you prefer the explicit name.
56
+
57
+ > **Note:** these packages currently install top-level modules named `core`, `inspection`,
58
+ > `evaluation`, and `portability`. Prefer `uvx` (isolated environments) over `pip install`
59
+ > into a shared venv until the 0.2 module-namespace rename lands.
60
+
61
+ Exit codes wire straight into CI / pre-commit: **PASS = 0 · NEEDS_HUMAN = 1 · FAIL = 2.**
62
+
63
+ ## Output modes
64
+
65
+ ```console
66
+ $ flowharness-scan . # terminal banner (default)
67
+ $ flowharness-scan . --json # full inspection/v1 report (content-addressed)
68
+ $ flowharness-scan . --badge > drift.svg # local SVG badge for your README
69
+ ```
70
+
71
+ ## Gating
72
+
73
+ ```console
74
+ $ flowharness-scan . --fail-on risk # fail on the quarantine verdict (default)
75
+ $ flowharness-scan . --fail-on "index>40" # fail when the drift index exceeds 40
76
+ $ flowharness-scan . --policy scoring.toml # custom, versioned scoring weights
77
+ ```
78
+
79
+ ### Baseline (only fail on *new* drift)
80
+
81
+ ```console
82
+ $ flowharness-scan . --set-baseline > .flowharness-baseline.json # commit this once
83
+ $ flowharness-scan . --baseline .flowharness-baseline.json --fail-on baseline
84
+ ```
85
+
86
+ `--set-baseline` writes nothing into your repo — it prints the baseline to stdout, so
87
+ the scanner stays strictly read-only on the project directory.
88
+
89
+ ## Platform (opt-in network: `pull` / `upload`)
90
+
91
+ The default scan path is **strictly zero-network**. The `pull`/`upload` subcommands and
92
+ `scan --upload` are the *only* paths that touch the network (install the `[remote]` extra for the
93
+ `httpx` dependency). They authenticate with a scoped bearer token.
94
+
95
+ ```console
96
+ $ export FLOWHARNESS_API_URL=https://app.example.com # required (or pass --api-url)
97
+ $ export FLOWHARNESS_TOKEN=fht_... # the scoped bearer token
98
+
99
+ $ flowharness-scan pull <release_id> # fetch a release's pins -> offline cache
100
+ $ flowharness-scan . --upload --enrollment <id> # scan, then upload the InspectionRecord
101
+ $ flowharness-scan upload sync --enrollment <id> --release <id> --observed observed.json
102
+ $ flowharness-scan upload eval --run run.json # signs the report (X-Signature) + uploads
103
+ ```
104
+
105
+ Notes: a leading token that names a real directory is scanned, not treated as a subcommand
106
+ (`flowharness-scan ./pull` scans `./pull`). A remote `http://` URL is refused before any socket
107
+ opens. Non-2xx responses map to stable exit codes (10–16); a duplicate upload (`409`) is treated as
108
+ an idempotent success. `FLOWHARNESS_TOKEN` is the eval-signing HMAC key and is never written to disk.
109
+
110
+ ## `status` — am I running what the channel publishes?
111
+
112
+ `flowharness status` answers two questions in one line — *is the applied release the channel's
113
+ head?* and *has anyone edited the governed files?* — and it is **strictly read-only**: it writes
114
+ nothing in any mode, and under `--offline` it opens no socket and imports no `httpx` at all.
115
+
116
+ ```console
117
+ $ flowharness status
118
+ flowharness: 2 releases behind stable (rel_9 → rel_11) — 'flowharness pull' to catch up
119
+
120
+ $ flowharness status --json # the flowharness/status/v1 payload, canonical bytes
121
+ $ flowharness status --check # exit 7 on proven divergence; stdout is unchanged
122
+ $ flowharness status --offline # local facts only; freshness is reported as unknown
123
+ $ flowharness status --dir path/to/repo --channel beta --api-url https://app.example.com
124
+ ```
125
+
126
+ `flowharness` and `flowharness-scan` are two names for the same entry point — the examples above
127
+ and below use them interchangeably, and every subcommand works under either.
128
+
129
+ Run it from anywhere inside the repo: `status` walks **up** to the nearest ancestor holding
130
+ `.flowharness/` or `flowharness.toml`, stopping at a `.git` boundary, the way `git status` does.
131
+ `--channel` overrides `[flowharness].channel`, which overrides the `stable` default.
132
+ `--api-url` is accepted and ignored under `--offline`.
133
+
134
+ **Exit map.** Bare `status` **always exits 0** — a corrupt lockfile, a dead network, a typo'd
135
+ `flowharness.toml`, or an unreadable governed file is a *reported state*, never an exit code, so
136
+ the verb is safe in a shell prompt. `--check` returns **7** on proven divergence (a governed file
137
+ drifted, or the applied release is provably behind the head); if nothing diverged but the probe
138
+ itself failed, it returns that failure's code (10–17). A bad flag or a `--dir` that does not
139
+ exist is the usual argparse **2**.
140
+
141
+ Divergence requires *proof*: an unreadable origin, an unrecognised origin, or an unorderable pair
142
+ of release versions is reported as `unknown` (`drift.known: false` in the JSON) and `--check`
143
+ returns 0 rather than claiming a divergence it did not observe.
144
+
145
+ **Not yet here.** `--diff` (show the actual edits) lands with PR-D; serverless freshness (a git
146
+ remote instead of a channel) lands with PR-F.
147
+
148
+ **Known limitations.** Drift is byte-comparison against the lockfile's hashes, so: a filename
149
+ stored NFC on Linux and NFD on macOS can flip between "converged" and "missing", and
150
+ `core.autocrlf=true` on Windows makes every governed text file read as `modified`. Every
151
+ governed file is re-hashed on every run (a megabyte at a time — a huge file is slow, never an
152
+ out-of-memory), and a console that cannot encode the banner's `·`/`—`/`→` gets those characters
153
+ back-slash-escaped rather than a traceback.
154
+
155
+ Behind a corporate proxy or a private CA, note that the client sets `trust_env=False`: `status`,
156
+ `pull` and `upload` deliberately ignore `HTTP_PROXY`/`HTTPS_PROXY` and
157
+ `SSL_CERT_FILE`/`SSL_CERT_DIR`/`REQUESTS_CA_BUNDLE`, and there is not yet an explicit option to
158
+ put them back.
159
+
160
+ ## Pre-commit
161
+
162
+ ```yaml
163
+ # .pre-commit-config.yaml
164
+ - repo: https://github.com/suleimanmahmoud/flowharness
165
+ rev: <tag>
166
+ hooks:
167
+ - id: flowharness-scan
168
+ ```
169
+
170
+ ## What it flags
171
+
172
+ | Dimension | Check | Catches |
173
+ | --- | --- | --- |
174
+ | duplication | `DuplicationCheck` | the same guideline pasted across files/sections |
175
+ | contradiction | `ContradictionCheck` | retry-vs-fail-fast, tests-first-vs-prototype, … |
176
+ | orphans | `OrphanCheck` | rules no active harness loads; leftovers of removed tools |
177
+ | divergence | `DivergenceCheck` | the "same" rule that differs across harnesses |
178
+ | risk | `LeakageCheck` | secrets/credentials/template-vars — **redacted to fingerprints** |
179
+ | risk | `InjectionHeuristicsCheck` | indirect prompt-injection (override / exfil / fetch-and-execute) |
180
+ | risk | `AttestationCheck` / `BoundsCheck` | unattested or implicitly always-on guidance |
181
+
182
+ A finding **never contains a secret value**; the report carries structural metadata
183
+ only (no rule-body text).
184
+
185
+ ## Guarantees
186
+
187
+ - **Deterministic** — identical directory state ⇒ byte-identical report; ids and the
188
+ `report_hash` are content hashes; no timestamps.
189
+ - **Read-only & offline** — the scanner only ever reads the project directory; no
190
+ network, no model calls on the default path.
191
+ - **Fast** — a 50-unit repo scans in tens of milliseconds (budget: < 2 s).
192
+
193
+ ## Report
194
+
195
+ `--json` emits the `inspection/v1` schema — snapshot metadata, redacted findings, the
196
+ risk assessment, and the scored drift index — documented in
197
+ [`docs/specs/inspection-report-v1.md`](../../docs/specs/inspection-report-v1.md).
@@ -0,0 +1,179 @@
1
+ <div align="center">
2
+
3
+ # flowharness (flowharness-scan console script)
4
+
5
+ <img src="assets/badge-example.svg" alt="flowharness drift badge" height="22" />
6
+
7
+ **The Architectural Drift Index + Vibe-Risk scan for your repo's agent-rules surface.**
8
+
9
+ Local · static · deterministic · zero network · zero model calls · zero config.
10
+
11
+ </div>
12
+
13
+ ---
14
+
15
+ `flowharness-scan` reads the agent-rules surface of a repository — `CLAUDE.md`,
16
+ `.cursorrules`, `.cursor/rules/*.mdc`, `AGENTS.md`, `.continue/**`, `.opencode/**`,
17
+ `playbook/**`, and an [agentharnesses](https://github.com/agentharnesses/agentharnesses)
18
+ bundle (`HARNESS.md` + `skills/**/SKILL.md` + routing/reference files) — and tells you
19
+ two things in one pass:
20
+
21
+ - **How messy** it is — the **Architectural Drift Index** (0–100): duplication,
22
+ contradictions, orphaned rules, and cross-harness divergence.
23
+ - **How dangerous** it is — a **quarantine verdict**: leaked secrets, indirect
24
+ prompt-injection, unattested/always-on guidance.
25
+
26
+ ## Quickstart
27
+
28
+ No install required:
29
+
30
+ ```console
31
+ $ uvx flowharness scan .
32
+ flowharness-scan: drift index 30/100 - QUARANTINE (policy scoring/1)
33
+ ```
34
+
35
+ `uvx flowharness init` scaffolds a new repo's agent-rules surface the same way, with no
36
+ persistent install. `flowharness` and `flowharness-scan` are the same entry point (see below);
37
+ `uvx --from flowharness flowharness-scan .` also works if you prefer the explicit name.
38
+
39
+ > **Note:** these packages currently install top-level modules named `core`, `inspection`,
40
+ > `evaluation`, and `portability`. Prefer `uvx` (isolated environments) over `pip install`
41
+ > into a shared venv until the 0.2 module-namespace rename lands.
42
+
43
+ Exit codes wire straight into CI / pre-commit: **PASS = 0 · NEEDS_HUMAN = 1 · FAIL = 2.**
44
+
45
+ ## Output modes
46
+
47
+ ```console
48
+ $ flowharness-scan . # terminal banner (default)
49
+ $ flowharness-scan . --json # full inspection/v1 report (content-addressed)
50
+ $ flowharness-scan . --badge > drift.svg # local SVG badge for your README
51
+ ```
52
+
53
+ ## Gating
54
+
55
+ ```console
56
+ $ flowharness-scan . --fail-on risk # fail on the quarantine verdict (default)
57
+ $ flowharness-scan . --fail-on "index>40" # fail when the drift index exceeds 40
58
+ $ flowharness-scan . --policy scoring.toml # custom, versioned scoring weights
59
+ ```
60
+
61
+ ### Baseline (only fail on *new* drift)
62
+
63
+ ```console
64
+ $ flowharness-scan . --set-baseline > .flowharness-baseline.json # commit this once
65
+ $ flowharness-scan . --baseline .flowharness-baseline.json --fail-on baseline
66
+ ```
67
+
68
+ `--set-baseline` writes nothing into your repo — it prints the baseline to stdout, so
69
+ the scanner stays strictly read-only on the project directory.
70
+
71
+ ## Platform (opt-in network: `pull` / `upload`)
72
+
73
+ The default scan path is **strictly zero-network**. The `pull`/`upload` subcommands and
74
+ `scan --upload` are the *only* paths that touch the network (install the `[remote]` extra for the
75
+ `httpx` dependency). They authenticate with a scoped bearer token.
76
+
77
+ ```console
78
+ $ export FLOWHARNESS_API_URL=https://app.example.com # required (or pass --api-url)
79
+ $ export FLOWHARNESS_TOKEN=fht_... # the scoped bearer token
80
+
81
+ $ flowharness-scan pull <release_id> # fetch a release's pins -> offline cache
82
+ $ flowharness-scan . --upload --enrollment <id> # scan, then upload the InspectionRecord
83
+ $ flowharness-scan upload sync --enrollment <id> --release <id> --observed observed.json
84
+ $ flowharness-scan upload eval --run run.json # signs the report (X-Signature) + uploads
85
+ ```
86
+
87
+ Notes: a leading token that names a real directory is scanned, not treated as a subcommand
88
+ (`flowharness-scan ./pull` scans `./pull`). A remote `http://` URL is refused before any socket
89
+ opens. Non-2xx responses map to stable exit codes (10–16); a duplicate upload (`409`) is treated as
90
+ an idempotent success. `FLOWHARNESS_TOKEN` is the eval-signing HMAC key and is never written to disk.
91
+
92
+ ## `status` — am I running what the channel publishes?
93
+
94
+ `flowharness status` answers two questions in one line — *is the applied release the channel's
95
+ head?* and *has anyone edited the governed files?* — and it is **strictly read-only**: it writes
96
+ nothing in any mode, and under `--offline` it opens no socket and imports no `httpx` at all.
97
+
98
+ ```console
99
+ $ flowharness status
100
+ flowharness: 2 releases behind stable (rel_9 → rel_11) — 'flowharness pull' to catch up
101
+
102
+ $ flowharness status --json # the flowharness/status/v1 payload, canonical bytes
103
+ $ flowharness status --check # exit 7 on proven divergence; stdout is unchanged
104
+ $ flowharness status --offline # local facts only; freshness is reported as unknown
105
+ $ flowharness status --dir path/to/repo --channel beta --api-url https://app.example.com
106
+ ```
107
+
108
+ `flowharness` and `flowharness-scan` are two names for the same entry point — the examples above
109
+ and below use them interchangeably, and every subcommand works under either.
110
+
111
+ Run it from anywhere inside the repo: `status` walks **up** to the nearest ancestor holding
112
+ `.flowharness/` or `flowharness.toml`, stopping at a `.git` boundary, the way `git status` does.
113
+ `--channel` overrides `[flowharness].channel`, which overrides the `stable` default.
114
+ `--api-url` is accepted and ignored under `--offline`.
115
+
116
+ **Exit map.** Bare `status` **always exits 0** — a corrupt lockfile, a dead network, a typo'd
117
+ `flowharness.toml`, or an unreadable governed file is a *reported state*, never an exit code, so
118
+ the verb is safe in a shell prompt. `--check` returns **7** on proven divergence (a governed file
119
+ drifted, or the applied release is provably behind the head); if nothing diverged but the probe
120
+ itself failed, it returns that failure's code (10–17). A bad flag or a `--dir` that does not
121
+ exist is the usual argparse **2**.
122
+
123
+ Divergence requires *proof*: an unreadable origin, an unrecognised origin, or an unorderable pair
124
+ of release versions is reported as `unknown` (`drift.known: false` in the JSON) and `--check`
125
+ returns 0 rather than claiming a divergence it did not observe.
126
+
127
+ **Not yet here.** `--diff` (show the actual edits) lands with PR-D; serverless freshness (a git
128
+ remote instead of a channel) lands with PR-F.
129
+
130
+ **Known limitations.** Drift is byte-comparison against the lockfile's hashes, so: a filename
131
+ stored NFC on Linux and NFD on macOS can flip between "converged" and "missing", and
132
+ `core.autocrlf=true` on Windows makes every governed text file read as `modified`. Every
133
+ governed file is re-hashed on every run (a megabyte at a time — a huge file is slow, never an
134
+ out-of-memory), and a console that cannot encode the banner's `·`/`—`/`→` gets those characters
135
+ back-slash-escaped rather than a traceback.
136
+
137
+ Behind a corporate proxy or a private CA, note that the client sets `trust_env=False`: `status`,
138
+ `pull` and `upload` deliberately ignore `HTTP_PROXY`/`HTTPS_PROXY` and
139
+ `SSL_CERT_FILE`/`SSL_CERT_DIR`/`REQUESTS_CA_BUNDLE`, and there is not yet an explicit option to
140
+ put them back.
141
+
142
+ ## Pre-commit
143
+
144
+ ```yaml
145
+ # .pre-commit-config.yaml
146
+ - repo: https://github.com/suleimanmahmoud/flowharness
147
+ rev: <tag>
148
+ hooks:
149
+ - id: flowharness-scan
150
+ ```
151
+
152
+ ## What it flags
153
+
154
+ | Dimension | Check | Catches |
155
+ | --- | --- | --- |
156
+ | duplication | `DuplicationCheck` | the same guideline pasted across files/sections |
157
+ | contradiction | `ContradictionCheck` | retry-vs-fail-fast, tests-first-vs-prototype, … |
158
+ | orphans | `OrphanCheck` | rules no active harness loads; leftovers of removed tools |
159
+ | divergence | `DivergenceCheck` | the "same" rule that differs across harnesses |
160
+ | risk | `LeakageCheck` | secrets/credentials/template-vars — **redacted to fingerprints** |
161
+ | risk | `InjectionHeuristicsCheck` | indirect prompt-injection (override / exfil / fetch-and-execute) |
162
+ | risk | `AttestationCheck` / `BoundsCheck` | unattested or implicitly always-on guidance |
163
+
164
+ A finding **never contains a secret value**; the report carries structural metadata
165
+ only (no rule-body text).
166
+
167
+ ## Guarantees
168
+
169
+ - **Deterministic** — identical directory state ⇒ byte-identical report; ids and the
170
+ `report_hash` are content hashes; no timestamps.
171
+ - **Read-only & offline** — the scanner only ever reads the project directory; no
172
+ network, no model calls on the default path.
173
+ - **Fast** — a 50-unit repo scans in tens of milliseconds (budget: < 2 s).
174
+
175
+ ## Report
176
+
177
+ `--json` emits the `inspection/v1` schema — snapshot metadata, redacted findings, the
178
+ risk assessment, and the scored drift index — documented in
179
+ [`docs/specs/inspection-report-v1.md`](../../docs/specs/inspection-report-v1.md).
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "flowharness"
3
+ version = "0.1.0"
4
+ description = "Architectural Drift Index and risk scan over a repo's agent-rules surface — local, deterministic, zero network"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Programming Language :: Python :: 3.12",
12
+ "Programming Language :: Python :: 3.13",
13
+ ]
14
+ dependencies = [
15
+ "flowharness-core==0.1.0",
16
+ "flowharness-inspection==0.1.0",
17
+ "flowharness-portability==0.1.0",
18
+ ]
19
+
20
+ [project.optional-dependencies]
21
+ remote = ["httpx>=0.27"]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/flowharness-ai"
25
+
26
+ [project.scripts]
27
+ flowharness = "flowharness_scan.cli:main"
28
+ flowharness-scan = "flowharness_scan.cli:main"
29
+
30
+ [build-system]
31
+ requires = ["uv_build>=0.9.0,<0.10.0"]
32
+ build-backend = "uv_build"
33
+
34
+ [tool.uv.build-backend]
35
+ module-name = "flowharness_scan"
36
+
37
+ [tool.uv.sources.flowharness-core]
38
+ workspace = true
39
+
40
+ [tool.uv.sources.flowharness-inspection]
41
+ workspace = true
42
+
43
+ [tool.uv.sources.flowharness-portability]
44
+ workspace = true
@@ -0,0 +1,50 @@
1
+ [project]
2
+ # Dist name is the bare `flowharness` (name verified free 2026-07; claimed at first
3
+ # v0.1.0 publish) so the spec-pinned
4
+ # `uvx flowharness scan` invocation (product/07 §4.1, ci_governance_spec §2.7) resolves
5
+ # verbatim. Module stays `flowharness_scan`; `flowharness-scan` console script kept for back-compat.
6
+ name = "flowharness"
7
+ version = "0.1.0"
8
+ description = "Architectural Drift Index and risk scan over a repo's agent-rules surface — local, deterministic, zero network"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Programming Language :: Python :: 3.12",
16
+ "Programming Language :: Python :: 3.13",
17
+ ]
18
+ # Internal deps pin ==0.1.0: the six OSS packages version in lockstep (release.yml builds
19
+ # them from one tag), and [tool.uv.sources] workspace=true overrides these locally.
20
+ dependencies = [
21
+ "flowharness-core==0.1.0",
22
+ "flowharness-inspection==0.1.0",
23
+ "flowharness-portability==0.1.0",
24
+ ]
25
+
26
+ # The opt-in network client (`pull`/`upload`) needs httpx; the default scan path stays
27
+ # zero-network and zero-dependency-on-httpx (rule 10). Install with `flowharness[remote]`.
28
+ [project.optional-dependencies]
29
+ remote = ["httpx>=0.27"]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/flowharness-ai"
33
+
34
+ [project.scripts]
35
+ # `flowharness` is the primary verb-router alias; `flowharness-scan` is KEPT for
36
+ # back-compat. Both dispatch the same `main` (PR-P2-B D-P2-7 / decision D-4).
37
+ flowharness = "flowharness_scan.cli:main"
38
+ flowharness-scan = "flowharness_scan.cli:main"
39
+
40
+ [build-system]
41
+ requires = ["uv_build>=0.9.0,<0.10.0"]
42
+ build-backend = "uv_build"
43
+
44
+ [tool.uv.build-backend]
45
+ module-name = "flowharness_scan"
46
+
47
+ [tool.uv.sources]
48
+ flowharness-core = { workspace = true }
49
+ flowharness-inspection = { workspace = true }
50
+ flowharness-portability = { workspace = true }