legis 1.0.0rc2__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 (68) hide show
  1. legis-1.0.0rc2/LICENSE +21 -0
  2. legis-1.0.0rc2/PKG-INFO +218 -0
  3. legis-1.0.0rc2/README.md +193 -0
  4. legis-1.0.0rc2/pyproject.toml +63 -0
  5. legis-1.0.0rc2/src/legis/__init__.py +3 -0
  6. legis-1.0.0rc2/src/legis/api/__init__.py +1 -0
  7. legis-1.0.0rc2/src/legis/api/app.py +830 -0
  8. legis-1.0.0rc2/src/legis/canonical.py +22 -0
  9. legis-1.0.0rc2/src/legis/checks/__init__.py +1 -0
  10. legis-1.0.0rc2/src/legis/checks/models.py +34 -0
  11. legis-1.0.0rc2/src/legis/checks/surface.py +122 -0
  12. legis-1.0.0rc2/src/legis/cli.py +317 -0
  13. legis-1.0.0rc2/src/legis/clock.py +30 -0
  14. legis-1.0.0rc2/src/legis/enforcement/__init__.py +1 -0
  15. legis-1.0.0rc2/src/legis/enforcement/engine.py +115 -0
  16. legis-1.0.0rc2/src/legis/enforcement/judge.py +111 -0
  17. legis-1.0.0rc2/src/legis/enforcement/judge_factory.py +31 -0
  18. legis-1.0.0rc2/src/legis/enforcement/lifecycle.py +122 -0
  19. legis-1.0.0rc2/src/legis/enforcement/llm_client.py +168 -0
  20. legis-1.0.0rc2/src/legis/enforcement/protected.py +288 -0
  21. legis-1.0.0rc2/src/legis/enforcement/signing.py +47 -0
  22. legis-1.0.0rc2/src/legis/enforcement/signoff.py +151 -0
  23. legis-1.0.0rc2/src/legis/enforcement/verdict.py +28 -0
  24. legis-1.0.0rc2/src/legis/filigree/__init__.py +1 -0
  25. legis-1.0.0rc2/src/legis/filigree/client.py +123 -0
  26. legis-1.0.0rc2/src/legis/git/__init__.py +1 -0
  27. legis-1.0.0rc2/src/legis/git/models.py +45 -0
  28. legis-1.0.0rc2/src/legis/git/pull_request.py +27 -0
  29. legis-1.0.0rc2/src/legis/git/rename_feed.py +48 -0
  30. legis-1.0.0rc2/src/legis/git/surface.py +207 -0
  31. legis-1.0.0rc2/src/legis/governance/__init__.py +1 -0
  32. legis-1.0.0rc2/src/legis/governance/binding_ledger.py +93 -0
  33. legis-1.0.0rc2/src/legis/governance/filigree_gate.py +32 -0
  34. legis-1.0.0rc2/src/legis/governance/gaps.py +115 -0
  35. legis-1.0.0rc2/src/legis/governance/params.py +11 -0
  36. legis-1.0.0rc2/src/legis/governance/sei_backfill.py +259 -0
  37. legis-1.0.0rc2/src/legis/governance/signoff_binding.py +74 -0
  38. legis-1.0.0rc2/src/legis/identity/__init__.py +1 -0
  39. legis-1.0.0rc2/src/legis/identity/entity_key.py +40 -0
  40. legis-1.0.0rc2/src/legis/identity/loomweave_client.py +219 -0
  41. legis-1.0.0rc2/src/legis/identity/resolver.py +96 -0
  42. legis-1.0.0rc2/src/legis/mcp.py +1123 -0
  43. legis-1.0.0rc2/src/legis/policy/__init__.py +1 -0
  44. legis-1.0.0rc2/src/legis/policy/boundary_scan.py +357 -0
  45. legis-1.0.0rc2/src/legis/policy/cells.py +99 -0
  46. legis-1.0.0rc2/src/legis/policy/decorator.py +212 -0
  47. legis-1.0.0rc2/src/legis/policy/evidence.py +152 -0
  48. legis-1.0.0rc2/src/legis/policy/exemptions.py +128 -0
  49. legis-1.0.0rc2/src/legis/policy/grammar.py +123 -0
  50. legis-1.0.0rc2/src/legis/pulls/__init__.py +6 -0
  51. legis-1.0.0rc2/src/legis/pulls/models.py +23 -0
  52. legis-1.0.0rc2/src/legis/pulls/surface.py +68 -0
  53. legis-1.0.0rc2/src/legis/py.typed +0 -0
  54. legis-1.0.0rc2/src/legis/records/__init__.py +1 -0
  55. legis-1.0.0rc2/src/legis/records/override_record.py +39 -0
  56. legis-1.0.0rc2/src/legis/service/__init__.py +47 -0
  57. legis-1.0.0rc2/src/legis/service/errors.py +28 -0
  58. legis-1.0.0rc2/src/legis/service/explain.py +122 -0
  59. legis-1.0.0rc2/src/legis/service/governance.py +248 -0
  60. legis-1.0.0rc2/src/legis/service/source_binding.py +89 -0
  61. legis-1.0.0rc2/src/legis/service/wardline.py +69 -0
  62. legis-1.0.0rc2/src/legis/store/__init__.py +1 -0
  63. legis-1.0.0rc2/src/legis/store/audit_store.py +186 -0
  64. legis-1.0.0rc2/src/legis/store/protocol.py +30 -0
  65. legis-1.0.0rc2/src/legis/wardline/__init__.py +1 -0
  66. legis-1.0.0rc2/src/legis/wardline/governor.py +142 -0
  67. legis-1.0.0rc2/src/legis/wardline/ingest.py +226 -0
  68. legis-1.0.0rc2/src/legis/wardline/policy.py +17 -0
