oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env python3
2"""Equipo's only device/Keychain mutation boundary is lifetime-guarded commit."""
3from pathlib import Path
4import re
5
6root = Path(__file__).resolve().parents[1]
7sources = root / 'apple/Sources/EquipoKit'
8account = sources / 'Pairing/DeviceAccount.swift'
9text = account.read_text()
10assert 'func commit(' in text, 'DeviceAccounts must expose one guarded commit function'
11start = text.index('{', text.index('func commit('))
12depth = 1
13end = start + 1
14while depth:
15 depth += (text[end] == '{') - (text[end] == '}')
16 end += 1
17commit = text[start:end]
18outside = text[:start] + text[end:]
19assert not re.search(r'store\.(?:write|remove)\s*\(', outside), 'persistence outside commit'
20assert 'try lifetimes.require(lifetime)' in commit, 'commit must reject an ended or foreign lifetime'
21assert commit.index('try lifetimes.require(lifetime)') < commit.index('store.write('), 'guard must precede persistence'
22for path in [*sources.rglob('*.swift'), *(root / 'ios').rglob('*.swift'), *(root / 'macos').rglob('*.swift')]:
23 value = path.read_text()
24 if path != account:
25 assert not re.search(r'\b(?:accounts|self\.accounts)\.(?:save|remove)\s*\(', value), f'unguarded account write: {path}'
26 assert not re.search(r'\.write\s*\(', value), f'raw secret-store write: {path}'
27 assert not re.search(r'\b\w*(?:store|Store)\.remove\s*\(', value), f'raw secret-store removal: {path}'
28 if path.name != 'SecretStore.swift':
29 assert not re.search(r'\bSecItem(?:Add|Update|Delete)\s*\(', value), f'raw Keychain write: {path}'
30assert 'private let store: SecretStore' in text, 'raw store must stay private'
31assert not re.search(r'func (?:save|remove)\(', text), 'do not add a persistence bypass'
32print('Sign-in lifetime: device and Keychain writes use the guarded commit')
33