7891e21c Andy McCall 1 month ago ↶
1
import re
2
3
with open ( ' /home/andymccall/development/oxygen/docs/xenon_spec.md' , ' r' ) as f :
4
text = f . read ( )
5
6
7
text = re . sub ( r ' Format Version\s * :\s * ( \d + ) \n Date\s * :\s * ( . *? ) \n Status\s * :\s * ( . *? ) \n Target VCS\s * :\s * ( . *? ) \n Audience\s * :\s * ( . *? ) \n ' ,
8
r ''' | | |
9
| ---| ---|
10
| * * Format version* * | \1 |
11
| * * Date* * | \2 |
12
| * * Status* * | \3 |
13
| * * Target VCS* * | \4 |
14
| * * Audience* * | \5 |
15
''' , text )
16
17
18
text = re . sub ( r ' ={10,} \n ( . *? ) \n ={10,} ' , lambda m : f " ## { m . group ( 1 ) . strip ( ) } " , text )
19
20
21
text = re . sub ( r ' \n ( \d + \. \d + \s + . *? ) \n ' , r ' \n ### \1 \n ' , text )
22
23
24
text = text . replace ( ' schema-version 1\n \n // Define' , ' ```kdl\n schema-version 1\n \n // Define' )
25
text = text . replace ( ' }\n }\n \n ### 3.2' , ' }\n }\n ```\n \n ### 3.2' )
26
27
28
text = text . replace ( ' Receipt {\n ' , ' ```cbor\n Receipt {\n ' )
29
text = text . replace ( ' duration_ms [8]: u64\n }\n ' , ' duration_ms [8]: u64\n }\n ```\n ' )
30
31
32
text = text . replace ( ' Attest {\n ' , ' ```json\n Attest {\n ' )
33
text = text . replace ( ' }\n }\n }\n \n ### 7.2' , ' }\n }\n }\n ```\n \n ### 7.2' )
34
35
36
text = text . replace ( ' Signature {\n ' , ' ```cbor\n Signature {\n ' )
37
text = text . replace ( ' ml [3]: bytes(3309) // Post-quantum signature\n }\n ' , ' ml [3]: bytes(3309) // Post-quantum signature\n }\n ```\n ' )
38
39
40
text = text . replace ( ' PolicyRule {\n ' , ' ```json\n PolicyRule {\n ' )
41
text = text . replace ( ' signer_roles: [ "official-worker" ]\n }\n ]\n }\n ' , ' signer_roles: [ "official-worker" ]\n }\n ]\n }\n ```\n ' )
42
43
44
45
46
47
text = text . replace ( ' change_closure [3]: [ChangeHash] // Sorted minimal dependency closure' , ' scope_tree_hash [3]: ObjectRef // BLAKE3 tree hash of the materialized scope' )
48
49
text = text . replace ( ''' ### 6.2 Cache Re-use Invariant
50
Let Scope(J) be the file paths and tree nodes declared by job J.
51
Let Closure(S) be the dependency closure of State S.
52
The restricted change closure is:
53
C_J(S) = { c in Closure(S) | TouchedPaths(c) intersects Scope(J) }
54
55
If an existing Receipt R exists such that:
56
R.job_name == J.name &&
57
R.pipeline_hash == Hash(J) &&
58
R.change_closure == C_J(S) &&
59
R.environment == CurrentEnvironmentHash''' ,
60
''' ### 6.2 Cache Re-use Invariant
61
Let Scope(J) be the file paths and tree nodes declared by job J.
62
Because changes that do not share scopes commute, we do not need to track lists of ChangeHashes. Instead, we hash the materialized tree of Scope(J).
63
64
If an existing Receipt R exists such that:
65
R.job_name == J.name &&
66
R.pipeline_hash == Hash(J) &&
67
R.scope_tree_hash == TreeHash(Scope(J)) &&
68
R.environment == CurrentEnvironmentHash''' )
69
70
71
text = text . replace ( ' "change_closure": [ChangeHash], // Transitive changes included' , ' "scope_tree_hash": ObjectRef, // Captures exact state without O(N) array bloat' )
72
73
74
text = text . replace ( ''' ### 8.1 Policy Gate Definition
75
A Policy rule governing a bookmark MAY demand valid Xenon attestations:''' ,
76
''' ### 8.1 Policy Gate Definition
77
A Policy rule governing a bookmark MAY demand valid Xenon attestations. To mitigate a compromised authorized worker, high-security repositories can require **Consensus Builds** by setting the threshold > 1. This requires multiple independent runner identities to arrive at the exact same output hashes and both sign it.''' )
78
79
80
text = text . replace ( ' - Missing chunks are fetched lazily using the POST /objects protocol.' , ' - Missing chunks are fetched lazily using the POST /objects protocol.\n - To prevent FUSE context-switch bottlenecks on many small reads, xenon-casfs aggressively mmaps chunk data and utilizes host page caching.' )
81
82
83
with open ( ' /home/andymccall/development/oxygen/docs/xenon_spec.md' , ' w' ) as f :
84
f . write ( text )