fix #363/#367: route unknown-command refusals to chat, not SpewBox

Owner direction 2026-09-07 (verbatim): "Unknown commands like /vt or
stuff from plugins shall now go to the SpewBox. They should go to the
chatbox." Retail itself types ChatCommandRouter's "Unknown command"
refusals as ClientLocal (0x1A) -- the bit every ChatInterface window's
default filter excludes, so they only ever reached the transient
SpewBox overlay and left no transcript record.

Three call sites in ChatCommandRouter.Submit/EmitVerbHelp now call
IChatCommandFeedback.ShowSystemMessage (chat scroll, retail
Default/0x00) instead of ShowInterfaceText (SpewBox): the degenerate-
prefix "Unknown command: {verb}." guard, EmitVerbHelp's confirmed-
null-help branch, and EmitVerbHelp's unresolved-verb fallback. Every
OTHER 0x1A refusal in this file (AP-183 bad-argument refusals of REAL
retail commands -- lifestone, marketplace, channel list/on/off,
allegiance, house, the generic HandleFailureEvent(0x26) fallback,
DoStupidChannelHack, DoReply) is unchanged and still SpewBox-only --
the owner named only unknown commands and plugin text.

This is a deliberate deviation from retail's own 0x1A typing, recorded
as register row AD-124 (also covers the sibling plugin-text change in
a follow-up commit). docs/ISSUES.md #363/#367 get a one-line note
under each pointing at the re-route; their CLOSED status is untouched.

Mutation check: temporarily reverted all three ShowSystemMessage call
sites back to ShowInterfaceText and confirmed the 3 new/changed pinned
tests fail (Assert.Single() on an empty chat log) while the AP-183
boundary test (real command, bad args, still SpewBox) continues to
pass -- see ChatCommandRouterFeedbackRoutingTests.cs and the updated
ChatCommandRouterTests.cs/RetailCommandHelpTableTests.cs assertions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-09-07 08:22:06 +02:00
parent 1637bae31d
commit 6b7b4bb213
7 changed files with 234 additions and 58 deletions

View file

