Prepare 0.2.0 Gate B pilot candidate
Build and verify web migration / verify (push) Has been cancelled
Build and verify web migration / verify (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"system": "guestops-automation-acceptance",
|
||||
"targetGate": "B",
|
||||
"dataClassification": "synthetic-only",
|
||||
"releaseCommit": "0000000000000000000000000000000000000000",
|
||||
"releaseRecordSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"environment": "https://sandbox-guestops.example.invalid",
|
||||
"operator": "REPLACE OPERATOR",
|
||||
"reviewedBy": "REPLACE REVIEWER",
|
||||
"startedAt": "2026-10-01T09:00:00Z",
|
||||
"endedAt": "2026-10-01T10:00:00Z",
|
||||
"reviewedAt": "2026-10-01T11:00:00Z",
|
||||
"faqEvaluation": {"positiveCases": 0, "negativeCases": 0, "falsePositives": 0, "falseNegatives": 0, "reportSha256": "0000000000000000000000000000000000000000000000000000000000000000"},
|
||||
"aiEvaluation": {"casesReviewed": 0, "unsafeDraftsApproved": 0, "reportSha256": "0000000000000000000000000000000000000000000000000000000000000000"},
|
||||
"staffTrained": 0,
|
||||
"monitoringOwner": "REPLACE",
|
||||
"rollbackOwner": "REPLACE",
|
||||
"scenarios": [
|
||||
{"id": "ai-suggestion-review", "status": "not-run", "evidence": []},
|
||||
{"id": "faq-positive-negative", "status": "not-run", "evidence": []},
|
||||
{"id": "faq-stop-control", "status": "not-run", "evidence": []},
|
||||
{"id": "knowledge-curation", "status": "not-run", "evidence": []},
|
||||
{"id": "monitoring-rollback", "status": "not-run", "evidence": []},
|
||||
{"id": "staff-training", "status": "not-run", "evidence": []}
|
||||
],
|
||||
"postAcceptanceState": {"faqMode": "off", "pmsWrites": "disabled", "paymentCreation": "disabled"}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate restricted Gate B knowledge, AI and FAQ acceptance evidence."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
SCENARIOS = {
|
||||
"knowledge-curation", "faq-positive-negative", "faq-stop-control",
|
||||
"ai-suggestion-review", "staff-training", "monitoring-rollback",
|
||||
}
|
||||
|
||||
|
||||
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:
|
||||
return dt.datetime.fromisoformat(value.removesuffix("Z") + "+00:00")
|
||||
except ValueError as error:
|
||||
raise ValueError(f"{field} is not a valid timestamp.") from error
|
||||
|
||||
|
||||
def name(value: object, field: str) -> str:
|
||||
result = str(value or "").strip()
|
||||
require(2 <= len(result) <= 120 and "@" not in result, f"{field} requires a name without an email address.")
|
||||
return result
|
||||
|
||||
|
||||
def refs(value: object, field: str) -> None:
|
||||
require(isinstance(value, list) and 1 <= len(value) <= 10 and all(
|
||||
isinstance(item, str) and 3 <= len(item) <= 200 and "@" not in item for item in value
|
||||
), f"{field} requires safe opaque evidence references.")
|
||||
|
||||
|
||||
def validate(record: object) -> None:
|
||||
require(isinstance(record, dict), "Acceptance record must be a JSON object.")
|
||||
require(record.get("schemaVersion") == 1, "Unsupported automation acceptance schema.")
|
||||
require(record.get("system") == "guestops-automation-acceptance", "system must be guestops-automation-acceptance.")
|
||||
require(record.get("targetGate") == "B", "Automation acceptance must target Gate B.")
|
||||
require(record.get("dataClassification") == "synthetic-only", "Automation acceptance 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.")
|
||||
origin = urlparse(str(record.get("environment", "")))
|
||||
require(origin.scheme == "https" and origin.hostname and origin.path in ("", "/") and not origin.query and not origin.fragment and origin.username is None and origin.password is None,
|
||||
"environment must be an HTTPS origin without credentials, path, query or fragment.")
|
||||
operator = name(record.get("operator"), "operator")
|
||||
reviewer = name(record.get("reviewedBy"), "reviewedBy")
|
||||
require(operator.casefold() != reviewer.casefold(), "operator and reviewedBy must be different people.")
|
||||
started = timestamp(record.get("startedAt"), "startedAt")
|
||||
ended = timestamp(record.get("endedAt"), "endedAt")
|
||||
reviewed = timestamp(record.get("reviewedAt"), "reviewedAt")
|
||||
require(started <= ended <= reviewed, "Acceptance timestamps are out of order.")
|
||||
|
||||
faq = record.get("faqEvaluation")
|
||||
require(isinstance(faq, dict), "faqEvaluation is required.")
|
||||
for field in ("positiveCases", "negativeCases"):
|
||||
require(isinstance(faq.get(field), int) and not isinstance(faq.get(field), bool) and faq[field] > 0,
|
||||
f"faqEvaluation.{field} must be a positive integer.")
|
||||
require(faq.get("falsePositives") == 0 and faq.get("falseNegatives") == 0,
|
||||
"FAQ activation requires zero false positives and zero false negatives.")
|
||||
require(re.fullmatch(r"[0-9a-f]{64}", str(faq.get("reportSha256", ""))) is not None,
|
||||
"faqEvaluation.reportSha256 must identify the retained report.")
|
||||
ai = record.get("aiEvaluation")
|
||||
require(isinstance(ai, dict) and isinstance(ai.get("casesReviewed"), int) and not isinstance(ai.get("casesReviewed"), bool) and ai["casesReviewed"] > 0,
|
||||
"aiEvaluation requires at least one reviewed case.")
|
||||
require(isinstance(ai.get("unsafeDraftsApproved"), int) and not isinstance(ai.get("unsafeDraftsApproved"), bool)
|
||||
and ai["unsafeDraftsApproved"] == 0, "No unsafe AI draft may be approved.")
|
||||
require(re.fullmatch(r"[0-9a-f]{64}", str(ai.get("reportSha256", ""))) is not None,
|
||||
"aiEvaluation.reportSha256 must identify the retained report.")
|
||||
require(isinstance(record.get("staffTrained"), int) and not isinstance(record.get("staffTrained"), bool) and record["staffTrained"] > 0,
|
||||
"At least one pilot staff member must complete training.")
|
||||
name(record.get("monitoringOwner"), "monitoringOwner")
|
||||
name(record.get("rollbackOwner"), "rollbackOwner")
|
||||
|
||||
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)]
|
||||
require(len(ids) == len(scenarios) and len(ids) == len(set(ids)) and set(ids) == SCENARIOS,
|
||||
"Acceptance record requires the exact automation scenario set.")
|
||||
for item in scenarios:
|
||||
require(item.get("status") == "pass", f"Scenario {item['id']} has not passed.")
|
||||
refs(item.get("evidence"), f"Scenario {item['id']}")
|
||||
require(record.get("postAcceptanceState") == {"faqMode": "off", "pmsWrites": "disabled", "paymentCreation": "disabled"},
|
||||
"Acceptance must end with FAQ live mode, PMS writes and payment creation disabled.")
|
||||
|
||||
|
||||
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("Automation acceptance record is structurally complete. This validates the record, not its restricted evidence.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except (OSError, ValueError, json.JSONDecodeError) as error:
|
||||
print(f"Automation acceptance record rejected: {error}", file=__import__("sys").stderr)
|
||||
raise SystemExit(1)
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"system": "guestops-identity-privacy",
|
||||
"targetGate": "B",
|
||||
"releaseCommit": "0000000000000000000000000000000000000000",
|
||||
"releaseRecordSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"environment": "https://sandbox-guestops.example.invalid",
|
||||
"operator": "REPLACE OPERATOR",
|
||||
"reviewedBy": "REPLACE REVIEWER",
|
||||
"startedAt": "2026-10-01T09:00:00Z",
|
||||
"endedAt": "2026-10-01T10:00:00Z",
|
||||
"reviewedAt": "2026-10-01T11:00:00Z",
|
||||
"retention": {
|
||||
"conversationDays": 0,
|
||||
"auditDays": 0,
|
||||
"backupDays": 0,
|
||||
"accountDays": 0,
|
||||
"privacyOwner": "REPLACE",
|
||||
"deletionOwner": "REPLACE",
|
||||
"legalHoldOwner": "REPLACE",
|
||||
"deletionProcedure": "REPLACE-RESTRICTED-REFERENCE",
|
||||
"legalHoldProcedure": "REPLACE-RESTRICTED-REFERENCE"
|
||||
},
|
||||
"providers": {
|
||||
"google": {"status": "pending", "evidence": []},
|
||||
"openai": {"status": "pending", "evidence": []}
|
||||
},
|
||||
"preferencesReviewed": [],
|
||||
"scenarios": [
|
||||
{"id": "account-lifecycle", "status": "not-run", "evidence": []},
|
||||
{"id": "audit-review", "status": "not-run", "evidence": []},
|
||||
{"id": "backup-retention", "status": "not-run", "evidence": []},
|
||||
{"id": "data-inventory", "status": "not-run", "evidence": []},
|
||||
{"id": "known-identity-limitations", "status": "not-run", "evidence": []},
|
||||
{"id": "login-throttling", "status": "not-run", "evidence": []},
|
||||
{"id": "preference-coverage", "status": "not-run", "evidence": []},
|
||||
{"id": "provider-processing", "status": "not-run", "evidence": []},
|
||||
{"id": "retention-deletion", "status": "not-run", "evidence": []},
|
||||
{"id": "role-boundaries", "status": "not-run", "evidence": []},
|
||||
{"id": "session-invalidation", "status": "not-run", "evidence": []}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate restricted Gate B identity, preference and privacy acceptance evidence."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
SCENARIOS = {
|
||||
"role-boundaries", "account-lifecycle", "login-throttling", "session-invalidation",
|
||||
"preference-coverage", "data-inventory", "retention-deletion", "backup-retention",
|
||||
"provider-processing", "audit-review", "known-identity-limitations",
|
||||
}
|
||||
PREFERENCES = {
|
||||
"hotel-name", "timezone", "signature", "ai-drafts", "staff-sending",
|
||||
"faq-mode", "pms-updates", "payment-creation",
|
||||
}
|
||||
|
||||
|
||||
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:
|
||||
return dt.datetime.fromisoformat(value.removesuffix("Z") + "+00:00")
|
||||
except ValueError as error:
|
||||
raise ValueError(f"{field} is not a valid timestamp.") from error
|
||||
|
||||
|
||||
def name(value: object, field: str) -> str:
|
||||
result = str(value or "").strip()
|
||||
require(2 <= len(result) <= 120 and "@" not in result, f"{field} requires a name without an email address.")
|
||||
return result
|
||||
|
||||
|
||||
def refs(value: object, field: str) -> None:
|
||||
require(isinstance(value, list) and 1 <= len(value) <= 10 and all(
|
||||
isinstance(item, str) and 3 <= len(item) <= 200 and "@" not in item for item in value
|
||||
), f"{field} requires safe opaque evidence references.")
|
||||
|
||||
|
||||
def validate(record: object) -> None:
|
||||
require(isinstance(record, dict), "Acceptance record must be a JSON object.")
|
||||
require(record.get("schemaVersion") == 1, "Unsupported identity/privacy acceptance schema.")
|
||||
require(record.get("system") == "guestops-identity-privacy", "system must be guestops-identity-privacy.")
|
||||
require(record.get("targetGate") == "B", "Identity/privacy acceptance must target Gate B.")
|
||||
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.")
|
||||
origin = urlparse(str(record.get("environment", "")))
|
||||
require(origin.scheme == "https" and origin.hostname and origin.path in ("", "/") and not origin.query and not origin.fragment and origin.username is None and origin.password is None,
|
||||
"environment must be an HTTPS origin without credentials, path, query or fragment.")
|
||||
operator = name(record.get("operator"), "operator")
|
||||
reviewer = name(record.get("reviewedBy"), "reviewedBy")
|
||||
require(operator.casefold() != reviewer.casefold(), "operator and reviewedBy must be different people.")
|
||||
started = timestamp(record.get("startedAt"), "startedAt")
|
||||
ended = timestamp(record.get("endedAt"), "endedAt")
|
||||
reviewed = timestamp(record.get("reviewedAt"), "reviewedAt")
|
||||
require(started <= ended <= reviewed, "Acceptance timestamps are out of order.")
|
||||
|
||||
retention = record.get("retention")
|
||||
require(isinstance(retention, dict), "retention decisions are required.")
|
||||
for field in ("conversationDays", "auditDays", "backupDays", "accountDays"):
|
||||
value = retention.get(field)
|
||||
require(isinstance(value, int) and not isinstance(value, bool) and 1 <= value <= 3650,
|
||||
f"retention.{field} must be between 1 and 3650 days.")
|
||||
for field in ("privacyOwner", "deletionOwner", "legalHoldOwner"):
|
||||
name(retention.get(field), f"retention.{field}")
|
||||
for field in ("deletionProcedure", "legalHoldProcedure"):
|
||||
refs([retention.get(field)], f"retention.{field}")
|
||||
|
||||
providers = record.get("providers")
|
||||
require(isinstance(providers, dict) and set(providers) == {"google", "openai"},
|
||||
"providers must contain exactly google and openai decisions.")
|
||||
require(all(isinstance(decision, dict) for decision in providers.values()),
|
||||
"Each provider decision must be an object.")
|
||||
require(providers["google"].get("status") == "accepted", "Google processing must be accepted for the Gate B mailbox pilot.")
|
||||
require(providers["openai"].get("status") in ("accepted", "disabled"), "OpenAI processing must be accepted or disabled.")
|
||||
for provider, decision in providers.items():
|
||||
refs(decision.get("evidence"), f"Provider {provider}")
|
||||
preferences = record.get("preferencesReviewed")
|
||||
require(isinstance(preferences, list) and all(isinstance(item, str) for item in preferences)
|
||||
and set(preferences) == PREFERENCES and len(preferences) == len(PREFERENCES),
|
||||
"preferencesReviewed must contain the exact owner-controlled preference set.")
|
||||
|
||||
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)]
|
||||
require(len(ids) == len(scenarios) and len(ids) == len(set(ids)) and set(ids) == SCENARIOS,
|
||||
"Acceptance record requires the exact identity/privacy scenario set.")
|
||||
for item in scenarios:
|
||||
require(item.get("status") == "pass", f"Scenario {item['id']} has not passed.")
|
||||
refs(item.get("evidence"), f"Scenario {item['id']}")
|
||||
|
||||
|
||||
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("Identity/privacy acceptance record is structurally complete. This validates the record, not its restricted evidence or legal decisions.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except (OSError, ValueError, json.JSONDecodeError) as error:
|
||||
print(f"Identity/privacy acceptance record rejected: {error}", file=__import__("sys").stderr)
|
||||
raise SystemExit(1)
|
||||
@@ -4,19 +4,31 @@
|
||||
"technicalOwner": {"approvedAt": "2026-01-01T00:00:00Z", "name": "REPLACE"}
|
||||
},
|
||||
"capacity": {
|
||||
"hostMetricsSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"observedConcurrency": 0,
|
||||
"observedCpuHeadroomPercent": 0,
|
||||
"observedErrorRate": 1,
|
||||
"observedMemoryHeadroomPercent": 0,
|
||||
"observedP95Ms": 0,
|
||||
"reportSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"targetConcurrency": 1,
|
||||
"targetCpuHeadroomPercent": 25,
|
||||
"targetErrorRate": 0,
|
||||
"targetMemoryHeadroomPercent": 25,
|
||||
"targetP95Ms": 0
|
||||
},
|
||||
"decidedAt": "2026-01-01T00:00:00Z",
|
||||
"decision": "pending",
|
||||
"evidence": [],
|
||||
"pilot": {
|
||||
"businessDaysObserved": 0,
|
||||
"hotelsObserved": 0,
|
||||
"recordSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"stopConditionsObserved": 1,
|
||||
"unresolvedFindings": 1
|
||||
},
|
||||
"releaseCommit": "0000000000000000000000000000000000000000",
|
||||
"releaseRecordSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"schemaVersion": 1,
|
||||
"schemaVersion": 2,
|
||||
"targetGate": "B"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"system": "guestops-supervised-pilot",
|
||||
"targetGate": "B",
|
||||
"releaseCommit": "0000000000000000000000000000000000000000",
|
||||
"releaseRecordSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"environment": "https://sandbox-guestops.example.invalid",
|
||||
"hotelLabel": "approved-pilot-hotel",
|
||||
"hotelCount": 1,
|
||||
"plannedBusinessDays": 5,
|
||||
"owners": {
|
||||
"hotelOwner": "REPLACE HOTEL OWNER",
|
||||
"technicalOwner": "REPLACE TECHNICAL OWNER",
|
||||
"rollbackDecisionMaker": "REPLACE ROLLBACK OWNER"
|
||||
},
|
||||
"startedOn": "2026-10-05",
|
||||
"endedOn": "2026-10-09",
|
||||
"pilotControls": {
|
||||
"pmsWrites": "disabled",
|
||||
"paymentCreation": "disabled",
|
||||
"faqMode": "off",
|
||||
"googleReviewedSending": "accepted"
|
||||
},
|
||||
"dailyReviews": [
|
||||
{"date": "2026-10-05", "status": "not-run", "reviewedBy": "REPLACE", "evidence": []},
|
||||
{"date": "2026-10-06", "status": "not-run", "reviewedBy": "REPLACE", "evidence": []},
|
||||
{"date": "2026-10-07", "status": "not-run", "reviewedBy": "REPLACE", "evidence": []},
|
||||
{"date": "2026-10-08", "status": "not-run", "reviewedBy": "REPLACE", "evidence": []},
|
||||
{"date": "2026-10-09", "status": "not-run", "reviewedBy": "REPLACE", "evidence": []}
|
||||
],
|
||||
"stopConditions": {
|
||||
"tenant-leakage": false,
|
||||
"credential-exposure": false,
|
||||
"data-loss": false,
|
||||
"unapproved-send": false,
|
||||
"duplicate-send": false,
|
||||
"unreconciled-uncertain-send": false,
|
||||
"failed-rollback": false,
|
||||
"monitoring-loss": false
|
||||
},
|
||||
"findings": [],
|
||||
"postPilotState": {
|
||||
"pmsWrites": "disabled",
|
||||
"paymentCreation": "disabled",
|
||||
"faqMode": "off"
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ def timestamp(value: object, field: str) -> dt.datetime:
|
||||
|
||||
def validate(record: object) -> None:
|
||||
require(isinstance(record, dict), "Approval record must be a JSON object.")
|
||||
require(record.get("schemaVersion") == 1, "Unsupported approval schema.")
|
||||
require(record.get("schemaVersion") == 2, "Unsupported approval schema; Gate B 0.2.0 requires schemaVersion 2.")
|
||||
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.")
|
||||
@@ -83,6 +83,8 @@ def validate(record: object) -> None:
|
||||
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.")
|
||||
require(re.fullmatch(r"[0-9a-f]{64}", str(capacity.get("hostMetricsSha256", ""))) is not None,
|
||||
"capacity.hostMetricsSha256 must identify the retained host metrics.")
|
||||
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)
|
||||
@@ -94,6 +96,21 @@ def validate(record: object) -> None:
|
||||
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.")
|
||||
for resource in ("Cpu", "Memory"):
|
||||
target = capacity.get(f"target{resource}HeadroomPercent")
|
||||
observed = capacity.get(f"observed{resource}HeadroomPercent")
|
||||
require(all(isinstance(value, (int, float)) and not isinstance(value, bool) for value in (target, observed))
|
||||
and 25 <= target <= observed <= 100,
|
||||
f"Observed {resource.lower()} headroom must meet the approved target of at least 25 percent.")
|
||||
|
||||
pilot = record.get("pilot")
|
||||
require(isinstance(pilot, dict), "A supervised pilot summary is required.")
|
||||
require(re.fullmatch(r"[0-9a-f]{64}", str(pilot.get("recordSha256", ""))) is not None,
|
||||
"pilot.recordSha256 must identify the retained pilot run record.")
|
||||
require(pilot.get("businessDaysObserved") == 5, "The pilot must cover exactly five business days.")
|
||||
require(pilot.get("hotelsObserved") == 1, "The Gate B pilot must cover exactly one hotel.")
|
||||
require(pilot.get("stopConditionsObserved") == 0, "A pilot with a stop condition cannot be approved.")
|
||||
require(pilot.get("unresolvedFindings") == 0, "All pilot findings must be resolved or explicitly contained.")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate a restricted five-business-day GuestOps pilot run record."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
STOP_CONDITIONS = {
|
||||
"tenant-leakage",
|
||||
"credential-exposure",
|
||||
"data-loss",
|
||||
"unapproved-send",
|
||||
"duplicate-send",
|
||||
"unreconciled-uncertain-send",
|
||||
"failed-rollback",
|
||||
"monitoring-loss",
|
||||
}
|
||||
|
||||
|
||||
def require(condition: bool, message: str) -> None:
|
||||
if not condition:
|
||||
raise ValueError(message)
|
||||
|
||||
|
||||
def date_value(value: object, field: str) -> dt.date:
|
||||
require(isinstance(value, str), f"{field} must be an ISO date.")
|
||||
try:
|
||||
return dt.date.fromisoformat(value)
|
||||
except ValueError as error:
|
||||
raise ValueError(f"{field} must be an ISO date.") from error
|
||||
|
||||
|
||||
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:
|
||||
return dt.datetime.fromisoformat(value.removesuffix("Z") + "+00:00")
|
||||
except ValueError as error:
|
||||
raise ValueError(f"{field} is not a valid timestamp.") from error
|
||||
|
||||
|
||||
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 references(value: object, field: str) -> None:
|
||||
require(isinstance(value, list) and 1 <= len(value) <= 10 and all(
|
||||
isinstance(item, str) and 3 <= len(item) <= 200 and "@" not in item for item in value
|
||||
), f"{field} requires one to ten safe opaque references without email addresses.")
|
||||
|
||||
|
||||
def business_dates(start: dt.date, end: dt.date) -> list[dt.date]:
|
||||
days = []
|
||||
current = start
|
||||
while current <= end:
|
||||
if current.weekday() < 5:
|
||||
days.append(current)
|
||||
current += dt.timedelta(days=1)
|
||||
return days
|
||||
|
||||
|
||||
def validate(record: object) -> None:
|
||||
require(isinstance(record, dict), "Pilot run record must be a JSON object.")
|
||||
require(record.get("schemaVersion") == 1, "Unsupported pilot run schema.")
|
||||
require(record.get("system") == "guestops-supervised-pilot", "Pilot run system must be guestops-supervised-pilot.")
|
||||
require(record.get("targetGate") == "B", "This pilot run record is restricted to Gate B.")
|
||||
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.")
|
||||
|
||||
origin = urlparse(str(record.get("environment", "")))
|
||||
require(origin.scheme == "https" and origin.hostname and origin.path in ("", "/") and not origin.query
|
||||
and not origin.fragment and origin.username is None and origin.password is None,
|
||||
"environment must be an HTTPS origin without credentials, path, query or fragment.")
|
||||
label = str(record.get("hotelLabel", "")).strip()
|
||||
require(3 <= len(label) <= 80 and "@" not in label, "hotelLabel must be a non-email alias.")
|
||||
require(record.get("hotelCount") == 1, "Gate B pilot must contain exactly one hotel.")
|
||||
require(record.get("plannedBusinessDays") == 5, "Gate B pilot must require five business days.")
|
||||
|
||||
owners = record.get("owners")
|
||||
require(isinstance(owners, dict) and set(owners) == {"hotelOwner", "technicalOwner", "rollbackDecisionMaker"},
|
||||
"owners must contain hotelOwner, technicalOwner and rollbackDecisionMaker.")
|
||||
names = {role: safe_name(value, f"owners.{role}") for role, value in owners.items()}
|
||||
require(names["hotelOwner"].casefold() != names["technicalOwner"].casefold(),
|
||||
"hotelOwner and technicalOwner must be different people.")
|
||||
|
||||
start = date_value(record.get("startedOn"), "startedOn")
|
||||
end = date_value(record.get("endedOn"), "endedOn")
|
||||
expected_days = business_dates(start, end)
|
||||
require(len(expected_days) == 5, "Pilot window must contain exactly five business days.")
|
||||
reviews = record.get("dailyReviews")
|
||||
require(isinstance(reviews, list) and len(reviews) == 5, "Exactly five daily reviews are required.")
|
||||
review_dates = []
|
||||
for index, review in enumerate(reviews):
|
||||
require(isinstance(review, dict), f"dailyReviews[{index}] must be an object.")
|
||||
review_date = date_value(review.get("date"), f"dailyReviews[{index}].date")
|
||||
review_dates.append(review_date)
|
||||
require(review.get("status") == "pass", f"Daily review {review_date} has not passed.")
|
||||
safe_name(review.get("reviewedBy"), f"dailyReviews[{index}].reviewedBy")
|
||||
references(review.get("evidence"), f"dailyReviews[{index}].evidence")
|
||||
require(review_dates == expected_days, "Daily reviews must cover each business day in chronological order.")
|
||||
|
||||
controls = record.get("pilotControls")
|
||||
require(controls == {"pmsWrites": "disabled", "paymentCreation": "disabled", "faqMode": "off",
|
||||
"googleReviewedSending": "accepted"},
|
||||
"Pilot controls require accepted reviewed Google sending with PMS, payments and FAQ live mode disabled.")
|
||||
stop_conditions = record.get("stopConditions")
|
||||
require(isinstance(stop_conditions, dict) and set(stop_conditions) == STOP_CONDITIONS,
|
||||
"stopConditions must contain the exact Gate B stop-condition set.")
|
||||
require(all(value is False for value in stop_conditions.values()),
|
||||
"A pilot with an observed stop condition cannot pass.")
|
||||
|
||||
findings = record.get("findings")
|
||||
require(isinstance(findings, list), "findings must be a list, including an empty list when none were found.")
|
||||
finding_ids = []
|
||||
for finding in findings:
|
||||
require(isinstance(finding, dict), "Each finding must be an object.")
|
||||
finding_id = str(finding.get("id", ""))
|
||||
require(re.fullmatch(r"[a-z0-9][a-z0-9-]{2,79}", finding_id) is not None, "Finding IDs must be safe opaque identifiers.")
|
||||
finding_ids.append(finding_id)
|
||||
severity = finding.get("severity")
|
||||
disposition = finding.get("disposition")
|
||||
require(severity in ("critical", "high", "medium", "low"), f"Finding {finding_id} has an invalid severity.")
|
||||
require(disposition in ("resolved", "contained"), f"Finding {finding_id} must be resolved or contained.")
|
||||
references(finding.get("evidence"), f"Finding {finding_id} evidence")
|
||||
require(not (severity in ("critical", "high") and disposition == "contained"),
|
||||
f"Finding {finding_id} is too severe for containment.")
|
||||
if disposition == "contained":
|
||||
containment = finding.get("containment")
|
||||
require(isinstance(containment, dict), f"Finding {finding_id} requires containment details.")
|
||||
safe_name(containment.get("owner"), f"Finding {finding_id} containment owner")
|
||||
require(timestamp(containment.get("expiresAt"), f"Finding {finding_id}.containment.expiresAt").date() > end,
|
||||
f"Finding {finding_id} containment must expire after the pilot.")
|
||||
require(5 <= len(str(containment.get("rollbackTrigger", ""))) <= 300,
|
||||
f"Finding {finding_id} containment requires a rollback trigger.")
|
||||
require(len(finding_ids) == len(set(finding_ids)), "Finding IDs must be unique.")
|
||||
|
||||
require(record.get("postPilotState") == {"pmsWrites": "disabled", "paymentCreation": "disabled", "faqMode": "off"},
|
||||
"Pilot must end with PMS writes, payment creation and FAQ live mode disabled.")
|
||||
|
||||
|
||||
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("Supervised pilot record is structurally complete: five business days passed without a stop condition. This validates the record, not its restricted evidence.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except (OSError, ValueError, json.JSONDecodeError) as error:
|
||||
print(f"Supervised pilot record rejected: {error}", file=__import__("sys").stderr)
|
||||
raise SystemExit(1)
|
||||
Reference in New Issue
Block a user