milestone 19 &20
Build and verify web migration / verify (push) Waiting to run

This commit is contained in:
wolf-demon
2026-09-29 20:50:40 +01:00
parent 2e8cf269fb
commit 4dd33c90e1
10 changed files with 492 additions and 2 deletions
+38
View File
@@ -0,0 +1,38 @@
{
"schemaVersion": 1,
"system": "guestops-incident-exercise",
"targetGate": "B",
"dataClassification": "synthetic-only",
"releaseCommit": "0000000000000000000000000000000000000000",
"releaseRecordSha256": "0000000000000000000000000000000000000000000000000000000000000000",
"environment": "https://sandbox-guestops.example.invalid",
"operator": "Exercise operator",
"incidentCommander": "Incident commander",
"reviewedBy": "Independent reviewer",
"startedAt": "2026-09-29T09:00:00Z",
"endedAt": "2026-09-29T10:00:00Z",
"reviewedAt": "2026-09-29T11:00:00Z",
"targetsMinutes": {
"detection": 10,
"containment": 20,
"recovery": 60
},
"observedMinutes": {
"detection": 0,
"containment": 0,
"recovery": 0
},
"scenarios": [
{"id": "alert-and-escalate", "status": "not-run", "evidence": []},
{"id": "controlled-recovery", "status": "not-run", "evidence": []},
{"id": "disable-worker-writes", "status": "not-run", "evidence": []},
{"id": "google-uncertain-send", "status": "not-run", "evidence": []},
{"id": "image-rollback", "status": "not-run", "evidence": []},
{"id": "restore-readiness", "status": "not-run", "evidence": []}
],
"postExerciseState": {
"externalWrites": "disabled",
"faqMode": "off",
"unresolvedOperations": 0
}
}
+132
View File
@@ -0,0 +1,132 @@
#!/usr/bin/env python3
"""Validate a restricted GuestOps incident and rollback exercise record."""
from __future__ import annotations
import argparse
import datetime as dt
import json
from pathlib import Path
import re
from urllib.parse import urlparse
GATE_B_SCENARIOS = {
"alert-and-escalate",
"disable-worker-writes",
"google-uncertain-send",
"restore-readiness",
"image-rollback",
"controlled-recovery",
}
GATE_C_SCENARIOS = GATE_B_SCENARIOS | {
"pms-ambiguous-write",
"payment-ambiguous-create",
}
def require(condition: bool, message: str) -> None:
if not condition:
raise ValueError(message)
def utc_timestamp(value: object, field: str) -> dt.datetime:
require(isinstance(value, str) and value.endswith("Z"), f"{field} must be a UTC timestamp ending in Z.")
try:
parsed = dt.datetime.fromisoformat(value.removesuffix("Z") + "+00:00")
except ValueError as error:
raise ValueError(f"{field} is not a valid timestamp.") from error
require(parsed.tzinfo == dt.timezone.utc, f"{field} must be UTC.")
return parsed
def safe_name(value: object, field: str) -> str:
name = str(value or "").strip()
require(2 <= len(name) <= 120 and "@" not in name, f"{field} requires a name without an email address.")
return name
def validate(record: object) -> None:
require(isinstance(record, dict), "Exercise record must be a JSON object.")
require(record.get("schemaVersion") == 1, "Unsupported exercise record schema.")
require(record.get("system") == "guestops-incident-exercise",
"Exercise record system must be guestops-incident-exercise.")
gate = record.get("targetGate")
require(gate in ("B", "C"), "targetGate must be B or C.")
require(record.get("dataClassification") == "synthetic-only",
"Incident exercises must use synthetic data only.")
require(re.fullmatch(r"[0-9a-f]{40}", str(record.get("releaseCommit", ""))) is not None,
"releaseCommit must be a full lowercase Git SHA.")
require(re.fullmatch(r"[0-9a-f]{64}", str(record.get("releaseRecordSha256", ""))) is not None,
"releaseRecordSha256 must be a SHA-256 digest.")
environment = str(record.get("environment", ""))
parsed_url = urlparse(environment)
require(parsed_url.scheme == "https" and parsed_url.hostname and parsed_url.path in ("", "/")
and not parsed_url.query and not parsed_url.fragment and parsed_url.username is None
and parsed_url.password is None,
"environment must be an HTTPS origin without credentials, path, query or fragment.")
operator = safe_name(record.get("operator"), "operator")
commander = safe_name(record.get("incidentCommander"), "incidentCommander")
reviewer = safe_name(record.get("reviewedBy"), "reviewedBy")
require(len({operator.casefold(), commander.casefold(), reviewer.casefold()}) == 3,
"operator, incidentCommander and reviewedBy must be different people.")
started = utc_timestamp(record.get("startedAt"), "startedAt")
ended = utc_timestamp(record.get("endedAt"), "endedAt")
reviewed = utc_timestamp(record.get("reviewedAt"), "reviewedAt")
require(started <= ended <= reviewed, "Exercise timestamps are out of order.")
targets = record.get("targetsMinutes")
observed = record.get("observedMinutes")
require(isinstance(targets, dict) and isinstance(observed, dict),
"targetsMinutes and observedMinutes are required.")
metric_keys = {"detection", "containment", "recovery"}
require(set(targets) == metric_keys and set(observed) == metric_keys,
"Timing records require exactly detection, containment and recovery.")
for metric in sorted(metric_keys):
target = targets[metric]
actual = observed[metric]
require(isinstance(target, (int, float)) and not isinstance(target, bool) and 0 < target <= 1440,
f"{metric} target must be greater than zero and no more than 1440 minutes.")
require(isinstance(actual, (int, float)) and not isinstance(actual, bool) and 0 <= actual <= target,
f"Observed {metric} time must meet its pre-agreed target.")
scenarios = record.get("scenarios")
require(isinstance(scenarios, list), "scenarios must be a list.")
ids = [item.get("id") for item in scenarios if isinstance(item, dict)]
required = GATE_C_SCENARIOS if gate == "C" else GATE_B_SCENARIOS
require(len(ids) == len(scenarios) and len(ids) == len(set(ids)) and set(ids) == required,
f"Gate {gate} requires the exact incident scenario set.")
for item in scenarios:
scenario_id = item["id"]
require(item.get("status") == "pass", f"Scenario {scenario_id} has not passed.")
evidence = item.get("evidence")
require(isinstance(evidence, list) and 1 <= len(evidence) <= 10 and all(
isinstance(value, str) and 3 <= len(value) <= 200 and "@" not in value
for value in evidence
), f"Scenario {scenario_id} requires safe opaque evidence references without email addresses.")
final_state = record.get("postExerciseState")
require(isinstance(final_state, dict) and final_state == {
"externalWrites": "disabled",
"faqMode": "off",
"unresolvedOperations": 0,
}, "Exercise must end with writes disabled, FAQ mode off and no unresolved operations.")
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("record", type=Path)
args = parser.parse_args()
validate(json.loads(args.record.read_text(encoding="utf-8")))
print("Incident exercise record is structurally complete and passed. This validates the record, not its restricted evidence.")
if __name__ == "__main__":
try:
main()
except (OSError, ValueError, json.JSONDecodeError) as error:
print(f"Incident exercise record rejected: {error}", file=__import__("sys").stderr)
raise SystemExit(1)
+22
View File
@@ -0,0 +1,22 @@
{
"approvals": {
"hotelOwner": {"approvedAt": "2026-01-01T00:00:00Z", "name": "REPLACE"},
"technicalOwner": {"approvedAt": "2026-01-01T00:00:00Z", "name": "REPLACE"}
},
"capacity": {
"observedConcurrency": 0,
"observedErrorRate": 1,
"observedP95Ms": 0,
"reportSha256": "0000000000000000000000000000000000000000000000000000000000000000",
"targetConcurrency": 1,
"targetErrorRate": 0,
"targetP95Ms": 0
},
"decidedAt": "2026-01-01T00:00:00Z",
"decision": "pending",
"evidence": [],
"releaseCommit": "0000000000000000000000000000000000000000",
"releaseRecordSha256": "0000000000000000000000000000000000000000000000000000000000000000",
"schemaVersion": 1,
"targetGate": "B"
}
+112
View File
@@ -0,0 +1,112 @@
#!/usr/bin/env python3
"""Validate a GuestOps supervised-pilot go/no-go record."""
from __future__ import annotations
import argparse
import datetime as dt
import json
from pathlib import Path
import re
GATE_B = {
"release-ci", "debian-host", "persistence", "backup-restore", "google-mailbox",
"automation", "identity-privacy", "inbox-usability", "capacity",
"incident-support", "pilot-findings",
}
GATE_C = GATE_B | {"pms-provider", "payment-provider"}
def require(condition: bool, message: str) -> None:
if not condition:
raise ValueError(message)
def timestamp(value: object, field: str) -> dt.datetime:
require(isinstance(value, str) and value.endswith("Z"), f"{field} must be a UTC timestamp ending in Z.")
try:
parsed = dt.datetime.fromisoformat(value[:-1] + "+00:00")
except ValueError as error:
raise ValueError(f"{field} is not a valid timestamp.") from error
return parsed
def validate(record: object) -> None:
require(isinstance(record, dict), "Approval record must be a JSON object.")
require(record.get("schemaVersion") == 1, "Unsupported approval schema.")
gate = record.get("targetGate")
require(gate in ("B", "C"), "targetGate must be B or C.")
require(record.get("decision") == "approved", "Only an explicit approved decision passes validation.")
require(re.fullmatch(r"[0-9a-f]{40}", str(record.get("releaseCommit", ""))) is not None,
"releaseCommit must be a full lowercase Git SHA.")
require(re.fullmatch(r"[0-9a-f]{64}", str(record.get("releaseRecordSha256", ""))) is not None,
"releaseRecordSha256 must be a SHA-256 digest.")
decided = timestamp(record.get("decidedAt"), "decidedAt")
approvals = record.get("approvals")
require(isinstance(approvals, dict) and set(approvals) == {"hotelOwner", "technicalOwner"},
"Separate hotelOwner and technicalOwner approvals are required.")
approver_names = []
for role, approval in approvals.items():
name = str(approval.get("name", "")).strip() if isinstance(approval, dict) else ""
require(2 <= len(name) <= 120 and "@" not in name,
f"{role} approval requires a named owner without an email address.")
approver_names.append(name.casefold())
require(timestamp(approval.get("approvedAt"), f"{role}.approvedAt") <= decided,
f"{role} approval cannot occur after the decision.")
require(len(set(approver_names)) == 2, "hotelOwner and technicalOwner must be different people.")
evidence = record.get("evidence")
require(isinstance(evidence, list), "evidence must be a list.")
ids = [item.get("id") for item in evidence if isinstance(item, dict)]
required = GATE_C if gate == "C" else GATE_B
require(len(ids) == len(evidence) and len(ids) == len(set(ids)) and set(ids) == required,
f"Gate {gate} requires the exact evidence set.")
for item in evidence:
item_id = item["id"]
status = item.get("status")
require(status in ("pass", "contained"), f"Evidence {item_id} must pass or have approved containment.")
references = item.get("references")
require(isinstance(references, list) and 1 <= len(references) <= 10 and all(isinstance(value, str) and 3 <= len(value) <= 200 and "@" not in value for value in references),
f"Evidence {item_id} requires safe opaque references without email addresses.")
if status == "contained":
containment = item.get("containment")
require(isinstance(containment, dict), f"Evidence {item_id} requires containment details.")
require(2 <= len(str(containment.get("owner", ""))) <= 120, f"Evidence {item_id} containment requires an owner.")
require(timestamp(containment.get("expiresAt"), f"{item_id}.containment.expiresAt") > decided,
f"Evidence {item_id} containment must expire after the decision.")
require(5 <= len(str(containment.get("rollbackTrigger", ""))) <= 300,
f"Evidence {item_id} containment requires a rollback trigger.")
capacity = record.get("capacity")
require(isinstance(capacity, dict), "Capacity thresholds and observations are required.")
require(re.fullmatch(r"[0-9a-f]{64}", str(capacity.get("reportSha256", ""))) is not None,
"capacity.reportSha256 must identify the retained probe report.")
for observed, target in (("observedP95Ms", "targetP95Ms"), ("observedErrorRate", "targetErrorRate")):
values = (capacity.get(observed), capacity.get(target))
require(all(isinstance(value, (int, float)) and not isinstance(value, bool) for value in values)
and 0 <= capacity[observed] <= capacity[target],
f"Capacity {observed} must be within its approved {target}.")
require(capacity["targetP95Ms"] > 0, "Capacity targetP95Ms must be positive.")
require(capacity["targetErrorRate"] <= 1, "Capacity targetErrorRate must be a ratio no greater than 1.")
concurrency = (capacity.get("observedConcurrency"), capacity.get("targetConcurrency"))
require(all(isinstance(value, int) and not isinstance(value, bool) for value in concurrency)
and capacity["observedConcurrency"] >= capacity["targetConcurrency"] > 0,
"Observed concurrency must meet the approved positive target.")
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("record", type=Path)
args = parser.parse_args()
validate(json.loads(args.record.read_text(encoding="utf-8")))
print("Pilot approval record is structurally complete and approved. This validates the record, not its restricted evidence.")
if __name__ == "__main__":
try:
main()
except (OSError, ValueError, json.JSONDecodeError) as error:
print(f"Pilot approval rejected: {error}", file=__import__("sys").stderr)
raise SystemExit(1)