Some checks failed
WAI breaking changes and the conformance runner / WAI breaking · does this change touch WAI (push) Successful in 8s
WAI breaking changes and the conformance runner / WAI breaking · wire, record and API against main · linux (push) Failing after 45s
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Successful in 11m51s
WAI breaking changes and the conformance runner / WAI breaking and conform · their tests, and the independent verifiers through wai conform · linux (push) Successful in 7m31s
settle_decide now refuses (returns -3, before any record or the chain changes) a meter whose grade or weakest input's grade is not one of oer-receipts §2's four, or which grades a figure measured by a method other than hardware_meter, the corpus's term for a meter that reads an instrument. The kernel already writes the grade its meter states (1f5bfbd1e); a model's figure handed to it as a reading can no longer be signed as one. The host harness checks, after writing its file, three refusals (a model graded measured, a grade outside the four, a weakest grade outside them) and that a measured figure from hardware_meter is taken, and exits 4 otherwise. So the existing CI step that rebuilds firmware_vectors.json checks the rule on every unix leg; its comment says so. The pinned corpus is unchanged. Re-landed from PR #459 (8570389f9,a184a44cf): main took the grade from the meter and regenerated the one pinned corpus, so the branch's issued/modelled modes and its second corpus are not carried; its refusal is. Tested on the M3 Ultra (Apple clang 21) and the Linux build host (gcc 15.2), with the CI step's flags: no warning in settle.c or host_main.c; the output equals ../firmware_vectors.json under cmp; oer2_verify.py passes it on the M3 (the Linux host has no Ed25519 library for that check). Falsified on both: the method rule removed, and the call removed, each make the harness exit 4; so does refusing every measured figure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
37 lines
2.4 KiB
C
37 lines
2.4 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). settle_decide refuses
|
|
(returns -3, writing nothing) a meter whose grade or weakest grade is not one of the four, or
|
|
which grades `measured` by a method other than `hardware_meter`. */
|
|
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; -3 for a meter whose grade it cannot
|
|
support (above), before any record or the chain changes. */
|
|
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
|