legis-1.0.0rc2/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 John Morrissey
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,218 @@
1
+ Metadata-Version: 2.4
2
+ Name: legis
3
+ Version: 1.0.0rc2
4
+ Summary: Legis — the git/CI + governance layer of the Weft suite
5
+ Author: John Morrissey
6
+ Author-email: John Morrissey <john@foundryside.dev>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Topic :: Software Development :: Version Control :: Git
15
+ Classifier: Topic :: Software Development :: Quality Assurance
16
+ Requires-Dist: fastapi>=0.115
17
+ Requires-Dist: pyyaml>=6.0
18
+ Requires-Dist: uvicorn[standard]>=0.30
19
+ Requires-Dist: sqlalchemy>=2.0
20
+ Requires-Python: >=3.12
21
+ Project-URL: Homepage, https://github.com/foundryside-dev/legis
22
+ Project-URL: Repository, https://github.com/foundryside-dev/legis
23
+ Project-URL: Issues, https://github.com/foundryside-dev/legis/issues
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Legis
27
+
28
+ Legis is the fourth Weft product: the git/CI and governance side of the suite's common operating picture.
29
+
30
+ > The authoritative Weft federation roster and axiom live in the hub at `~/weft/doctrine.md`. This README does not independently restate the roster; Legis's "fourth Weft product" framing is its own self-description, consistent with the hub's ruling (Legis is a realized member). See `~/weft/members/legis.md` for Legis's thin briefing.
31
+
32
+ ## Status
33
+
34
+ Legis is at **`1.0.0rc1`** — the first release candidate. The standalone git/CI surfaces, the graded 2×2 enforcement engine, the agent-programmable policy grammar, SEI-keyed attestations, and the Wardline/Filigree suite combinations are all built and tested; the git-rename provider to Loomweave is contract-locked, operative pending Loomweave's committed-range driving. The transport-agnostic service layer (WP-M1) underpinning the forthcoming agent-facing MCP surface has landed. See the combination matrix below for per-pairing status and `CHANGELOG.md` for the release notes.
35
+
36
+ ## The Weft suite
37
+
38
+ > Federation roster and axiom are authoritative in the hub at `~/weft/doctrine.md`. The framing below describes the substrate from Legis's vantage point and is not the canonical roster — consult the hub for that.
39
+
40
+ Weft is a suite of four tools that share a single substrate: a codebase modelled as **entities**, each carrying typed facts from different tools, all keyed on one durable identity, all freshness-honest, all consumable in one call.
41
+
42
+ ```
43
+ ┌──────────────── the entity (one durable identity: SEI) ───────────────┐
44
+ Wardline ──taint facts──► │
45
+ Loomweave ──structure/linkages/lineage──► [ Loomweave: identity authority + fact store ] │
46
+ Legis ──governance attestations──► │
47
+ Filigree ──issue associations──► │
48
+ └─────────────────────────────────────────────────────────────────────┘
49
+
50
+ one freshness-honest read: dossier(entity) / traverse(...)
51
+
52
+ a coding agent
53
+ ```
54
+
55
+ **Goal state:** a coding agent can ask *"what is true of this function, and what should I do about it?"* and get a complete, current, cited answer — and that answer stays correct when the function is renamed tomorrow.
56
+
57
+ ### Operating model
58
+
59
+ One root invariant generates the entire stack:
60
+
61
+ > **Agent-first: humans on the loop, not in the loop.** The agent *operates and extends* the environment; the human *supervises, approves, and governs* from outside the operating cycle.
62
+
63
+ Consequences:
64
+
65
+ - **Zero *human* config.** Each tool stands itself up preloaded with agent-calibrated instructions — the instruction layer *is* the configuration mechanism.
66
+ - **Agent-programmable extension.** Agents can define new boundary types and the rules enforced at them, expressed in a shared grammar with builtins as preloaded defaults.
67
+ - **Legis graded enforcement.** When a policy fires, its mode decides who answers: **block + escalate** (the human operator signs off — in the loop by exception) or **surface + override** (the agent must *recordably* override, and the human reviews the trail asynchronously). The recorded override is what makes "humans not in the loop" safe: an attributable audit event, never a silent pass.
68
+
69
+ ### The combination matrix
70
+
71
+ Weft's value is the *matrix* of its tools' combinations, not their sum. Each pair is an opt-in layer that lights up a capability neither tool has alone:
72
+
73
+ | Combination | Capability | Status |
74
+ |---|---|---|
75
+ | **Wardline + Loomweave** | Structure + trust posture in one view (the dossier) | **Live** |
76
+ | **Wardline + Filigree** | Findings become tracked work | **Live** |
77
+ | **Loomweave + Filigree** | Issues bound to live code, surviving refactors | **Partial** — orphans on rename (SEI gap) |
78
+ | **Wardline + Legis** | Agent-defined policy enforced at the CI/git boundary | **Live** — findings route through legis enforcement into the configured 2×2 cell (Sprint 6 WP-6.1) |
79
+ | **Loomweave + Legis** | Governance attestations keyed to stable code identity | **Live** (SEI-keyed attestations, Sprint 5); git-rename provider **contract-locked**, operative pending Loomweave committed-range driving (WP-6.3) |
80
+ | **Filigree + Legis** | Governed issue lifecycle — sign-offs, RTM, verification states | **Live** — governed SEI-keyed sign-off binding; Filigree retains lifecycle authority (Sprint 6 WP-6.2) |
81
+
82
+ Higher-order: **all four** closes the loop — the agent understands the code (Loomweave) and its trust posture (Wardline), Legis governs what it may do and records overrides, and every decision and unit of work is tracked against stable identity (Filigree + Loomweave).
83
+
84
+ SEI is the connective tissue of the whole matrix: one non-conformant binding orphans every combination it participates in.
85
+
86
+ ## What Legis is
87
+
88
+ Legis is the planned Weft authority for:
89
+
90
+ - project change provenance,
91
+ - branch / commit / pull request context,
92
+ - CI and check context, and
93
+ - governance and attestation context over change.
94
+
95
+ Legis answers: *what changed, in which branch/commit/PR/check context, and what governance or attestation state exists for that change?*
96
+
97
+ ### The governance 2×2
98
+
99
+ Legis's enforcement surface is a **2×2**, and the base always stays weightless. Two independent axes: how much governance *structure* you want (simple / complex), and whether an LLM *judge* sits inline (off / on). Each axis is agent-set; every cell is genuinely useful.
100
+
101
+ | | **Judge OFF** | **Judge ON** |
102
+ |---|---|---|
103
+ | **Simple** | **Chill** — CI flags the violation; the agent self-reports a recordable override; the human reviews the trail asynchronously. No LLM, no crypto, no ceremony. | **Coached** — same flow, but the agent pushes against an interactive LLM wall *before* the override records. One config flag. |
104
+ | **Complex** | **Structured** — block + escalate; a designated human signs off before the gate clears. Procedural gates, no model in the critical path. | **Protected** — the full machinery: HMAC-signed verdicts, decay sweep, override-rate gate. |
105
+
106
+ **Chill (simple, judge off).** Legis is invisible until you want it. No judge, no required attestations, no configuration burden. When a policy fires at the CI/git boundary, the agent has a choice: refactor, or make a *recordable override* — an attributable audit event the human reviews from the loop's edge, asynchronously. The trail exists; the human is not blocked. A solo project that never switches Legis on pays nothing.
107
+
108
+ **Coached (simple, judge on) — the config-flag cell.** The same flow, but an LLM judge evaluates the proposed override *before* it records. This is the casual coder's interactive wall: CI pushes back on a policy-breaking change until the agent corrects the code or explains itself convincingly. Verdicts are `ACCEPTED` or `BLOCKED`; a blocked agent must correct or sharpen its rationale and re-submit — it cannot self-clear past the judge. **A single config flag** — no HMAC key management, no decay sweep, no deployment ceremony. It raises the cost of lazy overrides without raising the cost of honest ones. There is no operator override here; for that authority, upgrade to complex.
109
+
110
+ **Structured (complex, judge off).** Block + escalate without an LLM in the loop: for high-stakes policies, a designated human operator must sign off before the gate clears. Clear procedural governance with explicit human authority — for teams that want hard gates but no model in the critical path. The human is in the loop by exception, not by default.
111
+
112
+ **Protected (complex, judge on) — the full machinery.** When both dials are up, Legis adds the cryptographic layer over the coached cell:
113
+
114
+ - **LLM judge gate** on every new suppression/attestation, now returning `ACCEPTED`, `BLOCKED`, or `OVERRIDDEN_BY_OPERATOR`. The judge *blocks but does not fix* — a BLOCKED verdict returns the failure to the agent; the agent figures out remediation. The judge's rationale is recorded verbatim as audit evidence, bound to the source bytes and AST node it inspected (`file_fingerprint` + `ast_path`), and HMAC-signed so tamper-attempts are detectable.
115
+ - **Decay sweep.** At renewal time, existing suppressions re-run through the judge. Decisions to keep an entry must survive a fresh judge pass. Closes the "self-attested, never re-reviewed" failure mode.
116
+ - **Override-rate gate.** A rolling-window threshold on the ratio of `OVERRIDDEN_BY_OPERATOR` verdicts. Too many overrides is itself an audit signal — either the policy is miscalibrated, or the operator is breaking their own rules to ship. Either way, it is observable rather than silent.
117
+ - **Block + escalate** is also available here, with the added constraint that even a human sign-off produces a tamper-bound record.
118
+ - **Audit lineage keyed on SEI.** Every verdict, override, and sign-off is recorded in an append-only trail keyed on Stable Entity Identity so the record survives rename/move.
119
+
120
+ The elspeth CI judge (`/home/john/elspeth`) is the working design ancestor of the protected cell — it is the "thick version" shipped inside elspeth's own codebase. Legis is where the same mechanisms land as a suite-level, opt-in layer.
121
+
122
+ ### Graded enforcement
123
+
124
+ Across all four cells, one underlying primitive: when a policy fires, the *cell* decides who answers and what is recorded.
125
+
126
+ - **Surface + override** — agent may proceed, but makes a recordable override (with, in the coached/protected cells, a judge inline before it records). Human reviews the trail asynchronously. This is the simple tier's active state and the default for any policy that does not require a human gate.
127
+ - **Block + escalate** — hard gate; a designated human operator must sign off before the gate clears. The complex tier; used for high-stakes decisions.
128
+
129
+ Every cell produces an append-only audit trail keyed on SEI, so the record survives refactors.
130
+
131
+ ## What Legis is not
132
+
133
+ Legis is not:
134
+
135
+ - a federation registry,
136
+ - a hidden suite runtime,
137
+ - a replacement for Loomweave's code identity authority,
138
+ - a replacement for Filigree's workflow authority, or
139
+ - a replacement for Wardline's policy analysis authority.
140
+
141
+ ## How Legis fits into Weft
142
+
143
+ ### Loomweave
144
+
145
+ Loomweave remains the sole authority for code identity and structure, including SEI. Legis is an SEI *consumer* (governance attestations key on SEI; SEI lineage is Legis's audit spine). Legis is also a *potential provider*: once Legis ships a git interface, it may supply the git-rename and history signals the SEI re-binding matcher consumes — but that does not move identity authority out of Loomweave.
146
+
147
+ ### Filigree
148
+
149
+ Filigree remains the authority for issue and workflow state. Legis adds branch, commit, pull request, and check context around that work, and governs the issue lifecycle through verification sign-offs and requirement traceability — without taking over issue state or work-claim semantics.
150
+
151
+ ### Wardline
152
+
153
+ Wardline remains the authority for policy findings, taint facts, and dossier truth. Legis contributes the git/CI context that Wardline cites when attaching findings or enforcement gates to real repository state, and adds governed enforcement modes on top of Wardline's analysis.
154
+
155
+ The division of responsibility is explicit: **Wardline analyses trust; Legis governs it — one judge, not two.** Wardline already has the gate primitive (`--fail-on`, exit codes); Legis adds the governed policy layer around it. This is Wardline's Milestone 5 (governance & trust-vocabulary convergence) from its roadmap — Wardline's half is thin and ready; the gate is Legis existing.
156
+
157
+ When Legis ships, the Wardline + Legis combination unlocks:
158
+ - agent-defined policy, enforced at the git/CI boundary with graded modes;
159
+ - trust-vocabulary convergence — one `@trust_boundary` grammar across the suite, delivering elspeth's custody and fabrication-test guarantees in Weft's own terms, not a second naming scheme bolted on beside the first; and
160
+ - the full chill → coached → protected progression across the 2×2, with Wardline's findings as the input and Legis's enforcement layer as the output.
161
+
162
+ ## Stable Entity Identity
163
+
164
+ Legis is an SEI **consumer**, not an authority.
165
+
166
+ - Loomweave mints, persists, re-binds, and resolves SEI.
167
+ - Legis treats SEI as opaque: never derived, parsed, or reinterpreted.
168
+ - Governance attestations key on **SEI** when the subject is a code entity, so attestations survive rename/move.
169
+ - SEI lineage (the append-only event log Loomweave maintains) is Legis's ready-made, tamper-evidence-able audit trail.
170
+ - If Loomweave does not advertise the `sei` capability, Legis degrades honestly rather than guessing.
171
+
172
+ See `docs/federation/sei-conformance.md` for Legis's specific conformance obligations.
173
+
174
+ ## Goal-state checklist (Legis's contribution)
175
+
176
+ Legis is complete when:
177
+
178
+ - [ ] Legis ships as opt-in: invisible to a solo project, complete for a regulated one — all four 2×2 cells work end-to-end
179
+ - [ ] Governance attestations key on SEI and survive rename/move
180
+ - [ ] `lineage(sei)` is consumed as the audit spine for governance records
181
+ - [ ] Chill cell (simple, judge off): surface+override is live; agent overrides produce attributable audit events; human reviews async
182
+ - [ ] Coached cell (simple, judge on): LLM wall on overrides behind a single config flag (ACCEPTED / BLOCKED); no HMAC keys, no decay sweep; agent must correct or convince
183
+ - [ ] Protected cell (complex, judge on): judge gate adds OVERRIDDEN_BY_OPERATOR; verdicts HMAC-signed and SEI-keyed; decay sweep and override-rate gate wired into CI
184
+ - [ ] Structured cell (complex, judge off): human sign-off gate available for high-stakes policies, no model in the critical path
185
+ - [ ] Wardline + Legis: Wardline's `--fail-on` / exit codes governed by Legis's policy layer; trust-vocabulary converged to one grammar across the suite
186
+ - [ ] Legis governs trust while Wardline analyses it — one judge, not two
187
+ - [ ] Filigree + Legis: verification sign-offs and governed issue lifecycle work end-to-end
188
+ - [ ] Git-rename / history signal available for Loomweave's SEI matcher (if/when the git interface ships)
189
+
190
+ ## Repository layout
191
+
192
+ - `docs/federation/` — Weft-facing contracts and participation notes
193
+ - `docs/design/` — product intent and design notes
194
+ - `docs/superpowers/specs/` — approved design specs
195
+ - `docs/superpowers/plans/` — implementation plans
196
+
197
+ ## Documents
198
+
199
+ **Design and federation:**
200
+ - `docs/design/legis-charter.md` — authority boundary, operating modes, near-term scope
201
+ - `docs/federation/README.md` — Weft participation overview
202
+ - `docs/federation/sei-conformance.md` — Legis-specific SEI posture and obligations
203
+
204
+ **Planning:**
205
+ - `docs/superpowers/specs/2026-06-01-legis-federation-repo-design.md` — federation repo design spec
206
+ - `docs/superpowers/specs/2026-06-01-legis-roadmap-to-first-class.md` — final-form roadmap (the two halves, the 2×2, dependency gates, SEI conformance)
207
+ - `docs/superpowers/plans/2026-06-01-legis-bootstrap.md` — bootstrap implementation plan (docs-first repo)
208
+ - `docs/superpowers/plans/2026-06-01-legis-implementation-sprints.md` — sprint / work-package breakdown of the roadmap
209
+
210
+ **Suite-wide context (lives in wardline/docs/superpowers/specs/):**
211
+ - `2026-06-01-weft-goal-state-case-study.md` — Weft goal state, operating model, combination matrix
212
+ - `2026-06-01-weft-stable-entity-identity-conformance.md` — SEI standard (Legis is a named consumer in §5)
213
+ - `2026-06-01-wardline-roadmap-to-first-class.md` — Wardline's staged path to first-class; Milestone 5 (governance & trust-vocabulary convergence) is gated on Legis existing
214
+
215
+ **Design ancestor:**
216
+ - `/home/john/elspeth` — elspeth's CI judge (`elspeth-lints justify / reaudit / check-judge-coverage / check-override-rate`) is the working "thick version" of Legis's protected cell. The judge gate, `@trust_boundary` decorator, HMAC-signed audit trail, decay sweep, and override-rate gate are all elspeth concepts that Legis inherits as suite-level mechanisms. Elspeth is a standalone project, not a Weft federation member — Legis borrows its *effects* and re-expresses them in Weft's vocabulary.
217
+
218
+ This repo stays explicit, narrow, and honest about what exists today.
@@ -0,0 +1,193 @@
1
+ # Legis
2
+
3
+ Legis is the fourth Weft product: the git/CI and governance side of the suite's common operating picture.
4
+
5
+ > The authoritative Weft federation roster and axiom live in the hub at `~/weft/doctrine.md`. This README does not independently restate the roster; Legis's "fourth Weft product" framing is its own self-description, consistent with the hub's ruling (Legis is a realized member). See `~/weft/members/legis.md` for Legis's thin briefing.
6
+
7
+ ## Status
8
+
9
+ Legis is at **`1.0.0rc1`** — the first release candidate. The standalone git/CI surfaces, the graded 2×2 enforcement engine, the agent-programmable policy grammar, SEI-keyed attestations, and the Wardline/Filigree suite combinations are all built and tested; the git-rename provider to Loomweave is contract-locked, operative pending Loomweave's committed-range driving. The transport-agnostic service layer (WP-M1) underpinning the forthcoming agent-facing MCP surface has landed. See the combination matrix below for per-pairing status and `CHANGELOG.md` for the release notes.
10
+
11
+ ## The Weft suite
12
+
13
+ > Federation roster and axiom are authoritative in the hub at `~/weft/doctrine.md`. The framing below describes the substrate from Legis's vantage point and is not the canonical roster — consult the hub for that.
14
+
15
+ Weft is a suite of four tools that share a single substrate: a codebase modelled as **entities**, each carrying typed facts from different tools, all keyed on one durable identity, all freshness-honest, all consumable in one call.
16
+
17
+ ```
18
+ ┌──────────────── the entity (one durable identity: SEI) ───────────────┐
19
+ Wardline ──taint facts──► │
20
+ Loomweave ──structure/linkages/lineage──► [ Loomweave: identity authority + fact store ] │
21
+ Legis ──governance attestations──► │
22
+ Filigree ──issue associations──► │
23
+ └─────────────────────────────────────────────────────────────────────┘
24
+
25
+ one freshness-honest read: dossier(entity) / traverse(...)
26
+
27
+ a coding agent
28
+ ```
29
+
30
+ **Goal state:** a coding agent can ask *"what is true of this function, and what should I do about it?"* and get a complete, current, cited answer — and that answer stays correct when the function is renamed tomorrow.
31
+
32
+ ### Operating model
33
+
34
+ One root invariant generates the entire stack:
35
+
36
+ > **Agent-first: humans on the loop, not in the loop.** The agent *operates and extends* the environment; the human *supervises, approves, and governs* from outside the operating cycle.
37
+
38
+ Consequences:
39
+
40
+ - **Zero *human* config.** Each tool stands itself up preloaded with agent-calibrated instructions — the instruction layer *is* the configuration mechanism.
41
+ - **Agent-programmable extension.** Agents can define new boundary types and the rules enforced at them, expressed in a shared grammar with builtins as preloaded defaults.
42
+ - **Legis graded enforcement.** When a policy fires, its mode decides who answers: **block + escalate** (the human operator signs off — in the loop by exception) or **surface + override** (the agent must *recordably* override, and the human reviews the trail asynchronously). The recorded override is what makes "humans not in the loop" safe: an attributable audit event, never a silent pass.
43
+
44
+ ### The combination matrix
45
+
46
+ Weft's value is the *matrix* of its tools' combinations, not their sum. Each pair is an opt-in layer that lights up a capability neither tool has alone:
47
+
48
+ | Combination | Capability | Status |
49
+ |---|---|---|
50
+ | **Wardline + Loomweave** | Structure + trust posture in one view (the dossier) | **Live** |
51
+ | **Wardline + Filigree** | Findings become tracked work | **Live** |
52
+ | **Loomweave + Filigree** | Issues bound to live code, surviving refactors | **Partial** — orphans on rename (SEI gap) |
53
+ | **Wardline + Legis** | Agent-defined policy enforced at the CI/git boundary | **Live** — findings route through legis enforcement into the configured 2×2 cell (Sprint 6 WP-6.1) |
54
+ | **Loomweave + Legis** | Governance attestations keyed to stable code identity | **Live** (SEI-keyed attestations, Sprint 5); git-rename provider **contract-locked**, operative pending Loomweave committed-range driving (WP-6.3) |
55
+ | **Filigree + Legis** | Governed issue lifecycle — sign-offs, RTM, verification states | **Live** — governed SEI-keyed sign-off binding; Filigree retains lifecycle authority (Sprint 6 WP-6.2) |
56
+
57
+ Higher-order: **all four** closes the loop — the agent understands the code (Loomweave) and its trust posture (Wardline), Legis governs what it may do and records overrides, and every decision and unit of work is tracked against stable identity (Filigree + Loomweave).
58
+
59
+ SEI is the connective tissue of the whole matrix: one non-conformant binding orphans every combination it participates in.
60
+
61
+ ## What Legis is
62
+
63
+ Legis is the planned Weft authority for:
64
+
65
+ - project change provenance,
66
+ - branch / commit / pull request context,
67
+ - CI and check context, and
68
+ - governance and attestation context over change.
69
+
70
+ Legis answers: *what changed, in which branch/commit/PR/check context, and what governance or attestation state exists for that change?*
71
+
72
+ ### The governance 2×2
73
+
74
+ Legis's enforcement surface is a **2×2**, and the base always stays weightless. Two independent axes: how much governance *structure* you want (simple / complex), and whether an LLM *judge* sits inline (off / on). Each axis is agent-set; every cell is genuinely useful.
75
+
76
+ | | **Judge OFF** | **Judge ON** |
77
+ |---|---|---|
78
+ | **Simple** | **Chill** — CI flags the violation; the agent self-reports a recordable override; the human reviews the trail asynchronously. No LLM, no crypto, no ceremony. | **Coached** — same flow, but the agent pushes against an interactive LLM wall *before* the override records. One config flag. |
79
+ | **Complex** | **Structured** — block + escalate; a designated human signs off before the gate clears. Procedural gates, no model in the critical path. | **Protected** — the full machinery: HMAC-signed verdicts, decay sweep, override-rate gate. |
80
+
81
+ **Chill (simple, judge off).** Legis is invisible until you want it. No judge, no required attestations, no configuration burden. When a policy fires at the CI/git boundary, the agent has a choice: refactor, or make a *recordable override* — an attributable audit event the human reviews from the loop's edge, asynchronously. The trail exists; the human is not blocked. A solo project that never switches Legis on pays nothing.
82
+
83
+ **Coached (simple, judge on) — the config-flag cell.** The same flow, but an LLM judge evaluates the proposed override *before* it records. This is the casual coder's interactive wall: CI pushes back on a policy-breaking change until the agent corrects the code or explains itself convincingly. Verdicts are `ACCEPTED` or `BLOCKED`; a blocked agent must correct or sharpen its rationale and re-submit — it cannot self-clear past the judge. **A single config flag** — no HMAC key management, no decay sweep, no deployment ceremony. It raises the cost of lazy overrides without raising the cost of honest ones. There is no operator override here; for that authority, upgrade to complex.
84
+
85
+ **Structured (complex, judge off).** Block + escalate without an LLM in the loop: for high-stakes policies, a designated human operator must sign off before the gate clears. Clear procedural governance with explicit human authority — for teams that want hard gates but no model in the critical path. The human is in the loop by exception, not by default.
86
+
87
+ **Protected (complex, judge on) — the full machinery.** When both dials are up, Legis adds the cryptographic layer over the coached cell:
88
+
89
+ - **LLM judge gate** on every new suppression/attestation, now returning `ACCEPTED`, `BLOCKED`, or `OVERRIDDEN_BY_OPERATOR`. The judge *blocks but does not fix* — a BLOCKED verdict returns the failure to the agent; the agent figures out remediation. The judge's rationale is recorded verbatim as audit evidence, bound to the source bytes and AST node it inspected (`file_fingerprint` + `ast_path`), and HMAC-signed so tamper-attempts are detectable.
90
+ - **Decay sweep.** At renewal time, existing suppressions re-run through the judge. Decisions to keep an entry must survive a fresh judge pass. Closes the "self-attested, never re-reviewed" failure mode.
91
+ - **Override-rate gate.** A rolling-window threshold on the ratio of `OVERRIDDEN_BY_OPERATOR` verdicts. Too many overrides is itself an audit signal — either the policy is miscalibrated, or the operator is breaking their own rules to ship. Either way, it is observable rather than silent.
92
+ - **Block + escalate** is also available here, with the added constraint that even a human sign-off produces a tamper-bound record.
93
+ - **Audit lineage keyed on SEI.** Every verdict, override, and sign-off is recorded in an append-only trail keyed on Stable Entity Identity so the record survives rename/move.
94
+
95
+ The elspeth CI judge (`/home/john/elspeth`) is the working design ancestor of the protected cell — it is the "thick version" shipped inside elspeth's own codebase. Legis is where the same mechanisms land as a suite-level, opt-in layer.
96
+
97
+ ### Graded enforcement
98
+
99
+ Across all four cells, one underlying primitive: when a policy fires, the *cell* decides who answers and what is recorded.
100
+
101
+ - **Surface + override** — agent may proceed, but makes a recordable override (with, in the coached/protected cells, a judge inline before it records). Human reviews the trail asynchronously. This is the simple tier's active state and the default for any policy that does not require a human gate.
102
+ - **Block + escalate** — hard gate; a designated human operator must sign off before the gate clears. The complex tier; used for high-stakes decisions.
103
+
104
+ Every cell produces an append-only audit trail keyed on SEI, so the record survives refactors.
105
+
106
+ ## What Legis is not
107
+
108
+ Legis is not:
109
+
110
+ - a federation registry,
111
+ - a hidden suite runtime,
112
+ - a replacement for Loomweave's code identity authority,
113
+ - a replacement for Filigree's workflow authority, or
114
+ - a replacement for Wardline's policy analysis authority.
115
+
116
+ ## How Legis fits into Weft
117
+
118
+ ### Loomweave
119
+
120
+ Loomweave remains the sole authority for code identity and structure, including SEI. Legis is an SEI *consumer* (governance attestations key on SEI; SEI lineage is Legis's audit spine). Legis is also a *potential provider*: once Legis ships a git interface, it may supply the git-rename and history signals the SEI re-binding matcher consumes — but that does not move identity authority out of Loomweave.
121
+
122
+ ### Filigree
123
+
124
+ Filigree remains the authority for issue and workflow state. Legis adds branch, commit, pull request, and check context around that work, and governs the issue lifecycle through verification sign-offs and requirement traceability — without taking over issue state or work-claim semantics.
125
+
126
+ ### Wardline
127
+
128
+ Wardline remains the authority for policy findings, taint facts, and dossier truth. Legis contributes the git/CI context that Wardline cites when attaching findings or enforcement gates to real repository state, and adds governed enforcement modes on top of Wardline's analysis.
129
+
130
+ The division of responsibility is explicit: **Wardline analyses trust; Legis governs it — one judge, not two.** Wardline already has the gate primitive (`--fail-on`, exit codes); Legis adds the governed policy layer around it. This is Wardline's Milestone 5 (governance & trust-vocabulary convergence) from its roadmap — Wardline's half is thin and ready; the gate is Legis existing.
131
+
132
+ When Legis ships, the Wardline + Legis combination unlocks:
133
+ - agent-defined policy, enforced at the git/CI boundary with graded modes;
134
+ - trust-vocabulary convergence — one `@trust_boundary` grammar across the suite, delivering elspeth's custody and fabrication-test guarantees in Weft's own terms, not a second naming scheme bolted on beside the first; and
135
+ - the full chill → coached → protected progression across the 2×2, with Wardline's findings as the input and Legis's enforcement layer as the output.
136
+
137
+ ## Stable Entity Identity
138
+
139
+ Legis is an SEI **consumer**, not an authority.
140
+
141
+ - Loomweave mints, persists, re-binds, and resolves SEI.
142
+ - Legis treats SEI as opaque: never derived, parsed, or reinterpreted.
143
+ - Governance attestations key on **SEI** when the subject is a code entity, so attestations survive rename/move.
144
+ - SEI lineage (the append-only event log Loomweave maintains) is Legis's ready-made, tamper-evidence-able audit trail.
145
+ - If Loomweave does not advertise the `sei` capability, Legis degrades honestly rather than guessing.
146
+
147
+ See `docs/federation/sei-conformance.md` for Legis's specific conformance obligations.
148
+
149
+ ## Goal-state checklist (Legis's contribution)
150
+
151
+ Legis is complete when:
152
+
153
+ - [ ] Legis ships as opt-in: invisible to a solo project, complete for a regulated one — all four 2×2 cells work end-to-end
154
+ - [ ] Governance attestations key on SEI and survive rename/move
155
+ - [ ] `lineage(sei)` is consumed as the audit spine for governance records
156
+ - [ ] Chill cell (simple, judge off): surface+override is live; agent overrides produce attributable audit events; human reviews async
157
+ - [ ] Coached cell (simple, judge on): LLM wall on overrides behind a single config flag (ACCEPTED / BLOCKED); no HMAC keys, no decay sweep; agent must correct or convince
158
+ - [ ] Protected cell (complex, judge on): judge gate adds OVERRIDDEN_BY_OPERATOR; verdicts HMAC-signed and SEI-keyed; decay sweep and override-rate gate wired into CI
159
+ - [ ] Structured cell (complex, judge off): human sign-off gate available for high-stakes policies, no model in the critical path
160
+ - [ ] Wardline + Legis: Wardline's `--fail-on` / exit codes governed by Legis's policy layer; trust-vocabulary converged to one grammar across the suite
161
+ - [ ] Legis governs trust while Wardline analyses it — one judge, not two
162
+ - [ ] Filigree + Legis: verification sign-offs and governed issue lifecycle work end-to-end
163
+ - [ ] Git-rename / history signal available for Loomweave's SEI matcher (if/when the git interface ships)
164
+
165
+ ## Repository layout
166
+
167
+ - `docs/federation/` — Weft-facing contracts and participation notes
168
+ - `docs/design/` — product intent and design notes
169
+ - `docs/superpowers/specs/` — approved design specs
170
+ - `docs/superpowers/plans/` — implementation plans
171
+
172
+ ## Documents
173
+
174
+ **Design and federation:**
175
+ - `docs/design/legis-charter.md` — authority boundary, operating modes, near-term scope
176
+ - `docs/federation/README.md` — Weft participation overview
177
+ - `docs/federation/sei-conformance.md` — Legis-specific SEI posture and obligations
178
+
179
+ **Planning:**
180
+ - `docs/superpowers/specs/2026-06-01-legis-federation-repo-design.md` — federation repo design spec
181
+ - `docs/superpowers/specs/2026-06-01-legis-roadmap-to-first-class.md` — final-form roadmap (the two halves, the 2×2, dependency gates, SEI conformance)
182
+ - `docs/superpowers/plans/2026-06-01-legis-bootstrap.md` — bootstrap implementation plan (docs-first repo)
183
+ - `docs/superpowers/plans/2026-06-01-legis-implementation-sprints.md` — sprint / work-package breakdown of the roadmap
184
+
185
+ **Suite-wide context (lives in wardline/docs/superpowers/specs/):**
186
+ - `2026-06-01-weft-goal-state-case-study.md` — Weft goal state, operating model, combination matrix
187
+ - `2026-06-01-weft-stable-entity-identity-conformance.md` — SEI standard (Legis is a named consumer in §5)
188
+ - `2026-06-01-wardline-roadmap-to-first-class.md` — Wardline's staged path to first-class; Milestone 5 (governance & trust-vocabulary convergence) is gated on Legis existing
189
+
190
+ **Design ancestor:**
191
+ - `/home/john/elspeth` — elspeth's CI judge (`elspeth-lints justify / reaudit / check-judge-coverage / check-override-rate`) is the working "thick version" of Legis's protected cell. The judge gate, `@trust_boundary` decorator, HMAC-signed audit trail, decay sweep, and override-rate gate are all elspeth concepts that Legis inherits as suite-level mechanisms. Elspeth is a standalone project, not a Weft federation member — Legis borrows its *effects* and re-expresses them in Weft's vocabulary.
192
+
193
+ This repo stays explicit, narrow, and honest about what exists today.
@@ -0,0 +1,63 @@
1
+ [project]
2
+ name = "legis"
3
+ version = "1.0.0rc2"
4
+ description = "Legis — the git/CI + governance layer of the Weft suite"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "John Morrissey", email = "john@foundryside.dev" }
10
+ ]
11
+ requires-python = ">=3.12"
12
+ dependencies = [
13
+ "fastapi>=0.115",
14
+ "pyyaml>=6.0",
15
+ "uvicorn[standard]>=0.30",
16
+ "sqlalchemy>=2.0",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 4 - Beta",
20
+ "Intended Audience :: Developers",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Operating System :: OS Independent",
24
+ "Topic :: Software Development :: Version Control :: Git",
25
+ "Topic :: Software Development :: Quality Assurance",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/foundryside-dev/legis"
30
+ Repository = "https://github.com/foundryside-dev/legis"
31
+ Issues = "https://github.com/foundryside-dev/legis/issues"
32
+
33
+ [project.scripts]
34
+ legis = "legis.cli:main"
35
+
36
+ [dependency-groups]
37
+ dev = [
38
+ "pytest>=8.0",
39
+ "pytest-cov>=5.0",
40
+ "httpx>=0.27",
41
+ "mypy>=1.19",
42
+ "types-PyYAML>=6.0",
43
+ ]
44
+
45
+ [build-system]
46
+ requires = ["uv_build>=0.10.2,<0.11.0"]
47
+ build-backend = "uv_build"
48
+
49
+ [tool.pytest.ini_options]
50
+ testpaths = ["tests"]
51
+ pythonpath = ["src"]
52
+ filterwarnings = [
53
+ "error",
54
+ # Third-party: Starlette's TestClient warns about its bundled httpx usage.
55
+ # Matched by message (category is StarletteDeprecationWarning, not DeprecationWarning).
56
+ "ignore:Using `httpx` with `starlette.testclient` is deprecated",
57
+ ]
58
+
59
+ [tool.mypy]
60
+ python_version = "3.12"
61
+ files = ["src/legis"]
62
+ show_error_codes = true
63
+ warn_unused_configs = true
@@ -0,0 +1,3 @@
1
+ """Legis — the git/CI + governance layer of the Weft suite."""
2
+
3
+ __version__ = "1.0.0rc2"
@@ -0,0 +1 @@
1
+ """Legis HTTP read API (consumer model)."""