open-standards/wai/oer-conformance/settle/settle.h
Transaction Science 1f5bfbd1e0 wai: no modelled or zero figure shown as a measurement
- The C settlement kernel graded every receipt measured, from hardware, by
  hardware_meter, whatever its meter; it now writes the grade and device the
  meter states. Its host harness's figures are constants: projected, from a
  simulation, by model_estimated (oer-receipts §2: an Estimator figure is
  projected). The Zephyr skeleton states projected and no longer seals a
  compute figure of 0. firmware_vectors.json is regenerated; both verifiers
  pass it.
- wai-web: the world demo seals the page's estimate labelled Estimator and says
  so on screen (label_page_figure, tested); the quantum demos seal the unmetered
  marker instead of invented constants, and their getters say a 0 is unmetered.
- The quantum studio shows a figure with its class, coverage and uncertainty;
  the quantum CLI prints the unmetered marker as unmetered (tested); the
  metering tools head a bracket as a bracket and print the marker on stdout when
  they seal it; a provenance total names the class it reads at (tested).
- energy-measurement §2.8 and §6 record which demos still seal an illustrative
  figure the page passes in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2a8d45aa0d)
2026-10-26 08:30:49 -04:00

34 lines
2.2 KiB
C

/* SPDX-License-Identifier: Apache-2.0 */
/* The settlement kernel: the keystone loop as portable C.
canonicalize -> key -> lookup -> verify -> decide -> record -> receipt
(OER/2 draft 0.1 as profiled by extensions/oer-receipts.md). */
#ifndef SETTLE_H
#define SETTLE_H
#include <stdint.h>
#include <stddef.h>
#define SETTLE_RECORDS 4096
#define SETTLE_ANSWER 24
/* The meter's figures and how they were obtained. `how` is the receipt's evidential grade
(oer-receipts §2: projected, simulated, derived, measured) and `device` its provenance text;
a meter states both, and the kernel writes them as given: a figure computed from constants is
never graded measured (oer-receipts §2: an Estimator figure is projected). */
typedef struct { double compute_j, movement_j, idle_alloc_j, shared_alloc_j, upstream_j; double latency_s; const char *method; const char *how, *device; const char *weakest_how, *weakest_input; } settle_meter_t;
typedef struct { uint8_t key[32]; char answer[SETTLE_ANSWER]; double created, valid_until, deriv_j; uint32_t reuse, id; uint8_t used; } settle_record_t;
typedef struct { int status; const char *outcome; char answer[SETTLE_ANSWER]; uint32_t record_id; uint32_t reuse; char receipt_hash[72]; double joules_total; } settle_result_t;
typedef struct {
settle_record_t rec[SETTLE_RECORDS];
uint32_t rec_next, receipt_n;
char prev_hash[72];
uint8_t pk[32], sk[64];
double temperature_k, validity_s, cycle_j;
uint32_t bits_committed;
const char *boundary, *rules_hash;
} settle_ctx_t;
int settle_init(settle_ctx_t *c, const uint8_t seed[32], double temperature_k, double validity_s);
/* Runs the loop for one question. cls is 'A' (charging authorization) or 'B' (sensor check), id the canonical question id.
Writes the full receipt JSON (with chain) into out. Returns 0 on success. */
int settle_decide(settle_ctx_t *c, char cls, uint32_t id, double now, const settle_meter_t *m, char *out, size_t outlen, settle_result_t *res);
/* Records as a JSON object {id: {key, answer, created, valid_until}}, for vector files. */
int settle_records_json(const settle_ctx_t *c, char *out, size_t outlen);
void settle_pk_hex(const settle_ctx_t *c, char out[65]);
#endif