physics-mv
FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence.
Brought by drakestapleton
physics-mv / forge / forge_realize.h
| 1 | #ifndef FORGE_REALIZE_H |
| 2 | #define FORGE_REALIZE_H |
| 3 | |
| 4 | #include "forge_types.h" |
| 5 | #include "nvrm.h" |
| 6 | |
| 7 | /* |
| 8 | * Canonical FORGE realization API: |
| 9 | * Produces the code buffer of a realization request for the specified |
| 10 | * ForgeMachineDescriptor. Today this is a lowering SIMULATION: the IR bytes are |
| 11 | * copied into a zero-padded aligned buffer and the result is labelled |
| 12 | * FORGE_LOWERING_SIMULATED. Real lowering is not implemented (DRA-176). |
| 13 | * Does NOT submit to hardware. |
| 14 | */ |
| 15 | int forge_realize(const ForgeRealizationRequest *req, ForgeRealizationResult *out_res); |
| 16 | |
| 17 | /* |
| 18 | * Whether a realization may count as a compiler (native-code) effect. |
| 19 | * Returns 1 only when res->is_lowered is set, res->lowering_kind is |
| 20 | * FORGE_LOWERING_COMPILED and the code buffer does not contain the request's IR |
| 21 | * bytes verbatim at any offset (nor is a prefix of them). Returns 0 for every |
| 22 | * simulated, unlabelled or copied realization, and for invalid arguments or an |
| 23 | * empty IR. These are necessary conditions, not a proof that a compiler ran. |
| 24 | * AEGIS verification refuses a COMPILED label unless this answers 1. |
| 25 | */ |
| 26 | int forge_realization_is_compiled(const ForgeRealizationRequest *req, |
| 27 | const ForgeRealizationResult *res); |
| 28 | |
| 29 | /* |
| 30 | * Canonical AEGIS verification API (physics module entry point): |
| 31 | * Verifies that the lowered realization satisfies all contracts and invariants |
| 32 | * for the target descriptor before hardware submission is permitted. It refuses |
| 33 | * a lowering label outside NONE/SIMULATED/COMPILED, and a COMPILED label unless |
| 34 | * forge_realization_is_compiled() answers 1 for this request; the verification |
| 35 | * token covers the label it seals. |
| 36 | */ |
| 37 | int aegis_verify_realization(const ForgeRealizationRequest *req, |
| 38 | const ForgeRealizationResult *res, |
| 39 | const ForgeMachineDescriptor *desc, |
| 40 | ForgeVerifiedRealization *out_verified); |
| 41 | |
| 42 | /* |
| 43 | * Canonical Hardware Submission API: |
| 44 | * Strictly accepts only a ForgeVerifiedRealization. |
| 45 | * Rejects unverified, mismatched descriptor, stale, mutated or relabelled |
| 46 | * realizations. The submission is a semaphore release that proves the typed |
| 47 | * path reached the GPU; it never executes the code buffer, and the evidence |
| 48 | * says so (code_executed = false, lowering_kind = the sealed label). |
| 49 | */ |
| 50 | int forge_submit_realization(Nvrm *rm, |
| 51 | const ForgeVerifiedRealization *verified_real, |
| 52 | const ForgeMachineDescriptor *live_desc, |
| 53 | ForgeExecutionEvidence *out_evidence); |
| 54 | |
| 55 | #endif /* FORGE_REALIZE_H */ |