docs(diagnostics): command history is oldest first, not newest first (part of #344) - #452
Conversation
…(part of #344) GetCommandHistoryAsync was documented as returning the remembered commands "newest first". The device emits them OLDEST FIRST. The wire format is a "Last N commands:" header followed by "<n>: <command>" lines where <n> counts backwards from the present -- "1:" is the most recent command and it is printed LAST. Confirmed three times on a real Nq1 running fw 3.7.2. The decisive evidence: when you call the history query itself, SYSTem:LOG:CMDHistory? appears in the LAST slot of the returned list. It is necessarily the most recent command the device has seen at the moment it builds the reply, so if the list were newest-first it would be at index 0. The parser and its unit-test fixture were both already correct -- the fixture uses the true descending "3: / 2: / 1:" layout and CommandHistoryParser faithfully preserves the device's order. Only the prose was wrong, so this fixes the documentation rather than the returned order: the device's order is a meaningful chronological transcript, and reversing it would be a silent breaking change for consumers already reading it correctly. Corrects all five sites that claimed "newest first" (IDeviceDiagnostics, CommandHistoryParser class remarks and Parse returns, ScpiMessageProducer, and the DEVICE_INTERFACES.md recipe), each now also explaining that the stripped "<n>:" prefix counts backwards from the present. Adds a parser test that pins the direction so the contract cannot silently drift back. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
/agentic_review |
PR Summary by QodoFix diagnostics docs: SCPI command history is oldest-first (add test)
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
Summary
GetCommandHistoryAsyncis documented as returning the remembered commands "newest first". The device actually emits them oldest first. This PR fixes the prose — it does not change the returned order.Not merging — for review.
Bench evidence
Confirmed three times on a real Nq1 running fw 3.7.2. Full evidence is posted at daqifi-core#344 (comment).
The wire format is a
Last N commands:header followed by<n>: <command>lines where<n>counts backwards from the present —1:is the most recent command, and it is printed last:The decisive evidence: when you call the history query itself,
SYSTem:LOG:CMDHistory?appears in the last slot of the returned list. It is necessarily the most recent command the device has seen at the moment it builds the reply, so if the list were newest-first it would be at index 0.Why the docs, and not the code
The parser and its unit-test fixture were both already correct.
CommandHistoryParserTestsalready used the true descending3: / 2: / 1:layout, andCommandHistoryParserfaithfully preserves the device's order. Only the prose was wrong.Deliberately not reversing the returned list: the device's order is a meaningful chronological transcript, and flipping it would be a silent breaking change for any consumer already reading it correctly.
Changes
Five sites claimed "newest first" and all five were wrong. Each now says oldest first and explains that the stripped
<n>:prefix counts backwards from the present:<returns>, plus a new<remarks>explaining the numberingParse<returns>GetCommandHistoryremarksPlus a new parser test,
Parse_ReturnsOldestFirst_BecauseDeviceNumbersLinesBackwardsAndPrintsNewestLast, that pins the direction against the realLast 3 commands: / 3: A / 2: B / 1: Clayout and asserts exactly[A, B, C]— with C documented as the newest — so the contract cannot silently drift back.No production behavior changes; the only non-doc change is the added test.
Testing
Build clean on both TFMs, 0 warnings / 0 errors. Full suite run on net9.0 and net10.0:
Daqifi.Core.Tests— 2699 passed, 2 skipped, 5 failed on each TFMDaqifi.Mcp.Tests— 23 passedmainand unrelated to this PR. All five are inFirmwareUpdateServiceTests(WiFi module update / LAN recovery sequencing) and appear to come from the recently merged #444 / #445 WiFi prep commits. Verified by stashing this branch's changes and re-running against a clean tree at7965b26— the identical 5 tests fail:UpdateWifiModuleAsync_WhenCanceledAfterEnteringUpdateMode_StillTakesDeviceBackOutUpdateWifiModuleAsync_WhenCanceledDuringTransparentModeExitSettle_LeavesLanRestoreUnsentUpdateWifiModuleAsync_WhenFlashToolFails_TakesDeviceBackOutOfLanUpdateModeUpdateWifiModuleAsync_WhenRecoveryBudgetExpiresAfterReconnect_StillFinishesTheBridgeExitUpdateWifiModuleAsync_WhenRecoveryBudgetExpiresWaitingForReconnect_SendsNoBridgeExitThey all assert on expected SCPI command sequences and are failing on an unexpected leading
SYSTem:POWer:STATe 1. Worth a separate look — this PR touches none of that code.Part of #344.
🤖 Generated with Claude Code