@ -74,30 +74,30 @@ after each deliberate `Top` write for the imported-layout element. Precedent:
`MapPageController.cs:235-249` (the same fix already landed for other
runtime-repositioned imported/programmatic elements).
## #488 — MossTank `.utl` expression block: length prefix measured before newline normalization
**Status:** OPEN — found 2026-09-07 by the final Opus re-check of Campaign VT
slice 1 Part A (`f58e997b1`), not reachable from the UI.
**Severity:** LOW (latent)
**Component:** `src/AcDream.Plugins.MossTank/MossTankLootProfileStore.cs` (`AttachMossTankExpressions` ~504-521, `ApplyMossTankExpressions` ~539-554) vs `VtankLootProfileSerializer.cs` (`WriteBlock` ~357-366, `NormalizePayload`)
**Description.** The MossTank-owned unknown block that carries each loot rule's
`Expression` text writes `expression.Length` as a length prefix and then the raw
text; `WriteBlock` normalizes the whole payload afterwards, rewriting a lone
`
## #488 — MossTank `.utl` expression block: length prefix measured before newline normalization
**Status:** OPEN — found 2026-09-07 by the final Opus re-check of Campaign VT
slice 1 Part A (`f58e997b1`), not reachable from the UI.
**Severity:** LOW (latent)
**Component:** `src/AcDream.Plugins.MossTank/MossTankLootProfileStore.cs` (`AttachMossTankExpressions` ~504-521, `ApplyMossTankExpressions` ~539-554) vs `VtankLootProfileSerializer.cs` (`WriteBlock` ~357-366, `NormalizePayload`)
**Description.** The MossTank-owned unknown block that carries each loot rule's
`Expression` text writes `expression.Length` as a length prefix and then the raw
text; `WriteBlock` normalizes the whole payload afterwards, rewriting a lone
`
`/` ` to `
`. An expression containing a bare newline therefore grows
after its prefix was measured, the reader truncates it, lands mid-text on the
next length line, fails `int.TryParse` and silently abandons every remaining
rule's expression. The loot expression control is a single-line field so the UI
cannot author one; the legacy-JSON sweep can (free-form JSON).
**Fix shape.** Normalize the expression before measuring it (or escape/refuse
newlines in the block), with a pin that writes a two-line expression and reads
it back through `VtankLootProfileSerializer.TryRead`. Companion cosmetics from
the same re-check: the unreachable `remaining` roster branch in the route and
loot sweeps, and the meta Delete notice printing the raw file name.
`. An expression containing a bare newline therefore grows
after its prefix was measured, the reader truncates it, lands mid-text on the
next length line, fails `int.TryParse` and silently abandons every remaining
rule's expression. The loot expression control is a single-line field so the UI
cannot author one; the legacy-JSON sweep can (free-form JSON).
**Fix shape.** Normalize the expression before measuring it (or escape/refuse
newlines in the block), with a pin that writes a two-line expression and reads
it back through `VtankLootProfileSerializer.TryRead`. Companion cosmetics from
the same re-check: the unreachable `remaining` roster branch in the route and
loot sweeps, and the meta Delete notice printing the raw file name.
## #487 — Radar compass tokens may be pinned by the anchor pass (candidate)
**Status:** OPEN — CANDIDATE, found 2026-09-06 by the Opus review of
@ -5922,6 +5922,13 @@ slice CH4).
## #363 — Chat refusal/usage call sites are typed ClientLocal 0x00 where retail types several 0x1A
**2026-09-07 owner-directed re-route:** the "Unknown command" refusals this
issue's closure routed to `ShowInterfaceText`/SpewBox now route to
`ShowSystemMessage`/the chat scroll instead, per explicit owner direction
that unknown commands must be visible in chat, not the SpewBox overlay.
Every OTHER site this issue named (bad-args refusals of real commands,
AP-183) is unaffected. See register row AD-124.
**Status:** CLOSED 2026-08-10. `ChatVM` gained a typed interface-text seam
(`OnInterfaceText` init hook + `ShowInterfaceText(text)`) that the App-layer
composition (`InteractionRetainedUiComposition.CreateRetainedUi`) wires to
@ -6261,6 +6268,14 @@ still missing); `src/AcDream.App/UI/Layout/LayoutImporter.cs`
## #367 — ChatCommandRouter's local-presentation fallbacks type-0x1A text still lands in the chat scroll, never the SpewBox
**2026-09-07 owner-directed re-route:** the two fallbacks this issue named
(`RetailCommandHelpTable.UnknownCommand` in `EmitVerbHelp`, and the
degenerate-prefix "Unknown command: {verb}." refusal) now call
`ShowSystemMessage(...)` again — back to the chat scroll, by explicit owner
direction that unknown commands must be visible there rather than in the
SpewBox this issue's 2026-08-10 closure moved them to. See register row
AD-124; this is a deliberate re-reversal, not a regression of this issue.
**Status:** CLOSED 2026-08-10, closed as a side effect of #363's
interface-text seam (fix shape (a) from this issue's own filing).
`ChatVM.OnInterfaceText` is exactly the hook this issue asked for; both

File diff suppressed because one or more lines are too long

View file

@ -120,13 +120,19 @@ public static class ChatCommandRouter
// Command-shaped but no letter verb ("/", "//shrug", "@ x"):
// refuse locally rather than putting junk on the wire or in speech.
// #363/#367: this is one of retail's DoHelp-family "Unknown
// command" fallbacks (0x1A ClientLocal, SpewBox-only) — routed
// through the interface-text seam now that one exists, instead of
// the chat scroll.
// command" fallbacks — retail itself types it 0x1A ClientLocal
// (SpewBox-only). Owner-directed override 2026-09-07 (register row
// AD-124): unknown-command refusals specifically must reach the
// chat window instead, so ShowSystemMessage (chat scroll, retail
// Default/0x00) replaces ShowInterfaceText (SpewBox) HERE ONLY —
// do not "fix" this back to ShowInterfaceText; that would silently
// re-hide the refusal the owner asked to keep visible. Real
// retail-command bad-argument refusals (AP-183) are UNCHANGED and
// still use ShowInterfaceText/SpewBox elsewhere in this file.
if (trimmed[0] is '/' or '@'
&& (trimmed.Length == 1 || !char.IsLetter(trimmed[1])))
{
feedback.ShowInterfaceText(
feedback.ShowSystemMessage(
$"Unknown command: {ChatInputParser.GetVerbToken(trimmed)}. Type /help for the list of supported commands.");
return SubmitOutcome.UnknownCommand;
}
@ -345,7 +351,11 @@ public static class ChatCommandRouter
// SAME fallback an unregistered verb gets — DoHelp's help-
// pointer-null guard skips its callback branch entirely. See
// RetailCommandHelpTable.CatalogVerbsWithNoRetailHelp's remarks.
feedback.ShowInterfaceText(RetailCommandHelpTable.UnknownCommand);
// Owner-directed override 2026-09-07 (register row AD-124):
// this is an "Unknown command" refusal, so ShowSystemMessage
// (chat scroll) replaces ShowInterfaceText (SpewBox) here —
// do not revert.
feedback.ShowSystemMessage(RetailCommandHelpTable.UnknownCommand);
return;
}
@ -370,10 +380,14 @@ public static class ChatCommandRouter
return;
}
// Retail types this 0x1A (ClientLocal) -> SpewBox-only. #363/#367:
// now routed through IChatCommandFeedback.ShowInterfaceText instead
// of the chat scroll — see RetailCommandHelpTable.UnknownCommand.
feedback.ShowInterfaceText(RetailCommandHelpTable.UnknownCommand);
// Retail types this 0x1A (ClientLocal) -> SpewBox-only. #363/#367
// originally routed it through IChatCommandFeedback.ShowInterfaceText
// for exactly that reason. Owner-directed override 2026-09-07
// (register row AD-124): "Unknown command" refusals must reach the
// chat window instead, so ShowSystemMessage replaces
// ShowInterfaceText here — see RetailCommandHelpTable.UnknownCommand
// and do not revert this to ShowInterfaceText.
feedback.ShowSystemMessage(RetailCommandHelpTable.UnknownCommand);
}
private static bool EqAny(string value, params string[] options)

