resolveSessionDeadline function
Seeds the session deadline from the two boot sources with the ticket's override order: the host env first, the CLI flag second (later wins).
The env value is an epoch-ms integer; missing/invalid/past = feature
OFF, silent (the host's env is not the user's typo — never nag about
it). The flag spec (--timer/--deadline) is the user's own words:
an invalid one throws FormatException and the host must surface it
as a usage error, never boot with a silently wrong clock.
Implementation
SessionDeadline resolveSessionDeadline({
String? envValue,
String? flagSpec,
DateTime Function()? clock,
}) {
final deadline = SessionDeadline(clock: clock);
final raw = envValue?.trim();
if (raw != null && raw.isNotEmpty) {
final epoch = int.tryParse(raw);
if (epoch != null && epoch >= deadlineEpochMsFloor) {
try {
deadline.setEpochMs(epoch);
} on FormatException {
// Feature off, silent: the host env is not user input at the
// keyboard (a past deadline is the host's stale export, not a
// typo to nag about).
}
}
}
final flag = flagSpec?.trim();
if (flag != null && flag.isNotEmpty) {
deadline.setFromSpec(flag);
}
return deadline;
}