Skip to content
Open
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
7 changes: 5 additions & 2 deletions .github/workflows/fullrun-compare.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Compare six real patcher installations
name: Compare real patcher installations against the packaged patcher
on:
workflow_call:
inputs:
game: {type: string, required: true}
# JSON list of installed routes, e.g. '["cli","gui"]' or '["cli"]'.
modes: {type: string, default: '["cli","gui"]'}
secrets:
CACHE_ENCRYPTION_KEY: {required: true}
DIAGNOSTICS_ENCRYPTION_KEY: {required: false}
Expand All @@ -26,11 +28,12 @@ jobs:
- name: Verify same-run provenance and compare every component and final tree
env:
GAME: ${{ inputs.game }}
MODES: ${{ join(fromJSON(inputs.modes), ',') }}
GITHUB_TOKEN: ${{ github.token }}
CACHE_ENCRYPTION_KEY: ${{ secrets.CACHE_ENCRYPTION_KEY }}
run: |
umask 077
python tools/modsync-ci/patcher_comparison_artifacts.py --game "$GAME" \
python tools/modsync-ci/patcher_comparison_artifacts.py --game "$GAME" --modes "$MODES" \
--work-dir "$RUNNER_TEMP/comparison-inputs" --output-dir "$RUNNER_TEMP/comparison-evidence"
- name: Retain complete encrypted file differences
if: ${{ success() || failure() }}
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/fullrun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,17 @@ jobs:
MOD_CACHE_S3_ENDPOINT: ${{ vars.MOD_CACHE_BUCKET && secrets.MOD_CACHE_S3_ENDPOINT || '' }}
comparison:
needs: [plan, install]
if: ${{ !cancelled() && (needs.plan.outputs.operation == 'full' || needs.plan.outputs.operation == 'install') && contains(fromJSON(needs.plan.outputs.modes || '[]'), 'cli') && contains(fromJSON(needs.plan.outputs.modes || '[]'), 'gui') }}
# Every installation plan runs all three patcher backends per route, so every
# one is compared against the packaged-patcher lane, for one route or both.
if: ${{ !cancelled() && (needs.plan.outputs.operation == 'full' || needs.plan.outputs.operation == 'install') }}
strategy:
fail-fast: false
matrix:
game: ${{ fromJSON(needs.plan.outputs.games) }}
uses: ./.github/workflows/fullrun-compare.yml
with:
game: ${{ matrix.game }}
modes: ${{ needs.plan.outputs.modes }}
secrets:
CACHE_ENCRYPTION_KEY: ${{ secrets.CACHE_ENCRYPTION_KEY }}
DIAGNOSTICS_ENCRYPTION_KEY: ${{ !vars.DIAGNOSTICS_ENCRYPTION_RECIPIENT && secrets.DIAGNOSTICS_ENCRYPTION_KEY || '' }}
Expand Down Expand Up @@ -280,7 +283,7 @@ jobs:
OPERATION: ${{ needs.plan.outputs.operation || 'check' }}
REQUIRE_DOWNLOADER: ${{ needs.plan.outputs.release_candidate || 'false' }}
REQUIRE_PRODUCTION: ${{ needs.plan.outputs.operation == 'full' || needs.plan.outputs.operation == 'install' }}
REQUIRE_COMPARISON: ${{ (needs.plan.outputs.operation == 'full' || needs.plan.outputs.operation == 'install') && contains(fromJSON(needs.plan.outputs.modes || '[]'), 'cli') && contains(fromJSON(needs.plan.outputs.modes || '[]'), 'gui') }}
REQUIRE_COMPARISON: ${{ needs.plan.outputs.operation == 'full' || needs.plan.outputs.operation == 'install' }}
run: python tools/modsync-ci/fullrun_contract.py aggregate --operation "$OPERATION" --output "$RUNNER_TEMP/fullrun-result.json"
- name: Retain public requested-scope verdict
if: ${{ success() || failure() }}
Expand Down
2 changes: 1 addition & 1 deletion COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5357,7 +5357,7 @@ The full installation matrix selects OdyPatcher, HoloPatcher and each mod's orig

CI prints the actual ModSync commands and follows their stdout and stderr while they run. The desktop's `--stream-output` option includes complete installation events. Unix external process execution forwards child output to stderr while preserving structured CLI stdout. Public output is credential-redacted and prefixed against workflow-command injection. Complete raw logs are retained in encrypted diagnostics, with explicit resource limits reported as failures. Fresh patcher logs are also emitted when a process fails. Retained patcher output directories that may contain game files receive an additional envelope using the existing game-cache key before entering diagnostics.

