367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
61 lines
3.0 KiB
Python
61 lines
3.0 KiB
Python
"""Exact admission for the new original-UI-created local paladin fixture.
|
|
|
|
The receipt contains character identity and creation provenance only. The
|
|
manager must still validate the actual Source row before launching its client.
|
|
This helper neither authenticates nor reads an account/password fixture.
|
|
"""
|
|
import json
|
|
from pathlib import Path
|
|
import re
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
RECEIPT = ROOT / 'runtime/continuation-20261113/codex/Paladin-fixture/created-paladin.private.json'
|
|
ACCOUNT_FIXTURE = Path('/mnt/Games/@scratch/Forever-C1-Disposable-20261114/runtime/c68-private-account/GW82BF4A7B4D/account.json')
|
|
SCHEMA = 'owned-ui-created-paladin-v1'
|
|
|
|
|
|
def validate_receipt(value):
|
|
expected = {'schema', 'guid', 'account', 'race', 'class', 'name',
|
|
'creation_run', 'created_via_original_ui', 'source_guid_high_water_before'}
|
|
if not isinstance(value, dict) or set(value) != expected or value['schema'] != SCHEMA:
|
|
raise ValueError('Exact new-paladin creation receipt required')
|
|
if any(type(value[k]) is not int for k in ('guid', 'account', 'race', 'class', 'source_guid_high_water_before')):
|
|
raise ValueError('Integer paladin identity required')
|
|
if ((value['account'], value['race'], value['class']) != (513, 1, 2)
|
|
or not 4526 <= value['source_guid_high_water_before'] < value['guid'] < 2**32
|
|
or value['created_via_original_ui'] is not True):
|
|
raise ValueError('Only the newly created owned human paladin is admitted')
|
|
if not isinstance(value['name'], str) or not re.fullmatch(r'[A-Za-z]{2,12}', value['name']):
|
|
raise ValueError('Exact bounded paladin name required')
|
|
if not isinstance(value['creation_run'], str) or not re.fullmatch(r'[A-Za-z0-9]{1,96}', value['creation_run']):
|
|
raise ValueError('Owned creation run required')
|
|
return dict(value)
|
|
|
|
|
|
def load_receipt():
|
|
"""Read the one fixed noncredential receipt after original UI creation."""
|
|
return validate_receipt(json.loads(RECEIPT.read_text()))
|
|
|
|
|
|
def first_profile(receipt):
|
|
value = validate_receipt(receipt)
|
|
return value['guid'], value['account'], 4, ACCOUNT_FIXTURE
|
|
|
|
|
|
def validate_source_row(receipt, row):
|
|
"""Bind a fresh read-only Source identity tuple to the creation receipt."""
|
|
value = validate_receipt(receipt)
|
|
expected = [str(value[k]) for k in ('guid', 'account', 'race', 'class')]
|
|
expected.append(value['name'].encode('ascii').hex().upper())
|
|
if not isinstance(row, (list, tuple)) or list(row) != expected:
|
|
raise ValueError('Actual owned paladin Source identity differs')
|
|
|
|
|
|
def bound_context(receipt, first, second):
|
|
"""A receipt grants one exact single-login character, never account scope."""
|
|
value = validate_receipt(receipt)
|
|
return (isinstance(first, dict) and second is None
|
|
and (first.get('guid'), first.get('account'), first.get('original_rank'), first.get('runtime_rank'))
|
|
== (value['guid'], 513, 4, 4)
|
|
and Path(first.get('fixture', '')).resolve() == ACCOUNT_FIXTURE.resolve())
|