GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mcpx): validate spec-parity input shapes by dezren39 · Pull Request #7046 · developing-today/code

fix(mcpx): validate spec-parity input shapes #7046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
dezren39 merged 2 commits into main from queue/11074-6852-spec-parity-shape-validation
Nov 11, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(mcpx): validate spec-parity input shapes #7046

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
412ef69
fix(mcpx): validate spec parity input shapes
Nov 8, 2026
0151da5
test(mcpx): property-cover the spec-parity shape invariant (Codex P1,…
Nov 11, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

89 changes: 84 additions & 5 deletions 89 pkgs/mcpx/scripts/spec-parity.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,70 @@ def parse(ts):
return dt.datetime.strptime(ts, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=dt.timezone.utc)


class BadInput(Exception):
def __init__(self, field, message):
super().__init__(message)
self.field = field
self.message = message


def load_json(raw, field):
try:
return json.loads(raw)
except json.JSONDecodeError:
raise BadInput(field, "is not valid JSON") from None


def require_string_list(value, field):
if not isinstance(value, list) or any(not isinstance(item, str) for item in value):
raise BadInput(field, "must be a JSON array of strings")


def validate_timestamp(record, name, field):
if field not in record:
return
value = record[field]
if not isinstance(value, str):
raise BadInput(f"{name}.{field}", "must be a parseable timestamp")
try:
parse(value)
except ValueError:
raise BadInput(f"{name}.{field}", "must be a parseable timestamp") from None


def validate_record(value, name, *, timestamps=(), strings=(), string_lists=()):
if value is None:
return
if not isinstance(value, dict):
raise BadInput(f"{name} record", "must be a JSON object or null")
record = value
for field in timestamps:
validate_timestamp(record, name, field)
for field in strings:
if field in record and not isinstance(record[field], str):
raise BadInput(f"{name}.{field}", "must be a string")
for field in string_lists:
if field in record:
require_string_list(record[field], f"{name}.{field}")
if name == "failure" and "count" in record:
count = record["count"]
if isinstance(count, bool) or not isinstance(count, int) or count < 0:
raise BadInput("failure.count", "must be a non-negative integer")
if name == "failure" and record.get("count", 0) > 0 and "first_timestamp" not in record:
raise BadInput("failure.first_timestamp", "is required when failure.count is positive")


def could_not_read(summary, out, field, message):
with open(summary, "a") as f:
f.write(f"\n## Spec parity: ❌ could not read {field}\n\n{field}: {message}.\n")
os.makedirs(out, exist_ok=True)
with open(os.path.join(out, "status"), "w") as f:
f.write("error")
with open(os.path.join(out, "sleep"), "w") as f:
f.write("0")
return 0


def hours(a, b):
return (b - a).total_seconds() / 3600.0

Expand Down Expand Up @@ -186,9 +250,26 @@ def decide(mcpx, suite, now, run, success, failure, on_main, allow_mcpx=(), allo

def main(argv):
(mcpx_raw, suite_raw, now, run, succ_raw, fail_raw, on_main, summary, out) = argv[1:10]
allow_mcpx = json.loads(argv[10]) if len(argv) > 10 and argv[10].strip() else []
allow_suite = json.loads(argv[11]) if len(argv) > 11 and argv[11].strip() else []
mcpx, suite = json.loads(mcpx_raw), json.loads(suite_raw)
try:
allow_mcpx = load_json(argv[10], "MCPX allow list") if len(argv) > 10 and argv[10].strip() else []
allow_suite = load_json(argv[11], "suite allow list") if len(argv) > 11 and argv[11].strip() else []
mcpx = load_json(mcpx_raw, "MCPX revisions")
suite = load_json(suite_raw, "suite revisions")
require_string_list(mcpx, "MCPX revisions")
require_string_list(suite, "suite revisions")
require_string_list(allow_mcpx, "MCPX allow list")
require_string_list(allow_suite, "suite allow list")
success = load_json(succ_raw, "success record") if succ_raw.strip() else None
failure = load_json(fail_raw, "failure record") if fail_raw.strip() else None
validate_record(success, "success", timestamps=("timestamp",), strings=("run",),
string_lists=("specs",))
validate_record(failure, "failure", timestamps=("first_timestamp", "latest_timestamp"),
strings=("first_run", "latest_run"))
parse(now)
except BadInput as exc:
return could_not_read(summary, out, exc.field, exc.message)
except ValueError:
return could_not_read(summary, out, "now", "must be a parseable timestamp")
if not mcpx or not suite:
with open(summary, "a") as f:
f.write("\n## Spec parity: ❌ could not read the lists\n\n"
Expand All @@ -198,8 +279,6 @@ def main(argv):
open(os.path.join(out, "status"), "w").write("error")
open(os.path.join(out, "sleep"), "w").write("0")
return 0
success = json.loads(succ_raw) if succ_raw.strip() else None
failure = json.loads(fail_raw) if fail_raw.strip() else None
status, sleep, new_s, new_f, lines = decide(mcpx, suite, now, run, success, failure,
on_main == "true", allow_mcpx, allow_suite)
os.makedirs(out, exist_ok=True)
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.