feat(vm): add VM-owned PCG64 random and coverage headroom
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

Implement GC-managed random generators, next/nextf intrinsics, bounded ranges and deterministic conformance coverage. Publish the runtime contract and producer guidance.

Give coverage domains at least five percentage points of measured headroom while preserving sufficient floors. Record local qualification: make ci-domains passes with 939 tests and all domain gates green.
This commit is contained in:
2026-10-09 12:51:05 +01:00
parent 9318cf7cd3
commit 3e39a90083
50 changed files with 2545 additions and 189 deletions
@@ -0,0 +1,49 @@
seed draw word_hex signed float_bits
0 1 9B3184D7EE6BACDB -7263878661019030309 3FE366309AFDCD75
0 2 8B7B271AA4769FD4 -8396074084920287276 3FE16F64E3548ED3
0 3 9B4DB63DFE544AAB -7255943047247803733 3FE369B6C7BFCA89
0 4 E714BA3532308667 -1795605613775911321 3FECE29746A64610
0 5 64EAF919A9A040E2 7271898436958437602 3FD93ABE466A6810
0 6 325BCFFB862545B0 3628722603971397040 3FC92DE7FDC312A0
0 7 70180161DC24B6EC 8077207451505833708 3FDC06005877092C
0 8 39257F36B038F771 4117837307161671537 3FCC92BF9B581C78
1 1 3150032F5C48AC0A 3553343607941934090 3FC8A80197AE2454
1 2 099B2F21D97DB047 692198790160822343 3FA3365E43B2FB60
1 3 7539BA4A2ED012EB 8446987403885810411 3FDD4E6E928BB404
1 4 C842BA297694C455 -4016443230415174571 3FE90857452ED298
1 5 C8AE2BB397CD3537 -3986200569830361801 3FE915C57672F9A6
1 6 C2F1AF39457336BA -4399542700451088710 3FE85E35E728AE66
1 7 8710A37C51FEC0AD -8714285524614987603 3FE0E2146F8A3FD8
1 8 A4C73DCA70459C07 -6573217191447651321 3FE498E7B94E08B3
42 1 86B1DA1D72062B68 -8740965581747508376 3FE0D63B43AE40C5
42 2 1304AA46C9853D39 1370407407632858425 3FB304AA46C98538
42 3 A3670E9E0DD50358 -6672348250926415016 3FE46CE1D3C1BAA0
42 4 F9090E529A7DAE00 -501854135533064704 3FEF2121CA534FB5
42 5 C85B9FD837996F2C -4009435292248740052 3FE90B73FB06F32D
42 6 606121F8E3919196 6944869453235589526 3FD818487E38E464
42 7 7CE1C7FF478354BA 8998693429693338810 3FDF3871FFD1E0D4
42 8 CBC4AC70E541310E -3763693787692322546 3FE978958E1CA826
-1 1 EE89537ECBD16900 -1258382816822859520 3FEDD12A6FD97A2D
-1 2 DCBE53D8A6C852E6 -2540500949814193434 3FEB97CA7B14D90A
-1 3 561BA13FFCFD5094 6204730207832461460 3FD586E84FFF3F54
-1 4 76962EA43FCF9400 8545068625962177536 3FDDA58BA90FF3E4
-1 5 A2BF24C068F28D0D -6719611710200443635 3FE457E4980D1E51
-1 6 3D575F16AA0C40D8 4420106110234280152 3FCEABAF8B550620
-1 7 032B99D40D100946 228445342143613254 3F895CCEA0688040
-1 8 7053160AB14A824F 8093837190494847567 3FDC14C582AC52A0
-9223372036854775808 1 1C08F9C51E05B9F1 2020139057883232753 3FBC08F9C51E05B8
-9223372036854775808 2 4CC379FA6A441AFF 5531398883772734207 3FD330DE7E9A9106
-9223372036854775808 3 1E9926CF448F8AA7 2204836164224912039 3FBE9926CF448F88
-9223372036854775808 4 18ADD82F6DA7760F 1778315126095967759 3FB8ADD82F6DA770
-9223372036854775808 5 77DFD36640320B00 8637855046437047040 3FDDF7F4D9900C82
-9223372036854775808 6 CE09AC671D48BD0F -3600156868233085681 3FE9C1358CE3A917
-9223372036854775808 7 B15DBA0399E9E3D1 -5666168231532305455 3FE62BB740733D3C
-9223372036854775808 8 E88252991CF3E42C -1692699692368665556 3FED104A53239E7C
9223372036854775807 1 77D44C809FDF62DB 8634610500897825499 3FDDF5132027F7D8
9223372036854775807 2 05BCF3AED615466A 413473198052820586 3F96F3CEBB585500
9223372036854775807 3 693ED392E1CE694A 7583731450345580874 3FDA4FB4E4B8739A
9223372036854775807 4 83D248E707AC837B -8948009352528362629 3FE07A491CE0F590
9223372036854775807 5 5DD1D07026E00956 6760413695766956374 3FD774741C09B802
9223372036854775807 6 5713B8336C9A861C 6274561236862141980 3FD5C4EE0CDB26A0
9223372036854775807 7 4F2E7352ED7CCE69 5705624577933889129 3FD3CB9CD4BB5F32
9223372036854775807 8 DB109447225C784B -2661464346535888821 3FEB621288E44B8F
1 seed draw word_hex signed float_bits
2 0 1 9B3184D7EE6BACDB -7263878661019030309 3FE366309AFDCD75
3 0 2 8B7B271AA4769FD4 -8396074084920287276 3FE16F64E3548ED3
4 0 3 9B4DB63DFE544AAB -7255943047247803733 3FE369B6C7BFCA89
5 0 4 E714BA3532308667 -1795605613775911321 3FECE29746A64610
6 0 5 64EAF919A9A040E2 7271898436958437602 3FD93ABE466A6810
7 0 6 325BCFFB862545B0 3628722603971397040 3FC92DE7FDC312A0
8 0 7 70180161DC24B6EC 8077207451505833708 3FDC06005877092C
9 0 8 39257F36B038F771 4117837307161671537 3FCC92BF9B581C78
10 1 1 3150032F5C48AC0A 3553343607941934090 3FC8A80197AE2454
11 1 2 099B2F21D97DB047 692198790160822343 3FA3365E43B2FB60
12 1 3 7539BA4A2ED012EB 8446987403885810411 3FDD4E6E928BB404
13 1 4 C842BA297694C455 -4016443230415174571 3FE90857452ED298
14 1 5 C8AE2BB397CD3537 -3986200569830361801 3FE915C57672F9A6
15 1 6 C2F1AF39457336BA -4399542700451088710 3FE85E35E728AE66
16 1 7 8710A37C51FEC0AD -8714285524614987603 3FE0E2146F8A3FD8
17 1 8 A4C73DCA70459C07 -6573217191447651321 3FE498E7B94E08B3
18 42 1 86B1DA1D72062B68 -8740965581747508376 3FE0D63B43AE40C5
19 42 2 1304AA46C9853D39 1370407407632858425 3FB304AA46C98538
20 42 3 A3670E9E0DD50358 -6672348250926415016 3FE46CE1D3C1BAA0
21 42 4 F9090E529A7DAE00 -501854135533064704 3FEF2121CA534FB5
22 42 5 C85B9FD837996F2C -4009435292248740052 3FE90B73FB06F32D
23 42 6 606121F8E3919196 6944869453235589526 3FD818487E38E464
24 42 7 7CE1C7FF478354BA 8998693429693338810 3FDF3871FFD1E0D4
25 42 8 CBC4AC70E541310E -3763693787692322546 3FE978958E1CA826
26 -1 1 EE89537ECBD16900 -1258382816822859520 3FEDD12A6FD97A2D
27 -1 2 DCBE53D8A6C852E6 -2540500949814193434 3FEB97CA7B14D90A
28 -1 3 561BA13FFCFD5094 6204730207832461460 3FD586E84FFF3F54
29 -1 4 76962EA43FCF9400 8545068625962177536 3FDDA58BA90FF3E4
30 -1 5 A2BF24C068F28D0D -6719611710200443635 3FE457E4980D1E51
31 -1 6 3D575F16AA0C40D8 4420106110234280152 3FCEABAF8B550620
32 -1 7 032B99D40D100946 228445342143613254 3F895CCEA0688040
33 -1 8 7053160AB14A824F 8093837190494847567 3FDC14C582AC52A0
34 -9223372036854775808 1 1C08F9C51E05B9F1 2020139057883232753 3FBC08F9C51E05B8
35 -9223372036854775808 2 4CC379FA6A441AFF 5531398883772734207 3FD330DE7E9A9106
36 -9223372036854775808 3 1E9926CF448F8AA7 2204836164224912039 3FBE9926CF448F88
37 -9223372036854775808 4 18ADD82F6DA7760F 1778315126095967759 3FB8ADD82F6DA770
38 -9223372036854775808 5 77DFD36640320B00 8637855046437047040 3FDDF7F4D9900C82
39 -9223372036854775808 6 CE09AC671D48BD0F -3600156868233085681 3FE9C1358CE3A917
40 -9223372036854775808 7 B15DBA0399E9E3D1 -5666168231532305455 3FE62BB740733D3C
41 -9223372036854775808 8 E88252991CF3E42C -1692699692368665556 3FED104A53239E7C
42 9223372036854775807 1 77D44C809FDF62DB 8634610500897825499 3FDDF5132027F7D8
43 9223372036854775807 2 05BCF3AED615466A 413473198052820586 3F96F3CEBB585500
44 9223372036854775807 3 693ED392E1CE694A 7583731450345580874 3FDA4FB4E4B8739A
45 9223372036854775807 4 83D248E707AC837B -8948009352528362629 3FE07A491CE0F590
46 9223372036854775807 5 5DD1D07026E00956 6760413695766956374 3FD774741C09B802
47 9223372036854775807 6 5713B8336C9A861C 6274561236862141980 3FD5C4EE0CDB26A0
48 9223372036854775807 7 4F2E7352ED7CCE69 5705624577933889129 3FD3CB9CD4BB5F32
49 9223372036854775807 8 DB109447225C784B -2661464346535888821 3FEB621288E44B8F
@@ -0,0 +1,19 @@
# Random fixture provenance
The canonical PCG-XSL-RR 128/64 setseq source is pcg-cpp revision
`428802d1a5634f96bcd0705fab379ff0113bcf13`.
Its [check-pcg64.out](https://github.com/imneme/pcg-cpp/blob/428802d1a5634f96bcd0705fab379ff0113bcf13/test-high/expected/check-pcg64.out)
contains the first six seed=42, seq=54 words used here.
Downloaded upstream fixture SHA-256: `afc9e7775bdc59ab90d85caebe533d58ae7324be36cf9a4c975e6d7f86b9df24`.
[random-oracle.py](random-oracle.py) independently uses Python mathematical
integers modulo 2^128, division-based rotation, and Fraction-to-binary64
conversion. It imports no VM/production RNG code and cross-checks those six
canonical words. Additional seeds 0, 1, -1, MIN/MAX and draws 7–8 are generated
by that independent arithmetic model. The Float column maps the same word;
it does not represent alternating calls. Signed values are stored explicitly.
Reproduce with `python3 crates/console/prometeu-vm/tests/fixtures/random-oracle.py`
and check the TSV diff. This is a test oracle, never a runtime dependency.
Statistical quality and sequence conformance are different evidence; these
fixtures establish bits/consumption, not cryptographic or independence claims.
@@ -0,0 +1,23 @@
"""Independent mathematical fixture model (test-only Python arbitrary precision).
Pinned canonical PCG64 seed=42 words cross-check this model; no VM code imported.
"""
from pathlib import Path
from fractions import Fraction
import struct
M = 47026247687942121848144207491837523525
mod = 2**128
rows = ['seed\tdraw\tword_hex\tsigned\tfloat_bits']
first = []
for seed in [0, 1, 42, -1, -(2**63), 2**63-1]:
state = ((seed % 2**64 + 109) * M + 109) % mod
for index in range(1, 9):
state = (state * M + 109) % mod
x = (state % 2**64) ^ (state // 2**64)
rotation = state // 2**122
word = (x // 2**rotation + (x % 2**rotation) * 2**(64-rotation)) % 2**64
signed = word if word < 2**63 else word - 2**64
bits = struct.unpack('>Q', struct.pack('>d', float(Fraction(word // 2**11, 2**53))))[0]
rows.append(f'{seed}\t{index}\t{word:016X}\t{signed}\t{bits:016X}')
if seed == 42 and index <= 6: first.append(f'{word:016X}')
assert first == ['86B1DA1D72062B68','1304AA46C9853D39','A3670E9E0DD50358','F9090E529A7DAE00','C85B9FD837996F2C','606121F8E3919196']
Path(__file__).with_name('random-conformance.tsv').write_text('\n'.join(rows)+'\n')