fix(headless): S4 report UnknownCommand/Dropped and never let submit escape DrainDue

HeadlessConsoleController.Handle called _submit(rawLine) bare: an
UnknownCommand/Dropped outcome printed nothing (the operator had no way
to tell their line did nothing), and any exception from the submit
callback would propagate out of DrainDue into the scheduler's
per-session quarantine catch, faulting the whole session over one
console typo. Wrap the submit in try/catch and report both cases with a
visible line, mirroring LoginCommandSequence.DrainDue's own reporting
for login-line failures.

N1: also corrected this class's own <remarks> doc comment, which
described the dispatch order as "plugin-verb registry -> client/server
slash commands" -- the real ChatCommandRouter.Submit order is retail's
client-command catalog, then local /help, then plugin verbs, then the
unregistered-channel-tag fallback, then an explicit server command, then
chat.

UnknownOrDroppedOutcomePrintsAVisibleLine and
SubmitFailurePrintsALineAndNeverEscapesDrainDue were shown to fail
against the prior bare `_submit(rawLine);` call: the outcome tests found
nothing printed, and the failure test caught the InvalidOperationException
escaping DrainDue itself rather than being reported as a line.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-09-07 07:56:34 +02:00
parent cb076c6558
commit f0b7a136b2
2 changed files with 78 additions and 4 deletions

View file

@ -15,9 +15,12 @@ namespace AcDream.Headless.Hosting;
/// "Control" section) — they never reach <see cref="ChatCommandRouter"/>,
/// matching retail's own client-local commands. Every other line goes
/// through <paramref name="submit"/>, which a production caller binds to
/// <c>HeadlessSessionHost.SubmitConsoleLine</c> — the exact plugin-verb
/// registry → client/server slash-command pipeline
/// <c>LoginCommandSequence</c> and the graphical chat box both already use.
/// <c>HeadlessSessionHost.SubmitConsoleLine</c> — the exact
/// <see cref="ChatCommandRouter.Submit"/> pipeline (retail's client-command
/// catalog first, then local <c>/help</c>, then the plugin-verb registry,
/// then the retail unregistered-channel-tag fallback, then an explicit
/// server command, then plain chat) <c>LoginCommandSequence</c> and the
/// graphical chat box both already use.
/// </remarks>
internal sealed class HeadlessConsoleController : IDisposable
{
@ -83,7 +86,24 @@ internal sealed class HeadlessConsoleController : IDisposable
return;
}
_submit(rawLine);
// S4 (2026-09-07 review round): mirrors
// LoginCommandSequence.DrainDue's own try/catch and
// UnknownCommand/Dropped reporting — a console typo (a bad line, a
// downstream bug in a plugin verb handler) must never escape to the
// scheduler's per-session quarantine catch and fault the whole
// session, and the operator deserves the same "this line did
// nothing" signal LoginCommandSequence already gives a login-line
// failure.
try
{
SubmitOutcome outcome = _submit(rawLine);
if (outcome is SubmitOutcome.UnknownCommand or SubmitOutcome.Dropped)
WriteLine($"not handled ({outcome}): {rawLine}");
}
catch (Exception error)
{
WriteLine($"command failed: {error.GetBaseException().Message}");
}
}
private void WriteLine(string text)