The comparison exporter verifies committed production Store boundaries and records every game file's hash, size and permissions after each component and at completion. Six successful installations are judged against the lane that runs each mod's own packaged patcher (`mod-packaged`), which is authoritative: per route, OdyPatcher and HoloPatcher are each compared with `mod-packaged`, and the `mod-packaged` GUI route with its CLI route. Between backends on the same route, trees are compared after preparation, after every component that runs a Patcher operation, and at completion; a component without a patcher runs identical engine code in every backend lane and is not compared on its own. The CLI-versus-GUI pair installs every component through different code, so it is compared after every component. Any difference fails the comparison gate and names the non-authoritative lane as incorrect, with its first differing boundary. Missing lanes, failed execution and invalid evidence fail the comparison gate. Same-run encrypted manifests use the existing game-cache key for comparison access, while complete diagnostics and private differences use the independent diagnostics recipient. Hosted six-way installation and comparison verification remains pending.
The comparison exporter verifies committed production Store boundaries and records every game file's hash, size and permissions after each component and at completion. Every installation plan runs and requires this comparison, whether it installs one route (three lanes) or both (six lanes). A plan whose selected components run no Patcher operation fails the comparison as vacuous instead of passing. The installations are judged against the lane that runs each mod's own packaged patcher (`mod-packaged`), which is authoritative: per route, OdyPatcher and HoloPatcher are each compared with `mod-packaged`, and the `mod-packaged` GUI route with its CLI route. Between backends on the same route, trees are compared after preparation, after every component that runs a Patcher operation, and at completion; a component without a patcher runs identical engine code in every backend lane and is not compared on its own. The CLI-versus-GUI pair installs every component through different code, so it is compared after every component. Any difference fails the comparison gate and names the non-authoritative lane as incorrect, with its first differing boundary. Missing lanes, failed execution and invalid evidence fail the comparison gate. Same-run encrypted manifests use the existing game-cache key for comparison access, while complete diagnostics and private differences use the independent diagnostics recipient. Hosted six-way installation and comparison verification remains pending.

Checkpoint ancestry validation streams full documents into a compact authenticated index. Selected documents are freshly checked against their complete digest, session identity and unchanged HEAD. Per-document bounds and all ancestry, definition-prefix, backend, finalization and lineage checks remain enforced. The aggregate validation budget supports full-guide histories above the former 256 MiB ceiling. The production `checkpoint export-history` command authenticates all finalized lineage boundaries and verifies each distinct content object once, then publishes a bounded file-backed index after checking unchanged session and HEAD identities. Comparison export uses this command instead of launching repeated whole-inventory verification. Actual full-guide coverage remains subject to the hosted installation gate.
### OdyPatcher source boundary and explicit executable selection
Expand Down
40 changes: 26 additions & 14 deletions tools/modsync-ci/patcher_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,14 @@ def differences(left, right):
return changes


