[Feat] (MG_Remote, P11 B2): T0 is the default - an unset MOBILEGL_IPC_ADOPT_TIER asks T0 (ask 0x80) and falls back to T2 quietly (MGLOG_D, still counted: client T0Fallbacks, server T0Refusals), while an explicit 0 keeps every named line; revision 5's schema comment and pin fixed up

This commit is contained in:
2026-09-29 20:15:29 -04:00
parent e44d6ac7da
commit b32140e614
11 changed files with 173 additions and 65 deletions
+25 -11
View File
@@ -22,15 +22,20 @@ namespace MobileGL::MG_Remote::Transport {
const char* SideName(AdoptTierSide side) { return side == AdoptTierSide::Client ? "client" : "server"; }
} // namespace
bool AdoptTierIsDefault() { return MG_Config::Ipc.AdoptTier == MG_Config::kAdoptTierUnset; }
bool AdoptTierWantsT0() { return MG_Config::Ipc.AdoptTier == 0 || AdoptTierIsDefault(); }
std::uint32_t AdoptTierAskFor(bool streamDataPlane) {
return (MG_Config::Ipc.AdoptTier == 0 && !streamDataPlane) ? 0u : 2u;
if (streamDataPlane || !AdoptTierWantsT0()) return 2u;
return AdoptTierIsDefault() ? kAdoptAskT0Default : 0u;
}
std::uint32_t SettleAdoptTierAtHandshake(bool streamDataPlane, AdoptTierSide side) {
const std::uint32_t knob = MG_Config::Ipc.AdoptTier;
if (knob > 2) {
// Unreachable through ConfigLoader (it admits 0..2); a direct assignment is the only
// way here, and "T<n>" of a 7 would be a lie.
if (knob > 2 && knob != MG_Config::kAdoptTierUnset) {
// Unreachable through ConfigLoader (it admits 0..2 or leaves the knob unset); a direct
// assignment is the only way here, and "T<n>" of a 7 would be a lie.
SessionFail(MGFatalFamily::UnimplementedAdoptTier,
"MGPipe: Fatal{UnimplementedAdoptTier, \"%u\"} - MOBILEGL_IPC_ADOPT_TIER=%u is not an "
"adoption tier; the values are 0 (T0), 1 (closed) and 2 (emulate, the default)",
@@ -39,9 +44,17 @@ namespace MobileGL::MG_Remote::Transport {
g_settled.store(true, std::memory_order_release);
if (knob == 2) return 2;
if (streamDataPlane) {
// A1, UNCHANGED: ONE LINE PER SESSION, on the side that holds the knob. The tcp lane's
// server is a shared fixture that never sees the client's environment, so each side
// says it for itself; neither side dies, because T2 is the only tier a stream carries.
// A1, UNCHANGED FOR A NAMED KNOB: ONE LINE PER SESSION, on the side that holds the knob.
// The tcp lane's server is a shared fixture that never sees the client's environment,
// so each side says it for itself; neither side dies, because T2 is the only tier a
// stream carries. AN UNSET KNOB (T0 by default) SAYS IT AT MGLOG_D: every tcp session
// would otherwise carry the line. The client counts it (ClientSession::T0Fallbacks).
if (AdoptTierIsDefault()) {
MGLOG_D("MG_Remote %s: T0 by default is not available on a stream data plane (tcp): the "
"session runs T2 (MOBILEGL_IPC_ADOPT_TIER unset; set 0 to have this named)",
SideName(side));
return 2;
}
MGLOG_W("MG_Remote %s: Refuse{AdoptTierOnStream, \"T%u\"} - MOBILEGL_IPC_ADOPT_TIER=%u names a "
"shared-mapping adoption tier and this session's data plane is a stream (tcp): the two "
"sides share no memory to map, so the session runs T2 (emulate: the client keeps the "
@@ -61,10 +74,11 @@ namespace MobileGL::MG_Remote::Transport {
"could run it); the session runs T2 (emulate). Set 0 for T0 or 2 for T2");
return 2;
}
// knob 0 over shared segments: asked in the Hello. Nothing is said yet - the answer is the
// server's, at its first native bind, and a T0 this session cannot use is named once, at
// the first map_persistent (ClientSession::AdoptT0).
return 0;
// knob 0 (or unset) over shared segments: asked in the Hello. Nothing is said yet - the
// answer is the server's, at its first native bind, and a T0 this session cannot use is
// named once (knob 0) or said at MGLOG_D (unset), at the first map_persistent
// (ClientSession::AdoptT0).
return AdoptTierAskFor(false);
}
bool AdoptTierSettledAtHandshake() { return g_settled.load(std::memory_order_acquire); }
+23 -8
View File
@@ -13,9 +13,11 @@
// and the server imports it; T1 = the server exports an opaque fd (CLOSED, ID-P11-1); T2 = the
// resource owner declines and the client keeps the shadow and pushes.
//
// MOBILEGL_IPC_ADOPT_TIER IS THE SWITCH (ruling ID-P11-14): 2, the default, is today's T2 byte
// for byte; 0 asks for T0; 1 is refused by name and runs T2. T0 that this session cannot use is
// never a Fatal - it is T2 plus one named line:
// MOBILEGL_IPC_ADOPT_TIER IS THE SWITCH (ruling ID-P11-14). UNSET - the default since 2026-09-29,
// the user's decision - asks for T0 and falls back to T2 QUIETLY (MGLOG_D only, still counted),
// so a tcp session or a host session is not one line longer; 0 asks for T0 BY NAME (the table
// below); 1 is refused by name and runs T2; 2 is T2 byte for byte. T0 that this session cannot use
// is never a Fatal - it is T2 plus one named line (knob 0) or one D line (unset):
//
// data plane side knob 0 knob 1
// Stream (tcp) either `Refuse{AdoptTierOnStream, "T0"}`, T2 `Refuse{AdoptTierOnStream, "T1"}`, T2
@@ -40,15 +42,28 @@ namespace MobileGL::MG_Remote::Transport {
enum class AdoptTierSide : std::uint8_t { Client, Server };
// THE HELLO'S T0 ASK WHEN THE KNOB IS UNSET (LinkTerms.adoptTier, protocol.fbs): T0 as asked
// by 0, except that the server names a refusal only at MGLOG_D. The ask travels because only
// the server knows why it did not grant T0 (its allow switch, its platform, its POST).
inline constexpr std::uint32_t kAdoptAskT0Default = 0x80;
// An ask that is a T0 ask (0 by name, kAdoptAskT0Default by default).
inline bool AdoptAskIsT0(std::uint32_t ask) { return ask == 0 || ask == kAdoptAskT0Default; }
// This process's knob asks for T0 (0, or unset).
bool AdoptTierWantsT0();
// This process's knob is unset: T0 fallbacks are quiet.
bool AdoptTierIsDefault();
// The tier the client's Hello asks for (LinkTerms.adoptTier): 0 when the knob says 0 and the
// plane it proposes is shared segments, else 2. Pure - the lines are the settle's.
// plane it proposes is shared segments, kAdoptAskT0Default when the knob is unset on shared
// segments, else 2. Pure - the lines are the settle's.
std::uint32_t AdoptTierAskFor(bool streamDataPlane);
// Settles this side's handshake answer from MOBILEGL_IPC_ADOPT_TIER and the negotiated data
// plane and returns the tier this side asks (client) or serves by its own knob (server): 0
// only for a client asking T0 over shared segments, 2 otherwise. Logs at most one line per
// call (A1's stream refusal, the T1 refusal). Never aborts for 0/1; a knob above 2 (only a
// direct assignment can make one) is still Fatal{UnimplementedAdoptTier}.
// plane and returns the ask this side made (client) or serves by its own knob (server):
// AdoptTierAskFor's value for a client asking T0 over shared segments, 2 otherwise. Logs at
// most one line per call (A1's stream refusal - at MGLOG_D when the knob is unset - and the
// T1 refusal). Never aborts for 0/1/unset; any other value (only a direct assignment can
// make one) is still Fatal{UnimplementedAdoptTier}.
std::uint32_t SettleAdoptTierAtHandshake(bool streamDataPlane, AdoptTierSide side);
// True once a handshake in this process has settled the tier. The at-use check trusts a