View file

@ -210,15 +210,29 @@ namespace AcDream.Runtime.Chat;
/// </para>
///
/// <para>
/// <b>Issue #363 (2026-08-10):</b> <c>ChatCommandRouter</c> now routes this
/// <b>Issue #363 (2026-08-10):</b> <c>ChatCommandRouter</c> routed this
/// fallback (and every other <c>0x1A</c> command-refusal call site) through
/// <c>IChatCommandFeedback.ShowInterfaceText</c> — an optional hook the host
/// wires to <c>RuntimeCommunicationState.AddText</c>, the same SpewBox
/// chokepoint every other producer of interface text uses. The retained
/// <c>ChatVM</c> implements this four-member feedback seam without entering
/// command-routing code. Closes ISSUES.md #367 and retires register row
/// command-routing code. Closed ISSUES.md #367 and retired register row
/// AP-186.
/// </para>
///
/// <para>
/// <b>Owner-directed override 2026-09-07 (register row AD-124):</b> the
/// paragraph above still describes retail's own behavior faithfully, but
/// acdream no longer matches it for exactly this <see cref="UnknownCommand"/>
/// text (both its call sites in <c>ChatCommandRouter.EmitVerbHelp</c>) and
/// the sibling "Unknown command: {verb}." refusal in
/// <c>ChatCommandRouter.Submit</c>'s own body: those three sites now call
/// <c>IChatCommandFeedback.ShowSystemMessage</c> (the chat scroll, retail
/// <c>Default</c>/0x00) instead of <c>ShowInterfaceText</c> (SpewBox), so an
/// unknown command is actually visible and stays in the transcript. Every
/// OTHER <c>0x1A</c> refusal this class documents (bad-args, AP-183) is
/// unchanged and still SpewBox-only.
/// </para>
/// </summary>
public static class RetailCommandHelpTable
{
@ -266,9 +280,16 @@ public static class RetailCommandHelpTable
// acclient_2013_pseudo_c.txt:395052 (u"Unknown command", UTF-16LE) --
// DoHelp's fallback when the verb hash lookup fails, or resolves to an
// entry with no registered help callback. Retail types this 0x1A
// (ClientLocal) -- SpewBox-only; see the class remarks' routing note --
// ChatCommandRouter routes it through IChatCommandFeedback.ShowInterfaceText
// (issue #363), closing #367.
// (ClientLocal) -- SpewBox-only; see the class remarks' routing note.
// Owner-directed override 2026-09-07 (register row AD-124): acdream
// now routes THIS text (and the sibling "Unknown command: {verb}."
// refusal in ChatCommandRouter.Submit's own body) through
// IChatCommandFeedback.ShowSystemMessage (chat scroll) instead of
// ShowInterfaceText (SpewBox) — a deliberate deviation from retail's
// own 0x1A typing, scoped to unknown-command text only. Do not revert
// this to ShowInterfaceText without a fresh owner direction; every
// other 0x1A refusal in ChatCommandRouter (bad-args, AP-183) is
// unaffected and still uses ShowInterfaceText/SpewBox.
public const string UnknownCommand = "Unknown command";
// @mr/@pr are registered with a NULL function pointer in the 2013

View file

@ -0,0 +1,111 @@
using AcDream.Core.Chat;
using AcDream.Runtime.Chat;
using AcDream.Runtime.Gameplay;
namespace AcDream.Runtime.Tests.Chat;
/// <summary>
/// Owner direction 2026-09-07 (verbatim): "Unknown commands like /vt or
/// stuff from plugins shall now go to the SpewBox. They should go to the
/// chatbox." Register row AD-124 records the deviation from retail's own
/// ClientLocal (0x1A) typing for exactly these two families. This file pins
/// the <see cref="ChatCommandRouter"/> half of that change at the Runtime
/// layer — <see cref="RuntimeChatCommandFeedback"/> bound to a real
/// <see cref="RuntimeCommunicationState"/> — since the existing router
/// coverage in <c>AcDream.UI.Abstractions.Tests</c> only exercises the
/// <c>ChatVM</c> feedback implementation. The plugin-text half is pinned at
/// the App layer (<c>AppAutomationSurfaceTests.PostSystemMessage_RoutesToChatLog_NeverSpewBox</c>),
/// since <c>AppAutomationSurface</c> is the App-layer production
/// implementation of <c>IPluginChat</c>.
/// </summary>
public sealed class ChatCommandRouterFeedbackRoutingTests
{
[Fact]
public void DegeneratePrefix_UnknownCommandRefusal_RoutesToChatLog_NeverSpewBox()
{
// "/" alone (no letter verb) is the degenerate-prefix guard's
// "Unknown command: {verb}." refusal — retail itself types this
// 0x1A (ClientLocal / SpewBox-only); the owner override moves it to
// the chat scroll (Default/0x00) instead.
using var communication = new RuntimeCommunicationState();
var feedback = new RuntimeChatCommandFeedback(communication);
SubmitOutcome outcome = ChatCommandRouter.Submit(
"/", feedback, NullCommandBus.Instance, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.UnknownCommand, outcome);
ChatEntry entry = Assert.Single(communication.Chat.Snapshot());
Assert.Contains("Unknown command:", entry.Text);
Assert.Equal((uint)RetailLogTextType.Default, entry.LogTextType);
communication.SpewBox.Tick(0d);
Assert.Equal(0, communication.SpewBox.Count);
}
[Fact]
public void HelpUnresolvedVerb_UnknownCommandText_RoutesToChatLog_NeverSpewBox()
{
// "/help nonsenseverb" hits EmitVerbHelp's final unresolved-verb
// fallback (RetailCommandHelpTable.UnknownCommand), the exact
// existing retail-swept text — only the destination changes.
using var communication = new RuntimeCommunicationState();
var feedback = new RuntimeChatCommandFeedback(communication);
SubmitOutcome outcome = ChatCommandRouter.Submit(
"/help nonsenseverb", feedback, NullCommandBus.Instance, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
ChatEntry entry = Assert.Single(communication.Chat.Snapshot());
Assert.Equal(RetailCommandHelpTable.UnknownCommand, entry.Text);
Assert.Equal((uint)RetailLogTextType.Default, entry.LogTextType);
communication.SpewBox.Tick(0d);
Assert.Equal(0, communication.SpewBox.Count);
}
[Fact]
public void HelpConfirmedNullVerb_UnknownCommandText_RoutesToChatLog_NeverSpewBox()
{
// "index" is one of the four catalog verbs retail registers with a
// genuinely NULL help pointer (RetailCommandHelpTable.
// CatalogVerbsWithNoRetailHelp) — EmitVerbHelp's OTHER "Unknown
// command" call site, distinct from the unresolved-verb fallback
// above.
using var communication = new RuntimeCommunicationState();
var feedback = new RuntimeChatCommandFeedback(communication);
SubmitOutcome outcome = ChatCommandRouter.Submit(
"/help index", feedback, NullCommandBus.Instance, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
ChatEntry entry = Assert.Single(communication.Chat.Snapshot());
Assert.Equal(RetailCommandHelpTable.UnknownCommand, entry.Text);
Assert.Equal((uint)RetailLogTextType.Default, entry.LogTextType);
communication.SpewBox.Tick(0d);
Assert.Equal(0, communication.SpewBox.Count);
}
[Fact]
public void RealCommandBadArguments_StillRoutesToSpewBox_NeverChatLog()
{
// Boundary pin: AP-183's bad-argument refusals of REAL retail
// commands are UNCHANGED by the owner's 2026-09-07 direction, which
// named only unknown commands and plugin text. "/ls now" (Lifestone
// with bad args) must still land in the SpewBox exclusively.
using var communication = new RuntimeCommunicationState();
var feedback = new RuntimeChatCommandFeedback(communication);
SubmitOutcome outcome = ChatCommandRouter.Submit(
"/ls now", feedback, NullCommandBus.Instance, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
Assert.Empty(communication.Chat.Snapshot());
communication.SpewBox.Tick(0d);
Assert.Equal(1, communication.SpewBox.Count);
Assert.Equal(
"Please see @help lifestone for more information on how to use this command.",
communication.SpewBox.Snapshot()[0].Text);
}
}

View file

@ -406,28 +406,35 @@ public class ChatCommandRouterTests
}
[Fact]
public void HelpVerb_UnknownVerb_ShowsRetailUnknownCommandText_ViaInterfaceTextSeam()
public void HelpVerb_UnknownVerb_ShowsRetailUnknownCommandText_InChatLog_TaggedDefault()
{
// Campaign CH user-gate round 3 (2026-08-10): retail's own DoHelp
// fallback text is "Unknown command" (swept verbatim), not an
// acdream-invented "No help available" message. Retail types this
// 0x1A (ClientLocal / SpewBox-only). Issue #363/#367: now routed
// through the interface-text seam as ONE entry (no HelpPrefixNote
// wrapper — DoHelp's fallback bypasses the two-entry shape
// entirely), not the chat scroll.
// acdream-invented "No help available" message. Retail itself types
// this 0x1A (ClientLocal / SpewBox-only). Owner-directed override
// 2026-09-07 (register row AD-124): "Unknown command" refusals now
// route to the CHAT SCROLL (ShowSystemMessage, Default/0x00) instead
// of the interface-text/SpewBox seam — the seam stays empty.
var (vm, log, bus, interfaceTexts) = FixtureWithInterfaceSink();
var outcome = ChatCommandRouter.Submit("/help nonsenseverb", vm, bus, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
Assert.Empty(bus.Published);
Assert.Equal(RetailCommandHelpTable.UnknownCommand, Assert.Single(interfaceTexts));
Assert.Empty(log.Snapshot());
Assert.Empty(interfaceTexts);
var entry = Assert.Single(log.Snapshot());
Assert.Equal(RetailCommandHelpTable.UnknownCommand, entry.Text);
Assert.Equal((uint)RetailLogTextType.Default, entry.LogTextType);
}
[Fact]
public void HelpVerb_UnknownVerb_NoInterfaceSinkWired_FallsBackToChatLog_TaggedClientLocal()
public void HelpVerb_UnknownVerb_NoInterfaceSinkWired_StillRoutesToChatLog_TaggedDefault()
{
// Owner-directed override 2026-09-07 (register row AD-124):
// ShowSystemMessage never depended on OnInterfaceText wiring in the
// first place, so headless / no-window hosts see the identical
// chat-log entry whether or not a sink is wired — unlike the old
// ShowInterfaceText null-fallback this test used to pin.
var (vm, log, bus) = Fixture();
var outcome = ChatCommandRouter.Submit("/help nonsenseverb", vm, bus, ChatChannelKind.Say);
@ -435,7 +442,7 @@ public class ChatCommandRouterTests
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
var entry = Assert.Single(log.Snapshot());
Assert.Equal(RetailCommandHelpTable.UnknownCommand, entry.Text);
Assert.Equal((uint)RetailLogTextType.ClientLocal, entry.LogTextType);
Assert.Equal((uint)RetailLogTextType.Default, entry.LogTextType);
}
[Fact]
@ -588,19 +595,23 @@ public class ChatCommandRouterTests
}
[Fact]
public void DegeneratePrefix_UnknownCommand_ShowsRefusal_ViaInterfaceTextSeam()
public void DegeneratePrefix_UnknownCommand_ShowsRefusal_InChatLog_TaggedDefault()
{
// "/" alone (no letter verb) — the pre-existing "Unknown command:
// {verb}." refusal, now also routed through the interface-text
// seam (issue #367).
// {verb}." refusal. Owner-directed override 2026-09-07 (register
// row AD-124): routed to the chat scroll (ShowSystemMessage,
// Default/0x00), NOT the interface-text/SpewBox seam issue #367
// originally moved it to.
var (vm, log, bus, interfaceTexts) = FixtureWithInterfaceSink();
var outcome = ChatCommandRouter.Submit("/", vm, bus, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.UnknownCommand, outcome);
Assert.Empty(bus.Published);
Assert.Contains("Unknown command:", Assert.Single(interfaceTexts));
Assert.Empty(log.Snapshot());
Assert.Empty(interfaceTexts);
var entry = Assert.Single(log.Snapshot());
Assert.Contains("Unknown command:", entry.Text);
Assert.Equal((uint)RetailLogTextType.Default, entry.LogTextType);
}
[Fact]

View file

@ -395,10 +395,13 @@ public sealed class RetailCommandHelpTableTests
// assignment, unlike every extracted verb above -- confirming a
// genuinely NULL help function pointer. Retail's own DoHelp skips
// its help-callback branch entirely for these and falls to the
// SAME "Unknown command" 0x1A text an unregistered verb gets, even
// though the verb dispatches fine for ordinary (non-help) use.
// Showing the catalog's own invented summary here would be
// retail-inaccurate.
// SAME "Unknown command" text an unregistered verb gets (retail
// itself types it 0x1A), even though the verb dispatches fine for
// ordinary (non-help) use. Showing the catalog's own invented
// summary here would be retail-inaccurate. Owner-directed override
// 2026-09-07 (register row AD-124): acdream routes this "Unknown
// command" text to the CHAT SCROLL (Default/0x00) rather than
// retail's own SpewBox-only 0x1A typing.
var log = new AcDream.Core.Chat.ChatLog();
var vm = new ChatVM(log, displayLimit: 50);
var bus = new RecordingCommandBus();
@ -411,7 +414,7 @@ public sealed class RetailCommandHelpTableTests
Assert.Single(entries);
Assert.Equal(RetailCommandHelpTable.UnknownCommand, entries[0].Text);
Assert.Equal(
(uint)AcDream.Core.Chat.RetailLogTextType.ClientLocal,
(uint)AcDream.Core.Chat.RetailLogTextType.Default,
entries[0].LogTextType);
}