Files
rune/scripts/admit_wave_alert_gateway.py
T
Nick 251b7a105f feat(runtime): alert gateway 4.4 — four honest types, toggles, urgent override, digests
New module alert-gateway (library + thin shell per the law): info/
warning/urgent/critical with honest severity (unknown refused, never
re-graded); per-channel toggles; background-only + destructive-permission
urgent override (8-row matrix); evidence-required law (bare alerts
refused, journal untouched); 2h absence digest severity-ordered; one
real channel (bell) — desktop/gateway/webhook honestly stubbed, receipts
carry Stub:true, never claim Delivered. 12/12 frozen tests red-first.
Main-session verify: suite green own run.
2026-10-16 22:58:52 +01:00

109 lines
4.0 KiB
Python

"""Admission dispatch for the alert-gateway wave (spec 4.4 runtime side).
classify + activate + admit (the headless scaffolding entry law,
tests/test_construction_admission.py pattern): the alert-gateway Go
module build on the existing rune project, user-dispatch approved.
"""
import json
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
from rune import construction_activation as cact # noqa: E402
from rune import construction_admission as cadm # noqa: E402
from rune import construction_mode as cmode # noqa: E402
from rune import scaffold as sc # noqa: E402
ROOT = os.path.join(os.path.dirname(__file__), "..")
OBJECTIVE = (
"build the spec 4.4 runtime-side alert gateway as a new Go module "
"(library + thin shell): four alert types (info/warning/urgent/critical) "
"with an honest severity mapping, toggleable platform-general channels "
"(desktop/sound/gateway/webhook adapters as interfaces, one real impl — "
"terminal-bell sound — the webhook an honestly marked stub), "
"background-only firing with the urgent override (destructive-permission "
"urgent fires focused), evidence-bearing alerts (bare ones refused), and "
"long-absence digest composition (>=2h threshold, severity-ordered "
"sections, empty omitted); frozen tests written red-first"
)
AFFECTED = [
"src/go/alert-gateway/go.mod",
"src/go/alert-gateway/main.go",
"src/go/alert-gateway/internal/gateway/types.go",
"src/go/alert-gateway/internal/gateway/channels.go",
"src/go/alert-gateway/internal/gateway/gateway.go",
"src/go/alert-gateway/internal/gateway/digest.go",
"src/go/alert-gateway/internal/gateway/cli.go",
"src/go/alert-gateway/internal/gateway/toggle_test.go",
"src/go/alert-gateway/internal/gateway/override_test.go",
"src/go/alert-gateway/internal/gateway/severity_test.go",
"src/go/alert-gateway/internal/gateway/evidence_test.go",
"src/go/alert-gateway/internal/gateway/digest_test.go",
]
def main() -> int:
store = os.path.join(ROOT, "store", "scaffold")
scaffold = sc.Scaffold(store, "rune")
md = cmode.classify_mode(
OBJECTIVE,
target_project="rune",
project_exists=True,
affected_surface=AFFECTED,
)
print("classified mode:", md.mode)
need = {
"need_id": "need-wave-alert-gateway",
"objective": OBJECTIVE,
"origin": "worker",
"project": "rune",
"task_ref": "wave-alert-gateway",
"affected_surface": AFFECTED,
"evidence_refs": [
"docs/openspec/changes/add-native-rune-tui/tasks.md",
"src/go/event-bus/main.go",
"src/go/event-bus/internal/eventbus/bus.go",
],
}
act = cact.activate(md, need=need, scaffold=scaffold,
builder="wave-alert-gateway")
print("activated:", act.get("activated"), act.get("mode"))
env = cadm.admit(
act,
objective=OBJECTIVE,
builder="wave-alert-gateway",
affected_surface=AFFECTED,
evidence_refs=need["evidence_refs"],
origin="worker",
task_ref="wave-alert-gateway",
expected_new_entities=[
"src/go/alert-gateway (Go module)",
"src/go/alert-gateway/internal/gateway (package)",
],
expected_runtime_effects=[
"evidence-bearing alerts fire to toggleable channels under "
"background-only + urgent-override law",
"long-absence (>=2h) digest composes severity-ordered sections "
"with empty sections omitted",
],
verification_obligations=[
"go test ./... in src/go/alert-gateway/ green (frozen suites)",
"henxels check holds for the new module",
],
approval_ref="user:wave-alert-gateway dispatch",
contract_id="ADMIT-wave-alert-gateway",
project_store=store,
project_id="rune",
)
print(json.dumps(env, indent=2, default=str)[:2400])
return 0 if env.get("success") else 1
if __name__ == "__main__":
sys.exit(main())