Files
scriptc/tests/library-mode/int-returns/lib.ts
T
Chris Tate a2c68beadb The ask-4 conformance corpus end to end, with the sidecar attestation and inbound-trap fixtures
- tests/harness/library-int.test.ts: all 16 reference-corpus cases as library fixtures on both emissions — send/sendU64 are profile-mapped exports with i64/u64 params, PROVE cases pin every crossed value against the Node oracle (the test process runs the same case source), the counter loop crosses 0..9 in order, REFUSE cases name obligation, slot path, and evidence
- int-returns fixture: i64/u64 returns cross as real int64_t/uint64_t (9007199254740991, -0 as 0, -7 % 3 as -1, ToUint32 max on a u64 slot)
- int-trap fixture: inbound integers past 2^53-1 deliver the structured SC4012 host-contract trap with profile teaching/remediation; in-range extremes convert exactly
- Sidecar slots: integer_slots attestation in declaration order, declared slots spelled i64 (V10 bijection validated), unproven writes refused by slot path (Msg.count, helpers.clampIdx.return), unresolvable and non-number declarations refused SC4009, teachings ride SC4022 as attributed notes
- Layer-1 differential: no Layer-1 representation exists (trivially unobservable); pinned consequence — f64-declared vs i64-declared builds cross byte-identical values
- Integer-declared helpers join libRoots so their attestation covers a compiled body, never a dead-stripped vacuity
2026-07-24 11:39:43 -05:00

30 lines
1.1 KiB
TypeScript

/* Ask 4's outbound declared-integer returns: each export's return slot is
* profile-declared i64 (u64 for the unsigned one), so every value below
* must PROVE whole-in-range at compile time — and the wrapper's
* fp-to-int conversion then carries the mathematically exact integer the
* f64 held (the probe reads real int64_t/uint64_t and pins the corpus's
* singleton crossing values against the Node oracle). */
// The largest safe integer crosses exactly (corpus case 1 at the real edge).
export function retMax(): number {
return 2 ** 53 - 1;
}
// -0 is whole: the sign of zero is f64-interior; the mathematically
// exact integer 0 crosses (corpus case 4 at the real edge).
export function retNegZero(): number {
return -0;
}
// JS remainder: the sign follows the dividend — -7 % 3 is exactly -1,
// not 2 (corpus case 9 at the real edge).
export function retRem(): number {
return -7 % 3;
}
// ToUint32 by the program's own >>> 0: whole, non-negative, uint32 —
// satisfies a u64 slot (corpus case 11 at the real edge).
export function retU32Max(): number {
return 4294967295 >>> 0;
}