Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions contracts/preauth-wiring.requirements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"id": "preauth-wiring",
"status": "requirements draft (not a contract; not hashed; nothing approved)",
"recorded_with": "preauth-envelope r5 (RED commit on red/preauth-envelope); extended at r6",
"depends_on": [
"gate-authority (S1)",
"preauth-envelope (S2)"
],
"frozen_requirements": [
"The gate (.github/scripts/lease_tamper.py), the lane (scripts/merge_lane_v5.py) and every other file under .github/ and scripts/ use only preauth.check() and catch only preauth.PreauthRefused. No other preauth name (oracle_paths, load_envelope, read_trust_root, constants, _decide, _check_for_tests), no import of scripts/preauth_verify.py or its _ssh_verify, and no reference to the module object other than .check / .PreauthRefused.",
"No dynamic loading anywhere under .github/ or scripts/: no importlib, runpy, imp, pkgutil or zipimport import; no __import__, eval, exec, compile, spec_from_file_location, SourceFileLoader, exec_module, load_module, run_path or run_module; no sys.modules access; no getattr/hasattr/setattr/delattr with a computed name; no getattr on the preauth module at all.",
"Non-Python files under .github/ and scripts/ (workflows, shell) never import preauth, name preauth_verify, _ssh_verify or check_for_tests, or reach a preauth attribute inline.",
"tests/test_preauth_envelope.py::WiringFreezeTest (all four tests, including the whole-tree scan, the 22 wiring must-fail fixtures and the dynamic trap that makes every preauth name except check and PreauthRefused raise on the lane and gate paths) stays unchanged as a regression suite.",
"The lane and gate load preauth from the BASE checkout's scripts/ directory placed first on sys.path, so `from preauth_verify import _ssh_verify` resolves to the frozen, sha256-pinned scripts/preauth_verify.py; add a call-site test that the loaded verifier's file is that path and its sha256 equals the pin (never a module from the PR head, cwd or another sys.path entry).",
"Add a call-site test that check() is the one preauth entry on the merge and dispatch paths, with every fact measured by the lane itself (revocations, consumed uses, nonces, attempts, bees in flight, ancestry), never a caller-supplied trust root or pin.",
"Must land before any unattended T1/T3 use of envelopes; until then every owner approval stays a typed line.",
"Exceptions: the lane and gate treat any exception from check() other than PreauthRefused as a refusal and never print, log or post its text or traceback (exception text can carry data); they report only PreauthRefused.reason, which is one of the closed REFUSAL_REASONS."
],
"r6_additions_from_grokchat_round5_advisory_high_2": {
"requirement": "Extend wiring_violations (or add a wiring rule in this slice) so each case below is refused, and add these cases verbatim as wiring must-fail fixtures. GROKCHAT demonstrated that after any legitimate `from scripts import preauth`, each reaches a forbidden preauth name while passing the r5 rule.",
"rules": [
"Flag any `.modules` attribute on any object (not only the literal `sys.modules`), so `import sys as s; s.modules[...]` is refused.",
"Flag any dotted chain through `scripts.preauth` (for example `import scripts; scripts.preauth.oracle_paths`); only `preauth.check` / `preauth.PreauthRefused` after a direct import stay allowed.",
"Flag `vars()` anywhere, and any `getattr`/`hasattr` whose target is not a plain local variable, including constant non-private names such as getattr(<module>, \"oracle_paths\").",
"Flag `from scripts import *` (and any star import under .github/ and scripts/).",
"Drive the dynamic trap test through an envelope/T3 decision path on both the lane and the gate (a T3 merge that consults check() with measured facts), not only lane.decide on minimal facts and the gate on a docs-only change."
],
"cases": {
"sys_alias_modules.py": "import sys as system_modules_view\npre = system_modules_view.modules[\"preauth\"]\npre.oracle_paths(\".\")\n",
"getattr_constant_public.py": "import sys as s\ngetattr(s.modules[\"preauth\"], \"oracle_paths\")(\".\")\n",
"package_attr_chain.py": "import scripts\nscripts.preauth.oracle_paths(\".\")\n",
"vars_package.py": "import scripts\nvars(scripts)[\"preauth\"].oracle_paths(\".\")\n",
"from_scripts_star_pkg.py": "from scripts import *\npreauth.oracle_paths(\".\")\n"
}
},
"s1_gate_authority_advisories_recorded_here": {
"note": "From GROKCHAT round 5 on S1 (gate-authority f23d3ab3, approved-ready and unchanged). Recorded here so the wiring slice, which touches the same lane and gate files, picks them up; neither is in S1's frozen tests.",
"items": [
"The live rulesets protect only the default branch, so release/* branches are unprotected (direct push or force-push by any writer), and S1's AC-029 lets the lane merge into such a branch judged by that branch's own gate copy. Either restrict the lane to the repository's default branch (refuse any other base), or have the owner add a ruleset protecting release/* (deletion, non_fast_forward, pull_request, required checks, no bypass) before the lane serves those bases.",
"In the stale-gate compare check, treat entries with status \"copied\" or \"changed\" like \"renamed\": check both filename and previous_filename against the gate-code paths (.github/workflows/gate-authority.yml, .github/workflows/review-rerun.yml, .github/scripts/**), with a test for each status (S1's test covers renamed only)."
]
}
}
2 changes: 1 addition & 1 deletion policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Known gaps: no required reviewer (one maintainer); rizzstack's path-filtered `co
- `merge-lane-v5.md`: what merges, and on what evidence (slice/non-slice, risk tier T1/T3, the review format, carry-forward, the dry run and go-live).
- `outside-review.md`: who may review a pull request, reviewer model routing, what a review bee receives, and how its verdict is validated and posted.
- `identities.md`: the owner, coordinator and reviewer identities on GitHub, key custody, and the migration off the owner's token.
- Planned: `preauth.md`, bounded pre-authorization envelopes the owner approves ahead of time (coordinator program, Phase 2).
- `preauth.md`: bounded pre-authorization envelopes the owner signs ahead of time (coordinator program, Phase 2), the never-pre-authorizable classes, and revocation.
10 changes: 10 additions & 0 deletions policy/allowed_signers
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# rizzstack preauth trust root: public keys only, one per line.
#
# <principal> namespaces="rizzstack-preauth" <ssh-ed25519|sk-ssh-ed25519@openssh.com> <base64-key>
#
# Read-only for every implementer. Its bytes are pinned by tests/test_preauth_envelope.py,
# so adding a key needs a new owner-approved contract. No cert-authority lines, no wildcard
# or negated principals, one principal per line. The private key never leaves the owner's
# machine and is never on the Hermes host, the worker PC or the box.
#
# Empty on purpose: until the owner adds a key here, every envelope is refused.
57 changes: 57 additions & 0 deletions policy/preauth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Signed pre-authorization envelopes

