engine, imsd: a submit report for a MESSAGE no longer in flight that this run sent in the last hour is answered 200

TS 24.341 5.3.1.2 has a submit report answered 200 when its In-Reply-To
"indicates that the request corresponds to a short message submitted by
the SM-over-IP sender" and 488 when it does not, and its NOTE 3 has the
sender store the Call-ID for that. imsd knew only the Call-ID of the
segment in flight (OwnsReport): a report that came once its message had
ended — the 40 s wait run out — or once its segment was followed by the
next was answered 488 like a stranger's, and its line said only "no
MESSAGE of ours in flight" (issue #3, the first of its three cases).

RecentSubmissions keeps the Call-ID of every MESSAGE a submission goes
out in for an hour, with the message's id and the segment. A report
In-Reply-To one of them that the message in flight does not take is
answered 200, and the journal has `submit report (RP-ACK) In-Reply-To
…: sms <id>'s segment i/n, no longer in flight; 200`, an RP-ERROR's
with its cause. The 488 is left for an In-Reply-To that names no MESSAGE
of ours on record, and its line says so ("on record" for "in flight").
A report without In-Reply-To that no message in flight takes by its
RP-MR is answered 200 as before; its line ends `that no message in
flight owns; 200` where it ended `for no message in flight; 200`.

The bus is told nothing of a late report: the Messaging interface is
frozen with `failed` as a message's last word (AGENTS.md §8.4), so a
text the service centre took after its wait had run out stays `failed`
there; the journal's line is the record of it.

Tested by tests/Engine: the table (a Call-ID on record for 3600 s, the
first of a list that is ours, each segment's MESSAGE put on record as it
goes out) and OnSmsMessage (200 and the line for a report on a segment
that was followed by the next, on a message that was sent and, with an
RP-ERROR's cause, on one its wait had ended; 488 and its line for a
stranger's). On the dev phone, with the binary of this range's last
commit, no report came for a MESSAGE no longer in flight (the fp6
journal's 2026-11-20-issues-2-5 capture, phone-form6), so the 200 for
one and its line have run in the suite alone.
This commit is contained in:
Jorijn van der Graaf 2026-11-22 17:35:12 +01:00
commit ef04b473a7
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
4 changed files with 203 additions and 94 deletions

View file

@ -1676,6 +1676,7 @@ private:
std::string smsc_; // the service centre's number (empty: none known)
std::vector<std::uint8_t> scAddress_; // the same as the RP-DATA's destination: [octets][toa][digits]
std::optional<std::uint8_t> smsValidity_; // EF_SMSP's TP-Validity-Period
imsd::engine::RecentSubmissions smsSubmitted_; // the Call-IDs of the MESSAGEs our submissions went out in, an hour each: a late submit report is answered 200, not 488
std::optional<imsd::engine::SmsOutbound> smsOut_; // the message in flight
std::deque<std::pair<std::string, imsd::engine::SmsOutbound::Params>> smsPending_; // queued behind it
std::set<std::string> reportCallIds_; // the delivery reports' Call-IDs, each until a final comes for it
@ -2932,7 +2933,7 @@ private:
p.tpMr = tpMr_; p.rpMr = rpMr_; p.concatRef = concatRef_;
const bool wantsReport = p.statusReport;
const std::string destination = p.number;
smsOut_.emplace(ctx_, rng_, id, std::move(p));
smsOut_.emplace(ctx_, rng_, smsSubmitted_, id, std::move(p));
auto actions = smsOut_->Start(Mono());
// on record from the start — the SC may deliver segment 1 and report on
// it while segment 2 is still in flight — and only for a message that
@ -3016,7 +3017,7 @@ private:
if (reply_) reply_(*again);
return;
}
auto r = imsd::engine::OnSmsMessage(ctx_, rng_, msg, reassembler_, smsOut_ ? &*smsOut_ : nullptr, Mono());
auto r = imsd::engine::OnSmsMessage(ctx_, rng_, msg, reassembler_, smsOut_ ? &*smsOut_ : nullptr, smsSubmitted_, Mono());
recentMessages_.Remember(key, r.response, Mono());
if (reply_) reply_(r.response);
if (!r.reportCallId.empty()) reportCallIds_.insert(r.reportCallId);