open-standards/wai/oer-conformance/settle/host_main.c
Transaction Science afc7ece2e5
Some checks failed
no-vanity-metrics / Scan committed Markdown for vanity metrics (push) Successful in 4s
standards workspaces build + test / eoc-rs (push) Successful in 1m49s
standards workspaces build + test / jouleclaw-rs (push) Successful in 2m0s
standards workspaces build + test / aac-rs (push) Successful in 37s
standards workspaces build + test / jcp-rs (push) Successful in 1m17s
standards workspaces build + test / joule-code-rs (push) Successful in 39s
standards workspaces build + test / arl-rs (push) Successful in 3m28s
standards workspaces build + test / joulecontract-rs (push) Successful in 37s
standards workspaces build + test / proof-rs (push) Successful in 1m14s
standards workspaces build + test / map-rs (push) Successful in 34s
standards workspaces build + test / mesh-rs (push) Successful in 26s
standards workspaces build + test / sandbox-rs (push) Successful in 2m5s
standards workspaces build + test / openpay (push) Successful in 1m45s
standards workspaces build + test / joule-ui-rs (push) Successful in 3m26s
WAI conformance / cargo-class corpora · linux-arm64 (push) Successful in 46s
WAI conformance / cross-arch byte-equality · linux-arm64 (push) Successful in 17s
standards workspaces build + test / smart-byte-rs (push) Successful in 2m32s
standards workspaces build + test / jouledesk-rs (push) Successful in 2m51s
WAI conformance / cargo-class corpora · linux (push) Successful in 56s
WAI conformance / cross-arch byte-equality · linux (push) Successful in 15s
WAI conformance / C2PA manifest emission · signed, read back, validated (push) Successful in 40s
standards workspaces build + test / joulehook-rs (push) Successful in 2m42s
standards workspaces build + test / sense-rs (push) Successful in 2m41s
standards workspaces build + test / macOS energy backend (jcp-energy) (push) Failing after 2m56s
WAI conformance / cargo-class corpora · macos (push) Successful in 57s
WAI conformance / cross-arch byte-equality · macos (push) Successful in 16s
WAI conformance / cargo-class corpora · windows (push) Has been cancelled
WAI conformance / cross-arch byte-equality · windows (push) Has been cancelled
wai: ingest OER/2 receipts — extension, conformance corpus, wai-rs verifier, C kernel in CI
Adds extensions/oer-receipts.md, oer-conformance/ (upstream 9 + C-kernel 1 + 13
hand-declared edge vectors, canonical fixture), crate::oer behind --features oer
with wai_oer_vectors, and CI steps running it on the matrix and rebuilding the C
kernel byte-for-byte. Fixes five reference-verifier defects the edge vectors found.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-27 03:58:55 -04:00

28 lines
2.3 KiB
C

/* SPDX-License-Identifier: Apache-2.0 */
/* Host harness: replays a day of demand through the kernel with a modelled meter and writes an OER/2 vector file. */
#include "settle.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static uint32_t rng_s = 42; static double urand(void){ rng_s = rng_s * 1664525u + 1013904223u; return (rng_s >> 8) / 16777216.0; }
int main(int argc, char **argv){
const char *path = argc > 1 ? argv[1] : "firmware_vectors.json"; int n_events = argc > 2 ? atoi(argv[2]) : 400;
static settle_ctx_t ctx; uint8_t seed[32]; int i; for (i = 0; i < 32; i++) seed[i] = (uint8_t)(i * 7 + 3);
settle_init(&ctx, seed, 300.0, 86400.0);
FILE *f = fopen(path, "w"); if (!f) return 1;
char pk[65]; settle_pk_hex(&ctx, pk);
fprintf(f, "{\"oer\":\"2.0\",\"draft\":\"0.1\",\"source\":\"settle kernel host harness, %d events\",\"keys\":{\"ed25519:bench-node-01\":\"%s\"},\"vectors\":[{\"name\":\"v10 firmware chain from the C kernel\",\"receipts\":[", n_events, pk);
static char buf[4096]; double now = 0, last = 0, meter = 0; const double standby_w = 1.8e-3, shared_w = 0.06;
for (i = 0; i < n_events; i++) {
now += 20 + 80 * urand(); char cls = urand() < 0.34 ? 'A' : 'B';
double z = urand(); uint32_t id = (uint32_t)(cls == 'A' ? 1 + 2999 * z * z * z : 1 + 399 * z * z * z);
settle_meter_t m; m.compute_j = 120000.0 * ctx.cycle_j; m.movement_j = cls == 'A' ? 2.3e-6 : 0; m.idle_alloc_j = standby_w * (now - last); m.shared_alloc_j = shared_w * (now - last); m.upstream_j = 0;
m.latency_s = cls == 'A' ? 0.019 : 0.0017; m.method = "hardware_meter"; m.weakest_how = "projected"; m.weakest_input = "wire_w";
settle_result_t res; if (settle_decide(&ctx, cls, id, now, &m, buf, sizeof buf, &res)) { fprintf(stderr, "decide failed\n"); return 2; }
meter += res.joules_total; last = now;
fprintf(f, "%s%s", i ? "," : "", buf);
}
static char recbuf[1 << 20]; fprintf(f, "],\"records\":"); if (settle_records_json(&ctx, recbuf, sizeof recbuf)) { fprintf(stderr, "records overflow\n"); return 3; } fputs(recbuf, f);
fprintf(f, ",\"ledger\":{\"meter_joules\":\"%.12e\",\"unallocated_joules\":\"0.000000e+00\",\"carried_forward_joules\":\"0.000000e+00\"},\"expected\":[]}]}\n", meter);
fclose(f); fprintf(stderr, "wrote %s: %d receipts, meter %.6f J\n", path, n_events, meter); return 0;
}