A pre-authorization envelope is one bounded, owner-signed batch: the owner signs the exact
envelope bytes with `ssh-keygen -Y sign` using namespace `rizzstack-preauth`, and the key is
held only by the owner and never on the Hermes host. The signature is checked against
`policy/allowed_signers`, the read-only trust root, and every key line there must also match
the frozen fingerprint pin in the checker. An envelope the owner did not sign is refused.
Typed hashes prove content, not who approved it: only the owner's signature is approval.

An envelope is capped at **7 days**: `expires_at` minus `issued_at` must not exceed seven
days, and `expires_at` must be after `issued_at`. The checker decides one use from measured
facts only and must prove every condition from data; a missing, null, malformed or unprovable
fact is a named refusal, not a pass. The checker is bound to this policy by its sha256.

Agents never create, widen or extend envelopes. Only the owner signs one. Agents may ask for
a specific envelope and may execute exactly the action a valid envelope names, nothing more.

## Revocation

The owner revokes with `revoke preauth <id>`, effective immediately: the envelope id goes on
the measured revocation list before the next decision, and every later use refuses. A nonce
and a consumed-use record make replay visible, and budget counters are read from measured
state, never from the envelope's own claims.

## Never pre-authorizable

Some classes are never pre-authorizable, at any tier, for any budget: changes to the gate,
the merge lane, `policy/**` (including this file and `policy/allowed_signers`), rulesets,
the preauth checker or verifier, secrets handling, force-push, deleting data, and automatic
rollback. An envelope that names one of these, or a case variant of it, is refused. A
pre-authorization can never widen preauth itself.

