Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,17 @@ our host is unreachable and perfectly alive.
and a count. The engine clause is load-bearing and was measured — without it, two games lose the
only reading that says what they run (`northern-crossroads-ncmud` declares `NC-7.0.357.7940b961`,
`primal-darkness-ii` declares `PD/NM III`). `FAMILY` may **not** stand in for it: both of those
games declare one. **`INFO` and `VERSION` have no `AwaitingCorroboration` escape and are still
typed at the family above, every crawl** — issue #182 is where that is being thought about, and it
is not the same problem: there is nothing they would publish, so "not asking must imply publishing"
has nothing to hold on to.
games declare one.
- **Type `INFO` or `VERSION` at an address that has never answered them.** A game with no MSSP can
never pass `MsspSelfDescription`, so the family above was typed at every crawl: `INFO` read as a
character name, `VERSION` answered *create a new character called version? (y/n)* (issue #182).
`crawl_target.login_commands_*` (migration 0046) is the memory and `LoginCommands` the one place
that reads it: three sessions running in which `LoginCommandReading.Answered` finds nothing silence
the address **for good** (there is deliberately no retrial), and a submission still
awaiting §7.8 is always asked. **Only a session that typed `INFO` counts** (`ProbeResult.InfoAsked`): there is
nothing they would publish, so "not asking must imply publishing" has nothing to hold on to, and the
rule 5 hazard instead is our silence counted as theirs. Within a session, `INFO` answered by a name
prompt (`NamePrompt`) also spares the game our `VERSION`; a plain `Huh?` does not.
- **Type `MSSP-REQUEST` at an address that has reported over option 70, or that left its trial
unanswered.** The plaintext form is text at a login prompt, and eight of twenty surveyed games read
it as a character name. `crawl_target.mssp_route` (migration 0042) remembers each address's answer
Expand Down
5 changes: 4 additions & 1 deletion docs/codebase-survey-2026-07-30.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,10 @@ and `us.muds.net:4000` answer `negotiated (none observed)`, `mssp NotOffered`, a
chain is `WHO` → *好吧﹐那麼請重新輸入您的英文名字﹕* → `INFO` → the same → `VERSION` →
*使用 version 這個名字將會創造一個新的人物﹐您確定嗎(y/n)﹖*. `ProbeTarget.AwaitingCorroboration`
stops the `WHO`, on the argument that §7.8's signals are read by exactly one caller and only for an
uncorroborated submission. `INFO` and `VERSION` are not stopped — see issue #182.
uncorroborated submission. `INFO` and `VERSION` were not stopped until issue #182: an address now
stops being asked them after three sessions in which nothing in either reply was readable
(`LoginCommands`, `crawl_target.login_commands_*`), and `VERSION` is not sent at all once `INFO` has
come back as this name prompt.

### Verified against live servers, 2026-08-20

Expand Down
38 changes: 38 additions & 0 deletions migrations/0046_login_commands.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- crawl_target.login_commands_*: whether INFO and VERSION are still worth typing at this address.
--
-- Issue #182. MsspSelfDescription stops them only where an MSSP report already answers both, so a
-- game that publishes no MSSP was asked on every crawl, for ever, whatever it answered. At
-- fs.twkang.net:5555 and its siblings it answers nothing readable: INFO comes back as the name prompt
-- again and VERSION as "create a new character called version? (y/n)". A codebase that does not
-- answer INFO today almost certainly never will, so the decision is learned from the address's own
-- history rather than re-derived from one session (LoginCommands, in MUI.Discovery).
--
-- login_commands_unanswered consecutive sessions in which INFO was typed here and nothing in
-- the replies was something a reader stands behind. Capped at the
-- threshold. Back to 0 on the first session that yields anything.
-- login_commands_quiet_at NULL: asked. Set: the run reached the threshold at this time, and
-- INFO and VERSION are not typed here again. There is no retrial. The
-- one exception is a submission still awaiting corroboration, which
-- is asked regardless; an answer from it clears both columns.
--
-- A session in which we did not type INFO is no evidence either way and changes neither column, so
-- our silence is never counted as theirs (rule 5). And none of this is a fact about the game on any
-- public surface: it is our note about which questions we have stopped asking, read only by the
-- crawl loop.
--
-- No backfill: nothing persisted records what an INFO reply said, so every address starts asking
-- and earns its quiet in three sessions.
--
-- No BEGIN/COMMIT: MigrationRunner opens its own transaction per script and writes the ledger entry
-- inside it.

ALTER TABLE crawl_target
ADD COLUMN login_commands_unanswered smallint NOT NULL DEFAULT 0
CHECK (login_commands_unanswered >= 0),
ADD COLUMN login_commands_quiet_at timestamptz;

COMMENT ON COLUMN crawl_target.login_commands_unanswered IS
'Consecutive sessions in which INFO was typed here and no reply was readable. Capped.';

COMMENT ON COLUMN crawl_target.login_commands_quiet_at IS
'When INFO and VERSION stopped being typed here for want of an answer. NULL: still asked.';
28 changes: 28 additions & 0 deletions src/MUI.Crawl/LoginFlow/LoginCommandReading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,34 @@ public static partial class LoginCommandReading
?? FromUnlabelledVersion(version);
}

