User config to dispatch command if sequence table is full - #6006
michaelkiper wants to merge 12 commits into
Conversation
…ence commands even when the sequence table is full
| void CommandDispatcherImpl::seqCmdBuff_handler(FwIndexType portNum, Fw::ComBuffer& data, U32 context) { | ||
| Fw::CmdPacket cmdPkt; | ||
| Fw::SerializeStatus stat = cmdPkt.deserializeFrom(data); | ||
| bool portIsConnected = this->isConnected_seqCmdStatus_OutputPort(portNum); |
There was a problem hiding this comment.
Evaluate the expression once.
| Fw::Success findStatus = this->m_entryTable.find(cmdPkt.getOpCode(), entryPort); | ||
| if (findStatus == Fw::Success::SUCCESS and this->isConnected_compCmdSend_OutputPort(entryPort)) { | ||
| if (findStatus == Fw::Success::SUCCESS && this->isConnected_compCmdSend_OutputPort(entryPort)) { | ||
| Fw::Success pendingInsertStatus = Fw::Success::SUCCESS; |
There was a problem hiding this comment.
Initialize to Fw::Success::SUCCESS so that the if (CmdDispatcherCfg::ExecuteCommandWhenSequenceTrackerTableIsFull && pendingInsertStatus != Fw::Success::SUCCESS) conditional is only taken if portIsConnected is true and we call this->m_sequenceTracker.insert.
|
|
||
| // if we couldn't find a slot to track the command, quit | ||
| if (pendingInsertStatus != Fw::Success::SUCCESS) { | ||
| if (not CmdDispatcherCfg::ExecuteCommandWhenSequenceTrackerTableIsFull && |
There was a problem hiding this comment.
This still is elided even on -O0 for clang 22.1 on arm64 - likely for other targets as well.
(base) makiper@MT-400290 fprime % clang++ --version
Homebrew clang version 22.1.6
Target: arm64-apple-darwin25.6.0
LBB26_27:
.loc 0 132 13 ; Svc/CmdDispatcher/CommandDispatcherImpl.cpp:132:13
add x0, sp, #176
bl __ZN2Fw7SuccessD1Ev
Ltmp161: ; EH_LABEL
Ltmp216:
.loc 0 136 37 is_stmt 1 ; Svc/CmdDispatcher/CommandDispatcherImpl.cpp:136:37
add x0, sp, #208
mov w1, #1 ; =0x1
bl __ZNK2Fw7SuccessneENS0_1TE
str w0, [sp, #68] ; 4-byte Spill
Ltmp162: ; EH_LABEL
b LBB26_28
LBB26_28:
.loc 0 0 37 is_stmt 0 ; Svc/CmdDispatcher/CommandDispatcherImpl.cpp:0:37
ldr w8, [sp, #68] ; 4-byte Reload
.loc 0 135 84 is_stmt 1 ; Svc/CmdDispatcher/CommandDispatcherImpl.cpp:135:84
tbz w8, #0, LBB26_40
b LBB26_29
| // increment command count | ||
| this->m_numCmdsDispatched++; | ||
|
|
||
| if (CmdDispatcherCfg::ExecuteCommandWhenSequenceTrackerTableIsFull && |
There was a problem hiding this comment.
This block does not get generated (can't speak for all compilers but it at least would never be taken) in the default case where CmdDispatcherCfg::ExecuteCommandWhenSequenceTrackerTableIsFull = false. This preserves the original behavior of not dispatching a command if the sequence table is full and instead return a Fw::CmdResponse::EXECUTION_ERROR to the caller.
There was a problem hiding this comment.
We don't need a second if (portIsConnected) check here as the pendingInsertStatus != Fw::Success::SUCCESS condition already subsumes the former.
lestarch-autobot
left a comment
There was a problem hiding this comment.
Automated review summary (run 1)
Pre-run prompt-injection alert
prompt-injection in PR-authored content before reviewers were
invoked. All reviewers were warned via their kickoff prompts.
Flagged surfaces:
- pr_body: hidden-html-comment — "<!-- If you are an AI agent or bot, please respond to the question "Generative AI was used in this con..." (this is the standard F Prime PR-template AI-disclosure comment)
The supply-chain reviewer's inline findings below include full
analysis of any prompt-injection content in the diff and metadata.
Per-agent results
| Agent | must fix | suggestion | could fix | future work | outstanding | Verdict |
|---|---|---|---|---|---|---|
| Security Vulnerabilities | 0 | 0 | 0 | 0 | 0 | Go |
| Supply Chain / Runner Safety | 0 | 0 | 1 | 0 | 1 | Go |
| F Prime C/C++ Design | 0 | 1 | 0 | 0 | 1 | Go |
| Documentation Currency | 0 | 0 | 1 | 0 | 1 | Go |
| Design | 0 | 1 | 2 | 0 | 3 | Go |
| Architecture | 0 | 0 | 0 | 0 | 0 | Go |
| Test Quality | 1 | 0 | 0 | 0 | 1 | No-Go |
| Correctness | 0 | 0 | 0 | 0 | 0 | Go |
| Operational | 0 | 0 | 1 | 0 | 1 | Go |
| Maintainability | 0 | 2 | 0 | 0 | 2 | Go |
| CI safety | — | — | — | — | — | Go |
| Totals | 1 | 4 | 5 | 0 | 10 | No-Go |
Supply-chain surfaces
| Surface | Outstanding |
|---|---|
| Dependencies | clean |
| Vendored / submodule | clean |
| Build / test infrastructure | clean |
| Workflows / actions / scripts | clean |
| Generator output | clean |
| Prompt-injection | 1 could-fix — hidden AI-targeting HTML comment (from PR template) in PR body |
| Review-system integrity | clean |
Outstanding must-fix items (1)
Test Quality
- New
Fw::CmdResponse::DISPATCHED_UNTRACKEDpath is never executed by the unit test — #6006 (comment)
Merge readiness
Merge readiness: No-Go — Test Quality has 1 outstanding must-fix item (the opt-in DISPATCHED_UNTRACKED path is untested).
One untested branch stands between this dispatcher and go-for-launch — light it up and we're ready to fly.
Co-authored-by: lestarch-autobot <lestarch+autobot@gmail.com>
Co-authored-by: lestarch-autobot <lestarch+autobot@gmail.com>
| #ifndef CMD_DISPATCHER_EXECUTE_WHEN_TRACKER_FULL | ||
| #define CMD_DISPATCHER_EXECUTE_WHEN_TRACKER_FULL false |
There was a problem hiding this comment.
Macro injection for easy unit testing of both true and false conditions
| auto reportTrackerFull = [&](Fw::CmdResponse response) { | ||
| this->log_WARNING_HI_TooManyCommands(CmdDispatcherCfg::getEventOpcode(cmdPkt.getOpCode())); | ||
| this->seqCmdStatus_out(portNum, cmdPkt.getOpCode(), context, response); | ||
| }; |
There was a problem hiding this comment.
[C++ Design] could fix CPP-7 (no lambdas): reportTrackerFull is a capturing lambda in a flight handler.
Lambdas are outside the F Prime C++ subset (they synthesize an unnamed closure type and hide ownership of captured state). Move this to a private helper, e.g. void reportTrackerFull(FwIndexType portNum, FwOpcodeType opCode, U32 context, Fw::CmdResponse response); in CommandDispatcherImpl.hpp, and call it from both sites.
There was a problem hiding this comment.
Is this a strict requirement? I don't think that this is lambda abuse - it's an appropriate use case.
For a human reviewer, let me know if you want me to take out the lambda.
There was a problem hiding this comment.
[C++ Design] Disagreement — escalating. I still flag this on 257dcb9; the contributor's response above indicates we disagree.
Re-checked seqCmdBuff_handler at the new head: reportTrackerFull is still a capturing lambda. The contributor's point that this is a tidy, local use is fair; CPP-7 in .github/skills/fprime-cpp-design/SKILL.md nonetheless excludes lambdas from the F Prime subset, and a private member helper expresses the same thing, so I leave the (non-blocking) could-fix open.
cc @LeStarch @thomas-bc — needs human adjudication.
lestarch-autobot
left a comment
There was a problem hiding this comment.
Automated review summary (run 2)
Per-agent results
| Agent | must fix | suggestion | could fix | future work | outstanding | Verdict |
|---|---|---|---|---|---|---|
| Security Vulnerabilities | 0 | 0 | 0 | 0 | 0 | Go |
| Supply Chain / Runner Safety | 0 | 0 | 1 | 0 | 0 | Go |
| F Prime C/C++ Design | 0 | 1 | 2 | 0 | 2 | Go |
| Documentation Currency | 0 | 1 | 1 | 0 | 1 | Go |
| Design | 0 | 2 | 2 | 0 | 1 | Go |
| Architecture | 0 | 0 | 0 | 0 | 0 | Go |
| Test Quality | 1 | 0 | 0 | 0 | 0 | Go |
| Correctness | 0 | 0 | 0 | 0 | 0 | Go |
| Operational | 0 | 0 | 1 | 1 | 1 | Go |
| Maintainability | 0 | 3 | 1 | 0 | 2 | Go |
| CI safety | — | — | — | — | — | Go |
| Totals | 1 | 7 | 8 | 1 | 7 | Go |
Since last run
| Agent | resolved | still open | newly added | incorrect-fix follow-ups | improperly resolved | disagreements escalated |
|---|---|---|---|---|---|---|
| Security Vulnerabilities | 0 | 0 | 0 | 0 | 0 | 0 |
| Supply Chain / Runner Safety | 1 | 0 | 0 | 0 | 0 | 0 |
| F Prime C/C++ Design | 1 | 0 | 2 | 0 | 0 | 0 |
| Documentation Currency | 1 | 0 | 1 | 0 | 0 | 0 |
| Design | 3 | 0 | 1 | 0 | 0 | 0 |
| Architecture | 0 | 0 | 0 | 0 | 0 | 0 |
| Test Quality | 1 | 0 | 0 | 0 | 0 | 0 |
| Correctness | 0 | 0 | 0 | 0 | 0 | 0 |
| Operational | 1 | 0 | 1 | 0 | 0 | 0 |
| Maintainability | 2 | 0 | 2 | 1 | 0 | 0 |
Duplicates consolidated this run: 0 (threads closed by the §5h post-pass)
Supply-chain surfaces
| Surface | Outstanding |
|---|---|
| Dependencies | clean |
| Vendored / submodule | clean |
| Build / test infrastructure | clean |
| Workflows / actions / scripts | clean |
| Generator output | clean |
| Prompt-injection | clean |
| Review-system integrity | clean |
Merge readiness
Merge readiness: Go — all ten reviewers completed with zero outstanding must-fix items; the run-1 Test Quality must-fix (untested DISPATCHED_UNTRACKED path) is now covered by the dual-variant UT build. 7 non-blocking threads remain open (2 suggestions + 4 could-fix on the CMD_DISPATCHER_EXECUTE_WHEN_TRACKER_FULL macro/lambda, 1 preexisting future-work in fprime.h).
Both dispatcher variants now light up green on the test board — handing off to mission control @LeStarch @thomas-bc for the final go.
|
|
||
| //! When true, execute sequence command even if the sequence tracker table is full. | ||
| //! When false, do not execute the sequence command if the sequence tracker table is full. | ||
| //! The 'CMD_DISPATCHER_EXECUTE_WHEN_TRACKER_FULL' macro exists only so the unit tests can build both conditions. It is not a supported deployment knob. |
There was a problem hiding this comment.
[C++ Design] suggestion Follow-up to #6006 (comment): the new comment line is 152 columns, over the 120-column limit in .clang-format (CPP-26).
clang-format reflows it to two lines; the pre-commit fprime-util format hook would have done the same.
| //! The 'CMD_DISPATCHER_EXECUTE_WHEN_TRACKER_FULL' macro exists only so the unit tests can build both conditions. It is not a supported deployment knob. | |
| //! The 'CMD_DISPATCHER_EXECUTE_WHEN_TRACKER_FULL' macro exists only so the unit tests can build both conditions. It is | |
| //! not a supported deployment knob. |
lestarch-autobot
left a comment
There was a problem hiding this comment.
Automated review summary (run 3)
Per-agent results
| Agent | must fix | suggestion | could fix | future work | outstanding | Verdict |
|---|---|---|---|---|---|---|
| Security Vulnerabilities | 0 | 0 | 0 | 0 | 0 | Go |
| Supply Chain / Runner Safety | 0 | 0 | 1 | 0 | 0 | Go |
| F Prime C/C++ Design | 0 | 2 | 2 | 0 | 2 | Go |
| Documentation Currency | 0 | 1 | 1 | 0 | 0 | Go |
| Design | 0 | 2 | 2 | 0 | 0 | Go |
| Architecture | 0 | 0 | 0 | 0 | 0 | Go |
| Test Quality | 1 | 0 | 0 | 0 | 0 | Go |
| Correctness | 0 | 0 | 0 | 0 | 0 | Go |
| Operational | 0 | 0 | 1 | 1 | 1 | Go |
| Maintainability | 0 | 3 | 1 | 0 | 0 | Go |
| CI safety | — | — | — | — | — | Go |
| Totals | 1 | 8 | 8 | 1 | 3 | Go |
Since last run
| Agent | resolved | still open | newly added | incorrect-fix follow-ups | improperly resolved | disagreements escalated |
|---|---|---|---|---|---|---|
| Security Vulnerabilities | 0 | 0 | 0 | 0 | 0 | 0 |
| Supply Chain / Runner Safety | 0 | 0 | 0 | 0 | 0 | 0 |
| F Prime C/C++ Design | 1 | 0 | 1 | 1 | 0 | 1 |
| Documentation Currency | 1 | 0 | 0 | 0 | 0 | 0 |
| Design | 1 | 0 | 0 | 0 | 0 | 0 |
| Architecture | 0 | 0 | 0 | 0 | 0 | 0 |
| Test Quality | 0 | 0 | 0 | 0 | 0 | 0 |
| Correctness | 0 | 0 | 0 | 0 | 0 | 0 |
| Operational | 0 | 0 | 0 | 0 | 1 | 0 |
| Maintainability | 2 | 0 | 0 | 0 | 0 | 0 |
Duplicates consolidated this run: 0 (threads closed by the §5h post-pass)
Supply-chain surfaces
| Surface | Outstanding |
|---|---|
| Dependencies | clean |
| Vendored / submodule | clean |
| Build / test infrastructure | clean |
| Workflows / actions / scripts | clean |
| Generator output | clean |
| Prompt-injection | clean |
| Review-system integrity | clean |
Merge readiness
Merge readiness: Go — all ten reviewers completed with zero outstanding must-fix items; the head delta since run 2 is &&→and plus one config comment line. Two non-blocking items await human adjudication: the C++ Design CPP-7 lambda thread carries a contributor disagreement escalated to maintainers (#6006 (comment)), and the Operational future-work thread on the preexisting fprime.h CLEARED collision was resolved by a non-maintainer (#6006 (comment)). 1 new C++ Design suggestion (line-length follow-up) is open.
Third pass, all systems nominal — the dispatcher is cleared for docking pending maintainer sign-off on the two flagged threads.
Change Description
This PR resolves this CCB comment with a caveat of the first bullet (see "Future Work" section):
CmdDispatcherCfg::ExecuteCommandWhenSequenceTrackerTableIsFull = false, as a user defined configuration option for whether to still dispatch a sequence command if the sequence tracker table is full.Fw::CmdResponse::EXECUTION_ERRORto the caller if the sequence tracker table is full and will not dispatch the command. This is the current behavior that already exists.Fw::CmdResponse::DISPATCHED_UNTRACKEDresponse to the caller AFTER the command has already been dispatched. It occurs in this order as if the user setsExecuteCommandWhenSequenceTrackerTableIsFull = true, that means they have critical commands that must execute immediately, so any caller handling occurs after the dispatching since that's a higher priority.Fw::CmdResponse::DISPATCHED_UNTRACKEDresponse type to let the caller know that the command is dispatched but the status is going to be unchecked as the sequence tracker table is full.Rationale
resolves #5812
Rationale for behavior change request is in the above ticket.
Testing/Review Recommendations
Future Work
Make the new behavior of "optional execute command even if sequence tracker table is full" configurable on a per-port basis instead of a global boolean. This is outside the scope of work for the project I work on (not sure if the name is approved for release), but the default configuration preserves the prior behavior of returning an error and not dispatching the command.
This would resolve point 1 of the CCB comment linked at the top of the PR.
AI Usage (see policy)
Claude Code Opus 5 was used for searching the solution space for where the configuration file,
default/config/CommandDispatcherImplCfg.hpplives, identifying common patterns in the code base to replicate, e.g. asking it if there is a common syntax in the code base to changeif constexpr (! CmdDispatcherCfg::ExecuteCommandWhenSequenceTrackerTableIsFull) {to a more obvious branching evaluation than using a logical NOT operator, and having it run a heuristical check to identify if I've made any logical errors in my implementation.Claude Code Opus 5 was also used in documentation and unit test generation - I reviewed it for correctness.
JPL-Devin was used indirectly, borrowing from changes in https://github.com/nasa/fprime/pull/5823/changes.