[MG_Remote] (P6/dl): a dying session names itself to the peer

Step three of CONTRACT-P6 5.2, the funnel's whole point: instead of the peer
reading a bare EOF and guessing, the session publishes a SessionFault frame
that names the family before it aborts.

THE WIRE CHANGE IS D2's, exactly: `table Fatal` appends `family: string`,
append-only, so an older peer still reads `code` and `message`. `code` stays
the coarse seven-value projection; `family` carries the full word.

SessionFail publishes it before the abort, on whichever session's control
plane is active - the client has a ClientSession, the server a ServerSession,
so under spawn the frame reaches the far side whichever role is dying. Under
inproc both exist and it goes to an in-process transport the aborting process
will never read, which is harmless and cheaper than a special case that would
then be the untested one. Best-effort by nature: this thread is about to die,
so a send that blocks or fails changes nothing.

seq/op from the prose are NOT threaded through the 90 sites: the message
already names the op where it matters, so the frame carries what it can name
honestly (code, family, message) rather than a field that is always zero.

The client recognizes it: RunRemoteSurfaceControlFrame's reply loop, which
already demuxes CapsSnapshot from SurfaceReply, gains a Fatal arm that logs the
family and detail, latches device-lost from it, and returns transport-closed.
A server that DETECTS a fatal condition and aborts itself now tells the client
why; a kill -9 still bypasses abort entirely and is caught by dl's hangup
witness instead - the two cover the two ways a server can die.

The census learns SessionFail: a SessionFail call, like a WireLogFatal call,
must carry a Fatal{ word in its string, so the enum and the string cannot
disagree. FatalFunnel.{h,cpp} join the funnel exemption. Baseline is 4 aborts.

FatalFamilyTest gains the wire round-trip: every family's frame carries its
word and its projected code across encode/verify/decode.

G1 re-measured after the schema change: 0 symbol diff, .text unchanged at
0xa52203. Unit 2359 (one pre-existing environmental failure), integration-split
186/186, integration-spawn 102/102, retrace 6/6, census 0 unmarked.
This commit is contained in:
2026-09-21 21:51:50 -04:00
parent 4bb4d4fa4f
commit b46da7002c
5 changed files with 104 additions and 9 deletions
+27
View File
@@ -9,7 +9,9 @@
// P6 `dl` (CONTRACT-P6 5.2). The Fatal-family table and its projection onto the wire FatalCode.
#include <MG_Remote/FatalFamily.h>
#include <MG_Remote/Protocol/generated/protocol_generated.h>
#include <flatbuffers/flatbuffers.h>
#include <gtest/gtest.h>
#include <set>
@@ -81,3 +83,28 @@ TEST(FatalFamily, TheAnchorFamiliesProjectWhereTheirMeaningSays) {
// An unmigrated verb is a protocol-level "cannot honour this", not a crash.
EXPECT_EQ(FatalCodeForFamily(MGFatalFamily::UnmigratedVerb), FatalCode::ProtocolCorruption);
}
TEST(FatalFamily, TheSessionFaultFrameCarriesTheFamilyAndItsCode) {
// `dl` step three (5.2): the Fatal frame a dying session publishes carries the full family
// WORD beside the coarse code, so a peer names which family ended the session instead of
// reading a bare EOF. This is the wire round-trip that proves the field is there and that the
// code the frame carries is the family's own projection.
for (const MGFatalFamily family : kAllFamilies) {
::flatbuffers::FlatBufferBuilder builder(256);
const auto fatal = ::MobileGL::Wire::CreateFatalDirect(
builder, FatalCodeForFamily(family), "detail line", FatalFamilyName(family));
const auto root = ::MobileGL::Wire::CreateCtrlEnvelope(
builder, ::MobileGL::Wire::CtrlMsg::Fatal, fatal.Union());
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, root);
::flatbuffers::Verifier verifier(builder.GetBufferPointer(), builder.GetSize());
ASSERT_TRUE(::MobileGL::Wire::VerifyCtrlEnvelopeBuffer(verifier));
const auto* envelope = ::MobileGL::Wire::GetCtrlEnvelope(builder.GetBufferPointer());
ASSERT_EQ(envelope->msg_type(), ::MobileGL::Wire::CtrlMsg::Fatal);
const auto* decoded = envelope->msg_as_Fatal();
ASSERT_NE(decoded, nullptr);
ASSERT_NE(decoded->family(), nullptr) << "the family field did not survive the wire";
EXPECT_STREQ(decoded->family()->c_str(), FatalFamilyName(family));
EXPECT_EQ(decoded->code(), FatalCodeForFamily(family));
}
}