/// <summary>
/// Whether these replies held anything a reader downstream would stand behind.
/// </summary>
/// <remarks>
/// <para>
/// The question <c>LoginCommands.Learn</c> asks of a session: was typing <c>INFO</c> and
/// <c>VERSION</c> at this login prompt worth it? Answered by the consumers themselves rather than
/// by the shape of the text, so it cannot say yes to a reply nothing reads or no to one something
/// does: a codebase or a name (<c>FieldObservations</c>, <c>CatalogueBinder</c>,
/// <c>IdentityMatcher</c>), a count (<c>PresenceChoice</c>), and the MUCK reading that both
/// replies feed (<see cref="MuckNaming"/>).
/// </para>
/// <para>
/// <c>MuLikeness</c>'s vocabulary signal is not consulted. Its one consumer only reads it for a
/// submission still awaiting §7.8, and such a game is asked every session whatever this says.
/// </para>
/// <para>
/// A name prompt and a plain <c>Huh?</c> are the same answer here. Either way there was nothing to
/// read; the difference matters only within a session, where a name prompt to <c>INFO</c> also
/// spares the game our <c>VERSION</c> (<see cref="NamePrompt"/>).
/// </para>
/// </remarks>
public static bool Answered(string? info, string? version) =>
MeaningfulCodebase(info, version) is not null
|| MeaningfulName(info, version) is not null
|| ConnectedPlayers(info) is not null
|| MuckNaming.Assumed(info, version) is not null;

/// <summary>
/// The game's own name as its <c>INFO</c> block gives it, or null.
/// </summary>
Expand Down
45 changes: 45 additions & 0 deletions src/MUI.Crawl/LoginFlow/NamePrompt.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Text.RegularExpressions;

namespace MUI.Crawl;