## The five initial envelopes the owner is asked to consider

Each candidate is proposed with mechanical conditions, and the ledger records every use.

1. **P1 — Re-freeze behind an identical oracle.** A re-freeze of a frozen contract is allowed
only when the frozen test blobs are identical at the old and new source_rev: the same
conftest files, the same pytest config, and the same fixtures, byte-identical. Any added,
removed or changed oracle file refuses; product code may differ. This is not a spec
change.
2. **P2 — Merge one reviewed slice.** Merge a named slice whose RED evidence is present, whose
review packet is byte-identical to the reviewed head, and whose contract, source_rev and
tier match the envelope; at most the signed merge budget.
3. **P3 — Vendor a pinned dependency sync.** Land a dependency order that only updates a
vendored, pinned copy, with the upstream revision named and no other path touched.
4. **P4 — Close a superseding PR.** Close a superseded pull request whose superseding PR is
identified in the envelope; no merges, no branch deletion.
5. **P5 — Dispatch a bounded wave.** Dispatch a wave in dependency order with at most
4 bees in flight, each on a listed contract; a failing health check stops the wave, and an
automatic rollback is a separate action that is never pre-authorizable.

## Ledger and digest

Every decision appends to a ledger: envelope id, nonce, contract_sha256, source_rev, tier,
action, the measured facts it used, and the policy and trust-root sha256 it decided under.
The owner receives a daily digest of the ledger: uses, refusals and remaining budgets.
126 changes: 126 additions & 0 deletions schemas/preauth.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"title": "rizzstack signed pre-authorization envelope",
"description": "One bounded, owner-signed batch: rizzstack.preauth/2. Additional fields are refused.",
"type": "object",
"additionalProperties": false,
"required": [
"schema",
"id",
"issuer",
"issued_at",
"expires_at",
"nonce",
"action_class",
"repos",
"bases",
"contracts",
"review",
"budget",
"conditions",
"max_uses",
"created_from"
],
"properties": {
"schema": {
"type": "string",
"const": "rizzstack.preauth/2"
},
"id": {
"type": "string",
"minLength": 1,
"description": "Envelope id; the unit of revocation and replay accounting."
},
"issuer": {
"type": "string",
"pattern": "^[A-Za-z0-9._@-]{1,64}$",
"description": "The owner principal that signs; ssh-keygen -Y verify identity."
},
"issued_at": {
"type": "string",
"format": "date-time",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
},
"expires_at": {
"type": "string",
"format": "date-time",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
},
"nonce": {
"type": "string",
"minLength": 1
},
"action_class": {
"type": "string",
"enum": [
"merge_slice",
"refreeze_contract",
"vendor_sync",
"close_superseded_pr",
"dispatch_wave"
]
},
"repos": {
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"minLength": 1
}
},
"bases": {
"type": "object",
"additionalProperties": {
"type": "string",
"minLength": 1
}
},
"contracts": {
"type": "array",
"minItems": 1,
"items": {
"type": "object"
}
},
"review": {
"type": "object"
},
"budget": {
"type": "object",
"additionalProperties": false,
"required": [
"max_merges",
"max_bees",
"max_attempts_per_contract"
],
"properties": {
"max_merges": {
"type": "integer",
"minimum": 1
},
"max_bees": {
"type": "integer",
"minimum": 1,
"maximum": 4
},
"max_attempts_per_contract": {
"type": "integer",
"minimum": 1
}
}
},
"conditions": {
"type": "array",
"items": {
"type": "object"
}
},
"max_uses": {
"type": "integer",
"minimum": 1
},
"created_from": {
"type": "string",
"minLength": 1
}
}
}
Loading
Loading