legis 1.0.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 (82) hide show
  1. legis-1.0.0/LICENSE +21 -0
  2. legis-1.0.0/PKG-INFO +281 -0
  3. legis-1.0.0/README.md +254 -0
  4. legis-1.0.0/pyproject.toml +92 -0
  5. legis-1.0.0/src/legis/__init__.py +3 -0
  6. legis-1.0.0/src/legis/api/__init__.py +1 -0
  7. legis-1.0.0/src/legis/api/app.py +916 -0
  8. legis-1.0.0/src/legis/canonical.py +48 -0
  9. legis-1.0.0/src/legis/checks/__init__.py +1 -0
  10. legis-1.0.0/src/legis/checks/models.py +42 -0
  11. legis-1.0.0/src/legis/checks/surface.py +132 -0
  12. legis-1.0.0/src/legis/cli.py +801 -0
  13. legis-1.0.0/src/legis/clock.py +30 -0
  14. legis-1.0.0/src/legis/config.py +202 -0
  15. legis-1.0.0/src/legis/data/instructions.md +16 -0
  16. legis-1.0.0/src/legis/data/skills/legis-workflow/SKILL.md +252 -0
  17. legis-1.0.0/src/legis/doctor.py +917 -0
  18. legis-1.0.0/src/legis/enforcement/__init__.py +1 -0
  19. legis-1.0.0/src/legis/enforcement/engine.py +119 -0
  20. legis-1.0.0/src/legis/enforcement/judge.py +185 -0
  21. legis-1.0.0/src/legis/enforcement/judge_factory.py +31 -0
  22. legis-1.0.0/src/legis/enforcement/lifecycle.py +134 -0
  23. legis-1.0.0/src/legis/enforcement/llm_client.py +168 -0
  24. legis-1.0.0/src/legis/enforcement/protected.py +421 -0
  25. legis-1.0.0/src/legis/enforcement/signing.py +61 -0
  26. legis-1.0.0/src/legis/enforcement/signoff.py +193 -0
  27. legis-1.0.0/src/legis/enforcement/verdict.py +50 -0
  28. legis-1.0.0/src/legis/filigree/__init__.py +1 -0
  29. legis-1.0.0/src/legis/filigree/client.py +184 -0
  30. legis-1.0.0/src/legis/git/__init__.py +1 -0
  31. legis-1.0.0/src/legis/git/models.py +45 -0
  32. legis-1.0.0/src/legis/git/pull_request.py +27 -0
  33. legis-1.0.0/src/legis/git/rename_feed.py +48 -0
  34. legis-1.0.0/src/legis/git/surface.py +207 -0
  35. legis-1.0.0/src/legis/governance/__init__.py +1 -0
  36. legis-1.0.0/src/legis/governance/binding_ledger.py +93 -0
  37. legis-1.0.0/src/legis/governance/filigree_gate.py +32 -0
  38. legis-1.0.0/src/legis/governance/gaps.py +120 -0
  39. legis-1.0.0/src/legis/governance/params.py +11 -0
  40. legis-1.0.0/src/legis/governance/sei_backfill.py +268 -0
  41. legis-1.0.0/src/legis/governance/signoff_binding.py +82 -0
  42. legis-1.0.0/src/legis/hooks.py +222 -0
  43. legis-1.0.0/src/legis/identity/__init__.py +1 -0
  44. legis-1.0.0/src/legis/identity/entity_key.py +40 -0
  45. legis-1.0.0/src/legis/identity/loomweave_client.py +239 -0
  46. legis-1.0.0/src/legis/identity/resolver.py +262 -0
  47. legis-1.0.0/src/legis/install.py +1319 -0
  48. legis-1.0.0/src/legis/mcp.py +2541 -0
  49. legis-1.0.0/src/legis/policy/__init__.py +1 -0
  50. legis-1.0.0/src/legis/policy/boundary_scan.py +422 -0
  51. legis-1.0.0/src/legis/policy/cells.py +137 -0
  52. legis-1.0.0/src/legis/policy/decorator.py +226 -0
  53. legis-1.0.0/src/legis/policy/evidence.py +232 -0
  54. legis-1.0.0/src/legis/policy/grammar.py +108 -0
  55. legis-1.0.0/src/legis/posture/__init__.py +65 -0
  56. legis-1.0.0/src/legis/posture/floor.py +89 -0
  57. legis-1.0.0/src/legis/posture/ledger.py +435 -0
  58. legis-1.0.0/src/legis/posture/records.py +54 -0
  59. legis-1.0.0/src/legis/posture/session.py +175 -0
  60. legis-1.0.0/src/legis/posture/signing.py +284 -0
  61. legis-1.0.0/src/legis/provenance.py +27 -0
  62. legis-1.0.0/src/legis/pulls/__init__.py +6 -0
  63. legis-1.0.0/src/legis/pulls/models.py +29 -0
  64. legis-1.0.0/src/legis/pulls/surface.py +77 -0
  65. legis-1.0.0/src/legis/py.typed +0 -0
  66. legis-1.0.0/src/legis/records/__init__.py +1 -0
  67. legis-1.0.0/src/legis/records/override_record.py +39 -0
  68. legis-1.0.0/src/legis/service/__init__.py +59 -0
  69. legis-1.0.0/src/legis/service/errors.py +98 -0
  70. legis-1.0.0/src/legis/service/explain.py +175 -0
  71. legis-1.0.0/src/legis/service/governance.py +616 -0
  72. legis-1.0.0/src/legis/service/source_binding.py +107 -0
  73. legis-1.0.0/src/legis/service/wardline.py +249 -0
  74. legis-1.0.0/src/legis/store/__init__.py +1 -0
  75. legis-1.0.0/src/legis/store/audit_store.py +438 -0
  76. legis-1.0.0/src/legis/store/head_anchor.py +142 -0
  77. legis-1.0.0/src/legis/store/protocol.py +68 -0
  78. legis-1.0.0/src/legis/wardline/__init__.py +1 -0
  79. legis-1.0.0/src/legis/wardline/governor.py +177 -0
  80. legis-1.0.0/src/legis/wardline/ingest.py +533 -0
  81. legis-1.0.0/src/legis/wardline/policy.py +17 -0
  82. legis-1.0.0/src/legis/weft_signing.py +90 -0