/// <summary>
/// Whether a line is a login prompt that took what we typed for a character name.
/// </summary>
/// <remarks>
/// <para>
/// Read in two places, and one list so the two cannot drift: <see cref="WhoParser"/> asks it of the
/// reply to <c>WHO</c>, where a match means the server never had a <c>WHO</c> to answer
/// (<see cref="WhoReading.LoginPrompt"/>); and <c>TelnetProbe</c> asks it of the reply to
/// <c>INFO</c>, where a match means <c>VERSION</c> would be read the same way and is not sent.
/// </para>
/// <para>
/// The vocabulary is wider than one codebase: a game may ask for an <em>account</em> name rather than
/// a character's, print nothing but <c>Name:</c>, refuse a disliked name outright (<c>Illegal name,
/// try again.</c>, <c>That name is reserved for a senior member of the mud.</c>), or ask us to
/// confirm the spelling (<c>Did I get that right, Who (Y/N)?</c>).
/// </para>
/// <para>
/// The Chinese forms are the ES2/MudOS family's, measured at <c>fs.twkang.net:5555</c> (issue #182):
/// <c>INFO</c> came back <em>好吧﹐那麼請重新輸入您的英文名字﹕</em> ("re-enter your English name") and
/// <c>VERSION</c> <em>使用 version 這個名字將會創造一個新的人物﹐您確定嗎(y/n)﹖</em> ("the name version
/// will create a new character — are you sure?"). Both scripts, since the family runs in Big5 and
/// GBK alike. Readable only once the screen has been decoded as what it is, which for these games
/// means an operator's <c>CHARSET</c>; in the Latin-1 fallback they match nothing, and the probe
/// asks <c>VERSION</c> as it did before.
/// </para>
/// </remarks>
public static partial class NamePrompt
{
/// <summary>Whether this one line is a login prompt reading our input as a name.</summary>
public static bool IsIn(string line) => Pattern().IsMatch(line);

[GeneratedRegex(
@"no\s+character\s+by\s+that\s+name|enter\s+(?:the\s+|your\s+)?(?:\w+\s+)?name"
+ @"|create\s+a\s+new\s+(?:character|account|player)"
+ @"|what\s+is\s+your\s+name|password\s*:|type\s+'?new'?|\bname\s*:\s*$"
+ @"|\billegal\s+name\b|\bno\s+record\s+found\s+for\b|\bname\s+is\s+reserved\b"
+ @"|\bdid\s+i\s+get\s+that\s+right\b"
+ @"|[輸输]入[^\n]{0,6}名字|[創创]造一[個个]新的?人物",
RegexOptions.IgnoreCase)]
private static partial Regex Pattern();
}
16 changes: 16 additions & 0 deletions src/MUI.Crawl/Telnet/ProbeResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ public sealed record ProbeResult
/// <summary>The reply to <c>VERSION</c> at the login screen, when one arrived.</summary>
public string? Version { get; init; }

/// <summary>Whether <c>INFO</c> was typed at the login screen this session.</summary>
/// <remarks>
/// The difference between "not asked" and "asked, and nothing came back", which a null
/// <see cref="Info"/> cannot carry: it is null for both. <c>LoginCommands.Learn</c> counts a
/// session against a game only when this is true, so a session in which we held our tongue is
/// never read as one in which the game said nothing (rule 5, the <c>who_not_offered</c> lesson).
/// </remarks>
public bool InfoAsked { get; init; }

/// <summary>Whether <c>VERSION</c> was typed at the login screen this session.</summary>
/// <remarks>
/// Never without <see cref="InfoAsked"/>, and not always with it: a login prompt that took
/// <c>INFO</c> for a character name is not handed <c>VERSION</c> as a second one.
/// </remarks>
public bool VersionAsked { get; init; }

/// <summary>
/// Layer 4 — MSSP as the server reported it over telnet option 70. Every variable, every value,
/// in wire order.
Expand Down
20 changes: 20 additions & 0 deletions src/MUI.Crawl/Telnet/Probing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ public sealed record ProbeTarget(string Host, int Port)
/// </remarks>
public bool AwaitingCorroboration { get; init; } = true;

/// <summary>
/// Whether <c>INFO</c> and <c>VERSION</c> may be typed at this address's login prompt.
/// </summary>
/// <remarks>
/// <para>
/// False means this address has been asked both, session after session, and nothing in any reply
/// was something a reader here would stand behind — so it is not asked again. A codebase that does not answer <c>INFO</c> today almost certainly never will, and
/// at <c>fs.twkang.net:5555</c> each word is read as a character name: <c>VERSION</c> comes back
/// as <em>create a new character called version? (y/n)</em>, every crawl (issue #182).
/// </para>
/// <para>
/// True by default, so a caller that cannot say keeps asking, as with
/// <see cref="AwaitingCorroboration"/>. Only the crawl loop answers it, from
/// <c>crawl_target.login_commands_quiet_at</c> (migration 0046, see <c>LoginCommands</c>). An MSSP
/// report that already answers both (<see cref="MsspSelfDescription"/>) stops them whatever this
/// says.
/// </para>
/// </remarks>
public bool AskLoginCommands { get; init; } = true;

