|
| 1 | +# KERN 5 R2/M3.1 Internal Transactional Runtime Envelope |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Implementation contract for the first M3 slice. The envelope is internal, |
| 6 | +default-off, and does not freeze the runtime, handler, trace, or capability |
| 7 | +ABI. **DECIDED** |
| 8 | + |
| 9 | +## Baseline and Decision |
| 10 | + |
| 11 | +- Alpha KIR/evidence/receipt is remotely verified at `7099c95d`. **VERIFIED** |
| 12 | +- Sixteen runner constructs plus trace, handler, and capability ABIs remain |
| 13 | + explicitly deferred to M3. **VERIFIED** |
| 14 | +- Public `executeKernSource*` wrappers return stdout strings; sync and async |
| 15 | + execution still use separate evaluators. **VERIFIED** |
| 16 | +- Agon tribunal `tribunal-1783864102213-mjaw2b-kern5-m3-first-slice` |
| 17 | + completed 3/3 and selected transactional envelope normalization before typed |
| 18 | + arguments or scheduler unification. **VERIFIED** |
| 19 | + |
| 20 | +## Envelope Contract |
| 21 | + |
| 22 | +Format is `kern.runtime.internal.r0`. The exact envelope contains `format`, |
| 23 | +`outcome`, `completion`, `result`, `events`, and `diagnostics`. All fields are |
| 24 | +always present and canonical JSON encoding ends in one LF. **DECIDED** |
| 25 | + |
| 26 | +- Success completion is `normal | return`; `result` is an explicit slot so |
| 27 | + absent/void and explicit null cannot collapse. |
| 28 | +- Failure completion is `error`, result is absent, and events are empty. |
| 29 | +- Diagnostics contain stable `category`, `code`, and `phase` only. Host error |
| 30 | + messages are not identity and do not enter envelope bytes. |
| 31 | +- Observable events are only `stdout`, `stderr`, and `capability`. Assignment, |
| 32 | + call, iteration, enter, and exit events remain internal trace mechanics. |
| 33 | + **GUARD** |
| 34 | + |
| 35 | +## Portable Value Contract |
| 36 | + |
| 37 | +Values are closed tagged forms: null, boolean, text, safe integer text, |
| 38 | +canonical decimal text, list, and code-point-sorted record entries. Undefined |
| 39 | +is represented only by an absent slot. Functions, symbols, bigint, negative |
| 40 | +zero, NaN/infinity, unsafe integers, exponent-form numbers, RegExp, Date, Map, |
| 41 | +Set, class instances, sparse arrays, forbidden record keys, cycles, malformed |
| 42 | +Unicode, and configured resource overflow reject. **GUARD** |
| 43 | + |
| 44 | +Limits are required caller configuration: maximum depth, collection length, |
| 45 | +string UTF-8 bytes, events, diagnostics, and encoded bytes. **DECIDED** |
| 46 | + |
| 47 | +## Execution and Containment |
| 48 | + |
| 49 | +Sync and async internal entrypoints require `enabled: true`; omission or false |
| 50 | +rejects before execution. Both run the current semantic lanes and then pass |
| 51 | +through the same normalizer. Existing source executors and public exports are |
| 52 | +unchanged. The module is unreachable from runtime/browser/public barrels and |
| 53 | +package exports. **GUARD** |
| 54 | + |
| 55 | +Transactional means the new envelope exposes no partial result, diagnostic, |
| 56 | +or event after execution failure. It does not claim rollback of a host |
| 57 | +capability effect that already occurred inside the current evaluators; that |
| 58 | +requires the unified effect scheduler slice. **DECIDED** |
| 59 | + |
| 60 | +## Acceptance |
| 61 | + |
| 62 | +- [x] Success, explicit null, void, stdout, and capability events normalize. |
| 63 | +- [x] Sync and immediately-resolved async execution encode byte-identically. |
| 64 | +- [x] Failure after stdout or attempted return yields empty events and absent |
| 65 | + result with stable diagnostic identity. |
| 66 | +- [x] Hostile values and every configured resource overflow reject or become a |
| 67 | + transactional `non-portable-value` failure without partial output. |
| 68 | +- [x] Default-off and internal containment kill public/runtime adoption. |
| 69 | +- [x] Existing R1 gates and full KERN 5 fitness wall remain green. |
| 70 | +- [x] Final Agon review with exactly `claude,codex,agy` has zero verified |
| 71 | + findings. |
| 72 | + |
| 73 | +## Deferred |
| 74 | + |
| 75 | +Typed handler arguments/results at the source entry boundary, unified effect |
| 76 | +scheduler, cancellation, actual effect rollback, stable public ABI, all 16 |
| 77 | +runner-contract promotions, KIR v1 freeze, and runtime cutover. **DEFERRED** |
| 78 | + |
| 79 | +## Kill Switches |
| 80 | + |
| 81 | +- Any existing public executor changes behavior or return type. |
| 82 | +- Any failed envelope contains result or events. |
| 83 | +- Any host message becomes diagnostic identity. |
| 84 | +- Any unknown/non-portable value falls back or stringifies. |
| 85 | +- Any internal envelope becomes publicly exported or default-on. |
0 commit comments