legis-1.0.0/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.
legis-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.4
2
+ Name: legis
3
+ Version: 1.0.0
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 :: 5 - Production/Stable
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: cryptography>=42
17
+ Requires-Dist: fastapi>=0.115
18
+ Requires-Dist: pydantic>=2
19
+ Requires-Dist: pyyaml>=6.0
20
+ Requires-Dist: uvicorn[standard]>=0.30
21
+ Requires-Dist: sqlalchemy>=2.0
22
+ Requires-Python: >=3.12
23
+ Project-URL: Homepage, https://github.com/foundryside-dev/legis
24
+ Project-URL: Repository, https://github.com/foundryside-dev/legis
25
+ Project-URL: Issues, https://github.com/foundryside-dev/legis/issues
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Legis
29
+
30
+ Legis is the fourth Weft product: the git/CI and governance side of the suite's common operating picture.
31
+
32
+ > 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.
33
+
34
+ ## Status
35
+
36
+ Legis is at **`1.0.0`** — the gold release. The standalone git/CI surfaces, the graded 2x2 enforcement engine, the agent-programmable policy grammar, SEI-keyed attestations, and the Wardline/Filigree suite combinations are built and tested. The git-rename provider to Loomweave is contract-locked, operative pending Loomweave's committed-range driving.
37
+
38
+ The transport-agnostic service layer (WP-M1) and the agent-facing MCP surface on top of it have landed (`legis mcp`). The MCP surface now declares output schemas across its tools, exposes read-side governance/diagnostic tools (`doctor_get`, `override_list`, `policy_boundary_check`, lineage-honesty reads, `check_report`, `signoff_bind_issue`), and keeps the API/MCP/CLI paths routed through the same service layer instead of duplicating governance decisions.
39
+
40
+ Legis stands itself up with `legis install`: instruction block, `legis-workflow` skill pack, SessionStart hook, `.mcp.json` registration, and the Legis-only `.weft/legis/` ignore rule. `legis doctor [--fix]` provides an operator health view and safe repair for the install + config layer, tagging each problem `[auto-fixable]` or `[operator]` so it is clear what `--fix` will and will not touch. Doctor names enablement paths when governance is unwired (policy cells, Wardline routing), but it reports rather than auto-enabling policy surfaces or touching signing keys.
41
+
42
+ Gold was earned, not declared: 1.0.0 was first cut on 2026-06-09, then re-opened when a P0 governance-honesty false-green (G1 — an absent Wardline `findings` key routing zero defects under a green status) was caught *after* the cut. The fix, the cross-member conformance vector that makes it real, and a small batch of follow-through hardening shipped before final. See the combination matrix below for per-pairing status and `CHANGELOG.md` for the full release notes.
43
+
44
+ ### Last week in practical terms
45
+
46
+ The last week moved Legis from "feature-complete release candidate" to "operationally hardened gold":
47
+
48
+ - **Release and conformance.** PyPI publishing is gated on live Loomweave SEI conformance with required `LOOMWEAVE_URL`, `LOOMWEAVE_LIVE_ORACLE_LOCATOR`, and `LEGIS_LOOMWEAVE_HMAC_KEY`; optional CI-only skips no longer decide release integrity.
49
+ - **Doctor and install hardening.** Doctor validates `.mcp.json` as an executable Legis stdio server, rejects repo-local SessionStart hooks, handles missing roots without crashing, and keeps audit-chain checks report-only instead of initializing truncated stores. Instruction refresh compares the whole owned block to the packaged block, not just the marker token.
50
+ - **Governance honesty.** Wardline dirty unsigned artifacts no longer return transport success when nothing was governed; malformed or missing scan fields fail as malformed input rather than routing zero findings under green. Policy-boundary evidence fingerprints now include semantic decorators such as `pytest.mark.skip`, `parametrize`, and wrapper decorators.
51
+ - **Configuration custody.** Repo `weft.toml` can no longer redirect Legis governance stores; explicit `LEGIS_*_DB` environment variables are the relocation mechanism. The root `.gitignore` ignores only `.weft/legis/`, not the whole shared `.weft/` namespace.
52
+ - **Transport custody.** Loomweave request signing sends the exact canonical bytes it signs and rejects redirects before `X-Weft-*` HMAC headers can leak. Filigree binds intentionally send no `X-Weft-*` transport HMAC headers; the app-level `binding_signature` remains the governance evidence in the JSON body. Loomweave/Filigree remote plaintext remains a dev-only escape hatch that voids response-integrity custody.
53
+
54
+ ## The Weft suite
55
+
56
+ > 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.
57
+
58
+ 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.
59
+
60
+ ```mermaid
61
+ flowchart LR
62
+ Agent["Coding agent"]
63
+ Entity["Entity dossier<br/>one durable identity: SEI"]
64
+ Loomweave["Loomweave<br/>identity authority + fact store"]
65
+ Wardline["Wardline<br/>taint and trust facts"]
66
+ Legis["Legis<br/>governance attestations"]
67
+ Filigree["Filigree<br/>issue associations"]
68
+
69
+ Wardline -->|"taint facts"| Entity
70
+ Loomweave -->|"structure, linkages, lineage"| Entity
71
+ Legis -->|"governance attestations"| Entity
72
+ Filigree -->|"issue associations"| Entity
73
+ Entity -->|"fresh dossier(entity) / traverse(...)"| Agent
74
+ ```
75
+
76
+ **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.
77
+
78
+ ### Operating model
79
+
80
+ One root invariant generates the entire stack:
81
+
82
+ > **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.
83
+
84
+ Consequences:
85
+
86
+ - **Zero *human* config.** Each tool stands itself up preloaded with agent-calibrated instructions — the instruction layer *is* the configuration mechanism.
87
+ - **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.
88
+ - **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.
89
+
90
+ ### The combination matrix
91
+
92
+ 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:
93
+
94
+ | Combination | Capability | Status |
95
+ |---|---|---|
96
+ | **Wardline + Loomweave** | Structure + trust posture in one view (the dossier) | **Live** |
97
+ | **Wardline + Filigree** | Findings become tracked work | **Live** |
98
+ | **Loomweave + Filigree** | Issues bound to live code, surviving refactors | **Partial** — orphans on rename (SEI gap) |
99
+ | **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) |
100
+ | **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) |
101
+ | **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) |
102
+
103
+ 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).
104
+
105
+ SEI is the connective tissue of the whole matrix: one non-conformant binding orphans every combination it participates in.
106
+
107
+ ## What Legis is
108
+
109
+ Legis is the Weft authority for:
110
+
111
+ - project change provenance,
112
+ - branch / commit / pull request context,
113
+ - CI and check context, and
114
+ - governance and attestation context over change.
115
+
116
+ Legis answers: *what changed, in which branch/commit/PR/check context, and what governance or attestation state exists for that change?*
117
+
118
+ ### The governance 2×2
119
+
120
+ 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.
121
+
122
+ ```mermaid
123
+ flowchart TB
124
+ Policy["Policy fires at git/CI boundary"]
125
+ Policy --> Mode{"Configured cell"}
126
+ Mode --> Chill["Chill<br/>surface + recordable override"]
127
+ Mode --> Coached["Coached<br/>LLM wall before override records"]
128
+ Mode --> Structured["Structured<br/>human sign-off gate"]
129
+ Mode --> Protected["Protected<br/>signed verdicts + decay + override-rate gate"]
130
+ Chill --> Trail["SEI-keyed audit trail"]
131
+ Coached --> Trail
132
+ Structured --> Trail
133
+ Protected --> Trail
134
+ ```
135
+
136
+ | | **Judge OFF** | **Judge ON** |
137
+ |---|---|---|
138
+ | **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. |
139
+ | **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. |
140
+
141
+ **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.
142
+
143
+ **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.
144
+
145
+ **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.
146
+
147
+ **Protected (complex, judge on) — the full machinery.** When both dials are up, Legis adds the cryptographic layer over the coached cell:
148
+
149
+ - **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.
150
+ - **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.
151
+ - **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.
152
+ - **Block + escalate** is also available here, with the added constraint that even a human sign-off produces a tamper-bound record.
153
+ - **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.
154
+
155
+ > **What "cryptographic layer" means here.** The HMAC signing is intra-suite *tamper-evidence* — it binds a governance record to SEI-stable code identity and detects after-the-fact edits by an actor who cannot recompute the keyed signature (e.g. a holder of raw DB-file access). The recorded actor is *self-asserted* (not a third-party-authenticated identity), and verification today is same-process Python over v1 canonical JSON. It is **not** a third-party-verifiable, cross-party authenticated cryptographic proof. RFC-8785 canonicalization is the named one-file upgrade for the day a non-Python verifier of a Legis attestation lands.
156
+
157
+ 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.
158
+
159
+ ### Known security limitations
160
+
161
+ Legis is a governance-*honesty* tool, so it states its own residual limits plainly rather than leaving them in source comments:
162
+
163
+ - **The coached cell is a model-robustness wall, not a cryptographic one.** A blocked agent clears the coached gate by convincing the LLM judge; a *malicious prompt injection* that persuades the model will likewise clear it. Structural injection (forging a verdict key) is closed and any transport/parse failure is fail-closed to `BLOCKED`, but the coached cell has no defense-in-depth against a model that is genuinely fooled. For verdicts that must not rest on the model's word, use the **protected** cell, where a judge `ACCEPTED` is advisory only and is downgraded to require operator sign-off (unless a deterministic, non-LLM validator confirms it).
164
+ - **Tamper-evidence assumes the signing key is out of the attacker's reach, and is not absolute against raw DB-file writes.** v3 signing binds each record's chain position, so in-place edits, reordering, and renumbering are detected. A holder of raw write access to the governance `.db` can still *delete* a record and re-chain, or rewrite a record's policy to a non-protected value and strip its protected markers ("modify-to-unsigned"), or truncate the tail — these are residuals of the conceded raw-file-write threat tier. The opt-in `HeadAnchor` mitigates truncation/rewind (with a documented anchor-replay caveat). `legis doctor` now refuses to bless zero-byte or missing-schema audit stores without creating replacement tables, but that is an operator diagnostic, not a substitute for storage custody. Keep the governance store on storage only the operator controls.
165
+ - **The operator session file is a metadata record, not an encrypted vault.** A process with read access to `.weft/legis/operator_session.json` can read the keychain item id and, if it also has keychain access, produce arbitrary signatures during the window. This is the same tier as raw-DB-write access. The mitigation is OS keychain access control (the item accessible only to the legis process user), not file encryption of the session file. The file never holds the key, a passphrase, or a raw age blob — only window metadata and a backend-specific unlock reference (`None` for the age-file/env backends, where re-prompt is the unlock).
166
+ - **Durability tier.** The audit store runs `synchronous=FULL`, but a power loss can still drop the most recent un-checkpointed appends; the trail stays internally consistent (a shortened-but-valid tail), it does not corrupt.
167
+ - **SEI binding integrity rests on TLS by design.** The Weft request HMAC authenticates legis's *requests* to Loomweave; it does not sign Loomweave's *responses*. Filigree binds are transport-open and rely on TLS plus the app-level `binding_signature` and local `BindingLedger` evidence, not on `X-Weft-*` headers. `LEGIS_ALLOW_INSECURE_REMOTE_HTTP=1` still permits plaintext to a remote sibling and therefore **voids that custody seal** (an on-path attacker could forge a stable identity binding) — it logs a warning and is for dev/loopback use only.
168
+
169
+ **The full adversarial threat model is published — attack recipes and all.** Legis holds itself to the honesty bar it enforces, so both pre-1.0 adversarial reviews ship in the open, including the *reproduced* attack recipes for every residual above:
170
+
171
+ - [`docs/release-1.0-risk-audit.md`](docs/release-1.0-risk-audit.md) — the multi-lane pre-release risk audit.
172
+ - [`docs/release-1.0-pre-ship-review.md`](docs/release-1.0-pre-ship-review.md) — the independent second pass that re-attacked the audit's own fixes (and caught a real fail-open the self-verified pass had missed).
173
+
174
+ This is deliberate. Legis is a *"forced me to do the right thing"* discipline, not a hardened security boundary — its worth is the effort the threat model forces and the residual tiers it names honestly (raw DB-file write, model-robustness, response-integrity-rests-on-TLS), not a claim to withstand an attacker who already holds those capabilities. **The system is only as load-bearing as the effort put into it.**
175
+
176
+ ### Graded enforcement
177
+
178
+ Across all four cells, one underlying primitive: when a policy fires, the *cell* decides who answers and what is recorded.
179
+
180
+ - **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.
181
+ - **Block + escalate** — hard gate; a designated human operator must sign off before the gate clears. The complex tier; used for high-stakes decisions.
182
+
183
+ Every cell produces an append-only audit trail keyed on SEI, so the record survives refactors.
184
+
185
+ ## What Legis is not
186
+
187
+ Legis is not:
188
+
189
+ - a federation registry,
190
+ - a hidden suite runtime,
191
+ - a replacement for Loomweave's code identity authority,
192
+ - a replacement for Filigree's workflow authority, or
193
+ - a replacement for Wardline's policy analysis authority.
194
+
195
+ ## How Legis fits into Weft
196
+
197
+ ### Loomweave
198
+
199
+ 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 git-signal provider: the git interface and rename feed are built and contract-locked for Loomweave's SEI matcher, but operative use still depends on Loomweave driving a committed rev-range. That does not move identity authority out of Loomweave.
200
+
201
+ ### Filigree
202
+
203
+ 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.
204
+
205
+ ### Wardline
206
+
207
+ 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.
208
+
209
+ 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.
210
+
211
+ With Legis live, the Wardline + Legis combination unlocks:
212
+ - agent-defined policy, enforced at the git/CI boundary with graded modes;
213
+ - 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
214
+ - 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.
215
+
216
+ ## Stable Entity Identity
217
+
218
+ Legis is an SEI **consumer**, not an authority.
219
+
220
+ - Loomweave mints, persists, re-binds, and resolves SEI.
221
+ - Legis treats SEI as opaque: never derived, parsed, or reinterpreted.
222
+ - Governance attestations key on **SEI** when the subject is a code entity, so attestations survive rename/move.
223
+ - SEI lineage (the append-only event log Loomweave maintains) is Legis's ready-made, tamper-evidence-able audit trail.
224
+ - If Loomweave does not advertise the `sei` capability, Legis degrades honestly rather than guessing.
225
+
226
+ See `docs/federation/sei-conformance.md` for Legis's specific conformance obligations.
227
+
228
+ ## Goal-state checklist (Legis's contribution)
229
+
230
+ Legis is complete when:
231
+
232
+ - [x] Legis ships as opt-in: invisible to a solo project, complete for a regulated one — all four 2×2 cells work end-to-end
233
+ - [x] Governance attestations key on SEI and survive rename/move
234
+ - [x] `lineage(sei)` is consumed as the audit spine for governance records
235
+ - [x] Chill cell (simple, judge off): surface+override is live; agent overrides produce attributable audit events; human reviews async
236
+ - [x] 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
237
+ - [x] 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
238
+ - [x] Structured cell (complex, judge off): human sign-off gate available for high-stakes policies, no model in the critical path
239
+ - [x] Wardline + Legis: Wardline's `--fail-on` / exit codes governed by Legis's policy layer; trust-vocabulary converged to one grammar across the suite
240
+ - [x] Legis governs trust while Wardline analyses it — one judge, not two
241
+ - [x] Filigree + Legis: verification sign-offs and governed issue lifecycle work end-to-end
242
+ - [ ] Git-rename / history signal available for Loomweave's SEI matcher — the git interface and rename-feed are **built and contract-locked**; operative once Loomweave drives a committed rev-range (the one cross-tool gate that remains)
243
+
244
+ ## Repository layout
245
+
246
+ - `docs/guide/` — operator guides: configuration reference and output interpretation
247
+ - `docs/federation/` — Weft-facing contracts and participation notes
248
+ - `docs/design/` — product intent and design notes
249
+ - `docs/superpowers/specs/` — approved design specs
250
+ - `docs/superpowers/plans/` — implementation plans
251
+
252
+ ## Documents
253
+
254
+ **Operator guides (how to configure and read Legis):**
255
+ - `docs/guide/configuration.md` — what to set, what each cell costs to enable, the full env-var/flag reference, and the dev-only escape hatches
256
+ - `docs/guide/reading-legis-output.md` — what you're seeing when an agent acts: the verdict/outcome/status vocabulary and which signals need a human
257
+
258
+ **Design and federation:**
259
+ - `docs/design/legis-charter.md` — authority boundary, operating modes, near-term scope
260
+ - `docs/federation/README.md` — Weft participation overview
261
+ - `docs/federation/sei-conformance.md` — Legis-specific SEI posture and obligations
262
+
263
+ **Security & threat model (published in full, by design):**
264
+ - `docs/release-1.0-risk-audit.md` — the pre-1.0 adversarial risk audit (multi-lane), with reproduced attack recipes for every residual
265
+ - `docs/release-1.0-pre-ship-review.md` — the independent second-pass review that re-attacked the audit's own fixes
266
+
267
+ **Planning:**
268
+ - `docs/superpowers/specs/2026-06-01-legis-federation-repo-design.md` — federation repo design spec
269
+ - `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)
270
+ - `docs/superpowers/plans/2026-06-01-legis-bootstrap.md` — bootstrap implementation plan (docs-first repo)
271
+ - `docs/superpowers/plans/2026-06-01-legis-implementation-sprints.md` — sprint / work-package breakdown of the roadmap
272
+
273
+ **Suite-wide context (lives in wardline/docs/superpowers/specs/):**
274
+ - `2026-06-01-weft-goal-state-case-study.md` — Weft goal state, operating model, combination matrix
275
+ - `2026-06-01-weft-stable-entity-identity-conformance.md` — SEI standard (Legis is a named consumer in §5)
276
+ - `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
277
+
278
+ **Design ancestor:**
279
+ - `/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.
280
+
281
+ This repo stays explicit, narrow, and honest about what exists today.
legis-1.0.0/README.md ADDED
@@ -0,0 +1,254 @@
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.0`** — the gold release. The standalone git/CI surfaces, the graded 2x2 enforcement engine, the agent-programmable policy grammar, SEI-keyed attestations, and the Wardline/Filigree suite combinations are built and tested. The git-rename provider to Loomweave is contract-locked, operative pending Loomweave's committed-range driving.
10
+
11
+ The transport-agnostic service layer (WP-M1) and the agent-facing MCP surface on top of it have landed (`legis mcp`). The MCP surface now declares output schemas across its tools, exposes read-side governance/diagnostic tools (`doctor_get`, `override_list`, `policy_boundary_check`, lineage-honesty reads, `check_report`, `signoff_bind_issue`), and keeps the API/MCP/CLI paths routed through the same service layer instead of duplicating governance decisions.
12
+
13
+ Legis stands itself up with `legis install`: instruction block, `legis-workflow` skill pack, SessionStart hook, `.mcp.json` registration, and the Legis-only `.weft/legis/` ignore rule. `legis doctor [--fix]` provides an operator health view and safe repair for the install + config layer, tagging each problem `[auto-fixable]` or `[operator]` so it is clear what `--fix` will and will not touch. Doctor names enablement paths when governance is unwired (policy cells, Wardline routing), but it reports rather than auto-enabling policy surfaces or touching signing keys.
14
+
15
+ Gold was earned, not declared: 1.0.0 was first cut on 2026-06-09, then re-opened when a P0 governance-honesty false-green (G1 — an absent Wardline `findings` key routing zero defects under a green status) was caught *after* the cut. The fix, the cross-member conformance vector that makes it real, and a small batch of follow-through hardening shipped before final. See the combination matrix below for per-pairing status and `CHANGELOG.md` for the full release notes.
16
+
17
+ ### Last week in practical terms
18
+
19
+ The last week moved Legis from "feature-complete release candidate" to "operationally hardened gold":
20
+
21
+ - **Release and conformance.** PyPI publishing is gated on live Loomweave SEI conformance with required `LOOMWEAVE_URL`, `LOOMWEAVE_LIVE_ORACLE_LOCATOR`, and `LEGIS_LOOMWEAVE_HMAC_KEY`; optional CI-only skips no longer decide release integrity.
22
+ - **Doctor and install hardening.** Doctor validates `.mcp.json` as an executable Legis stdio server, rejects repo-local SessionStart hooks, handles missing roots without crashing, and keeps audit-chain checks report-only instead of initializing truncated stores. Instruction refresh compares the whole owned block to the packaged block, not just the marker token.
23
+ - **Governance honesty.** Wardline dirty unsigned artifacts no longer return transport success when nothing was governed; malformed or missing scan fields fail as malformed input rather than routing zero findings under green. Policy-boundary evidence fingerprints now include semantic decorators such as `pytest.mark.skip`, `parametrize`, and wrapper decorators.
24
+ - **Configuration custody.** Repo `weft.toml` can no longer redirect Legis governance stores; explicit `LEGIS_*_DB` environment variables are the relocation mechanism. The root `.gitignore` ignores only `.weft/legis/`, not the whole shared `.weft/` namespace.
25
+ - **Transport custody.** Loomweave request signing sends the exact canonical bytes it signs and rejects redirects before `X-Weft-*` HMAC headers can leak. Filigree binds intentionally send no `X-Weft-*` transport HMAC headers; the app-level `binding_signature` remains the governance evidence in the JSON body. Loomweave/Filigree remote plaintext remains a dev-only escape hatch that voids response-integrity custody.
26
+
27
+ ## The Weft suite
28
+
29
+ > 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.
30
+
31
+ 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.
32
+
33
+ ```mermaid
34
+ flowchart LR
35
+ Agent["Coding agent"]
36
+ Entity["Entity dossier<br/>one durable identity: SEI"]
37
+ Loomweave["Loomweave<br/>identity authority + fact store"]
38
+ Wardline["Wardline<br/>taint and trust facts"]
39
+ Legis["Legis<br/>governance attestations"]
40
+ Filigree["Filigree<br/>issue associations"]
41
+
42
+ Wardline -->|"taint facts"| Entity
43
+ Loomweave -->|"structure, linkages, lineage"| Entity
44
+ Legis -->|"governance attestations"| Entity
45
+ Filigree -->|"issue associations"| Entity
46
+ Entity -->|"fresh dossier(entity) / traverse(...)"| Agent
47
+ ```
48
+
49
+ **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.
50
+
51
+ ### Operating model
52
+
53
+ One root invariant generates the entire stack:
54
+
55
+ > **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.
56
+
57
+ Consequences:
58
+
59
+ - **Zero *human* config.** Each tool stands itself up preloaded with agent-calibrated instructions — the instruction layer *is* the configuration mechanism.
60
+ - **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.
61
+ - **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.
62
+
63
+ ### The combination matrix
64
+
65
+ 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:
66
+
67
+ | Combination | Capability | Status |
68
+ |---|---|---|
69
+ | **Wardline + Loomweave** | Structure + trust posture in one view (the dossier) | **Live** |
70
+ | **Wardline + Filigree** | Findings become tracked work | **Live** |
71
+ | **Loomweave + Filigree** | Issues bound to live code, surviving refactors | **Partial** — orphans on rename (SEI gap) |
72
+ | **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) |
73
+ | **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) |
74
+ | **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) |
75
+
76
+ 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).
77
+
78
+ SEI is the connective tissue of the whole matrix: one non-conformant binding orphans every combination it participates in.
79
+
80
+ ## What Legis is
81
+
82
+ Legis is the Weft authority for:
83
+
84
+ - project change provenance,
85
+ - branch / commit / pull request context,
86
+ - CI and check context, and
87
+ - governance and attestation context over change.
88
+
89
+ Legis answers: *what changed, in which branch/commit/PR/check context, and what governance or attestation state exists for that change?*
90
+
91
+ ### The governance 2×2
92
+
93
+ 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.
94
+
95
+ ```mermaid
96
+ flowchart TB
97
+ Policy["Policy fires at git/CI boundary"]
98
+ Policy --> Mode{"Configured cell"}
99
+ Mode --> Chill["Chill<br/>surface + recordable override"]
100
+ Mode --> Coached["Coached<br/>LLM wall before override records"]
101
+ Mode --> Structured["Structured<br/>human sign-off gate"]
102
+ Mode --> Protected["Protected<br/>signed verdicts + decay + override-rate gate"]
103
+ Chill --> Trail["SEI-keyed audit trail"]
104
+ Coached --> Trail
105
+ Structured --> Trail
106
+ Protected --> Trail
107
+ ```
108
+
109
+ | | **Judge OFF** | **Judge ON** |
110
+ |---|---|---|
111
+ | **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. |
112
+ | **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. |
113
+
114
+ **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.
115
+
116
+ **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.
117
+
118
+ **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.
119
+
120
+ **Protected (complex, judge on) — the full machinery.** When both dials are up, Legis adds the cryptographic layer over the coached cell:
121
+
122
+ - **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.
123
+ - **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.
124
+ - **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.
125
+ - **Block + escalate** is also available here, with the added constraint that even a human sign-off produces a tamper-bound record.
126
+ - **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.
127
+
128
+ > **What "cryptographic layer" means here.** The HMAC signing is intra-suite *tamper-evidence* — it binds a governance record to SEI-stable code identity and detects after-the-fact edits by an actor who cannot recompute the keyed signature (e.g. a holder of raw DB-file access). The recorded actor is *self-asserted* (not a third-party-authenticated identity), and verification today is same-process Python over v1 canonical JSON. It is **not** a third-party-verifiable, cross-party authenticated cryptographic proof. RFC-8785 canonicalization is the named one-file upgrade for the day a non-Python verifier of a Legis attestation lands.
129
+
130
+ 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.
131
+
132
+ ### Known security limitations
133
+
134
+ Legis is a governance-*honesty* tool, so it states its own residual limits plainly rather than leaving them in source comments:
135
+
136
+ - **The coached cell is a model-robustness wall, not a cryptographic one.** A blocked agent clears the coached gate by convincing the LLM judge; a *malicious prompt injection* that persuades the model will likewise clear it. Structural injection (forging a verdict key) is closed and any transport/parse failure is fail-closed to `BLOCKED`, but the coached cell has no defense-in-depth against a model that is genuinely fooled. For verdicts that must not rest on the model's word, use the **protected** cell, where a judge `ACCEPTED` is advisory only and is downgraded to require operator sign-off (unless a deterministic, non-LLM validator confirms it).
137
+ - **Tamper-evidence assumes the signing key is out of the attacker's reach, and is not absolute against raw DB-file writes.** v3 signing binds each record's chain position, so in-place edits, reordering, and renumbering are detected. A holder of raw write access to the governance `.db` can still *delete* a record and re-chain, or rewrite a record's policy to a non-protected value and strip its protected markers ("modify-to-unsigned"), or truncate the tail — these are residuals of the conceded raw-file-write threat tier. The opt-in `HeadAnchor` mitigates truncation/rewind (with a documented anchor-replay caveat). `legis doctor` now refuses to bless zero-byte or missing-schema audit stores without creating replacement tables, but that is an operator diagnostic, not a substitute for storage custody. Keep the governance store on storage only the operator controls.
138
+ - **The operator session file is a metadata record, not an encrypted vault.** A process with read access to `.weft/legis/operator_session.json` can read the keychain item id and, if it also has keychain access, produce arbitrary signatures during the window. This is the same tier as raw-DB-write access. The mitigation is OS keychain access control (the item accessible only to the legis process user), not file encryption of the session file. The file never holds the key, a passphrase, or a raw age blob — only window metadata and a backend-specific unlock reference (`None` for the age-file/env backends, where re-prompt is the unlock).
139
+ - **Durability tier.** The audit store runs `synchronous=FULL`, but a power loss can still drop the most recent un-checkpointed appends; the trail stays internally consistent (a shortened-but-valid tail), it does not corrupt.
140
+ - **SEI binding integrity rests on TLS by design.** The Weft request HMAC authenticates legis's *requests* to Loomweave; it does not sign Loomweave's *responses*. Filigree binds are transport-open and rely on TLS plus the app-level `binding_signature` and local `BindingLedger` evidence, not on `X-Weft-*` headers. `LEGIS_ALLOW_INSECURE_REMOTE_HTTP=1` still permits plaintext to a remote sibling and therefore **voids that custody seal** (an on-path attacker could forge a stable identity binding) — it logs a warning and is for dev/loopback use only.
141
+
142
+ **The full adversarial threat model is published — attack recipes and all.** Legis holds itself to the honesty bar it enforces, so both pre-1.0 adversarial reviews ship in the open, including the *reproduced* attack recipes for every residual above:
143
+
144
+ - [`docs/release-1.0-risk-audit.md`](docs/release-1.0-risk-audit.md) — the multi-lane pre-release risk audit.
145
+ - [`docs/release-1.0-pre-ship-review.md`](docs/release-1.0-pre-ship-review.md) — the independent second pass that re-attacked the audit's own fixes (and caught a real fail-open the self-verified pass had missed).
146
+
147
+ This is deliberate. Legis is a *"forced me to do the right thing"* discipline, not a hardened security boundary — its worth is the effort the threat model forces and the residual tiers it names honestly (raw DB-file write, model-robustness, response-integrity-rests-on-TLS), not a claim to withstand an attacker who already holds those capabilities. **The system is only as load-bearing as the effort put into it.**
148
+
149
+ ### Graded enforcement
150
+
151
+ Across all four cells, one underlying primitive: when a policy fires, the *cell* decides who answers and what is recorded.
152
+
153
+ - **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.
154
+ - **Block + escalate** — hard gate; a designated human operator must sign off before the gate clears. The complex tier; used for high-stakes decisions.
155
+
156
+ Every cell produces an append-only audit trail keyed on SEI, so the record survives refactors.
157
+
158
+ ## What Legis is not
159
+
160
+ Legis is not:
161
+
162
+ - a federation registry,
163
+ - a hidden suite runtime,
164
+ - a replacement for Loomweave's code identity authority,
165
+ - a replacement for Filigree's workflow authority, or
166
+ - a replacement for Wardline's policy analysis authority.
167
+
168
+ ## How Legis fits into Weft
169
+
170
+ ### Loomweave
171
+
172
+ 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 git-signal provider: the git interface and rename feed are built and contract-locked for Loomweave's SEI matcher, but operative use still depends on Loomweave driving a committed rev-range. That does not move identity authority out of Loomweave.
173
+
174
+ ### Filigree
175
+
176
+ 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.
177
+
178
+ ### Wardline
179
+
180
+ 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.
181
+
182
+ 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.
183
+
184
+ With Legis live, the Wardline + Legis combination unlocks:
185
+ - agent-defined policy, enforced at the git/CI boundary with graded modes;
186
+ - 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
187
+ - 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.
188
+
189
+ ## Stable Entity Identity
190
+
191
+ Legis is an SEI **consumer**, not an authority.
192
+
193
+ - Loomweave mints, persists, re-binds, and resolves SEI.
194
+ - Legis treats SEI as opaque: never derived, parsed, or reinterpreted.
195
+ - Governance attestations key on **SEI** when the subject is a code entity, so attestations survive rename/move.
196
+ - SEI lineage (the append-only event log Loomweave maintains) is Legis's ready-made, tamper-evidence-able audit trail.
197
+ - If Loomweave does not advertise the `sei` capability, Legis degrades honestly rather than guessing.
198
+
199
+ See `docs/federation/sei-conformance.md` for Legis's specific conformance obligations.
200
+
201
+ ## Goal-state checklist (Legis's contribution)
202
+
203
+ Legis is complete when:
204
+
205
+ - [x] Legis ships as opt-in: invisible to a solo project, complete for a regulated one — all four 2×2 cells work end-to-end
206
+ - [x] Governance attestations key on SEI and survive rename/move
207
+ - [x] `lineage(sei)` is consumed as the audit spine for governance records
208
+ - [x] Chill cell (simple, judge off): surface+override is live; agent overrides produce attributable audit events; human reviews async
209
+ - [x] 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
210
+ - [x] 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
211
+ - [x] Structured cell (complex, judge off): human sign-off gate available for high-stakes policies, no model in the critical path
212
+ - [x] Wardline + Legis: Wardline's `--fail-on` / exit codes governed by Legis's policy layer; trust-vocabulary converged to one grammar across the suite
213
+ - [x] Legis governs trust while Wardline analyses it — one judge, not two
214
+ - [x] Filigree + Legis: verification sign-offs and governed issue lifecycle work end-to-end
215
+ - [ ] Git-rename / history signal available for Loomweave's SEI matcher — the git interface and rename-feed are **built and contract-locked**; operative once Loomweave drives a committed rev-range (the one cross-tool gate that remains)
216
+
217
+ ## Repository layout
218
+
219
+ - `docs/guide/` — operator guides: configuration reference and output interpretation
220
+ - `docs/federation/` — Weft-facing contracts and participation notes
221
+ - `docs/design/` — product intent and design notes
222
+ - `docs/superpowers/specs/` — approved design specs
223
+ - `docs/superpowers/plans/` — implementation plans
224
+
225
+ ## Documents
226
+
227
+ **Operator guides (how to configure and read Legis):**
228
+ - `docs/guide/configuration.md` — what to set, what each cell costs to enable, the full env-var/flag reference, and the dev-only escape hatches
229
+ - `docs/guide/reading-legis-output.md` — what you're seeing when an agent acts: the verdict/outcome/status vocabulary and which signals need a human
230
+
231
+ **Design and federation:**
232
+ - `docs/design/legis-charter.md` — authority boundary, operating modes, near-term scope
233
+ - `docs/federation/README.md` — Weft participation overview
234
+ - `docs/federation/sei-conformance.md` — Legis-specific SEI posture and obligations
235
+
236
+ **Security & threat model (published in full, by design):**
237
+ - `docs/release-1.0-risk-audit.md` — the pre-1.0 adversarial risk audit (multi-lane), with reproduced attack recipes for every residual
238
+ - `docs/release-1.0-pre-ship-review.md` — the independent second-pass review that re-attacked the audit's own fixes
239
+
240
+ **Planning:**
241
+ - `docs/superpowers/specs/2026-06-01-legis-federation-repo-design.md` — federation repo design spec
242
+ - `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)
243
+ - `docs/superpowers/plans/2026-06-01-legis-bootstrap.md` — bootstrap implementation plan (docs-first repo)
244
+ - `docs/superpowers/plans/2026-06-01-legis-implementation-sprints.md` — sprint / work-package breakdown of the roadmap
245
+
246
+ **Suite-wide context (lives in wardline/docs/superpowers/specs/):**
247
+ - `2026-06-01-weft-goal-state-case-study.md` — Weft goal state, operating model, combination matrix
248
+ - `2026-06-01-weft-stable-entity-identity-conformance.md` — SEI standard (Legis is a named consumer in §5)
249
+ - `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
250
+
251
+ **Design ancestor:**
252
+ - `/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.
253
+
254
+ This repo stays explicit, narrow, and honest about what exists today.