/// <summary>Whether to open this dial with a TLS handshake rather than in the clear.</summary>
/// <remarks>
/// <para>
Expand Down
69 changes: 63 additions & 6 deletions src/MUI.Crawl/Telnet/TelnetProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,26 @@ async Task<int> AskAsync(string command, int baseline, TimeSpan grace, Action? s
&& MsspSelfDescription.AnswersTheLoginCommands(
MsspReport.From(seen.Mssp, WireEncoding.Fallback));

if (Live(connection) && !described)
//
// And an address that has been asked both, session after session, and never once said
// anything a reader here could use (ProbeTarget.AskLoginCommands, issue #182). Whether to
// stop is the crawl loop's call, made from this address's history; this only obeys it.
var ask = !described && target.AskLoginCommands;

if (Live(connection) && ask)
{
cursors.Info = cursors.Version = await AskAsync(InfoCommand, cursors.Who, _options.SilenceGrace);
cursors.Info = cursors.Version = await AskAsync(
InfoCommand, cursors.Who, _options.SilenceGrace, () => seen.InfoAsked = true);
}

if (Live(connection) && !described)
// Within the session, too: a login prompt that took INFO for a character name will take
// VERSION for one, and at fs.twkang.net:5555 that is "create a new character called
// version? (y/n)". Only a name prompt stops it. A plain "Huh?" to INFO says nothing about
// VERSION, which some codebases answer without answering INFO.
if (Live(connection) && ask && !TookForAName(lines, cursors.Who, cursors.Info, seen, target))
{
cursors.Version = await AskAsync(VersionCommand, cursors.Info, _options.SilenceGrace);
cursors.Version = await AskAsync(
VersionCommand, cursors.Info, _options.SilenceGrace, () => seen.VersionAsked = true);
}
}
catch (Exception error) when (HungUp(error) && Measured(lines, cursors.Banner, seen))
Expand Down Expand Up @@ -967,8 +979,8 @@ async Task<int> AskAsync(string command, int baseline, TimeSpan grace, Action? s
/// nothing, publish no MSSP, state their count on the screen in Chinese, and read every line we
/// send as a character name: <c>WHO</c> comes back <em>請重新輸入您的英文名字</em> ("re-enter your
/// English name"), reproducibly, on every crawl. See <c>ChineseCount</c> for the reading that
/// makes the screen answer, and issue #182 for <c>INFO</c> and <c>VERSION</c>, which are still
/// typed at the same prompt.
/// makes the screen answer, and <see cref="ProbeTarget.AskLoginCommands"/> for <c>INFO</c> and
/// <c>VERSION</c> at the same prompt (issue #182).
/// </para>
/// </remarks>
private async Task<int?> PublishedCountAsync(
Expand Down Expand Up @@ -1023,6 +1035,40 @@ async Task<int> AskAsync(string command, int baseline, TimeSpan grace, Action? s
return BannerCount.Find(PuebloSignal.IsPresent(banner) ? PuebloSignal.StripKnown(banner) : banner);
}

/// <summary>
/// Whether the reply between these two cursors is a login prompt that read our command as a
/// character name, and offered nothing else.
/// </summary>
/// <remarks>
/// Decoded the way <see cref="PublishedCountAsync"/> decodes the connect screen, and for the same
/// reason: the session-wide charset decision is still ahead, and this has to be answered before
/// the next line is sent. A reply that a reader could use is never a name prompt here, whatever
/// else it contains: a real <c>INFO</c> block may well say <c>Name:</c>.
/// </remarks>
private static bool TookForAName(List<byte[]> lines, int from, int to, Observations seen, ProbeTarget target)
{
if (to <= from)
{
return false;
}

List<byte[]> reply;
lock (lines)
{
reply = [.. lines.Skip(from).Take(to - from)];
}

var text = string.Join(
"\n",
WireEncoding.Read(reply, target.Charset, MsspReport.RawValues(seen.Mssp), target.MsspCharset).Lines);

return !LoginCommandReading.Answered(text, null)
&& global::MarkupString.Ansi.AnsiEscapeParser.Parse(text).ToPlainText()
.Split('\n')
.Select(line => line.TrimEnd())
.Any(NamePrompt.IsIn);
}

/// <summary>Builds the <see cref="ProbeOutcome.Answered"/> result from a completed session.</summary>
private static ProbeResult BuildAnsweredResult(
ProbeTarget target,
Expand Down Expand Up @@ -1103,6 +1149,8 @@ private static ProbeResult BuildAnsweredResult(
: (asked ? PayloadRedaction.Replayable(whoText) : null),
Info = infoText.Length == 0 ? null : infoText,
Version = versionText.Length == 0 ? null : versionText,
InfoAsked = seen.InfoAsked,
VersionAsked = seen.VersionAsked,
// `published` is the count that bought this game its silence — see PublishedCountAsync for
// why not asking must imply publishing. Second, not first: the session-wide charset
// decision is made above and a screen this decode reads better is read better.
Expand Down Expand Up @@ -1664,6 +1712,15 @@ private sealed class Observations
/// <summary>Set while a plaintext <c>MSSP-REQUEST</c> waits for its reply.</summary>
public volatile bool AskingPlaintext;
public int? MsspRejectedBytes;

/// <summary>
/// Whether <c>INFO</c> and <c>VERSION</c> left this session, each set between its write and
/// its wait. See <see cref="ProbeResult.InfoAsked"/>.
/// </summary>
public bool InfoAsked;

/// <inheritdoc cref="InfoAsked"/>
public bool VersionAsked;
public string? Charset;
public bool Prompts;
public int? CompressionVersion;
Expand Down
17 changes: 1 addition & 16 deletions src/MUI.Crawl/Who/WhoParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ private static bool IsTerminator(string line) =>
/// <summary>
/// Whether the server answered the login prompt rather than the question.
/// </summary>
private static bool LooksLikeLoginPrompt(string line) => LoginPromptPattern().IsMatch(line);
private static bool LooksLikeLoginPrompt(string line) => NamePrompt.IsIn(line);

private static string StripAnsi(string text) => AnsiEscapeParser.Parse(text).ToPlainText();

Expand Down Expand Up @@ -560,19 +560,4 @@ private static bool IsTerminator(string line) =>
+ @"\b[^.\n]{0,40}?\b" + Connectivity + @"\b",
RegexOptions.IgnoreCase)]
private static partial Regex WordedOutOfPattern();

// Login prompts that mean WHO was eaten as a character name. Vocabulary is wider than one
// codebase: a game may ask for an *account* name rather than a character's, print nothing but
// "Name:", refuse a disliked name outright ("Illegal name, try again.", "That name is reserved
// for a senior member of the mud."), or ask us to confirm the spelling ("Did I get that right,
// Who (Y/N)?").
[GeneratedRegex(
@"no\s+character\s+by\s+that\s+name|enter\s+(?:the\s+|your\s+)?(?:\w+\s+)?name"
+ @"|create\s+a\s+new\s+(?:character|account|player)"
+ @"|what\s+is\s+your\s+name|password\s*:|type\s+'?new'?|\bname\s*:\s*$"
+ @"|\billegal\s+name\b|\bno\s+record\s+found\s+for\b|\bname\s+is\s+reserved\b"
+ @"|\bdid\s+i\s+get\s+that\s+right\b",
RegexOptions.IgnoreCase)]
private static partial Regex LoginPromptPattern();

}
Loading
Loading