def comparison_pairs():
def comparison_pairs(modes=MODES):
"""(reference, candidate) cells. Each backend is held against the packaged-patcher
lane of the same route; the packaged GUI route is held against its CLI route."""
pairs = [((AUTHORITY, mode), (backend, mode)) for mode in MODES
lane of the same route; when both routes ran, the packaged GUI route is held
against its CLI route."""
pairs = [((AUTHORITY, mode), (backend, mode)) for mode in modes
for backend in BACKENDS if backend != AUTHORITY]
pairs.append(((AUTHORITY, "cli"), (AUTHORITY, "gui")))
if set(modes) == set(MODES):
pairs.append(((AUTHORITY, "cli"), (AUTHORITY, "gui")))
return pairs


Expand All @@ -435,13 +437,17 @@ def route_boundaries(keys):
return [key for key in keys if key != "sessionBaseline"]


def judge(trees, operations, load_tree):
def judge(trees, operations, load_tree, modes=MODES):
"""Compare every candidate lane with its reference after each relevant component.

trees maps (backend, mode) to an ordered {boundary key: handle}; load_tree(handle)
returns that boundary's game tree. Returns (comparisons, wrong_lanes)."""
# With no Patcher operation, every lane installs the same instructions with no
# patcher in play, so equal trees would prove nothing about any patcher.
require(operations, "No selected component runs a Patcher operation; the patcher "
"comparison would be vacuous")
comparisons, wrong = [], []
for reference, candidate in comparison_pairs():
for reference, candidate in comparison_pairs(modes):
ordered = list(trees[reference])
keys = (route_boundaries(ordered) if reference[0] == candidate[0]
else patcher_boundaries(ordered, operations))
Expand Down Expand Up @@ -483,7 +489,11 @@ def verdict(wrong, game):


def compare(args):
require(len(args.receipt) == 6, "Exactly six independently exported receipts are required")
modes = tuple(getattr(args, "modes", None) or MODES)
require(modes and set(modes) <= set(MODES) and len(set(modes)) == len(modes), "Unsupported route set")
expected_cells = len(BACKENDS) * len(modes)
require(len(args.receipt) == expected_cells,
f"Exactly {expected_cells} independently exported receipts are required")
lanes = []
cells = set()
for path in map(Path, args.receipt):
Expand All @@ -501,7 +511,7 @@ def compare(args):
and re.fullmatch(r"[0-9a-f]{40}", receipt["engine_sha"]) is not None,
"Invalid source or engine digest")
cell = (receipt["backend"], receipt["mode"])
require(cell in set(itertools.product(BACKENDS, MODES)) and cell not in cells,
require(cell in set(itertools.product(BACKENDS, modes)) and cell not in cells,
"Repeated or unsupported comparison cell")
cells.add(cell)
root = path.parent
Expand Down Expand Up @@ -594,19 +604,19 @@ def compare(args):
require(trees["sessionBaseline"][1]["game_tree_sha256"] == receipt["baseline_game_tree_sha256"]
and list(trees.values())[-1][1]["game_tree_sha256"] == receipt["final_game_tree_sha256"],
"Baseline or final tree digest differs")
require(len({lane[0]["session_chain"][-1]["session_id"] for lane in lanes}) == 6,
"Six cells reused an installation session")
for mode in MODES:
require(len({lane[0]["session_chain"][-1]["session_id"] for lane in lanes}) == expected_cells,
"Comparison cells reused an installation session")
for mode in modes:
require(len({receipt["binary_sha256"] for receipt, _ in lanes if receipt["mode"] == mode}) == 1,
"Backend cells used different binaries for the same route")
output = Path(args.output_dir)
output.mkdir(mode=0o700, parents=True, exist_ok=False)
cells = {(receipt["backend"], receipt["mode"]): (receipt, trees) for receipt, trees in lanes}
authority = cells[(AUTHORITY, MODES[0])][0]
authority = cells[(AUTHORITY, modes[0])][0]
require(all(receipt["patcher_operations"] == authority["patcher_operations"] for receipt, _ in lanes),
"Lanes disagree on which components run a Patcher operation")
comparisons, wrong = judge({cell: trees for cell, (_, trees) in cells.items()},
authority["patcher_operations"], load_boundary)
authority["patcher_operations"], load_boundary, modes)
total, pairs = 0, []
for pair_index, result in enumerate(comparisons):
pair = {"reference": result["reference"], "candidate": result["candidate"], "boundaries": []}
Expand All @@ -627,7 +637,7 @@ def compare(args):
pairs.append(pair)
write(output / "private-diff.json", {"schema": SCHEMA, "game": first["game"], "authority": AUTHORITY,
"pairs": pairs})
write(output / "summary.json", {"schema": SCHEMA, "game": first["game"], "cells": 6,
write(output / "summary.json", {"schema": SCHEMA, "game": first["game"], "cells": expected_cells, "modes": list(modes),
"pairs": len(pairs), "differences": total, "equal": total == 0,
"authority": AUTHORITY, "wrong_lanes": wrong,
"patcher_components": len({str(op[0]).lower() for op in
Expand All @@ -650,6 +660,8 @@ def main():
capture.add_argument("--mode", required=True, choices=MODES)
comparison = sub.add_parser("compare")
comparison.add_argument("--receipt", action="append", required=True)
comparison.add_argument("--mode", dest="modes", action="append", choices=MODES,
help="installed route; repeat for both (default: cli and gui)")
comparison.add_argument("--output-dir", required=True)
args = parser.parse_args()
try:
Expand Down
19 changes: 13 additions & 6 deletions tools/modsync-ci/patcher_comparison_artifacts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Authenticate six current-run encrypted comparison exports and compare them."""
"""Authenticate the current run's encrypted comparison exports (three backends per
installed route) and compare them."""

import argparse
import contextlib
Expand Down Expand Up @@ -97,7 +98,7 @@ def validate_artifact(artifact, name, repository, expected, source):
"Comparison artifact belongs to another source/run/repository")


def selected_artifacts(api, repository, expected, source, game):
def selected_artifacts(api, repository, expected, source, game, modes=comparison.MODES):
found = []
for page in range(1, 21):
response = api.get(f"/actions/runs/{expected['run_id']}/artifacts?per_page=100&page={page}")
Expand All @@ -113,7 +114,7 @@ def selected_artifacts(api, repository, expected, source, game):
else:
raise ValueError("Run artifact pagination exceeded bound")
selected = []
for backend, mode in itertools.product(comparison.BACKENDS, comparison.MODES):
for backend, mode in itertools.product(comparison.BACKENDS, modes):
name = artifact_name(game, backend, mode, expected)
matches = [artifact for artifact in found if artifact.get("name") == name]
require(len(matches) == 1, "Missing or duplicate current comparison cell artifact")
Expand All @@ -124,7 +125,7 @@ def selected_artifacts(api, repository, expected, source, game):
require(all(fresh[key] == artifact[key] for key in ("id", "name", "digest", "size_in_bytes", "workflow_run")),
"Comparison artifact metadata changed before download")
selected.append((backend, mode, fresh))
require(len({artifact["id"] for _, _, artifact in selected}) == 6,
require(len({artifact["id"] for _, _, artifact in selected}) == len(comparison.BACKENDS) * len(modes),
"Comparison cells reused an artifact")
return selected

Expand Down Expand Up @@ -355,7 +356,12 @@ def main():
parser.add_argument("--game", required=True, choices=("k1", "k2"))
parser.add_argument("--work-dir", required=True)
parser.add_argument("--output-dir", required=True)
parser.add_argument("--modes", default=",".join(comparison.MODES),
help="comma-separated routes the run installed (cli, gui or both)")
args = parser.parse_args()
modes = tuple(mode for mode in comparison.MODES if mode in args.modes.split(","))
if not modes or len(modes) != len(set(args.modes.split(","))):
parser.error("--modes must name cli, gui or both")
os.umask(0o077)
try:
expected, source = expected_identity(os.environ)
Expand All @@ -364,7 +370,7 @@ def main():
work.mkdir(mode=0o700, parents=True)
api = API()
repository, _ = validate_run(api, expected, source, os.environ)
artifacts = selected_artifacts(api, repository, expected, source, args.game)
artifacts = selected_artifacts(api, repository, expected, source, args.game, modes)
client = ArtifactsClient(REPOSITORY, os.environ["GITHUB_TOKEN"])
receipts, retained = [], []
for backend, mode, artifact in artifacts:
Expand Down Expand Up @@ -398,7 +404,8 @@ def main():
comparison.write(work / "artifact-receipts.json", {"identity": expected, "artifacts": retained})
with (work / "comparison-events.jsonl").open("x", encoding="utf-8") as events:
with contextlib.redirect_stdout(events):
result = comparison.compare(argparse.Namespace(receipt=receipts, output_dir=str(output)))
result = comparison.compare(argparse.Namespace(receipt=receipts, output_dir=str(output),
modes=modes))
with (work / "comparison-events.jsonl").open(encoding="utf-8") as events:
for line in events:
value = json.loads(line)
Expand Down
11 changes: 11 additions & 0 deletions tools/modsync-ci/test_fullrun_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ def test_every_local_workflow_action_and_python_entrypoint_exists(self):
self.assertTrue((ROOT / action[2:] / "action.yml").is_file())
for tool in re.findall(r"tools/modsync-ci/[A-Za-z0-9_-]+\.py", step.get("run", "")):
self.assertTrue((ROOT / tool).is_file(), tool)
def test_every_installation_plan_runs_and_requires_the_patcher_comparison(self):
# A single-route dispatch still runs all three backends, so it must still be
# compared against the packaged lane rather than pass as "unverified".
main = yaml.load((ROOT / ".github/workflows/fullrun.yml").read_text(), Loader=yaml.BaseLoader)
comparison = main["jobs"]["comparison"]
self.assertNotIn("modes", comparison["if"])
self.assertEqual(comparison["with"]["modes"], "${{ needs.plan.outputs.modes }}")
required = main["jobs"]["result"]["steps"][1]["env"]["REQUIRE_COMPARISON"]
self.assertNotIn("modes", required)
self.assertIn("install", required)

def test_matrix_has_no_fail_fast_and_honest_final_collector(self):
main = yaml.load((ROOT / ".github/workflows/fullrun.yml").read_text(), Loader=yaml.BaseLoader)
self.assertEqual(main["jobs"]["install"]["strategy"]["fail-fast"], "false")
Expand Down
Loading
Loading